From 7f9130215cde5218dc4cb68ab23c43cab570986e Mon Sep 17 00:00:00 2001 From: fractasy Date: Wed, 13 Mar 2024 16:19:16 +0000 Subject: [PATCH] Fix logs in internal calls in FullTracer --- src/config/version.hpp | 2 +- src/main_sm/fork_8/main/full_tracer.cpp | 65 +++++++++++++---------- src/service/executor/executor_service.cpp | 8 +++ 3 files changed, 45 insertions(+), 30 deletions(-) diff --git a/src/config/version.hpp b/src/config/version.hpp index f893a4178..683048e70 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 "v5.0.7-RC1" +#define ZKEVM_PROVER_VERSION "v5.0.7" #endif diff --git a/src/main_sm/fork_8/main/full_tracer.cpp b/src/main_sm/fork_8/main/full_tracer.cpp index cfa98eedc..e6df8cf1e 100644 --- a/src/main_sm/fork_8/main/full_tracer.cpp +++ b/src/main_sm/fork_8/main/full_tracer.cpp @@ -914,49 +914,32 @@ zkresult FullTracer::onFinishBlock (Context &ctx) // Clear logs currentBlock.logs.clear(); - // Order all logs (from all CTX) in order of index map auxLogs; - map>::iterator logIt; - map::const_iterator it; - for (logIt=logs.begin(); logIt!=logs.end(); logIt++) + + // Add blockhash to all logs on every tx, and add logs to block response + for (uint64_t r = 0; r < currentBlock.responses.size(); r++) { - for (it = logIt->second.begin(); it != logIt->second.end(); it++) + // Set block hash to all txs of block + currentBlock.responses[r].block_hash = currentBlock.block_hash; + currentBlock.responses[r].block_number = currentBlock.block_number; + + for (uint64_t l = 0; l < currentBlock.responses[r].logs.size(); l++) { - auxLogs[it->second.index] = it->second; + currentBlock.responses[r].logs[l].block_hash = currentBlock.block_hash; + + // Store all logs in auxLogs, in order of index + auxLogs[currentBlock.responses[r].logs[l].index] = currentBlock.responses[r].logs[l]; } } // Append to response logs, overwriting log indexes to be sequential - //uint64_t logIndex = 0; map::iterator auxLogsIt; for (auxLogsIt = auxLogs.begin(); auxLogsIt != auxLogs.end(); auxLogsIt++) { - // Set log index - //auxLogsIt->second.index = logIndex; - //logIndex++; - - // Set block hash - auxLogsIt->second.block_hash = currentBlock.block_hash; - // Store block log currentBlock.logs.emplace_back(auxLogsIt->second); - - // Store transaction log - if (auxLogsIt->second.tx_index >= currentBlock.responses.size()) - { - zklog.error("FullTracer::onFinishBlock() found log.tx_index=" + to_string(auxLogsIt->second.tx_index) + " >= currentBlock.responses.size=" + to_string(currentBlock.responses.size())); - exitProcess(); - } - currentBlock.responses[auxLogsIt->second.tx_index].logs.emplace_back(auxLogsIt->second); } - // Set block hash to all txs of block - for (uint64_t tx=0; tx auxLogs; + map>::iterator logIt; + map::const_iterator it; + for (logIt=logs.begin(); logIt!=logs.end(); logIt++) + { + for (it = logIt->second.begin(); it != logIt->second.end(); it++) + { + auxLogs[it->second.index] = it->second; + } + } + + // Append to response logs, overwriting log indexes to be sequential + map::iterator auxLogsIt; + uint64_t lastTx = currentBlock.responses.size() - 1; + currentBlock.responses[lastTx].logs.clear(); + for (auxLogsIt = auxLogs.begin(); auxLogsIt != auxLogs.end(); auxLogsIt++) + { + currentBlock.responses[lastTx].logs.push_back(auxLogsIt->second); + } + + // Reset logs + logs.clear(); + // Call finishTx() ctx.pHashDB->finishTx(ctx.proverRequest.uuid, response.state_root, ctx.proverRequest.input.bUpdateMerkleTree ? PERSISTENCE_DATABASE : PERSISTENCE_CACHE); diff --git a/src/service/executor/executor_service.cpp b/src/service/executor/executor_service.cpp index 4209c41f0..9675edaee 100644 --- a/src/service/executor/executor_service.cpp +++ b/src/service/executor/executor_service.cpp @@ -1409,6 +1409,8 @@ ::grpc::Status ExecutorServiceImpl::ProcessBatchV2 (::grpc::ServerContext* conte pLog->set_tx_index(block_responses[block].logs[log].tx_index); // Index of the transaction in the block //pLog->set_batch_hash(string2ba(block_responses[block].logs[log].batch_hash)); // Hash of the batch in which the transaction was included pLog->set_index(block_responses[block].logs[log].index); // Index of the log in the block + pLog->set_block_hash(string2ba(block_responses[block].logs[log].block_hash)); + pLog->set_block_number(block_responses[block].logs[log].block_number); } vector &responses = block_responses[block].responses; @@ -1458,6 +1460,8 @@ ::grpc::Status ExecutorServiceImpl::ProcessBatchV2 (::grpc::ServerContext* conte pLog->set_tx_index(responses[tx].logs[log].tx_index); // Index of the transaction in the block //pLog->set_batch_hash(string2ba(responses[tx].logs[log].batch_hash)); // Hash of the batch in which the transaction was included pLog->set_index(responses[tx].logs[log].index); // Index of the log in the block + pLog->set_block_hash(string2ba(responses[tx].logs[log].block_hash)); + pLog->set_block_number(responses[tx].logs[log].block_number); } if (proverRequest.input.traceConfig.bEnabled && (proverRequest.input.traceConfig.txHashToGenerateFullTrace == responses[tx].tx_hash)) { @@ -2049,6 +2053,8 @@ ::grpc::Status ExecutorServiceImpl::ProcessStatelessBatchV2 (::grpc::ServerConte pLog->set_tx_index(block_responses[block].logs[log].tx_index); // Index of the transaction in the block //pLog->set_batch_hash(string2ba(block_responses[block].logs[log].batch_hash)); // Hash of the batch in which the transaction was included pLog->set_index(block_responses[block].logs[log].index); // Index of the log in the block + pLog->set_block_hash(string2ba(block_responses[block].logs[log].block_hash)); + pLog->set_block_number(block_responses[block].logs[log].block_number); } vector &responses = block_responses[block].responses; @@ -2098,6 +2104,8 @@ ::grpc::Status ExecutorServiceImpl::ProcessStatelessBatchV2 (::grpc::ServerConte pLog->set_tx_index(responses[tx].logs[log].tx_index); // Index of the transaction in the block //pLog->set_batch_hash(string2ba(responses[tx].logs[log].batch_hash)); // Hash of the batch in which the transaction was included pLog->set_index(responses[tx].logs[log].index); // Index of the log in the block + pLog->set_block_hash(string2ba(responses[tx].logs[log].block_hash)); + pLog->set_block_number(responses[tx].logs[log].block_number); } if (proverRequest.input.traceConfig.bEnabled && (proverRequest.input.traceConfig.txHashToGenerateFullTrace == responses[tx].tx_hash)) {