Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:0xPolygonHermez/zkevm-prover int…
Browse files Browse the repository at this point in the history
…o develop
  • Loading branch information
fractasy committed Feb 20, 2024
2 parents 153bfe6 + 313969e commit 0415b42
Show file tree
Hide file tree
Showing 12 changed files with 318 additions and 479 deletions.
5 changes: 1 addition & 4 deletions src/config/zkresult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,7 @@ struct

{ ZKR_SM_MAIN_INVALID_WITNESS, "ZKR_SM_MAIN_INVALID_WITNESS" },
{ ZKR_CBOR_INVALID_DATA, "ZKR_CBOR_INVALID_DATA" },
{ ZKR_DATA_STREAM_INVALID_DATA, "ZKR_DATA_STREAM_INVALID_DATA" },
{ ZKR_SM_MAIN_UNSUPPORTED_PRECOMPILED, "ZKR_SM_MAIN_UNSUPPORTED_PRECOMPILED" },
{ ZKR_SM_MAIN_OOG_2, "ZKR_SM_MAIN_OOG_2" },
{ ZKR_SM_MAIN_CLOSE_BATCH, "ZKR_SM_MAIN_CLOSE_BATCH" }
{ ZKR_DATA_STREAM_INVALID_DATA, "ZKR_DATA_STREAM_INVALID_DATA" }
};

string zkresult2string (int code)
Expand Down
3 changes: 0 additions & 3 deletions src/config/zkresult.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,6 @@ typedef enum : int
ZKR_SM_MAIN_INVALID_WITNESS = 96, // Main state machine input witness is invalid or corrupt
ZKR_CBOR_INVALID_DATA = 97, // CBOR data is invalid
ZKR_DATA_STREAM_INVALID_DATA = 98, // Data stream data is invalid
ZKR_SM_MAIN_UNSUPPORTED_PRECOMPILED = 99, // Main state machine tried to use an unsupported precompiled
ZKR_SM_MAIN_OOG_2 = 100, // Main state machine found an out of gase
ZKR_SM_MAIN_CLOSE_BATCH = 101, // Main state machine completes but batch must be closed

} zkresult;

Expand Down
658 changes: 314 additions & 344 deletions src/grpc/gen/executor.pb.cc

Large diffs are not rendered by default.

36 changes: 1 addition & 35 deletions src/grpc/gen/executor.pb.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions src/grpc/proto/executor.proto
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ message ProcessBatchRequestV2 {
// prior to executing the call.
map<string, OverrideAccountV2> state_override = 23;
DebugV2 debug = 24;
uint64 execution_mode = 25;
}

