Skip to content

Commit

Permalink
fix: pass error message along
Browse files Browse the repository at this point in the history
  • Loading branch information
alexghr committed Apr 26, 2024
1 parent c4aef42 commit ba3f1ab
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 22 deletions.
12 changes: 4 additions & 8 deletions yarn-project/aztec-node/src/aztec-node/config.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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;
Expand All @@ -17,30 +19,24 @@ export type AztecNodeConfig = ArchiverConfig &

/** A URL for an archiver service that the node will use. */
archiverUrl?: string;

proverAgents: number;
};

/**
* Returns the config of the aztec node from environment variables with reasonable defaults.
* @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;
Expand Down
3 changes: 1 addition & 2 deletions yarn-project/aztec-node/src/aztec-node/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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({
Expand Down
37 changes: 31 additions & 6 deletions yarn-project/prover-client/src/config.ts
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: PROVER_REAL_PROOFS === '1',
};
}
2 changes: 1 addition & 1 deletion yarn-project/prover-client/src/prover-pool/prover-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
30 changes: 27 additions & 3 deletions yarn-project/prover-client/src/tx-prover/tx-prover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit ba3f1ab

Please sign in to comment.