@aztec/sequencer-client 0.0.1-commit.6c91f13 → 0.0.1-commit.96bb3f7

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 (67) hide show
  1. package/dest/client/sequencer-client.d.ts +4 -5
  2. package/dest/client/sequencer-client.d.ts.map +1 -1
  3. package/dest/config.d.ts +1 -1
  4. package/dest/config.d.ts.map +1 -1
  5. package/dest/config.js +8 -1
  6. package/dest/global_variable_builder/global_builder.d.ts +4 -4
  7. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  8. package/dest/global_variable_builder/global_builder.js +12 -12
  9. package/dest/index.d.ts +2 -3
  10. package/dest/index.d.ts.map +1 -1
  11. package/dest/index.js +1 -2
  12. package/dest/publisher/sequencer-publisher-metrics.d.ts +1 -1
  13. package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
  14. package/dest/publisher/sequencer-publisher-metrics.js +15 -86
  15. package/dest/publisher/sequencer-publisher.d.ts +17 -16
  16. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  17. package/dest/publisher/sequencer-publisher.js +442 -49
  18. package/dest/sequencer/block_builder.d.ts +1 -1
  19. package/dest/sequencer/block_builder.d.ts.map +1 -1
  20. package/dest/sequencer/block_builder.js +1 -1
  21. package/dest/sequencer/checkpoint_proposal_job.d.ts +11 -8
  22. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
  23. package/dest/sequencer/checkpoint_proposal_job.js +475 -28
  24. package/dest/sequencer/index.d.ts +1 -2
  25. package/dest/sequencer/index.d.ts.map +1 -1
  26. package/dest/sequencer/index.js +0 -1
  27. package/dest/sequencer/metrics.d.ts +3 -3
  28. package/dest/sequencer/metrics.d.ts.map +1 -1
  29. package/dest/sequencer/metrics.js +30 -121
  30. package/dest/sequencer/sequencer.d.ts +13 -11
  31. package/dest/sequencer/sequencer.d.ts.map +1 -1
  32. package/dest/sequencer/sequencer.js +425 -37
  33. package/dest/test/index.d.ts +2 -3
  34. package/dest/test/index.d.ts.map +1 -1
  35. package/dest/test/mock_checkpoint_builder.d.ts +10 -2
  36. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
  37. package/dest/test/mock_checkpoint_builder.js +23 -0
  38. package/dest/test/utils.d.ts +8 -4
  39. package/dest/test/utils.d.ts.map +1 -1
  40. package/dest/test/utils.js +21 -12
  41. package/package.json +27 -27
  42. package/src/client/sequencer-client.ts +3 -4
  43. package/src/config.ts +7 -0
  44. package/src/global_variable_builder/global_builder.ts +12 -12
  45. package/src/index.ts +0 -3
  46. package/src/publisher/sequencer-publisher-metrics.ts +14 -70
  47. package/src/publisher/sequencer-publisher.ts +84 -73
  48. package/src/sequencer/block_builder.ts +1 -2
  49. package/src/sequencer/checkpoint_proposal_job.ts +75 -39
  50. package/src/sequencer/index.ts +0 -1
  51. package/src/sequencer/metrics.ts +23 -131
  52. package/src/sequencer/sequencer.ts +46 -35
  53. package/src/test/index.ts +1 -2
  54. package/src/test/mock_checkpoint_builder.ts +34 -2
  55. package/src/test/utils.ts +39 -19
  56. package/dest/sequencer/checkpoint_builder.d.ts +0 -63
  57. package/dest/sequencer/checkpoint_builder.d.ts.map +0 -1
  58. package/dest/sequencer/checkpoint_builder.js +0 -131
  59. package/dest/tx_validator/nullifier_cache.d.ts +0 -14
  60. package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
  61. package/dest/tx_validator/nullifier_cache.js +0 -24
  62. package/dest/tx_validator/tx_validator_factory.d.ts +0 -18
  63. package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
  64. package/dest/tx_validator/tx_validator_factory.js +0 -53
  65. package/src/sequencer/checkpoint_builder.ts +0 -217
  66. package/src/tx_validator/nullifier_cache.ts +0 -30
  67. package/src/tx_validator/tx_validator_factory.ts +0 -133
@@ -63,6 +63,379 @@ function _ts_dispose_resources(env) {
63
63
  return next();
64
64
  })(env);
65
65
  }
