@aztec/prover-client 0.0.0-test.1 → 0.0.1-fake-c83136db25

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.
Files changed (121) hide show
  1. package/dest/block-factory/index.d.ts +2 -0
  2. package/dest/block-factory/index.d.ts.map +1 -0
  3. package/dest/block-factory/light.d.ts +38 -0
  4. package/dest/block-factory/light.d.ts.map +1 -0
  5. package/dest/block-factory/light.js +94 -0
  6. package/dest/config.d.ts +6 -6
  7. package/dest/config.d.ts.map +1 -1
  8. package/dest/config.js +11 -1
  9. package/dest/mocks/fixtures.d.ts +7 -4
  10. package/dest/mocks/fixtures.d.ts.map +1 -1
  11. package/dest/mocks/fixtures.js +32 -4
  12. package/dest/mocks/test_context.d.ts +43 -15
  13. package/dest/mocks/test_context.d.ts.map +1 -1
  14. package/dest/mocks/test_context.js +110 -48
  15. package/dest/orchestrator/block-building-helpers.d.ts +37 -28
  16. package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
  17. package/dest/orchestrator/block-building-helpers.js +156 -150
  18. package/dest/orchestrator/block-proving-state.d.ts +62 -46
  19. package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
  20. package/dest/orchestrator/block-proving-state.js +223 -179
  21. package/dest/orchestrator/checkpoint-proving-state.d.ts +63 -0
  22. package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -0
  23. package/dest/orchestrator/checkpoint-proving-state.js +211 -0
  24. package/dest/orchestrator/epoch-proving-state.d.ts +37 -24
  25. package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
  26. package/dest/orchestrator/epoch-proving-state.js +143 -73
  27. package/dest/orchestrator/orchestrator.d.ts +34 -31
  28. package/dest/orchestrator/orchestrator.d.ts.map +1 -1
  29. package/dest/orchestrator/orchestrator.js +392 -234
  30. package/dest/orchestrator/orchestrator_metrics.d.ts +2 -0
  31. package/dest/orchestrator/orchestrator_metrics.d.ts.map +1 -1
  32. package/dest/orchestrator/orchestrator_metrics.js +9 -0
  33. package/dest/orchestrator/tx-proving-state.d.ts +12 -10
  34. package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
  35. package/dest/orchestrator/tx-proving-state.js +30 -38
  36. package/dest/prover-client/prover-client.d.ts +3 -3
  37. package/dest/prover-client/prover-client.d.ts.map +1 -1
  38. package/dest/prover-client/prover-client.js +5 -4
  39. package/dest/prover-client/server-epoch-prover.d.ts +13 -10
  40. package/dest/prover-client/server-epoch-prover.d.ts.map +1 -1
  41. package/dest/prover-client/server-epoch-prover.js +11 -11
  42. package/dest/proving_broker/broker_prover_facade.d.ts +22 -15
  43. package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
  44. package/dest/proving_broker/broker_prover_facade.js +64 -39
  45. package/dest/proving_broker/config.d.ts +9 -4
  46. package/dest/proving_broker/config.d.ts.map +1 -1
  47. package/dest/proving_broker/config.js +15 -4
  48. package/dest/proving_broker/factory.d.ts +1 -1
  49. package/dest/proving_broker/factory.d.ts.map +1 -1
  50. package/dest/proving_broker/factory.js +5 -1
  51. package/dest/proving_broker/fixtures.js +1 -1
  52. package/dest/proving_broker/proof_store/factory.js +1 -1
  53. package/dest/proving_broker/proof_store/gcs_proof_store.d.ts.map +1 -1
  54. package/dest/proving_broker/proof_store/gcs_proof_store.js +1 -0
  55. package/dest/proving_broker/proof_store/index.d.ts +1 -0
  56. package/dest/proving_broker/proof_store/index.d.ts.map +1 -1
  57. package/dest/proving_broker/proof_store/index.js +1 -0
  58. package/dest/proving_broker/proving_agent.d.ts +3 -3
  59. package/dest/proving_broker/proving_agent.d.ts.map +1 -1
  60. package/dest/proving_broker/proving_agent.js +83 -47
  61. package/dest/proving_broker/proving_broker.d.ts +11 -2
  62. package/dest/proving_broker/proving_broker.d.ts.map +1 -1
  63. package/dest/proving_broker/proving_broker.js +34 -22
  64. package/dest/proving_broker/proving_broker_database/memory.js +1 -1
  65. package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -1
  66. package/dest/proving_broker/proving_broker_database/persisted.js +9 -8
  67. package/dest/proving_broker/proving_job_controller.d.ts +7 -8
  68. package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
  69. package/dest/proving_broker/proving_job_controller.js +89 -61
  70. package/dest/proving_broker/rpc.d.ts +3 -5
  71. package/dest/proving_broker/rpc.d.ts.map +1 -1
  72. package/dest/proving_broker/rpc.js +1 -4
  73. package/dest/test/mock_proof_store.d.ts +9 -0
  74. package/dest/test/mock_proof_store.d.ts.map +1 -0
  75. package/dest/test/mock_proof_store.js +10 -0
  76. package/dest/test/mock_prover.d.ts +23 -16
  77. package/dest/test/mock_prover.d.ts.map +1 -1
  78. package/dest/test/mock_prover.js +38 -20
  79. package/package.json +29 -29
  80. package/src/block-factory/index.ts +1 -0
  81. package/src/block-factory/light.ts +140 -0
  82. package/src/config.ts +24 -8
  83. package/src/mocks/fixtures.ts +43 -15
  84. package/src/mocks/test_context.ts +201 -75
  85. package/src/orchestrator/block-building-helpers.ts +247 -243
  86. package/src/orchestrator/block-proving-state.ts +247 -231
  87. package/src/orchestrator/checkpoint-proving-state.ts +299 -0
  88. package/src/orchestrator/epoch-proving-state.ts +187 -111
  89. package/src/orchestrator/orchestrator.ts +590 -289
  90. package/src/orchestrator/orchestrator_metrics.ts +20 -1
  91. package/src/orchestrator/tx-proving-state.ts +60 -61
  92. package/src/prover-client/prover-client.ts +16 -14
  93. package/src/prover-client/server-epoch-prover.ts +40 -21
  94. package/src/proving_broker/broker_prover_facade.ts +200 -113
  95. package/src/proving_broker/config.ts +17 -6
  96. package/src/proving_broker/factory.ts +2 -1
  97. package/src/proving_broker/fixtures.ts +1 -1
  98. package/src/proving_broker/proof_store/factory.ts +1 -1
  99. package/src/proving_broker/proof_store/gcs_proof_store.ts +5 -1
  100. package/src/proving_broker/proof_store/index.ts +1 -0
  101. package/src/proving_broker/proof_store/inline_proof_store.ts +1 -1
  102. package/src/proving_broker/proving_agent.ts +89 -47
  103. package/src/proving_broker/proving_broker.ts +51 -32
  104. package/src/proving_broker/proving_broker_database/memory.ts +1 -1
  105. package/src/proving_broker/proving_broker_database/persisted.ts +9 -8
  106. package/src/proving_broker/proving_job_controller.ts +92 -81
  107. package/src/proving_broker/rpc.ts +1 -6
  108. package/src/test/mock_proof_store.ts +14 -0
  109. package/src/test/mock_prover.ts +164 -60
  110. package/dest/bin/get-proof-inputs.d.ts +0 -2
  111. package/dest/bin/get-proof-inputs.d.ts.map +0 -1
  112. package/dest/bin/get-proof-inputs.js +0 -51
  113. package/dest/block_builder/index.d.ts +0 -6
  114. package/dest/block_builder/index.d.ts.map +0 -1
  115. package/dest/block_builder/light.d.ts +0 -33
  116. package/dest/block_builder/light.d.ts.map +0 -1
  117. package/dest/block_builder/light.js +0 -82
  118. package/src/bin/get-proof-inputs.ts +0 -59
  119. package/src/block_builder/index.ts +0 -6
  120. package/src/block_builder/light.ts +0 -101
  121. /package/dest/{block_builder → block-factory}/index.js +0 -0
