@aztec/prover-client 0.81.0 → 0.82.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"test_context.d.ts","sourceRoot":"","sources":["../../src/mocks/test_context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAKpD,OAAO,EAEL,eAAe,EAEf,wBAAwB,EACxB,iBAAiB,EAElB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,KAAK,sBAAsB,EAAsB,MAAM,qBAAqB,CAAC;AACtF,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,eAAe,EAAE,KAAK,WAAW,EAAiB,KAAK,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACpH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAOlE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGpD,qBAAa,WAAW;IAKb,iBAAiB,EAAE,iBAAiB;IACpC,UAAU,EAAE,uBAAuB;IACnC,eAAe,EAAE,eAAe;IAChC,eAAe,EAAE,eAAe;IAChC,MAAM,EAAE,mBAAmB;IAC3B,MAAM,EAAE,U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C,WAAW,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAK5D,sBAAsB,CAAC,kBAAkB,SAAmB,GAAG,WAAW;IAI3E,OAAO;IAYA,eAAe,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC;IAC1F,eAAe,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAuBjE,8EAA8E;IACjE,gBAAgB,CAC3B,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,MAAU,EACnB,iBAAiB,GAAE,eAAe,GAAG,MAA6B,EAClE,mBAAmB,GAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAc;;;;;IAiB/F,sBAAsB,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,eAAe,EAAE,MAAM;IAIzD,YAAY,CAAC,GAAG,EAAE,WAAW,EAAE;CAsB7C;AAED,cAAM,uBAAwB,SAAQ,mBAAmB;IAChD,2CAA2C,UAAS;cAIxC,kCAAkC,CACnD,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,sBAAsB,GACjC,OAAO,CAAC,IAAI,CAAC;CAMjB"}
@@ -12,6 +12,8 @@ import { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
12
12
  import { TreeSnapshots } from '@aztec/stdlib/tx';
13
13
  import { NativeWorldStateService } from '@aztec/world-state/native';
14
14
  import { promises as fs } from 'fs';
15
+ // TODO(#12613) This means of sharing test code is not ideal.
16
+ // eslint-disable-next-line import/no-relative-packages
15
17
  import { TestCircuitProver } from '../../../bb-prover/src/test/test_circuit_prover.js';
16
18
  import { buildBlock } from '../block_builder/light.js';
17
19
  import { ProvingOrchestrator } from '../orchestrator/index.js';
@@ -160,7 +160,7 @@ const logger = createLogger('prover-client:orchestrator');
160
160
  }
161
161
  for (const tx of txs){
162
162
  const txHash = (await tx.getTxHash()).toString();
163
- const tubeInputs = new TubeInputs(tx.clientIvcProof);
163
+ const tubeInputs = new TubeInputs(!!tx.data.forPublic, tx.clientIvcProof);
164
164
  const tubeProof = promiseWithResolvers();
165
165
  logger.debug(`Starting tube circuit for tx ${txHash}`);
166
166
  this.doEnqueueTube(txHash, tubeInputs, (proof)=>tubeProof.resolve(proof));
@@ -24,7 +24,7 @@ import { VkWitnessData } from '@aztec/stdlib/vks';
24
24
  return !!this.tube && (!this.requireAvmProof || !!this.avm);
25
25
  }
26
26
  getTubeInputs() {
27
- return new TubeInputs(this.processedTx.clientIvcProof);
27
+ return new TubeInputs(!!this.processedTx.data.forPublic, this.processedTx.clientIvcProof);
28
28
  }
