@aztec/prover-node 4.0.0-nightly.20250907 → 4.0.0-nightly.20260108

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 (48) hide show
  1. package/dest/actions/download-epoch-proving-job.d.ts +4 -4
  2. package/dest/actions/index.d.ts +1 -1
  3. package/dest/actions/rerun-epoch-proving-job.d.ts +2 -2
  4. package/dest/actions/upload-epoch-proof-failure.d.ts +1 -1
  5. package/dest/bin/run-failed-epoch.d.ts +1 -1
  6. package/dest/bin/run-failed-epoch.js +1 -1
  7. package/dest/config.d.ts +7 -4
  8. package/dest/config.d.ts.map +1 -1
  9. package/dest/config.js +21 -15
  10. package/dest/factory.d.ts +2 -4
  11. package/dest/factory.d.ts.map +1 -1
  12. package/dest/factory.js +31 -13
  13. package/dest/index.d.ts +1 -1
  14. package/dest/job/epoch-proving-job-data.d.ts +8 -6
  15. package/dest/job/epoch-proving-job-data.d.ts.map +1 -1
  16. package/dest/job/epoch-proving-job-data.js +25 -18
  17. package/dest/job/epoch-proving-job.d.ts +11 -16
  18. package/dest/job/epoch-proving-job.d.ts.map +1 -1
  19. package/dest/job/epoch-proving-job.js +493 -77
  20. package/dest/metrics.d.ts +4 -3
  21. package/dest/metrics.d.ts.map +1 -1
  22. package/dest/metrics.js +9 -3
  23. package/dest/monitors/epoch-monitor.d.ts +5 -2
  24. package/dest/monitors/epoch-monitor.d.ts.map +1 -1
  25. package/dest/monitors/epoch-monitor.js +11 -11
  26. package/dest/monitors/index.d.ts +1 -1
  27. package/dest/prover-node-publisher.d.ts +9 -10
  28. package/dest/prover-node-publisher.d.ts.map +1 -1
  29. package/dest/prover-node-publisher.js +51 -53
  30. package/dest/prover-node.d.ts +8 -7
  31. package/dest/prover-node.d.ts.map +1 -1
  32. package/dest/prover-node.js +435 -50
  33. package/dest/prover-publisher-factory.d.ts +6 -2
  34. package/dest/prover-publisher-factory.d.ts.map +1 -1
  35. package/dest/prover-publisher-factory.js +6 -0
  36. package/dest/test/index.d.ts +1 -1
  37. package/dest/test/index.d.ts.map +1 -1
  38. package/package.json +26 -25
  39. package/src/bin/run-failed-epoch.ts +2 -2
  40. package/src/config.ts +33 -30
  41. package/src/factory.ts +37 -20
  42. package/src/job/epoch-proving-job-data.ts +31 -25
  43. package/src/job/epoch-proving-job.ts +138 -82
  44. package/src/metrics.ts +16 -4
  45. package/src/monitors/epoch-monitor.ts +16 -13
  46. package/src/prover-node-publisher.ts +74 -73
  47. package/src/prover-node.ts +52 -45
  48. package/src/prover-publisher-factory.ts +12 -1
