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

set read wrire addresses from final root #337

Merged
merged 3 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
27 changes: 22 additions & 5 deletions src/sm/sm_main/debug/full-tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
/* eslint-disable camelcase */
const fs = require('fs');
const path = require('path');
const { fea2scalar, fea2String } = require('@0xpolygonhermez/zkevm-commonjs').smtUtils;
const { Constants } = require('@0xpolygonhermez/zkevm-commonjs');
const { fea2scalar, fea2String, stringToH4 } = require('@0xpolygonhermez/zkevm-commonjs').smtUtils;
const { Constants, stateUtils } = require('@0xpolygonhermez/zkevm-commonjs');
const { ethers } = require('ethers');
const { Scalar } = require('ffjavascript');
const {
Expand Down Expand Up @@ -89,6 +89,7 @@ class FullTracer {
this.options = options;
this.setTracerOptions();

this.smt = smt;
this.verbose = new Verbose(options.verbose, smt, logFileName);
this.reservedCounters = reservedCounters;

Expand Down Expand Up @@ -143,6 +144,7 @@ class FullTracer {
try {
if (tag.params[0].varName === 'onFinishBatch') {
await this.printStates();
await this.fillInReadWriteAddresses();
}
} catch (e) {
console.log(e);
Expand Down Expand Up @@ -651,9 +653,6 @@ class FullTracer {
cnt_reserve_arithmetics: Number(this.reservedCounters.outOfCountersArith.reserved),
cnt_reserve_binaries: Number(this.reservedCounters.outOfCountersBinary.reserved),
};

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

/**
Expand Down Expand Up @@ -1002,6 +1001,24 @@ class FullTracer {
}
}

async fillInReadWriteAddresses() {
const keys = Object.keys(this.finalTrace.read_write_addresses);
const rootArray = stringToH4(this.finalTrace.new_state_root);

// get balance and noince
krlosMata marked this conversation as resolved.
Show resolved Hide resolved
for (const address of keys) {
// get balance & nonce
krlosMata marked this conversation as resolved.
Show resolved Hide resolved
const state = await stateUtils.getState(address, this.smt, rootArray);
this.finalTrace.read_write_addresses[address] = {
balance: Scalar.e(state.balance).toString(),
nonce: Number(Scalar.e(state.nonce)).toString(),
};
}

// Create output files and dirs
this.exportTrace();
krlosMata marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* Export the current trace to a file
*/
Expand Down
2 changes: 1 addition & 1 deletion tools/build-genesis/input_executor.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"oldNumBatch": 0,
"newNumBatch": 1,
"chainID": 1000,
"forkID": 8,
"forkID": 9,
"forcedBlockHashL1": "0x0000000000000000000000000000000000000000000000000000000000000000",
"batchL2Data": "0x0b73e6af6f00000000ee80843b9aca00830186a0944d5cf5032b2a844602278b01199ed191a86c93ff8829a2241af62c0000808203e8808030b042c001e60b5e93c5d20786896d6ee49161492162f0f2a06fbaa4e74e94d779539c219adbb6bacf96dd0d10a44b1e30cade645363216f77b7938c2437ed391cff",
"l1InfoRoot": "0x090bcaf734c4f06c93954a827b45a6e8c67b8e0fd1e0a35a1c5982d6961828f9",
Expand Down
Loading