mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: move pre_block_beacon_root_contract_call to evm crates (#9244)
This commit is contained in:
@ -25,8 +25,7 @@ use reth_provider::{
|
||||
BlockReaderIdExt, BlockSource, CanonStateNotification, ProviderError, StateProviderFactory,
|
||||
};
|
||||
use reth_revm::state_change::{
|
||||
apply_beacon_root_contract_call, apply_withdrawal_requests_contract_call,
|
||||
post_block_withdrawals_balance_increments,
|
||||
apply_withdrawal_requests_contract_call, post_block_withdrawals_balance_increments,
|
||||
};
|
||||
use reth_tasks::TaskSpawner;
|
||||
use reth_transaction_pool::TransactionPool;
|
||||
@ -923,49 +922,6 @@ pub fn commit_withdrawals<DB: Database<Error = ProviderError>>(
|
||||
})
|
||||
}
|
||||
|
||||
/// Apply the [EIP-4788](https://eips.ethereum.org/EIPS/eip-4788) pre block contract call.
|
||||
///
|
||||
/// This constructs a new [Evm] with the given DB, and environment
|
||||
/// ([`CfgEnvWithHandlerCfg`] and [`BlockEnv`]) to execute the pre block contract call.
|
||||
///
|
||||
/// The parent beacon block root used for the call is gathered from the given
|
||||
/// [`PayloadBuilderAttributes`].
|
||||
///
|
||||
/// This uses [`apply_beacon_root_contract_call`] to ultimately apply the beacon root contract state
|
||||
/// change.
|
||||
pub fn pre_block_beacon_root_contract_call<DB: Database + DatabaseCommit, Attributes>(
|
||||
db: &mut DB,
|
||||
chain_spec: &ChainSpec,
|
||||
block_number: u64,
|
||||
initialized_cfg: &CfgEnvWithHandlerCfg,
|
||||
initialized_block_env: &BlockEnv,
|
||||
attributes: &Attributes,
|
||||
) -> Result<(), PayloadBuilderError>
|
||||
where
|
||||
DB::Error: std::fmt::Display,
|
||||
Attributes: PayloadBuilderAttributes,
|
||||
{
|
||||
// apply pre-block EIP-4788 contract call
|
||||
let mut evm_pre_block = Evm::builder()
|
||||
.with_db(db)
|
||||
.with_env_with_handler_cfg(EnvWithHandlerCfg::new_with_cfg_env(
|
||||
initialized_cfg.clone(),
|
||||
initialized_block_env.clone(),
|
||||
Default::default(),
|
||||
))
|
||||
.build();
|
||||
|
||||
// initialize a block from the env, because the pre block call needs the block itself
|
||||
apply_beacon_root_contract_call(
|
||||
chain_spec,
|
||||
attributes.timestamp(),
|
||||
block_number,
|
||||
attributes.parent_beacon_block_root(),
|
||||
&mut evm_pre_block,
|
||||
)
|
||||
.map_err(|err| PayloadBuilderError::Internal(err.into()))
|
||||
}
|
||||
|
||||
/// Apply the [EIP-7002](https://eips.ethereum.org/EIPS/eip-7002) post block contract call.
|
||||
///
|
||||
/// This constructs a new [Evm] with the given DB, and environment
|
||||
|
||||
Reference in New Issue
Block a user