Skip to content

Commit

Permalink
Port release changes on minTimestampMap
Browse files Browse the repository at this point in the history
  • Loading branch information
fractasy committed Apr 23, 2024
1 parent c587ca6 commit f0f0cc5
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 1 deletion.
36 changes: 36 additions & 0 deletions src/prover/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,26 @@ void Input::loadGlobals (json &input)
#endif
}
}

// minTimestampMap
if ( input.contains("minTimestampMap") &&
input["minTimestampMap"].is_array() )
{
for (uint64_t i = 0; i < input["minTimestampMap"].size(); i++)
{
if (!input["minTimestampMap"][i].is_array())
{
zklog.error("Input::loadGlobals() minTimestampMap[" + to_string(i) + "] is not an array");
exitProcess();
}
if (input["minTimestampMap"][i].size() != 2)
{
zklog.error("Input::loadGlobals() minTimestampMap[" + to_string(i) + "] is an array but size=" + to_string(input["minTimestampMap"][i].size()) + " != 2");
exitProcess();
}
minTimestampMap[input["minTimestampMap"][i][0]] = input["minTimestampMap"][i][1];
}
}
}

string Input::saveGlobals (json &input) const
Expand Down Expand Up @@ -1592,6 +1612,22 @@ string Input::saveGlobals (json &input) const
}
}

// minTimestampMap
if (!minTimestampMap.empty())
{
s += "minTimestampMap=[";
unordered_map<uint64_t, uint64_t>::const_iterator minTimestampMapIt;
uint64_t minTimestampCounter = 0;
for (minTimestampMapIt = minTimestampMap.begin(); minTimestampMapIt != minTimestampMap.end(); minTimestampMapIt++)
{
input["minTimestampMap"][minTimestampCounter][0] = minTimestampMapIt->first;
input["minTimestampMap"][minTimestampCounter][1] = minTimestampMapIt->second;
s += "[" + to_string(minTimestampMapIt->first) + "," + to_string(minTimestampMapIt->second) + "]";
minTimestampCounter++;
}
s += "] ";
}

return s;
}

Expand Down
1 change: 1 addition & 0 deletions src/prover/input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class Input
unordered_map<string, OverrideEntry> stateOverride;
uint64_t stepsN;
InputDebug debug;
unordered_map<uint64_t, uint64_t> minTimestampMap;

// Constructor
Input (Goldilocks &fr) :
Expand Down
2 changes: 1 addition & 1 deletion src/prover/witness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ zkresult witness2db (const string &witness, DatabaseMap::MTMap &db, DatabaseMap:
// Convert state root
fea2scalar(fr, stateRoot, hash);

zklog.info("witness2db() calculated stateRoot=" + stateRoot.get_str(16));
zklog.info("witness2db() calculated stateRoot=" + stateRoot.get_str(16) + " from size=" + to_string(witness.size()));

#ifdef WITNESS_CHECK_SMT
zklog.info("witness2db() calculated SMT root=" + fea2string(fr, ctx.root));
Expand Down
24 changes: 24 additions & 0 deletions src/service/executor/executor_service_v2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,28 @@ ::grpc::Status ExecutorServiceImpl::ProcessStatelessBatchV2 (::grpc::ServerConte
proverRequest.input.publicInputsExtended.newLocalExitRoot = "0x0";
proverRequest.input.publicInputsExtended.newBatchNum = 0;

// l1_info_tree_index_min_timestamp
google::protobuf::Map<google::protobuf::uint64, google::protobuf::uint64>::const_iterator minTimestampIt;
for (minTimestampIt = request->l1_info_tree_index_min_timestamp().begin(); minTimestampIt != request->l1_info_tree_index_min_timestamp().end(); minTimestampIt++)
{
proverRequest.input.minTimestampMap[minTimestampIt->first] = minTimestampIt->second;
}

// Generate l1InfoTreeData from data stream and from l1_info_tree_index_min_timestamp
for (uint64_t i = 0; i < batch.blocks.size(); i++)
{
L1Data data;
data.blockHashL1.set_str(batch.blocks[i].l1BlockHash, 16);
data.globalExitRoot.set_str(batch.blocks[i].globalExitRoot, 16);
unordered_map<uint64_t, uint64_t>::const_iterator it;
it = proverRequest.input.minTimestampMap.find(batch.blocks[i].l1InfoTreeIndex);
if (it != proverRequest.input.minTimestampMap.end())
{
data.minTimestamp = it->second;
}
proverRequest.input.l1InfoTreeData[batch.blocks[i].l1InfoTreeIndex] = data;
}

#ifdef LOG_SERVICE_EXECUTOR_INPUT
string l1InfoTreeDataString = " l1InfoTreeData.size=" + to_string(proverRequest.input.l1InfoTreeData.size()) + "=";
unordered_map<uint64_t, L1Data>::const_iterator itl1;
Expand Down Expand Up @@ -1644,6 +1666,8 @@ ::grpc::Status ExecutorServiceImpl::ProcessStatelessBatchV2 (::grpc::ServerConte
" totalTime=" + to_string(totalTime) +
" filedesc=" + to_string(nfd),
&proverRequest.tags);

//zklog.info("ExecutorServiceImpl::ProcessStatelessBatchV2() response.ByteSizeLong=" + to_string(response->ByteSizeLong()));

// If the TP in gas/s is < threshold, log the input, unless it has been done before
if (!config.logExecutorServerInput && (config.logExecutorServerInputGasThreshold > 0) && ((double(execGas)/execTime) < config.logExecutorServerInputGasThreshold))
Expand Down

0 comments on commit f0f0cc5

Please sign in to comment.