-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: configure prover as separate process (#5973)
Update the `aztec` command to allow running as an independent prover connected to a prover pool
- Loading branch information
Showing
25 changed files
with
329 additions
and
33 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
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { type ProvingJobSource } from '@aztec/circuit-types'; | ||
import { ProverPool, createProvingJobSourceClient } from '@aztec/prover-client/prover-pool'; | ||
|
||
import { type ServiceStarter, parseModuleOptions } from '../util.js'; | ||
|
||
type ProverOptions = Partial<{ | ||
proverUrl: string; | ||
agents: string; | ||
acvmBinaryPath?: string; | ||
bbBinaryPath?: string; | ||
simulate?: string; | ||
}>; | ||
|
||
export const startProver: ServiceStarter = async (options, signalHandlers, logger) => { | ||
const proverOptions: ProverOptions = parseModuleOptions(options.prover); | ||
let source: ProvingJobSource; | ||
|
||
if (typeof proverOptions.proverUrl === 'string') { | ||
logger(`Connecting to prover at ${proverOptions.proverUrl}`); | ||
source = createProvingJobSourceClient(proverOptions.proverUrl, 'provingJobSource'); | ||
} else { | ||
throw new Error('Starting prover without an orchestrator is not supported'); | ||
} | ||
|
||
const agentCount = proverOptions.agents ? parseInt(proverOptions.agents, 10) : 1; | ||
if (agentCount === 0 || !Number.isSafeInteger(agentCount)) { | ||
throw new Error('Cannot start prover without agents'); | ||
} | ||
|
||
let pool: ProverPool; | ||
if (proverOptions.simulate) { | ||
pool = ProverPool.testPool(undefined, agentCount); | ||
} else if (proverOptions.acvmBinaryPath && proverOptions.bbBinaryPath) { | ||
pool = ProverPool.nativePool( | ||
{ | ||
acvmBinaryPath: proverOptions.acvmBinaryPath, | ||
bbBinaryPath: proverOptions.bbBinaryPath, | ||
}, | ||
agentCount, | ||
); | ||
} else { | ||
throw new Error('Cannot start prover without simulation or native prover options'); | ||
} | ||
|
||
logger(`Starting ${agentCount} prover agents`); | ||
await pool.start(source); | ||
signalHandlers.push(() => pool.stop()); | ||
|
||
return Promise.resolve([]); | ||
}; |
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 |
---|---|---|
|
@@ -51,6 +51,9 @@ | |
{ | ||
"path": "../protocol-contracts" | ||
}, | ||
{ | ||
"path": "../prover-client" | ||
}, | ||
{ | ||
"path": "../pxe" | ||
} | ||
|
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
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: ['1', 'true'].includes(PROVER_REAL_PROOFS), | ||
}; | ||
} |
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,3 +1,4 @@ | ||
export * from './prover-agent.js'; | ||
export * from './memory-proving-queue.js'; | ||
export * from './prover-pool.js'; | ||
export * from './rpc.js'; |
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
Oops, something went wrong.