66
+ function applyDecs2203RFactory() {
67
+ function createAddInitializerMethod(initializers, decoratorFinishedRef) {
68
+ return function addInitializer(initializer) {
69
+ assertNotFinished(decoratorFinishedRef, "addInitializer");
70
+ assertCallable(initializer, "An initializer");
71
+ initializers.push(initializer);
72
+ };
73
+ }
74
+ function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
75
+ var kindStr;
76
+ switch(kind){
77
+ case 1:
78
+ kindStr = "accessor";
79
+ break;
80
+ case 2:
81
+ kindStr = "method";
82
+ break;
83
+ case 3:
84
+ kindStr = "getter";
85
+ break;
86
+ case 4:
87
+ kindStr = "setter";
88
+ break;
89
+ default:
90
+ kindStr = "field";
91
+ }
92
+ var ctx = {
93
+ kind: kindStr,
94
+ name: isPrivate ? "#" + name : name,
95
+ static: isStatic,
96
+ private: isPrivate,
97
+ metadata: metadata
98
+ };
99
+ var decoratorFinishedRef = {
100
+ v: false
101
+ };
102
+ ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
103
+ var get, set;
104
+ if (kind === 0) {
105
+ if (isPrivate) {
106
+ get = desc.get;
107
+ set = desc.set;
108
+ } else {
109
+ get = function() {
110
+ return this[name];
111
+ };
112
+ set = function(v) {
113
+ this[name] = v;
114
+ };
115
+ }
116
+ } else if (kind === 2) {
117
+ get = function() {
118
+ return desc.value;
119
+ };
120
+ } else {
121
+ if (kind === 1 || kind === 3) {
122
+ get = function() {
123
+ return desc.get.call(this);
124
+ };
125
+ }
126
+ if (kind === 1 || kind === 4) {
127
+ set = function(v) {
128
+ desc.set.call(this, v);
129
+ };
130
+ }
131
+ }
132
+ ctx.access = get && set ? {
133
+ get: get,
134
+ set: set
135
+ } : get ? {
136
+ get: get
137
+ } : {
138
+ set: set
139
+ };
140
+ try {
141
+ return dec(value, ctx);
142
+ } finally{
143
+ decoratorFinishedRef.v = true;
144
+ }
145
+ }
146
+ function assertNotFinished(decoratorFinishedRef, fnName) {
147
+ if (decoratorFinishedRef.v) {
148
+ throw new Error("attempted to call " + fnName + " after decoration was finished");
149
+ }
150
+ }
151
+ function assertCallable(fn, hint) {
152
+ if (typeof fn !== "function") {
153
+ throw new TypeError(hint + " must be a function");
154
+ }
155
+ }
156
+ function assertValidReturnValue(kind, value) {
157
+ var type = typeof value;
158
+ if (kind === 1) {
159
+ if (type !== "object" || value === null) {
160
+ throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
161
+ }
162
+ if (value.get !== undefined) {
163
+ assertCallable(value.get, "accessor.get");
164
+ }
165
+ if (value.set !== undefined) {
166
+ assertCallable(value.set, "accessor.set");
167
+ }
168
+ if (value.init !== undefined) {
169
+ assertCallable(value.init, "accessor.init");
170
+ }
171
+ } else if (type !== "function") {
172
+ var hint;
173
+ if (kind === 0) {
174
+ hint = "field";
175
+ } else if (kind === 10) {
176
+ hint = "class";
177
+ } else {
178
+ hint = "method";
179
+ }
180
+ throw new TypeError(hint + " decorators must return a function or void 0");
181
+ }
182
+ }
183
+ function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
184
+ var decs = decInfo[0];
185
+ var desc, init, value;
186
+ if (isPrivate) {
187
+ if (kind === 0 || kind === 1) {
188
+ desc = {
189
+ get: decInfo[3],
190
+ set: decInfo[4]
191
+ };
192
+ } else if (kind === 3) {
193
+ desc = {
194
+ get: decInfo[3]
195
+ };
196
+ } else if (kind === 4) {
197
+ desc = {
198
+ set: decInfo[3]
199
+ };
200
+ } else {
201
+ desc = {
202
+ value: decInfo[3]
203
+ };
204
+ }
205
+ } else if (kind !== 0) {
206
+ desc = Object.getOwnPropertyDescriptor(base, name);
207
+ }
208
+ if (kind === 1) {
209
+ value = {
210
+ get: desc.get,
211
+ set: desc.set
212
+ };
213
+ } else if (kind === 2) {
214
+ value = desc.value;
215
+ } else if (kind === 3) {
216
+ value = desc.get;
217
+ } else if (kind === 4) {
218
+ value = desc.set;
219
+ }
220
+ var newValue, get, set;
221
+ if (typeof decs === "function") {
222
+ newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
223
+ if (newValue !== void 0) {
224
+ assertValidReturnValue(kind, newValue);
225
+ if (kind === 0) {
226
+ init = newValue;
227
+ } else if (kind === 1) {
228
+ init = newValue.init;
229
+ get = newValue.get || value.get;
230
+ set = newValue.set || value.set;
231
+ value = {
232
+ get: get,
233
+ set: set
234
+ };
235
+ } else {
236
+ value = newValue;
237
+ }
238
+ }
239
+ } else {
240
+ for(var i = decs.length - 1; i >= 0; i--){
241
+ var dec = decs[i];
242
+ newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
243
+ if (newValue !== void 0) {
244
+ assertValidReturnValue(kind, newValue);
245
+ var newInit;
246
+ if (kind === 0) {
247
+ newInit = newValue;
248
+ } else if (kind === 1) {
249
+ newInit = newValue.init;
250
+ get = newValue.get || value.get;
251
+ set = newValue.set || value.set;
252
+ value = {
253
+ get: get,
254
+ set: set
255
+ };
256
+ } else {
257
+ value = newValue;
258
+ }
259
+ if (newInit !== void 0) {
260
+ if (init === void 0) {
261
+ init = newInit;
262
+ } else if (typeof init === "function") {
263
+ init = [
264
+ init,
265
+ newInit
266
+ ];
267
+ } else {
268
+ init.push(newInit);
269
+ }
270
+ }
271
+ }
272
+ }
273
+ }
274
+ if (kind === 0 || kind === 1) {
275
+ if (init === void 0) {
276
+ init = function(instance, init) {
277
+ return init;
278
+ };
279
+ } else if (typeof init !== "function") {
280
+ var ownInitializers = init;
281
+ init = function(instance, init) {
282
+ var value = init;
283
+ for(var i = 0; i < ownInitializers.length; i++){
284
+ value = ownInitializers[i].call(instance, value);
285
+ }
286
+ return value;
287
+ };
288
+ } else {
289
+ var originalInitializer = init;
290
+ init = function(instance, init) {
291
+ return originalInitializer.call(instance, init);
292
+ };
293
+ }
294
+ ret.push(init);
295
+ }
296
+ if (kind !== 0) {
297
+ if (kind === 1) {
298
+ desc.get = value.get;
299
+ desc.set = value.set;
300
+ } else if (kind === 2) {
301
+ desc.value = value;
302
+ } else if (kind === 3) {
303
+ desc.get = value;
304
+ } else if (kind === 4) {
305
+ desc.set = value;
306
+ }
307
+ if (isPrivate) {
308
+ if (kind === 1) {
309
+ ret.push(function(instance, args) {
310
+ return value.get.call(instance, args);
311
+ });
312
+ ret.push(function(instance, args) {
313
+ return value.set.call(instance, args);
314
+ });
315
+ } else if (kind === 2) {
316
+ ret.push(value);
317
+ } else {
318
+ ret.push(function(instance, args) {
319
+ return value.call(instance, args);
320
+ });
321
+ }
322
+ } else {
323
+ Object.defineProperty(base, name, desc);
324
+ }
325
+ }
326
+ }
327
+ function applyMemberDecs(Class, decInfos, metadata) {
328
+ var ret = [];
329
+ var protoInitializers;
330
+ var staticInitializers;
331
+ var existingProtoNonFields = new Map();
332
+ var existingStaticNonFields = new Map();
333
+ for(var i = 0; i < decInfos.length; i++){
334
+ var decInfo = decInfos[i];
335
+ if (!Array.isArray(decInfo)) continue;
336
+ var kind = decInfo[1];
337
+ var name = decInfo[2];
338
+ var isPrivate = decInfo.length > 3;
339
+ var isStatic = kind >= 5;
340
+ var base;
341
+ var initializers;
342
+ if (isStatic) {
343
+ base = Class;
344
+ kind = kind - 5;
345
+ staticInitializers = staticInitializers || [];
346
+ initializers = staticInitializers;
347
+ } else {
348
+ base = Class.prototype;
349
+ protoInitializers = protoInitializers || [];
350
+ initializers = protoInitializers;
351
+ }
352
+ if (kind !== 0 && !isPrivate) {
353
+ var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
354
+ var existingKind = existingNonFields.get(name) || 0;
355
+ if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) {
356
+ 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);
357
+ } else if (!existingKind && kind > 2) {
358
+ existingNonFields.set(name, kind);
359
+ } else {
360
+ existingNonFields.set(name, true);
361
+ }
362
+ }
363
+ applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
364
+ }
365
+ pushInitializers(ret, protoInitializers);
366
+ pushInitializers(ret, staticInitializers);
367
+ return ret;
368
+ }
369
+ function pushInitializers(ret, initializers) {
370
+ if (initializers) {
371
+ ret.push(function(instance) {
372
+ for(var i = 0; i < initializers.length; i++){
373
+ initializers[i].call(instance);
374
+ }
375
+ return instance;
376
+ });
377
+ }
378
+ }
379
+ function applyClassDecs(targetClass, classDecs, metadata) {
380
+ if (classDecs.length > 0) {
381
+ var initializers = [];
382
+ var newClass = targetClass;
383
+ var name = targetClass.name;
384
+ for(var i = classDecs.length - 1; i >= 0; i--){
385
+ var decoratorFinishedRef = {
386
+ v: false
387
+ };
388
+ try {
389
+ var nextNewClass = classDecs[i](newClass, {
390
+ kind: "class",
391
+ name: name,
392
+ addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
393
+ metadata
394
+ });
395
+ } finally{
396
+ decoratorFinishedRef.v = true;
397
+ }
398
+ if (nextNewClass !== undefined) {
399
+ assertValidReturnValue(10, nextNewClass);
400
+ newClass = nextNewClass;
401
+ }
402
+ }
403
+ return [
404
+ defineMetadata(newClass, metadata),
405
+ function() {
406
+ for(var i = 0; i < initializers.length; i++){
407
+ initializers[i].call(newClass);
408
+ }
409
+ }
410
+ ];
411
+ }
412
+ }
413
+ function defineMetadata(Class, metadata) {
414
+ return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
415
+ configurable: true,
416
+ enumerable: true,
417
+ value: metadata
418
+ });
419
+ }
420
+ return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
421
+ if (parentClass !== void 0) {
422
+ var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
423
+ }
424
+ var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
425
+ var e = applyMemberDecs(targetClass, memberDecs, metadata);
426
+ if (!classDecs.length) defineMetadata(targetClass, metadata);
427
+ return {
428
+ e: e,
429
+ get c () {
430
+ return applyClassDecs(targetClass, classDecs, metadata);
431
+ }
432
+ };
433
+ };
434
+ }
435
+ function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
436
+ return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
437
+ }
438
+ var _dec, _dec1, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _initProto;
66
439
  import { BLOBS_PER_CHECKPOINT, FIELDS_PER_BLOB } from '@aztec/constants';
