@aztec/sequencer-client 0.0.1-fake-c83136db25 → 0.0.1-private.d0bedffd

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 (119) hide show
  1. package/dest/client/index.d.ts +1 -1
  2. package/dest/client/sequencer-client.d.ts +32 -16
  3. package/dest/client/sequencer-client.d.ts.map +1 -1
  4. package/dest/client/sequencer-client.js +118 -27
  5. package/dest/config.d.ts +33 -8
  6. package/dest/config.d.ts.map +1 -1
  7. package/dest/config.js +106 -42
  8. package/dest/global_variable_builder/global_builder.d.ts +20 -16
  9. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  10. package/dest/global_variable_builder/global_builder.js +52 -39
  11. package/dest/global_variable_builder/index.d.ts +1 -1
  12. package/dest/index.d.ts +2 -3
  13. package/dest/index.d.ts.map +1 -1
  14. package/dest/index.js +1 -2
  15. package/dest/publisher/config.d.ts +43 -20
  16. package/dest/publisher/config.d.ts.map +1 -1
  17. package/dest/publisher/config.js +109 -34
  18. package/dest/publisher/index.d.ts +2 -1
  19. package/dest/publisher/index.d.ts.map +1 -1
  20. package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
  21. package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
  22. package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
  23. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +59 -0
  24. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
  25. package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +1 -0
  26. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
  27. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
  28. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +34 -0
  29. package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
  30. package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
  31. package/dest/publisher/l1_tx_failed_store/index.js +2 -0
  32. package/dest/publisher/sequencer-publisher-factory.d.ts +15 -6
  33. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  34. package/dest/publisher/sequencer-publisher-factory.js +28 -3
  35. package/dest/publisher/sequencer-publisher-metrics.d.ts +3 -3
  36. package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
  37. package/dest/publisher/sequencer-publisher-metrics.js +23 -86
  38. package/dest/publisher/sequencer-publisher.d.ts +99 -67
  39. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  40. package/dest/publisher/sequencer-publisher.js +976 -183
  41. package/dest/sequencer/checkpoint_proposal_job.d.ts +100 -0
  42. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
  43. package/dest/sequencer/checkpoint_proposal_job.js +1244 -0
  44. package/dest/sequencer/checkpoint_voter.d.ts +35 -0
  45. package/dest/sequencer/checkpoint_voter.d.ts.map +1 -0
  46. package/dest/sequencer/checkpoint_voter.js +109 -0
  47. package/dest/sequencer/config.d.ts +3 -2
  48. package/dest/sequencer/config.d.ts.map +1 -1
  49. package/dest/sequencer/errors.d.ts +1 -1
  50. package/dest/sequencer/errors.d.ts.map +1 -1
  51. package/dest/sequencer/events.d.ts +46 -0
  52. package/dest/sequencer/events.d.ts.map +1 -0
  53. package/dest/sequencer/events.js +1 -0
  54. package/dest/sequencer/index.d.ts +4 -2
  55. package/dest/sequencer/index.d.ts.map +1 -1
  56. package/dest/sequencer/index.js +3 -1
  57. package/dest/sequencer/metrics.d.ts +44 -3
  58. package/dest/sequencer/metrics.d.ts.map +1 -1
  59. package/dest/sequencer/metrics.js +232 -50
  60. package/dest/sequencer/sequencer.d.ts +125 -144
  61. package/dest/sequencer/sequencer.d.ts.map +1 -1
  62. package/dest/sequencer/sequencer.js +740 -525
  63. package/dest/sequencer/timetable.d.ts +54 -16
  64. package/dest/sequencer/timetable.d.ts.map +1 -1
  65. package/dest/sequencer/timetable.js +147 -62
  66. package/dest/sequencer/types.d.ts +6 -0
  67. package/dest/sequencer/types.d.ts.map +1 -0
  68. package/dest/sequencer/types.js +1 -0
  69. package/dest/sequencer/utils.d.ts +14 -8
  70. package/dest/sequencer/utils.d.ts.map +1 -1
  71. package/dest/sequencer/utils.js +7 -4
  72. package/dest/test/index.d.ts +6 -7
  73. package/dest/test/index.d.ts.map +1 -1
  74. package/dest/test/mock_checkpoint_builder.d.ts +95 -0
  75. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -0
  76. package/dest/test/mock_checkpoint_builder.js +231 -0
  77. package/dest/test/utils.d.ts +53 -0
  78. package/dest/test/utils.d.ts.map +1 -0
  79. package/dest/test/utils.js +104 -0
  80. package/package.json +33 -30
  81. package/src/client/sequencer-client.ts +158 -52
  82. package/src/config.ts +122 -52
  83. package/src/global_variable_builder/global_builder.ts +67 -59
  84. package/src/index.ts +1 -7
  85. package/src/publisher/config.ts +139 -50
  86. package/src/publisher/index.ts +3 -0
  87. package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
  88. package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +55 -0
  89. package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +46 -0
  90. package/src/publisher/l1_tx_failed_store/index.ts +3 -0
  91. package/src/publisher/sequencer-publisher-factory.ts +45 -11
  92. package/src/publisher/sequencer-publisher-metrics.ts +19 -71
  93. package/src/publisher/sequencer-publisher.ts +692 -241
  94. package/src/sequencer/README.md +531 -0
  95. package/src/sequencer/checkpoint_proposal_job.ts +960 -0
  96. package/src/sequencer/checkpoint_voter.ts +130 -0
  97. package/src/sequencer/config.ts +2 -1
  98. package/src/sequencer/events.ts +27 -0
  99. package/src/sequencer/index.ts +3 -1
  100. package/src/sequencer/metrics.ts +296 -61
  101. package/src/sequencer/sequencer.ts +494 -717
  102. package/src/sequencer/timetable.ts +178 -83
  103. package/src/sequencer/types.ts +9 -0
  104. package/src/sequencer/utils.ts +18 -9
  105. package/src/test/index.ts +5 -6
  106. package/src/test/mock_checkpoint_builder.ts +323 -0
  107. package/src/test/utils.ts +167 -0
  108. package/dest/sequencer/block_builder.d.ts +0 -27
  109. package/dest/sequencer/block_builder.d.ts.map +0 -1
  110. package/dest/sequencer/block_builder.js +0 -130
  111. package/dest/tx_validator/nullifier_cache.d.ts +0 -14
  112. package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
  113. package/dest/tx_validator/nullifier_cache.js +0 -24
  114. package/dest/tx_validator/tx_validator_factory.d.ts +0 -17
  115. package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
  116. package/dest/tx_validator/tx_validator_factory.js +0 -53
  117. package/src/sequencer/block_builder.ts +0 -218
  118. package/src/tx_validator/nullifier_cache.ts +0 -30
  119. package/src/tx_validator/tx_validator_factory.ts +0 -132
@@ -1,18 +1,398 @@
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
+ };
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, _dec2, _initProto;
1
374
  import { Blob, getBlobsPerL1Block, getPrefixedEthBlobCommitments } from '@aztec/blob-lib';
2
- import { createBlobSinkClient } from '@aztec/blob-sink/client';
3
- import { FormattedViemError, MULTI_CALL_3_ADDRESS, Multicall3, RollupContract, formatViemError, tryExtractEvent } from '@aztec/ethereum';
375
+ import { FeeAssetPriceOracle, MULTI_CALL_3_ADDRESS, Multicall3, RollupContract } from '@aztec/ethereum/contracts';
376
+ import { L1FeeAnalyzer } from '@aztec/ethereum/l1-fee-analysis';
377
+ import { MAX_L1_TX_LIMIT, WEI_CONST } from '@aztec/ethereum/l1-tx-utils';
378
+ import { FormattedViemError, formatViemError, mergeAbis, tryExtractEvent } from '@aztec/ethereum/utils';
4
379
  import { sumBigint } from '@aztec/foundation/bigint';
5
380
  import { toHex as toPaddedHex } from '@aztec/foundation/bigint-buffer';
