Skip to content

Commit

Permalink
refactor: prover broker host
Browse files Browse the repository at this point in the history
  • Loading branch information
alexghr committed Nov 26, 2024
1 parent 1344aeb commit 606e6d9
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 41 deletions.
4 changes: 2 additions & 2 deletions docker-compose.provernet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ services:
ARCHIVER_VIEM_POLLING_INTERVAL_MS: 1000
PROVER_VIEM_POLLING_INTERVAL_MS: 1000
PROVER_AGENT_COUNT: 0
PROVER_BROKER_URL: http://aztec-prover-broker
PROVER_BROKER_HOST: http://aztec-prover-broker
PROVER_PUBLISHER_PRIVATE_KEY: "0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97"
PROVER_REAL_PROOFS: "${PROVER_REAL_PROOFS:-false}"
PROVER_MINIMUM_ESCROW_AMOUNT: 1000000000
Expand Down Expand Up @@ -111,7 +111,7 @@ services:
environment:
LOG_LEVEL: verbose
ETHEREUM_HOST: http://ethereum:8545
PROVER_BROKER_URL: http://aztec-prover-broker
PROVER_BROKER_HOST: http://aztec-prover-broker
L1_CHAIN_ID: 31337
AZTEC_PORT: 80
PROVER_REAL_PROOFS: "${PROVER_REAL_PROOFS:-false}"
Expand Down
1 change: 0 additions & 1 deletion spartan/aztec-network/templates/prover-agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ spec:
- "-c"
- |
source /shared/config/service-addresses && \
PROVER_BROKER_URL=${PROVER_NODE_HOST} \
node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js start --prover-agent
env:
- name: AZTEC_PORT
Expand Down
3 changes: 0 additions & 3 deletions spartan/aztec-network/templates/prover-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,6 @@ spec:
value: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
- name: OTEL_RESOURCE_ATTRIBUTES
value: service.name={{ .Release.Name }},service.namespace={{ .Release.Namespace }},service.version={{ .Chart.AppVersion }},environment={{ .Values.environment | default "production" }}
# get private proofs from the boot node
- name: PROVER_JOB_SOURCE_URL
value: "http://$(POD_IP):{{ .Values.proverNode.service.nodePort }}"
- name: OTEL_EXPORTER_OTLP_METRICS_ENDPOINT
value: {{ include "aztec-network.otelCollectorMetricsEndpoint" . | quote }}
- name: OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
Expand Down
6 changes: 4 additions & 2 deletions yarn-project/aztec/src/cli/cmds/start_prover_broker.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ProverBrokerConfig, proverBrokerConfigMappings } from '@aztec/circuit-types';
import { type ProverBrokerConfig, type ProvingJobBroker, 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';
Expand All @@ -11,7 +11,7 @@ export async function startProverBroker(
signalHandlers: (() => Promise<void>)[],
services: NamespacedApiHandlers,
userLog: LogFn,
) {
): Promise<ProvingJobBroker> {
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);
Expand All @@ -27,4 +27,6 @@ export async function startProverBroker(
signalHandlers.push(() => broker.stop());

await broker.start();

return broker;
}
29 changes: 18 additions & 11 deletions yarn-project/aztec/src/cli/cmds/start_prover_node.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ProverNodeApiSchema, createAztecNodeClient } from '@aztec/circuit-types';
import { ProverNodeApiSchema, type ProvingJobBroker, createAztecNodeClient } from '@aztec/circuit-types';
import { NULL_KEY } from '@aztec/ethereum';
import { type NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
import { type LogFn } from '@aztec/foundation/log';
Expand All @@ -14,6 +14,7 @@ import { createAndStartTelemetryClient, telemetryClientConfigMappings } from '@a
import { mnemonicToAccount } from 'viem/accounts';

import { extractRelevantOptions } from '../util.js';
import { startProverBroker } from './start_prover_broker.js';

export async function startProverNode(
options: any,
Expand All @@ -36,14 +37,6 @@ export async function startProverNode(
process.exit(1);
}

if (options.prover || options.proverAgentEnabled) {
userLog(`Running prover node with local prover agent.`);
proverConfig.proverAgentCount = 1;
} else {
userLog(`Running prover node without local prover agent. Connect one or more prover agents to this node.`);
proverConfig.proverAgentCount = 0;
}

if (!proverConfig.publisherPrivateKey || proverConfig.publisherPrivateKey === NULL_KEY) {
if (!options.l1Mnemonic) {
userLog(`--l1-mnemonic is required to start a Prover Node without --node.publisherPrivateKey`);
Expand All @@ -69,9 +62,23 @@ export async function startProverNode(
extractRelevantOptions(options, telemetryClientConfigMappings, 'tel'),
);

const broker = proverConfig.proverBrokerUrl ? createProvingJobBrokerClient(proverConfig.proverBrokerUrl) : undefined;
const proverNode = await createProverNode(proverConfig, { telemetry, broker });
let broker: ProvingJobBroker;
if (proverConfig.proverBrokerUrl) {
broker = createProvingJobBrokerClient(proverConfig.proverBrokerUrl);
} else if (options.proverBroker) {
broker = await startProverBroker(options, signalHandlers, services, userLog);
} else {
userLog(`--prover-broker-url or --prover-broker is required to start a Prover Node`);
process.exit(1);
}

if (proverConfig.proverAgentCount === 0) {
userLog(
`Running prover node without local prover agent. Connect one or more prover agents to this node or pass --proverAgent.proverAgentCount`,
);
}

const proverNode = await createProverNode(proverConfig, { telemetry, broker });
services.proverNode = [proverNode, ProverNodeApiSchema];

if (!proverConfig.proverBrokerUrl) {
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/circuit-types/src/interfaces/prover-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const proverAgentConfigMappings: ConfigMappingsType<ProverAgentConfig> =
.filter(v => typeof v === 'number'),
},
proverBrokerUrl: {
env: 'PROVER_BROKER_URL',
env: 'PROVER_BROKER_HOST',
description: 'The URL where this agent takes jobs from',
},
realProofs: {
Expand Down
7 changes: 0 additions & 7 deletions yarn-project/circuit-types/src/interfaces/prover-broker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import { type ConfigMappingsType, numberConfigHelper } from '@aztec/foundation/c
import { z } from 'zod';

export const ProverBrokerConfig = z.object({
/** Whether to enable the prover broker */
proverBrokerEnabled: z.boolean(),
/** If starting a prover broker locally, the max number of retries per proving job */
proverBrokerJobMaxRetries: z.number(),
/** If starting a prover broker locally, the time after which a job times out and gets assigned to a different agent */
Expand All @@ -26,11 +24,6 @@ export const ProverBrokerConfig = z.object({
export type ProverBrokerConfig = z.infer<typeof ProverBrokerConfig>;

export const proverBrokerConfigMappings: ConfigMappingsType<ProverBrokerConfig> = {
proverBrokerEnabled: {
env: 'PROVER_BROKER_ENABLED',
description: 'Whether to enable the prover broker',
...numberConfigHelper(1),
},
proverBrokerJobTimeoutMs: {
env: 'PROVER_BROKER_JOB_TIMEOUT_MS',
description: 'Jobs are retried if not kept alive for this long',
Expand Down
3 changes: 1 addition & 2 deletions yarn-project/foundation/src/config/env_var.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export type EnvVar =
| 'PROVER_AGENT_COUNT'
| 'PROVER_AGENT_PROOF_TYPES'
| 'PROVER_AGENT_POLL_INTERVAL_MS'
| 'PROVER_BROKER_URL'
| 'PROVER_BROKER_HOST'
| 'PROVER_BROKER_ENABLED'
| 'PROVER_BROKER_JOB_TIMEOUT_MS'
| 'PROVER_BROKER_POLL_INTERVAL_MS'
Expand All @@ -113,7 +113,6 @@ export type EnvVar =
| 'PROVER_ID'
| 'PROVER_JOB_POLL_INTERVAL_MS'
| 'PROVER_JOB_TIMEOUT_MS'
| 'PROVER_JOB_SOURCE_URL'
| 'PROVER_NODE_POLLING_INTERVAL_MS'
| 'PROVER_NODE_MAX_PENDING_JOBS'
| 'PROVER_PUBLISH_RETRY_INTERVAL_MS'
Expand Down
13 changes: 1 addition & 12 deletions yarn-project/prover-client/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,7 @@ import { type ConfigMappingsType, booleanConfigHelper, getConfigFromMappings } f
/**
* The prover configuration.
*/
export type ProverClientConfig = ProverConfig &
ProverAgentConfig &
ProverBrokerConfig &
BBConfig &
ACVMConfig & {
/** The URL to the Aztec prover node to take proving jobs from */
proverJobSourceUrl?: string;
};
export type ProverClientConfig = ProverConfig & ProverAgentConfig & ProverBrokerConfig & BBConfig & ACVMConfig;

export const bbConfigMappings: ConfigMappingsType<BBConfig & ACVMConfig> = {
acvmWorkingDirectory: {
Expand All @@ -46,10 +39,6 @@ export const bbConfigMappings: ConfigMappingsType<BBConfig & ACVMConfig> = {
};

export const proverClientConfigMappings: ConfigMappingsType<ProverClientConfig> = {
proverJobSourceUrl: {
env: 'PROVER_JOB_SOURCE_URL',
description: 'The URL to the Aztec prover node to take proving jobs from',
},
...bbConfigMappings,
...proverConfigMappings,
...proverAgentConfigMappings,
Expand Down

0 comments on commit 606e6d9

Please sign in to comment.