diff --git a/yarn-project/aztec-node/src/aztec-node/config.ts b/yarn-project/aztec-node/src/aztec-node/config.ts index 4b644ca3b78..d4c71c30421 100644 --- a/yarn-project/aztec-node/src/aztec-node/config.ts +++ b/yarn-project/aztec-node/src/aztec-node/config.ts @@ -1,5 +1,6 @@ import { type ArchiverConfig, getConfigEnvVars as getArchiverVars } from '@aztec/archiver'; import { type P2PConfig, getP2PConfigEnvVars } from '@aztec/p2p'; +import { type ProverConfig, getProverEnvVars } from '@aztec/prover-client'; import { type SequencerClientConfig, getConfigEnvVars as getSequencerVars } from '@aztec/sequencer-client'; import { getConfigEnvVars as getWorldStateVars } from '@aztec/world-state'; @@ -8,6 +9,7 @@ import { getConfigEnvVars as getWorldStateVars } from '@aztec/world-state'; */ export type AztecNodeConfig = ArchiverConfig & SequencerClientConfig & + ProverConfig & P2PConfig & { /** Whether the sequencer is disabled for this node. */ disableSequencer: boolean; @@ -17,8 +19,6 @@ export type AztecNodeConfig = ArchiverConfig & /** A URL for an archiver service that the node will use. */ archiverUrl?: string; - - proverAgents: number; }; /** @@ -26,21 +26,17 @@ export type AztecNodeConfig = ArchiverConfig & * @returns A valid aztec node config. */ export function getConfigEnvVars(): AztecNodeConfig { - const { SEQ_DISABLED, PROVER_DISABLED, ARCHIVER_URL, PROVER_AGENTS = '1' } = process.env; - let proverAgents = parseInt(PROVER_AGENTS, 10); - if (Number.isNaN(proverAgents)) { - proverAgents = 1; - } + const { SEQ_DISABLED, PROVER_DISABLED, ARCHIVER_URL } = process.env; const allEnvVars: AztecNodeConfig = { ...getSequencerVars(), ...getArchiverVars(), ...getP2PConfigEnvVars(), ...getWorldStateVars(), + ...getProverEnvVars(), disableSequencer: !!SEQ_DISABLED, archiverUrl: ARCHIVER_URL, disableProver: PROVER_DISABLED === '1', - proverAgents, }; return allEnvVars; diff --git a/yarn-project/aztec-node/src/aztec-node/server.ts b/yarn-project/aztec-node/src/aztec-node/server.ts index 7ec441d29a4..3bf5b97ab46 100644 --- a/yarn-project/aztec-node/src/aztec-node/server.ts +++ b/yarn-project/aztec-node/src/aztec-node/server.ts @@ -52,7 +52,6 @@ import { initStoreForRollup, openTmpStore } from '@aztec/kv-store/utils'; import { SHA256Trunc, StandardTree } from '@aztec/merkle-tree'; import { AztecKVTxPool, type P2P, createP2PClient } from '@aztec/p2p'; import { DummyProver, TxProver } from '@aztec/prover-client'; -import { ProverPool } from '@aztec/prover-client/prover-pool'; import { type GlobalVariableBuilder, SequencerClient, getGlobalVariableBuilder } from '@aztec/sequencer-client'; import { PublicProcessorFactory, WASMSimulator } from '@aztec/simulator'; import { @@ -152,7 +151,7 @@ export class AztecNodeService implements AztecNode { const simulationProvider = await getSimulationProvider(config, log); const prover = config.disableProver ? await DummyProver.new() - : await TxProver.new(worldStateSynchronizer, ProverPool.testPool(simulationProvider, config.proverAgents)); + : await TxProver.new(config, simulationProvider, worldStateSynchronizer); // now create the sequencer const sequencer = config.disableSequencer diff --git a/yarn-project/end-to-end/src/composed/integration_l1_publisher.test.ts b/yarn-project/end-to-end/src/composed/integration_l1_publisher.test.ts index 8e66f351f66..29432464114 100644 --- a/yarn-project/end-to-end/src/composed/integration_l1_publisher.test.ts +++ b/yarn-project/end-to-end/src/composed/integration_l1_publisher.test.ts @@ -36,7 +36,6 @@ import { openTmpStore } from '@aztec/kv-store/utils'; import { AvailabilityOracleAbi, InboxAbi, OutboxAbi, RollupAbi } from '@aztec/l1-artifacts'; import { SHA256Trunc, StandardTree } from '@aztec/merkle-tree'; import { TxProver } from '@aztec/prover-client'; -import { ProverPool } from '@aztec/prover-client/prover-pool'; import { type L1Publisher, getL1Publisher } from '@aztec/sequencer-client'; import { WASMSimulator } from '@aztec/simulator'; import { MerkleTrees, ServerWorldStateSynchronizer, type WorldStateConfig } from '@aztec/world-state'; @@ -144,7 +143,7 @@ describe('L1Publisher integration', () => { }; const worldStateSynchronizer = new ServerWorldStateSynchronizer(tmpStore, builderDb, blockSource, worldStateConfig); await worldStateSynchronizer.start(); - builder = await TxProver.new(worldStateSynchronizer, ProverPool.testPool(new WASMSimulator(), 4)); + builder = await TxProver.new(config, new WASMSimulator(), worldStateSynchronizer); l2Proof = Buffer.alloc(0); publisher = getL1Publisher({ diff --git a/yarn-project/prover-client/src/config.ts b/yarn-project/prover-client/src/config.ts index a6d2cefb83c..6d840cac681 100644 --- a/yarn-project/prover-client/src/config.ts +++ b/yarn-project/prover-client/src/config.ts @@ -1,11 +1,21 @@ +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; } /** @@ -13,10 +23,25 @@ export interface ProverConfig { * 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', }; } diff --git a/yarn-project/prover-client/src/prover-pool/prover-agent.ts b/yarn-project/prover-client/src/prover-pool/prover-agent.ts index 098359b49f0..e5ae9f156f9 100644 --- a/yarn-project/prover-client/src/prover-pool/prover-agent.ts +++ b/yarn-project/prover-client/src/prover-pool/prover-agent.ts @@ -47,7 +47,7 @@ export class ProverAgent { this.log.error( `Error processing proving job id=${job.id} type=${ProvingRequestType[job.request.type]}: ${err}`, ); - await queue.rejectProvingJob(job.id, new ProvingError(String(err))); + await queue.rejectProvingJob(job.id, new ProvingError((err as any)?.message ?? String(err))); } }, this.intervalMs); diff --git a/yarn-project/prover-client/src/tx-prover/tx-prover.ts b/yarn-project/prover-client/src/tx-prover/tx-prover.ts index bc45cc582bf..e5b08a74560 100644 --- a/yarn-project/prover-client/src/tx-prover/tx-prover.ts +++ b/yarn-project/prover-client/src/tx-prover/tx-prover.ts @@ -6,12 +6,14 @@ import { type ProvingTicket, } from '@aztec/circuit-types/interfaces'; import { type Fr, type GlobalVariables } from '@aztec/circuits.js'; +import { type SimulationProvider } from '@aztec/simulator'; import { type WorldStateSynchronizer } from '@aztec/world-state'; +import { type ProverConfig } from '../config.js'; import { type VerificationKeys, getVerificationKeys } from '../mocks/verification_keys.js'; import { ProvingOrchestrator } from '../orchestrator/orchestrator.js'; import { MemoryProvingQueue } from '../prover-pool/memory-proving-queue.js'; -import { type ProverPool } from '../prover-pool/prover-pool.js'; +import { ProverPool } from '../prover-pool/prover-pool.js'; /** * A prover accepting individual transaction requests @@ -48,8 +50,30 @@ export class TxProver implements ProverClient { * @param worldStateSynchronizer - An instance of the world state * @returns An instance of the prover, constructed and started. */ - public static async new(worldStateSynchronizer: WorldStateSynchronizer, proverPool?: ProverPool) { - const prover = new TxProver(worldStateSynchronizer, getVerificationKeys(), proverPool); + public static async new( + config: ProverConfig, + simulationProvider: SimulationProvider, + worldStateSynchronizer: WorldStateSynchronizer, + ) { + let pool: ProverPool | undefined; + if (config.proverAgents === 0) { + pool = undefined; + } else if (config.realProofs) { + if ( + !config.acvmBinaryPath || + !config.acvmWorkingDirectory || + !config.bbBinaryPath || + !config.bbWorkingDirectory + ) { + throw new Error(); + } + + pool = ProverPool.nativePool(config, config.proverAgents, 10); + } else { + pool = ProverPool.testPool(simulationProvider, config.proverAgents, 10); + } + + const prover = new TxProver(worldStateSynchronizer, getVerificationKeys(), pool); await prover.start(); return prover; }