@@ -1,22 +1,399 @@
1
- function _ts_decorate(decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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
- return c > 3 && r && Object.defineProperty(target, key, r), r;
1
+ function applyDecs2203RFactory() {
2
+ function createAddInitializerMethod(initializers, decoratorFinishedRef) {
3
+ return function addInitializer(initializer) {
4
+ assertNotFinished(decoratorFinishedRef, "addInitializer");
5
+ assertCallable(initializer, "An initializer");
6
+ initializers.push(initializer);
7
+ };
8
+ }
9
+ function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
10
+ var kindStr;
11
+ switch(kind){
12
+ case 1:
13
+ kindStr = "accessor";
14
+ break;
15
+ case 2:
16
+ kindStr = "method";
17
+ break;
18
+ case 3:
19
+ kindStr = "getter";
20
+ break;
21
+ case 4:
22
+ kindStr = "setter";
23
+ break;
24
+ default:
25
+ kindStr = "field";
26
+ }
27
+ var ctx = {
28
+ kind: kindStr,
29
+ name: isPrivate ? "#" + name : name,
30
+ static: isStatic,
31
+ private: isPrivate,
32
+ metadata: metadata
33
+ };
34
+ var decoratorFinishedRef = {
35
+ v: false
36
+ };
37
+ ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
38
+ var get, set;
39
+ if (kind === 0) {
40
+ if (isPrivate) {
41
+ get = desc.get;
42
+ set = desc.set;
43
+ } else {
44
+ get = function() {
45
+ return this[name];
46
+ };
47
+ set = function(v) {
48
+ this[name] = v;
49
+ };
50
+ }
51
+ } else if (kind === 2) {
52
+ get = function() {
53
+ return desc.value;
54
+ };
55
+ } else {
56
+ if (kind === 1 || kind === 3) {
57
+ get = function() {
58
+ return desc.get.call(this);
59
+ };
60
+ }
61
+ if (kind === 1 || kind === 4) {
62
+ set = function(v) {
63
+ desc.set.call(this, v);
64
+ };
65
+ }
66
+ }
67
+ ctx.access = get && set ? {
68
+ get: get,
69
+ set: set
70
+ } : get ? {
71
+ get: get
72
+ } : {
73
+ set: set
74
+ };
75
+ try {
76
+ return dec(value, ctx);
77
+ } finally{
78
+ decoratorFinishedRef.v = true;
79
+ }
80
+ }
81
+ function assertNotFinished(decoratorFinishedRef, fnName) {
82
+ if (decoratorFinishedRef.v) {
83
+ throw new Error("attempted to call " + fnName + " after decoration was finished");
84
+ }
85
+ }
86
+ function assertCallable(fn, hint) {
87
+ if (typeof fn !== "function") {
88
+ throw new TypeError(hint + " must be a function");
89
+ }
90
+ }
91
+ function assertValidReturnValue(kind, value) {
92
+ var type = typeof value;
93
+ if (kind === 1) {
94
+ if (type !== "object" || value === null) {
95
+ throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
96
+ }
97
+ if (value.get !== undefined) {
98
+ assertCallable(value.get, "accessor.get");
99
+ }
100
+ if (value.set !== undefined) {
101
+ assertCallable(value.set, "accessor.set");
102
+ }
103
+ if (value.init !== undefined) {
104
+ assertCallable(value.init, "accessor.init");
105
+ }
106
+ } else if (type !== "function") {
107
+ var hint;
108
+ if (kind === 0) {
109
+ hint = "field";
110
+ } else if (kind === 10) {
111
+ hint = "class";
112
+ } else {
113
+ hint = "method";
114
+ }
115
+ throw new TypeError(hint + " decorators must return a function or void 0");
116
+ }
117
+ }
118
+ function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
119
+ var decs = decInfo[0];
120
+ var desc, init, value;
121
+ if (isPrivate) {
122
+ if (kind === 0 || kind === 1) {
123
+ desc = {
124
+ get: decInfo[3],
125
+ set: decInfo[4]
126
+ };
127
+ } else if (kind === 3) {
128
+ desc = {
129
+ get: decInfo[3]
130
+ };
131
+ } else if (kind === 4) {
132
+ desc = {
133
+ set: decInfo[3]
134
+ };
135
+ } else {
136
+ desc = {
137
+ value: decInfo[3]
138
+ };
139
+ }
140
+ } else if (kind !== 0) {
141
+ desc = Object.getOwnPropertyDescriptor(base, name);
142
+ }
143
+ if (kind === 1) {
144
+ value = {
145
+ get: desc.get,
146
+ set: desc.set
147
+ };
148
+ } else if (kind === 2) {
149
+ value = desc.value;
150
+ } else if (kind === 3) {
151
+ value = desc.get;
152
+ } else if (kind === 4) {
153
+ value = desc.set;
154
+ }
155
+ var newValue, get, set;
156
+ if (typeof decs === "function") {
157
+ newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
158
+ if (newValue !== void 0) {
159
+ assertValidReturnValue(kind, newValue);
160
+ if (kind === 0) {
161
+ init = newValue;
162
+ } else if (kind === 1) {
163
+ init = newValue.init;
164
+ get = newValue.get || value.get;
165
+ set = newValue.set || value.set;
166
+ value = {
167
+ get: get,
168
+ set: set
169
+ };
170
+ } else {
171
+ value = newValue;
172
+ }
173
+ }
174
+ } else {
175
+ for(var i = decs.length - 1; i >= 0; i--){
176
+ var dec = decs[i];
177
+ newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
178
+ if (newValue !== void 0) {
179
+ assertValidReturnValue(kind, newValue);
180
+ var newInit;
181
+ if (kind === 0) {
182
+ newInit = newValue;
183
+ } else if (kind === 1) {
184
+ newInit = newValue.init;
185
+ get = newValue.get || value.get;
186
+ set = newValue.set || value.set;
187
+ value = {
188
+ get: get,
189
+ set: set
190
+ };
191
+ } else {
192
+ value = newValue;
193
+ }
194
+ if (newInit !== void 0) {
195
+ if (init === void 0) {
196
+ init = newInit;
197
+ } else if (typeof init === "function") {
198
+ init = [
199
+ init,
200
+ newInit
201
+ ];
202
+ } else {
203
+ init.push(newInit);
204
+ }
205
+ }
206
+ }
207
+ }
208
+ }
209
+ if (kind === 0 || kind === 1) {
210
+ if (init === void 0) {
211
+ init = function(instance, init) {
212
+ return init;
213
+ };
214
+ } else if (typeof init !== "function") {
215
+ var ownInitializers = init;
216
+ init = function(instance, init) {
217
+ var value = init;
218
+ for(var i = 0; i < ownInitializers.length; i++){
219
+ value = ownInitializers[i].call(instance, value);
220
+ }
221
+ return value;
222
+ };
223
+ } else {
224
+ var originalInitializer = init;
225
+ init = function(instance, init) {
226
+ return originalInitializer.call(instance, init);
227
+ };
228
+ }
229
+ ret.push(init);
230
+ }
231
+ if (kind !== 0) {
232
+ if (kind === 1) {
233
+ desc.get = value.get;
234
+ desc.set = value.set;
235
+ } else if (kind === 2) {
236
+ desc.value = value;
237
+ } else if (kind === 3) {
238
+ desc.get = value;
239
+ } else if (kind === 4) {
240
+ desc.set = value;
241
+ }
242
+ if (isPrivate) {
243
+ if (kind === 1) {
244
+ ret.push(function(instance, args) {
245
+ return value.get.call(instance, args);
246
+ });
247
+ ret.push(function(instance, args) {
248
+ return value.set.call(instance, args);
249
+ });
250
+ } else if (kind === 2) {
251
+ ret.push(value);
252
+ } else {
253
+ ret.push(function(instance, args) {
254
+ return value.call(instance, args);
255
+ });
256
+ }
257
+ } else {
258
+ Object.defineProperty(base, name, desc);
259
+ }
260
+ }
261
+ }
262
+ function applyMemberDecs(Class, decInfos, metadata) {
263
+ var ret = [];
264
+ var protoInitializers;
265
+ var staticInitializers;
266
+ var existingProtoNonFields = new Map();
267
+ var existingStaticNonFields = new Map();
268
+ for(var i = 0; i < decInfos.length; i++){
269
+ var decInfo = decInfos[i];
270
+ if (!Array.isArray(decInfo)) continue;
271
+ var kind = decInfo[1];
272
+ var name = decInfo[2];
273
+ var isPrivate = decInfo.length > 3;
274
+ var isStatic = kind >= 5;
275
+ var base;
276
+ var initializers;
277
+ if (isStatic) {
278
+ base = Class;
279
+ kind = kind - 5;
280
+ staticInitializers = staticInitializers || [];
281
+ initializers = staticInitializers;
282
+ } else {
283
+ base = Class.prototype;
284
+ protoInitializers = protoInitializers || [];
285
+ initializers = protoInitializers;
286
+ }
287
+ if (kind !== 0 && !isPrivate) {
288
+ var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
289
+ var existingKind = existingNonFields.get(name) || 0;
290
+ if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) {
291
+ throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
292
+ } else if (!existingKind && kind > 2) {
293
+ existingNonFields.set(name, kind);
294
+ } else {
295
+ existingNonFields.set(name, true);
296
+ }
297
+ }
298
+ applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
299
+ }
300
+ pushInitializers(ret, protoInitializers);
301
+ pushInitializers(ret, staticInitializers);
302
+ return ret;
303
+ }
304
+ function pushInitializers(ret, initializers) {
305
+ if (initializers) {
306
+ ret.push(function(instance) {
307
+ for(var i = 0; i < initializers.length; i++){
308
+ initializers[i].call(instance);
309
+ }
310
+ return instance;
311
+ });
312
+ }
313
+ }
314
+ function applyClassDecs(targetClass, classDecs, metadata) {
315
+ if (classDecs.length > 0) {
316
+ var initializers = [];
317
+ var newClass = targetClass;
318
+ var name = targetClass.name;
319
+ for(var i = classDecs.length - 1; i >= 0; i--){
320
+ var decoratorFinishedRef = {
321
+ v: false
322
+ };
323
+ try {
324
+ var nextNewClass = classDecs[i](newClass, {
325
+ kind: "class",
326
+ name: name,
327
+ addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
328
+ metadata
329
+ });
330
+ } finally{
331
+ decoratorFinishedRef.v = true;
332
+ }
333
+ if (nextNewClass !== undefined) {
334
+ assertValidReturnValue(10, nextNewClass);
335
+ newClass = nextNewClass;
336
+ }
337
+ }
338
+ return [
339
+ defineMetadata(newClass, metadata),
340
+ function() {
341
+ for(var i = 0; i < initializers.length; i++){
342
+ initializers[i].call(newClass);
343
+ }
344
+ }
345
+ ];
346
+ }
347
+ }
348
+ function defineMetadata(Class, metadata) {
349
+ return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
350
+ configurable: true,
351
+ enumerable: true,
352
+ value: metadata
353
+ });
354
+ }
355
+ return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
356
+ if (parentClass !== void 0) {
357
+ var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
358
+ }
359
+ var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
360
+ var e = applyMemberDecs(targetClass, memberDecs, metadata);
361
+ if (!classDecs.length) defineMetadata(targetClass, metadata);
362
+ return {
363
+ e: e,
364
+ get c () {
365
+ return applyClassDecs(targetClass, classDecs, metadata);
366
+ }
367
+ };
368
+ };
6
369
  }
