mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
renamed OptimismEvmConfig to OpEvmConfig (#12284)
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
//! Optimism block execution strategy.
|
//! Optimism block execution strategy.
|
||||||
|
|
||||||
use crate::{l1::ensure_create2_deployer, OptimismBlockExecutionError, OptimismEvmConfig};
|
use crate::{l1::ensure_create2_deployer, OpEvmConfig, OptimismBlockExecutionError};
|
||||||
use alloc::{boxed::Box, sync::Arc, vec::Vec};
|
use alloc::{boxed::Box, sync::Arc, vec::Vec};
|
||||||
use alloy_consensus::Transaction as _;
|
use alloy_consensus::Transaction as _;
|
||||||
use alloy_eips::eip7685::Requests;
|
use alloy_eips::eip7685::Requests;
|
||||||
@ -29,7 +29,7 @@ use tracing::trace;
|
|||||||
|
|
||||||
/// Factory for [`OpExecutionStrategy`].
|
/// Factory for [`OpExecutionStrategy`].
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct OpExecutionStrategyFactory<EvmConfig = OptimismEvmConfig> {
|
pub struct OpExecutionStrategyFactory<EvmConfig = OpEvmConfig> {
|
||||||
/// The chainspec
|
/// The chainspec
|
||||||
chain_spec: Arc<OpChainSpec>,
|
chain_spec: Arc<OpChainSpec>,
|
||||||
/// How to create an EVM.
|
/// How to create an EVM.
|
||||||
@ -39,7 +39,7 @@ pub struct OpExecutionStrategyFactory<EvmConfig = OptimismEvmConfig> {
|
|||||||
impl OpExecutionStrategyFactory {
|
impl OpExecutionStrategyFactory {
|
||||||
/// Creates a new default optimism executor strategy factory.
|
/// Creates a new default optimism executor strategy factory.
|
||||||
pub fn optimism(chain_spec: Arc<OpChainSpec>) -> Self {
|
pub fn optimism(chain_spec: Arc<OpChainSpec>) -> Self {
|
||||||
Self::new(chain_spec.clone(), OptimismEvmConfig::new(chain_spec))
|
Self::new(chain_spec.clone(), OpEvmConfig::new(chain_spec))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,7 +339,7 @@ mod tests {
|
|||||||
chain_spec: Arc<OpChainSpec>,
|
chain_spec: Arc<OpChainSpec>,
|
||||||
) -> BasicBlockExecutorProvider<OpExecutionStrategyFactory> {
|
) -> BasicBlockExecutorProvider<OpExecutionStrategyFactory> {
|
||||||
let strategy_factory =
|
let strategy_factory =
|
||||||
OpExecutionStrategyFactory::new(chain_spec.clone(), OptimismEvmConfig::new(chain_spec));
|
OpExecutionStrategyFactory::new(chain_spec.clone(), OpEvmConfig::new(chain_spec));
|
||||||
|
|
||||||
BasicBlockExecutorProvider::new(strategy_factory)
|
BasicBlockExecutorProvider::new(strategy_factory)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,12 +38,12 @@ use revm_primitives::{
|
|||||||
|
|
||||||
/// Optimism-related EVM configuration.
|
/// Optimism-related EVM configuration.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct OptimismEvmConfig {
|
pub struct OpEvmConfig {
|
||||||
chain_spec: Arc<OpChainSpec>,
|
chain_spec: Arc<OpChainSpec>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OptimismEvmConfig {
|
impl OpEvmConfig {
|
||||||
/// Creates a new [`OptimismEvmConfig`] with the given chain spec.
|
/// Creates a new [`OpEvmConfig`] with the given chain spec.
|
||||||
pub const fn new(chain_spec: Arc<OpChainSpec>) -> Self {
|
pub const fn new(chain_spec: Arc<OpChainSpec>) -> Self {
|
||||||
Self { chain_spec }
|
Self { chain_spec }
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ impl OptimismEvmConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConfigureEvmEnv for OptimismEvmConfig {
|
impl ConfigureEvmEnv for OpEvmConfig {
|
||||||
type Header = Header;
|
type Header = Header;
|
||||||
type Error = DecodeError;
|
type Error = DecodeError;
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ impl ConfigureEvmEnv for OptimismEvmConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConfigureEvm for OptimismEvmConfig {
|
impl ConfigureEvm for OpEvmConfig {
|
||||||
type DefaultExternalContext<'a> = ();
|
type DefaultExternalContext<'a> = ();
|
||||||
|
|
||||||
fn evm<DB: Database>(&self, db: DB) -> Evm<'_, Self::DefaultExternalContext<'_>, DB> {
|
fn evm<DB: Database>(&self, db: DB) -> Evm<'_, Self::DefaultExternalContext<'_>, DB> {
|
||||||
@ -226,8 +226,8 @@ mod tests {
|
|||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn test_evm_config() -> OptimismEvmConfig {
|
fn test_evm_config() -> OpEvmConfig {
|
||||||
OptimismEvmConfig::new(BASE_MAINNET.clone())
|
OpEvmConfig::new(BASE_MAINNET.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -254,9 +254,9 @@ mod tests {
|
|||||||
// Define the total difficulty as zero (default)
|
// Define the total difficulty as zero (default)
|
||||||
let total_difficulty = U256::ZERO;
|
let total_difficulty = U256::ZERO;
|
||||||
|
|
||||||
// Use the `OptimismEvmConfig` to fill the `cfg_env` and `block_env` based on the ChainSpec,
|
// Use the `OpEvmConfig` to fill the `cfg_env` and `block_env` based on the ChainSpec,
|
||||||
// Header, and total difficulty
|
// Header, and total difficulty
|
||||||
OptimismEvmConfig::new(Arc::new(OpChainSpec { inner: chain_spec.clone() }))
|
OpEvmConfig::new(Arc::new(OpChainSpec { inner: chain_spec.clone() }))
|
||||||
.fill_cfg_and_block_env(&mut cfg_env, &mut block_env, &header, total_difficulty);
|
.fill_cfg_and_block_env(&mut cfg_env, &mut block_env, &header, total_difficulty);
|
||||||
|
|
||||||
// Assert that the chain ID in the `cfg_env` is correctly set to the chain ID of the
|
// Assert that the chain ID in the `cfg_env` is correctly set to the chain ID of the
|
||||||
@ -266,7 +266,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_evm_configure() {
|
fn test_evm_configure() {
|
||||||
// Create a default `OptimismEvmConfig`
|
// Create a default `OpEvmConfig`
|
||||||
let evm_config = test_evm_config();
|
let evm_config = test_evm_config();
|
||||||
|
|
||||||
// Initialize an empty database wrapped in CacheDB
|
// Initialize an empty database wrapped in CacheDB
|
||||||
|
|||||||
@ -20,7 +20,7 @@ use reth_node_builder::{
|
|||||||
};
|
};
|
||||||
use reth_optimism_chainspec::OpChainSpec;
|
use reth_optimism_chainspec::OpChainSpec;
|
||||||
use reth_optimism_consensus::OpBeaconConsensus;
|
use reth_optimism_consensus::OpBeaconConsensus;
|
||||||
use reth_optimism_evm::{OpExecutionStrategyFactory, OptimismEvmConfig};
|
use reth_optimism_evm::{OpEvmConfig, OpExecutionStrategyFactory};
|
||||||
use reth_optimism_rpc::OpEthApi;
|
use reth_optimism_rpc::OpEthApi;
|
||||||
use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService};
|
use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService};
|
||||||
use reth_primitives::{Block, Header};
|
use reth_primitives::{Block, Header};
|
||||||
@ -185,14 +185,14 @@ impl<Node> ExecutorBuilder<Node> for OpExecutorBuilder
|
|||||||
where
|
where
|
||||||
Node: FullNodeTypes<Types: NodeTypes<ChainSpec = OpChainSpec>>,
|
Node: FullNodeTypes<Types: NodeTypes<ChainSpec = OpChainSpec>>,
|
||||||
{
|
{
|
||||||
type EVM = OptimismEvmConfig;
|
type EVM = OpEvmConfig;
|
||||||
type Executor = BasicBlockExecutorProvider<OpExecutionStrategyFactory>;
|
type Executor = BasicBlockExecutorProvider<OpExecutionStrategyFactory>;
|
||||||
|
|
||||||
async fn build_evm(
|
async fn build_evm(
|
||||||
self,
|
self,
|
||||||
ctx: &BuilderContext<Node>,
|
ctx: &BuilderContext<Node>,
|
||||||
) -> eyre::Result<(Self::EVM, Self::Executor)> {
|
) -> eyre::Result<(Self::EVM, Self::Executor)> {
|
||||||
let evm_config = OptimismEvmConfig::new(ctx.chain_spec());
|
let evm_config = OpEvmConfig::new(ctx.chain_spec());
|
||||||
let strategy_factory =
|
let strategy_factory =
|
||||||
OpExecutionStrategyFactory::new(ctx.chain_spec(), evm_config.clone());
|
OpExecutionStrategyFactory::new(ctx.chain_spec(), evm_config.clone());
|
||||||
let executor = BasicBlockExecutorProvider::new(strategy_factory);
|
let executor = BasicBlockExecutorProvider::new(strategy_factory);
|
||||||
@ -359,7 +359,7 @@ where
|
|||||||
ctx: &BuilderContext<Node>,
|
ctx: &BuilderContext<Node>,
|
||||||
pool: Pool,
|
pool: Pool,
|
||||||
) -> eyre::Result<PayloadBuilderHandle<OptimismEngineTypes>> {
|
) -> eyre::Result<PayloadBuilderHandle<OptimismEngineTypes>> {
|
||||||
self.spawn(OptimismEvmConfig::new(ctx.chain_spec()), ctx, pool)
|
self.spawn(OpEvmConfig::new(ctx.chain_spec()), ctx, pool)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user