Skip to content

Commit

Permalink
chore(rpc): use block_hash as BlockId on eth_callMany (paradigm…
Browse files Browse the repository at this point in the history
  • Loading branch information
joshieDo authored and ebo committed Oct 14, 2024
1 parent c25cc57 commit a383537
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions crates/rpc/rpc-eth-api/src/helpers/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use reth_primitives::{
},
Header, TransactionSignedEcRecovered,
};
use reth_provider::{ChainSpecProvider, HeaderProvider, StateProvider};
use reth_provider::{BlockIdReader, ChainSpecProvider, HeaderProvider, StateProvider};
use reth_revm::{database::StateProviderDatabase, db::CacheDB, DatabaseRef};
use reth_rpc_eth_types::{
cache::db::{StateCacheDbRefMutWrapper, StateProviderTraitObjWrapper},
Expand Down Expand Up @@ -247,9 +247,19 @@ pub trait EthCall: Call + LoadPendingBlock {
state_context.unwrap_or_default();
let transaction_index = transaction_index.unwrap_or_default();

let target_block = block_number.unwrap_or_default();
let mut target_block = block_number.unwrap_or_default();
let is_block_target_pending = target_block.is_pending();

// if it's not pending, we should always use block_hash over block_number to ensure that
// different provider calls query data related to the same block.
if !is_block_target_pending {
target_block = LoadBlock::provider(self)
.block_hash_for_id(target_block)
.map_err(|_| EthApiError::HeaderNotFound(target_block))?
.ok_or_else(|| EthApiError::HeaderNotFound(target_block))?
.into();
}

let ((cfg, block_env, _), block) = futures::try_join!(
self.evm_env_at(target_block),
self.block_with_senders(target_block)
Expand Down

0 comments on commit a383537

Please sign in to comment.