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

add flags BALANCE & GASPRICE #214

Merged
merged 1 commit into from
Sep 21, 2023
Merged
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 @@ -118,7 +118,7 @@
"license": "UNLICENSED",
"dependencies": {
"@0xpolygonhermez/zkasmcom": "https://github.com/0xPolygonHermez/zkasmcom.git#v1.0.0",
"@0xpolygonhermez/zkevm-commonjs": "https://github.com/0xpolygonhermez/zkevm-commonjs.git#v1.1.0-rc.4",
"@0xpolygonhermez/zkevm-commonjs": "https://github.com/0xPolygonHermez/zkevm-commonjs.git#v2.0.0-fork.5",
"@0xpolygonhermez/zkevm-rom": "https://github.com/0xPolygonHermez/zkevm-rom.git#v1.1.0-fork.4",
"@0xpolygonhermez/zkevm-storage-rom": "https://github.com/0xPolygonHermez/zkevm-storage-rom.git#v1.0.0-fork.3",
"@grpc/grpc-js": "^1.8.14",
Expand Down
21 changes: 21 additions & 0 deletions src/sm/sm_main/debug/full-tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ class FullTracer {
// Opcode step traces of all processed tx
this.call_trace = [];
this.execution_trace = [];

// Track opcodes called
this.hasGaspriceOpcode = false;
this.hasBalanceOpcode = false;

// Logs path
this.folderLogs = path.join(__dirname, '../logs-full-trace');
this.pathLogFile = `${this.folderLogs}/${logFileName.split('.')[0]}__full_trace`;
Expand Down Expand Up @@ -377,6 +382,10 @@ class FullTracer {
}
}

// set flags has_gasprice_opcode and has_balance_opcode
this.finalTrace.responses[this.finalTrace.responses.length - 1].has_gasprice_opcode = this.hasGaspriceOpcode;
this.finalTrace.responses[this.finalTrace.responses.length - 1].has_balance_opcode = this.hasBalanceOpcode;

// Append logs correctly formatted to response logs
this.logs = this.logs.filter((n) => n); // Remove null values
// Put all logs in an array
Expand Down Expand Up @@ -414,6 +423,8 @@ class FullTracer {
this.execution_trace = [];
this.logs = [];
this.callData = [];
this.hasGaspriceOpcode = false;
this.hasBalanceOpcode = false;
}

/**
Expand Down Expand Up @@ -516,6 +527,16 @@ class FullTracer {
}
const opcode = codes[codeId][0];

// set flag 'has_gasprice_opcode' if opcode is GASPRICE
if (this.hasGaspriceOpcode === false && opcode === 'GASPRICE') {
this.hasGaspriceOpcode = true;
}

// set flag 'has_balance_opcode' if opcode is BALANCE
if (this.hasBalanceOpcode === false && opcode === 'BALANCE') {
this.hasBalanceOpcode = true;
}

// store memory
const offsetCtx = Number(ctx.CTX) * 0x40000;
let addrMem = 0;
Expand Down