Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(op): skip validation on deposit tx #1065

Merged
merged 2 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading