From 44e01f4cdd6515990a7233fcb79fc2c01baf46d5 Mon Sep 17 00:00:00 2001 From: David Banks <47112877+dbanks12@users.noreply.github.com> Date: Thu, 9 Jan 2025 03:43:49 -0500 Subject: [PATCH] chore: log number of instructions executed for call in AVM. Misc fix. (#11110) --- yarn-project/simulator/src/avm/avm_simulator.ts | 1 + yarn-project/simulator/src/avm/journal/journal.ts | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/yarn-project/simulator/src/avm/avm_simulator.ts b/yarn-project/simulator/src/avm/avm_simulator.ts index fff7f7d7fd5..a69aa089377 100644 --- a/yarn-project/simulator/src/avm/avm_simulator.ts +++ b/yarn-project/simulator/src/avm/avm_simulator.ts @@ -180,6 +180,7 @@ export class AvmSimulator { const revertReason = reverted ? await revertReasonFromExplicitRevert(output, this.context) : undefined; const results = new AvmContractCallResult(reverted, output, machineState.gasLeft, revertReason); this.log.debug(`Context execution results: ${results.toString()}`); + this.log.debug(`Executed ${instrCounter} instructions`); this.tallyPrintFunction(); // Return results for processing by calling context diff --git a/yarn-project/simulator/src/avm/journal/journal.ts b/yarn-project/simulator/src/avm/journal/journal.ts index f962f2aa3b8..87f93d97b45 100644 --- a/yarn-project/simulator/src/avm/journal/journal.ts +++ b/yarn-project/simulator/src/avm/journal/journal.ts @@ -124,13 +124,14 @@ export class AvmPersistableStateManager { this.publicStorage.acceptAndMerge(forkedState.publicStorage); this.nullifiers.acceptAndMerge(forkedState.nullifiers); this.trace.merge(forkedState.trace, reverted); - if (!reverted) { - this.merkleTrees = forkedState.merkleTrees; + if (reverted) { if (this.doMerkleOperations) { this.log.debug( `Rolled back nullifier tree to root ${this.merkleTrees.treeMap.get(MerkleTreeId.NULLIFIER_TREE)!.getRoot()}`, ); } + } else { + this.merkleTrees = forkedState.merkleTrees; } }