Skip to content

Commit

Permalink
Create Config::check() and call it from main()
Browse files Browse the repository at this point in the history
  • Loading branch information
fractasy committed Sep 20, 2023
1 parent f80e771 commit baf3ab0
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 146 deletions.
156 changes: 156 additions & 0 deletions src/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,162 @@ void Config::print(void)
zklog.info(" fullTracerTraceReserveSize=" + to_string(fullTracerTraceReserveSize));
zklog.info(" ECRecoverPrecalc=" + to_string(ECRecoverPrecalc));
zklog.info(" ECRecoverPrecalcNThreads=" + to_string(ECRecoverPrecalcNThreads));
}

bool Config::check (void)
{
// Check required files presence
bool bError = false;
if (!fileExists(rom))
{
zklog.error("Required file config.rom=" + rom + " does not exist");
bError = true;
}
if (generateProof())
{
if (!fileExists(zkevmConstPols))
{
zklog.error("required file config.zkevmConstPols=" + zkevmConstPols + " does not exist");
bError = true;
}
if (!fileExists(c12aConstPols))
{
zklog.error("required file config.c12aConstPols=" + c12aConstPols + " does not exist");
bError = true;
}
if (!fileExists(recursive1ConstPols))
{
zklog.error("required file config.recursive1ConstPols=" + recursive1ConstPols + " does not exist");
bError = true;
}
if (!fileExists(recursive2ConstPols))
{
zklog.error("required file config.recursive2ConstPols=" + recursive2ConstPols + " does not exist");
bError = true;
}
if (!fileExists(recursivefConstPols))
{
zklog.error("required file config.recursivefConstPols=" + recursivefConstPols + " does not exist");
bError = true;
}

if (!fileExists(zkevmConstantsTree))
{
zklog.error("required file config.zkevmConstantsTree=" + zkevmConstantsTree + " does not exist");
bError = true;
}
if (!fileExists(c12aConstantsTree))
{
zklog.error("required file config.c12aConstantsTree=" + c12aConstantsTree + " does not exist");
bError = true;
}
if (!fileExists(recursive1ConstantsTree))
{
zklog.error("required file config.recursive1ConstantsTree=" + recursive1ConstantsTree + " does not exist");
bError = true;
}
if (!fileExists(recursive2ConstantsTree))
{
zklog.error("required file config.recursive2ConstantsTree=" + recursive2ConstantsTree + " does not exist");
bError = true;
}
if (!fileExists(recursivefConstantsTree))
{
zklog.error("required file config.recursivefConstantsTree=" + recursivefConstantsTree + " does not exist");
bError = true;
}
if (!fileExists(zkevmVerifier))
{
zklog.error("required file config.zkevmVerifier=" + zkevmVerifier + " does not exist");
bError = true;
}
if (!fileExists(recursive1Verifier))
{
zklog.error("required file config.recursive1Verifier=" + recursive1Verifier + " does not exist");
bError = true;
}
if (!fileExists(recursive2Verifier))
{
zklog.error("required file config.recursive2Verifier=" + recursive2Verifier + " does not exist");
bError = true;
}
if (!fileExists(recursive2Verkey))
{
zklog.error("required file config.recursive2Verkey=" + recursive2Verkey + " does not exist");
bError = true;
}
if (!fileExists(finalVerifier))
{
zklog.error("required file config.finalVerifier=" + finalVerifier + " does not exist");
bError = true;
}
if (!fileExists(recursivefVerifier))
{
zklog.error("required file config.recursivefVerifier=" + recursivefVerifier + " does not exist");
bError = true;
}
if (!fileExists(finalStarkZkey))
{
zklog.error("required file config.finalStarkZkey=" + finalStarkZkey + " does not exist");
bError = true;
}
if (!fileExists(storageRomFile))
{
zklog.error("required file config.storageRomFile=" + storageRomFile + " does not exist");
bError = true;
}
if (!fileExists(zkevmStarkInfo))
{
zklog.error("required file config.zkevmStarkInfo=" + zkevmStarkInfo + " does not exist");
bError = true;
}
if (!fileExists(c12aStarkInfo))
{
zklog.error("required file config.c12aStarkInfo=" + c12aStarkInfo + " does not exist");
bError = true;
}
if (!fileExists(recursive1StarkInfo))
{
zklog.error("required file config.recursive1StarkInfo=" + recursive1StarkInfo + " does not exist");
bError = true;
}
if (!fileExists(recursive2StarkInfo))
{
zklog.error("required file config.recursive2StarkInfo=" + recursive2StarkInfo + " does not exist");
bError = true;
}
if (!fileExists(recursivefStarkInfo))
{
zklog.error("required file config.recursivefStarkInfo=" + recursivefStarkInfo + " does not exist");
bError = true;
}
if (!fileExists(c12aExec))
{
zklog.error("required file config.c12aExec=" + c12aExec + " does not exist");
bError = true;
}
if (!fileExists(recursive1Exec))
{
zklog.error("required file config.recursive1Exec=" + recursive1Exec + " does not exist");
bError = true;
}
if (!fileExists(recursive2Exec))
{
zklog.error("required file config.recursive2Exec=" + recursive2Exec + " does not exist");
bError = true;
}
if (!fileExists(recursivefExec))
{
zklog.error("required file config.recursivefExec=" + recursivefExec + " does not exist");
bError = true;
}
}

if (hashDB64 && !stateManager)
{
zklog.error("hashDB64=true but stateManager=false");
bError = true;
}

return bError;
}
1 change: 1 addition & 0 deletions src/config/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ class Config
void load(json &config);
bool generateProof(void) const { return runFileGenBatchProof || runFileGenAggregatedProof || runFileGenFinalProof || runAggregatorClient; }
void print(void);
bool check(void); // Checks that the loaded configuration is correct; returns true if there is at least one error
};

