Skip to content

Commit 90c7255

Browse files
Explicitly specify Latest block for RPC calls (#81)
1 parent 2ccb3d4 commit 90c7255

File tree

2 files changed

+34
-11
lines changed

2 files changed

+34
-11
lines changed

executors/src/eoa/worker/transaction.rs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use alloy::{
44
consensus::{
55
SignableTransaction, Signed, TxEip4844Variant, TxEip4844WithSidecar, TypedTransaction,
66
},
7+
eips::BlockNumberOrTag,
78
network::{TransactionBuilder, TransactionBuilder7702},
89
primitives::{Bytes, U256},
910
providers::Provider,
@@ -20,11 +21,16 @@ use engine_core::{
2021
};
2122

2223
use crate::eoa::{
24+
EoaTransactionRequest,
2325
store::{
2426
BorrowedTransaction, BorrowedTransactionData, PendingTransaction, SubmittedNoopTransaction,
25-
}, worker::{
26-
error::{is_retryable_preparation_error, is_unsupported_eip1559_error, EoaExecutorWorkerError}, EoaExecutorWorker
27-
}, EoaTransactionRequest
27+
},
28+
worker::{
29+
EoaExecutorWorker,
30+
error::{
31+
EoaExecutorWorkerError, is_retryable_preparation_error, is_unsupported_eip1559_error,
32+
},
33+
},
2834
};
2935

3036
// Retry constants for preparation phase
@@ -303,7 +309,13 @@ impl<C: Chain> EoaExecutorWorker<C> {
303309

304310
// Estimate gas if needed
305311
if tx_request.gas.is_none() {
306-
match self.chain.provider().estimate_gas(tx_request.clone()).await {
312+
match self
313+
.chain
314+
.provider()
315+
.estimate_gas(tx_request.clone())
316+
.block(BlockNumberOrTag::Latest.into())
317+
.await
318+
{
307319
Ok(gas_limit) => {
308320
tx_request = tx_request.with_gas_limit(gas_limit * 110 / 100); // 10% buffer
309321
}
@@ -397,10 +409,13 @@ impl<C: Chain> EoaExecutorWorker<C> {
397409
nonce: u64,
398410
) -> Result<Signed<TypedTransaction>, EoaExecutorWorkerError> {
399411
let typed_tx = self.build_typed_transaction(request, nonce).await?;
400-
412+
401413
// Inject KMS cache into the signing credential (after deserialization from Redis)
402-
let credential_with_cache = request.signing_credential.clone().with_aws_kms_cache(&self.kms_client_cache);
403-
414+
let credential_with_cache = request
415+
.signing_credential
416+
.clone()
417+
.with_aws_kms_cache(&self.kms_client_cache);
418+
404419
self.sign_transaction(typed_tx, &credential_with_cache)
405420
.await
406421
}

server/src/http/routes/contract_read.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,11 @@ async fn execute_direct_contract_calls<C: engine_core::chain::Chain>(
454454
call_request = call_request.from(*from_address);
455455
}
456456

457-
match provider.call(call_request).await {
457+
match provider
458+
.call(call_request)
459+
.block(BlockNumberOrTag::Latest.into())
460+
.await
461+
{
458462
Ok(result) => {
459463
// Decode the result
460464
match prepared_call.function.abi_decode_output(&result) {
@@ -511,9 +515,13 @@ async fn execute_multicall(
511515
.to(*multicall_address)
512516
.input(multicall_call.abi_encode().into());
513517

514-
let result = provider.call(call_request).await.map_err(|e| {
515-
EngineError::contract_multicall_error(chain_id, format!("Multicall failed: {e}"))
516-
})?;
518+
let result = provider
519+
.call(call_request)
520+
.block(BlockNumberOrTag::Latest.into())
521+
.await
522+
.map_err(|e| {
523+
EngineError::contract_multicall_error(chain_id, format!("Multicall failed: {e}"))
524+
})?;
517525

518526
let decoded = aggregate3Call::abi_decode_returns(&result).map_err(|e| {
519527
EngineError::contract_multicall_error(

0 commit comments

Comments
 (0)