67
440
  import { BlockNumber } from '@aztec/foundation/branded-types';
68
441
  import { randomInt } from '@aztec/foundation/crypto/random';
@@ -74,12 +447,21 @@ import { unfreeze } from '@aztec/foundation/types';
74
447
  import { CommitteeAttestationsAndSigners, MaliciousCommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
75
448
  import { getSlotStartBuildTimestamp } from '@aztec/stdlib/epoch-helpers';
76
449
  import { Gas } from '@aztec/stdlib/gas';
450
+ import { computeInHashFromL1ToL2Messages } from '@aztec/stdlib/messaging';
77
451
  import { orderAttestations } from '@aztec/stdlib/p2p';
78
452
  import { AttestationTimeoutError } from '@aztec/stdlib/validators';
453
+ import { Attributes, trackSpan } from '@aztec/telemetry-client';
79
454
  import { CheckpointVoter } from './checkpoint_voter.js';
80
455
  import { SequencerInterruptedError } from './errors.js';
81
456
  import { SequencerState } from './utils.js';
82
457
  /** How much time to sleep while waiting for min transactions to accumulate for a block */ const TXS_POLLING_MS = 500;
458
+ _dec = trackSpan('CheckpointProposalJob.execute'), _dec1 = trackSpan('CheckpointProposalJob.proposeCheckpoint', function() {
459
+ return {
460
+ // nullish operator needed for tests
461
+ [Attributes.COINBASE]: this.validatorClient.getCoinbaseForAttestor(this.attestorAddress)?.toString(),
462
+ [Attributes.SLOT_NUMBER]: this.slot
463
+ };
464
+ }), _dec2 = trackSpan('CheckpointProposalJob.buildBlocksForCheckpoint'), _dec3 = trackSpan('CheckpointProposalJob.waitUntilNextSubslot'), _dec4 = trackSpan('CheckpointProposalJob.buildSingleBlock'), _dec5 = trackSpan('CheckpointProposalJob.waitForMinTxs'), _dec6 = trackSpan('CheckpointProposalJob.waitForAttestations'), _dec7 = trackSpan('CheckpointProposalJob.waitUntilTimeInSlot');
83
465
  /**
84
466
  * Handles the execution of a checkpoint proposal after the initial preparation phase.
85
467
  * This includes building blocks, collecting attestations, and publishing the checkpoint to L1,
@@ -92,13 +474,14 @@ import { SequencerState } from './utils.js';
92
474
  proposer;
93
475
  publisher;
94
476
  attestorAddress;
95
- invalidateBlock;
477
+ invalidateCheckpoint;
96
478
  validatorClient;
97
479
  globalsBuilder;
98
480
  p2pClient;
99
481
  worldState;
100
482
  l1ToL2MessageSource;
101
483
  checkpointsBuilder;
484
+ blockSink;
102
485
  l1Constants;
103
486
  config;
104
487
  timetable;
@@ -109,21 +492,67 @@ import { SequencerState } from './utils.js';
109
492
  eventEmitter;
110
493
  setStateFn;
111
494
  log;
495
+ tracer;
496
+ static{
497
+ ({ e: [_initProto] } = _apply_decs_2203_r(this, [
498
+ [
499
+ _dec,
500
+ 2,
501
+ "execute"
502
+ ],
503
+ [
504
+ _dec1,
505
+ 2,
506
+ "proposeCheckpoint"
507
+ ],
508
+ [
509
+ _dec2,
510
+ 2,
511
+ "buildBlocksForCheckpoint"
512
+ ],
513
+ [
514
+ _dec3,
515
+ 2,
516
+ "waitUntilNextSubslot"
517
+ ],
518
+ [
519
+ _dec4,
520
+ 2,
521
+ "buildSingleBlock"
522
+ ],
523
+ [
524
+ _dec5,
525
+ 2,
526
+ "waitForMinTxs"
527
+ ],
528
+ [
529
+ _dec6,
530
+ 2,
531
+ "waitForAttestations"
532
+ ],
533
+ [
534
+ _dec7,
535
+ 2,
536
+ "waitUntilTimeInSlot"
537
+ ]
538
+ ], []));
539
+ }
112
540
  constructor(slot, checkpointNumber, syncedToBlockNumber, // TODO(palla/mbps): Can we remove the proposer in favor of attestorAddress? Need to check fisherman-node flows.
113
- proposer, publisher, attestorAddress, invalidateBlock, validatorClient, globalsBuilder, p2pClient, worldState, l1ToL2MessageSource, checkpointsBuilder, l1Constants, config, timetable, slasherClient, epochCache, dateProvider, metrics, eventEmitter, setStateFn, log){
541
+ proposer, publisher, attestorAddress, invalidateCheckpoint, validatorClient, globalsBuilder, p2pClient, worldState, l1ToL2MessageSource, checkpointsBuilder, blockSink, l1Constants, config, timetable, slasherClient, epochCache, dateProvider, metrics, eventEmitter, setStateFn, log, tracer){
114
542
  this.slot = slot;
115
543
  this.checkpointNumber = checkpointNumber;
116
544
  this.syncedToBlockNumber = syncedToBlockNumber;
117
545
  this.proposer = proposer;
118
546
  this.publisher = publisher;
119
547
  this.attestorAddress = attestorAddress;
120
- this.invalidateBlock = invalidateBlock;
548
+ this.invalidateCheckpoint = invalidateCheckpoint;
121
549
  this.validatorClient = validatorClient;
122
550
  this.globalsBuilder = globalsBuilder;
123
551
  this.p2pClient = p2pClient;
124
552
  this.worldState = worldState;
125
553
  this.l1ToL2MessageSource = l1ToL2MessageSource;
126
554
  this.checkpointsBuilder = checkpointsBuilder;
555
+ this.blockSink = blockSink;
127
556
  this.l1Constants = l1Constants;
128
557
  this.config = config;
129
558
  this.timetable = timetable;
@@ -134,6 +563,8 @@ import { SequencerState } from './utils.js';
134
563
  this.eventEmitter = eventEmitter;
135
564
  this.setStateFn = setStateFn;
136
565
  this.log = log;
566
+ this.tracer = tracer;
567
+ _initProto(this);
137
568
  }
138
569
  /**
139
570
  * Executes the checkpoint proposal job.
@@ -188,14 +619,15 @@ import { SequencerState } from './utils.js';
188
619
  // Start the checkpoint
189
620
  this.setStateFn(SequencerState.INITIALIZING_CHECKPOINT, this.slot);
190
621
  this.metrics.incOpenSlot(this.slot, this.proposer?.toString() ?? 'unknown');
191
- // Enqueues block invalidation (constant for the whole slot)
192
- if (this.invalidateBlock && !this.config.skipInvalidateBlockAsProposer) {
193
- this.publisher.enqueueInvalidateBlock(this.invalidateBlock);
622
+ // Enqueues checkpoint invalidation (constant for the whole slot)
623
+ if (this.invalidateCheckpoint && !this.config.skipInvalidateBlockAsProposer) {
624
+ this.publisher.enqueueInvalidateCheckpoint(this.invalidateCheckpoint);
194
625
  }
195
626
  // Create checkpoint builder for the slot
196
627
  const checkpointGlobalVariables = await this.globalsBuilder.buildCheckpointGlobalVariables(coinbase, feeRecipient, this.slot);
197
- // Collect L1 to L2 messages for the checkpoint
628
+ // Collect L1 to L2 messages for the checkpoint and compute their hash
198
629
  const l1ToL2Messages = await this.l1ToL2MessageSource.getL1ToL2Messages(this.checkpointNumber);
630
+ const inHash = computeInHashFromL1ToL2Messages(l1ToL2Messages);
199
631
  const fork = _ts_add_disposable_resource(env, await this.worldState.fork(this.syncedToBlockNumber, {
200
632
  closeDelayMs: 12_000
201
633
  }), false);
@@ -206,8 +638,12 @@ import { SequencerState } from './utils.js';
206
638
  publishFullTxs: !!this.config.publishTxsWithProposals,
207
639
  broadcastInvalidBlockProposal: this.config.broadcastInvalidBlockProposal
208
640
  };
641
+ const checkpointProposalOptions = {
642
+ publishFullTxs: !!this.config.publishTxsWithProposals,
643
+ broadcastInvalidCheckpointProposal: this.config.broadcastInvalidBlockProposal
644
+ };
209
645
  // Main loop: build blocks for the checkpoint
210
- const { blocksInCheckpoint, pendingBroadcast } = await this.buildBlocksForCheckpoint(checkpointBuilder, checkpointGlobalVariables.timestamp, blockProposalOptions);
646
+ const { blocksInCheckpoint, blockPendingBroadcast } = await this.buildBlocksForCheckpoint(checkpointBuilder, checkpointGlobalVariables.timestamp, inHash, blockProposalOptions);
211
647
  if (blocksInCheckpoint.length === 0) {
212
648
  this.log.warn(`No blocks were built for slot ${this.slot}`, {
213
649
  slot: this.slot
@@ -231,14 +667,20 @@ import { SequencerState } from './utils.js';
231
667
  this.metrics.recordCheckpointSuccess();
232
668
  return checkpoint;
233
669
  }
234
- // TODO(palla/mbps): Wire this to the new p2p API once available, including the pendingBroadcast.block
235
- const proposal = await this.validatorClient.createCheckpointProposal(checkpoint.header, checkpoint.archive.root, pendingBroadcast?.txs ?? [], this.proposer, blockProposalOptions);
670
+ // Include the block pending broadcast in the checkpoint proposal if any
671
+ const lastBlock = blockPendingBroadcast && {
672
+ blockHeader: blockPendingBroadcast.block.header,
673
+ indexWithinCheckpoint: blockPendingBroadcast.block.indexWithinCheckpoint,
674
+ txs: blockPendingBroadcast.txs
675
+ };
676
+ // Create the checkpoint proposal and broadcast it
677
+ const proposal = await this.validatorClient.createCheckpointProposal(checkpoint.header, checkpoint.archive.root, lastBlock, this.proposer, checkpointProposalOptions);
236
678
  const blockProposedAt = this.dateProvider.now();
237
- await this.p2pClient.broadcastProposal(proposal);
679
+ await this.p2pClient.broadcastCheckpointProposal(proposal);
238
680
  this.setStateFn(SequencerState.COLLECTING_ATTESTATIONS, this.slot);
239
681
  const attestations = await this.waitForAttestations(proposal);
240
682
  const blockAttestedAt = this.dateProvider.now();
241
- this.metrics.recordBlockAttestationDelay(blockAttestedAt - blockProposedAt);
683
+ this.metrics.recordCheckpointAttestationDelay(blockAttestedAt - blockProposedAt);
242
684
  // Proposer must sign over the attestations before pushing them to L1
243
685
  const signer = this.proposer ?? this.publisher.getSenderAddress();
244
686
  const attestationsSignature = await this.validatorClient.signAttestationsAndSigners(attestations, signer);
@@ -249,7 +691,7 @@ import { SequencerState } from './utils.js';
249
691
  const txTimeoutAt = new Date((slotStartBuildTimestamp + aztecSlotDuration) * 1000);
250
692
  await this.publisher.enqueueProposeCheckpoint(checkpoint, attestations, attestationsSignature, {
251
693
  txTimeoutAt,
252
- forcePendingBlockNumber: this.invalidateBlock?.forcePendingBlockNumber
694
+ forcePendingCheckpointNumber: this.invalidateCheckpoint?.forcePendingCheckpointNumber
253
695
  });
254
696
  return checkpoint;
255
697
  } catch (e) {
@@ -265,12 +707,12 @@ import { SequencerState } from './utils.js';
265
707
  }
266
708
  /**
267
709
  * Builds blocks for a checkpoint within the current slot.
268
- */ async buildBlocksForCheckpoint(checkpointBuilder, timestamp, blockProposalOptions) {
710
+ */ async buildBlocksForCheckpoint(checkpointBuilder, timestamp, inHash, blockProposalOptions) {
269
711
  const blocksInCheckpoint = [];
270
712
  const txHashesAlreadyIncluded = new Set();
271
713
  const initialBlockNumber = BlockNumber(this.syncedToBlockNumber + 1);
272
714
  // Last block in the checkpoint will usually be flagged as pending broadcast, so we send it along with the checkpoint proposal
273
- let pendingBroadcast = undefined;
715
+ let blockPendingBroadcast = undefined;
274
716
  while(true){
275
717
  const blocksBuilt = blocksInCheckpoint.length;
276
718
  const indexWithinCheckpoint = blocksBuilt;
@@ -328,7 +770,7 @@ import { SequencerState } from './utils.js';
328
770
  blockNumber,
329
771
  blocksBuilt
330
772
  });
331
- pendingBroadcast = {
773
+ blockPendingBroadcast = {
332
774
  block,
333
775
  txs: usedTxs
334
776
  };
@@ -337,8 +779,7 @@ import { SequencerState } from './utils.js';
337
779
  // For non-last blocks, broadcast the block proposal (unless we're in fisherman mode)
338
780
  // If the block is the last one, we'll broadcast it along with the checkpoint at the end of the loop
339
781
  if (!this.config.fishermanMode) {
340
- // TODO(palla/mbps): Wire this to the new p2p API once available
341
- const proposal = await this.validatorClient.createBlockProposal(block.header.globalVariables.blockNumber, (await checkpointBuilder.getCheckpoint()).header, block.archive.root, usedTxs, this.proposer, blockProposalOptions);
782
+ const proposal = await this.validatorClient.createBlockProposal(block.header, block.indexWithinCheckpoint, inHash, block.archive.root, usedTxs, this.proposer, blockProposalOptions);
342
783
  await this.p2pClient.broadcastProposal(proposal);
343
784
  }
344
785
  // Wait until the next block's start time
@@ -350,7 +791,7 @@ import { SequencerState } from './utils.js';
350
791
  });
351
792
  return {
352
793
  blocksInCheckpoint,
353
- pendingBroadcast
794
+ blockPendingBroadcast
354
795
  };
355
796
  }
