Skip to content

Commit

Permalink
add flags BALANCE & GASPRICE
Browse files Browse the repository at this point in the history
  • Loading branch information
krlosMata committed Sep 19, 2023
1 parent 5c9ee65 commit 15c95ee
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
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

0 comments on commit 15c95ee

Please sign in to comment.