Skip to content

Commit

Permalink
fix optimism
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhirin committed May 20, 2024
1 parent 90ef8ee commit 870db14
Showing 1 changed file with 7 additions and 26 deletions.
33 changes: 7 additions & 26 deletions crates/optimism/evm/src/execute.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
//! Optimism block executor.
use crate::{
l1::ensure_create2_deployer, verify::verify_receipts, OptimismBlockExecutionError,
OptimismEvmConfig,
};
use crate::{l1::ensure_create2_deployer, OptimismBlockExecutionError, OptimismEvmConfig};
use reth_evm::{
execute::{
BatchBlockExecutionOutput, BatchExecutor, BlockExecutionInput, BlockExecutionOutput,
Expand All @@ -30,7 +27,7 @@ use revm_primitives::{
BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, ResultAndState,
};
use std::sync::Arc;
use tracing::{debug, trace};
use tracing::trace;

/// Provides executors to execute regular ethereum blocks
#[derive(Debug, Clone)]
Expand Down Expand Up @@ -282,8 +279,8 @@ where
///
/// Returns the receipts of the transactions in the block and the total gas used.
///
/// Returns an error if execution fails or receipt verification fails.
fn execute_and_verify(
/// Returns an error if execution fails.
fn execute_without_verification(
&mut self,
block: &BlockWithSenders,
total_difficulty: U256,
Expand All @@ -302,23 +299,6 @@ where
// 3. apply post execution changes
self.post_execution(block, total_difficulty)?;

// Before Byzantium, receipts contained state root that would mean that expensive
// operation as hashing that is required for state root got calculated in every
// transaction This was replaced with is_success flag.
// See more about EIP here: https://eips.ethereum.org/EIPS/eip-658
if self.chain_spec().is_byzantium_active_at_block(block.header.number) {
if let Err(error) = verify_receipts(
block.header.receipts_root,
block.header.logs_bloom,
receipts.iter(),
self.chain_spec(),
block.timestamp,
) {
debug!(target: "evm", %error, ?receipts, "receipts verification failed");
return Err(error)
};
}

Ok((receipts, gas_used))
}

Expand Down Expand Up @@ -373,7 +353,7 @@ where
/// State changes are committed to the database.
fn execute(mut self, input: Self::Input<'_>) -> Result<Self::Output, Self::Error> {
let BlockExecutionInput { block, total_difficulty } = input;
let (receipts, gas_used) = self.execute_and_verify(block, total_difficulty)?;
let (receipts, gas_used) = self.execute_without_verification(block, total_difficulty)?;

// NOTE: we need to merge keep the reverts for the bundle retention
self.state.merge_transitions(BundleRetention::Reverts);
Expand Down Expand Up @@ -418,7 +398,8 @@ where

fn execute_one(&mut self, input: Self::Input<'_>) -> Result<(), Self::Error> {
let BlockExecutionInput { block, total_difficulty } = input;
let (receipts, _gas_used) = self.executor.execute_and_verify(block, total_difficulty)?;
let (receipts, _gas_used) =
self.executor.execute_without_verification(block, total_difficulty)?;

// prepare the state according to the prune mode
let retention = self.batch_record.bundle_retention(block.number);
Expand Down

0 comments on commit 870db14

Please sign in to comment.