Skip to content

Commit

Permalink
Port changes to reset cache before importing input.db
Browse files Browse the repository at this point in the history
  • Loading branch information
fractasy committed May 13, 2024
1 parent 251cdca commit f6fee38
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main_generator/main_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,12 @@ string generate(const json &rom, uint64_t forkID, string forkNamespace, const st
code += " remove(\"c.txt\");\n";
code += "#endif\n\n";

code += " // Clear cache if configured and we are using a local database\n";
code += " if (mainExecutor.config.dbClearCache && (mainExecutor.config.databaseURL == \"local\"))\n";
code += " {\n";
code += " mainExecutor.pHashDB->clearCache();\n";
code += " }\n";

code += " // Copy input database content into context database\n";
code += " if (proverRequest.input.db.size() > 0)\n";
code += " {\n";
Expand Down
6 changes: 6 additions & 0 deletions src/main_sm/fork_1/main/main_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols,
remove("c.txt");
#endif

// Clear cache if configured and we are using a local database
if (config.dbClearCache && (config.databaseURL == "local"))
{
pHashDB->clearCache();
}

// Copy input database content into context database
if (proverRequest.input.db.size() > 0)
{
Expand Down
6 changes: 6 additions & 0 deletions src/main_sm/fork_10/main/main_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols,
remove("c.txt");
#endif

// Clear cache if configured and we are using a local database
if (config.dbClearCache && (config.databaseURL == "local"))
{
pHashDB->clearCache();
}

// Copy input database content into context database
if (proverRequest.input.db.size() > 0)
{
Expand Down
6 changes: 6 additions & 0 deletions src/main_sm/fork_10_blob/main/main_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols,
remove("c.txt");
#endif

// Clear cache if configured and we are using a local database
if (config.dbClearCache && (config.databaseURL == "local"))
{
pHashDB->clearCache();
}

// Copy input database content into context database
if (proverRequest.input.db.size() > 0)
{
Expand Down
6 changes: 6 additions & 0 deletions src/main_sm/fork_2/main/main_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols,
remove("c.txt");
#endif

// Clear cache if configured and we are using a local database
if (config.dbClearCache && (config.databaseURL == "local"))
{
pHashDB->clearCache();
}

// Copy input database content into context database
if (proverRequest.input.db.size() > 0)
{
Expand Down
6 changes: 6 additions & 0 deletions src/main_sm/fork_3/main/main_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols,
remove("c.txt");
#endif

// Clear cache if configured and we are using a local database
if (config.dbClearCache && (config.databaseURL == "local"))
{
pHashDB->clearCache();
}

// Copy input database content into context database
if (proverRequest.input.db.size() > 0)
{
Expand Down
6 changes: 6 additions & 0 deletions src/main_sm/fork_4/main/main_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols,
remove("c.txt");
#endif

// Clear cache if configured and we are using a local database
if (config.dbClearCache && (config.databaseURL == "local"))
{
pHashDB->clearCache();
}

// Copy input database content into context database
if (proverRequest.input.db.size() > 0)
{
Expand Down
6 changes: 6 additions & 0 deletions src/main_sm/fork_5/main/main_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols,
remove("c.txt");
#endif

// Clear cache if configured and we are using a local database
if (config.dbClearCache && (config.databaseURL == "local"))
{
pHashDB->clearCache();
}

// Copy input database content into context database
if (proverRequest.input.db.size() > 0)
{
Expand Down
6 changes: 6 additions & 0 deletions src/main_sm/fork_6/main/main_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols,
remove("c.txt");
#endif

// Clear cache if configured and we are using a local database
if (config.dbClearCache && (config.databaseURL == "local"))
{
pHashDB->clearCache();
}

// Copy input database content into context database
if (proverRequest.input.db.size() > 0)
{
Expand Down
6 changes: 6 additions & 0 deletions src/main_sm/fork_7/main/main_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols,
remove("c.txt");
#endif

// Clear cache if configured and we are using a local database
if (config.dbClearCache && (config.databaseURL == "local"))
{
pHashDB->clearCache();
}

// Copy input database content into context database
if (proverRequest.input.db.size() > 0)
{
Expand Down
6 changes: 6 additions & 0 deletions src/main_sm/fork_8/main/main_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols,
remove("c.txt");
#endif

// Clear cache if configured and we are using a local database
if (config.dbClearCache && (config.databaseURL == "local"))
{
pHashDB->clearCache();
}

// Copy input database content into context database
if (proverRequest.input.db.size() > 0)
{
Expand Down
7 changes: 7 additions & 0 deletions src/main_sm/fork_9/main/main_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols,
remove("c.txt");
#endif

// Clear cache if configured and we are using a local database
if (config.dbClearCache && (config.databaseURL == "local"))
{
pHashDB->clearCache();
}

// Copy input database content into context database
if (proverRequest.input.db.size() > 0)
{
Expand Down Expand Up @@ -2621,6 +2627,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols,
SmtAction smtAction;
smtAction.bIsSet = true;
smtAction.setResult = ctx.lastSWrite.res;
zklog.info("SMT SIBLINGS SIZE=" + to_string(smtAction.setResult.siblings.size()));
required.Storage.push_back(smtAction);
}
#endif
Expand Down
4 changes: 4 additions & 0 deletions src/prover/witness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,10 @@ zkresult calculateWitnessHash (WitnessContext &ctx, Goldilocks::Element (&hash)[

} while ((numberOfOpcodes == 1) && (numberOfCodeOpcodes == 1));

#ifdef LOG_WITNESS
zklog.info("calculateWitnessHash() returns hash=" + fea2string(fr, hash));
#endif

return ZKR_SUCCESS;
}

Expand Down

0 comments on commit f6fee38

Please sign in to comment.