Skip to content

Commit

Permalink
Fix async events
Browse files Browse the repository at this point in the history
  • Loading branch information
ignasirv committed May 8, 2024
1 parent f3c1504 commit ac631c2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-mocha": "^10.1.0",
"mocha": "^9.1.3",
"@0xpolygonhermez/zkevm-rom": "github:0xPolygonHermez/zkevm-rom#v7.0.0-rc.1-fork.10",
"@0xpolygonhermez/zkevm-rom": "github:0xPolygonHermez/zkevm-rom#develop-feijoa",
"@0xpolygonhermez/zkevm-storage-rom": "https://github.com/0xPolygonHermez/zkevm-storage-rom.git#v4.0.0-fork.7",
"@0xpolygonhermez/zkevm-blob-rom": "github:0xPolygonHermez/zkevm-blob-rom#develop-feijoa",
"@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#develop-feijoa"
Expand Down
16 changes: 9 additions & 7 deletions src/sm/sm_main/debug/full-tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ class FullTracer {
handleEvent(ctx, tag) {
try {
const func = this[tag.params[0].varName];

if (func && typeof func === 'function') {
// Do not call onFinishBatch because it is called later asynchronously
if (func && typeof func === 'function' && tag.params[0].varName !== 'onFinishBatch') {
this[tag.params[0].varName](ctx, tag);
} else if (tag.funcName === 'storeLog') {
this.onStoreLog(ctx, tag);
Expand All @@ -144,7 +144,7 @@ class FullTracer {
try {
if (tag.params[0].varName === 'onFinishBatch') {
await this.printStates();
await this.fillInReadWriteAddresses();
await this.onFinishBatch(ctx);
}
} catch (e) {
console.log(e);
Expand Down Expand Up @@ -598,7 +598,7 @@ class FullTracer {
* @param {Object} ctx Current context object
* @param {Object} tag to identify the log values
*/
onFinishBatch(ctx) {
async onFinishBatch(ctx) {
this.finalTrace.gas_used = String(this.accBatchGas);
this.finalTrace.cnt_arithmetics = Number(ctx.cntArith);
this.finalTrace.cnt_binaries = Number(ctx.cntBinary);
Expand Down Expand Up @@ -655,6 +655,11 @@ class FullTracer {
cnt_reserve_arithmetics: Number(this.reservedCounters.outOfCountersArith.reserved),
cnt_reserve_binaries: Number(this.reservedCounters.outOfCountersBinary.reserved),
};

await this.fillInReadWriteAddresses();

// Create output files and dirs
this.exportTrace();
}

/**
Expand Down Expand Up @@ -1015,9 +1020,6 @@ class FullTracer {
nonce: Number(Scalar.e(state.nonce)).toString(),
};
}

// Create output files and dirs
this.exportTrace();
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/sm/sm_main/sm_main_exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,9 @@ module.exports = async function execute(pols, input, rom, config = {}, metadata
for (let j=0; j< l.cmdBefore.length; j++) {
evalCommand(ctx, l.cmdBefore[j]);
}
if (fullTracer){
await eventsAsyncTracer(ctx, l.cmdBefore);
}
}

// print external logs
Expand Down

0 comments on commit ac631c2

Please sign in to comment.