mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: use OpChainSpec in OptimismNode and its components (#11304)
This commit is contained in:
@ -32,23 +32,20 @@ use tracing::trace;
|
||||
/// Provides executors to execute regular optimism blocks
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct OpExecutorProvider<EvmConfig = OptimismEvmConfig> {
|
||||
chain_spec: Arc<ChainSpec>,
|
||||
chain_spec: Arc<OpChainSpec>,
|
||||
evm_config: EvmConfig,
|
||||
}
|
||||
|
||||
impl OpExecutorProvider {
|
||||
/// Creates a new default optimism executor provider.
|
||||
pub fn optimism(chain_spec: Arc<ChainSpec>) -> Self {
|
||||
Self::new(
|
||||
chain_spec.clone(),
|
||||
OptimismEvmConfig::new(Arc::new(OpChainSpec { inner: (*chain_spec).clone() })),
|
||||
)
|
||||
pub fn optimism(chain_spec: Arc<OpChainSpec>) -> Self {
|
||||
Self::new(chain_spec.clone(), OptimismEvmConfig::new(chain_spec))
|
||||
}
|
||||
}
|
||||
|
||||
impl<EvmConfig> OpExecutorProvider<EvmConfig> {
|
||||
/// Creates a new executor provider.
|
||||
pub const fn new(chain_spec: Arc<ChainSpec>, evm_config: EvmConfig) -> Self {
|
||||
pub const fn new(chain_spec: Arc<OpChainSpec>, evm_config: EvmConfig) -> Self {
|
||||
Self { chain_spec, evm_config }
|
||||
}
|
||||
}
|
||||
@ -98,7 +95,7 @@ where
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct OpEvmExecutor<EvmConfig> {
|
||||
/// The chainspec
|
||||
chain_spec: Arc<ChainSpec>,
|
||||
chain_spec: Arc<OpChainSpec>,
|
||||
/// How to create an EVM.
|
||||
evm_config: EvmConfig,
|
||||
}
|
||||
@ -240,7 +237,11 @@ pub struct OpBlockExecutor<EvmConfig, DB> {
|
||||
|
||||
impl<EvmConfig, DB> OpBlockExecutor<EvmConfig, DB> {
|
||||
/// Creates a new Optimism block executor.
|
||||
pub const fn new(chain_spec: Arc<ChainSpec>, evm_config: EvmConfig, state: State<DB>) -> Self {
|
||||
pub const fn new(
|
||||
chain_spec: Arc<OpChainSpec>,
|
||||
evm_config: EvmConfig,
|
||||
state: State<DB>,
|
||||
) -> Self {
|
||||
Self { executor: OpEvmExecutor { chain_spec, evm_config }, state }
|
||||
}
|
||||
|
||||
@ -504,12 +505,8 @@ mod tests {
|
||||
}
|
||||
|
||||
fn executor_provider(chain_spec: Arc<ChainSpec>) -> OpExecutorProvider<OptimismEvmConfig> {
|
||||
OpExecutorProvider {
|
||||
evm_config: OptimismEvmConfig::new(Arc::new(OpChainSpec {
|
||||
inner: (*chain_spec).clone(),
|
||||
})),
|
||||
chain_spec,
|
||||
}
|
||||
let chain_spec = Arc::new(OpChainSpec::new(Arc::unwrap_or_clone(chain_spec)));
|
||||
OpExecutorProvider { evm_config: OptimismEvmConfig::new(chain_spec.clone()), chain_spec }
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@ -4,6 +4,7 @@ use crate::OptimismBlockExecutionError;
|
||||
use alloy_primitives::{address, b256, hex, Address, Bytes, B256, U256};
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_execution_errors::BlockExecutionError;
|
||||
use reth_optimism_chainspec::OpChainSpec;
|
||||
use reth_optimism_forks::OptimismHardfork;
|
||||
use reth_primitives::Block;
|
||||
use revm::{
|
||||
@ -260,7 +261,7 @@ impl RethL1BlockInfo for L1BlockInfo {
|
||||
/// deployer contract. This is done by directly setting the code of the create2 deployer account
|
||||
/// prior to executing any transactions on the timestamp activation of the fork.
|
||||
pub fn ensure_create2_deployer<DB>(
|
||||
chain_spec: Arc<ChainSpec>,
|
||||
chain_spec: Arc<OpChainSpec>,
|
||||
timestamp: u64,
|
||||
db: &mut revm::State<DB>,
|
||||
) -> Result<(), DB::Error>
|
||||
|
||||
Reference in New Issue
Block a user