356
797
  /** Sleeps until it is time to produce the next block in the slot */ async waitUntilNextSubslot(nextSubslotStart) {
@@ -534,8 +975,7 @@ import { SequencerState } from './utils.js';
534
975
  const sorted = orderAttestations(attestations, committee);
535
976
  // Manipulate the attestations if we've been configured to do so
536
977
  if (this.config.injectFakeAttestation || this.config.shuffleAttestationOrdering) {
537
- const checkpoint = proposal.payload.header;
538
- return this.manipulateAttestations(checkpoint, epoch, seed, committee, sorted);
978
+ return this.manipulateAttestations(proposal.slotNumber, epoch, seed, committee, sorted);
539
979
  }
540
980
  return new CommitteeAttestationsAndSigners(sorted);
541
981
  } catch (err) {
@@ -547,10 +987,9 @@ import { SequencerState } from './utils.js';
547
987
  this.metrics.recordCollectedAttestations(collectedAttestationsCount, collectAttestationsTimer.ms());
548
988
  }
549
989
  }
550
- /** Breaks the attestations before publishing based on attack configs */ manipulateAttestations(checkpoint, epoch, seed, committee, attestations) {
990
+ /** Breaks the attestations before publishing based on attack configs */ manipulateAttestations(slotNumber, epoch, seed, committee, attestations) {
551
991
  // Compute the proposer index in the committee, since we dont want to tweak it.
552
992
  // Otherwise, the L1 rollup contract will reject the block outright.
553
- const { slotNumber } = checkpoint;
554
993
  const proposerIndex = Number(this.epochCache.computeProposerIndex(slotNumber, epoch, seed, BigInt(committee.length)));
555
994
  if (this.config.injectFakeAttestation) {
556
995
  // Find non-empty attestations that are not from the proposer
@@ -595,15 +1034,23 @@ import { SequencerState } from './utils.js';
595
1034
  await this.p2pClient.deleteTxs(failedTxHashes);
596
1035
  }
597
1036
  /**
598
- * Placeholder for pushing block to archiver and waiting for sync.
599
- * To be implemented when archiver and world-state support proposed blocks.
1037
+ * Adds the proposed block to the archiver so it's available via P2P.
1038
+ * Gossip doesn't echo messages back to the sender, so the proposer's archiver/world-state
1039
+ * would never receive its own block without this explicit sync.
600
1040
  */ async syncProposedBlockToArchiver(block) {
601
- this.log.debug(`Syncing proposed block ${block.number}`, {
1041
+ // TODO(palla/mbps): Change default to false once block sync is stable.
1042
+ if (this.config.skipPushProposedBlocksToArchiver !== false) {
1043
+ this.log.warn(`Skipping push of proposed block ${block.number} to archiver`, {
1044
+ blockNumber: block.number,
1045
+ slot: block.header.globalVariables.slotNumber
1046
+ });
1047
+ return;
1048
+ }
1049
+ this.log.debug(`Syncing proposed block ${block.number} to archiver`, {
602
1050
  blockNumber: block.number,
603
1051
  slot: block.header.globalVariables.slotNumber
604
1052
  });
605
- // TODO(palla/mbps): Implement actual sync to archiver and world-state
606
- await Promise.resolve();
1053
+ await this.blockSink.addBlock(block);
607
1054
  }
608
1055
  /** Runs fee analysis and logs checkpoint outcome as fisherman */ async handleCheckpointEndAsFisherman(checkpoint) {
609
1056
  // Perform L1 fee analysis before clearing requests
@@ -1,8 +1,7 @@
1
1
  export * from './block_builder.js';
2
- export * from './checkpoint_builder.js';
3
2
  export * from './checkpoint_proposal_job.js';
4
3
  export * from './checkpoint_voter.js';
5
4
  export * from './config.js';
6
5
  export * from './events.js';
7
6
  export * from './sequencer.js';
8
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zZXF1ZW5jZXIvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxvQkFBb0IsQ0FBQztBQUNuQyxjQUFjLHlCQUF5QixDQUFDO0FBQ3hDLGNBQWMsOEJBQThCLENBQUM7QUFDN0MsY0FBYyx1QkFBdUIsQ0FBQztBQUN0QyxjQUFjLGFBQWEsQ0FBQztBQUM1QixjQUFjLGFBQWEsQ0FBQztBQUM1QixjQUFjLGdCQUFnQixDQUFDIn0=
7
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zZXF1ZW5jZXIvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxvQkFBb0IsQ0FBQztBQUNuQyxjQUFjLDhCQUE4QixDQUFDO0FBQzdDLGNBQWMsdUJBQXVCLENBQUM7QUFDdEMsY0FBYyxhQUFhLENBQUM7QUFDNUIsY0FBYyxhQUFhLENBQUM7QUFDNUIsY0FBYyxnQkFBZ0IsQ0FBQyJ9
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sequencer/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sequencer/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
@@ -1,5 +1,4 @@
1
1
  export * from './block_builder.js';
2
- export * from './checkpoint_builder.js';
3
2
  export * from './checkpoint_proposal_job.js';
4
3
  export * from './checkpoint_voter.js';
5
4
  export * from './config.js';