diff --git a/crates/rpc/rpc/src/debug.rs b/crates/rpc/rpc/src/debug.rs index dd1cd9739ed1..9551647d5aef 100644 --- a/crates/rpc/rpc/src/debug.rs +++ b/crates/rpc/rpc/src/debug.rs @@ -98,6 +98,7 @@ where cfg: CfgEnvWithHandlerCfg, block_env: BlockEnv, opts: GethDebugTracingOptions, + parent_beacon_block_root: Option, ) -> Result, Eth::Error> { if transactions.is_empty() { // nothing to trace @@ -111,6 +112,26 @@ where let block_hash = at.as_block_hash(); let mut results = Vec::with_capacity(transactions.len()); let mut db = CacheDB::new(StateProviderDatabase::new(state)); + + let mut system_caller = SystemCaller::new( + RpcNodeCore::evm_config(this.eth_api()).clone(), + RpcNodeCore::provider(this.eth_api()).chain_spec(), + ); + + // apply relevant system calls + system_caller + .pre_block_beacon_root_contract_call( + &mut db, + &cfg, + &block_env, + parent_beacon_block_root, + ) + .map_err(|_| { + EthApiError::EvmCustom( + "failed to apply 4788 beacon root system call".to_string(), + ) + })?; + let mut transactions = transactions.into_iter().enumerate().peekable(); let mut inspector = None; while let Some((index, tx)) = transactions.next() { @@ -176,6 +197,7 @@ where block .body .transactions + .clone() .into_iter() .map(|tx| { tx.into_ecrecovered() @@ -187,6 +209,7 @@ where block .body .transactions + .clone() .into_iter() .map(|tx| { tx.into_ecrecovered_unchecked() @@ -196,7 +219,15 @@ where .collect::, Eth::Error>>()? }; - self.trace_block(parent.into(), transactions, cfg, block_env, opts).await + self.trace_block( + parent.into(), + transactions, + cfg, + block_env, + opts, + block.parent_beacon_block_root, + ) + .await } /// Replays a block and returns the trace of each transaction. @@ -228,6 +259,7 @@ where cfg, block_env, opts, + block.parent_beacon_block_root, ) .await }