convert ``OptimismBlockExecution`` error variant into a general purpose error variant (#8100)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Rupam Dey
2024-05-06 18:37:25 +05:30
committed by GitHub
parent 7fd091536f
commit 5e778317fb
12 changed files with 111 additions and 116 deletions

View File

@@ -1,6 +1,9 @@
//! Optimism block executor.
use crate::{l1::ensure_create2_deployer, verify::verify_receipts, OptimismEvmConfig};
use crate::{
l1::ensure_create2_deployer, verify::verify_receipts, OptimismBlockExecutionError,
OptimismEvmConfig,
};
use reth_evm::{
execute::{
BatchBlockExecutionOutput, BatchExecutor, BlockExecutionInput, BlockExecutionOutput,
@@ -9,7 +12,7 @@ use reth_evm::{
ConfigureEvm, ConfigureEvmEnv,
};
use reth_interfaces::{
executor::{BlockExecutionError, BlockValidationError, OptimismBlockExecutionError},
executor::{BlockExecutionError, BlockValidationError},
provider::ProviderError,
};
use reth_primitives::{
@@ -141,13 +144,8 @@ where
// blocks will always have at least a single transaction in them (the L1 info transaction),
// 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(
|_| {
BlockExecutionError::OptimismBlockExecution(
OptimismBlockExecutionError::ForceCreate2DeployerFail,
)
},
)?;
ensure_create2_deployer(self.chain_spec.clone(), block.timestamp, evm.db_mut())
.map_err(|_| OptimismBlockExecutionError::ForceCreate2DeployerFail)?;
let mut cumulative_gas_used = 0;
let mut receipts = Vec::with_capacity(block.body.len());
@@ -167,9 +165,7 @@ where
// An optimism block should never contain blob transactions.
if matches!(transaction.tx_type(), TxType::Eip4844) {
return Err(BlockExecutionError::OptimismBlockExecution(
OptimismBlockExecutionError::BlobTransactionRejected,
));
return Err(OptimismBlockExecutionError::BlobTransactionRejected.into());
}
// Cache the depositor account prior to the state transition for the deposit nonce.
@@ -184,11 +180,7 @@ where
.map(|acc| acc.account_info().unwrap_or_default())
})
.transpose()
.map_err(|_| {
BlockExecutionError::OptimismBlockExecution(
OptimismBlockExecutionError::AccountLoadFailed(*sender),
)
})?;
.map_err(|_| OptimismBlockExecutionError::AccountLoadFailed(*sender))?;
let mut buf = Vec::with_capacity(transaction.length_without_header());
transaction.encode_enveloped(&mut buf);