29
29
  getAvmInputs() {
30
30
  return this.processedTx.avmProvingRequest.inputs;
@@ -14,6 +14,8 @@ export declare const ProverBrokerConfig: z.ZodObject<{
14
14
  dataDirectory: z.ZodOptional<z.ZodString>;
15
15
  /** The size of the data store map */
16
16
  dataStoreMapSizeKB: z.ZodNumber;
17
+ /** The size of the prover broker's database. Will override the dataStoreMapSizeKB if set. */
18
+ proverBrokerStoreMapSizeKB: z.ZodOptional<z.ZodNumber>;
17
19
  /** The prover broker may batch jobs together before writing to the database */
18
20
  proverBrokerBatchSize: z.ZodNumber;
19
21
  /** How often the job batches get flushed */
@@ -29,6 +31,7 @@ export declare const ProverBrokerConfig: z.ZodObject<{
29
31
  proverBrokerBatchIntervalMs: number;
30
32
  proverBrokerMaxEpochsToKeepResultsFor: number;
31
33
  dataDirectory?: string | undefined;
34
+ proverBrokerStoreMapSizeKB?: number | undefined;
32
35
  }, {
33
36
  proverBrokerJobMaxRetries: number;
34
37
  proverBrokerJobTimeoutMs: number;
@@ -38,6 +41,7 @@ export declare const ProverBrokerConfig: z.ZodObject<{
38
41
  proverBrokerBatchIntervalMs: number;
39
42
  proverBrokerMaxEpochsToKeepResultsFor: number;
40
43
  dataDirectory?: string | undefined;
44
+ proverBrokerStoreMapSizeKB?: number | undefined;
41
45
  }>;
42
46
  export type ProverBrokerConfig = z.infer<typeof ProverBrokerConfig> & Pick<DataStoreConfig, 'dataStoreMapSizeKB' | 'dataDirectory'> & L1ReaderConfig;
43
47
  export declare const proverBrokerConfigMappings: ConfigMappingsType<ProverBrokerConfig>;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/proving_broker/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAA0B,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EACL,KAAK,kBAAkB,EAIxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,wBAAwB,CAAC;AAClF,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,kBAAkB;IAC7B,qFAAqF;;IAErF,uHAAuH;;IAEvH,6FAA6F;;IAE7F,8EAA8E;;IAE9E,qCAAqC;;IAErC,+EAA+E;;IAE/E,4CAA4C;;IAE5C,uDAAuD;;;;;;;;;;;;;;;;;;;;EAEvD,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,GACjE,IAAI,CAAC,eAAe,EAAE,oBAAoB,GAAG,eAAe,CAAC,GAC7D,cAAc,CAAC;AAEjB,eAAO,MAAM,0BAA0B,EAAE,kBAAkB,CAAC,kBAAkB,CAiC7E,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,kBAAiE,CAAC;AAE1G,eAAO,MAAM,iBAAiB;IAC5B,2CAA2C;;IAE3C,wDAAwD;;IAExD,gDAAgD;;IAEhD,+CAA+C;;IAE/C,uCAAuC;;IAEvC,gDAAgD;;IAEhD,2DAA2D;;IAE3D,8EAA8E;;;;;;;;;;;;;;;;;;;;EAE9E,CAAC;AAEH,MAAM,MAAM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iBAAiB,CAAC,CAAC;AAElE,eAAO,MAAM,yBAAyB,EAAE,kBAAkB,CAAC,iBAAiB,CA4C3E,CAAC"}
@@ -9,6 +9,7 @@ export const ProverBrokerConfig = z.object({
9
9
  /** If starting a prover broker locally, the interval the broker checks for timed out jobs */ proverBrokerPollIntervalMs: z.number().int().nonnegative(),
10
10
  /** If starting a prover broker locally, the directory to store broker data */ dataDirectory: z.string().optional(),
11
11
  /** The size of the data store map */ dataStoreMapSizeKB: z.number().int().nonnegative(),
12
+ /** The size of the prover broker's database. Will override the dataStoreMapSizeKB if set. */ proverBrokerStoreMapSizeKB: z.number().int().nonnegative().optional(),
12
13
  /** The prover broker may batch jobs together before writing to the database */ proverBrokerBatchSize: z.number().int().nonnegative(),
13
14
  /** How often the job batches get flushed */ proverBrokerBatchIntervalMs: z.number().int().nonnegative(),
14
15
  /** The maximum number of epochs to keep results for */ proverBrokerMaxEpochsToKeepResultsFor: z.number().int().nonnegative()
@@ -44,8 +45,13 @@ export const proverBrokerConfigMappings = {
44
45
  description: 'The maximum number of epochs to keep results for',
45
46
  ...numberConfigHelper(1)
46
47
  },
47
- ...l1ReaderConfigMappings,
48
- ...dataConfigMappings
48
+ proverBrokerStoreMapSizeKB: {
49
+ env: 'PROVER_BROKER_STORE_MAP_SIZE_KB',
50
+ parseEnv: (val)=>val ? +val : undefined,
51
+ description: "The size of the prover broker's database. Will override the dataStoreMapSizeKB if set."
52
+ },
53
+ ...dataConfigMappings,
54
+ ...l1ReaderConfigMappings
49
55
  };
50
56
  export const defaultProverBrokerConfig = getDefaultConfig(proverBrokerConfigMappings);
51
57
  export const ProverAgentConfig = z.object({
@@ -1,5 +1,5 @@
1
1
  import type { TelemetryClient } from '@aztec/telemetry-client';
2
2
  import type { ProverBrokerConfig } from './config.js';
3
3
  import { ProvingBroker } from './proving_broker.js';
4
- export declare function createAndStartProvingBroker(config: ProverBrokerConfig, client: TelemetryClient): Promise<ProvingBroker>;
4
+ export declare function createAndStartProvingBroker(_config: ProverBrokerConfig, client: TelemetryClient): Promise<ProvingBroker>;
5
5
  //# sourceMappingURL=factory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/proving_broker/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIpD,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,kBAAkB,EAC1B,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,aAAa,CAAC,CAOxB"}
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/proving_broker/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIpD,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,kBAAkB,EAC3B,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,aAAa,CAAC,CAQxB"}
@@ -1,7 +1,11 @@
1
1
  import { ProvingBroker } from './proving_broker.js';
2
2
  import { InMemoryBrokerDatabase } from './proving_broker_database/memory.js';
3
3
  import { KVBrokerDatabase } from './proving_broker_database/persisted.js';
4
- export async function createAndStartProvingBroker(config, client) {
4
+ export async function createAndStartProvingBroker(_config, client) {
5
+ const config = {
6
+ ..._config,
7
+ dataStoreMapSizeKB: _config.proverBrokerStoreMapSizeKB ?? _config.dataStoreMapSizeKB
8
+ };
5
9
  const database = config.dataDirectory ? await KVBrokerDatabase.new(config, client) : new InMemoryBrokerDatabase();
6
10
  const broker = new ProvingBroker(database, config, client);
7
11
  await broker.start();
@@ -1,4 +1,4 @@
1
- import type { ProvingJobConsumer, ProvingJobId, ProvingJobResultsMap, ServerCircuitProver } from '@aztec/stdlib/interfaces/server';
1
+ import type { ProvingJobConsumer, ServerCircuitProver } from '@aztec/stdlib/interfaces/server';
2
2
  import { ProvingRequestType } from '@aztec/stdlib/proofs';
3
3
  import { type TelemetryClient, type Traceable, type Tracer } from '@aztec/telemetry-client';
4
4
  import type { ProofStore } from './proof_store/index.js';
@@ -20,7 +20,6 @@ export declare class ProvingAgent implements Traceable {
20
20
  private currentJobController?;
21
21
  private runningPromise;
22
22
  private instrumentation;
23
- private idleTimer;
24
23
  readonly tracer: Tracer;
25
24
  constructor(
26
25
  /** The source of proving jobs */
@@ -41,6 +40,6 @@ export declare class ProvingAgent implements Traceable {
41
40
  stop(): Promise<void>;
42
41
  private work;
43
42
  private startJob;
44
- handleJobResult: <T extends ProvingRequestType>(jobId: ProvingJobId, type: T, err: Error | undefined, result: ProvingJobResultsMap[T] | undefined) => Promise<void>;
43
+ private reportResult;
45
44
  }
46
45
  //# sourceMappingURL=proving_agent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"proving_agent.d.ts","sourceRoot":"","sources":["../../src/proving_broker/proving_agent.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,kBAAkB,EAClB,YAAY,EAEZ,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,MAAM,EAGZ,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAIzD;;GAEG;AACH,qBAAa,YAAa,YAAW,SAAS;IAS1C,iCAAiC;IACjC,OAAO,CAAC,MAAM;IACd,gDAAgD;IAChD,OAAO,CAAC,UAAU;IAClB,iDAAiD;IACjD,OAAO,CAAC,aAAa;IACrB,oDAAoD;IACpD,OA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IAQ1C,iCAAiC;IACjC,OAAO,CAAC,MAAM;IACd,gDAAgD;IAChD,OAAO,CAAC,UAAU;IAClB,iDAAiD;IACjD,OAAO,CAAC,aAAa;IACrB,oDAAoD;IACpD,OAAO,CAAC,cAAc;IACtB,oCAAoC;IACpC,OAAO,CAAC,cAAc;IAGtB,OAAO,CAAC,GAAG;IAnBb,OAAO,CAAC,oBAAoB,CAAC,CAAuB;IACpD,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,eAAe,CAA8B;IAErD,SAAgB,MAAM,EAAE,MAAM,CAAC;;IAG7B,iCAAiC;IACzB,MAAM,EAAE,kBAAkB;IAClC,gDAAgD;IACxC,UAAU,EAAE,UAAU;IAC9B,iDAAiD;IACzC,aAAa,EAAE,mBAAmB;IAC1C,oDAAoD;IAC5C,cAAc,GAAE,KAAK,CAAC,kBAAkB,CAAM;IACtD,oCAAoC;IAC5B,cAAc,SAAO;IAC7B,uDAAuD;IACvD,MAAM,GAAE,eAAsC,EACtC,GAAG,yCAA8C;IAOpD,gBAAgB,CAAC,aAAa,EAAE,mBAAmB,GAAG,IAAI;IAI1D,SAAS,IAAI,OAAO;IAIpB,KAAK,IAAI,IAAI;IAIP,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;YAMpB,IAAI;YAqDJ,QAAQ;YAuDR,YAAY;CA0B3B"}
@@ -4,10 +4,10 @@ function _ts_decorate(decorators, target, key, desc) {
4
4
  else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  }
7
+ import { AbortError } from '@aztec/foundation/error';
7
8
  import { createLogger } from '@aztec/foundation/log';
8
9
  import { RunningPromise } from '@aztec/foundation/running-promise';
9
10
  import { truncate } from '@aztec/foundation/string';
10
- import { Timer } from '@aztec/foundation/timer';
11
11
  import { ProvingError } from '@aztec/stdlib/errors';
12
12
  import { ProvingRequestType } from '@aztec/stdlib/proofs';
13
13
  import { getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
@@ -25,7 +25,6 @@ import { ProvingJobController, ProvingJobControllerStatus } from './proving_job_
25
25
  currentJobController;
26
26
  runningPromise;
27
27
  instrumentation;
28
- idleTimer;
29
28
  tracer;
30
29
  constructor(/** The source of proving jobs */ broker, /** Database holding proof inputs and outputs */ proofStore, /** The prover implementation to defer jobs to */ circuitProver, /** Optional list of allowed proof types to build */ proofAllowList = [], /** How long to wait between jobs */ pollIntervalMs = 1000, /** A telemetry client through which to emit metrics */ client = getTelemetryClient(), log = createLogger('prover-client:proving-agent')){
31
30
  this.broker = broker;
@@ -34,28 +33,6 @@ import { ProvingJobController, ProvingJobControllerStatus } from './proving_job_
34
33
  this.proofAllowList = proofAllowList;
35
34
  this.pollIntervalMs = pollIntervalMs;
36
35
  this.log = log;
37
- this.handleJobResult = async (jobId, type, err, result)=>{
38
- let maybeJob;
39
- if (err) {
40
- const retry = err.name === ProvingError.NAME ? err.retry : false;
41
- this.log.error(`Job id=${jobId} type=${ProvingRequestType[type]} failed err=${err.message} retry=${retry}`, err);
42
- maybeJob = await this.broker.reportProvingJobError(jobId, err.message, retry, {
43
- allowList: this.proofAllowList
44
- });
45
- } else if (result) {
46
- const outputUri = await this.proofStore.saveProofOutput(jobId, type, result);
47
- this.log.info(`Job id=${jobId} type=${ProvingRequestType[type]} completed outputUri=${truncate(outputUri)}`);
48
- maybeJob = await this.broker.reportProvingJobSuccess(jobId, outputUri, {
49
- allowList: this.proofAllowList
50
- });
51
- }
52
- if (maybeJob) {
53
- const { job, time } = maybeJob;
54
- await this.startJob(job, time);
55
- } else {
56
- this.idleTimer = new Timer();
57
- }
58
- };
59
36
  this.tracer = client.getTracer('ProvingAgent');
60
37
  this.instrumentation = new ProvingAgentInstrumentation(client);
61
38
  this.runningPromise = new RunningPromise(this.work.bind(this), this.log, this.pollIntervalMs);
@@ -67,7 +44,6 @@ import { ProvingJobController, ProvingJobControllerStatus } from './proving_job_
67
44
  return this.runningPromise?.isRunning() ?? false;
68
45
  }
69
46
  start() {
70
- this.idleTimer = new Timer();
71
47
  this.runningPromise.start();
72
48
  }
73
49
  async stop() {
@@ -75,34 +51,56 @@ import { ProvingJobController, ProvingJobControllerStatus } from './proving_job_
75
51
  await this.runningPromise.stop();
76
52
  }
77
53
  async work() {
78
- // every tick we need to
79
- // (1) either do a heartbeat, telling the broker that we're working
80
- // (2) get a new job
81
- // If during (1) the broker returns a new job that means we can cancel the current job and start the new one
54
+ // every tick we need to take one of the following actions:
55
+ // 1. send a hearbeat to the broker that we're working on some job
56
+ // 2. if the job is complete, send its result to the broker
57
+ // 3. get a job from the broker
58
+ // Any one of these actions could give us a new job to work on. If that happens we abort the current job.
59
+ //
60
+ // This loop gets triggered in one of two ways:
61
+ // - either on a timer (see pollIntervalMs)
62
+ // - or when a proof completes
82
63
  let maybeJob;
83
- if (this.currentJobController?.getStatus() === ProvingJobControllerStatus.PROVING) {
84
- maybeJob = await this.broker.reportProvingJobProgress(this.currentJobController.getJobId(), this.currentJobController.getStartedAt(), {
85
- allowList: this.proofAllowList
86
- });
64
+ if (this.currentJobController) {
65
+ const status = this.currentJobController.getStatus();
66
+ const jobId = this.currentJobController.getJobId();
67
+ const proofType = this.currentJobController.getProofType();
68
+ const startedAt = this.currentJobController.getStartedAt();
69
+ const result = this.currentJobController.getResult();
70
+ if (status === ProvingJobControllerStatus.RUNNING) {
71
+ maybeJob = await this.broker.reportProvingJobProgress(jobId, startedAt, {
72
+ allowList: this.proofAllowList
73
+ });
74
+ } else if (status === ProvingJobControllerStatus.DONE) {
75
+ if (result) {
76
+ maybeJob = await this.reportResult(jobId, proofType, result);
77
+ } else {
78
+ this.log.warn(`Job controller for job ${this.currentJobController.getJobId()} is done but doesn't have a result`, {
79
+ jobId
80
+ });
81
+ maybeJob = await this.reportResult(jobId, proofType, new ProvingError('No result found after proving', undefined, /* retry */ true));
82
+ }
83
+ this.currentJobController = undefined;
84
+ } else {
85
+ // IDLE status should not be seen because a job is started as soon as it is created
86
+ this.log.warn(`Idle job controller for job: ${this.currentJobController.getJobId()}. Skipping main loop work`, {
87
+ jobId: this.currentJobController.getJobId()
88
+ });
89
+ return;
90
+ }
87
91
  } else {
88
92
  maybeJob = await this.broker.getProvingJob({
89
93
  allowList: this.proofAllowList
90
94
  });
91
95
  }
92
- if (!maybeJob) {
93
- return;
94
- }
95
- if (this.idleTimer) {
96
- this.instrumentation.recordIdleTime(this.idleTimer);
96
+ if (maybeJob) {
97
+ await this.startJob(maybeJob);
97
98
  }
98
- this.idleTimer = undefined;
99
- const { job, time } = maybeJob;
100
- await this.startJob(job, time);
101
99
  }
102
- async startJob(job, startedAt) {
100
+ async startJob({ job, time: startedAt }) {
103
101
  let abortedProofJobId;
104
102
  let abortedProofName;
105
- if (this.currentJobController?.getStatus() === ProvingJobControllerStatus.PROVING) {
103
+ if (this.currentJobController?.getStatus() === ProvingJobControllerStatus.RUNNING) {
106
104
  abortedProofJobId = this.currentJobController.getJobId();
107
105
  abortedProofName = this.currentJobController.getProofTypeName();
108
106
  this.currentJobController?.abort();
@@ -115,11 +113,15 @@ import { ProvingJobController, ProvingJobControllerStatus } from './proving_job_
115
113
  allowList: this.proofAllowList
116
114
  });
117
115
  if (maybeJob) {
118
- return this.startJob(maybeJob.job, maybeJob.time);
116
+ return this.startJob(maybeJob);
119
117
  }
120
118
  return;
121
119
  }
122
- this.currentJobController = new ProvingJobController(job.id, inputs, job.epochNumber, startedAt, this.circuitProver, this.handleJobResult);
120
+ this.currentJobController = new ProvingJobController(job.id, inputs, job.epochNumber, startedAt, this.circuitProver, ()=>{
121
+ // trigger a run of the main work loop when proving completes
122
+ // no need to await this here. The controller will stay alive (in DONE state) until the result is send to the broker
123
+ void this.runningPromise.trigger();
124
+ });
123
125
  if (abortedProofJobId) {
124
126
  this.log.info(`Aborting job id=${abortedProofJobId} type=${abortedProofName} to start new job id=${this.currentJobController.getJobId()} type=${this.currentJobController.getProofTypeName()} inputsUri=${truncate(job.inputsUri)}`);
125
127
  } else {
@@ -127,7 +129,26 @@ import { ProvingJobController, ProvingJobControllerStatus } from './proving_job_
127
129
  }
128
130
  this.currentJobController.start();
129
131
  }
130
- handleJobResult;
132
+ async reportResult(jobId, type, result) {
133
+ let maybeJob;
134
+ if (result instanceof AbortError) {
135
+ // no-op
136
+ this.log.warn(`Job id=${jobId} was aborted. Not reporting result back to broker`, result);
137
+ } else if (result instanceof Error) {
138
+ const retry = result.name === ProvingError.NAME ? result.retry : false;
139
+ this.log.error(`Job id=${jobId} type=${ProvingRequestType[type]} failed err=${result.message} retry=${retry}`, result);
140
+ maybeJob = await this.broker.reportProvingJobError(jobId, result.message, retry, {
141
+ allowList: this.proofAllowList
142
+ });
143
+ } else {
144
+ const outputUri = await this.proofStore.saveProofOutput(jobId, type, result);
145
+ this.log.info(`Job id=${jobId} type=${ProvingRequestType[type]} completed outputUri=${truncate(outputUri)}`);
146
+ maybeJob = await this.broker.reportProvingJobSuccess(jobId, outputUri, {
147
+ allowList: this.proofAllowList
148
+ });
149
+ }
150
+ return maybeJob;
151
+ }
131
152
  }
132
153
  _ts_decorate([
133
154
  trackSpan('ProvingAgent.safeWork')
@@ -2,12 +2,8 @@ import type { ProvingJobId, ProvingJobInputs, ProvingJobResultsMap, ServerCircui
2
2
  import { ProvingRequestType } from '@aztec/stdlib/proofs';
3
3
  export declare enum ProvingJobControllerStatus {
4
4
  IDLE = "idle",
5
- PROVING = "proving",
6
- DONE = "done",
7
- ABORTED = "aborted"
8
- }
9
- interface ProvingJobCompletionCallback<T extends ProvingRequestType = ProvingRequestType> {
10
- (jobId: ProvingJobId, type: T, error: Error | undefined, result: ProvingJobResultsMap[T] | undefined): void | Promise<void>;
5
+ RUNNING = "running",
6
+ DONE = "done"
11
7
  }
12
8
  export declare class ProvingJobController {
13
9
  private jobId;
@@ -20,14 +16,17 @@ export declare class ProvingJobController {
20
16
  private status;
21
17
  private promise?;
22
18
  private abortController;
23
- constructor(jobId: ProvingJobId, inputs: ProvingJobInputs, epochNumber: number, startedAt: number, circuitProver: ServerCircuitProver, onComplete: ProvingJobCompletionCallback, log?: import("@aztec/foundation/log").Logger);
19
+ private result?;
20
+ constructor(jobId: ProvingJobId, inputs: ProvingJobInputs, epochNumber: number, startedAt: number, circuitProver: ServerCircuitProver, onComplete: () => void, log?: import("@aztec/foundation/log").Logger);
24
21
  start(): void;
25
22
  getStatus(): ProvingJobControllerStatus;
23
+ getResult(): ProvingJobResultsMap[ProvingRequestType] | Error | undefined;
26
24
  abort(): void;
27
25
  getJobId(): ProvingJobId;
26
+ getProofType(): ProvingRequestType;
28
27
  getStartedAt(): number;
29
28
  getProofTypeName(): string;
29
+ private run;
30
30
  private generateProof;
31
31
  }
32
- export {};
33
32
  //# sourceMappingURL=proving_job_controller.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"proving_job_controller.d.ts","sourceRoot":"","sources":["../../src/proving_broker/proving_job_controller.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,oBAAY,0BAA0B;IACpC,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,IAAI,SAAS;IACb,OAAO,YAAY;CACpB;AAED,UAAU,4BAA4B,CAAC,CAAC,SAAS,kBAAkB,GAAG,kBAAkB;IACtF,CACE,KAAK,EAAE,YAAY,EACnB,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,KAAK,GAAG,SAAS,EACxB,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,SAAS,GAC1C,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB;AAED,qBAAa,oBAAoB;IAM7B,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,GAAG;IAXb,OAAO,CAAC,MAAM,CAA+D;IAC7E,OAAO,CAAC,OAAO,CAAC,CAAgB;IAChC,OAAO,CAAC,eAAe,CAAyB;gBAGtC,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,gBAAgB,EACxB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,mBAAmB,EAClC,UAAU,EAAE,4BAA4B,EACxC,GAAG,yCAA6D;IAGnE,KAAK,IAAI,IAAI;IA+Db,SAAS,IAAI,0BAA0B;IAIvC,KAAK,IAAI,IAAI;IAgBb,QAAQ,IAAI,YAAY;IAIxB,YAAY,IAAI,MAAM;IAItB,gBAAgB,IAAI,MAAM;YAInB,aAAa;CA0D5B"}
1
+ {"version":3,"file":"proving_job_controller.d.ts","sourceRoot":"","sources":["../../src/proving_broker/proving_job_controller.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,oBAAY,0BAA0B;IACpC,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,IAAI,SAAS;CACd;AAED,qBAAa,oBAAoB;IAO7B,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,GAAG;IAZb,OAAO,CAAC,MAAM,CAA+D;IAC7E,OAAO,CAAC,OAAO,CAAC,CAAgB;IAChC,OAAO,CAAC,eAAe,CAAyB;IAChD,OAAO,CAAC,MAAM,CAAC,CAAmD;gBAGxD,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,gBAAgB,EACxB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,mBAAmB,EAClC,UAAU,EAAE,MAAM,IAAI,EACtB,GAAG,yCAA+F;IAGrG,KAAK,IAAI,IAAI;IAmBb,SAAS,IAAI,0BAA0B;IAIvC,SAAS,IAAI,oBAAoB,CAAC,kBAAkB,CAAC,GAAG,KAAK,GAAG,SAAS;IAIzE,KAAK,IAAI,IAAI;IAeb,QAAQ,IAAI,YAAY;IAIxB,YAAY,IAAI,kBAAkB;IAIlC,YAAY,IAAI,MAAM;IAItB,gBAAgB,IAAI,MAAM;IAIjC,OAAO,CAAC,GAAG,CA4BT;YAEY,aAAa;CA0D5B"}
@@ -1,10 +1,11 @@
1
+ import { randomBytes } from '@aztec/foundation/crypto';
2
+ import { AbortError } from '@aztec/foundation/error';
1
3
  import { createLogger } from '@aztec/foundation/log';
2
4
  import { ProvingRequestType } from '@aztec/stdlib/proofs';
3
5
  export var ProvingJobControllerStatus = /*#__PURE__*/ function(ProvingJobControllerStatus) {
4
6
  ProvingJobControllerStatus["IDLE"] = "idle";
5
- ProvingJobControllerStatus["PROVING"] = "proving";
7
+ ProvingJobControllerStatus["RUNNING"] = "running";
6
8
  ProvingJobControllerStatus["DONE"] = "done";
7
- ProvingJobControllerStatus["ABORTED"] = "aborted";
8
9
  return ProvingJobControllerStatus;
9
10
  }({});
10
11
  export class ProvingJobController {
@@ -18,7 +19,8 @@ export class ProvingJobController {
18
19
  status;
19
20
  promise;
20
21
  abortController;
21
- constructor(jobId, inputs, epochNumber, startedAt, circuitProver, onComplete, log = createLogger('prover-client:proving-agent:job-controller')){
22
+ result;
23
+ constructor(jobId, inputs, epochNumber, startedAt, circuitProver, onComplete, log = createLogger('prover-client:proving-agent:job-controller-' + randomBytes(4).toString('hex'))){
22
24
  this.jobId = jobId;
23
25
  this.inputs = inputs;
24
26
  this.epochNumber = epochNumber;
@@ -28,82 +30,83 @@ export class ProvingJobController {
28
30
  this.log = log;
29
31
  this.status = "idle";
30
32
  this.abortController = new AbortController();
31
- }
32
- start() {
33
- if (this.status !== "idle") {
34
- this.log.verbose(`Job controller for jobId=${this.jobId} not starting because it is not idle currentStatus=${this.status}`, {
35
- currentStatus: this.status,
36
- jobId: this.jobId
37
- });
38
- return;
39
- }
40
- this.status = "proving";
41
- this.log.verbose(`Job controller started jobId=${this.jobId}`, {
42
- jobId: this.jobId
43
- });
44
- this.promise = this.generateProof().then((result)=>{
45
- if (this.status === "aborted") {
46
- this.log.warn(`Job controller for jobId=${this.jobId} completed successfully but job was aborted`, {
33
+ this.run = async ()=>{
34
+ this.status = "running";
35
+ let result;
36
+ try {
37
+ result = await this.generateProof();
38
+ } catch (err) {
39
+ if (err && err instanceof Error) {
40
+ result = err;
41
+ } else {
42
+ result = new Error('Unknown proving error: ' + String(err), {
43
+ cause: err
44
+ });
45
+ }
46
+ }
47
+ if (this.abortController.signal.aborted) {
48
+ this.log.warn(`Job controller for jobId=${this.jobId} completed but job was aborted`, {
47
49
  currentStatus: this.status,
48
50
  jobId: this.jobId
49
51
  });
50
- return;
52
+ result = new AbortError('Proof was aborted');
51
53
  }
54
+ this.result = result;
52
55
  this.status = "done";
53
- this.log.verbose(`Job controller for jobId=${this.jobId} completed successfully`, {
54
- jobId: this.jobId
55
- });
56
- return this.onComplete(this.jobId, this.inputs.type, undefined, result);
57
- }, (error)=>{
58
- if (this.status === "aborted") {
59
- this.log.warn(`Job controller for jobId=${this.jobId} finished with an error but job was aborted`, {
60
- currentStatus: this.status,
56
+ try {
57
+ this.onComplete();
58
+ } catch (err) {
59
+ this.log.warn(`On complete handler error: ${err}`, {
61
60
  jobId: this.jobId
62
61
  });
63
- return;
64
- }
65
- if (error.name === 'AbortError') {
66
- // Ignore abort errors
67
- return;
68
62
  }
69
- this.log.verbose(`Job controller for jobId=${this.jobId} finished with an error`, {
70
- jobId: this.jobId,
71
- err: error
72
- });
73
- this.status = "done";
74
- return this.onComplete(this.jobId, this.inputs.type, error, undefined);
75
- }).catch((err)=>{
76
- this.log.error(`Job constroller failed to send result for jobId=${this.jobId}: ${err}`, err, {
63
+ };
64
+ }
65
+ start() {
66
+ if (this.status !== "idle") {
67
+ this.log.warn(`Job controller for jobId=${this.jobId} not starting because it is not idle currentStatus=${this.status}`, {
68
+ currentStatus: this.status,
77
69
  jobId: this.jobId
78
70
  });
71
+ return;
72
+ }
73
+ this.promise = this.run();
74
+ this.log.info(`Job controller started jobId=${this.jobId}`, {
75
+ jobId: this.jobId
79
76
  });
80
77
  }
81
78
  getStatus() {
82
79
  return this.status;
83
80
  }
81
+ getResult() {
82
+ return this.result;
83
+ }
84
84
  abort() {
85
- if (this.status !== "proving") {
85
+ if (this.status !== "running") {
86
86
  this.log.warn(`Tried to abort job controller for jobId=${this.jobId} but it is not running`, {
87
87
  currentStatus: this.status,
88
88
  jobId: this.jobId
89
89
  });
90
90
  return;
91
91
  }
92
- this.status = "aborted";
93
92
  this.abortController.abort();
94
- this.log.verbose(`Aborted job controller for jobId=${this.jobId}`, {
93
+ this.log.warn(`Aborted job controller for jobId=${this.jobId}`, {
95
94
  jobId: this.jobId
96
95
  });
97
96
  }
98
97
  getJobId() {
99
98
  return this.jobId;
100
99
  }
100
+ getProofType() {
101
+ return this.inputs.type;
102
+ }
101
103
  getStartedAt() {
102
104
  return this.startedAt;
103
105
  }
104
106
  getProofTypeName() {
105
107
  return ProvingRequestType[this.inputs.type];
106
108
  }
109
+ run;
107
110
  async generateProof() {
108
111
  const { type, inputs } = this.inputs;
109
112
  const signal = this.abortController.signal;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/prover-client",
3
- "version": "0.81.0",
3
+ "version": "0.82.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
@@ -66,19 +66,19 @@
66
66
  ]
67
67
  },
68
68
  "dependencies": {
69
- "@aztec/bb-prover": "0.81.0",
70
- "@aztec/blob-lib": "0.81.0",
71
- "@aztec/constants": "0.81.0",
72
- "@aztec/ethereum": "0.81.0",
73
- "@aztec/foundation": "0.81.0",
74
- "@aztec/kv-store": "0.81.0",
75
- "@aztec/noir-protocol-circuits-types": "0.81.0",
76
- "@aztec/noir-types": "0.81.0",
77
- "@aztec/protocol-contracts": "0.81.0",
78
- "@aztec/simulator": "0.81.0",
79
- "@aztec/stdlib": "0.81.0",
80
- "@aztec/telemetry-client": "0.81.0",
81
- "@aztec/world-state": "0.81.0",
69
+ "@aztec/bb-prover": "0.82.0",
70
+ "@aztec/blob-lib": "0.82.0",
71
+ "@aztec/constants": "0.82.0",
72
+ "@aztec/ethereum": "0.82.0",
73
+ "@aztec/foundation": "0.82.0",
74
+ "@aztec/kv-store": "0.82.0",
75
+ "@aztec/noir-protocol-circuits-types": "0.82.0",
76
+ "@aztec/noir-types": "0.82.0",
77
+ "@aztec/protocol-contracts": "0.82.0",
78
+ "@aztec/simulator": "0.82.0",
79
+ "@aztec/stdlib": "0.82.0",
80
+ "@aztec/telemetry-client": "0.82.0",
81
+ "@aztec/world-state": "0.82.0",
82
82
  "@google-cloud/storage": "^7.15.0",
83
83
  "@iarna/toml": "^2.2.5",
84
84
  "commander": "^12.1.0",
@@ -88,7 +88,7 @@
88
88
  "zod": "^3.23.8"
89
89
  },
90
90
  "devDependencies": {
91
- "@aztec/noir-contracts.js": "0.81.0",
91
+ "@aztec/noir-contracts.js": "0.82.0",
92
92
  "@jest/globals": "^29.5.0",
93
93
  "@types/jest": "^29.5.0",
94
94
  "@types/memdown": "^3.0.0",
@@ -26,6 +26,8 @@ import { NativeWorldStateService } from '@aztec/world-state/native';
26
26
 
27
27
  import { promises as fs } from 'fs';
28
28
 
29
+ // TODO(#12613) This means of sharing test code is not ideal.
30
+ // eslint-disable-next-line import/no-relative-packages
29
31
  import { TestCircuitProver } from '../../../bb-prover/src/test/test_circuit_prover.js';
30
32
  import { buildBlock } from '../block_builder/light.js';
31
33
  import { ProvingOrchestrator } from '../orchestrator/index.js';
@@ -237,7 +237,7 @@ export class ProvingOrchestrator implements EpochProver {
237
237
  }
238
238
  for (const tx of txs) {
239
239
  const txHash = (await tx.getTxHash()).toString();
240
- const tubeInputs = new TubeInputs(tx.clientIvcProof);
240
+ const tubeInputs = new TubeInputs(!!tx.data.forPublic, tx.clientIvcProof);
241
241
  const tubeProof = promiseWithResolvers<ProofAndVerificationKey<typeof TUBE_PROOF_LENGTH>>();
242
242
  logger.debug(`Starting tube circuit for tx ${txHash}`);
243
243
  this.doEnqueueTube(txHash, tubeInputs, proof => tubeProof.resolve(proof));
@@ -42,7 +42,7 @@ export class TxProvingState {
42
42
  }
43
43
 
44
44
  public getTubeInputs() {
45
- return new TubeInputs(this.processedTx.clientIvcProof);
45
+ return new TubeInputs(!!this.processedTx.data.forPublic, this.processedTx.clientIvcProof);
46
46
  }
47
47
 
48
48
  public getAvmInputs(): AvmCircuitInputs {
@@ -21,6 +21,8 @@ export const ProverBrokerConfig = z.object({
21
21
  dataDirectory: z.string().optional(),
22
22
  /** The size of the data store map */
23
23
  dataStoreMapSizeKB: z.number().int().nonnegative(),
24
+ /** The size of the prover broker's database. Will override the dataStoreMapSizeKB if set. */
25
+ proverBrokerStoreMapSizeKB: z.number().int().nonnegative().optional(),
24
26
  /** The prover broker may batch jobs together before writing to the database */
25
27
  proverBrokerBatchSize: z.number().int().nonnegative(),
26
28
  /** How often the job batches get flushed */
@@ -64,8 +66,13 @@ export const proverBrokerConfigMappings: ConfigMappingsType<ProverBrokerConfig>
64
66
  description: 'The maximum number of epochs to keep results for',
65
67
  ...numberConfigHelper(1),
66
68
  },
67
- ...l1ReaderConfigMappings,
69
+ proverBrokerStoreMapSizeKB: {
70
+ env: 'PROVER_BROKER_STORE_MAP_SIZE_KB',
71
+ parseEnv: (val: string | undefined) => (val ? +val : undefined),
72
+ description: "The size of the prover broker's database. Will override the dataStoreMapSizeKB if set.",
73
+ },
68
74
  ...dataConfigMappings,
75
+ ...l1ReaderConfigMappings,
69
76
  };
70
77
 
71
78
  export const defaultProverBrokerConfig: ProverBrokerConfig = getDefaultConfig(proverBrokerConfigMappings);
@@ -6,9 +6,10 @@ import { InMemoryBrokerDatabase } from './proving_broker_database/memory.js';
6
6
  import { KVBrokerDatabase } from './proving_broker_database/persisted.js';
7
7
 
8
8
  export async function createAndStartProvingBroker(
9
- config: ProverBrokerConfig,
9
+ _config: ProverBrokerConfig,
10
10
  client: TelemetryClient,
11
11
  ): Promise<ProvingBroker> {
12
+ const config = { ..._config, dataStoreMapSizeKB: _config.proverBrokerStoreMapSizeKB ?? _config.dataStoreMapSizeKB };
12
13
  const database = config.dataDirectory ? await KVBrokerDatabase.new(config, client) : new InMemoryBrokerDatabase();
13
14
 
14
15
  const broker = new ProvingBroker(database, config, client);
@@ -1,10 +1,10 @@
1
+ import { AbortError } from '@aztec/foundation/error';
1
2
  import { createLogger } from '@aztec/foundation/log';
2
3
  import { RunningPromise } from '@aztec/foundation/running-promise';
3
4
  import { truncate } from '@aztec/foundation/string';
4
- import { Timer } from '@aztec/foundation/timer';
5
5
  import { ProvingError } from '@aztec/stdlib/errors';
6
6
  import type {
7
- ProvingJob,
7
+ GetProvingJobResponse,
8
8
  ProvingJobConsumer,
9
9
  ProvingJobId,
10
10
  ProvingJobInputs,
@@ -31,7 +31,6 @@ export class ProvingAgent implements Traceable {
31
31
  private currentJobController?: ProvingJobController;
32
32
  private runningPromise: RunningPromise;
33
33
  private instrumentation: ProvingAgentInstrumentation;
34
- private idleTimer: Timer | undefined;
35
34
 
36
35
  public readonly tracer: Tracer;
37
36
 
@@ -64,7 +63,6 @@ export class ProvingAgent implements Traceable {
64
63
  }
65
64
 
66
65
  public start(): void {
67
- this.idleTimer = new Timer();
68
66
  this.runningPromise.start();
69
67
  }
70
68
 
@@ -75,39 +73,63 @@ export class ProvingAgent implements Traceable {
75
73
 
76
74
  @trackSpan('ProvingAgent.safeWork')
77
75
  private async work() {
78
- // every tick we need to
79
- // (1) either do a heartbeat, telling the broker that we're working
80
- // (2) get a new job
81
- // If during (1) the broker returns a new job that means we can cancel the current job and start the new one
82
- let maybeJob: { job: ProvingJob; time: number } | undefined;
83
- if (this.currentJobController?.getStatus() === ProvingJobControllerStatus.PROVING) {
84
- maybeJob = await this.broker.reportProvingJobProgress(
85
- this.currentJobController.getJobId(),
86
- this.currentJobController.getStartedAt(),
87
- { allowList: this.proofAllowList },
88
- );
76
+ // every tick we need to take one of the following actions:
77
+ // 1. send a hearbeat to the broker that we're working on some job
78
+ // 2. if the job is complete, send its result to the broker
79
+ // 3. get a job from the broker
80
+ // Any one of these actions could give us a new job to work on. If that happens we abort the current job.
81
+ //
82
+ // This loop gets triggered in one of two ways:
83
+ // - either on a timer (see pollIntervalMs)
84
+ // - or when a proof completes
85
+ let maybeJob: GetProvingJobResponse | undefined;
86
+
87
+ if (this.currentJobController) {
88
+ const status = this.currentJobController.getStatus();
89
+ const jobId = this.currentJobController.getJobId();
90
+ const proofType = this.currentJobController.getProofType();
91
+ const startedAt = this.currentJobController.getStartedAt();
92
+ const result = this.currentJobController.getResult();
93
+
94
+ if (status === ProvingJobControllerStatus.RUNNING) {
95
+ maybeJob = await this.broker.reportProvingJobProgress(jobId, startedAt, { allowList: this.proofAllowList });
96
+ } else if (status === ProvingJobControllerStatus.DONE) {
97
+ if (result) {
98
+ maybeJob = await this.reportResult(jobId, proofType, result);
99
+ } else {
100
+ this.log.warn(
101
+ `Job controller for job ${this.currentJobController.getJobId()} is done but doesn't have a result`,
102
+ { jobId },
103
+ );
104
+ maybeJob = await this.reportResult(
105
+ jobId,
106
+ proofType,
107
+ new ProvingError('No result found after proving', undefined, /* retry */ true),
108
+ );
109
+ }
110
+
111
+ this.currentJobController = undefined;
112
+ } else {
113
+ // IDLE status should not be seen because a job is started as soon as it is created
114
+ this.log.warn(`Idle job controller for job: ${this.currentJobController.getJobId()}. Skipping main loop work`, {
115
+ jobId: this.currentJobController.getJobId(),
116
+ });
117
+ return;
118
+ }
89
119
  } else {
90
120
  maybeJob = await this.broker.getProvingJob({ allowList: this.proofAllowList });
91
121
  }
92
122
 
93
- if (!maybeJob) {
94
- return;
95
- }
96
-
97
- if (this.idleTimer) {
98
- this.instrumentation.recordIdleTime(this.idleTimer);
123
+ if (maybeJob) {
124
+ await this.startJob(maybeJob);
99
125
  }
100
- this.idleTimer = undefined;
101
-
102
- const { job, time } = maybeJob;
103
- await this.startJob(job, time);
104
126
  }
105
127
 
106
- private async startJob(job: ProvingJob, startedAt: number): Promise<void> {
128
+ private async startJob({ job, time: startedAt }: GetProvingJobResponse): Promise<void> {
107
129
  let abortedProofJobId: string | undefined;
108
130
  let abortedProofName: string | undefined;
109
131
 
110
- if (this.currentJobController?.getStatus() === ProvingJobControllerStatus.PROVING) {
132
+ if (this.currentJobController?.getStatus() === ProvingJobControllerStatus.RUNNING) {
111
133
  abortedProofJobId = this.currentJobController.getJobId();
112
134
  abortedProofName = this.currentJobController.getProofTypeName();
113
135
  this.currentJobController?.abort();
@@ -122,7 +144,7 @@ export class ProvingAgent implements Traceable {
122
144
  });
123
145
 
124
146
  if (maybeJob) {
125
- return this.startJob(maybeJob.job, maybeJob.time);
147
+ return this.startJob(maybeJob);
126
148
  }
127
149
 
128
150
  return;
@@ -134,7 +156,11 @@ export class ProvingAgent implements Traceable {
134
156
  job.epochNumber,
135
157
  startedAt,
136
158
  this.circuitProver,
137
- this.handleJobResult,
159
+ () => {
160
+ // trigger a run of the main work loop when proving completes
161
+ // no need to await this here. The controller will stay alive (in DONE state) until the result is send to the broker
162
+ void this.runningPromise.trigger();
163
+ },
138
164
  );
139
165
 
140
166
  if (abortedProofJobId) {
@@ -154,28 +180,30 @@ export class ProvingAgent implements Traceable {
154
180
  this.currentJobController.start();
155
181
  }
156
182
 
157
- handleJobResult = async <T extends ProvingRequestType>(
183
+ private async reportResult<T extends ProvingRequestType>(
158
184
  jobId: ProvingJobId,
159
185
  type: T,
160
- err: Error | undefined,
161
- result: ProvingJobResultsMap[T] | undefined,
162
- ) => {
163
- let maybeJob: { job: ProvingJob; time: number } | undefined;
164
- if (err) {
165
- const retry = err.name === ProvingError.NAME ? (err as ProvingError).retry : false;
166
- this.log.error(`Job id=${jobId} type=${ProvingRequestType[type]} failed err=${err.message} retry=${retry}`, err);
167
- maybeJob = await this.broker.reportProvingJobError(jobId, err.message, retry, { allowList: this.proofAllowList });
168
- } else if (result) {
186
+ result: ProvingJobResultsMap[T] | Error,
187
+ ): Promise<GetProvingJobResponse | undefined> {
188
+ let maybeJob: GetProvingJobResponse | undefined;
189
+ if (result instanceof AbortError) {
190
+ // no-op
191
+ this.log.warn(`Job id=${jobId} was aborted. Not reporting result back to broker`, result);
192
+ } else if (result instanceof Error) {
193
+ const retry = result.name === ProvingError.NAME ? (result as ProvingError).retry : false;
194
+ this.log.error(
195
+ `Job id=${jobId} type=${ProvingRequestType[type]} failed err=${result.message} retry=${retry}`,
196
+ result,
197
+ );
198
+ maybeJob = await this.broker.reportProvingJobError(jobId, result.message, retry, {
199
+ allowList: this.proofAllowList,
200
+ });
201
+ } else {
169
202
  const outputUri = await this.proofStore.saveProofOutput(jobId, type, result);
170
203
  this.log.info(`Job id=${jobId} type=${ProvingRequestType[type]} completed outputUri=${truncate(outputUri)}`);
171
204
  maybeJob = await this.broker.reportProvingJobSuccess(jobId, outputUri, { allowList: this.proofAllowList });
172
205
  }
173
206
 
174
- if (maybeJob) {
175
- const { job, time } = maybeJob;
176
- await this.startJob(job, time);
177
- } else {
178
- this.idleTimer = new Timer();
179
- }
180
- };
207
+ return maybeJob;
208
+ }
181
209
  }
@@ -1,3 +1,5 @@
1
+ import { randomBytes } from '@aztec/foundation/crypto';
2
+ import { AbortError } from '@aztec/foundation/error';
1
3
  import { createLogger } from '@aztec/foundation/log';
2
4
  import type {
3
5
  ProvingJobId,
@@ -9,24 +11,15 @@ import { ProvingRequestType } from '@aztec/stdlib/proofs';
9
11
 
10
12
  export enum ProvingJobControllerStatus {
11
13
  IDLE = 'idle',
12
- PROVING = 'proving',
14
+ RUNNING = 'running',
13
15
  DONE = 'done',
14
- ABORTED = 'aborted',
15
- }
16
-
17
- interface ProvingJobCompletionCallback<T extends ProvingRequestType = ProvingRequestType> {
18
- (
19
- jobId: ProvingJobId,
20
- type: T,
21
- error: Error | undefined,
22
- result: ProvingJobResultsMap[T] | undefined,
23
- ): void | Promise<void>;
24
16
  }
25
17
 
26
18
  export class ProvingJobController {
27
19
  private status: ProvingJobControllerStatus = ProvingJobControllerStatus.IDLE;
28
20
  private promise?: Promise<void>;
29
21
  private abortController = new AbortController();
22
+ private result?: ProvingJobResultsMap[ProvingRequestType] | Error;
30
23
 
31
24
  constructor(
32
25
  private jobId: ProvingJobId,
@@ -34,13 +27,13 @@ export class ProvingJobController {
34
27
  private epochNumber: number,
35
28
  private startedAt: number,
36
29
  private circuitProver: ServerCircuitProver,
37
- private onComplete: ProvingJobCompletionCallback,
38
- private log = createLogger('prover-client:proving-agent:job-controller'),
30
+ private onComplete: () => void,
31
+ private log = createLogger('prover-client:proving-agent:job-controller-' + randomBytes(4).toString('hex')),
39
32
  ) {}
40
33
 
41
34
  public start(): void {
42
35
  if (this.status !== ProvingJobControllerStatus.IDLE) {
43
- this.log.verbose(
36
+ this.log.warn(
44
37
  `Job controller for jobId=${this.jobId} not starting because it is not idle currentStatus=${this.status}`,
45
38
  {
46
39
  currentStatus: this.status,
@@ -50,63 +43,23 @@ export class ProvingJobController {
50
43
  return;
51
44
  }
52
45
 
53
- this.status = ProvingJobControllerStatus.PROVING;
54
- this.log.verbose(`Job controller started jobId=${this.jobId}`, {
46
+ this.promise = this.run();
47
+
48
+ this.log.info(`Job controller started jobId=${this.jobId}`, {
55
49
  jobId: this.jobId,
56
50
  });
57
-
58
- this.promise = this.generateProof()
59
- .then(
60
- result => {
61
- if (this.status === ProvingJobControllerStatus.ABORTED) {
62
- this.log.warn(`Job controller for jobId=${this.jobId} completed successfully but job was aborted`, {
63
- currentStatus: this.status,
64
- jobId: this.jobId,
65
- });
66
- return;
67
- }
68
- this.status = ProvingJobControllerStatus.DONE;
69
- this.log.verbose(`Job controller for jobId=${this.jobId} completed successfully`, {
70
- jobId: this.jobId,
71
- });
72
- return this.onComplete(this.jobId, this.inputs.type, undefined, result);
73
- },
74
- error => {
75
- if (this.status === ProvingJobControllerStatus.ABORTED) {
76
- this.log.warn(`Job controller for jobId=${this.jobId} finished with an error but job was aborted`, {
77
- currentStatus: this.status,
78
- jobId: this.jobId,
79
- });
80
- return;
81
- }
82
-
83
- if (error.name === 'AbortError') {
84
- // Ignore abort errors
85
- return;
86
- }
87
-
88
- this.log.verbose(`Job controller for jobId=${this.jobId} finished with an error`, {
89
- jobId: this.jobId,
90
- err: error,
91
- });
92
-
93
- this.status = ProvingJobControllerStatus.DONE;
94
- return this.onComplete(this.jobId, this.inputs.type, error, undefined);
95
- },
96
- )
97
- .catch(err => {
98
- this.log.error(`Job constroller failed to send result for jobId=${this.jobId}: ${err}`, err, {
99
- jobId: this.jobId,
100
- });
101
- });
102
51
  }
103
52
 
104
53
  public getStatus(): ProvingJobControllerStatus {
105
54
  return this.status;
106
55
  }
107
56
 
57
+ public getResult(): ProvingJobResultsMap[ProvingRequestType] | Error | undefined {
58
+ return this.result;
59
+ }
60
+
108
61
  public abort(): void {
109
- if (this.status !== ProvingJobControllerStatus.PROVING) {
62
+ if (this.status !== ProvingJobControllerStatus.RUNNING) {
110
63
  this.log.warn(`Tried to abort job controller for jobId=${this.jobId} but it is not running`, {
111
64
  currentStatus: this.status,
112
65
  jobId: this.jobId,
@@ -114,9 +67,8 @@ export class ProvingJobController {
114
67
  return;
115
68
  }
116
69
 
117
- this.status = ProvingJobControllerStatus.ABORTED;
118
70
  this.abortController.abort();
119
- this.log.verbose(`Aborted job controller for jobId=${this.jobId}`, {
71
+ this.log.warn(`Aborted job controller for jobId=${this.jobId}`, {
120
72
  jobId: this.jobId,
121
73
  });
122
74
  }
@@ -125,6 +77,10 @@ export class ProvingJobController {
125
77
  return this.jobId;
126
78
  }
127
79
 
80
+ public getProofType(): ProvingRequestType {
81
+ return this.inputs.type;
82
+ }
83
+
128
84
  public getStartedAt(): number {
129
85
  return this.startedAt;
130
86
  }
@@ -133,6 +89,36 @@ export class ProvingJobController {
133
89
  return ProvingRequestType[this.inputs.type];
134
90
  }
135
91
 
92
+ private run = async () => {
93
+ this.status = ProvingJobControllerStatus.RUNNING;
94
+ let result: ProvingJobResultsMap[ProvingRequestType] | Error;
95
+ try {
96
+ result = await this.generateProof();
97
+ } catch (err) {
98
+ if (err && err instanceof Error) {
99
+ result = err;
100
+ } else {
101
+ result = new Error('Unknown proving error: ' + String(err), { cause: err });
102
+ }
103
+ }
104
+
105
+ if (this.abortController.signal.aborted) {
106
+ this.log.warn(`Job controller for jobId=${this.jobId} completed but job was aborted`, {
107
+ currentStatus: this.status,
108
+ jobId: this.jobId,
109
+ });
110
+ result = new AbortError('Proof was aborted');
111
+ }
112
+
113
+ this.result = result;
114
+ this.status = ProvingJobControllerStatus.DONE;
115
+ try {
116
+ this.onComplete();
117
+ } catch (err) {
118
+ this.log.warn(`On complete handler error: ${err}`, { jobId: this.jobId });
119
+ }
120
+ };
121
+
136
122
  private async generateProof(): Promise<ProvingJobResultsMap[ProvingRequestType]> {
137
123
  const { type, inputs } = this.inputs;
138
124
  const signal = this.abortController.signal;