@aztec/prover-node 0.0.1-commit.9b94fc1 → 0.0.1-commit.9ee6fcc6

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 (51) hide show
  1. package/dest/actions/download-epoch-proving-job.d.ts +1 -1
  2. package/dest/actions/rerun-epoch-proving-job.d.ts +4 -3
  3. package/dest/actions/rerun-epoch-proving-job.d.ts.map +1 -1
  4. package/dest/actions/rerun-epoch-proving-job.js +2 -2
  5. package/dest/actions/upload-epoch-proof-failure.d.ts +2 -2
  6. package/dest/actions/upload-epoch-proof-failure.d.ts.map +1 -1
  7. package/dest/bin/run-failed-epoch.js +5 -2
  8. package/dest/config.d.ts +8 -10
  9. package/dest/config.d.ts.map +1 -1
  10. package/dest/config.js +19 -21
  11. package/dest/factory.d.ts +20 -16
  12. package/dest/factory.d.ts.map +1 -1
  13. package/dest/factory.js +47 -62
  14. package/dest/index.d.ts +2 -1
  15. package/dest/index.d.ts.map +1 -1
  16. package/dest/index.js +1 -0
  17. package/dest/job/epoch-proving-job-data.d.ts +7 -6
  18. package/dest/job/epoch-proving-job-data.d.ts.map +1 -1
  19. package/dest/job/epoch-proving-job-data.js +24 -18
  20. package/dest/job/epoch-proving-job.d.ts +5 -4
  21. package/dest/job/epoch-proving-job.d.ts.map +1 -1
  22. package/dest/job/epoch-proving-job.js +511 -108
  23. package/dest/metrics.d.ts +14 -3
  24. package/dest/metrics.d.ts.map +1 -1
  25. package/dest/metrics.js +54 -97
  26. package/dest/monitors/epoch-monitor.d.ts +1 -1
  27. package/dest/monitors/epoch-monitor.d.ts.map +1 -1
  28. package/dest/monitors/epoch-monitor.js +8 -18
  29. package/dest/prover-node-publisher.d.ts +12 -10
  30. package/dest/prover-node-publisher.d.ts.map +1 -1
  31. package/dest/prover-node-publisher.js +46 -40
  32. package/dest/prover-node.d.ts +22 -12
  33. package/dest/prover-node.d.ts.map +1 -1
  34. package/dest/prover-node.js +442 -55
  35. package/dest/prover-publisher-factory.d.ts +10 -6
  36. package/dest/prover-publisher-factory.d.ts.map +1 -1
  37. package/dest/prover-publisher-factory.js +7 -5
  38. package/package.json +26 -25
  39. package/src/actions/rerun-epoch-proving-job.ts +5 -3
  40. package/src/actions/upload-epoch-proof-failure.ts +1 -1
  41. package/src/bin/run-failed-epoch.ts +5 -2
  42. package/src/config.ts +27 -33
  43. package/src/factory.ts +80 -104
  44. package/src/index.ts +1 -0
  45. package/src/job/epoch-proving-job-data.ts +28 -23
  46. package/src/job/epoch-proving-job.ts +151 -111
  47. package/src/metrics.ts +64 -81
  48. package/src/monitors/epoch-monitor.ts +6 -14
  49. package/src/prover-node-publisher.ts +67 -55
  50. package/src/prover-node.ts +54 -42
  51. package/src/prover-publisher-factory.ts +19 -11
@@ -1,9 +1,377 @@
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
  }
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, _dec1, _initProto;
374
+ import { BlockNumber } from '@aztec/foundation/branded-types';
7
375
  import { assertRequired, compact, pick, sum } from '@aztec/foundation/collection';
8
376
  import { memoize } from '@aztec/foundation/decorators';
9
377
  import { createLogger } from '@aztec/foundation/log';
@@ -15,6 +383,11 @@ import { Attributes, getTelemetryClient, trackSpan } from '@aztec/telemetry-clie
15
383
  import { uploadEpochProofFailure } from './actions/upload-epoch-proof-failure.js';
16
384
  import { EpochProvingJob } from './job/epoch-proving-job.js';
17
385
  import { ProverNodeJobMetrics, ProverNodeRewardsMetrics } from './metrics.js';
