Skip to content

Commit

Permalink
refactor: move prover agent config to prover client package
Browse files Browse the repository at this point in the history
  • Loading branch information
alexghr committed Jan 9, 2025
1 parent c36674d commit 75078f0
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 70 deletions.
8 changes: 6 additions & 2 deletions yarn-project/aztec/src/cli/aztec_start_options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { type ArchiverConfig, archiverConfigMappings } from '@aztec/archiver/con
import { faucetConfigMapping } from '@aztec/aztec-faucet/config';
import { sequencerClientConfigMappings } from '@aztec/aztec-node/config';
import { botConfigMappings } from '@aztec/bot/config';
import { type ProverAgentConfig, proverAgentConfigMappings } from '@aztec/circuit-types/config';
import {
type ConfigMapping,
type EnvVar,
Expand All @@ -12,7 +11,12 @@ import {
} from '@aztec/foundation/config';
import { bootnodeConfigMappings, p2pConfigMappings } from '@aztec/p2p/config';
import { proofVerifierConfigMappings } from '@aztec/proof-verifier/config';
import { type ProverBrokerConfig, proverBrokerConfigMappings } from '@aztec/prover-client/broker';
import {
type ProverAgentConfig,
type ProverBrokerConfig,
proverAgentConfigMappings,
proverBrokerConfigMappings,
} from '@aztec/prover-client/broker';
import { proverNodeConfigMappings } from '@aztec/prover-node/config';
import { allPxeConfigMappings } from '@aztec/pxe/config';
import { telemetryClientConfigMappings } from '@aztec/telemetry-client/start';
Expand Down
9 changes: 7 additions & 2 deletions yarn-project/aztec/src/cli/cmds/start_prover_agent.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
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 { buildServerCircuitProver } from '@aztec/prover-client';
import { InlineProofStore, ProvingAgent, createProvingJobBrokerClient } from '@aztec/prover-client/broker';
import {
InlineProofStore,
type ProverAgentConfig,
ProvingAgent,
createProvingJobBrokerClient,
proverAgentConfigMappings,
} from '@aztec/prover-client/broker';
import { getProverNodeAgentConfigFromEnv } from '@aztec/prover-node';
import { createAndStartTelemetryClient, telemetryClientConfigMappings } from '@aztec/telemetry-client/start';

Expand Down
1 change: 0 additions & 1 deletion yarn-project/circuit-types/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { ProverAgentConfig, proverAgentConfigMappings } from './interfaces/prover-agent.js';
export { SequencerConfig, AllowedElement, SequencerConfigSchema } from './interfaces/configs.js';
56 changes: 0 additions & 56 deletions yarn-project/circuit-types/src/interfaces/prover-agent.ts
Original file line number Diff line number Diff line change
@@ -1,63 +1,7 @@
import { type ConfigMappingsType, booleanConfigHelper, numberConfigHelper } from '@aztec/foundation/config';
import { type ApiSchemaFor } from '@aztec/foundation/schemas';

import { z } from 'zod';

import { ProvingRequestType } from './proving-job.js';

export const ProverAgentConfig = z.object({
/** The number of prover agents to start */
proverAgentCount: z.number(),
/** The types of proofs the prover agent can generate */
proverAgentProofTypes: z.array(z.nativeEnum(ProvingRequestType)),
/** How often the prover agents poll for jobs */
proverAgentPollIntervalMs: z.number(),
/** The URL where this agent takes jobs from */
proverBrokerUrl: z.string().optional(),
/** Whether to construct real proofs */
realProofs: z.boolean(),
/** Artificial delay to introduce to all operations to the test prover. */
proverTestDelayMs: z.number(),
});

export type ProverAgentConfig = z.infer<typeof ProverAgentConfig>;

export const proverAgentConfigMappings: ConfigMappingsType<ProverAgentConfig> = {
proverAgentCount: {
env: 'PROVER_AGENT_COUNT',
description: 'Whether this prover has a local prover agent',
...numberConfigHelper(1),
},
proverAgentPollIntervalMs: {
env: 'PROVER_AGENT_POLL_INTERVAL_MS',
description: 'The interval agents poll for jobs at',
...numberConfigHelper(100),
},
proverAgentProofTypes: {
env: 'PROVER_AGENT_PROOF_TYPES',
description: 'The types of proofs the prover agent can generate',
parseEnv: (val: string) =>
val
.split(',')
.map(v => ProvingRequestType[v as any])
.filter(v => typeof v === 'number'),
},
proverBrokerUrl: {
env: 'PROVER_BROKER_HOST',
description: 'The URL where this agent takes jobs from',
},
realProofs: {
env: 'PROVER_REAL_PROOFS',
description: 'Whether to construct real proofs',
...booleanConfigHelper(false),
},
proverTestDelayMs: {
env: 'PROVER_TEST_DELAY_MS',
description: 'Artificial delay to introduce to all operations to the test prover.',
...numberConfigHelper(0),
},
};

export interface ProverAgentApi {
setMaxConcurrency(maxConcurrency: number): Promise<void>;

Expand Down
12 changes: 6 additions & 6 deletions yarn-project/prover-client/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { type ACVMConfig, type BBConfig } from '@aztec/bb-prover';
import { type ProverConfig, proverConfigMappings } from '@aztec/circuit-types';
import { type ConfigMappingsType, booleanConfigHelper, getConfigFromMappings } from '@aztec/foundation/config';

import {
type ProverAgentConfig,
type ProverConfig,
type ProverBrokerConfig,
proverAgentConfigMappings,
proverConfigMappings,
} from '@aztec/circuit-types';
import { type ConfigMappingsType, booleanConfigHelper, getConfigFromMappings } from '@aztec/foundation/config';

import { type ProverBrokerConfig, proverBrokerConfigMappings } from './proving_broker/config.js';
proverBrokerConfigMappings,
} from './proving_broker/config.js';

/**
* The prover configuration.
Expand Down
56 changes: 55 additions & 1 deletion yarn-project/prover-client/src/proving_broker/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type ConfigMappingsType, numberConfigHelper } from '@aztec/foundation/config';
import { ProvingRequestType } from '@aztec/circuit-types';
import { type ConfigMappingsType, booleanConfigHelper, numberConfigHelper } from '@aztec/foundation/config';
import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';

import { z } from 'zod';
Expand Down Expand Up @@ -37,3 +38,56 @@ export const proverBrokerConfigMappings: ConfigMappingsType<ProverBrokerConfig>
},
...dataConfigMappings,
};

export const ProverAgentConfig = z.object({
/** The number of prover agents to start */
proverAgentCount: z.number(),
/** The types of proofs the prover agent can generate */
proverAgentProofTypes: z.array(z.nativeEnum(ProvingRequestType)),
/** How often the prover agents poll for jobs */
proverAgentPollIntervalMs: z.number(),
/** The URL where this agent takes jobs from */
proverBrokerUrl: z.string().optional(),
/** Whether to construct real proofs */
realProofs: z.boolean(),
/** Artificial delay to introduce to all operations to the test prover. */
proverTestDelayMs: z.number(),
});

export type ProverAgentConfig = z.infer<typeof ProverAgentConfig>;

export const proverAgentConfigMappings: ConfigMappingsType<ProverAgentConfig> = {
proverAgentCount: {
env: 'PROVER_AGENT_COUNT',
description: 'Whether this prover has a local prover agent',
...numberConfigHelper(1),
},
proverAgentPollIntervalMs: {
env: 'PROVER_AGENT_POLL_INTERVAL_MS',
description: 'The interval agents poll for jobs at',
...numberConfigHelper(100),
},
proverAgentProofTypes: {
env: 'PROVER_AGENT_PROOF_TYPES',
description: 'The types of proofs the prover agent can generate',
parseEnv: (val: string) =>
val
.split(',')
.map(v => ProvingRequestType[v as any])
.filter(v => typeof v === 'number'),
},
proverBrokerUrl: {
env: 'PROVER_BROKER_HOST',
description: 'The URL where this agent takes jobs from',
},
realProofs: {
env: 'PROVER_REAL_PROOFS',
description: 'Whether to construct real proofs',
...booleanConfigHelper(false),
},
proverTestDelayMs: {
env: 'PROVER_TEST_DELAY_MS',
description: 'Artificial delay to introduce to all operations to the test prover.',
...numberConfigHelper(0),
},
};
8 changes: 6 additions & 2 deletions yarn-project/prover-node/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { type ArchiverConfig, archiverConfigMappings, getArchiverConfigFromEnv } from '@aztec/archiver/config';
import { type ACVMConfig, type BBConfig } from '@aztec/bb-prover/config';
import { type ProverAgentConfig, proverAgentConfigMappings } from '@aztec/circuit-types/config';
import {
type ConfigMappingsType,
bigintConfigHelper,
Expand All @@ -9,7 +8,12 @@ import {
} from '@aztec/foundation/config';
import { type DataStoreConfig, dataConfigMappings, getDataConfigFromEnv } from '@aztec/kv-store/config';
import { type P2PConfig, getP2PConfigFromEnv, p2pConfigMappings } from '@aztec/p2p/config';
import { type ProverBrokerConfig, proverBrokerConfigMappings } from '@aztec/prover-client/broker';
import {
type ProverAgentConfig,
type ProverBrokerConfig,
proverAgentConfigMappings,
proverBrokerConfigMappings,
} from '@aztec/prover-client/broker';
import {
type ProverClientConfig,
bbConfigMappings,
Expand Down

0 comments on commit 75078f0

Please sign in to comment.