Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix async events #344

Open
wants to merge 1 commit into
base: develop-feijoa
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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