mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: move withdrawal_requests_contract_call to reth-evm (#9272)
This commit is contained in:
@ -19,19 +19,17 @@ use reth_payload_builder::{
|
||||
use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes};
|
||||
use reth_primitives::{
|
||||
constants::{EMPTY_WITHDRAWALS, RETH_CLIENT_VERSION, SLOT_DURATION},
|
||||
proofs, BlockNumberOrTag, Bytes, Request, SealedBlock, Withdrawals, B256, U256,
|
||||
proofs, BlockNumberOrTag, Bytes, SealedBlock, Withdrawals, B256, U256,
|
||||
};
|
||||
use reth_provider::{
|
||||
BlockReaderIdExt, BlockSource, CanonStateNotification, ProviderError, StateProviderFactory,
|
||||
};
|
||||
use reth_revm::state_change::{
|
||||
apply_withdrawal_requests_contract_call, post_block_withdrawals_balance_increments,
|
||||
};
|
||||
use reth_revm::state_change::post_block_withdrawals_balance_increments;
|
||||
use reth_tasks::TaskSpawner;
|
||||
use reth_transaction_pool::TransactionPool;
|
||||
use revm::{
|
||||
primitives::{BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg},
|
||||
Database, DatabaseCommit, Evm, State,
|
||||
primitives::{BlockEnv, CfgEnvWithHandlerCfg},
|
||||
Database, State,
|
||||
};
|
||||
use std::{
|
||||
fmt,
|
||||
@ -922,36 +920,6 @@ pub fn commit_withdrawals<DB: Database<Error = ProviderError>>(
|
||||
})
|
||||
}
|
||||
|
||||
/// 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
|
||||
/// ([`CfgEnvWithHandlerCfg`] and [`BlockEnv`]) to execute the post block contract call.
|
||||
///
|
||||
/// This uses [`apply_withdrawal_requests_contract_call`] to ultimately calculate the
|
||||
/// [requests](Request).
|
||||
pub fn post_block_withdrawal_requests_contract_call<DB: Database + DatabaseCommit>(
|
||||
db: &mut DB,
|
||||
initialized_cfg: &CfgEnvWithHandlerCfg,
|
||||
initialized_block_env: &BlockEnv,
|
||||
) -> Result<Vec<Request>, PayloadBuilderError>
|
||||
where
|
||||
DB::Error: std::fmt::Display,
|
||||
{
|
||||
// apply post-block EIP-7002 contract call
|
||||
let mut evm_post_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 post block call needs the block itself
|
||||
apply_withdrawal_requests_contract_call(&mut evm_post_block)
|
||||
.map_err(|err| PayloadBuilderError::Internal(err.into()))
|
||||
}
|
||||
|
||||
/// Checks if the new payload is better than the current best.
|
||||
///
|
||||
/// This compares the total fees of the blocks, higher is better.
|
||||
|
||||
Reference in New Issue
Block a user