Skip to content

Commit

Permalink
fix: set OP enveloped tx field
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse committed Apr 12, 2024
1 parent bdc04c2 commit 8a0fc50
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion crates/anvil/src/eth/backend/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<'
let difficulty = self.block_env.difficulty;
let beneficiary = self.block_env.coinbase;
let timestamp = self.block_env.timestamp.to::<u64>();
let base_fee = if (self.cfg_env.handler_cfg.spec_id as u8) >= (SpecId::LONDON as u8) {
let base_fee = if self.cfg_env.handler_cfg.spec_id >= SpecId::LONDON {
Some(self.block_env.basefee.to::<u128>())
} else {
None
Expand Down Expand Up @@ -208,6 +208,12 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<'
}

fn env_for(&self, tx: &PendingTransaction) -> EnvWithHandlerCfg {
let mut tx_env = tx.to_revm_tx_env();
if self.cfg_env.handler_cfg.is_optimism {
tx_env.optimism.enveloped_tx =
Some(alloy_rlp::encode(&tx.transaction.transaction).into());
}

EnvWithHandlerCfg::new_with_cfg_env(
self.cfg_env.clone(),
self.block_env.clone(),
Expand Down
6 changes: 6 additions & 0 deletions crates/anvil/src/eth/backend/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,12 @@ impl Backend {
> {
let mut env = self.next_env();
env.tx = tx.pending_transaction.to_revm_tx_env();

if env.handler_cfg.is_optimism {
env.tx.optimism.enveloped_tx =
Some(alloy_rlp::encode(&tx.pending_transaction.transaction.transaction).into());
}

let db = self.db.read().await;
let mut inspector = Inspector::default();
let mut evm = self.new_evm_with_inspector_ref(&*db, env, &mut inspector);
Expand Down

0 comments on commit 8a0fc50

Please sign in to comment.