7
- import { BatchedBlob, Blob } from '@aztec/blob-lib';
370
+ function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
371
+ return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
372
+ }
373
+ var _dec, _initProto;
8
374
  import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
9
375
  import { asyncPool } from '@aztec/foundation/async-pool';
376
+ import { BlockNumber } from '@aztec/foundation/branded-types';
10
377
  import { padArrayEnd } from '@aztec/foundation/collection';
11
- import { Fr } from '@aztec/foundation/fields';
378
+ import { Fr } from '@aztec/foundation/curves/bn254';
12
379
  import { createLogger } from '@aztec/foundation/log';
13
380
  import { RunningPromise, promiseWithResolvers } from '@aztec/foundation/promise';
14
381
  import { Timer } from '@aztec/foundation/timer';
382
+ import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
383
+ import { protocolContractsHash } from '@aztec/protocol-contracts';
384
+ import { buildFinalBlobChallenges } from '@aztec/prover-client/helpers';
385
+ import { PublicSimulatorConfig } from '@aztec/stdlib/avm';
15
386
  import { EpochProvingJobTerminalState } from '@aztec/stdlib/interfaces/server';
387
+ import { CheckpointConstantData } from '@aztec/stdlib/rollup';
16
388
  import { MerkleTreeId } from '@aztec/stdlib/trees';
