Skip to content

Commit

Permalink
fix: set OP enveloped tx field (#7649)
Browse files Browse the repository at this point in the history
* fix: set OP enveloped tx field

* use is enabled

* fix

* fmt

---------

Co-authored-by: Arsenii Kulikov <[email protected]>
  • Loading branch information
mattsse and klkvr committed Apr 15, 2024
1 parent 1122df5 commit 43587e2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
14 changes: 8 additions & 6 deletions 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.is_enabled_in(SpecId::LONDON) {
Some(self.block_env.basefee.to::<u128>())
} else {
None
Expand Down Expand Up @@ -208,11 +208,13 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<'
}

fn env_for(&self, tx: &PendingTransaction) -> EnvWithHandlerCfg {
EnvWithHandlerCfg::new_with_cfg_env(
self.cfg_env.clone(),
self.block_env.clone(),
tx.to_revm_tx_env(),
)
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(), tx_env)
}
}

Expand Down
9 changes: 8 additions & 1 deletion crates/anvil/src/eth/backend/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ use futures::channel::mpsc::{unbounded, UnboundedSender};
use parking_lot::{Mutex, RwLock};
use revm::{
db::WrapDatabaseRef,
primitives::{HashMap, ResultAndState},
primitives::{HashMap, OptimismFields, ResultAndState},
};
use std::{
collections::BTreeMap,
Expand Down 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 Expand Up @@ -1128,6 +1134,7 @@ impl Backend {
chain_id: None,
nonce,
access_list: access_list.unwrap_or_default().flattened(),
optimism: OptimismFields { enveloped_tx: Some(Bytes::new()), ..Default::default() },
..Default::default()
};

Expand Down

0 comments on commit 43587e2

Please sign in to comment.