@@ -1,10 +1,11 @@
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
+ ProverAgentStatus,
8
9
  ProvingJobConsumer,
9
10
  ProvingJobId,
10
11
  ProvingJobInputs,
@@ -31,7 +32,6 @@ export class ProvingAgent implements Traceable {
31
32
  private currentJobController?: ProvingJobController;
32
33
  private runningPromise: RunningPromise;
33
34
  private instrumentation: ProvingAgentInstrumentation;
34
- private idleTimer: Timer | undefined;
35
35
 
36
36
  public readonly tracer: Tracer;
37
37
 
@@ -64,7 +64,6 @@ export class ProvingAgent implements Traceable {
64
64
  }
65
65
 
66
66
  public start(): void {
67
- this.idleTimer = new Timer();
68
67
  this.runningPromise.start();
69
68
  }
70
69
 
@@ -73,41 +72,78 @@ export class ProvingAgent implements Traceable {
73
72
  await this.runningPromise.stop();
74
73
  }
75
74
 
75
+ public getStatus(): ProverAgentStatus {
76
+ if (this.currentJobController) {
77
+ return {
78
+ status: 'proving',
79
+ jobId: this.currentJobController.getJobId(),
80
+ proofType: this.currentJobController.getProofType(),
81
+ startedAtISO: new Date(this.currentJobController.getStartedAt()).toISOString(),
82
+ };
83
+ }
84
+
85
+ return this.runningPromise.isRunning() ? { status: 'running' } : { status: 'stopped' };
86
+ }
87
+
76
88
  @trackSpan('ProvingAgent.safeWork')
77
89
  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
- );
90
+ // every tick we need to take one of the following actions:
91
+ // 1. send a hearbeat to the broker that we're working on some job
92
+ // 2. if the job is complete, send its result to the broker
93
+ // 3. get a job from the broker
94
+ // Any one of these actions could give us a new job to work on. If that happens we abort the current job.
95
+ //
96
+ // This loop gets triggered in one of two ways:
97
+ // - either on a timer (see pollIntervalMs)
98
+ // - or when a proof completes
99
+ let maybeJob: GetProvingJobResponse | undefined;
100
+
101
+ if (this.currentJobController) {
102
+ const status = this.currentJobController.getStatus();
103
+ const jobId = this.currentJobController.getJobId();
104
+ const proofType = this.currentJobController.getProofType();
105
+ const startedAt = this.currentJobController.getStartedAt();
106
+ const result = this.currentJobController.getResult();
107
+
108
+ if (status === ProvingJobControllerStatus.RUNNING) {
109
+ maybeJob = await this.broker.reportProvingJobProgress(jobId, startedAt, { allowList: this.proofAllowList });
110
+ } else if (status === ProvingJobControllerStatus.DONE) {
111
+ if (result) {
112
+ maybeJob = await this.reportResult(jobId, proofType, result);
113
+ } else {
114
+ this.log.warn(
115
+ `Job controller for job ${this.currentJobController.getJobId()} is done but doesn't have a result`,
116
+ { jobId },
117
+ );
118
+ maybeJob = await this.reportResult(
119
+ jobId,
120
+ proofType,
121
+ new ProvingError('No result found after proving', undefined, /* retry */ true),
122
+ );
123
+ }
124
+
125
+ this.currentJobController = undefined;
126
+ } else {
127
+ // IDLE status should not be seen because a job is started as soon as it is created
128
+ this.log.warn(`Idle job controller for job: ${this.currentJobController.getJobId()}. Skipping main loop work`, {
129
+ jobId: this.currentJobController.getJobId(),
130
+ });
131
+ return;
132
+ }
89
133
  } else {
90
134
  maybeJob = await this.broker.getProvingJob({ allowList: this.proofAllowList });
91
135
  }
