-
Notifications
You must be signed in to change notification settings - Fork 265
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
59 changed files
with
1,925 additions
and
1,034 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,51 +1,51 @@ | ||
import { BBNativeRollupProver, TestCircuitProver } from '@aztec/bb-prover'; | ||
import { ProverAgentApiSchema, type ServerCircuitProver } from '@aztec/circuit-types'; | ||
import { type ProverAgentConfig, proverAgentConfigMappings } from '@aztec/circuit-types'; | ||
import { times } from '@aztec/foundation/collection'; | ||
import { type NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server'; | ||
import { type LogFn } from '@aztec/foundation/log'; | ||
import { type ProverClientConfig, proverClientConfigMappings } from '@aztec/prover-client'; | ||
import { ProverAgent, createProvingJobSourceClient } from '@aztec/prover-client/prover-agent'; | ||
import { | ||
type TelemetryClientConfig, | ||
createAndStartTelemetryClient, | ||
telemetryClientConfigMappings, | ||
} from '@aztec/telemetry-client/start'; | ||
import { buildServerCircuitProver } from '@aztec/prover-client'; | ||
import { InlineProofStore, ProvingAgent, createProvingJobConsumerClient } from '@aztec/prover-client/broker'; | ||
import { getProverNodeAgentConfigFromEnv } from '@aztec/prover-node'; | ||
import { createAndStartTelemetryClient, telemetryClientConfigMappings } from '@aztec/telemetry-client/start'; | ||
|
||
import { extractRelevantOptions } from '../util.js'; | ||
|
||
export async function startProverAgent( | ||
options: any, | ||
signalHandlers: (() => Promise<void>)[], | ||
services: NamespacedApiHandlers, | ||
logger: LogFn, | ||
userLog: LogFn, | ||
) { | ||
const proverConfig = extractRelevantOptions<ProverClientConfig>(options, proverClientConfigMappings, 'prover'); | ||
const proverJobSourceUrl = proverConfig.proverJobSourceUrl ?? proverConfig.nodeUrl; | ||
if (!proverJobSourceUrl) { | ||
throw new Error('Starting prover without PROVER_JOB_SOURCE_URL is not supported'); | ||
if (options.node || options.sequencer || options.pxe || options.p2pBootstrap || options.txe) { | ||
userLog(`Starting a prover agent with --node, --sequencer, --pxe, --p2p-bootstrap, or --txe is not supported.`); | ||
process.exit(1); | ||
} | ||
|
||
logger(`Connecting to prover at ${proverJobSourceUrl}`); | ||
const source = createProvingJobSourceClient(proverJobSourceUrl); | ||
const config = { | ||
...getProverNodeAgentConfigFromEnv(), // get default config from env | ||
...extractRelevantOptions<ProverAgentConfig>(options, proverAgentConfigMappings, 'proverAgent'), // override with command line options | ||
}; | ||
|
||
const telemetryConfig = extractRelevantOptions<TelemetryClientConfig>(options, telemetryClientConfigMappings, 'tel'); | ||
const telemetry = await createAndStartTelemetryClient(telemetryConfig); | ||
if (config.realProofs && (!config.bbBinaryPath || config.acvmBinaryPath)) { | ||
process.exit(1); | ||
} | ||
|
||
let circuitProver: ServerCircuitProver; | ||
if (proverConfig.realProofs) { | ||
if (!proverConfig.acvmBinaryPath || !proverConfig.bbBinaryPath) { | ||
throw new Error('Cannot start prover without simulation or native prover options'); | ||
} | ||
circuitProver = await BBNativeRollupProver.new(proverConfig, telemetry); | ||
} else { | ||
circuitProver = new TestCircuitProver(telemetry, undefined, proverConfig); | ||
if (!config.proverBrokerUrl) { | ||
process.exit(1); | ||
} | ||
|
||
const { proverAgentConcurrency, proverAgentPollInterval } = proverConfig; | ||
const agent = new ProverAgent(circuitProver, proverAgentConcurrency, proverAgentPollInterval); | ||
agent.start(source); | ||
const broker = createProvingJobConsumerClient(config.proverBrokerUrl); | ||
|
||
const telemetry = await createAndStartTelemetryClient( | ||
extractRelevantOptions(options, telemetryClientConfigMappings, 'tel'), | ||
); | ||
const prover = await buildServerCircuitProver(config, telemetry); | ||
const proofStore = new InlineProofStore(); | ||
const agents = times(config.proverAgentCount, () => new ProvingAgent(broker, proofStore, prover)); | ||
|
||
logger(`Started prover agent with concurrency limit of ${proverAgentConcurrency}`); | ||
await Promise.all(agents.map(agent => agent.start())); | ||
|
||
services.prover = [agent, ProverAgentApiSchema]; | ||
signalHandlers.push(() => agent.stop()); | ||
signalHandlers.push(async () => { | ||
await Promise.all(agents.map(agent => agent.stop())); | ||
await telemetry.stop(); | ||
}); | ||
} |
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,30 @@ | ||
import { type ProverBrokerConfig, proverBrokerConfigMappings } from '@aztec/circuit-types'; | ||
import { type NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server'; | ||
import { type LogFn } from '@aztec/foundation/log'; | ||
import { ProvingJobBrokerSchema, createAndStartProvingBroker } from '@aztec/prover-client/broker'; | ||
import { getProverNodeBrokerConfigFromEnv } from '@aztec/prover-node'; | ||
|
||
import { extractRelevantOptions } from '../util.js'; | ||
|
||
export async function startProverBroker( | ||
options: any, | ||
signalHandlers: (() => Promise<void>)[], | ||
services: NamespacedApiHandlers, | ||
userLog: LogFn, | ||
) { | ||
if (options.node || options.sequencer || options.pxe || options.p2pBootstrap || options.txe) { | ||
userLog(`Starting a prover broker with --node, --sequencer, --pxe, --p2p-bootstrap, or --txe is not supported.`); | ||
process.exit(1); | ||
} | ||
|
||
const config: ProverBrokerConfig = { | ||
...getProverNodeBrokerConfigFromEnv(), // get default config from env | ||
...extractRelevantOptions<ProverBrokerConfig>(options, proverBrokerConfigMappings, 'proverBroker'), // override with command line options | ||
}; | ||
|
||
const broker = await createAndStartProvingBroker(config); | ||
services.proverNodeProducer = [broker, ProvingJobBrokerSchema]; | ||
signalHandlers.push(() => broker.stop()); | ||
|
||
await broker.start(); | ||
} |
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
Oops, something went wrong.