From ab4959951f781bb8c385445c73f71bea3feaff05 Mon Sep 17 00:00:00 2001 From: dbanks12 Date: Wed, 8 Jan 2025 19:39:44 +0000 Subject: [PATCH] chore: log number of instructions executed for call in AVM. Misc fix. --- 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 fff7f7d7fd57..a69aa0893774 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 f962f2aa3b8b..87f93d97b451 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; } }