17
389
  import { Attributes, trackSpan } from '@aztec/telemetry-client';
18
390
  import * as crypto from 'node:crypto';
19
391
  import { validateEpochProvingJobData } from './epoch-proving-job-data.js';
392
+ _dec = trackSpan('EpochProvingJob.run', function() {
393
+ return {
394
+ [Attributes.EPOCH_NUMBER]: this.data.epochNumber
395
+ };
396
+ });
20
397
  /**
21
398
  * Job that grabs a range of blocks from the unfinalized chain from L1, gets their txs given their hashes,
22
399
  * re-executes their public calls, generates a rollup proof, and submits it to L1. This job will update the
@@ -31,6 +408,15 @@ import { validateEpochProvingJobData } from './epoch-proving-job-data.js';
31
408
  metrics;
32
409
  deadline;
33
410
  config;
411
+ static{
412
+ ({ e: [_initProto] } = _apply_decs_2203_r(this, [
413
+ [
414
+ _dec,
415
+ 2,
416
+ "run"
417
+ ]
418
+ ], []));
419
+ }
34
420
  state;
35
421
  log;
36
422
  uuid;
@@ -48,7 +434,7 @@ import { validateEpochProvingJobData } from './epoch-proving-job-data.js';
48
434
  this.metrics = metrics;
49
435
  this.deadline = deadline;
50
436
  this.config = config;
51
- this.state = 'initialized';
437
+ this.state = (_initProto(this), 'initialized');
52
438
  this.log = createLogger('prover-node:epoch-proving-job');
53
439
  validateEpochProvingJobData(data);
54
440
  this.uuid = crypto.randomUUID();
@@ -72,8 +458,8 @@ import { validateEpochProvingJobData } from './epoch-proving-job-data.js';
72
458
  get epochNumber() {
73
459
  return this.data.epochNumber;
74
460
  }
75
- get blocks() {
76
- return this.data.blocks;
461
+ get checkpoints() {
462
+ return this.data.checkpoints;
77
463
  }
78
464
  get txs() {
79
465
  return this.data.txs;
@@ -89,17 +475,18 @@ import { validateEpochProvingJobData } from './epoch-proving-job-data.js';
89
475
  await this.scheduleEpochCheck();
90
476
  }
91
477
  const attestations = this.attestations.map((attestation)=>attestation.toViem());
92
- const epochNumber = Number(this.epochNumber);
93
- const epochSizeBlocks = this.blocks.length;
94
- const epochSizeTxs = this.blocks.reduce((total, current)=>total + current.body.txEffects.length, 0);
95
- const [fromBlock, toBlock] = [
96
- this.blocks[0].number,
97
- this.blocks.at(-1).number
98
- ];
99
- this.log.info(`Starting epoch ${epochNumber} proving job with blocks ${fromBlock} to ${toBlock}`, {
478
+ const epochNumber = this.epochNumber;
479
+ const epochSizeCheckpoints = this.checkpoints.length;
480
+ const epochSizeBlocks = this.checkpoints.reduce((accum, checkpoint)=>accum + checkpoint.blocks.length, 0);
481
+ const epochSizeTxs = this.checkpoints.reduce((accum, checkpoint)=>accum + checkpoint.blocks.reduce((accumC, block)=>accumC + block.body.txEffects.length, 0), 0);
482
+ const fromCheckpoint = this.checkpoints[0].number;
483
+ const toCheckpoint = this.checkpoints.at(-1).number;
484
+ const fromBlock = this.checkpoints[0].blocks[0].number;
485
+ const toBlock = this.checkpoints.at(-1).blocks.at(-1).number;
486
+ this.log.info(`Starting epoch ${epochNumber} proving job with checkpoints ${fromCheckpoint} to ${toCheckpoint}`, {
100
487
  fromBlock,
101
488
  toBlock,
102
- epochSizeBlocks,
489
+ epochSizeTxs,
103
490
  epochNumber,
104
491
  uuid: this.uuid
105
492
  });
@@ -108,42 +495,75 @@ import { validateEpochProvingJobData } from './epoch-proving-job-data.js';
108
495
  const { promise, resolve } = promiseWithResolvers();
109
496
  this.runPromise = promise;
110
497
  try {
111
- const allBlobs = (await Promise.all(this.blocks.map(async (block)=>await Blob.getBlobsPerBlock(block.body.toBlobFields())))).flat();
112
- const finalBlobBatchingChallenges = await BatchedBlob.precomputeBatchedBlobChallenges(allBlobs);
113
- this.prover.startNewEpoch(epochNumber, fromBlock, epochSizeBlocks, finalBlobBatchingChallenges);
114
- await this.prover.startTubeCircuits(Array.from(this.txs.values()));
115
- await asyncPool(this.config.parallelBlockLimit ?? 32, this.blocks, async (block)=>{
498
+ const blobFieldsPerCheckpoint = this.checkpoints.map((checkpoint)=>checkpoint.toBlobFields());
499
+ const finalBlobBatchingChallenges = await buildFinalBlobChallenges(blobFieldsPerCheckpoint);
500
+ this.prover.startNewEpoch(epochNumber, epochSizeCheckpoints, finalBlobBatchingChallenges);
501
+ await this.prover.startChonkVerifierCircuits(Array.from(this.txs.values()));
502
+ // Everything in the epoch should have the same chainId and version.
503
+ const { chainId, version } = this.checkpoints[0].blocks[0].header.globalVariables;
504
+ const previousBlockHeaders = this.gatherPreviousBlockHeaders();
505
+ await asyncPool(this.config.parallelBlockLimit ?? 32, this.checkpoints, async (checkpoint)=>{
116
506
  this.checkState();
117
- const globalVariables = block.header.globalVariables;
118
- const txs = this.getTxs(block);
119
- const l1ToL2Messages = this.getL1ToL2Messages(block);
120
- const previousHeader = this.getBlockHeader(block.number - 1);
121
- this.log.verbose(`Starting processing block ${block.number}`, {
122
- number: block.number,
123
- blockHash: (await block.hash()).toString(),
124
- lastArchive: block.header.lastArchive.root,
125
- noteHashTreeRoot: block.header.state.partial.noteHashTree.root,
126
- nullifierTreeRoot: block.header.state.partial.nullifierTree.root,
127
- publicDataTreeRoot: block.header.state.partial.publicDataTree.root,
128
- previousHeader: previousHeader.hash(),
129
- uuid: this.uuid,
130
- ...globalVariables
507
+ const checkpointIndex = checkpoint.number - fromCheckpoint;
508
+ const checkpointConstants = CheckpointConstantData.from({
509
+ chainId,
510
+ version,
511
+ vkTreeRoot: getVKTreeRoot(),
512
+ protocolContractsHash: protocolContractsHash,
513
+ proverId: this.prover.getProverId().toField(),
514
+ slotNumber: checkpoint.header.slotNumber,
515
+ coinbase: checkpoint.header.coinbase,
516
+ feeRecipient: checkpoint.header.feeRecipient,
517
+ gasFees: checkpoint.header.gasFees
131
518
  });
132
- // Start block proving
133
- await this.prover.startNewBlock(globalVariables, l1ToL2Messages, previousHeader);
134
- // Process public fns
135
- const db = await this.createFork(block.number - 1, l1ToL2Messages);
136
- const publicProcessor = this.publicProcessorFactory.create(db, globalVariables, true);
137
- const processed = await this.processTxs(publicProcessor, txs);
138
- await this.prover.addTxs(processed);
139
- await db.close();
140
- this.log.verbose(`Processed all ${txs.length} txs for block ${block.number}`, {
141
- blockNumber: block.number,
142
- blockHash: (await block.hash()).toString(),
519
+ const previousHeader = previousBlockHeaders[checkpointIndex];
520
+ const l1ToL2Messages = this.getL1ToL2Messages(checkpoint);
521
+ this.log.verbose(`Starting processing checkpoint ${checkpoint.number}`, {
522
+ number: checkpoint.number,
523
+ checkpointHash: checkpoint.hash().toString(),
524
+ lastArchive: checkpoint.header.lastArchiveRoot,
525
+ previousHeader: previousHeader.hash(),
143
526
  uuid: this.uuid
144
527
  });
145
- // Mark block as completed to pad it
146
- await this.prover.setBlockCompleted(block.number, block.header);
528
+ await this.prover.startNewCheckpoint(checkpointIndex, checkpointConstants, l1ToL2Messages, checkpoint.blocks.length, previousHeader);
529
+ for (const block of checkpoint.blocks){
530
+ const globalVariables = block.header.globalVariables;
531
+ const txs = this.getTxs(block);
532
+ this.log.verbose(`Starting processing block ${block.number}`, {
533
+ number: block.number,
534
+ blockHash: (await block.hash()).toString(),
535
+ lastArchive: block.header.lastArchive.root,
536
+ noteHashTreeRoot: block.header.state.partial.noteHashTree.root,
537
+ nullifierTreeRoot: block.header.state.partial.nullifierTree.root,
538
+ publicDataTreeRoot: block.header.state.partial.publicDataTree.root,
539
+ ...globalVariables,
540
+ numTxs: txs.length
541
+ });
542
+ // Start block proving
543
+ await this.prover.startNewBlock(block.number, globalVariables.timestamp, txs.length);
544
+ // Process public fns
545
+ const db = await this.createFork(BlockNumber(block.number - 1), l1ToL2Messages);
546
+ const config = PublicSimulatorConfig.from({
547
+ proverId: this.prover.getProverId().toField(),
548
+ skipFeeEnforcement: false,
549
+ collectDebugLogs: false,
550
+ collectHints: true,
551
+ collectPublicInputs: true,
552
+ collectStatistics: false
553
+ });
554
+ const publicProcessor = this.publicProcessorFactory.create(db, globalVariables, config);
555
+ const processed = await this.processTxs(publicProcessor, txs);
556
+ await this.prover.addTxs(processed);
557
+ await db.close();
558
+ this.log.verbose(`Processed all ${txs.length} txs for block ${block.number}`, {
559
+ blockNumber: block.number,
560
+ blockHash: (await block.hash()).toString(),
561
+ uuid: this.uuid
562
+ });
563
+ // Mark block as completed to pad it
564
+ const expectedBlockHeader = block.header;
565
+ await this.prover.setBlockCompleted(block.number, expectedBlockHeader);
566
+ }
147
567
  });
148
568
  const executionTime = timer.ms();
149
569
  this.progressState('awaiting-prover');
@@ -154,9 +574,15 @@ import { validateEpochProvingJobData } from './epoch-proving-job-data.js';
154
574
  duration: timer.ms()
155
575
  });
156
576
  this.progressState('publishing-proof');
577
+ if (this.config.skipSubmitProof) {
578
+ this.log.info(`Proof publishing is disabled. Dropping valid proof for epoch ${epochNumber} (checkpoints ${fromCheckpoint} to ${toCheckpoint})`);
579
+ this.state = 'completed';
580
+ this.metrics.recordProvingJob(executionTime, timer.ms(), epochSizeCheckpoints, epochSizeBlocks, epochSizeTxs);
581
+ return;
582
+ }
157
583
  const success = await this.publisher.submitEpochProof({
158
- fromBlock,
159
- toBlock,
584
+ fromCheckpoint,
585
+ toCheckpoint,
160
586
  epochNumber,
161
587
  publicInputs,
162
588
  proof,
@@ -166,12 +592,12 @@ import { validateEpochProvingJobData } from './epoch-proving-job-data.js';
166
592
  if (!success) {
167
593
  throw new Error('Failed to submit epoch proof to L1');
168
594
  }
169
- this.log.info(`Submitted proof for epoch ${epochNumber} (blocks ${fromBlock} to ${toBlock})`, {
595
+ this.log.info(`Submitted proof for epoch ${epochNumber} (checkpoints ${fromCheckpoint} to ${toCheckpoint})`, {
170
596
  epochNumber,
171
597
  uuid: this.uuid
172
598
  });
173
599
  this.state = 'completed';
174
- this.metrics.recordProvingJob(executionTime, timer.ms(), epochSizeBlocks, epochSizeTxs);
600
+ this.metrics.recordProvingJob(executionTime, timer.ms(), epochSizeCheckpoints, epochSizeBlocks, epochSizeTxs);
175
601
  } catch (err) {
176
602
  if (err && err.name === 'HaltExecutionError') {
177
603
  this.log.warn(`Halted execution of epoch ${epochNumber} prover job`, {
@@ -203,7 +629,7 @@ import { validateEpochProvingJobData } from './epoch-proving-job-data.js';
203
629
  const l1ToL2MessagesPadded = padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, 'Too many L1 to L2 messages');
204
630
  this.log.verbose(`Creating fork at ${blockNumber} with ${l1ToL2Messages.length} L1 to L2 messages`, {
205
631
  blockNumber,
206
- l1ToL2Messages: l1ToL2MessagesPadded.map((m)=>m.toString())
632
+ l1ToL2Messages: l1ToL2Messages.map((m)=>m.toString())
207
633
  });
208
634
  await db.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, l1ToL2MessagesPadded);
209
635
  return db;
@@ -220,7 +646,6 @@ import { validateEpochProvingJobData } from './epoch-proving-job-data.js';
220
646
  async stop(state = 'stopped') {
221
647
  this.state = state;
222
648
  this.prover.cancel();
223
- // TODO(palla/prover): Stop the publisher as well
224
649
  if (this.runPromise) {
225
650
  await this.runPromise;
226
651
  }
@@ -262,8 +687,9 @@ import { validateEpochProvingJobData } from './epoch-proving-job-data.js';
262
687
  this.epochCheckPromise = new RunningPromise(async ()=>{
263
688
  const blocks = await l2BlockSource.getBlockHeadersForEpoch(this.epochNumber);
264
689
  const blockHashes = await Promise.all(blocks.map((block)=>block.hash()));
265
- const thisBlockHashes = await Promise.all(this.blocks.map((block)=>block.hash()));
266
- if (blocks.length !== this.blocks.length || !blockHashes.every((block, i)=>block.equals(thisBlockHashes[i]))) {
690
+ const thisBlocks = this.checkpoints.flatMap((checkpoint)=>checkpoint.blocks);
691
+ const thisBlockHashes = await Promise.all(thisBlocks.map((block)=>block.hash()));
692
+ if (blocks.length !== thisBlocks.length || !blockHashes.every((block, i)=>block.equals(thisBlockHashes[i]))) {
267
693
  this.log.warn('Epoch blocks changed underfoot', {
268
694
  uuid: this.uuid,
269
695
  epochNumber: this.epochNumber,
@@ -275,21 +701,18 @@ import { validateEpochProvingJobData } from './epoch-proving-job-data.js';
275
701
  }, this.log, intervalMs).start();
276
702
  this.log.verbose(`Scheduled epoch check for epoch ${this.epochNumber} every ${intervalMs}ms`);
277
703
  }
278
- /* Returns the header for the given block number based on the epoch proving job data. */ getBlockHeader(blockNumber) {
279
- const block = this.blocks.find((b)=>b.number === blockNumber);
280
- if (block) {
281
- return block.header;
282
- }
283
- if (blockNumber === Number(this.data.previousBlockHeader.getBlockNumber())) {
284
- return this.data.previousBlockHeader;
285
- }
286
- throw new Error(`Block header not found for block number ${blockNumber} (got ${this.blocks.map((b)=>b.number).join(', ')} and previous header ${this.data.previousBlockHeader.getBlockNumber()})`);
704
+ /* Returns the last block header in the previous checkpoint for all checkpoints in the epoch */ gatherPreviousBlockHeaders() {
705
+ const lastBlocks = this.checkpoints.map((checkpoint)=>checkpoint.blocks.at(-1));
706
+ return [
707
+ this.data.previousBlockHeader,
708
+ ...lastBlocks.map((block)=>block.header).slice(0, -1)
709
+ ];
287
710
  }
288
711
  getTxs(block) {
289
712
  return block.body.txEffects.map((txEffect)=>this.txs.get(txEffect.txHash.toString()));
290
713
  }
291
- getL1ToL2Messages(block) {
292
- return this.data.l1ToL2Messages[block.number];
714
+ getL1ToL2Messages(checkpoint) {
715
+ return this.data.l1ToL2Messages[checkpoint.number];
293
716
  }
294
717
  async processTxs(publicProcessor, txs) {
295
718
  const { deadline } = this;
@@ -306,13 +729,6 @@ import { validateEpochProvingJobData } from './epoch-proving-job-data.js';
306
729
  return processedTxs;
307
730
  }
308
731
  }
309
- _ts_decorate([
310
- trackSpan('EpochProvingJob.run', function() {
311
- return {
312
- [Attributes.EPOCH_NUMBER]: Number(this.data.epochNumber)
313
- };
314
- })
315
- ], EpochProvingJob.prototype, "run", null);
316
732
  class HaltExecutionError extends Error {
317
733
  state;
318
734
  constructor(state){