From 8d488f59823c13111e67c8278d06b20b206e88dd Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 27 Mar 2024 23:53:27 +0100 Subject: [PATCH] fix: eth_callMany pending tag (#7351) --- crates/rpc/rpc/src/eth/api/call.rs | 7 +++++-- crates/rpc/rpc/src/eth/api/mod.rs | 5 ----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/crates/rpc/rpc/src/eth/api/call.rs b/crates/rpc/rpc/src/eth/api/call.rs index 675ef3aa59..a94ae0fd05 100644 --- a/crates/rpc/rpc/src/eth/api/call.rs +++ b/crates/rpc/rpc/src/eth/api/call.rs @@ -99,6 +99,7 @@ where let transaction_index = transaction_index.unwrap_or_default(); let target_block = block_number.unwrap_or(BlockId::Number(BlockNumberOrTag::Latest)); + let is_block_target_pending = target_block.is_pending(); let ((cfg, block_env, _), block) = futures::try_join!( self.evm_env_at(target_block), @@ -113,9 +114,11 @@ where let mut at = block.parent_hash; let mut replay_block_txs = true; - // but if all transactions are to be replayed, we can use the state at the block itself let num_txs = transaction_index.index().unwrap_or(block.body.len()); - if num_txs == block.body.len() { + // but if all transactions are to be replayed, we can use the state at the block itself, + // however only if we're not targeting the pending block, because for pending we can't rely + // on the block's state being available + if !is_block_target_pending && num_txs == block.body.len() { at = block.hash(); replay_block_txs = false; } diff --git a/crates/rpc/rpc/src/eth/api/mod.rs b/crates/rpc/rpc/src/eth/api/mod.rs index 43d7f0d30b..2828cef004 100644 --- a/crates/rpc/rpc/src/eth/api/mod.rs +++ b/crates/rpc/rpc/src/eth/api/mod.rs @@ -337,11 +337,6 @@ where } } - // if we're currently syncing, we're unable to build a pending block - if this.network().is_syncing() { - return Ok(None) - } - // we rebuild the block let pending_block = match pending.build_block(this.provider(), this.pool()) { Ok(block) => block,