From fed19566ceaab486abe57d87640aa5f1d785c45d Mon Sep 17 00:00:00 2001 From: fractasy Date: Wed, 17 Apr 2024 15:52:18 +0000 Subject: [PATCH] Call fillInReadWriteAddresses() from FullTracer::onFinishBatch() in all forks --- src/config/version.hpp | 2 +- src/main_sm/fork_1/main/full_tracer.cpp | 20 +++++++++++++++++--- src/main_sm/fork_2/main/full_tracer.cpp | 20 +++++++++++++++++--- src/main_sm/fork_3/main/full_tracer.cpp | 20 +++++++++++++++++--- src/main_sm/fork_4/main/full_tracer.cpp | 25 ++++++++++++++++++++++--- src/main_sm/fork_5/main/full_tracer.cpp | 25 ++++++++++++++++++++++--- src/main_sm/fork_6/main/full_tracer.cpp | 25 ++++++++++++++++++++++--- src/main_sm/fork_7/main/full_tracer.cpp | 25 ++++++++++++++++++++++--- src/main_sm/fork_8/main/full_tracer.cpp | 25 ++++++++++++++++++++++--- src/main_sm/fork_9/main/full_tracer.cpp | 25 ++++++++++++++++++++++--- 10 files changed, 184 insertions(+), 28 deletions(-) diff --git a/src/config/version.hpp b/src/config/version.hpp index fc0972dbb..275684408 100644 --- a/src/config/version.hpp +++ b/src/config/version.hpp @@ -1,6 +1,6 @@ #ifndef ZKEVM_PROVER_VERSION_HPP #define ZKEVM_PROVER_VERSION_HPP -#define ZKEVM_PROVER_VERSION "v6.0.2-RC1" +#define ZKEVM_PROVER_VERSION "v6.0.2-RC2" #endif diff --git a/src/main_sm/fork_1/main/full_tracer.cpp b/src/main_sm/fork_1/main/full_tracer.cpp index e84994fbb..81a23db2d 100644 --- a/src/main_sm/fork_1/main/full_tracer.cpp +++ b/src/main_sm/fork_1/main/full_tracer.cpp @@ -858,6 +858,9 @@ void FullTracer::onFinishBatch(Context &ctx, const RomCommand &cmd) // getVarFromCtx(ctx, true, "newNumBatch", auxScalar); // finalTrace.new_batch_num = auxScalar.get_ui(); + // Call fillInReadWriteAddresses + fillInReadWriteAddresses(ctx); + #ifdef LOG_FULL_TRACER zklog.info("FullTracer::onFinishBatch() new_state_root=" + finalTrace.new_state_root); #endif @@ -1333,6 +1336,8 @@ void FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, cons gettimeofday(&t, NULL); #endif + zkassert(!fr.isZero(key[0]) || !fr.isZero(key[1]) || !fr.isZero(key[2]) || !fr.isZero(key[3])); + // Get address mpz_class address; fea2scalar(fr, address, address0, address1, address2, address3, address4, address5, address6, address7); @@ -1359,6 +1364,10 @@ void FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, cons else { it->second.balance = value.get_str(); + it->second.balanceKey[0]= key[0]; + it->second.balanceKey[1]= key[1]; + it->second.balanceKey[2]= key[2]; + it->second.balanceKey[3]= key[3]; } } else if (keyType == SMT_KEY_NONCE) @@ -1377,6 +1386,10 @@ void FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, cons else { it->second.nonce = value.get_str(); + it->second.nonceKey[0]= key[0]; + it->second.nonceKey[1]= key[1]; + it->second.nonceKey[2]= key[2]; + it->second.nonceKey[3]= key[3]; } } @@ -1389,13 +1402,14 @@ zkresult FullTracer::fillInReadWriteAddresses (Context &ctx) { zkresult zkr; + // Get new state root fea + Goldilocks::Element newStateRoot[4]; + string2fea(fr, NormalizeToNFormat(finalTrace.new_state_root, 64), newStateRoot); + // For all entries in read_write_addresses unordered_map::iterator it; for (it = read_write_addresses.begin(); it != read_write_addresses.end(); it++) { - Goldilocks::Element newStateRoot[4]; - string2fea(fr, finalTrace.new_state_root, newStateRoot); - // Re-read balance for this state root if (!it->second.balance.empty()) { diff --git a/src/main_sm/fork_2/main/full_tracer.cpp b/src/main_sm/fork_2/main/full_tracer.cpp index 9757bf6e6..126a6820f 100644 --- a/src/main_sm/fork_2/main/full_tracer.cpp +++ b/src/main_sm/fork_2/main/full_tracer.cpp @@ -862,6 +862,9 @@ void FullTracer::onFinishBatch(Context &ctx, const RomCommand &cmd) // getVarFromCtx(ctx, true, "newNumBatch", auxScalar); // finalTrace.new_batch_num = auxScalar.get_ui(); + // Call fillInReadWriteAddresses + fillInReadWriteAddresses(ctx); + #ifdef LOG_FULL_TRACER zklog.info("FullTracer::onFinishBatch() new_state_root=" + finalTrace.new_state_root); #endif @@ -1337,6 +1340,8 @@ void FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, cons gettimeofday(&t, NULL); #endif + zkassert(!fr.isZero(key[0]) || !fr.isZero(key[1]) || !fr.isZero(key[2]) || !fr.isZero(key[3])); + // Get address mpz_class address; fea2scalar(fr, address, address0, address1, address2, address3, address4, address5, address6, address7); @@ -1363,6 +1368,10 @@ void FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, cons else { it->second.balance = value.get_str(); + it->second.balanceKey[0]= key[0]; + it->second.balanceKey[1]= key[1]; + it->second.balanceKey[2]= key[2]; + it->second.balanceKey[3]= key[3]; } } else if (keyType == SMT_KEY_NONCE) @@ -1381,6 +1390,10 @@ void FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, cons else { it->second.nonce = value.get_str(); + it->second.nonceKey[0]= key[0]; + it->second.nonceKey[1]= key[1]; + it->second.nonceKey[2]= key[2]; + it->second.nonceKey[3]= key[3]; } } @@ -1393,13 +1406,14 @@ zkresult FullTracer::fillInReadWriteAddresses (Context &ctx) { zkresult zkr; + // Get new state root fea + Goldilocks::Element newStateRoot[4]; + string2fea(fr, NormalizeToNFormat(finalTrace.new_state_root, 64), newStateRoot); + // For all entries in read_write_addresses unordered_map::iterator it; for (it = read_write_addresses.begin(); it != read_write_addresses.end(); it++) { - Goldilocks::Element newStateRoot[4]; - string2fea(fr, finalTrace.new_state_root, newStateRoot); - // Re-read balance for this state root if (!it->second.balance.empty()) { diff --git a/src/main_sm/fork_3/main/full_tracer.cpp b/src/main_sm/fork_3/main/full_tracer.cpp index 46b957e81..635956b1d 100644 --- a/src/main_sm/fork_3/main/full_tracer.cpp +++ b/src/main_sm/fork_3/main/full_tracer.cpp @@ -862,6 +862,9 @@ void FullTracer::onFinishBatch(Context &ctx, const RomCommand &cmd) // getVarFromCtx(ctx, true, "newNumBatch", auxScalar); // finalTrace.new_batch_num = auxScalar.get_ui(); + // Call fillInReadWriteAddresses + fillInReadWriteAddresses(ctx); + #ifdef LOG_FULL_TRACER zklog.info("FullTracer::onFinishBatch() new_state_root=" + finalTrace.new_state_root); #endif @@ -1337,6 +1340,8 @@ void FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, cons gettimeofday(&t, NULL); #endif + zkassert(!fr.isZero(key[0]) || !fr.isZero(key[1]) || !fr.isZero(key[2]) || !fr.isZero(key[3])); + // Get address mpz_class address; fea2scalar(fr, address, address0, address1, address2, address3, address4, address5, address6, address7); @@ -1363,6 +1368,10 @@ void FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, cons else { it->second.balance = value.get_str(); + it->second.balanceKey[0]= key[0]; + it->second.balanceKey[1]= key[1]; + it->second.balanceKey[2]= key[2]; + it->second.balanceKey[3]= key[3]; } } else if (keyType == SMT_KEY_NONCE) @@ -1381,6 +1390,10 @@ void FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, cons else { it->second.nonce = value.get_str(); + it->second.nonceKey[0]= key[0]; + it->second.nonceKey[1]= key[1]; + it->second.nonceKey[2]= key[2]; + it->second.nonceKey[3]= key[3]; } } @@ -1393,13 +1406,14 @@ zkresult FullTracer::fillInReadWriteAddresses (Context &ctx) { zkresult zkr; + // Get new state root fea + Goldilocks::Element newStateRoot[4]; + string2fea(fr, NormalizeToNFormat(finalTrace.new_state_root, 64), newStateRoot); + // For all entries in read_write_addresses unordered_map::iterator it; for (it = read_write_addresses.begin(); it != read_write_addresses.end(); it++) { - Goldilocks::Element newStateRoot[4]; - string2fea(fr, finalTrace.new_state_root, newStateRoot); - // Re-read balance for this state root if (!it->second.balance.empty()) { diff --git a/src/main_sm/fork_4/main/full_tracer.cpp b/src/main_sm/fork_4/main/full_tracer.cpp index 10da9acf9..e7538c01a 100644 --- a/src/main_sm/fork_4/main/full_tracer.cpp +++ b/src/main_sm/fork_4/main/full_tracer.cpp @@ -1026,6 +1026,14 @@ zkresult FullTracer::onFinishBatch(Context &ctx, const RomCommand &cmd) // getVarFromCtx(ctx, true, "newNumBatch", auxScalar); // finalTrace.new_batch_num = auxScalar.get_ui(); + // Call fillInReadWriteAddresses + zkr = fillInReadWriteAddresses(ctx); + if (zkr != ZKR_SUCCESS) + { + zklog.error("FullTracer::onFinishBatch() failed calling fillInReadWriteAddresses()"); + return zkr; + } + #ifdef LOG_FULL_TRACER zklog.info("FullTracer::onFinishBatch() new_state_root=" + finalTrace.new_state_root); #endif @@ -1655,6 +1663,8 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, gettimeofday(&t, NULL); #endif + zkassert(!fr.isZero(key[0]) || !fr.isZero(key[1]) || !fr.isZero(key[2]) || !fr.isZero(key[3])); + // Get address mpz_class address; if (!fea2scalar(fr, address, address0, address1, address2, address3, address4, address5, address6, address7)) @@ -1689,6 +1699,10 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, else { it->second.balance = value.get_str(); + it->second.balanceKey[0]= key[0]; + it->second.balanceKey[1]= key[1]; + it->second.balanceKey[2]= key[2]; + it->second.balanceKey[3]= key[3]; } } else if (keyType == SMT_KEY_NONCE) @@ -1707,6 +1721,10 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, else { it->second.nonce = value.get_str(); + it->second.nonceKey[0]= key[0]; + it->second.nonceKey[1]= key[1]; + it->second.nonceKey[2]= key[2]; + it->second.nonceKey[3]= key[3]; } } @@ -1721,13 +1739,14 @@ zkresult FullTracer::fillInReadWriteAddresses (Context &ctx) { zkresult zkr; + // Get new state root fea + Goldilocks::Element newStateRoot[4]; + string2fea(fr, NormalizeToNFormat(finalTrace.new_state_root, 64), newStateRoot); + // For all entries in read_write_addresses unordered_map::iterator it; for (it = read_write_addresses.begin(); it != read_write_addresses.end(); it++) { - Goldilocks::Element newStateRoot[4]; - string2fea(fr, finalTrace.new_state_root, newStateRoot); - // Re-read balance for this state root if (!it->second.balance.empty()) { diff --git a/src/main_sm/fork_5/main/full_tracer.cpp b/src/main_sm/fork_5/main/full_tracer.cpp index 45d5fc265..5c80e5f60 100644 --- a/src/main_sm/fork_5/main/full_tracer.cpp +++ b/src/main_sm/fork_5/main/full_tracer.cpp @@ -1065,6 +1065,14 @@ zkresult FullTracer::onFinishBatch(Context &ctx, const RomCommand &cmd) // getVarFromCtx(ctx, true, "newNumBatch", auxScalar); // finalTrace.new_batch_num = auxScalar.get_ui(); + // Call fillInReadWriteAddresses + zkr = fillInReadWriteAddresses(ctx); + if (zkr != ZKR_SUCCESS) + { + zklog.error("FullTracer::onFinishBatch() failed calling fillInReadWriteAddresses()"); + return zkr; + } + #ifdef LOG_FULL_TRACER zklog.info("FullTracer::onFinishBatch() new_state_root=" + finalTrace.new_state_root); #endif @@ -1718,6 +1726,8 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, gettimeofday(&t, NULL); #endif + zkassert(!fr.isZero(key[0]) || !fr.isZero(key[1]) || !fr.isZero(key[2]) || !fr.isZero(key[3])); + // Get address mpz_class address; if (!fea2scalar(fr, address, address0, address1, address2, address3, address4, address5, address6, address7)) @@ -1752,6 +1762,10 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, else { it->second.balance = value.get_str(); + it->second.balanceKey[0]= key[0]; + it->second.balanceKey[1]= key[1]; + it->second.balanceKey[2]= key[2]; + it->second.balanceKey[3]= key[3]; } } else if (keyType == SMT_KEY_NONCE) @@ -1770,6 +1784,10 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, else { it->second.nonce = value.get_str(); + it->second.nonceKey[0]= key[0]; + it->second.nonceKey[1]= key[1]; + it->second.nonceKey[2]= key[2]; + it->second.nonceKey[3]= key[3]; } } @@ -1784,13 +1802,14 @@ zkresult FullTracer::fillInReadWriteAddresses (Context &ctx) { zkresult zkr; + // Get new state root fea + Goldilocks::Element newStateRoot[4]; + string2fea(fr, NormalizeToNFormat(finalTrace.new_state_root, 64), newStateRoot); + // For all entries in read_write_addresses unordered_map::iterator it; for (it = read_write_addresses.begin(); it != read_write_addresses.end(); it++) { - Goldilocks::Element newStateRoot[4]; - string2fea(fr, finalTrace.new_state_root, newStateRoot); - // Re-read balance for this state root if (!it->second.balance.empty()) { diff --git a/src/main_sm/fork_6/main/full_tracer.cpp b/src/main_sm/fork_6/main/full_tracer.cpp index 8a4cc9b1f..daeabe36d 100644 --- a/src/main_sm/fork_6/main/full_tracer.cpp +++ b/src/main_sm/fork_6/main/full_tracer.cpp @@ -1065,6 +1065,14 @@ zkresult FullTracer::onFinishBatch(Context &ctx, const RomCommand &cmd) // getVarFromCtx(ctx, true, "newNumBatch", auxScalar); // finalTrace.new_batch_num = auxScalar.get_ui(); + // Call fillInReadWriteAddresses + zkr = fillInReadWriteAddresses(ctx); + if (zkr != ZKR_SUCCESS) + { + zklog.error("FullTracer::onFinishBatch() failed calling fillInReadWriteAddresses()"); + return zkr; + } + #ifdef LOG_FULL_TRACER zklog.info("FullTracer::onFinishBatch() new_state_root=" + finalTrace.new_state_root); #endif @@ -1718,6 +1726,8 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, gettimeofday(&t, NULL); #endif + zkassert(!fr.isZero(key[0]) || !fr.isZero(key[1]) || !fr.isZero(key[2]) || !fr.isZero(key[3])); + // Get address mpz_class address; if (!fea2scalar(fr, address, address0, address1, address2, address3, address4, address5, address6, address7)) @@ -1752,6 +1762,10 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, else { it->second.balance = value.get_str(); + it->second.balanceKey[0]= key[0]; + it->second.balanceKey[1]= key[1]; + it->second.balanceKey[2]= key[2]; + it->second.balanceKey[3]= key[3]; } } else if (keyType == SMT_KEY_NONCE) @@ -1770,6 +1784,10 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, else { it->second.nonce = value.get_str(); + it->second.nonceKey[0]= key[0]; + it->second.nonceKey[1]= key[1]; + it->second.nonceKey[2]= key[2]; + it->second.nonceKey[3]= key[3]; } } @@ -1784,13 +1802,14 @@ zkresult FullTracer::fillInReadWriteAddresses (Context &ctx) { zkresult zkr; + // Get new state root fea + Goldilocks::Element newStateRoot[4]; + string2fea(fr, NormalizeToNFormat(finalTrace.new_state_root, 64), newStateRoot); + // For all entries in read_write_addresses unordered_map::iterator it; for (it = read_write_addresses.begin(); it != read_write_addresses.end(); it++) { - Goldilocks::Element newStateRoot[4]; - string2fea(fr, finalTrace.new_state_root, newStateRoot); - // Re-read balance for this state root if (!it->second.balance.empty()) { diff --git a/src/main_sm/fork_7/main/full_tracer.cpp b/src/main_sm/fork_7/main/full_tracer.cpp index 01de6b31f..04d80e2fe 100644 --- a/src/main_sm/fork_7/main/full_tracer.cpp +++ b/src/main_sm/fork_7/main/full_tracer.cpp @@ -1427,6 +1427,14 @@ zkresult FullTracer::onFinishBatch(Context &ctx, const RomCommand &cmd) // getVarFromCtx(ctx, true, "newNumBatch", auxScalar); // finalTrace.new_batch_num = auxScalar.get_ui(); + // Call fillInReadWriteAddresses + zkr = fillInReadWriteAddresses(ctx); + if (zkr != ZKR_SUCCESS) + { + zklog.error("FullTracer::onFinishBatch() failed calling fillInReadWriteAddresses()"); + return zkr; + } + #ifdef LOG_FULL_TRACER zklog.info("FullTracer::onFinishBatch() new_state_root=" + finalTrace.new_state_root); #endif @@ -2080,6 +2088,8 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, gettimeofday(&t, NULL); #endif + zkassert(!fr.isZero(key[0]) || !fr.isZero(key[1]) || !fr.isZero(key[2]) || !fr.isZero(key[3])); + // Get address mpz_class address; if (!fea2scalar(fr, address, address0, address1, address2, address3, address4, address5, address6, address7)) @@ -2114,6 +2124,10 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, else { it->second.balance = value.get_str(); + it->second.balanceKey[0]= key[0]; + it->second.balanceKey[1]= key[1]; + it->second.balanceKey[2]= key[2]; + it->second.balanceKey[3]= key[3]; } } else if (keyType == SMT_KEY_NONCE) @@ -2132,6 +2146,10 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, else { it->second.nonce = value.get_str(); + it->second.nonceKey[0]= key[0]; + it->second.nonceKey[1]= key[1]; + it->second.nonceKey[2]= key[2]; + it->second.nonceKey[3]= key[3]; } } @@ -2146,13 +2164,14 @@ zkresult FullTracer::fillInReadWriteAddresses (Context &ctx) { zkresult zkr; + // Get new state root fea + Goldilocks::Element newStateRoot[4]; + string2fea(fr, NormalizeToNFormat(finalTrace.new_state_root, 64), newStateRoot); + // For all entries in read_write_addresses unordered_map::iterator it; for (it = read_write_addresses.begin(); it != read_write_addresses.end(); it++) { - Goldilocks::Element newStateRoot[4]; - string2fea(fr, finalTrace.new_state_root, newStateRoot); - // Re-read balance for this state root if (!it->second.balance.empty()) { diff --git a/src/main_sm/fork_8/main/full_tracer.cpp b/src/main_sm/fork_8/main/full_tracer.cpp index 312908ae1..fcab9555e 100644 --- a/src/main_sm/fork_8/main/full_tracer.cpp +++ b/src/main_sm/fork_8/main/full_tracer.cpp @@ -1989,6 +1989,14 @@ zkresult FullTracer::onFinishBatch(Context &ctx, const RomCommand &cmd) // getVarFromCtx(ctx, true, "newNumBatch", auxScalar); // finalTrace.new_batch_num = auxScalar.get_ui(); + // Call fillInReadWriteAddresses + zkr = fillInReadWriteAddresses(ctx); + if (zkr != ZKR_SUCCESS) + { + zklog.error("FullTracer::onFinishBatch() failed calling fillInReadWriteAddresses()"); + return zkr; + } + #ifdef LOG_FULL_TRACER zklog.info("FullTracer::onFinishBatch() new_state_root=" + finalTrace.new_state_root); #endif @@ -2771,6 +2779,8 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, gettimeofday(&t, NULL); #endif + zkassert(!fr.isZero(key[0]) || !fr.isZero(key[1]) || !fr.isZero(key[2]) || !fr.isZero(key[3])); + // Get address mpz_class address; if (!fea2scalar(fr, address, address0, address1, address2, address3, address4, address5, address6, address7)) @@ -2805,6 +2815,10 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, else { it->second.balance = value.get_str(); + it->second.balanceKey[0]= key[0]; + it->second.balanceKey[1]= key[1]; + it->second.balanceKey[2]= key[2]; + it->second.balanceKey[3]= key[3]; } } else if (keyType == SMT_KEY_NONCE) @@ -2823,6 +2837,10 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, else { it->second.nonce = value.get_str(); + it->second.nonceKey[0]= key[0]; + it->second.nonceKey[1]= key[1]; + it->second.nonceKey[2]= key[2]; + it->second.nonceKey[3]= key[3]; } } else if (keyType == SMT_KEY_SC_CODE) @@ -2887,13 +2905,14 @@ zkresult FullTracer::fillInReadWriteAddresses (Context &ctx) { zkresult zkr; + // Get new state root fea + Goldilocks::Element newStateRoot[4]; + string2fea(fr, NormalizeToNFormat(finalTrace.new_state_root, 64), newStateRoot); + // For all entries in read_write_addresses unordered_map::iterator it; for (it = read_write_addresses.begin(); it != read_write_addresses.end(); it++) { - Goldilocks::Element newStateRoot[4]; - string2fea(fr, finalTrace.new_state_root, newStateRoot); - // Re-read balance for this state root if (!it->second.balance.empty()) { diff --git a/src/main_sm/fork_9/main/full_tracer.cpp b/src/main_sm/fork_9/main/full_tracer.cpp index 7ccb75e75..112615bf3 100644 --- a/src/main_sm/fork_9/main/full_tracer.cpp +++ b/src/main_sm/fork_9/main/full_tracer.cpp @@ -1455,6 +1455,14 @@ zkresult FullTracer::onFinishBatch(Context &ctx, const RomCommand &cmd) // getVarFromCtx(ctx, true, "newNumBatch", auxScalar); // finalTrace.new_batch_num = auxScalar.get_ui(); + // Call fillInReadWriteAddresses + zkr = fillInReadWriteAddresses(ctx); + if (zkr != ZKR_SUCCESS) + { + zklog.error("FullTracer::onFinishBatch() failed calling fillInReadWriteAddresses()"); + return zkr; + } + #ifdef LOG_FULL_TRACER zklog.info("FullTracer::onFinishBatch() new_state_root=" + finalTrace.new_state_root); #endif @@ -2178,6 +2186,8 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, gettimeofday(&t, NULL); #endif + zkassert(!fr.isZero(key[0]) || !fr.isZero(key[1]) || !fr.isZero(key[2]) || !fr.isZero(key[3])); + // Get address mpz_class address; if (!fea2scalar(fr, address, address0, address1, address2, address3, address4, address5, address6, address7)) @@ -2212,6 +2222,10 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, else { it->second.balance = value.get_str(); + it->second.balanceKey[0]= key[0]; + it->second.balanceKey[1]= key[1]; + it->second.balanceKey[2]= key[2]; + it->second.balanceKey[3]= key[3]; } } else if (keyType == SMT_KEY_NONCE) @@ -2230,6 +2244,10 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, else { it->second.nonce = value.get_str(); + it->second.nonceKey[0]= key[0]; + it->second.nonceKey[1]= key[1]; + it->second.nonceKey[2]= key[2]; + it->second.nonceKey[3]= key[3]; } } else if (keyType == SMT_KEY_SC_CODE) @@ -2294,13 +2312,14 @@ zkresult FullTracer::fillInReadWriteAddresses (Context &ctx) { zkresult zkr; + // Get new state root fea + Goldilocks::Element newStateRoot[4]; + string2fea(fr, NormalizeToNFormat(finalTrace.new_state_root, 64), newStateRoot); + // For all entries in read_write_addresses unordered_map::iterator it; for (it = read_write_addresses.begin(); it != read_write_addresses.end(); it++) { - Goldilocks::Element newStateRoot[4]; - string2fea(fr, finalTrace.new_state_root, newStateRoot); - // Re-read balance for this state root if (!it->second.balance.empty()) {