386
+ _dec = trackSpan('ProverNode.createProvingJob', (epochNumber)=>({
387
+ [Attributes.EPOCH_NUMBER]: epochNumber
388
+ })), _dec1 = trackSpan('ProverNode.gatherEpochData', (epochNumber)=>({
389
+ [Attributes.EPOCH_NUMBER]: epochNumber
390
+ }));
18
391
  /**
19
392
  * An Aztec Prover Node is a standalone process that monitors the unfinalized chain on L1 for unproven epochs,
20
393
  * fetches their txs from the p2p network or external nodes, re-executes their public functions, creates a rollup
@@ -31,15 +404,35 @@ import { ProverNodeJobMetrics, ProverNodeRewardsMetrics } from './metrics.js';
31
404
  rollupContract;
32
405
  l1Metrics;
33
406
  telemetryClient;
34
- log;
407
+ delayer;
35
408
  dateProvider;
409
+ static{
410
+ ({ e: [_initProto] } = _apply_decs_2203_r(this, [
411
+ [
412
+ _dec,
413
+ 2,
414
+ "createProvingJob"
415
+ ],
416
+ [
417
+ memoize,
418
+ 2,
419
+ "getL1Constants"
420
+ ],
421
+ [
422
+ _dec1,
423
+ 2,
424
+ "gatherEpochData"
425
+ ]
426
+ ], []));
427
+ }
428
+ log;
36
429
  jobs;
37
430
  config;
38
431
  jobMetrics;
39
432
  rewardsMetrics;
40
433
  tracer;
41
434
  publisher;
42
- constructor(prover, publisherFactory, l2BlockSource, l1ToL2MessageSource, contractDataSource, worldState, p2pClient, epochsMonitor, rollupContract, l1Metrics, config = {}, telemetryClient = getTelemetryClient()){
435
+ constructor(prover, publisherFactory, l2BlockSource, l1ToL2MessageSource, contractDataSource, worldState, p2pClient, epochsMonitor, rollupContract, l1Metrics, config = {}, telemetryClient = getTelemetryClient(), delayer, dateProvider = new DateProvider()){
43
436
  this.prover = prover;
44
437
  this.publisherFactory = publisherFactory;
45
438
  this.l2BlockSource = l2BlockSource;
@@ -51,13 +444,14 @@ import { ProverNodeJobMetrics, ProverNodeRewardsMetrics } from './metrics.js';
51
444
  this.rollupContract = rollupContract;
52
445
  this.l1Metrics = l1Metrics;
53
446
  this.telemetryClient = telemetryClient;
54
- this.log = createLogger('prover-node');
55
- this.dateProvider = new DateProvider();
447
+ this.delayer = delayer;
448
+ this.dateProvider = dateProvider;
449
+ this.log = (_initProto(this), createLogger('prover-node'));
56
450
  this.jobs = new Map();
57
451
  this.config = {
58
452
  proverNodePollingIntervalMs: 1_000,
59
453
  proverNodeMaxPendingJobs: 100,
60
- proverNodeMaxParallelBlocksPerEpoch: 32,
454
+ proverNodeMaxParallelBlocksPerEpoch: 0,
61
455
  txGatheringIntervalMs: 1_000,
62
456
  txGatheringBatchSize: 10,
63
457
  txGatheringMaxParallelRequestsPerNode: 100,
@@ -78,6 +472,9 @@ import { ProverNodeJobMetrics, ProverNodeRewardsMetrics } from './metrics.js';
78
472
  getP2P() {
79
473
  return this.p2pClient;
80
474
  }
475
+ /** Returns the shared tx delayer for prover L1 txs, if enabled. Test-only. */ getDelayer() {
476
+ return this.delayer;
477
+ }
81
478
  /**
82
479
  * Handles an epoch being completed by starting a proof for it if there are no active jobs for it.
83
480
  * @param epochNumber - The epoch number that was just completed.
@@ -118,16 +515,14 @@ import { ProverNodeJobMetrics, ProverNodeRewardsMetrics } from './metrics.js';
118
515
  }
119
516
  /**
120
517
  * Stops the prover node and all its dependencies.
518
+ * Resources not owned by this node (shared with the parent aztec-node) are skipped.
121
519
  */ async stop() {
122
520
  this.log.info('Stopping ProverNode');
123
521
  await this.epochsMonitor.stop();
124
522
  await this.prover.stop();
125
- await tryStop(this.p2pClient);
126
- await tryStop(this.l2BlockSource);
127
523
  await tryStop(this.publisherFactory);
128
524
  this.publisher?.interrupt();
129
525
  await Promise.all(Array.from(this.jobs.values()).map((job)=>job.stop()));
130
- await this.worldState.stop();
131
526
  this.rewardsMetrics.stop();
132
527
  this.l1Metrics.stop();
133
528
  await this.telemetryClient.stop();
@@ -208,13 +603,17 @@ import { ProverNodeJobMetrics, ProverNodeRewardsMetrics } from './metrics.js';
208
603
  this.publisher = await this.publisherFactory.create();
209
604
  // Gather all data for this epoch
210
605
  const epochData = await this.gatherEpochData(epochNumber);
211
- const fromBlock = epochData.blocks[0].number;
212
- const toBlock = epochData.blocks.at(-1).number;
213
- this.log.verbose(`Creating proving job for epoch ${epochNumber} for block range ${fromBlock} to ${toBlock}`);
606
+ const fromCheckpoint = epochData.checkpoints[0].number;
607
+ const toCheckpoint = epochData.checkpoints.at(-1).number;
608
+ const fromBlock = epochData.checkpoints[0].blocks[0].number;
609
+ const lastBlock = epochData.checkpoints.at(-1).blocks.at(-1);
610
+ const toBlock = lastBlock.number;
611
+ this.log.verbose(`Creating proving job for epoch ${epochNumber} for checkpoint range ${fromCheckpoint} to ${toCheckpoint} and block range ${fromBlock} to ${toBlock}`);
214
612
  // Fast forward world state to right before the target block and get a fork
215
- await this.worldState.syncImmediate(toBlock);
613
+ const lastBlockHash = await lastBlock.header.hash();
614
+ await this.worldState.syncImmediate(toBlock, lastBlockHash);
216
615
  // Create a processor factory
217
- const publicProcessorFactory = new PublicProcessorFactory(this.contractDataSource, this.dateProvider, this.telemetryClient);
616
+ const publicProcessorFactory = new PublicProcessorFactory(this.contractDataSource, this.dateProvider, this.telemetryClient, this.log.getBindings());
218
617
  // Set deadline for this job to run. It will abort if it takes too long.
219
618
  const deadlineTs = getProofSubmissionDeadlineTimestamp(epochNumber, await this.getL1Constants());
220
619
  const deadline = new Date(Number(deadlineTs) * 1000);
@@ -226,18 +625,19 @@ import { ProverNodeJobMetrics, ProverNodeRewardsMetrics } from './metrics.js';
226
625
  return this.l2BlockSource.getL1Constants();
227
626
  }
