refactor: simplify SystemCaller API (#14578)

This commit is contained in:
Arsenii Kulikov
2025-02-19 14:08:49 +04:00
committed by GitHub
parent 849c04cb34
commit e92cf35ac9
11 changed files with 81 additions and 217 deletions

View File

@ -90,7 +90,7 @@ where
/// Current state for block execution.
state: State<DB>,
/// Utility to call system smart contracts.
system_caller: SystemCaller<EvmConfig, ChainSpec>,
system_caller: SystemCaller<Arc<ChainSpec>>,
}
impl<DB, EvmConfig> EthExecutionStrategy<DB, EvmConfig>
@ -99,7 +99,7 @@ where
{
/// Creates a new [`EthExecutionStrategy`]
pub fn new(state: State<DB>, chain_spec: Arc<ChainSpec>, evm_config: EvmConfig) -> Self {
let system_caller = SystemCaller::new(evm_config.clone(), chain_spec.clone());
let system_caller = SystemCaller::new(chain_spec.clone());
Self { state, chain_spec, evm_config, system_caller }
}
}

View File

@ -202,11 +202,12 @@ where
let block_number = evm_env.block_env.number;
let beneficiary = evm_env.block_env.beneficiary;
let mut system_caller = SystemCaller::new(evm_config.clone(), chain_spec.clone());
let mut evm = evm_config.evm_with_env(&mut db, evm_env);
let mut system_caller = SystemCaller::new(chain_spec.clone());
// apply eip-4788 pre block contract call
system_caller
.pre_block_beacon_root_contract_call(&mut db, &evm_env, attributes.parent_beacon_block_root)
.apply_beacon_root_contract_call(attributes.parent_beacon_block_root, &mut evm)
.map_err(|err| {
warn!(target: "payload_builder",
parent_hash=%parent_header.hash(),
@ -217,18 +218,15 @@ where
})?;
// apply eip-2935 blockhashes update
system_caller.pre_block_blockhashes_contract_call(
&mut db,
&evm_env,
system_caller.apply_blockhashes_contract_call(
parent_header.hash(),
&mut evm,
)
.map_err(|err| {
warn!(target: "payload_builder", parent_hash=%parent_header.hash(), %err, "failed to update parent header blockhashes for payload");
PayloadBuilderError::Internal(err.into())
})?;
let mut evm = evm_config.evm_with_env(&mut db, evm_env);
let mut receipts = Vec::new();
let mut block_blob_count = 0;
let blob_params = chain_spec.blob_params_at_timestamp(attributes.timestamp);