Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(rpc): use block_hash as BlockId on eth_callMany #11595

Merged
merged 4 commits into from
Oct 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading