Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
Stop after a reversion happens, and only return the transactions that…
Browse files Browse the repository at this point in the history
… we simulate
  • Loading branch information
jeffsmale90 committed Jun 16, 2023
1 parent dd2cc12 commit 9187d86
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/chains/ethereum/ethereum/src/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,16 @@ export default class Blockchain extends Emittery<BlockchainTypedEvents> {
const results: InternalTransactionSimulationResult<Estimate>[] = new Array(
transactions.length
);
for (let i = 0; i < transactions.length; i++) {

// We only simulate transactions until a reversion occurs. We hang onto `i`, so that we know how many we simulated.
let i = 0;
for (
;
i < transactions.length &&
// break out as soon as we receive an error
(i === 0 || results[i - 1].result.exceptionError === undefined);
i++
) {
const transaction = transactions[i];
const trace: TraceEntry[] = [];
const storageChanges: {
Expand Down Expand Up @@ -1507,7 +1516,7 @@ export default class Blockchain extends Emittery<BlockchainTypedEvents> {
await vm.eei.cleanupTouchedAccounts();
}

return results;
return i < transactions.length ? results.slice(0, i) : results;
}

/**
Expand Down

0 comments on commit 9187d86

Please sign in to comment.