Skip to content

Commit 1f9c77a

Browse files
authored
chore: use dyn InspectorExt in Backend (#8919)
1 parent 90541f0 commit 1f9c77a

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

crates/evm/core/src/backend/mod.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ impl Backend {
868868
let fork = self.inner.get_fork_by_id_mut(id)?;
869869
let full_block = fork.db.db.get_full_block(env.block.number.to::<u64>())?;
870870

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

887887
commit_transaction(
888-
tx,
888+
&tx.inner,
889889
env.clone(),
890890
journaled_state,
891891
fork,
@@ -1235,8 +1235,12 @@ impl DatabaseExt for Backend {
12351235
fork.db.db.get_transaction(transaction)?
12361236
};
12371237

1238-
// 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>
1239-
// So we modify the env to match the transaction's block
1238+
// This is a bit ambiguous because the user wants to transact an arbitrary transaction in
1239+
// the current context, but we're assuming the user wants to transact the transaction as it
1240+
// was mined. Usually this is used in a combination of a fork at the transaction's parent
1241+
// transaction in the block and then the transaction is transacted:
1242+
// <https://github.com/foundry-rs/foundry/issues/6538>
1243+
// So we modify the env to match the transaction's block.
12401244
let (_fork_block, block) =
12411245
self.get_block_number_and_block_for_transaction(id, transaction)?;
12421246
let mut env = env.clone();
@@ -1245,7 +1249,7 @@ impl DatabaseExt for Backend {
12451249
let env = self.env_with_handler_cfg(env);
12461250
let fork = self.inner.get_fork_by_id_mut(id)?;
12471251
commit_transaction(
1248-
tx,
1252+
&tx,
12491253
env,
12501254
journaled_state,
12511255
fork,
@@ -1903,17 +1907,17 @@ fn update_env_block<T>(env: &mut Env, block: &Block<T>) {
19031907
}
19041908

19051909
/// Executes the given transaction and commits state changes to the database _and_ the journaled
1906-
/// state, with an optional inspector
1907-
fn commit_transaction<I: InspectorExt<Backend>>(
1908-
tx: WithOtherFields<Transaction>,
1910+
/// state, with an inspector.
1911+
fn commit_transaction(
1912+
tx: &Transaction,
19091913
mut env: EnvWithHandlerCfg,
19101914
journaled_state: &mut JournaledState,
19111915
fork: &mut Fork,
19121916
fork_id: &ForkId,
19131917
persistent_accounts: &HashSet<Address>,
1914-
inspector: I,
1918+
inspector: &mut dyn InspectorExt<Backend>,
19151919
) -> eyre::Result<()> {
1916-
configure_tx_env(&mut env.env, &tx.inner);
1920+
configure_tx_env(&mut env.env, tx);
19171921

19181922
let now = Instant::now();
19191923
let res = {

crates/evm/core/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ pub trait InspectorExt<DB: Database>: Inspector<DB> {
4545
false
4646
}
4747

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

51+
/// Returns `true` if the current network is Alphanet.
5152
fn is_alphanet(&self) -> bool {
5253
false
5354
}

0 commit comments

Comments
 (0)