228
627
  async gatherEpochData(epochNumber) {
229
- const blocks = await this.gatherBlocks(epochNumber);
230
- const txArray = await this.gatherTxs(epochNumber, blocks);
628
+ const checkpoints = await this.gatherCheckpoints(epochNumber);
629
+ const txArray = await this.gatherTxs(epochNumber, checkpoints);
231
630
  const txs = new Map(txArray.map((tx)=>[
232
631
  tx.getTxHash().toString(),
233
632
  tx
234
633
  ]));
235
- const l1ToL2Messages = await this.gatherMessages(epochNumber, blocks);
236
- const previousBlockHeader = await this.gatherPreviousBlockHeader(epochNumber, blocks[0]);
237
- const [lastBlock] = await this.l2BlockSource.getPublishedBlocks(blocks.at(-1).number, 1);
238
- const attestations = lastBlock?.attestations ?? [];
634
+ const l1ToL2Messages = await this.gatherMessages(epochNumber, checkpoints);
635
+ const [firstBlock] = checkpoints[0].blocks;
636
+ const previousBlockHeader = await this.gatherPreviousBlockHeader(epochNumber, firstBlock.number - 1);
637
+ const [lastPublishedCheckpoint] = await this.l2BlockSource.getCheckpoints(checkpoints.at(-1).number, 1);
638
+ const attestations = lastPublishedCheckpoint?.attestations ?? [];
239
639
  return {
240
- blocks,
640
+ checkpoints,
241
641
  txs,
242
642
  l1ToL2Messages,
243
643
  epochNumber,
@@ -245,16 +645,17 @@ import { ProverNodeJobMetrics, ProverNodeRewardsMetrics } from './metrics.js';
245
645
  attestations
246
646
  };
247
647
  }
