Skip to content

Commit

Permalink
fix(op): skip validation on deposit tx (#1065)
Browse files Browse the repository at this point in the history
* fix(op): skip validation on deposit tx

* compile it
  • Loading branch information
rakita authored Feb 8, 2024
1 parent 53718f2 commit 0654850
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/revm/src/optimism.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ mod l1block;

pub use handler_register::{
deduct_caller, end, last_frame_return, load_accounts, optimism_handle_register, output,
reward_beneficiary, validate_env,
reward_beneficiary, validate_env, validate_tx_against_state,
};
pub use l1block::{L1BlockInfo, BASE_FEE_RECIPIENT, L1_BLOCK_CONTRACT, L1_FEE_RECIPIENT};
12 changes: 12 additions & 0 deletions crates/revm/src/optimism/handler_register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ pub fn optimism_handle_register<DB: Database, EXT>(handler: &mut EvmHandler<'_,
spec_to_generic!(handler.cfg.spec_id, {
// validate environment
handler.validation.env = Arc::new(validate_env::<SPEC, DB>);
// Validate transaction against state.
handler.validation.tx_against_state = Arc::new(validate_tx_against_state::<SPEC, EXT, DB>);
// load l1 data
handler.pre_execution.load_accounts = Arc::new(load_accounts::<SPEC, EXT, DB>);
// An estimated batch cost is charged from the caller and added to L1 Fee Vault.
Expand Down Expand Up @@ -52,6 +54,16 @@ pub fn validate_env<SPEC: Spec, DB: Database>(env: &Env) -> Result<(), EVMError<
Ok(())
}

/// Don not perform any extra validation for deposit transactions, they are pre-verified on L1.
pub fn validate_tx_against_state<SPEC: Spec, EXT, DB: Database>(
context: &mut Context<EXT, DB>,
) -> Result<(), EVMError<DB::Error>> {
if context.evm.env.tx.optimism.source_hash.is_some() {
return Ok(());
}
mainnet::validate_tx_against_state::<SPEC, EXT, DB>(context)
}

/// Handle output of the transaction
#[inline]
pub fn last_frame_return<SPEC: Spec, EXT, DB: Database>(
Expand Down

0 comments on commit 0654850

Please sign in to comment.