From d8b7f6014f90c86afc0415b0200929752a415a63 Mon Sep 17 00:00:00 2001 From: Francis Li Date: Fri, 11 Oct 2024 10:55:22 -0700 Subject: [PATCH] fix(rpc): add missing codes for witness (#11673) --- crates/rpc/rpc/src/debug.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/crates/rpc/rpc/src/debug.rs b/crates/rpc/rpc/src/debug.rs index b26459c4f0..738b91ad0e 100644 --- a/crates/rpc/rpc/src/debug.rs +++ b/crates/rpc/rpc/src/debug.rs @@ -34,7 +34,7 @@ use reth_rpc_server_types::{result::internal_rpc_err, ToRpcResult}; use reth_tasks::pool::BlockingTaskGuard; use reth_trie::{HashedPostState, HashedStorage}; use revm::{ - db::CacheDB, + db::{CacheDB, State}, primitives::{db::DatabaseCommit, BlockEnv, CfgEnvWithHandlerCfg, Env, EnvWithHandlerCfg}, }; use revm_inspectors::tracing::{ @@ -614,12 +614,23 @@ where let _ = block_executor .execute_with_state_closure( (&block.clone().unseal(), block.difficulty).into(), - |statedb| { + |statedb: &State<_>| { codes = statedb .cache .contracts .iter() .map(|(hash, code)| (*hash, code.original_bytes())) + .chain( + // cache state does not have all the contracts, especially when + // a contract is created within the block + // the contract only exists in bundle state, therefore we need + // to include them as well + statedb + .bundle_state + .contracts + .iter() + .map(|(hash, code)| (*hash, code.original_bytes())), + ) .collect(); for (address, account) in &statedb.cache.accounts {