381
+ import { CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
382
+ import { pick } from '@aztec/foundation/collection';
383
+ import { TimeoutError } from '@aztec/foundation/error';
6
384
  import { EthAddress } from '@aztec/foundation/eth-address';
7
385
  import { Signature } from '@aztec/foundation/eth-signature';
8
386
  import { createLogger } from '@aztec/foundation/log';
387
+ import { makeBackoff, retry } from '@aztec/foundation/retry';
9
388
  import { bufferToHex } from '@aztec/foundation/string';
10
389
  import { Timer } from '@aztec/foundation/timer';
11
390
  import { EmpireBaseAbi, ErrorsAbi, RollupAbi } from '@aztec/l1-artifacts';
12
391
  import { encodeSlashConsensusVotes } from '@aztec/slasher';
13
- import { CommitteeAttestation, CommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
14
- import { getTelemetryClient } from '@aztec/telemetry-client';
15
- import { encodeFunctionData, toHex } from 'viem';
392
+ import { CommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
393
+ import { getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
394
+ import { encodeFunctionData, keccak256, multicall3Abi, toHex } from 'viem';
395
+ import { createL1TxFailedStore } from './l1_tx_failed_store/index.js';
16
396
  import { SequencerPublisherMetrics } from './sequencer-publisher-metrics.js';
17
397
  export const Actions = [
18
398
  'invalidate-by-invalid-attestation',
@@ -27,21 +407,44 @@ export const Actions = [
27
407
  ];
28
408
  // Sorting for actions such that invalidations go before proposals, and proposals go before votes
29
409
  export const compareActions = (a, b)=>Actions.indexOf(a) - Actions.indexOf(b);
410
+ _dec = trackSpan('SequencerPublisher.sendRequests'), _dec1 = trackSpan('SequencerPublisher.validateBlockHeader'), _dec2 = trackSpan('SequencerPublisher.validateCheckpointForSubmission');
30
411
  export class SequencerPublisher {
31
412
  config;
413
+ static{
414
+ ({ e: [_initProto] } = _apply_decs_2203_r(this, [
415
+ [
416
+ _dec,
417
+ 2,
418
+ "sendRequests"
419
+ ],
420
+ [
421
+ _dec1,
422
+ 2,
423
+ "validateBlockHeader"
424
+ ],
425
+ [
426
+ _dec2,
427
+ 2,
428
+ "validateCheckpointForSubmission"
429
+ ]
430
+ ], []));
431
+ }
32
432
  interrupted;
33
433
  metrics;
34
434
  epochCache;
435
+ failedTxStore;
35
436
  governanceLog;
36
437
  slashingLog;
37
438
  lastActions;
439
+ isPayloadEmptyCache;
440
+ payloadProposedCache;
38
441
  log;
39
442
  ethereumSlotDuration;
40
- blobSinkClient;
41
- // @note - with blobs, the below estimate seems too large.
42
- // Total used for full block from int_l1_pub e2e test: 1m (of which 86k is 1x blob)
43
- // Total used for emptier block from above test: 429k (of which 84k is 1x blob)
44
- static PROPOSE_GAS_GUESS = 12_000_000n;
443
+ blobClient;
444
+ /** Address to use for simulations in fisherman mode (actual proposer's address) */ proposerAddressForSimulation;
445
+ /** Optional callback to obtain a replacement publisher when the current one fails to send. */ getNextPublisher;
446
+ /** L1 fee analyzer for fisherman mode */ l1FeeAnalyzer;
447
+ /** Fee asset price oracle for computing price modifiers from Uniswap V4 */ feeAssetPriceOracle;
45
448
  // A CALL to a cold address is 2700 gas
46
449
  static MULTICALL_OVERHEAD_GAS_GUESS = 5000n;
47
450
  // Gas report for VotingWithSigTest shows a max gas of 100k, but we've seen it cost 700k+ in testnet
@@ -51,24 +454,27 @@ export class SequencerPublisher {
51
454
  govProposerContract;
52
455
  slashingProposerContract;
53
456
  slashFactoryContract;
457
+ tracer;
54
458
  requests;
55
459
  constructor(config, deps){
56
460
  this.config = config;
57
- this.interrupted = false;
461
+ this.interrupted = (_initProto(this), false);
58
462
  this.governanceLog = createLogger('sequencer:publisher:governance');
59
463
  this.slashingLog = createLogger('sequencer:publisher:slashing');
60
464
  this.lastActions = {};
465
+ this.isPayloadEmptyCache = new Map();
466
+ this.payloadProposedCache = new Set();
61
467
  this.requests = [];
62
468
  this.log = deps.log ?? createLogger('sequencer:publisher');
63
469
  this.ethereumSlotDuration = BigInt(config.ethereumSlotDuration);
64
470
  this.epochCache = deps.epochCache;
65
471
  this.lastActions = deps.lastActions;
66
- this.blobSinkClient = deps.blobSinkClient ?? createBlobSinkClient(config, {
67
- logger: createLogger('sequencer:blob-sink:client')
68
- });
472
+ this.blobClient = deps.blobClient;
69
473
  const telemetry = deps.telemetry ?? getTelemetryClient();
70
474
  this.metrics = deps.metrics ?? new SequencerPublisherMetrics(telemetry, 'SequencerPublisher');
475
+ this.tracer = telemetry.getTracer('SequencerPublisher');
71
476
  this.l1TxUtils = deps.l1TxUtils;
477
+ this.getNextPublisher = deps.getNextPublisher;
72
478
  this.rollupContract = deps.rollupContract;
73
479
  this.govProposerContract = deps.governanceProposerContract;
74
480
  this.slashingProposerContract = deps.slashingProposerContract;
@@ -78,13 +484,54 @@ export class SequencerPublisher {
78
484
  this.slashingProposerContract = newSlashingProposer;
79
485
  });
80
486
  this.slashFactoryContract = deps.slashFactoryContract;
487
+ // Initialize L1 fee analyzer for fisherman mode
488
+ if (config.fishermanMode) {
489
+ this.l1FeeAnalyzer = new L1FeeAnalyzer(this.l1TxUtils.client, deps.dateProvider, createLogger('sequencer:publisher:fee-analyzer'));
490
+ }
491
+ // Initialize fee asset price oracle
492
+ this.feeAssetPriceOracle = new FeeAssetPriceOracle(this.l1TxUtils.client, this.rollupContract, createLogger('sequencer:publisher:price-oracle'));
493
+ // Initialize failed L1 tx store (optional, for test networks)
494
+ this.failedTxStore = createL1TxFailedStore(config.l1TxFailedStore, this.log);
495
+ }
496
+ /**
497
+ * Backs up a failed L1 transaction to the configured store for debugging.
498
+ * Does nothing if no store is configured.
499
+ */ backupFailedTx(failedTx) {
500
+ if (!this.failedTxStore) {
501
+ return;
502
+ }
503
+ const tx = {
504
+ ...failedTx,
505
+ timestamp: Date.now()
506
+ };
507
+ // Fire and forget - don't block on backup
508
+ void this.failedTxStore.then((store)=>store?.saveFailedTx(tx)).catch((err)=>{
509
+ this.log.warn(`Failed to backup failed L1 tx to store`, err);
510
+ });
81
511
  }
82
512
  getRollupContract() {
83
513
  return this.rollupContract;
84
514
  }
515
+ /**
516
+ * Gets the fee asset price modifier from the oracle.
517
+ * Returns 0n if the oracle query fails.
518
+ */ getFeeAssetPriceModifier() {
519
+ return this.feeAssetPriceOracle.computePriceModifier();
520
+ }
85
521
  getSenderAddress() {
86
522
  return this.l1TxUtils.getSenderAddress();
87
523
  }
524
+ /**
525
+ * Gets the L1 fee analyzer instance (only available in fisherman mode)
526
+ */ getL1FeeAnalyzer() {
527
+ return this.l1FeeAnalyzer;
528
+ }
529
+ /**
530
+ * Sets the proposer address to use for simulations in fisherman mode.
531
+ * @param proposerAddress - The actual proposer's address to use for balance lookups in simulations
532
+ */ setProposerAddressForSimulation(proposerAddress) {
533
+ this.proposerAddressForSimulation = proposerAddress;
534
+ }
88
535
  addRequest(request) {
89
536
  this.requests.push(request);
90
537
  }
@@ -92,6 +539,55 @@ export class SequencerPublisher {
92
539
  return this.epochCache.getEpochAndSlotNow().slot;
93
540
  }
94
541
  /**
542
+ * Clears all pending requests without sending them.
543
+ */ clearPendingRequests() {
544
+ const count = this.requests.length;
545
+ this.requests = [];
546
+ if (count > 0) {
547
+ this.log.debug(`Cleared ${count} pending request(s)`);
548
+ }
549
+ }
550
+ /**
551
+ * Analyzes L1 fees for the pending requests without sending them.
552
+ * This is used in fisherman mode to validate fee calculations.
553
+ * @param l2SlotNumber - The L2 slot number for this analysis
554
+ * @param onComplete - Optional callback to invoke when analysis completes (after block is mined)
555
+ * @returns The analysis result (incomplete until block mines), or undefined if no requests
556
+ */ async analyzeL1Fees(l2SlotNumber, onComplete) {
557
+ if (!this.l1FeeAnalyzer) {
558
+ this.log.warn('L1 fee analyzer not available (not in fisherman mode)');
559
+ return undefined;
560
+ }
561
+ const requestsToAnalyze = [
562
+ ...this.requests
563
+ ];
564
+ if (requestsToAnalyze.length === 0) {
565
+ this.log.debug('No requests to analyze for L1 fees');
566
+ return undefined;
567
+ }
568
+ // Extract blob config from requests (if any)
569
+ const blobConfigs = requestsToAnalyze.filter((request)=>request.blobConfig).map((request)=>request.blobConfig);
570
+ const blobConfig = blobConfigs[0];
571
+ // Get gas configs
572
+ const gasConfigs = requestsToAnalyze.filter((request)=>request.gasConfig).map((request)=>request.gasConfig);
573
+ const gasLimits = gasConfigs.map((g)=>g?.gasLimit).filter((g)=>g !== undefined);
574
+ const gasLimit = gasLimits.length > 0 ? gasLimits.reduce((sum, g)=>sum + g, 0n) : 0n;
575
+ // Get the transaction requests
576
+ const l1Requests = requestsToAnalyze.map((r)=>r.request);
577
+ // Start the analysis
578
+ const analysisId = await this.l1FeeAnalyzer.startAnalysis(l2SlotNumber, gasLimit > 0n ? gasLimit : MAX_L1_TX_LIMIT, l1Requests, blobConfig, onComplete);
579
+ this.log.info('Started L1 fee analysis', {
580
+ analysisId,
581
+ l2SlotNumber: l2SlotNumber.toString(),
582
+ requestCount: requestsToAnalyze.length,
583
+ hasBlobConfig: !!blobConfig,
584
+ gasLimit: gasLimit.toString(),
585
+ actions: requestsToAnalyze.map((r)=>r.action)
586
+ });
587
+ // Return the analysis result (will be incomplete until block mines)
588
+ return this.l1FeeAnalyzer.getAnalysis(analysisId);
589
+ }
590
+ /**
95
591
  * Sends all requests that are still valid.
96
592
  * @returns one of:
97
593
  * - A receipt and stats if the tx succeeded
@@ -102,7 +598,7 @@ export class SequencerPublisher {
102
598
  ...this.requests
103
599
  ];
104
600
  this.requests = [];
105
- if (this.interrupted) {
601
+ if (this.interrupted || requestsToProcess.length === 0) {
106
602
  return undefined;
107
603
  }
108
604
  const currentL2Slot = this.getCurrentL2Slot();
@@ -137,7 +633,16 @@ export class SequencerPublisher {
137
633
  const blobConfig = blobConfigs[0];
138
634
  // Merge gasConfigs. Yields the sum of gasLimits, and the earliest txTimeoutAt, or undefined if no gasConfig sets them.
139
635
  const gasLimits = gasConfigs.map((g)=>g?.gasLimit).filter((g)=>g !== undefined);
140
- const gasLimit = gasLimits.length > 0 ? sumBigint(gasLimits) : undefined; // sum
636
+ let gasLimit = gasLimits.length > 0 ? sumBigint(gasLimits) : undefined; // sum
637
+ // Cap at L1 block gas limit so the node accepts the tx ("gas limit too high" otherwise).
638
+ const maxGas = MAX_L1_TX_LIMIT;
639
+ if (gasLimit !== undefined && gasLimit > maxGas) {
640
+ this.log.debug('Capping bundled tx gas limit to L1 max', {
641
+ requested: gasLimit,
642
+ capped: maxGas
643
+ });
644
+ gasLimit = maxGas;
645
+ }
141
646
  const txTimeoutAts = gasConfigs.map((g)=>g?.txTimeoutAt).filter((g)=>g !== undefined);
142
647
  const txTimeoutAt = txTimeoutAts.length > 0 ? new Date(Math.min(...txTimeoutAts.map((g)=>g.getTime()))) : undefined; // earliest
143
648
  const txConfig = {
@@ -148,12 +653,34 @@ export class SequencerPublisher {
148
653
  // This ensures the committee gets precomputed correctly
149
654
  validRequests.sort((a, b)=>compareActions(a.action, b.action));
150
655
  try {
656
+ // Capture context for failed tx backup before sending
657
+ const l1BlockNumber = await this.l1TxUtils.getBlockNumber();
658
+ const multicallData = encodeFunctionData({
659
+ abi: multicall3Abi,
660
+ functionName: 'aggregate3',
661
+ args: [
662
+ validRequests.map((r)=>({
663
+ target: r.request.to,
664
+ callData: r.request.data,
665
+ allowFailure: true
666
+ }))
667
+ ]
668
+ });
669
+ const blobDataHex = blobConfig?.blobs?.map((b)=>toHex(b));
670
+ const txContext = {
671
+ multicallData,
672
+ blobData: blobDataHex,
673
+ l1BlockNumber
674
+ };
151
675
  this.log.debug('Forwarding transactions', {
152
676
  validRequests: validRequests.map((request)=>request.action),
153
677
  txConfig
154
678
  });
155
- const result = await Multicall3.forward(validRequests.map((request)=>request.request), this.l1TxUtils, txConfig, blobConfig, this.rollupContract.address, this.log);
156
- const { successfulActions = [], failedActions = [] } = this.callbackBundledTransactions(validRequests, result);
679
+ const result = await this.forwardWithPublisherRotation(validRequests, txConfig, blobConfig);
680
+ if (result === undefined) {
681
+ return undefined;
682
+ }
683
+ const { successfulActions = [], failedActions = [] } = this.callbackBundledTransactions(validRequests, result, txContext);
157
684
  return {
158
685
  result,
159
686
  expiredActions,
@@ -173,10 +700,67 @@ export class SequencerPublisher {
173
700
  }
174
701
  }
175
702
  }
176
- callbackBundledTransactions(requests, result) {
703
+ /**
704
+ * Forwards transactions via Multicall3, rotating to the next available publisher if a send
705
+ * failure occurs (i.e. the tx never reached the chain).
706
+ * On-chain reverts and simulation errors are returned as-is without rotation.
707
+ */ async forwardWithPublisherRotation(validRequests, txConfig, blobConfig) {
708
+ const triedAddresses = [];
709
+ let currentPublisher = this.l1TxUtils;
710
+ while(true){
711
+ triedAddresses.push(currentPublisher.getSenderAddress());
712
+ try {
713
+ const result = await Multicall3.forward(validRequests.map((r)=>r.request), currentPublisher, txConfig, blobConfig, this.rollupContract.address, this.log);
714
+ this.l1TxUtils = currentPublisher;
715
+ return result;
716
+ } catch (err) {
717
+ if (err instanceof TimeoutError) {
718
+ throw err;
719
+ }
720
+ const viemError = formatViemError(err);
721
+ if (!this.getNextPublisher) {
722
+ this.log.error('Failed to publish bundled transactions', viemError);
723
+ return undefined;
724
+ }
725
+ this.log.warn(`Publisher ${currentPublisher.getSenderAddress()} failed to send, rotating to next publisher`, viemError);
726
+ const nextPublisher = await this.getNextPublisher([
727
+ ...triedAddresses
728
+ ]);
729
+ if (!nextPublisher) {
730
+ this.log.error('All available publishers exhausted, failed to publish bundled transactions');
731
+ return undefined;
732
+ }
733
+ currentPublisher = nextPublisher;
734
+ }
735
+ }
736
+ }
737
+ callbackBundledTransactions(requests, result, txContext) {
177
738
  const actionsListStr = requests.map((r)=>r.action).join(', ');
178
739
  if (result instanceof FormattedViemError) {
179
740
  this.log.error(`Failed to publish bundled transactions (${actionsListStr})`, result);
741
+ this.backupFailedTx({
742
+ id: keccak256(txContext.multicallData),
743
+ failureType: 'send-error',
744
+ request: {
745
+ to: MULTI_CALL_3_ADDRESS,
746
+ data: txContext.multicallData
747
+ },
748
+ blobData: txContext.blobData,
749
+ l1BlockNumber: txContext.l1BlockNumber.toString(),
750
+ error: {
751
+ message: result.message,
752
+ name: result.name
753
+ },
754
+ context: {
755
+ actions: requests.map((r)=>r.action),
756
+ requests: requests.map((r)=>({
757
+ action: r.action,
758
+ to: r.request.to,
759
+ data: r.request.data
760
+ })),
761
+ sender: this.getSenderAddress().toString()
762
+ }
763
+ });
180
764
  return {
181
765
  failedActions: requests.map((r)=>r.action)
182
766
  };
@@ -194,6 +778,37 @@ export class SequencerPublisher {
194
778
  failedActions.push(request.action);
195
779
  }
196
780
  }
781
+ // Single backup for the whole reverted tx
782
+ if (failedActions.length > 0 && result?.receipt?.status === 'reverted') {
783
+ this.backupFailedTx({
784
+ id: result.receipt.transactionHash,
785
+ failureType: 'revert',
786
+ request: {
787
+ to: MULTI_CALL_3_ADDRESS,
788
+ data: txContext.multicallData
789
+ },
790
+ blobData: txContext.blobData,
791
+ l1BlockNumber: result.receipt.blockNumber.toString(),
792
+ receipt: {
793
+ transactionHash: result.receipt.transactionHash,
794
+ blockNumber: result.receipt.blockNumber.toString(),
795
+ gasUsed: (result.receipt.gasUsed ?? 0n).toString(),
796
+ status: 'reverted'
797
+ },
798
+ error: {
799
+ message: result.errorMsg ?? 'Transaction reverted'
800
+ },
801
+ context: {
802
+ actions: failedActions,
803
+ requests: requests.filter((r)=>failedActions.includes(r.action)).map((r)=>({
804
+ action: r.action,
805
+ to: r.request.to,
806
+ data: r.request.data
807
+ })),
808
+ sender: this.getSenderAddress().toString()
809
+ }
810
+ });
811
+ }
197
812
  return {
198
813
  successfulActions,
199
814
  failedActions
@@ -211,7 +826,9 @@ export class SequencerPublisher {
211
826
  'InvalidProposer',
212
827
  'InvalidArchive'
213
828
  ];
214
- return this.rollupContract.canProposeAtNextEthBlock(tipArchive.toBuffer(), msgSender.toString(), this.ethereumSlotDuration, opts).catch((err)=>{
829
+ return this.rollupContract.canProposeAtNextEthBlock(tipArchive.toBuffer(), msgSender.toString(), Number(this.ethereumSlotDuration), {
830
+ forcePendingCheckpointNumber: opts.forcePendingCheckpointNumber
831
+ }).catch((err)=>{
215
832
  if (err instanceof FormattedViemError && ignoredErrors.find((e)=>err.message.includes(e))) {
216
833
  this.log.warn(`Failed canProposeAtTime check with ${ignoredErrors.find((e)=>err.message.includes(e))}`, {
217
834
  error: err.message
@@ -238,13 +855,23 @@ export class SequencerPublisher {
238
855
  [],
239
856
  Signature.empty().toViemSignature(),
240
857
  `0x${'0'.repeat(64)}`,
241
- header.contentCommitment.blobsHash.toString(),
858
+ header.blobsHash.toString(),
242
859
  flags
243
860
  ];
244
861
  const ts = BigInt((await this.l1TxUtils.getBlock()).timestamp + this.ethereumSlotDuration);
245
- // use sender balance to simulate
246
- const balance = await this.l1TxUtils.getSenderBalance();
247
- this.log.debug(`Simulating validateHeader with balance: ${balance}`);
862
+ const stateOverrides = await this.rollupContract.makePendingCheckpointNumberOverride(opts?.forcePendingCheckpointNumber);
863
+ let balance = 0n;
864
+ if (this.config.fishermanMode) {
865
+ // In fisherman mode, we can't know where the proposer is publishing from
866
+ // so we just add sufficient balance to the multicall3 address
867
+ balance = 10n * WEI_CONST * WEI_CONST; // 10 ETH
868
+ } else {
869
+ balance = await this.l1TxUtils.getSenderBalance();
870
+ }
871
+ stateOverrides.push({
872
+ address: MULTI_CALL_3_ADDRESS,
873
+ balance
874
+ });
248
875
  await this.l1TxUtils.simulate({
249
876
  to: this.rollupContract.address,
250
877
  data: encodeFunctionData({
@@ -255,44 +882,42 @@ export class SequencerPublisher {
255
882
  from: MULTI_CALL_3_ADDRESS
256
883
  }, {
257
884
  time: ts + 1n
258
- }, [
259
- {
260
- address: MULTI_CALL_3_ADDRESS,
261
- balance
262
- },
263
- ...await this.rollupContract.makePendingBlockNumberOverride(opts?.forcePendingBlockNumber)
264
- ]);
885
+ }, stateOverrides);
265
886
  this.log.debug(`Simulated validateHeader`);
266
887
  }
267
888
  /**
268
- * Simulate making a call to invalidate a block with invalid attestations. Returns undefined if no need to invalidate.
269
- * @param block - The block to invalidate and the criteria for invalidation (as returned by the archiver)
270
- */ async simulateInvalidateBlock(validationResult) {
889
+ * Simulate making a call to invalidate a checkpoint with invalid attestations. Returns undefined if no need to invalidate.
890
+ * @param validationResult - The validation result indicating which checkpoint to invalidate (as returned by the archiver)
891
+ */ async simulateInvalidateCheckpoint(validationResult) {
271
892
  if (validationResult.valid) {
272
893
  return undefined;
273
894
  }
274
- const { reason, block } = validationResult;
275
- const blockNumber = block.blockNumber;
895
+ const { reason, checkpoint } = validationResult;
896
+ const checkpointNumber = checkpoint.checkpointNumber;
276
897
  const logData = {
277
- ...block,
898
+ ...checkpoint,
278
899
  reason
279
900
  };
280
- const currentBlockNumber = await this.rollupContract.getBlockNumber();
281
- if (currentBlockNumber < validationResult.block.blockNumber) {
282
- this.log.verbose(`Skipping block ${blockNumber} invalidation since it has already been removed from the pending chain`, {
283
- currentBlockNumber,
901
+ const currentCheckpointNumber = await this.rollupContract.getCheckpointNumber();
902
+ if (currentCheckpointNumber < checkpointNumber) {
903
+ this.log.verbose(`Skipping checkpoint ${checkpointNumber} invalidation since it has already been removed from the pending chain`, {
904
+ currentCheckpointNumber,
284
905
  ...logData
285
906
  });
286
907
  return undefined;
287
908
  }
288
- const request = this.buildInvalidateBlockRequest(validationResult);
289
- this.log.debug(`Simulating invalidate block ${blockNumber}`, {
909
+ const request = this.buildInvalidateCheckpointRequest(validationResult);
910
+ this.log.debug(`Simulating invalidate checkpoint ${checkpointNumber}`, {
290
911
  ...logData,
291
912
  request
292
913
  });
914
+ const l1BlockNumber = await this.l1TxUtils.getBlockNumber();
293
915
  try {
294
- const { gasUsed } = await this.l1TxUtils.simulate(request, undefined, undefined, ErrorsAbi);
295
- this.log.verbose(`Simulation for invalidate block ${blockNumber} succeeded`, {
916
+ const { gasUsed } = await this.l1TxUtils.simulate(request, undefined, undefined, mergeAbis([
917
+ request.abi ?? [],
918
+ ErrorsAbi
919
+ ]));
920
+ this.log.verbose(`Simulation for invalidate checkpoint ${checkpointNumber} succeeded`, {
296
921
  ...logData,
297
922
  request,
298
923
  gasUsed
@@ -300,91 +925,92 @@ export class SequencerPublisher {
300
925
  return {
301
926
  request,
302
927
  gasUsed,
303
- blockNumber,
304
- forcePendingBlockNumber: blockNumber - 1,
928
+ checkpointNumber,
929
+ forcePendingCheckpointNumber: CheckpointNumber(checkpointNumber - 1),
305
930
  reason
306
931
  };
307
932
  } catch (err) {
308
933
  const viemError = formatViemError(err);
309
- // If the error is due to the block not being in the pending chain, and it was indeed removed by someone else,
310
- // we can safely ignore it and return undefined so we go ahead with block building.
311
- if (viemError.message?.includes('Rollup__BlockNotInPendingChain')) {
312
- this.log.verbose(`Simulation for invalidate block ${blockNumber} failed due to block not being in pending chain`, {
934
+ // If the error is due to the checkpoint not being in the pending chain, and it was indeed removed by someone else,
935
+ // we can safely ignore it and return undefined so we go ahead with checkpoint building.
936
+ if (viemError.message?.includes('Rollup__CheckpointNotInPendingChain')) {
937
+ this.log.verbose(`Simulation for invalidate checkpoint ${checkpointNumber} failed due to checkpoint not being in pending chain`, {
313
938
  ...logData,
314
939
  request,
315
940
  error: viemError.message
316
941
  });
317
- const latestPendingBlockNumber = await this.rollupContract.getBlockNumber();
318
- if (latestPendingBlockNumber < blockNumber) {
319
- this.log.verbose(`Block number ${blockNumber} has already been invalidated`, {
942
+ const latestPendingCheckpointNumber = await this.rollupContract.getCheckpointNumber();
943
+ if (latestPendingCheckpointNumber < checkpointNumber) {
944
+ this.log.verbose(`Checkpoint ${checkpointNumber} has already been invalidated`, {
320
945
  ...logData
321
946
  });
322
947
  return undefined;
323
948
  } else {
324
- this.log.error(`Simulation for invalidate ${blockNumber} failed and it is still in pending chain`, viemError, logData);
325
- throw new Error(`Failed to simulate invalidate block ${blockNumber} while it is still in pending chain`, {
949
+ this.log.error(`Simulation for invalidate checkpoint ${checkpointNumber} failed and it is still in pending chain`, viemError, logData);
950
+ throw new Error(`Failed to simulate invalidate checkpoint ${checkpointNumber} while it is still in pending chain`, {
326
951
  cause: viemError
327
952
  });
328
953
  }
329
954
  }
330
- // Otherwise, throw. We cannot build the next block if we cannot invalidate the previous one.
331
- this.log.error(`Simulation for invalidate block ${blockNumber} failed`, viemError, logData);
332
- throw new Error(`Failed to simulate invalidate block ${blockNumber}`, {
955
+ // Otherwise, throw. We cannot build the next checkpoint if we cannot invalidate the previous one.
956
+ this.log.error(`Simulation for invalidate checkpoint ${checkpointNumber} failed`, viemError, logData);
957
+ this.backupFailedTx({
958
+ id: keccak256(request.data),
959
+ failureType: 'simulation',
960
+ request: {
961
+ to: request.to,
962
+ data: request.data,
963
+ value: request.value?.toString()
964
+ },
965
+ l1BlockNumber: l1BlockNumber.toString(),
966
+ error: {
967
+ message: viemError.message,
968
+ name: viemError.name
969
+ },
970
+ context: {
971
+ actions: [
972
+ `invalidate-${reason}`
973
+ ],
974
+ checkpointNumber,
975
+ sender: this.getSenderAddress().toString()
976
+ }
977
+ });
978
+ throw new Error(`Failed to simulate invalidate checkpoint ${checkpointNumber}`, {
333
979
  cause: viemError
334
980
  });
335
981
  }
336
982
  }
337
- buildInvalidateBlockRequest(validationResult) {
983
+ buildInvalidateCheckpointRequest(validationResult) {
338
984
  if (validationResult.valid) {
339
- throw new Error('Cannot invalidate a valid block');
985
+ throw new Error('Cannot invalidate a valid checkpoint');
340
986
  }
341
- const { block, committee, reason } = validationResult;
987
+ const { checkpoint, committee, reason } = validationResult;
342
988
  const logData = {
343
- ...block,
989
+ ...checkpoint,
344
990
  reason
345
991
  };
346
- this.log.debug(`Simulating invalidate block ${block.blockNumber}`, logData);
992
+ this.log.debug(`Building invalidate checkpoint ${checkpoint.checkpointNumber} request`, logData);
347
993
  const attestationsAndSigners = new CommitteeAttestationsAndSigners(validationResult.attestations).getPackedAttestations();
348
994
  if (reason === 'invalid-attestation') {
349
- return this.rollupContract.buildInvalidateBadAttestationRequest(block.blockNumber, attestationsAndSigners, committee, validationResult.invalidIndex);
995
+ return this.rollupContract.buildInvalidateBadAttestationRequest(checkpoint.checkpointNumber, attestationsAndSigners, committee, validationResult.invalidIndex);
350
996
  } else if (reason === 'insufficient-attestations') {
351
- return this.rollupContract.buildInvalidateInsufficientAttestationsRequest(block.blockNumber, attestationsAndSigners, committee);
997
+ return this.rollupContract.buildInvalidateInsufficientAttestationsRequest(checkpoint.checkpointNumber, attestationsAndSigners, committee);
352
998
  } else {
353
999
  const _ = reason;
354
1000
  throw new Error(`Unknown reason for invalidation`);
355
1001
  }
356
1002
  }
357
- /**
358
- * @notice Will simulate `propose` to make sure that the block is valid for submission
359
- *
360
- * @dev Throws if unable to propose
361
- *
362
- * @param block - The block to propose
363
- * @param attestationData - The block's attestation data
364
- *
365
- */ async validateBlockForSubmission(block, attestationsAndSigners, attestationsAndSignersSignature, options) {
1003
+ /** Simulates `propose` to make sure that the checkpoint is valid for submission */ async validateCheckpointForSubmission(checkpoint, attestationsAndSigners, attestationsAndSignersSignature, options) {
366
1004
  const ts = BigInt((await this.l1TxUtils.getBlock()).timestamp + this.ethereumSlotDuration);
367
- // If we have no attestations, we still need to provide the empty attestations
368
- // so that the committee is recalculated correctly
369
- const ignoreSignatures = attestationsAndSigners.attestations.length === 0;
370
- if (ignoreSignatures) {
371
- const { committee } = await this.epochCache.getCommittee(block.header.globalVariables.slotNumber.toBigInt());
372
- if (!committee) {
373
- this.log.warn(`No committee found for slot ${block.header.globalVariables.slotNumber.toBigInt()}`);
374
- throw new Error(`No committee found for slot ${block.header.globalVariables.slotNumber.toBigInt()}`);
375
- }
376
- attestationsAndSigners.attestations = committee.map((committeeMember)=>CommitteeAttestation.fromAddress(committeeMember));
377
- }
378
- const blobFields = block.getCheckpointBlobFields();
379
- const blobs = getBlobsPerL1Block(blobFields);
1005
+ const blobFields = checkpoint.toBlobFields();
1006
+ const blobs = await getBlobsPerL1Block(blobFields);
380
1007
  const blobInput = getPrefixedEthBlobCommitments(blobs);
381
1008
  const args = [
382
1009
  {
383
- header: block.getCheckpointHeader().toViem(),
384
- archive: toHex(block.archive.root.toBuffer()),
385
- stateReference: block.header.state.toViem(),
1010
+ header: checkpoint.header.toViem(),
1011
+ archive: toHex(checkpoint.archive.root.toBuffer()),
386
1012
  oracleInput: {
387
- feeAssetPriceModifier: 0n
1013
+ feeAssetPriceModifier: checkpoint.feeAssetPriceModifier
388
1014
  }
389
1015
  },
390
1016
  attestationsAndSigners.getPackedAttestations(),
@@ -409,9 +1035,38 @@ export class SequencerPublisher {
409
1035
  }
410
1036
  const round = await base.computeRound(slotNumber);
411
1037
  const roundInfo = await base.getRoundInfo(this.rollupContract.address, round);
1038
+ if (roundInfo.quorumReached) {
1039
+ return false;
1040
+ }
412
1041
  if (roundInfo.lastSignalSlot >= slotNumber) {
413
1042
  return false;
414
1043
  }
1044
+ if (await this.isPayloadEmpty(payload)) {
1045
+ this.log.warn(`Skipping vote cast for payload with empty code`);
1046
+ return false;
1047
+ }
1048
+ // Check if payload was already submitted to governance
1049
+ const cacheKey = payload.toString();
1050
+ if (!this.payloadProposedCache.has(cacheKey)) {
1051
+ try {
1052
+ const l1StartBlock = await this.rollupContract.getL1StartBlock();
1053
+ const proposed = await retry(()=>base.hasPayloadBeenProposed(payload.toString(), l1StartBlock), 'Check if payload was proposed', makeBackoff([
1054
+ 0,
1055
+ 1,
1056
+ 2
1057
+ ]), this.log, true);
1058
+ if (proposed) {
1059
+ this.payloadProposedCache.add(cacheKey);
1060
+ }
1061
+ } catch (err) {
1062
+ this.log.warn(`Failed to check if payload ${payload} was proposed after retries, skipping signal`, err);
1063
+ return false;
1064
+ }
1065
+ }
1066
+ if (this.payloadProposedCache.has(cacheKey)) {
1067
+ this.log.info(`Payload ${payload} was already proposed to governance, stopping signals`);
1068
+ return false;
1069
+ }
415
1070
  const cachedLastVote = this.lastActions[signalType];
416
1071
  this.lastActions[signalType] = slotNumber;
417
1072
  const action = signalType;
@@ -422,15 +1077,41 @@ export class SequencerPublisher {
422
1077
  signer: this.l1TxUtils.client.account?.address,
423
1078
  lastValidL2Slot: slotNumber
424
1079
  });
1080
+ const l1BlockNumber = await this.l1TxUtils.getBlockNumber();
425
1081
  try {
426
1082
  await this.l1TxUtils.simulate(request, {
427
1083
  time: timestamp
428
- }, [], ErrorsAbi);
1084
+ }, [], mergeAbis([
1085
+ request.abi ?? [],
1086
+ ErrorsAbi
1087
+ ]));
429
1088
  this.log.debug(`Simulation for ${action} at slot ${slotNumber} succeeded`, {
430
1089
  request
431
1090
  });
432
1091
  } catch (err) {
433
- this.log.error(`Failed simulation for ${action} at slot ${slotNumber} (enqueuing the action anyway)`, err);
1092
+ const viemError = formatViemError(err);
1093
+ this.log.error(`Failed simulation for ${action} at slot ${slotNumber} (enqueuing the action anyway)`, viemError);
1094
+ this.backupFailedTx({
1095
+ id: keccak256(request.data),
1096
+ failureType: 'simulation',
1097
+ request: {
1098
+ to: request.to,
1099
+ data: request.data,
1100
+ value: request.value?.toString()
1101
+ },
1102
+ l1BlockNumber: l1BlockNumber.toString(),
1103
+ error: {
1104
+ message: viemError.message,
1105
+ name: viemError.name
1106
+ },
1107
+ context: {
1108
+ actions: [
1109
+ action
1110
+ ],
1111
+ slot: slotNumber,
1112
+ sender: this.getSenderAddress().toString()
1113
+ }
1114
+ });
434
1115
  // Yes, we enqueue the request anyway, in case there was a bug with the simulation itself
435
1116
  }
436
1117
  // TODO(palla/slash): All votes (governance and slashing) should txTimeoutAt at the end of the slot.
@@ -450,17 +1131,27 @@ export class SequencerPublisher {
450
1131
  payload: payload.toString()
451
1132
  };
452
1133
  if (!success) {
453
- this.log.error(`Signaling in [${action}] for ${payload} at slot ${slotNumber} in round ${round} failed`, logData);
1134
+ this.log.error(`Signaling in ${action} for ${payload} at slot ${slotNumber} in round ${round} failed`, logData);
454
1135
  this.lastActions[signalType] = cachedLastVote;
455
1136
  return false;
456
1137
  } else {
457
- this.log.info(`Signaling in [${action}] for ${payload} at slot ${slotNumber} in round ${round} succeeded`, logData);
1138
+ this.log.info(`Signaling in ${action} for ${payload} at slot ${slotNumber} in round ${round} succeeded`, logData);
458
1139
  return true;
459
1140
  }
460
1141
  }
461
1142
  });
462
1143
  return true;
463
1144
  }
1145
+ async isPayloadEmpty(payload) {
1146
+ const key = payload.toString();
1147
+ const cached = this.isPayloadEmptyCache.get(key);
1148
+ if (cached) {
1149
+ return cached;
1150
+ }
1151
+ const isEmpty = !await this.l1TxUtils.getCode(payload);
1152
+ this.isPayloadEmptyCache.set(key, isEmpty);
1153
+ return isEmpty;
1154
+ }
464
1155
  /**
465
1156
  * Enqueues a governance castSignal transaction to cast a signal for a given slot number.
466
1157
  * @param slotNumber - The slot number to cast a signal for.
@@ -556,23 +1247,17 @@ export class SequencerPublisher {
556
1247
  }
557
1248
  return true;
558
1249
  }
559
- /**
560
- * Proposes a L2 block on L1.
561
- *
562
- * @param block - L2 block to propose.
563
- * @returns True if the tx has been enqueued, throws otherwise. See #9315
564
- */ async enqueueProposeL2Block(block, attestationsAndSigners, attestationsAndSignersSignature, opts = {}) {
565
- const checkpointHeader = block.getCheckpointHeader();
566
- const blobFields = block.getCheckpointBlobFields();
567
- const blobs = getBlobsPerL1Block(blobFields);
1250
+ /** Simulates and enqueues a proposal for a checkpoint on L1 */ async enqueueProposeCheckpoint(checkpoint, attestationsAndSigners, attestationsAndSignersSignature, opts = {}) {
1251
+ const checkpointHeader = checkpoint.header;
1252
+ const blobFields = checkpoint.toBlobFields();
1253
+ const blobs = await getBlobsPerL1Block(blobFields);
568
1254
  const proposeTxArgs = {
569
1255
  header: checkpointHeader,
570
- archive: block.archive.root.toBuffer(),
571
- stateReference: block.header.state,
572
- body: block.body.toBuffer(),
1256
+ archive: checkpoint.archive.root.toBuffer(),
573
1257
  blobs,
574
1258
  attestationsAndSigners,
575
- attestationsAndSignersSignature
1259
+ attestationsAndSignersSignature,
1260
+ feeAssetPriceModifier: checkpoint.feeAssetPriceModifier
576
1261
  };
577
1262
  let ts;
578
1263
  try {
@@ -581,36 +1266,35 @@ export class SequencerPublisher {
581
1266
  // By simulation issue, I mean the fact that the block.timestamp is equal to the last block, not the next, which
582
1267
  // make time consistency checks break.
583
1268
  // TODO(palla): Check whether we're validating twice, once here and once within addProposeTx, since we call simulateProposeTx in both places.
584
- ts = await this.validateBlockForSubmission(block, attestationsAndSigners, attestationsAndSignersSignature, opts);
1269
+ ts = await this.validateCheckpointForSubmission(checkpoint, attestationsAndSigners, attestationsAndSignersSignature, opts);
585
1270
  } catch (err) {
586
- this.log.error(`Block validation failed. ${err instanceof Error ? err.message : 'No error message'}`, err, {
587
- ...block.getStats(),
588
- slotNumber: block.header.globalVariables.slotNumber.toBigInt(),
589
- forcePendingBlockNumber: opts.forcePendingBlockNumber
1271
+ this.log.error(`Checkpoint validation failed. ${err instanceof Error ? err.message : 'No error message'}`, err, {
1272
+ ...checkpoint.getStats(),
1273
+ slotNumber: checkpoint.header.slotNumber,
1274
+ forcePendingCheckpointNumber: opts.forcePendingCheckpointNumber
590
1275
  });
591
1276
  throw err;
592
1277
  }
593
- this.log.verbose(`Enqueuing block propose transaction`, {
594
- ...block.toBlockInfo(),
1278
+ this.log.verbose(`Enqueuing checkpoint propose transaction`, {
1279
+ ...checkpoint.toCheckpointInfo(),
595
1280
  ...opts
596
1281
  });
597
- await this.addProposeTx(block, proposeTxArgs, opts, ts);
598
- return true;
1282
+ await this.addProposeTx(checkpoint, proposeTxArgs, opts, ts);
599
1283
  }
600
- enqueueInvalidateBlock(request, opts = {}) {
1284
+ enqueueInvalidateCheckpoint(request, opts = {}) {
601
1285
  if (!request) {
602
1286
  return;
603
1287
  }
604
1288
  // We issued the simulation against the rollup contract, so we need to account for the overhead of the multicall3
605
1289
  const gasLimit = this.l1TxUtils.bumpGasLimit(BigInt(Math.ceil(Number(request.gasUsed) * 64 / 63)));
606
- const { gasUsed, blockNumber } = request;
1290
+ const { gasUsed, checkpointNumber } = request;
607
1291
  const logData = {
608
1292
  gasUsed,
609
- blockNumber,
1293
+ checkpointNumber,
610
1294
  gasLimit,
611
1295
  opts
612
1296
  };
613
- this.log.verbose(`Enqueuing invalidate block request`, logData);
1297
+ this.log.verbose(`Enqueuing invalidate checkpoint request`, logData);
614
1298
  this.addRequest({
615
1299
  action: `invalidate-by-${request.reason}`,
616
1300
  request: request.request,
@@ -618,16 +1302,16 @@ export class SequencerPublisher {
618
1302
  gasLimit,
619
1303
  txTimeoutAt: opts.txTimeoutAt
620
1304
  },
621
- lastValidL2Slot: this.getCurrentL2Slot() + 2n,
1305
+ lastValidL2Slot: SlotNumber(this.getCurrentL2Slot() + 2),
622
1306
  checkSuccess: (_req, result)=>{
623
- const success = result && result.receipt && result.receipt.status === 'success' && tryExtractEvent(result.receipt.logs, this.rollupContract.address, RollupAbi, 'BlockInvalidated');
1307
+ const success = result && result.receipt && result.receipt.status === 'success' && tryExtractEvent(result.receipt.logs, this.rollupContract.address, RollupAbi, 'CheckpointInvalidated');
624
1308
  if (!success) {
625
- this.log.warn(`Invalidate block ${request.blockNumber} failed`, {
1309
+ this.log.warn(`Invalidate checkpoint ${request.checkpointNumber} failed`, {
626
1310
  ...result,
627
1311
  ...logData
628
1312
  });
629
1313
  } else {
630
- this.log.info(`Invalidate block ${request.blockNumber} succeeded`, {
1314
+ this.log.info(`Invalidate checkpoint ${request.checkpointNumber} succeeded`, {
631
1315
  ...result,
632
1316
  ...logData
633
1317
  });
@@ -649,28 +1333,60 @@ export class SequencerPublisher {
649
1333
  const cachedLastActionSlot = this.lastActions[action];
650
1334
  this.lastActions[action] = slotNumber;
651
1335
  this.log.debug(`Simulating ${action} for slot ${slotNumber}`, logData);
1336
+ const l1BlockNumber = await this.l1TxUtils.getBlockNumber();
652
1337
  let gasUsed;
1338
+ const simulateAbi = mergeAbis([
1339
+ request.abi ?? [],
1340
+ ErrorsAbi
1341
+ ]);
653
1342
  try {
654
1343
  ({ gasUsed } = await this.l1TxUtils.simulate(request, {
655
1344
  time: timestamp
656
- }, [], ErrorsAbi)); // TODO(palla/slash): Check the timestamp logic
1345
+ }, [], simulateAbi)); // TODO(palla/slash): Check the timestamp logic
657
1346
  this.log.verbose(`Simulation for ${action} succeeded`, {
658
1347
  ...logData,
659
1348
  request,
660
1349
  gasUsed
661
1350
  });
662
1351
  } catch (err) {
663
- const viemError = formatViemError(err);
1352
+ const viemError = formatViemError(err, simulateAbi);
664
1353
  this.log.error(`Simulation for ${action} at ${slotNumber} failed`, viemError, logData);
1354
+ this.backupFailedTx({
1355
+ id: keccak256(request.data),
1356
+ failureType: 'simulation',
1357
+ request: {
1358
+ to: request.to,
1359
+ data: request.data,
1360
+ value: request.value?.toString()
1361
+ },
1362
+ l1BlockNumber: l1BlockNumber.toString(),
1363
+ error: {
1364
+ message: viemError.message,
1365
+ name: viemError.name
1366
+ },
1367
+ context: {
1368
+ actions: [
1369
+ action
1370
+ ],
1371
+ slot: slotNumber,
1372
+ sender: this.getSenderAddress().toString()
1373
+ }
1374
+ });
665
1375
  return false;
666
1376
  }
667
1377
  // We issued the simulation against the rollup contract, so we need to account for the overhead of the multicall3
668
1378
  const gasLimit = this.l1TxUtils.bumpGasLimit(BigInt(Math.ceil(Number(gasUsed) * 64 / 63)));
669
1379
  logData.gasLimit = gasLimit;
1380
+ // Store the ABI used for simulation on the request so Multicall3.forward can decode errors
1381
+ // when the tx is sent and a revert is diagnosed via simulation.
1382
+ const requestWithAbi = {
1383
+ ...request,
1384
+ abi: simulateAbi
1385
+ };
670
1386
  this.log.debug(`Enqueuing ${action}`, logData);
671
1387
  this.addRequest({
672
1388
  action,
673
- request,
1389
+ request: requestWithAbi,
674
1390
  gasConfig: {
675
1391
  gasLimit
676
1392
  },
@@ -713,34 +1429,70 @@ export class SequencerPublisher {
713
1429
  this.log.debug('Validating blob input', {
714
1430
  blobInput
715
1431
  });
716
- const blobEvaluationGas = await this.l1TxUtils.estimateGas(this.getSenderAddress().toString(), {
717
- to: this.rollupContract.address,
718
- data: encodeFunctionData({
719
- abi: RollupAbi,
720
- functionName: 'validateBlobs',
721
- args: [
722
- blobInput
723
- ]
724
- })
725
- }, {}, {
726
- blobs: encodedData.blobs.map((b)=>b.data),
727
- kzg
728
- }).catch((err)=>{
729
- const { message, metaMessages } = formatViemError(err);
730
- this.log.error(`Failed to validate blobs`, message, {
731
- metaMessages
1432
+ // Get blob evaluation gas
1433
+ let blobEvaluationGas;
1434
+ if (this.config.fishermanMode) {
1435
+ // In fisherman mode, we can't estimate blob gas because estimateGas doesn't support state overrides
1436
+ // Use a fixed estimate.
1437
+ blobEvaluationGas = BigInt(encodedData.blobs.length) * 21_000n;
1438
+ this.log.debug(`Using fixed blob evaluation gas estimate in fisherman mode: ${blobEvaluationGas}`);
1439
+ } else {
1440
+ // Normal mode - use estimateGas with blob inputs
1441
+ blobEvaluationGas = await this.l1TxUtils.estimateGas(this.getSenderAddress().toString(), {
1442
+ to: this.rollupContract.address,
1443
+ data: encodeFunctionData({
1444
+ abi: RollupAbi,
1445
+ functionName: 'validateBlobs',
1446
+ args: [
1447
+ blobInput
1448
+ ]
1449
+ })
1450
+ }, {}, {
1451
+ blobs: encodedData.blobs.map((b)=>b.data),
1452
+ kzg
1453
+ }).catch(async (err)=>{
1454
+ const viemError = formatViemError(err);
1455
+ this.log.error(`Failed to validate blobs`, viemError.message, {
1456
+ metaMessages: viemError.metaMessages
1457
+ });
1458
+ const validateBlobsData = encodeFunctionData({
1459
+ abi: RollupAbi,
1460
+ functionName: 'validateBlobs',
1461
+ args: [
1462
+ blobInput
1463
+ ]
1464
+ });
1465
+ const l1BlockNumber = await this.l1TxUtils.getBlockNumber();
1466
+ this.backupFailedTx({
1467
+ id: keccak256(validateBlobsData),
1468
+ failureType: 'simulation',
1469
+ request: {
1470
+ to: this.rollupContract.address,
1471
+ data: validateBlobsData
1472
+ },
1473
+ blobData: encodedData.blobs.map((b)=>toHex(b.data)),
1474
+ l1BlockNumber: l1BlockNumber.toString(),
1475
+ error: {
1476
+ message: viemError.message,
1477
+ name: viemError.name
1478
+ },
1479
+ context: {
1480
+ actions: [
1481
+ 'validate-blobs'
1482
+ ],
1483
+ sender: this.getSenderAddress().toString()
1484
+ }
1485
+ });
1486
+ throw new Error('Failed to validate blobs');
732
1487
  });
733
- throw new Error('Failed to validate blobs');
734
- });
1488
+ }
735
1489
  const signers = encodedData.attestationsAndSigners.getSigners().map((signer)=>signer.toString());
736
1490
  const args = [
737
1491
  {
738
1492
  header: encodedData.header.toViem(),
739
1493
  archive: toHex(encodedData.archive),
740
- stateReference: encodedData.stateReference.toViem(),
741
1494
  oracleInput: {
742
- // We are currently not modifying these. See #9963
743
- feeAssetPriceModifier: 0n
1495
+ feeAssetPriceModifier: encodedData.feeAssetPriceModifier
744
1496
  }
745
1497
  },
746
1498
  encodedData.attestationsAndSigners.getPackedAttestations(),
@@ -767,18 +1519,9 @@ export class SequencerPublisher {
767
1519
  functionName: 'propose',
768
1520
  args
769
1521
  });
770
- // override the pending block number if requested
771
- const forcePendingBlockNumberStateDiff = (options.forcePendingBlockNumber !== undefined ? await this.rollupContract.makePendingBlockNumberOverride(options.forcePendingBlockNumber) : []).flatMap((override)=>override.stateDiff ?? []);
772
- const simulationResult = await this.l1TxUtils.simulate({
773
- to: this.rollupContract.address,
774
- data: rollupData,
775
- gas: SequencerPublisher.PROPOSE_GAS_GUESS
776
- }, {
777
- // @note we add 1n to the timestamp because geth implementation doesn't like simulation timestamp to be equal to the current block timestamp
778
- time: timestamp + 1n,
779
- // @note reth should have a 30m gas limit per block but throws errors that this tx is beyond limit so we increase here
780
- gasLimit: SequencerPublisher.PROPOSE_GAS_GUESS * 2n
781
- }, [
1522
+ // override the pending checkpoint number if requested
1523
+ const forcePendingCheckpointNumberStateDiff = (options.forcePendingCheckpointNumber !== undefined ? await this.rollupContract.makePendingCheckpointNumberOverride(options.forcePendingCheckpointNumber) : []).flatMap((override)=>override.stateDiff ?? []);
1524
+ const stateOverrides = [
782
1525
  {
783
1526
  address: this.rollupContract.address,
784
1527
  // @note we override checkBlob to false since blobs are not part simulate()
@@ -787,14 +1530,65 @@ export class SequencerPublisher {
787
1530
  slot: toPaddedHex(RollupContract.checkBlobStorageSlot, true),
788
1531
  value: toPaddedHex(0n, true)
789
1532
  },
790
- ...forcePendingBlockNumberStateDiff
1533
+ ...forcePendingCheckpointNumberStateDiff
791
1534
  ]
792
1535
  }
793
- ], RollupAbi, {
1536
+ ];
1537
+ // In fisherman mode, simulate as the proposer but with sufficient balance
1538
+ if (this.proposerAddressForSimulation) {
1539
+ stateOverrides.push({
1540
+ address: this.proposerAddressForSimulation.toString(),
1541
+ balance: 10n * WEI_CONST * WEI_CONST
1542
+ });
1543
+ }
1544
+ const l1BlockNumber = await this.l1TxUtils.getBlockNumber();
1545
+ const simulationResult = await this.l1TxUtils.simulate({
1546
+ to: this.rollupContract.address,
1547
+ data: rollupData,
1548
+ gas: MAX_L1_TX_LIMIT,
1549
+ ...this.proposerAddressForSimulation && {
1550
+ from: this.proposerAddressForSimulation.toString()
1551
+ }
1552
+ }, {
1553
+ // @note we add 1n to the timestamp because geth implementation doesn't like simulation timestamp to be equal to the current block timestamp
1554
+ time: timestamp + 1n,
1555
+ // @note reth should have a 30m gas limit per block but throws errors that this tx is beyond limit so we increase here
1556
+ gasLimit: MAX_L1_TX_LIMIT * 2n
1557
+ }, stateOverrides, RollupAbi, {
794
1558
  // @note fallback gas estimate to use if the node doesn't support simulation API
795
- fallbackGasEstimate: SequencerPublisher.PROPOSE_GAS_GUESS
1559
+ fallbackGasEstimate: MAX_L1_TX_LIMIT
796
1560
  }).catch((err)=>{
797
- this.log.error(`Failed to simulate propose tx`, err);
1561
+ // In fisherman mode, we expect ValidatorSelection__MissingProposerSignature since fisherman doesn't have proposer signature
1562
+ const viemError = formatViemError(err);
1563
+ if (this.config.fishermanMode && viemError.message?.includes('ValidatorSelection__MissingProposerSignature')) {
1564
+ this.log.debug(`Ignoring expected ValidatorSelection__MissingProposerSignature error in fisherman mode`);
1565
+ // Return a minimal simulation result with the fallback gas estimate
1566
+ return {
1567
+ gasUsed: MAX_L1_TX_LIMIT,
1568
+ logs: []
1569
+ };
1570
+ }
1571
+ this.log.error(`Failed to simulate propose tx`, viemError);
1572
+ this.backupFailedTx({
1573
+ id: keccak256(rollupData),
1574
+ failureType: 'simulation',
1575
+ request: {
1576
+ to: this.rollupContract.address,
1577
+ data: rollupData
1578
+ },
1579
+ l1BlockNumber: l1BlockNumber.toString(),
1580
+ error: {
1581
+ message: viemError.message,
1582
+ name: viemError.name
1583
+ },
1584
+ context: {
1585
+ actions: [
1586
+ 'propose'
1587
+ ],
1588
+ slot: Number(args[0].header.slotNumber),
1589
+ sender: this.getSenderAddress().toString()
1590
+ }
1591
+ });
798
1592
  throw err;
799
1593
  });
800
1594
  return {
@@ -802,24 +1596,25 @@ export class SequencerPublisher {
802
1596
  simulationResult
803
1597
  };
804
1598
  }
805
- async addProposeTx(block, encodedData, opts = {}, timestamp) {
1599
+ async addProposeTx(checkpoint, encodedData, opts = {}, timestamp) {
1600
+ const slot = checkpoint.header.slotNumber;
806
1601
  const timer = new Timer();
807
1602
  const kzg = Blob.getViemKzgInstance();
808
1603
  const { rollupData, simulationResult, blobEvaluationGas } = await this.prepareProposeTx(encodedData, timestamp, opts);
809
1604
  const startBlock = await this.l1TxUtils.getBlockNumber();
810
1605
  const gasLimit = this.l1TxUtils.bumpGasLimit(BigInt(Math.ceil(Number(simulationResult.gasUsed) * 64 / 63)) + blobEvaluationGas + SequencerPublisher.MULTICALL_OVERHEAD_GAS_GUESS);
811
- // Send the blobs to the blob sink preemptively. This helps in tests where the sequencer mistakingly thinks that the propose
812
- // tx fails but it does get mined. We make sure that the blobs are sent to the blob sink regardless of the tx outcome.
813
- void this.blobSinkClient.sendBlobsToBlobSink(encodedData.blobs).catch((_err)=>{
814
- this.log.error('Failed to send blobs to blob sink');
815
- });
1606
+ // Send the blobs to the blob client preemptively. This helps in tests where the sequencer mistakingly thinks that the propose
1607
+ // tx fails but it does get mined. We make sure that the blobs are sent to the blob client regardless of the tx outcome.
1608
+ void Promise.resolve().then(()=>this.blobClient.sendBlobsToFilestore(encodedData.blobs).catch((_err)=>{
1609
+ this.log.error('Failed to send blobs to blob client');
1610
+ }));
816
1611
  return this.addRequest({
817
1612
  action: 'propose',
818
1613
  request: {
819
1614
  to: this.rollupContract.address,
820
1615
  data: rollupData
821
1616
  },
822
- lastValidL2Slot: block.header.globalVariables.slotNumber.toBigInt(),
1617
+ lastValidL2Slot: checkpoint.header.slotNumber,
823
1618
  gasConfig: {
824
1619
  ...opts,
825
1620
  gasLimit
@@ -833,7 +1628,7 @@ export class SequencerPublisher {
833
1628
  return false;
834
1629
  }
835
1630
  const { receipt, stats, errorMsg } = result;
836
- const success = receipt && receipt.status === 'success' && tryExtractEvent(receipt.logs, this.rollupContract.address, RollupAbi, 'L2BlockProposed');
1631
+ const success = receipt && receipt.status === 'success' && tryExtractEvent(receipt.logs, this.rollupContract.address, RollupAbi, 'CheckpointProposed');
837
1632
  if (success) {
838
1633
  const endBlock = receipt.blockNumber;
839
1634
  const inclusionBlocks = Number(endBlock - startBlock);
@@ -847,25 +1642,23 @@ export class SequencerPublisher {
847
1642
  calldataGas,
848
1643
  calldataSize,
849
1644
  sender,
850
- ...block.getStats(),
1645
+ ...checkpoint.getStats(),
851
1646
  eventName: 'rollup-published-to-l1',
852
1647
  blobCount: encodedData.blobs.length,
853
1648
  inclusionBlocks
854
1649
  };
855
- this.log.info(`Published L2 block to L1 rollup contract`, {
1650
+ this.log.info(`Published checkpoint ${checkpoint.number} at slot ${slot} to rollup contract`, {
856
1651
  ...stats,
857
- ...block.getStats(),
858
- ...receipt
1652
+ ...checkpoint.getStats(),
1653
+ ...pick(receipt, 'transactionHash', 'blockHash')
859
1654
  });
860
1655
  this.metrics.recordProcessBlockTx(timer.ms(), publishStats);
861
1656
  return true;
862
1657
  } else {
863
1658
  this.metrics.recordFailedTx('process');
864
- this.log.error(`Rollup process tx failed: ${errorMsg ?? 'no error message'}`, undefined, {
865
- ...block.getStats(),
866
- receipt,
867
- txHash: receipt.transactionHash,
868
- slotNumber: block.header.globalVariables.slotNumber.toBigInt()
1659
+ this.log.error(`Publishing checkpoint at slot ${slot} failed with ${errorMsg ?? 'no error message'}`, undefined, {
1660
+ ...checkpoint.getStats(),
1661
+ ...receipt
869
1662
  });
870
1663
  return false;
871
1664
  }