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

Apply beacon system call to trace_block #12030

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
34 changes: 33 additions & 1 deletion crates/rpc/rpc/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ where
cfg: CfgEnvWithHandlerCfg,
block_env: BlockEnv,
opts: GethDebugTracingOptions,
parent_beacon_block_root: Option<B256>,
) -> Result<Vec<TraceResult>, Eth::Error> {
if transactions.is_empty() {
// nothing to trace
Expand All @@ -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() {
Expand Down Expand Up @@ -176,6 +197,7 @@ where
block
.body
.transactions
.clone()
.into_iter()
.map(|tx| {
tx.into_ecrecovered()
Expand All @@ -187,6 +209,7 @@ where
block
.body
.transactions
.clone()
.into_iter()
.map(|tx| {
tx.into_ecrecovered_unchecked()
Expand All @@ -196,7 +219,15 @@ where
.collect::<Result<Vec<_>, 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.
Expand Down Expand Up @@ -228,6 +259,7 @@ where
cfg,
block_env,
opts,
block.parent_beacon_block_root,
)
.await
}
Expand Down
Loading