Skip to content
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
24 changes: 14 additions & 10 deletions crates/evm/core/src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ impl Backend {
let fork = self.inner.get_fork_by_id_mut(id)?;
let full_block = fork.db.db.get_full_block(env.block.number.to::<u64>())?;

for tx in full_block.transactions.clone().into_transactions() {
for tx in full_block.inner.transactions.into_transactions() {
// System transactions such as on L2s don't contain any pricing info so we skip them
// otherwise this would cause reverts
if is_known_system_sender(tx.from) ||
Expand All @@ -885,7 +885,7 @@ impl Backend {
trace!(tx=?tx.hash, "committing transaction");

commit_transaction(
tx,
&tx.inner,
env.clone(),
journaled_state,
fork,
Expand Down Expand Up @@ -1235,8 +1235,12 @@ impl DatabaseExt for Backend {
fork.db.db.get_transaction(transaction)?
};

// This is a bit ambiguous because the user wants to transact an arbitrary transaction in the current context, but we're assuming the user wants to transact the transaction as it was mined. Usually this is used in a combination of a fork at the transaction's parent transaction in the block and then the transaction is transacted: <https://github.com/foundry-rs/foundry/issues/6538>
// So we modify the env to match the transaction's block
// This is a bit ambiguous because the user wants to transact an arbitrary transaction in
// the current context, but we're assuming the user wants to transact the transaction as it
// was mined. Usually this is used in a combination of a fork at the transaction's parent
// transaction in the block and then the transaction is transacted:
// <https://github.com/foundry-rs/foundry/issues/6538>
// So we modify the env to match the transaction's block.
let (_fork_block, block) =
self.get_block_number_and_block_for_transaction(id, transaction)?;
let mut env = env.clone();
Expand All @@ -1245,7 +1249,7 @@ impl DatabaseExt for Backend {
let env = self.env_with_handler_cfg(env);
let fork = self.inner.get_fork_by_id_mut(id)?;
commit_transaction(
tx,
&tx,
env,
journaled_state,
fork,
Expand Down Expand Up @@ -1903,17 +1907,17 @@ fn update_env_block<T>(env: &mut Env, block: &Block<T>) {
}

/// Executes the given transaction and commits state changes to the database _and_ the journaled
/// state, with an optional inspector
fn commit_transaction<I: InspectorExt<Backend>>(
tx: WithOtherFields<Transaction>,
/// state, with an inspector.
fn commit_transaction(
tx: &Transaction,
mut env: EnvWithHandlerCfg,
journaled_state: &mut JournaledState,
fork: &mut Fork,
fork_id: &ForkId,
persistent_accounts: &HashSet<Address>,
inspector: I,
inspector: &mut dyn InspectorExt<Backend>,
) -> eyre::Result<()> {
configure_tx_env(&mut env.env, &tx.inner);
configure_tx_env(&mut env.env, tx);

let now = Instant::now();
let res = {
Expand Down
3 changes: 2 additions & 1 deletion crates/evm/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ pub trait InspectorExt<DB: Database>: Inspector<DB> {
false
}

// Simulates `console.log` invocation.
/// Simulates `console.log` invocation.
fn console_log(&mut self, _input: String) {}

/// Returns `true` if the current network is Alphanet.
fn is_alphanet(&self) -> bool {
false
}
Expand Down