-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathexecutor.rs
More file actions
63 lines (53 loc) · 2.11 KB
/
Copy pathexecutor.rs
File metadata and controls
63 lines (53 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//! Helpers to build the ev-reth executor with EV-specific hooks applied.
use alloy_evm::eth::{spec::EthExecutorSpec, EthEvmFactory};
use ev_revm::{with_ev_handler, BaseFeeRedirect, EvEvmFactory};
use reth_chainspec::ChainSpec;
use reth_ethereum::{
chainspec::EthereumHardforks,
evm::EthEvmConfig,
node::{
api::FullNodeTypes,
builder::{components::ExecutorBuilder as RethExecutorBuilder, BuilderContext},
},
};
use reth_ethereum_forks::Hardforks;
use reth_node_builder::PayloadBuilderConfig;
use tracing::info;
use crate::{config::EvolvePayloadBuilderConfig, EvolveNode};
/// Type alias for the EV-aware EVM config we install into the node.
pub type EvolveEvmConfig = EthEvmConfig<ChainSpec, EvEvmFactory<EthEvmFactory>>;
/// Builds the EV-aware EVM configuration by wrapping the default config with the EV handler.
pub fn build_evm_config<Node>(ctx: &BuilderContext<Node>) -> eyre::Result<EvolveEvmConfig>
where
Node: FullNodeTypes<Types = EvolveNode>,
ChainSpec: Hardforks + EthExecutorSpec + EthereumHardforks,
{
let chain_spec = ctx.chain_spec();
let base_config = EthEvmConfig::new(chain_spec.clone())
.with_extra_data(ctx.payload_builder_config().extra_data_bytes());
let evolve_config = EvolvePayloadBuilderConfig::from_chain_spec(chain_spec.as_ref())?;
evolve_config.validate()?;
let redirect = evolve_config.base_fee_sink.map(|sink| {
info!(
target = "ev-reth::executor",
fee_sink = ?sink,
"Base fee redirect enabled"
);
BaseFeeRedirect::new(sink)
});
Ok(with_ev_handler(base_config, redirect))
}
/// Thin wrapper so we can plug the EV executor into the node components builder.
#[derive(Debug, Default, Clone, Copy)]
#[non_exhaustive]
pub struct EvolveExecutorBuilder;
impl<Node> RethExecutorBuilder<Node> for EvolveExecutorBuilder
where
Node: FullNodeTypes<Types = EvolveNode>,
ChainSpec: Hardforks + EthExecutorSpec + EthereumHardforks,
{
type EVM = EvolveEvmConfig;
async fn build_evm(self, ctx: &BuilderContext<Node>) -> eyre::Result<Self::EVM> {
build_evm_config(ctx)
}
}