feat: wire SystemCaller (#11321)

This commit is contained in:
Federico Gimenez
2024-09-30 17:59:55 +02:00
committed by GitHub
parent 09f0526e70
commit 6d57b9eaac
12 changed files with 99 additions and 431 deletions

View File

@ -6,10 +6,7 @@ use eyre::OptionExt;
use pretty_assertions::Comparison;
use reth_chainspec::{EthChainSpec, EthereumHardforks};
use reth_engine_primitives::InvalidBlockHook;
use reth_evm::{
system_calls::{apply_beacon_root_contract_call, apply_blockhashes_contract_call},
ConfigureEvm,
};
use reth_evm::{system_calls::SystemCaller, ConfigureEvm};
use reth_primitives::{Header, Receipt, SealedBlockWithSenders, SealedHeader};
use reth_provider::{BlockExecutionOutput, ChainSpecProvider, StateProviderFactory};
use reth_revm::{
@ -87,23 +84,10 @@ where
EnvWithHandlerCfg::new_with_cfg_env(cfg, block_env, Default::default()),
);
let mut system_caller = SystemCaller::new(&self.evm_config, self.provider.chain_spec());
// Apply pre-block system contract calls.
apply_beacon_root_contract_call(
&self.evm_config,
self.provider.chain_spec().as_ref(),
block.timestamp,
block.number,
block.parent_beacon_block_root,
&mut evm,
)?;
apply_blockhashes_contract_call(
&self.evm_config,
&self.provider.chain_spec(),
block.timestamp,
block.number,
block.parent_hash,
&mut evm,
)?;
system_caller.apply_pre_execution_changes(&block.clone().unseal(), &mut evm)?;
// Re-execute all of the transactions in the block to load all touched accounts into
// the cache DB.