#endif
149 changes: 3 additions & 146 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,154 +339,11 @@ int main(int argc, char **argv)

TimerStart(WHOLE_PROCESS);

// Check required files presence
bool bError = false;
if (!fileExists(config.rom))
if (config.check())
{
zklog.error("Required file config.rom=" + config.rom + " does not exist");
bError = true;
}
if (config.generateProof())
{
if (!fileExists(config.zkevmConstPols))
{
zklog.error("required file config.zkevmConstPols=" + config.zkevmConstPols + " does not exist");
bError = true;
}
if (!fileExists(config.c12aConstPols))
{
zklog.error("required file config.c12aConstPols=" + config.c12aConstPols + " does not exist");
bError = true;
}
if (!fileExists(config.recursive1ConstPols))
{
zklog.error("required file config.recursive1ConstPols=" + config.recursive1ConstPols + " does not exist");
bError = true;
}
if (!fileExists(config.recursive2ConstPols))
{
zklog.error("required file config.recursive2ConstPols=" + config.recursive2ConstPols + " does not exist");
bError = true;
}
if (!fileExists(config.recursivefConstPols))
{
zklog.error("required file config.recursivefConstPols=" + config.recursivefConstPols + " does not exist");
bError = true;
}

if (!fileExists(config.zkevmConstantsTree))
{
zklog.error("required file config.zkevmConstantsTree=" + config.zkevmConstantsTree + " does not exist");
bError = true;
}
if (!fileExists(config.c12aConstantsTree))
{
zklog.error("required file config.c12aConstantsTree=" + config.c12aConstantsTree + " does not exist");
bError = true;
}
if (!fileExists(config.recursive1ConstantsTree))
{
zklog.error("required file config.recursive1ConstantsTree=" + config.recursive1ConstantsTree + " does not exist");
bError = true;
}
if (!fileExists(config.recursive2ConstantsTree))
{
zklog.error("required file config.recursive2ConstantsTree=" + config.recursive2ConstantsTree + " does not exist");
bError = true;
}
if (!fileExists(config.recursivefConstantsTree))
{
zklog.error("required file config.recursivefConstantsTree=" + config.recursivefConstantsTree + " does not exist");
bError = true;
}
if (!fileExists(config.zkevmVerifier))
{
zklog.error("required file config.zkevmVerifier=" + config.zkevmVerifier + " does not exist");
bError = true;
}
if (!fileExists(config.recursive1Verifier))
{
zklog.error("required file config.recursive1Verifier=" + config.recursive1Verifier + " does not exist");
bError = true;
}
if (!fileExists(config.recursive2Verifier))
{
zklog.error("required file config.recursive2Verifier=" + config.recursive2Verifier + " does not exist");
bError = true;
}
if (!fileExists(config.recursive2Verkey))
{
zklog.error("required file config.recursive2Verkey=" + config.recursive2Verkey + " does not exist");
bError = true;
}
if (!fileExists(config.finalVerifier))
{
zklog.error("required file config.finalVerifier=" + config.finalVerifier + " does not exist");
bError = true;
}
if (!fileExists(config.recursivefVerifier))
{
zklog.error("required file config.recursivefVerifier=" + config.recursivefVerifier + " does not exist");
bError = true;
}
if (!fileExists(config.finalStarkZkey))
{
zklog.error("required file config.finalStarkZkey=" + config.finalStarkZkey + " does not exist");
bError = true;
}
if (!fileExists(config.storageRomFile))
{
zklog.error("required file config.storageRomFile=" + config.storageRomFile + " does not exist");
bError = true;
}
if (!fileExists(config.zkevmStarkInfo))
{
zklog.error("required file config.zkevmStarkInfo=" + config.zkevmStarkInfo + " does not exist");
bError = true;
}
if (!fileExists(config.c12aStarkInfo))
{
zklog.error("required file config.c12aStarkInfo=" + config.c12aStarkInfo + " does not exist");
bError = true;
}
if (!fileExists(config.recursive1StarkInfo))
{
zklog.error("required file config.recursive1StarkInfo=" + config.recursive1StarkInfo + " does not exist");
bError = true;
}
if (!fileExists(config.recursive2StarkInfo))
{
zklog.error("required file config.recursive2StarkInfo=" + config.recursive2StarkInfo + " does not exist");
bError = true;
}
if (!fileExists(config.recursivefStarkInfo))
{
zklog.error("required file config.recursivefStarkInfo=" + config.recursivefStarkInfo + " does not exist");
bError = true;
}
if (!fileExists(config.c12aExec))
{
zklog.error("required file config.c12aExec=" + config.c12aExec + " does not exist");
bError = true;
}
if (!fileExists(config.recursive1Exec))
{
zklog.error("required file config.recursive1Exec=" + config.recursive1Exec + " does not exist");
bError = true;
}
if (!fileExists(config.recursive2Exec))
{
zklog.error("required file config.recursive2Exec=" + config.recursive2Exec + " does not exist");
bError = true;
}
if (!fileExists(config.recursivefExec))
{
zklog.error("required file config.recursivefExec=" + config.recursivefExec + " does not exist");
bError = true;
}
}
if (bError)
zklog.error("main() failed calling config.check()");
exitProcess();
}

// Create one instance of the Goldilocks finite field instance
Goldilocks fr;
Expand Down

0 comments on commit baf3ab0

Please sign in to comment.