92
136
 
93
- if (!maybeJob) {
94
- return;
95
- }
96
-
97
- if (this.idleTimer) {
98
- this.instrumentation.recordIdleTime(this.idleTimer);
137
+ if (maybeJob) {
138
+ await this.startJob(maybeJob);
99
139
  }
100
- this.idleTimer = undefined;
101
-
102
- const { job, time } = maybeJob;
103
- await this.startJob(job, time);
104
140
  }
105
141
 
106
- private async startJob(job: ProvingJob, startedAt: number): Promise<void> {
142
+ private async startJob({ job, time: startedAt }: GetProvingJobResponse): Promise<void> {
107
143
  let abortedProofJobId: string | undefined;
108
144
  let abortedProofName: string | undefined;
109
145
 
110
- if (this.currentJobController?.getStatus() === ProvingJobControllerStatus.PROVING) {
146
+ if (this.currentJobController?.getStatus() === ProvingJobControllerStatus.RUNNING) {
111
147
  abortedProofJobId = this.currentJobController.getJobId();
112
148
  abortedProofName = this.currentJobController.getProofTypeName();
113
149
  this.currentJobController?.abort();
@@ -116,13 +152,13 @@ export class ProvingAgent implements Traceable {
116
152
  let inputs: ProvingJobInputs;
117
153
  try {
118
154
  inputs = await this.proofStore.getProofInput(job.inputsUri);
119
- } catch (err) {
155
+ } catch {
120
156
  const maybeJob = await this.broker.reportProvingJobError(job.id, 'Failed to load proof inputs', true, {
121
157
  allowList: this.proofAllowList,
122
158
  });
123
159
 
124
160
  if (maybeJob) {
125
- return this.startJob(maybeJob.job, maybeJob.time);
161
+ return this.startJob(maybeJob);
126
162
  }
127
163
 
128
164
  return;
@@ -134,7 +170,11 @@ export class ProvingAgent implements Traceable {
134
170
  job.epochNumber,
135
171
  startedAt,
136
172
  this.circuitProver,
137
- this.handleJobResult,
173
+ () => {
174
+ // trigger a run of the main work loop when proving completes
175
+ // no need to await this here. The controller will stay alive (in DONE state) until the result is send to the broker
176
+ void this.runningPromise.trigger();
177
+ },
138
178
  );
139
179
 
140
180
  if (abortedProofJobId) {
@@ -154,28 +194,30 @@ export class ProvingAgent implements Traceable {
154
194
  this.currentJobController.start();
155
195
  }
156
196
 
157
- handleJobResult = async <T extends ProvingRequestType>(
197
+ private async reportResult<T extends ProvingRequestType>(
158
198
  jobId: ProvingJobId,
159
199
  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) {
200
+ result: ProvingJobResultsMap[T] | Error,
201
+ ): Promise<GetProvingJobResponse | undefined> {
202
+ let maybeJob: GetProvingJobResponse | undefined;
203
+ if (result instanceof AbortError) {
204
+ // no-op
205
+ this.log.warn(`Job id=${jobId} was aborted. Not reporting result back to broker`, result);
206
+ } else if (result instanceof Error) {
207
+ const retry = result.name === ProvingError.NAME ? (result as ProvingError).retry : false;
208
+ this.log.error(
209
+ `Job id=${jobId} type=${ProvingRequestType[type]} failed err=${result.message} retry=${retry}`,
210
+ result,
211
+ );
212
+ maybeJob = await this.broker.reportProvingJobError(jobId, result.message, retry, {
213
+ allowList: this.proofAllowList,
214
+ });
215
+ } else {
169
216
  const outputUri = await this.proofStore.saveProofOutput(jobId, type, result);
170
217
  this.log.info(`Job id=${jobId} type=${ProvingRequestType[type]} completed outputUri=${truncate(outputUri)}`);
171
218
  maybeJob = await this.broker.reportProvingJobSuccess(jobId, outputUri, { allowList: this.proofAllowList });
172
219
  }
173
220
 
174
- if (maybeJob) {
175
- const { job, time } = maybeJob;
176
- await this.startJob(job, time);
177
- } else {
178
- this.idleTimer = new Timer();
179
- }
180
- };
221
+ return maybeJob;
222
+ }
181
223
  }
@@ -2,16 +2,17 @@ import { createLogger } from '@aztec/foundation/log';
2
2
  import { type PromiseWithResolvers, RunningPromise, promiseWithResolvers } from '@aztec/foundation/promise';
3
3
  import { PriorityMemoryQueue } from '@aztec/foundation/queue';
4
4
  import { Timer } from '@aztec/foundation/timer';
5
- import type {
6
- GetProvingJobResponse,
7
- ProofUri,
8
- ProvingJob,
9
- ProvingJobConsumer,
10
- ProvingJobFilter,
11
- ProvingJobId,
12
- ProvingJobProducer,
13
- ProvingJobSettledResult,
14
- ProvingJobStatus,
5
+ import {
6
+ type GetProvingJobResponse,
7
+ type ProofUri,
8
+ type ProvingJob,
9
+ type ProvingJobConsumer,
10
+ type ProvingJobFilter,
11
+ type ProvingJobId,
12
+ type ProvingJobProducer,
13
+ type ProvingJobSettledResult,
14
+ type ProvingJobStatus,
15
+ tryStop,
15
16
  } from '@aztec/stdlib/interfaces/server';
16
17
  import { ProvingRequestType } from '@aztec/stdlib/proofs';
17
18
  import {
@@ -43,20 +44,33 @@ type EnqueuedProvingJob = Pick<ProvingJob, 'id' | 'epochNumber'>;
43
44
  export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Traceable {
44
45
  private queues: ProvingQueues = {
45
46
  [ProvingRequestType.PUBLIC_VM]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
46
- [ProvingRequestType.TUBE_PROOF]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
47
+ [ProvingRequestType.PUBLIC_CHONK_VERIFIER]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
47
48
 
48
- [ProvingRequestType.PRIVATE_BASE_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
49
- [ProvingRequestType.PUBLIC_BASE_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
50
- [ProvingRequestType.MERGE_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
49
+ [ProvingRequestType.PRIVATE_TX_BASE_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
50
+ [ProvingRequestType.PUBLIC_TX_BASE_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
51
+ [ProvingRequestType.TX_MERGE_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
51
52
  [ProvingRequestType.ROOT_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
52
53
 
53
54
  [ProvingRequestType.BLOCK_MERGE_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
55
+ [ProvingRequestType.BLOCK_ROOT_FIRST_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
56
+ [ProvingRequestType.BLOCK_ROOT_SINGLE_TX_FIRST_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(
57
+ provingJobComparator,
58
+ ),
59
+ [ProvingRequestType.BLOCK_ROOT_EMPTY_TX_FIRST_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(
60
+ provingJobComparator,
61
+ ),
54
62
  [ProvingRequestType.BLOCK_ROOT_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
55
- [ProvingRequestType.SINGLE_TX_BLOCK_ROOT_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
56
- [ProvingRequestType.EMPTY_BLOCK_ROOT_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
63
+ [ProvingRequestType.BLOCK_ROOT_SINGLE_TX_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
64
+
65
+ [ProvingRequestType.CHECKPOINT_ROOT_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
66
+ [ProvingRequestType.CHECKPOINT_ROOT_SINGLE_BLOCK_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(
67
+ provingJobComparator,
68
+ ),
69
+ [ProvingRequestType.CHECKPOINT_MERGE_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
70
+ [ProvingRequestType.CHECKPOINT_PADDING_ROLLUP]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
57
71
 
58
- [ProvingRequestType.BASE_PARITY]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
59
- [ProvingRequestType.ROOT_PARITY]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
72
+ [ProvingRequestType.PARITY_BASE]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
73
+ [ProvingRequestType.PARITY_ROOT]: new PriorityMemoryQueue<EnqueuedProvingJob>(provingJobComparator),
60
74
  };
61
75
 
62
76
  // holds a copy of the database in memory in order to quickly fulfill requests
@@ -93,7 +107,7 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
93
107
  /**
94
108
  * The broker keeps track of the highest epoch its seen.
95
109
  * This information is used for garbage collection: once it reaches the next epoch, it can start pruning the database of old state.
96
- * It is important that this value is initialised to zero. This ensures that we don't delete any old jobs until the current
110
+ * It is important that this value is initialized to zero. This ensures that we don't delete any old jobs until the current
97
111
  * process instance receives a job request informing it of the actual current highest epoch
98
112
  * Example:
99
113
  * proving epoch 11 - the broker will wipe all jobs for epochs 9 and lower
@@ -184,7 +198,7 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
184
198
  this.logger.warn('ProvingBroker not started');
185
199
  return Promise.resolve();
186
200
  }
187
- await this.cleanupPromise.stop();
201
+ await tryStop(this.cleanupPromise);
188
202
  }
189
203
 
190
204
  public enqueueProvingJob(job: ProvingJob): Promise<ProvingJobStatus> {
@@ -313,7 +327,6 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
313
327
  return Promise.resolve(notifications.concat(completedJobs));
314
328
  }
315
329
 
316
- // eslint-disable-next-line require-await
317
330
  #getProvingJob(filter: ProvingJobFilter = { allowList: [] }): { job: ProvingJob; time: number } | undefined {
318
331
  const allowedProofs: ProvingRequestType[] =
319
332
  Array.isArray(filter.allowList) && filter.allowList.length > 0
@@ -571,7 +584,7 @@ export class ProvingBroker implements ProvingJobProducer, ProvingJobConsumer, Tr
571
584
 
572
585
  if (jobsToClean.length > 0) {
573
586
  this.cleanUpProvingJobState(jobsToClean);
574
- this.logger.info(`Cleaned up jobs=${jobsToClean.length}`);
587
+ this.logger.verbose(`Cleaned up proving jobs=${jobsToClean.length}`);
575
588
  }
576
589
  }
577
590
 
@@ -671,17 +684,23 @@ function proofTypeComparator(a: ProvingRequestType, b: ProvingRequestType): -1 |
671
684
  * The aim is that this will speed up block proving as the closer we get to a block's root proof the more likely it
672
685
  * is to get picked up by agents
673
686
  */
674
- const PROOF_TYPES_IN_PRIORITY_ORDER: ProvingRequestType[] = [
687
+ export const PROOF_TYPES_IN_PRIORITY_ORDER: ProvingRequestType[] = [
688
+ ProvingRequestType.ROOT_ROLLUP,
689
+ ProvingRequestType.BLOCK_ROOT_FIRST_ROLLUP,
690
+ ProvingRequestType.BLOCK_ROOT_SINGLE_TX_FIRST_ROLLUP,
691
+ ProvingRequestType.BLOCK_ROOT_EMPTY_TX_FIRST_ROLLUP,
675
692
  ProvingRequestType.BLOCK_ROOT_ROLLUP,
676
- ProvingRequestType.SINGLE_TX_BLOCK_ROOT_ROLLUP,
693
+ ProvingRequestType.BLOCK_ROOT_SINGLE_TX_ROLLUP,
677
694
  ProvingRequestType.BLOCK_MERGE_ROLLUP,
678
- ProvingRequestType.ROOT_ROLLUP,
679
- ProvingRequestType.MERGE_ROLLUP,
680
- ProvingRequestType.PUBLIC_BASE_ROLLUP,
681
- ProvingRequestType.PRIVATE_BASE_ROLLUP,
695
+ ProvingRequestType.CHECKPOINT_ROOT_ROLLUP,
696
+ ProvingRequestType.CHECKPOINT_ROOT_SINGLE_BLOCK_ROLLUP,
697
+ ProvingRequestType.CHECKPOINT_MERGE_ROLLUP,
698
+ ProvingRequestType.CHECKPOINT_PADDING_ROLLUP,
699
+ ProvingRequestType.TX_MERGE_ROLLUP,
700
+ ProvingRequestType.PUBLIC_TX_BASE_ROLLUP,
701
+ ProvingRequestType.PRIVATE_TX_BASE_ROLLUP,
682
702
  ProvingRequestType.PUBLIC_VM,
683
- ProvingRequestType.TUBE_PROOF,
684
- ProvingRequestType.ROOT_PARITY,
685
- ProvingRequestType.BASE_PARITY,
686
- ProvingRequestType.EMPTY_BLOCK_ROOT_ROLLUP,
703
+ ProvingRequestType.PUBLIC_CHONK_VERIFIER,
704
+ ProvingRequestType.PARITY_ROOT,
705
+ ProvingRequestType.PARITY_BASE,
687
706
  ];
@@ -52,7 +52,7 @@ export class InMemoryBrokerDatabase implements ProvingBrokerDatabase {
52
52
  }
53
53
 
54
54
  async *allProvingJobs(): AsyncIterableIterator<[ProvingJob, ProvingJobSettledResult | undefined]> {
55
- for await (const item of this.jobs.values()) {
55
+ for (const item of this.jobs.values()) {
56
56
  yield [item, this.results.get(item.id)] as const;
57
57
  }
58
58
  }
@@ -46,9 +46,9 @@ class SingleEpochDatabase {
46
46
 
47
47
  async *allProvingJobs(): AsyncIterableIterator<[ProvingJob, ProvingJobSettledResult | undefined]> {
48
48
  for await (const jobStr of this.jobs.valuesAsync()) {
49
- const job = await jsonParseWithSchema(jobStr, ProvingJob);
49
+ const job = jsonParseWithSchema(jobStr, ProvingJob);
50
50
  const resultStr = await this.jobResults.getAsync(job.id);
51
- const result = resultStr ? await jsonParseWithSchema(resultStr, ProvingJobSettledResult) : undefined;
51
+ const result = resultStr ? jsonParseWithSchema(resultStr, ProvingJobSettledResult) : undefined;
52
52
  yield [job, result];
53
53
  }
54
54
  }
@@ -111,7 +111,8 @@ export class KVBrokerDatabase implements ProvingBrokerDatabase {
111
111
  private async estimateSize() {
112
112
  const sizes = await Promise.all(Array.from(this.epochs.values()).map(x => x.estimateSize()));
113
113
  return {
114
- mappingSize: this.config.dataStoreMapSizeKB,
114
+ mappingSize: this.config.dataStoreMapSizeKb,
115
+ physicalFileSize: sizes.reduce((prev, curr) => prev + curr.physicalFileSize, 0),
115
116
  numItems: sizes.reduce((prev, curr) => prev + curr.numItems, 0),
116
117
  actualSize: sizes.reduce((prev, curr) => prev + curr.actualSize, 0),
117
118
  };
@@ -136,13 +137,13 @@ export class KVBrokerDatabase implements ProvingBrokerDatabase {
136
137
  continue;
137
138
  }
138
139
  logger.info(
139
- `Loading broker database for epoch ${epochNumber} from ${fullDirectory} with map size ${config.dataStoreMapSizeKB}KB`,
140
+ `Loading broker database for epoch ${epochNumber} from ${fullDirectory} with map size ${config.dataStoreMapSizeKb}KB`,
140
141
  );
141
142
  const db = await openVersionedStoreAt(
142
143
  fullDirectory,
143
144
  SingleEpochDatabase.SCHEMA_VERSION,
144
145
  config.l1Contracts.rollupAddress,
145
- config.dataStoreMapSizeKB,
146
+ config.dataStoreMapSizeKb,
146
147
  );
147
148
  const epochDb = new SingleEpochDatabase(db);
148
149
  epochs.set(epochNumber, epochDb);
@@ -170,7 +171,7 @@ export class KVBrokerDatabase implements ProvingBrokerDatabase {
170
171
  if (!db) {
171
172
  continue;
172
173
  }
173
- this.logger.info(`Deleting broker database for epoch ${old}`);
174
+ this.logger.verbose(`Deleting broker database for epoch ${old}`);
174
175
  await db.delete();
175
176
  this.epochs.delete(old);
176
177
  }
@@ -201,13 +202,13 @@ export class KVBrokerDatabase implements ProvingBrokerDatabase {
201
202
  const newEpochDirectory = join(this.config.dataDirectory!, epochNumber.toString());
202
203
  await mkdir(newEpochDirectory, { recursive: true });
203
204
  this.logger.info(
204
- `Creating broker database for epoch ${epochNumber} at ${newEpochDirectory} with map size ${this.config.dataStoreMapSizeKB}`,
205
+ `Creating broker database for epoch ${epochNumber} at ${newEpochDirectory} with map size ${this.config.dataStoreMapSizeKb}`,
205
206
  );
206
207
  const db = await openVersionedStoreAt(
207
208
  newEpochDirectory,
208
209
  SingleEpochDatabase.SCHEMA_VERSION,
209
210
  this.config.l1Contracts.rollupAddress,
210
- this.config.dataStoreMapSizeKB,
211
+ this.config.dataStoreMapSizeKb,
211
212
  );
212
213
  epochDb = new SingleEpochDatabase(db);
213
214
  this.epochs.set(epochNumber, epochDb);