248
- async gatherBlocks(epochNumber) {
249
- const blocks = await this.l2BlockSource.getBlocksForEpoch(epochNumber);
250
- if (blocks.length === 0) {
648
+ async gatherCheckpoints(epochNumber) {
649
+ const checkpoints = await this.l2BlockSource.getCheckpointsForEpoch(epochNumber);
650
+ if (checkpoints.length === 0) {
251
651
  throw new EmptyEpochError(epochNumber);
252
652
  }
253
- return blocks;
653
+ return checkpoints;
254
654
  }
255
- async gatherTxs(epochNumber, blocks) {
655
+ async gatherTxs(epochNumber, checkpoints) {
256
656
  const deadline = new Date(this.dateProvider.now() + this.config.txGatheringTimeoutMs);
257
657
  const txProvider = this.p2pClient.getTxProvider();
658
+ const blocks = checkpoints.flatMap((checkpoint)=>checkpoint.blocks);
258
659
  const txsByBlock = await Promise.all(blocks.map((block)=>txProvider.getTxsForBlock(block, {
259
660
  deadline
260
661
  })));
@@ -268,23 +669,22 @@ import { ProverNodeJobMetrics, ProverNodeRewardsMetrics } from './metrics.js';
268
669
  }
269
670
  throw new Error(`Txs not found for epoch ${epochNumber}: ${missingTxs.map((hash)=>hash.toString()).join(', ')}`);
270
671
  }
271
- async gatherMessages(epochNumber, blocks) {
272
- const messages = await Promise.all(blocks.map((b)=>this.l1ToL2MessageSource.getL1ToL2Messages(b.number)));
672
+ async gatherMessages(epochNumber, checkpoints) {
673
+ const messages = await Promise.all(checkpoints.map((c)=>this.l1ToL2MessageSource.getL1ToL2Messages(c.number)));
273
674
  const messageCount = sum(messages.map((m)=>m.length));
274
675
  this.log.verbose(`Gathered all ${messageCount} messages for epoch ${epochNumber}`, {
275
676
  epochNumber
276
677
  });
277
- const messagesByBlock = {};
278
- for(let i = 0; i < blocks.length; i++){
279
- messagesByBlock[blocks[i].number] = messages[i];
678
+ const messagesByCheckpoint = {};
679
+ for(let i = 0; i < checkpoints.length; i++){
680
+ messagesByCheckpoint[checkpoints[i].number] = messages[i];
280
681
  }
281
- return messagesByBlock;
682
+ return messagesByCheckpoint;
282
683
  }
283
- async gatherPreviousBlockHeader(epochNumber, initialBlock) {
284
- const previousBlockNumber = initialBlock.number - 1;
285
- const header = await (previousBlockNumber === 0 ? this.worldState.getCommitted().getInitialHeader() : this.l2BlockSource.getBlockHeader(previousBlockNumber));
684
+ async gatherPreviousBlockHeader(epochNumber, previousBlockNumber) {
685
+ const header = await (previousBlockNumber === 0 ? this.worldState.getCommitted().getInitialHeader() : this.l2BlockSource.getBlockHeader(BlockNumber(previousBlockNumber)));
286
686
  if (!header) {
287
- throw new Error(`Previous block header ${initialBlock.number} not found for proving epoch ${epochNumber}`);
687
+ throw new Error(`Previous block header ${previousBlockNumber} not found for proving epoch ${epochNumber}`);
288
688
  }
289
689
  this.log.verbose(`Gathered previous block header ${header.getBlockNumber()} for epoch ${epochNumber}`);
290
690
  return header;
@@ -295,31 +695,18 @@ import { ProverNodeJobMetrics, ProverNodeRewardsMetrics } from './metrics.js';
295
695
  parallelBlockLimit,
296
696
  skipSubmitProof: proverNodeDisableProofPublish,
297
697
  ...opts
298
- });
698
+ }, this.log.getBindings());
299
699
  }
300
700
  /** Extracted for testing purposes. */ async triggerMonitors() {
301
701
  await this.epochsMonitor.work();
302
702
  }
303
703
  validateConfig() {
304
- if (this.config.proverNodeFailedEpochStore && (!this.config.dataDirectory || !this.config.l1ChainId || !this.config.rollupVersion)) {
704
+ if (this.config.proverNodeFailedEpochStore && (!this.config.dataDirectory || !this.config.l1ChainId || this.config.rollupVersion === undefined)) {
305
705
  this.log.warn(`Invalid prover-node config (missing dataDirectory, l1ChainId, or rollupVersion)`, pick(this.config, 'proverNodeFailedEpochStore', 'dataDirectory', 'l1ChainId', 'rollupVersion'));
306
706
  throw new Error('All of dataDirectory, l1ChainId, and rollupVersion are required if proverNodeFailedEpochStore is set.');
307
707
  }
308
708
  }
309
709
  }
310
- _ts_decorate([
311
- trackSpan('ProverNode.createProvingJob', (epochNumber)=>({
312
- [Attributes.EPOCH_NUMBER]: epochNumber
313
- }))
314
- ], ProverNode.prototype, "createProvingJob", null);
315
- _ts_decorate([
316
- memoize
317
- ], ProverNode.prototype, "getL1Constants", null);
318
- _ts_decorate([
319
- trackSpan('ProverNode.gatherEpochData', (epochNumber)=>({
320
- [Attributes.EPOCH_NUMBER]: epochNumber
321
- }))
322
- ], ProverNode.prototype, "gatherEpochData", null);
323
710
  class EmptyEpochError extends Error {
324
711
  constructor(epochNumber){
325
712
  super(`No blocks found for epoch ${epochNumber}`);
@@ -1,21 +1,25 @@
1
- import type { L1TxUtils, PublisherManager, RollupContract } from '@aztec/ethereum';
2
- import type { PublisherConfig, TxSenderConfig } from '@aztec/sequencer-client';
1
+ import type { RollupContract } from '@aztec/ethereum/contracts';
2
+ import type { L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
3
+ import type { PublisherManager } from '@aztec/ethereum/publisher-manager';
4
+ import type { LoggerBindings } from '@aztec/foundation/log';
5
+ import type { ProverPublisherConfig, ProverTxSenderConfig } from '@aztec/sequencer-client';
3
6
  import type { TelemetryClient } from '@aztec/telemetry-client';
4
7
  import { ProverNodePublisher } from './prover-node-publisher.js';
5
8
  export declare class ProverPublisherFactory {
6
9
  private config;
7
10
  private deps;
8
- constructor(config: TxSenderConfig & PublisherConfig, deps: {
11
+ private bindings?;
12
+ constructor(config: ProverTxSenderConfig & ProverPublisherConfig, deps: {
9
13
  rollupContract: RollupContract;
10
14
  publisherManager: PublisherManager<L1TxUtils>;
11
15
  telemetry?: TelemetryClient;
12
- });
16
+ }, bindings?: LoggerBindings | undefined);
13
17
  start(): Promise<void>;
14
- stop(): void;
18
+ stop(): Promise<void>;
15
19
  /**
16
20
  * Creates a new Prover Publisher instance.
17
21
  * @returns A new ProverNodePublisher instance.
18
22
  */
19
23
  create(): Promise<ProverNodePublisher>;
20
24
  }
21
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvdmVyLXB1Ymxpc2hlci1mYWN0b3J5LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvcHJvdmVyLXB1Ymxpc2hlci1mYWN0b3J5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxnQkFBZ0IsRUFBRSxjQUFjLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUNuRixPQUFPLEtBQUssRUFBRSxlQUFlLEVBQUUsY0FBYyxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFDL0UsT0FBTyxLQUFLLEVBQUUsZUFBZSxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFFL0QsT0FBTyxFQUFFLG1CQUFtQixFQUFFLE1BQU0sNEJBQTRCLENBQUM7QUFFakUscUJBQWEsc0JBQXNCO0lBRS9CLE9BQU8sQ0FBQyxNQUFNO0lBQ2QsT0FBTyxDQUFDLElBQUk7SUFGZCxZQUNVLE1BQU0sRUFBRSxjQUFjLEdBQUcsZUFBZSxFQUN4QyxJQUFJLEVBQUU7UUFDWixjQUFjLEV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M7SUFQbkIsWUFDVSxNQUFNLEVBQUUsb0JBQW9CLEdBQUcscUJBQXFCLEVBQ3BELElBQUksRUFBRTtRQUNaLGNBQWMsRUFBRSxjQUFjLENBQUM7UUFDL0IsZ0JBQWdCLEVBQUUsZ0JBQWdCLENBQUMsU0FBUyxDQUFDLENBQUM7UUFDOUMsU0FBUyxDQUFDLEVBQUUsZUFBZSxDQUFDO0tBQzdCLEVBQ08sUUFBUSxDQUFDLDRCQUFnQixFQUMvQjtJQUVTLEtBQUssa0JBRWpCO0lBRVksSUFBSSxrQkFFaEI7SUFFRDs7O09BR0c7SUFDVSxNQUFNLElBQUksT0FBTyxDQUFDLG1CQUFtQixDQUFDLENBV2xEO0NBQ0YifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"prover-publisher-factory.d.ts","sourceRoot":"","sources":["../src/prover-publisher-factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACnF,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,qBAAa,sBAAsB;IAE/B,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,IAAI;IAFd,YACU,MAAM,EAAE,cAAc,GAAG,eAAe,EACxC,IAAI,EAAE;QACZ,cAAc,EAAE,cAAc,CAAC;QAC/B,gBAAgB,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC;QAC9C,SAAS,CAAC,EAAE,eAAe,CAAC;KAC7B,EACC;IAES,KAAK,kBAEjB;IAEM,IAAI,SAEV;IAED;;;OAGG;IACU,MAAM,IAAI,OAAO,CAAC,mBAAmB,CAAC,CAOlD;CACF"}
1
+ {"version":3,"file":"prover-publisher-factory.d.ts","sourceRoot":"","sources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