message ProcessStatelessBatchRequestV2 {
Expand Down Expand Up @@ -881,10 +880,4 @@ enum ExecutorError {
EXECUTOR_ERROR_INVALID_DATA_STREAM = 115;
// EXECUTOR_ERROR_INVALID_UPDATE_MERKLE_TREE indicates that the provided update merkle tree is invalid, e.g. because the executor is configured not to write to database
EXECUTOR_ERROR_INVALID_UPDATE_MERKLE_TREE = 116;
// EXECUTOR_ERROR_UNSUPPORTED_PRECOMPILED indicates that an unsupported precompiled has been used
EXECUTOR_ERROR_UNSUPPORTED_PRECOMPILED = 117;
// EXECUTOR_ERROR_OOG_2 indicates that an out of gas has occurred
EXECUTOR_ERROR_OOG_2 = 118;
// EXECUTOR_ERROR_CLOSE_BATCH indicates that batch must be closed
EXECUTOR_ERROR_CLOSE_BATCH = 119;
}
35 changes: 1 addition & 34 deletions src/main_generator/main_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,6 @@ string generate(const json &rom, uint64_t forkID, string forkNamespace, const st
code += " RawFq::Element x1fe, y1fe, x2fe, y2fe, x3fe, y3fe;\n";
code += " RawFq::Element _x3fe, _y3fe;\n";
}
if (forkID == 7)
{
code += " uint64_t depth;\n";
}

if (!bFastMode)
code += " MemoryAccess memoryAccess;\n";
Expand Down Expand Up @@ -5521,23 +5517,6 @@ code += " #endif\n";
code += " if (jmpnCondValue >= FrFirst32Negative)\n";
code += " {\n";

if ((forkID == 7) && (zkPC == 1582))
{
code += " depth = ((fork_7::FullTracer *)proverRequest.pFullTracer)->depth;\n";
code += " if (depth > 1)\n";
code += " {\n";
code += " proverRequest.result = ZKR_SM_MAIN_OOG_2;\n";
code += " mainExecutor.logError(ctx, \"Invalid OOG 2\");\n";
code += " mainExecutor.pHashDB->cancelBatch(proverRequest.uuid);\n";
code += " return;\n";
code += " }\n";
code += " else\n";
code += " {\n";
code += " proverRequest.result = ZKR_SM_MAIN_CLOSE_BATCH;\n";
code += " zklog.info(\"Main Executor OOG_2 ZKR_SM_MAIN_CLOSE_BATCH\");\n";
code += " }\n";
}

if (!bFastMode)
{
code += " pols.isNeg[i] = fr.one();\n";
Expand All @@ -5552,17 +5531,6 @@ code += " #endif\n";
code += " bJump = true;\n";
bConditionalJump = true;

if ((forkID == 7) && rom["program"][zkPC].contains("jmpAddrLabel") && (rom["program"][zkPC]["jmpAddrLabel"] == "funcModexp"))
{
code += " if (proverRequest.input.executionMode != 1)\n";
code += " {\n";
code += " proverRequest.result = ZKR_SM_MAIN_UNSUPPORTED_PRECOMPILED;\n";
code += " mainExecutor.logError(ctx, \"Invalid funcModexp call\");\n";
code += " mainExecutor.pHashDB->cancelBatch(proverRequest.uuid);\n";
code += " return;\n";
code += " }\n";
}

code += " }\n";
// If op>=0, simply increase zkPC'=zkPC+1
code += " else if (jmpnCondValue <= FrLast32Positive)\n";
Expand Down Expand Up @@ -6055,8 +6023,7 @@ code += " #endif\n";
code += " proverRequest.counters.steps = ctx.lastStep;\n\n";

code += " // Set the error (all previous errors generated a return)\n";
code += " if (proverRequest.result != ZKR_SM_MAIN_CLOSE_BATCH)\n";
code += " proverRequest.result = ZKR_SUCCESS;\n";
code += " proverRequest.result = ZKR_SUCCESS;\n";

code += " // Check that we did not run out of steps during the execution\n";
code += " if (ctx.lastStep == 0)\n";
Expand Down
29 changes: 1 addition & 28 deletions src/main_sm/fork_7/main/main_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4997,22 +4997,6 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols,
pols.isNeg[i] = fr.one();
if (rom.line[zkPC].useJmpAddr)
{
if (pols.zkPC[i] == fr.fromU64(1582))
{
uint64_t depth = ((fork_7::FullTracer *)proverRequest.pFullTracer)->depth;
if (depth > 1)
{
proverRequest.result = ZKR_SM_MAIN_OOG_2;
logError(ctx, "Invalid OOG_2");
pHashDB->cancelBatch(proverRequest.uuid);
return;
}
else
{
proverRequest.result = ZKR_SM_MAIN_CLOSE_BATCH;
zklog.info("Main Executor OOG_2 ZKR_SM_MAIN_CLOSE_BATCH");
}
}
pols.zkPC[nexti] = rom.line[zkPC].jmpAddr;
}
else
Expand Down Expand Up @@ -5059,14 +5043,6 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols,
jmpnCondValue = jmpnCondValue >> 1;
}
pols.JMPN[i] = fr.one();

if ((proverRequest.input.executionMode != 1) && (pols.zkPC[nexti] == fr.fromU64(funcModexpLabel)))
{
proverRequest.result = ZKR_SM_MAIN_UNSUPPORTED_PRECOMPILED;
logError(ctx, "Invalid funcModexp call");
pHashDB->cancelBatch(proverRequest.uuid);
return;
}
}
// If JMPC, jump conditionally if carry
else if (rom.line[zkPC].JMPC == 1)
Expand Down Expand Up @@ -5371,10 +5347,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols,
proverRequest.counters.steps = ctx.lastStep;

// Set the error (all previous errors generated a return)
if (proverRequest.result != ZKR_SM_MAIN_CLOSE_BATCH)
{
proverRequest.result = ZKR_SUCCESS;
}
proverRequest.result = ZKR_SUCCESS;

// Check that we did not run out of steps during the execution
if (ctx.lastStep == 0)
Expand Down
11 changes: 0 additions & 11 deletions src/prover/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,16 +341,6 @@ void Input::loadGlobals (json &input)
#endif
}

// Input JSON file may contain a executionMode key at the root level
if ( input.contains("executionMode") &&
input["executionMode"].is_number_unsigned() )
{
executionMode = input["executionMode"];
#ifdef LOG_INPUT
zklog.info("Input::loadGlobals() executionMode=" + to_string(executionMode));
#endif
}

if (publicInputsExtended.publicInputs.forkID >= 7)
{
// Input JSON file might contain a stepsN key at the root level
Expand Down Expand Up @@ -670,7 +660,6 @@ void Input::saveGlobals (json &input) const
if (!from.empty() && (from != "0x")) input["from"] = from;
input["updateMerkleTree"] = bUpdateMerkleTree;
if (bNoCounters) input["noCounters"] = bNoCounters;
if (executionMode != 0) input["executionMode"] = executionMode;
if (bGetKeys) input["getKeys"] = bGetKeys;
if (bSkipVerifyL1InfoRoot) input["skipVerifyL1InfoRoot"] = bSkipVerifyL1InfoRoot;
if (bSkipFirstChangeL2Block) input["skipFirstChangeL2Block"] = bSkipFirstChangeL2Block;
Expand Down
2 changes: 0 additions & 2 deletions src/prover/input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class Input
bool bSkipVerifyL1InfoRoot; // If true, skip the check when l1Data is verified (fork ID >= 7)
bool bSkipFirstChangeL2Block; // If true, skip the restriction to start a batch with a changeL2Block transaction (fork ID >= 7)
bool bSkipWriteBlockInfoRoot; // If true, skip the block info root (fork ID >= 7)
uint64_t executionMode;
TraceConfig traceConfig; // FullTracer configuration
unordered_map<uint64_t, L1Data> l1InfoTreeData;
unordered_map<string, OverrideEntry> stateOverride;
Expand All @@ -81,7 +80,6 @@ class Input
bSkipVerifyL1InfoRoot(false),
bSkipFirstChangeL2Block(false),
bSkipWriteBlockInfoRoot(false),
executionMode(0),
stepsN(0)
{};

Expand Down
4 changes: 0 additions & 4 deletions src/prover/prover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,6 @@ void Prover::genBatchProof(ProverRequest *pProverRequest)
// Execute all the State Machines
TimerStart(EXECUTOR_EXECUTE_BATCH_PROOF);
executor.execute(*pProverRequest, cmPols);
if (pProverRequest->result == ZKR_SM_MAIN_CLOSE_BATCH)
{
pProverRequest->result = ZKR_SUCCESS;
}
TimerStopAndLog(EXECUTOR_EXECUTE_BATCH_PROOF);

uint64_t lastN = cmPols.pilDegree() - 1;
Expand Down
5 changes: 0 additions & 5 deletions src/service/executor/executor_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,6 @@ ::grpc::Status ExecutorServiceImpl::ProcessBatchV2 (::grpc::ServerContext* conte
proverRequest.input.bSkipVerifyL1InfoRoot = request->skip_verify_l1_info_root();
proverRequest.input.bSkipFirstChangeL2Block = request->skip_first_change_l2_block();
proverRequest.input.bSkipWriteBlockInfoRoot = request->skip_write_block_info_root();
proverRequest.input.executionMode = request->execution_mode();

// Trace config
if (request->has_trace_config())
Expand Down Expand Up @@ -1296,7 +1295,6 @@ ::grpc::Status ExecutorServiceImpl::ProcessBatchV2 (::grpc::ServerContext* conte
" from=" + proverRequest.input.from +
" bUpdateMerkleTree=" + to_string(proverRequest.input.bUpdateMerkleTree) +
" bNoCounters=" + to_string(proverRequest.input.bNoCounters) +
" executionMode=" + to_string(proverRequest.input.executionMode) +
" bGetKeys=" + to_string(proverRequest.input.bGetKeys) +
" bSkipVerifyL1InfoRoot=" + to_string(proverRequest.input.bSkipVerifyL1InfoRoot) +
" bSkipFirstChangeL2Block=" + to_string(proverRequest.input.bSkipFirstChangeL2Block) +
Expand Down Expand Up @@ -2532,9 +2530,6 @@ ::executor::v1::ExecutorError ExecutorServiceImpl::zkresult2error (zkresult &res
case ZKR_SM_MAIN_INVALID_WITNESS: return ::executor::v1::EXECUTOR_ERROR_INVALID_WITNESS;
case ZKR_CBOR_INVALID_DATA: return ::executor::v1::EXECUTOR_ERROR_INVALID_CBOR;
case ZKR_DATA_STREAM_INVALID_DATA: return ::executor::v1::EXECUTOR_ERROR_INVALID_DATA_STREAM;
case ZKR_SM_MAIN_UNSUPPORTED_PRECOMPILED: return ::executor::v1::EXECUTOR_ERROR_UNSUPPORTED_PRECOMPILED;
case ZKR_SM_MAIN_OOG_2: return ::executor::v1::EXECUTOR_ERROR_OOG_2;
case ZKR_SM_MAIN_CLOSE_BATCH: return ::executor::v1::EXECUTOR_ERROR_CLOSE_BATCH;

case ZKR_AGGREGATED_PROOF_INVALID_INPUT: // Only returned when generating a proof
case ZKR_DB_VERSION_NOT_FOUND_KVDB: // To be mapped to an executor error when HashDB64 is operative
Expand Down
2 changes: 0 additions & 2 deletions test/service/executor/executor_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ bool ExecutorClient::ProcessBatch (const string &inputFile)
{
no_counters = true;
}
uint64_t executionMode = input.executionMode;

// Resulting new state root
string newStateRoot;
Expand Down Expand Up @@ -226,7 +225,6 @@ bool ExecutorClient::ProcessBatch (const string &inputFile)
request.set_forced_blockhash_l1(scalar2ba(input.publicInputsExtended.publicInputs.forcedBlockHashL1));
request.set_update_merkle_tree(update_merkle_tree);
request.set_no_counters(no_counters);
request.set_execution_mode(executionMode);
request.set_get_keys(get_keys);
request.set_skip_verify_l1_info_root(input.bSkipVerifyL1InfoRoot);
request.set_skip_first_change_l2_block(input.bSkipFirstChangeL2Block);
Expand Down

0 comments on commit 0415b42

Please sign in to comment.