chore: make op-evm compile with no-std (#11834)

This commit is contained in:
Matthias Seitz
2024-10-17 15:54:32 +02:00
committed by GitHub
parent 52407b18de
commit 6ba4bbe4aa
7 changed files with 22 additions and 11 deletions

2
Cargo.lock generated
View File

@ -8108,6 +8108,7 @@ dependencies = [
"alloy-eips", "alloy-eips",
"alloy-genesis", "alloy-genesis",
"alloy-primitives", "alloy-primitives",
"derive_more 1.0.0",
"op-alloy-consensus", "op-alloy-consensus",
"reth-chainspec", "reth-chainspec",
"reth-consensus", "reth-consensus",
@ -8123,7 +8124,6 @@ dependencies = [
"reth-revm", "reth-revm",
"revm", "revm",
"revm-primitives", "revm-primitives",
"thiserror",
"tracing", "tracing",
] ]

View File

@ -37,7 +37,7 @@ revm.workspace = true
revm-primitives.workspace = true revm-primitives.workspace = true
# misc # misc
thiserror.workspace = true derive_more.workspace = true
tracing.workspace = true tracing.workspace = true
[dev-dependencies] [dev-dependencies]
@ -51,6 +51,8 @@ alloy-genesis.workspace = true
alloy-consensus.workspace = true alloy-consensus.workspace = true
[features] [features]
default = ["std"]
std = []
optimism = [ optimism = [
"reth-primitives/optimism", "reth-primitives/optimism",
"reth-execution-types/optimism", "reth-execution-types/optimism",

View File

@ -1,27 +1,30 @@
//! Error types for the Optimism EVM module. //! Error types for the Optimism EVM module.
use alloc::string::String;
use reth_evm::execute::BlockExecutionError; use reth_evm::execute::BlockExecutionError;
/// Optimism Block Executor Errors /// Optimism Block Executor Errors
#[derive(thiserror::Error, Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq, derive_more::Display)]
pub enum OptimismBlockExecutionError { pub enum OptimismBlockExecutionError {
/// Error when trying to parse L1 block info /// Error when trying to parse L1 block info
#[error("could not get L1 block info from L2 block: {message:?}")] #[display("could not get L1 block info from L2 block: {message}")]
L1BlockInfoError { L1BlockInfoError {
/// The inner error message /// The inner error message
message: String, message: String,
}, },
/// Thrown when force deploy of create2deployer code fails. /// Thrown when force deploy of create2deployer code fails.
#[error("failed to force create2deployer account code")] #[display("failed to force create2deployer account code")]
ForceCreate2DeployerFail, ForceCreate2DeployerFail,
/// Thrown when a blob transaction is included in a sequencer's block. /// Thrown when a blob transaction is included in a sequencer's block.
#[error("blob transaction included in sequencer block")] #[display("blob transaction included in sequencer block")]
BlobTransactionRejected, BlobTransactionRejected,
/// Thrown when a database account could not be loaded. /// Thrown when a database account could not be loaded.
#[error("failed to load account {0}")] #[display("failed to load account {_0}")]
AccountLoadFailed(alloy_primitives::Address), AccountLoadFailed(alloy_primitives::Address),
} }
impl core::error::Error for OptimismBlockExecutionError {}
impl From<OptimismBlockExecutionError> for BlockExecutionError { impl From<OptimismBlockExecutionError> for BlockExecutionError {
fn from(err: OptimismBlockExecutionError) -> Self { fn from(err: OptimismBlockExecutionError) -> Self {
Self::other(err) Self::other(err)

View File

@ -3,8 +3,10 @@
use crate::{ use crate::{
l1::ensure_create2_deployer, OpChainSpec, OptimismBlockExecutionError, OptimismEvmConfig, l1::ensure_create2_deployer, OpChainSpec, OptimismBlockExecutionError, OptimismEvmConfig,
}; };
use alloc::{boxed::Box, sync::Arc, vec::Vec};
use alloy_consensus::Transaction as _; use alloy_consensus::Transaction as _;
use alloy_primitives::{BlockNumber, U256}; use alloy_primitives::{BlockNumber, U256};
use core::fmt::Display;
use reth_chainspec::{ChainSpec, EthereumHardforks}; use reth_chainspec::{ChainSpec, EthereumHardforks};
use reth_evm::{ use reth_evm::{
execute::{ execute::{
@ -27,7 +29,6 @@ use revm_primitives::{
db::{Database, DatabaseCommit}, db::{Database, DatabaseCommit},
BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, ResultAndState, BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, ResultAndState,
}; };
use std::{fmt::Display, sync::Arc};
use tracing::trace; use tracing::trace;
/// Provides executors to execute regular optimism blocks /// Provides executors to execute regular optimism blocks

View File

@ -1,6 +1,7 @@
//! Optimism-specific implementation and utilities for the executor //! Optimism-specific implementation and utilities for the executor
use crate::OptimismBlockExecutionError; use crate::OptimismBlockExecutionError;
use alloc::{string::ToString, sync::Arc};
use alloy_primitives::{address, b256, hex, Address, Bytes, B256, U256}; use alloy_primitives::{address, b256, hex, Address, Bytes, B256, U256};
use reth_chainspec::ChainSpec; use reth_chainspec::ChainSpec;
use reth_execution_errors::BlockExecutionError; use reth_execution_errors::BlockExecutionError;
@ -11,7 +12,6 @@ use revm::{
primitives::{Bytecode, HashMap, SpecId}, primitives::{Bytecode, HashMap, SpecId},
DatabaseCommit, L1BlockInfo, DatabaseCommit, L1BlockInfo,
}; };
use std::sync::Arc;
use tracing::trace; use tracing::trace;
/// The address of the create2 deployer /// The address of the create2 deployer

View File

@ -6,9 +6,14 @@
issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/" issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/"
)] )]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(not(feature = "std"), no_std)]
// The `optimism` feature must be enabled to use this crate. // The `optimism` feature must be enabled to use this crate.
#![cfg(feature = "optimism")] #![cfg(feature = "optimism")]
#[macro_use]
extern crate alloc;
use alloc::{sync::Arc, vec::Vec};
use alloy_primitives::{Address, U256}; use alloy_primitives::{Address, U256};
use reth_evm::{ConfigureEvm, ConfigureEvmEnv, NextBlockEnvAttributes}; use reth_evm::{ConfigureEvm, ConfigureEvmEnv, NextBlockEnvAttributes};
use reth_optimism_chainspec::OpChainSpec; use reth_optimism_chainspec::OpChainSpec;
@ -18,7 +23,6 @@ use reth_primitives::{
Head, Header, TransactionSigned, Head, Header, TransactionSigned,
}; };
use reth_revm::{inspector_handle_register, Database, Evm, EvmBuilder, GetInspector}; use reth_revm::{inspector_handle_register, Database, Evm, EvmBuilder, GetInspector};
use std::sync::Arc;
mod config; mod config;
pub use config::{revm_spec, revm_spec_by_timestamp_after_bedrock}; pub use config::{revm_spec, revm_spec_by_timestamp_after_bedrock};

View File

@ -1,7 +1,9 @@
//! Optimism block execution strategy, //! Optimism block execution strategy,
use crate::{l1::ensure_create2_deployer, OptimismBlockExecutionError, OptimismEvmConfig}; use crate::{l1::ensure_create2_deployer, OptimismBlockExecutionError, OptimismEvmConfig};
use alloc::{boxed::Box, sync::Arc, vec::Vec};
use alloy_consensus::Transaction as _; use alloy_consensus::Transaction as _;
use core::fmt::Display;
use reth_chainspec::EthereumHardforks; use reth_chainspec::EthereumHardforks;
use reth_consensus::ConsensusError; use reth_consensus::ConsensusError;
use reth_evm::{ use reth_evm::{
@ -24,7 +26,6 @@ use reth_revm::{
use revm_primitives::{ use revm_primitives::{
db::DatabaseCommit, BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, ResultAndState, U256, db::DatabaseCommit, BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, ResultAndState, U256,
}; };
use std::{fmt::Display, sync::Arc};
use tracing::trace; use tracing::trace;
/// Factory for [`OpExecutionStrategy`]. /// Factory for [`OpExecutionStrategy`].