-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
65 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,47 @@ | ||
import { tmpdir } from 'os'; | ||
|
||
/** | ||
* The prover configuration. | ||
*/ | ||
export interface ProverConfig { | ||
/** The working directory to use for simulation/proving */ | ||
acvmWorkingDirectory?: string; | ||
acvmWorkingDirectory: string; | ||
/** The path to the ACVM binary */ | ||
acvmBinaryPath?: string; | ||
acvmBinaryPath: string; | ||
/** The working directory to for proving */ | ||
bbWorkingDirectory: string; | ||
/** The path to the bb binary */ | ||
bbBinaryPath: string; | ||
/** How many agents to start */ | ||
proverAgents: number; | ||
/** Enable proving. If true, must set bb env vars */ | ||
realProofs: boolean; | ||
} | ||
|
||
/** | ||
* Returns the prover configuration from the environment variables. | ||
* Note: If an environment variable is not set, the default value is used. | ||
* @returns The prover configuration. | ||
*/ | ||
export function getConfigEnvVars(): ProverConfig { | ||
const { ACVM_WORKING_DIRECTORY, ACVM_BINARY_PATH } = process.env; | ||
export function getProverEnvVars(): ProverConfig { | ||
const { | ||
ACVM_WORKING_DIRECTORY = tmpdir(), | ||
ACVM_BINARY_PATH = '', | ||
BB_WORKING_DIRECTORY = tmpdir(), | ||
BB_BINARY_PATH = '', | ||
PROVER_AGENTS = '1', | ||
PROVER_REAL_PROOFS = '', | ||
} = process.env; | ||
|
||
const parsedProverAgents = parseInt(PROVER_AGENTS, 10); | ||
const proverAgents = Number.isSafeInteger(parsedProverAgents) ? parsedProverAgents : 0; | ||
|
||
return { | ||
acvmWorkingDirectory: ACVM_WORKING_DIRECTORY ? ACVM_WORKING_DIRECTORY : undefined, | ||
acvmBinaryPath: ACVM_BINARY_PATH ? ACVM_BINARY_PATH : undefined, | ||
acvmWorkingDirectory: ACVM_WORKING_DIRECTORY, | ||
acvmBinaryPath: ACVM_BINARY_PATH, | ||
bbBinaryPath: BB_BINARY_PATH, | ||
bbWorkingDirectory: BB_WORKING_DIRECTORY, | ||
proverAgents, | ||
realProofs: PROVER_REAL_PROOFS === '1', | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters