mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
renamed OptimismBlockExecutionError to OpBlockExecutionError (#12383)
This commit is contained in:
@ -5,7 +5,7 @@ use reth_evm::execute::BlockExecutionError;
|
||||
|
||||
/// Optimism Block Executor Errors
|
||||
#[derive(Debug, Clone, PartialEq, Eq, derive_more::Display)]
|
||||
pub enum OptimismBlockExecutionError {
|
||||
pub enum OpBlockExecutionError {
|
||||
/// Error when trying to parse L1 block info
|
||||
#[display("could not get L1 block info from L2 block: {message}")]
|
||||
L1BlockInfoError {
|
||||
@ -23,10 +23,10 @@ pub enum OptimismBlockExecutionError {
|
||||
AccountLoadFailed(alloy_primitives::Address),
|
||||
}
|
||||
|
||||
impl core::error::Error for OptimismBlockExecutionError {}
|
||||
impl core::error::Error for OpBlockExecutionError {}
|
||||
|
||||
impl From<OptimismBlockExecutionError> for BlockExecutionError {
|
||||
fn from(err: OptimismBlockExecutionError) -> Self {
|
||||
impl From<OpBlockExecutionError> for BlockExecutionError {
|
||||
fn from(err: OpBlockExecutionError) -> Self {
|
||||
Self::other(err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
//! Optimism block execution strategy.
|
||||
|
||||
use crate::{l1::ensure_create2_deployer, OpEvmConfig, OptimismBlockExecutionError};
|
||||
use crate::{l1::ensure_create2_deployer, OpBlockExecutionError, OpEvmConfig};
|
||||
use alloc::{boxed::Box, sync::Arc, vec::Vec};
|
||||
use alloy_consensus::Transaction as _;
|
||||
use alloy_eips::eip7685::Requests;
|
||||
@ -144,7 +144,7 @@ where
|
||||
// so we can safely assume that this will always be triggered upon the transition and that
|
||||
// the above check for empty blocks will never be hit on OP chains.
|
||||
ensure_create2_deployer(self.chain_spec.clone(), block.timestamp, evm.db_mut())
|
||||
.map_err(|_| OptimismBlockExecutionError::ForceCreate2DeployerFail)?;
|
||||
.map_err(|_| OpBlockExecutionError::ForceCreate2DeployerFail)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -178,7 +178,7 @@ where
|
||||
|
||||
// An optimism block should never contain blob transactions.
|
||||
if matches!(transaction.tx_type(), TxType::Eip4844) {
|
||||
return Err(OptimismBlockExecutionError::BlobTransactionRejected.into())
|
||||
return Err(OpBlockExecutionError::BlobTransactionRejected.into())
|
||||
}
|
||||
|
||||
// Cache the depositor account prior to the state transition for the deposit nonce.
|
||||
@ -193,7 +193,7 @@ where
|
||||
.map(|acc| acc.account_info().unwrap_or_default())
|
||||
})
|
||||
.transpose()
|
||||
.map_err(|_| OptimismBlockExecutionError::AccountLoadFailed(*sender))?;
|
||||
.map_err(|_| OpBlockExecutionError::AccountLoadFailed(*sender))?;
|
||||
|
||||
self.evm_config.fill_tx_env(evm.tx_mut(), transaction, *sender);
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
//! Optimism-specific implementation and utilities for the executor
|
||||
|
||||
use crate::OptimismBlockExecutionError;
|
||||
use crate::OpBlockExecutionError;
|
||||
use alloc::{string::ToString, sync::Arc};
|
||||
use alloy_primitives::{address, b256, hex, Address, Bytes, B256, U256};
|
||||
use reth_chainspec::ChainSpec;
|
||||
@ -31,17 +31,17 @@ const L1_BLOCK_ECOTONE_SELECTOR: [u8; 4] = hex!("440a5e20");
|
||||
/// transaction in the L2 block.
|
||||
///
|
||||
/// Returns an error if the L1 info transaction is not found, if the block is empty.
|
||||
pub fn extract_l1_info(body: &BlockBody) -> Result<L1BlockInfo, OptimismBlockExecutionError> {
|
||||
pub fn extract_l1_info(body: &BlockBody) -> Result<L1BlockInfo, OpBlockExecutionError> {
|
||||
let l1_info_tx_data = body
|
||||
.transactions
|
||||
.first()
|
||||
.ok_or_else(|| OptimismBlockExecutionError::L1BlockInfoError {
|
||||
.ok_or_else(|| OpBlockExecutionError::L1BlockInfoError {
|
||||
message: "could not find l1 block info tx in the L2 block".to_string(),
|
||||
})
|
||||
.map(|tx| tx.input())?;
|
||||
|
||||
if l1_info_tx_data.len() < 4 {
|
||||
return Err(OptimismBlockExecutionError::L1BlockInfoError {
|
||||
return Err(OpBlockExecutionError::L1BlockInfoError {
|
||||
message: "invalid l1 block info transaction calldata in the L2 block".to_string(),
|
||||
})
|
||||
}
|
||||
@ -52,7 +52,7 @@ pub fn extract_l1_info(body: &BlockBody) -> Result<L1BlockInfo, OptimismBlockExe
|
||||
/// Parses the input of the first transaction in the L2 block, into [`L1BlockInfo`].
|
||||
///
|
||||
/// Returns an error if data is incorrect length.
|
||||
pub fn parse_l1_info(input: &[u8]) -> Result<L1BlockInfo, OptimismBlockExecutionError> {
|
||||
pub fn parse_l1_info(input: &[u8]) -> Result<L1BlockInfo, OpBlockExecutionError> {
|
||||
// If the first 4 bytes of the calldata are the L1BlockInfoEcotone selector, then we parse the
|
||||
// calldata as an Ecotone hardfork L1BlockInfo transaction. Otherwise, we parse it as a
|
||||
// Bedrock hardfork L1BlockInfo transaction.
|
||||
@ -64,7 +64,7 @@ pub fn parse_l1_info(input: &[u8]) -> Result<L1BlockInfo, OptimismBlockExecution
|
||||
}
|
||||
|
||||
/// Parses the calldata of the [`L1BlockInfo`] transaction pre-Ecotone hardfork.
|
||||
pub fn parse_l1_info_tx_bedrock(data: &[u8]) -> Result<L1BlockInfo, OptimismBlockExecutionError> {
|
||||
pub fn parse_l1_info_tx_bedrock(data: &[u8]) -> Result<L1BlockInfo, OpBlockExecutionError> {
|
||||
// The setL1BlockValues tx calldata must be exactly 260 bytes long, considering that
|
||||
// we already removed the first 4 bytes (the function selector). Detailed breakdown:
|
||||
// 32 bytes for the block number
|
||||
@ -76,23 +76,23 @@ pub fn parse_l1_info_tx_bedrock(data: &[u8]) -> Result<L1BlockInfo, OptimismBloc
|
||||
// + 32 bytes for the fee overhead
|
||||
// + 32 bytes for the fee scalar
|
||||
if data.len() != 256 {
|
||||
return Err(OptimismBlockExecutionError::L1BlockInfoError {
|
||||
return Err(OpBlockExecutionError::L1BlockInfoError {
|
||||
message: "unexpected l1 block info tx calldata length found".to_string(),
|
||||
})
|
||||
}
|
||||
|
||||
let l1_base_fee = U256::try_from_be_slice(&data[64..96]).ok_or_else(|| {
|
||||
OptimismBlockExecutionError::L1BlockInfoError {
|
||||
OpBlockExecutionError::L1BlockInfoError {
|
||||
message: "could not convert l1 base fee".to_string(),
|
||||
}
|
||||
})?;
|
||||
let l1_fee_overhead = U256::try_from_be_slice(&data[192..224]).ok_or_else(|| {
|
||||
OptimismBlockExecutionError::L1BlockInfoError {
|
||||
OpBlockExecutionError::L1BlockInfoError {
|
||||
message: "could not convert l1 fee overhead".to_string(),
|
||||
}
|
||||
})?;
|
||||
let l1_fee_scalar = U256::try_from_be_slice(&data[224..256]).ok_or_else(|| {
|
||||
OptimismBlockExecutionError::L1BlockInfoError {
|
||||
OpBlockExecutionError::L1BlockInfoError {
|
||||
message: "could not convert l1 fee scalar".to_string(),
|
||||
}
|
||||
})?;
|
||||
@ -119,9 +119,9 @@ pub fn parse_l1_info_tx_bedrock(data: &[u8]) -> Result<L1BlockInfo, OptimismBloc
|
||||
/// 9. _batcherHash Versioned hash to authenticate batcher by.
|
||||
///
|
||||
/// <https://github.com/ethereum-optimism/optimism/blob/957e13dd504fb336a4be40fb5dd0d8ba0276be34/packages/contracts-bedrock/src/L2/L1Block.sol#L136>
|
||||
pub fn parse_l1_info_tx_ecotone(data: &[u8]) -> Result<L1BlockInfo, OptimismBlockExecutionError> {
|
||||
pub fn parse_l1_info_tx_ecotone(data: &[u8]) -> Result<L1BlockInfo, OpBlockExecutionError> {
|
||||
if data.len() != 160 {
|
||||
return Err(OptimismBlockExecutionError::L1BlockInfoError {
|
||||
return Err(OpBlockExecutionError::L1BlockInfoError {
|
||||
message: "unexpected l1 block info tx calldata length found".to_string(),
|
||||
})
|
||||
}
|
||||
@ -142,22 +142,22 @@ pub fn parse_l1_info_tx_ecotone(data: &[u8]) -> Result<L1BlockInfo, OptimismBloc
|
||||
// 132 bytes32 _batcherHash,
|
||||
|
||||
let l1_base_fee_scalar = U256::try_from_be_slice(&data[..4]).ok_or_else(|| {
|
||||
OptimismBlockExecutionError::L1BlockInfoError {
|
||||
OpBlockExecutionError::L1BlockInfoError {
|
||||
message: "could not convert l1 base fee scalar".to_string(),
|
||||
}
|
||||
})?;
|
||||
let l1_blob_base_fee_scalar = U256::try_from_be_slice(&data[4..8]).ok_or_else(|| {
|
||||
OptimismBlockExecutionError::L1BlockInfoError {
|
||||
OpBlockExecutionError::L1BlockInfoError {
|
||||
message: "could not convert l1 blob base fee scalar".to_string(),
|
||||
}
|
||||
})?;
|
||||
let l1_base_fee = U256::try_from_be_slice(&data[32..64]).ok_or_else(|| {
|
||||
OptimismBlockExecutionError::L1BlockInfoError {
|
||||
OpBlockExecutionError::L1BlockInfoError {
|
||||
message: "could not convert l1 blob base fee".to_string(),
|
||||
}
|
||||
})?;
|
||||
let l1_blob_base_fee = U256::try_from_be_slice(&data[64..96]).ok_or_else(|| {
|
||||
OptimismBlockExecutionError::L1BlockInfoError {
|
||||
OpBlockExecutionError::L1BlockInfoError {
|
||||
message: "could not convert l1 blob base fee".to_string(),
|
||||
}
|
||||
})?;
|
||||
@ -225,7 +225,7 @@ impl RethL1BlockInfo for L1BlockInfo {
|
||||
} else if chain_spec.is_fork_active_at_timestamp(OptimismHardfork::Bedrock, timestamp) {
|
||||
SpecId::BEDROCK
|
||||
} else {
|
||||
return Err(OptimismBlockExecutionError::L1BlockInfoError {
|
||||
return Err(OpBlockExecutionError::L1BlockInfoError {
|
||||
message: "Optimism hardforks are not active".to_string(),
|
||||
}
|
||||
.into())
|
||||
@ -247,7 +247,7 @@ impl RethL1BlockInfo for L1BlockInfo {
|
||||
} else if chain_spec.is_fork_active_at_timestamp(OptimismHardfork::Bedrock, timestamp) {
|
||||
SpecId::BEDROCK
|
||||
} else {
|
||||
return Err(OptimismBlockExecutionError::L1BlockInfoError {
|
||||
return Err(OpBlockExecutionError::L1BlockInfoError {
|
||||
message: "Optimism hardforks are not active".to_string(),
|
||||
}
|
||||
.into())
|
||||
|
||||
@ -31,7 +31,7 @@ pub mod l1;
|
||||
pub use l1::*;
|
||||
|
||||
mod error;
|
||||
pub use error::OptimismBlockExecutionError;
|
||||
pub use error::OpBlockExecutionError;
|
||||
use revm_primitives::{
|
||||
BlobExcessGasAndPrice, BlockEnv, Bytes, CfgEnv, Env, HandlerCfg, OptimismFields, SpecId, TxKind,
|
||||
};
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
use alloy_rpc_types::error::EthRpcErrorCode;
|
||||
use jsonrpsee_types::error::INTERNAL_ERROR_CODE;
|
||||
use reth_optimism_evm::OptimismBlockExecutionError;
|
||||
use reth_optimism_evm::OpBlockExecutionError;
|
||||
use reth_primitives::revm_primitives::{InvalidTransaction, OptimismInvalidTransaction};
|
||||
use reth_rpc_eth_api::AsEthApiError;
|
||||
use reth_rpc_eth_types::EthApiError;
|
||||
@ -16,7 +16,7 @@ pub enum OpEthApiError {
|
||||
Eth(#[from] EthApiError),
|
||||
/// EVM error originating from invalid optimism data.
|
||||
#[error(transparent)]
|
||||
Evm(#[from] OptimismBlockExecutionError),
|
||||
Evm(#[from] OpBlockExecutionError),
|
||||
/// Thrown when calculating L1 gas fee.
|
||||
#[error("failed to calculate l1 gas fee")]
|
||||
L1BlockFeeError,
|
||||
|
||||
Reference in New Issue
Block a user