chore: simplify SystemCaller setup (#12223)

This commit is contained in:
Matthias Seitz
2024-10-31 14:45:55 +01:00
committed by GitHub
parent 76c5aef911
commit 1f1dcc950d
2 changed files with 30 additions and 42 deletions

View File

@ -195,11 +195,7 @@ pub trait Trace: LoadState<Evm: ConfigureEvm<Header = Header>> {
let block_txs = block.transactions_with_sender();
// apply relevant system calls
let mut system_caller = SystemCaller::new(
this.evm_config().clone(),
RpcNodeCore::provider(&this).chain_spec(),
);
system_caller
SystemCaller::new(this.evm_config().clone(), this.provider().chain_spec())
.pre_block_beacon_root_contract_call(
&mut db,
&cfg,
@ -338,11 +334,7 @@ pub trait Trace: LoadState<Evm: ConfigureEvm<Header = Header>> {
CacheDB::new(StateProviderDatabase::new(StateProviderTraitObjWrapper(&state)));
// apply relevant system calls
let mut system_caller = SystemCaller::new(
this.evm_config().clone(),
RpcNodeCore::provider(&this).chain_spec(),
);
system_caller
SystemCaller::new(this.evm_config().clone(), this.provider().chain_spec())
.pre_block_beacon_root_contract_call(
&mut db,
&cfg,

View File

@ -113,24 +113,22 @@ where
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,
SystemCaller::new(
this.eth_api().evm_config().clone(),
this.eth_api().provider().chain_spec(),
)
.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(),
)
.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;
@ -296,23 +294,21 @@ where
let mut db = CacheDB::new(StateProviderDatabase::new(state));
// apply relevant system calls
let mut system_caller = SystemCaller::new(
RpcNodeCore::evm_config(this.eth_api()).clone(),
RpcNodeCore::provider(this.eth_api()).chain_spec(),
);
system_caller
.pre_block_beacon_root_contract_call(
&mut db,
&cfg,
&block_env,
parent_beacon_block_root,
SystemCaller::new(
this.eth_api().evm_config().clone(),
this.eth_api().provider().chain_spec(),
)
.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(),
)
.map_err(|_| {
EthApiError::EvmCustom(
"failed to apply 4788 beacon root system call".to_string(),
)
})?;
})?;
// replay all transactions prior to the targeted transaction
let index = this.eth_api().replay_transactions_until(