Skip to content

Commit

Permalink
Fix txIndex usage in FullTracer. Change version to v5.0.9.
Browse files Browse the repository at this point in the history
  • Loading branch information
fractasy committed Mar 23, 2024
1 parent a6f9edb commit 9c2c865
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/config/version.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef ZKEVM_PROVER_VERSION_HPP
#define ZKEVM_PROVER_VERSION_HPP

#define ZKEVM_PROVER_VERSION "v5.0.9-RC3"
#define ZKEVM_PROVER_VERSION "v5.0.9"

#endif
44 changes: 26 additions & 18 deletions src/main_sm/fork_8/main/full_tracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,17 +452,15 @@ zkresult FullTracer::onError(Context &ctx, const RomCommand &cmd)
if ( (responseErrors.find(lastError) != responseErrors.end()) ||
full_trace.empty() )
{
if (currentBlock.responses.size() > txIndex)
{
currentBlock.responses[txIndex].error = lastError;
}
else
if (currentBlock.responses.empty())
{
zklog.error("FullTracer::onError() got error=" + lastError + " with txIndex=" + to_string(txIndex) + " but currentBlock.responses.size()=" + to_string(currentBlock.responses.size()));
exitProcess();
}
currentBlock.responses[currentBlock.responses.size() - 1].error = lastError;

#ifdef LOG_FULL_TRACER_ON_ERROR
zklog.info("FullTracer::onError() 4 error=" + lastError + " zkPC=" + to_string(*ctx.pZKPC) + " rom=" + ctx.rom.line[*ctx.pZKPC].toString(ctx.fr) + " block=" + to_string(currentBlock.block_number) + " responses.size=" + to_string(currentBlock.responses.size()));
zklog.info("FullTracer::onError() 4 error=" + lastError + " zkPC=" + to_string(*ctx.pZKPC) + " rom=" + ctx.rom.line[*ctx.pZKPC].toString(ctx.fr) + " block=" + to_string(currentBlock.block_number) + " responses.size=" + to_string(currentBlock.responses.size()) + " txIndex=" + to_string(txIndex));
#endif
#ifdef LOG_TIME_STATISTICS
tms.add("onError", TimeDiff(t));
Expand Down Expand Up @@ -514,7 +512,7 @@ zkresult FullTracer::onError(ContextC &ctxc, const string &error)
lastErrorOpcode = numberOfOpcodesInThisTx;

// Intrinsic error should be set at tx level (not opcode)
if ( (responseErrors.find(lastError) != responseErrors.end()) ||
/*if ( (responseErrors.find(lastError) != responseErrors.end()) ||
(full_trace.size() == 0) )
{
if (currentBlock.responses.size() > txIndex)
Expand All @@ -540,7 +538,7 @@ zkresult FullTracer::onError(ContextC &ctxc, const string &error)
}
// Revert logs
/*uint64_t CTX = ctx.fr.toU64(ctx.pols.CTX[*ctx.pStep]);
uint64_t CTX = ctx.fr.toU64(ctx.pols.CTX[*ctx.pStep]);
mpz_class auxScalar;
zkr = getVarFromCtx(ctx, true, ctx.rom.lastCtxUsedOffset, auxScalar);
if (zkr != ZKR_SUCCESS)
Expand Down Expand Up @@ -642,8 +640,13 @@ zkresult FullTracer::onStoreLog (Context &ctx, const RomCommand &cmd)
return zkr;
}
it->second.block_number = auxScalar.get_ui();
it->second.tx_hash = currentBlock.responses[txIndex].tx_hash;
it->second.tx_hash_l2 = currentBlock.responses[txIndex].tx_hash_l2;
if (currentBlock.responses.empty())
{
zklog.error("FullTracer::onStoreLog() found currentBlock.responses empty");
exitProcess();
}
it->second.tx_hash = currentBlock.responses[currentBlock.responses.size() - 1].tx_hash;
it->second.tx_hash_l2 = currentBlock.responses[currentBlock.responses.size() - 1].tx_hash_l2;
it->second.tx_index = txIndex;
it->second.index = indexLog;

Expand Down Expand Up @@ -1509,7 +1512,7 @@ zkresult FullTracer::onFinishTx(Context &ctx, const RomCommand &cmd)
}

zkresult zkr;
ResponseV2 &response = currentBlock.responses[txIndex];
ResponseV2 &response = currentBlock.responses[currentBlock.responses.size() - 1];

// Set from address
mpz_class fromScalar;
Expand Down Expand Up @@ -1658,9 +1661,6 @@ zkresult FullTracer::onFinishTx(Context &ctx, const RomCommand &cmd)
currentBlock.responses[currentBlock.responses.size() - 1].has_gasprice_opcode = hasGaspriceOpcode;
currentBlock.responses[currentBlock.responses.size() - 1].has_balance_opcode = hasBalanceOpcode;

// Increase transaction index
txIndex++;

// Check TX status
if ((responseErrors.find(response.error) == responseErrors.end()) &&
( (response.error.empty() && (response.status == 0)) ||
Expand Down Expand Up @@ -1723,6 +1723,7 @@ zkresult FullTracer::onFinishTx (ContextC &ctxc)
gettimeofday(&t, NULL);
#endif
//zkresult zkr;
#if 0
ResponseV2 &response = currentBlock.responses[txIndex];

// Set from address
Expand All @@ -1734,7 +1735,6 @@ zkresult FullTracer::onFinishTx (ContextC &ctxc)
response.gas_used = ctxc.batch.tx[ctxc.tx].gas.get_ui();
response.full_trace.context.gas_used = response.gas_used;
accBatchGas += response.gas_used;
/*

// Set return data always; get it from memory
{
Expand Down Expand Up @@ -1779,7 +1779,7 @@ zkresult FullTracer::onFinishTx (ContextC &ctxc)

// Set gas left
response.gas_left -= response.gas_used;
*/

// Set new State Root
fea2scalar(ctxc.fr, auxScalar, ctxc.root);
response.state_root = NormalizeTo0xNFormat(auxScalar.get_str(16), 64);
Expand Down Expand Up @@ -1865,6 +1865,9 @@ zkresult FullTracer::onFinishTx (ContextC &ctxc)
#ifdef LOG_FULL_TRACER
//zklog.info("FullTracer::onFinishTx() txCount=" + to_string(txCount) + " finalTrace.responses.size()=" + to_string(finalTrace.responses.size()) + " create_address=" + response.create_address + " state_root=" + response.state_root);
#endif

#endif

#ifdef LOG_TIME_STATISTICS
tms.add("onFinishTx", TimeDiff(t));
#endif
Expand Down Expand Up @@ -2186,8 +2189,13 @@ zkresult FullTracer::onOpcode(Context &ctx, const RomCommand &cmd)
return zkr;
}
it->second.block_number = auxScalar.get_ui();
it->second.tx_hash = currentBlock.responses[txIndex].tx_hash;
it->second.tx_hash_l2 = currentBlock.responses[txIndex].tx_hash_l2;
if (currentBlock.responses.empty())
{
zklog.error("FullTracer::onOpcode() found currentBlock.responses empty");
exitProcess();
}
it->second.tx_hash = currentBlock.responses[currentBlock.responses.size() - 1].tx_hash;
it->second.tx_hash_l2 = currentBlock.responses[currentBlock.responses.size() - 1].tx_hash_l2;
it->second.tx_index = txIndex;
it->second.index = indexLog;
}
Expand Down

0 comments on commit 9c2c865

Please sign in to comment.