@aztec/ethereum 3.0.0-rc.5 → 4.0.0-nightly.20260107

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 (84) hide show
  1. package/dest/client.js +6 -2
  2. package/dest/config.d.ts +4 -1
  3. package/dest/config.d.ts.map +1 -1
  4. package/dest/config.js +6 -0
  5. package/dest/contracts/empire_base.d.ts +2 -1
  6. package/dest/contracts/empire_base.d.ts.map +1 -1
  7. package/dest/contracts/empire_slashing_proposer.d.ts +2 -1
  8. package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -1
  9. package/dest/contracts/empire_slashing_proposer.js +9 -0
  10. package/dest/contracts/governance_proposer.d.ts +2 -1
  11. package/dest/contracts/governance_proposer.d.ts.map +1 -1
  12. package/dest/contracts/governance_proposer.js +391 -8
  13. package/dest/contracts/inbox.d.ts +5 -1
  14. package/dest/contracts/inbox.d.ts.map +1 -1
  15. package/dest/contracts/inbox.js +4 -0
  16. package/dest/contracts/rollup.d.ts +125 -73
  17. package/dest/contracts/rollup.d.ts.map +1 -1
  18. package/dest/contracts/rollup.js +614 -125
  19. package/dest/deploy_aztec_l1_contracts.d.ts +3 -1
  20. package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
  21. package/dest/deploy_aztec_l1_contracts.js +7 -2
  22. package/dest/l1_artifacts.d.ts +3370 -104
  23. package/dest/l1_artifacts.d.ts.map +1 -1
  24. package/dest/l1_contract_addresses.d.ts +1 -1
  25. package/dest/l1_contract_addresses.d.ts.map +1 -1
  26. package/dest/l1_contract_addresses.js +3 -3
  27. package/dest/l1_tx_utils/constants.d.ts +7 -1
  28. package/dest/l1_tx_utils/constants.d.ts.map +1 -1
  29. package/dest/l1_tx_utils/constants.js +25 -0
  30. package/dest/l1_tx_utils/fee-strategies/index.d.ts +10 -0
  31. package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -0
  32. package/dest/l1_tx_utils/fee-strategies/index.js +12 -0
  33. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +8 -0
  34. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -0
  35. package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +129 -0
  36. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +23 -0
  37. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -0
  38. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +191 -0
  39. package/dest/l1_tx_utils/fee-strategies/types.d.ts +51 -0
  40. package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -0
  41. package/dest/l1_tx_utils/fee-strategies/types.js +3 -0
  42. package/dest/l1_tx_utils/index.d.ts +3 -1
  43. package/dest/l1_tx_utils/index.d.ts.map +1 -1
  44. package/dest/l1_tx_utils/index.js +2 -0
  45. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +233 -0
  46. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -0
  47. package/dest/l1_tx_utils/l1_fee_analyzer.js +506 -0
  48. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +4 -15
  49. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
  50. package/dest/l1_tx_utils/readonly_l1_tx_utils.js +34 -142
  51. package/dest/queries.d.ts +1 -1
  52. package/dest/queries.d.ts.map +1 -1
  53. package/dest/queries.js +8 -3
  54. package/dest/test/chain_monitor.js +1 -2
  55. package/dest/test/eth_cheat_codes.js +3 -1
  56. package/dest/test/rollup_cheat_codes.js +3 -1
  57. package/dest/test/tx_delayer.js +1 -1
  58. package/dest/utils.d.ts +14 -2
  59. package/dest/utils.d.ts.map +1 -1
  60. package/dest/utils.js +18 -0
  61. package/package.json +6 -5
  62. package/src/client.ts +2 -2
  63. package/src/config.ts +8 -0
  64. package/src/contracts/empire_base.ts +1 -1
  65. package/src/contracts/empire_slashing_proposer.ts +6 -1
  66. package/src/contracts/governance_proposer.ts +6 -1
  67. package/src/contracts/inbox.ts +5 -0
  68. package/src/contracts/rollup.ts +252 -84
  69. package/src/deploy_aztec_l1_contracts.ts +12 -2
  70. package/src/l1_contract_addresses.ts +22 -20
  71. package/src/l1_tx_utils/constants.ts +11 -0
  72. package/src/l1_tx_utils/fee-strategies/index.ts +22 -0
  73. package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +163 -0
  74. package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +245 -0
  75. package/src/l1_tx_utils/fee-strategies/types.ts +56 -0
  76. package/src/l1_tx_utils/index.ts +2 -0
  77. package/src/l1_tx_utils/l1_fee_analyzer.ts +803 -0
  78. package/src/l1_tx_utils/readonly_l1_tx_utils.ts +46 -184
  79. package/src/queries.ts +8 -2
  80. package/src/test/chain_monitor.ts +1 -1
  81. package/src/test/eth_cheat_codes.ts +1 -1
  82. package/src/test/rollup_cheat_codes.ts +1 -1
  83. package/src/test/tx_delayer.ts +1 -1
  84. package/src/utils.ts +29 -0
@@ -1,12 +1,382 @@
1
- function _ts_decorate(decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
1
+ function applyDecs2203RFactory() {
2
+ function createAddInitializerMethod(initializers, decoratorFinishedRef) {
3
+ return function addInitializer(initializer) {
4
+ assertNotFinished(decoratorFinishedRef, "addInitializer");
5
+ assertCallable(initializer, "An initializer");
6
+ initializers.push(initializer);
7
+ };
8
+ }
9
+ function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
10
+ var kindStr;
11
+ switch(kind){
12
+ case 1:
13
+ kindStr = "accessor";
14
+ break;
15
+ case 2:
16
+ kindStr = "method";
17
+ break;
18
+ case 3:
19
+ kindStr = "getter";
20
+ break;
21
+ case 4:
22
+ kindStr = "setter";
23
+ break;
24
+ default:
25
+ kindStr = "field";
26
+ }
27
+ var ctx = {
28
+ kind: kindStr,
29
+ name: isPrivate ? "#" + name : name,
30
+ static: isStatic,
31
+ private: isPrivate,
32
+ metadata: metadata
33
+ };
34
+ var decoratorFinishedRef = {
35
+ v: false
36
+ };
37
+ ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
38
+ var get, set;
39
+ if (kind === 0) {
40
+ if (isPrivate) {
41
+ get = desc.get;
42
+ set = desc.set;
43
+ } else {
44
+ get = function() {
45
+ return this[name];
46
+ };
47
+ set = function(v) {
48
+ this[name] = v;
49
+ };
50
+ }
51
+ } else if (kind === 2) {
52
+ get = function() {
53
+ return desc.value;
54
+ };
55
+ } else {
56
+ if (kind === 1 || kind === 3) {
57
+ get = function() {
58
+ return desc.get.call(this);
59
+ };
60
+ }
61
+ if (kind === 1 || kind === 4) {
62
+ set = function(v) {
63
+ desc.set.call(this, v);
64
+ };
65
+ }
66
+ }
67
+ ctx.access = get && set ? {
68
+ get: get,
69
+ set: set
70
+ } : get ? {
71
+ get: get
72
+ } : {
73
+ set: set
74
+ };
75
+ try {
76
+ return dec(value, ctx);
77
+ } finally{
78
+ decoratorFinishedRef.v = true;
79
+ }
80
+ }
81
+ function assertNotFinished(decoratorFinishedRef, fnName) {
82
+ if (decoratorFinishedRef.v) {
83
+ throw new Error("attempted to call " + fnName + " after decoration was finished");
84
+ }
85
+ }
86
+ function assertCallable(fn, hint) {
87
+ if (typeof fn !== "function") {
88
+ throw new TypeError(hint + " must be a function");
89
+ }
90
+ }
91
+ function assertValidReturnValue(kind, value) {
92
+ var type = typeof value;
93
+ if (kind === 1) {
94
+ if (type !== "object" || value === null) {
95
+ throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
96
+ }
97
+ if (value.get !== undefined) {
98
+ assertCallable(value.get, "accessor.get");
99
+ }
100
+ if (value.set !== undefined) {
101
+ assertCallable(value.set, "accessor.set");
102
+ }
103
+ if (value.init !== undefined) {
104
+ assertCallable(value.init, "accessor.init");
105
+ }
106
+ } else if (type !== "function") {
107
+ var hint;
108
+ if (kind === 0) {
109
+ hint = "field";
110
+ } else if (kind === 10) {
111
+ hint = "class";
112
+ } else {
113
+ hint = "method";
114
+ }
115
+ throw new TypeError(hint + " decorators must return a function or void 0");
116
+ }
117
+ }
118
+ function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
119
+ var decs = decInfo[0];
120
+ var desc, init, value;
121
+ if (isPrivate) {
122
+ if (kind === 0 || kind === 1) {
123
+ desc = {
124
+ get: decInfo[3],
125
+ set: decInfo[4]
126
+ };
127
+ } else if (kind === 3) {
128
+ desc = {
129
+ get: decInfo[3]
130
+ };
131
+ } else if (kind === 4) {
132
+ desc = {
133
+ set: decInfo[3]
134
+ };
135
+ } else {
136
+ desc = {
137
+ value: decInfo[3]
138
+ };
139
+ }
140
+ } else if (kind !== 0) {
141
+ desc = Object.getOwnPropertyDescriptor(base, name);
142
+ }
143
+ if (kind === 1) {
144
+ value = {
145
+ get: desc.get,
146
+ set: desc.set
147
+ };
148
+ } else if (kind === 2) {
149
+ value = desc.value;
150
+ } else if (kind === 3) {
151
+ value = desc.get;
152
+ } else if (kind === 4) {
153
+ value = desc.set;
154
+ }
155
+ var newValue, get, set;
156
+ if (typeof decs === "function") {
157
+ newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
158
+ if (newValue !== void 0) {
159
+ assertValidReturnValue(kind, newValue);
160
+ if (kind === 0) {
161
+ init = newValue;
162
+ } else if (kind === 1) {
163
+ init = newValue.init;
164
+ get = newValue.get || value.get;
165
+ set = newValue.set || value.set;
166
+ value = {
167
+ get: get,
168
+ set: set
169
+ };
170
+ } else {
171
+ value = newValue;
172
+ }
173
+ }
174
+ } else {
175
+ for(var i = decs.length - 1; i >= 0; i--){
176
+ var dec = decs[i];
177
+ newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
178
+ if (newValue !== void 0) {
179
+ assertValidReturnValue(kind, newValue);
180
+ var newInit;
181
+ if (kind === 0) {
182
+ newInit = newValue;
183
+ } else if (kind === 1) {
184
+ newInit = newValue.init;
185
+ get = newValue.get || value.get;
186
+ set = newValue.set || value.set;
187
+ value = {
188
+ get: get,
189
+ set: set
190
+ };
191
+ } else {
192
+ value = newValue;
193
+ }
194
+ if (newInit !== void 0) {
195
+ if (init === void 0) {
196
+ init = newInit;
197
+ } else if (typeof init === "function") {
198
+ init = [
199
+ init,
200
+ newInit
201
+ ];
202
+ } else {
203
+ init.push(newInit);
204
+ }
205
+ }
206
+ }
207
+ }
208
+ }
209
+ if (kind === 0 || kind === 1) {
210
+ if (init === void 0) {
211
+ init = function(instance, init) {
212
+ return init;
213
+ };
214
+ } else if (typeof init !== "function") {
215
+ var ownInitializers = init;
216
+ init = function(instance, init) {
217
+ var value = init;
218
+ for(var i = 0; i < ownInitializers.length; i++){
219
+ value = ownInitializers[i].call(instance, value);
220
+ }
221
+ return value;
222
+ };
223
+ } else {
224
+ var originalInitializer = init;
225
+ init = function(instance, init) {
226
+ return originalInitializer.call(instance, init);
227
+ };
228
+ }
229
+ ret.push(init);
230
+ }
231
+ if (kind !== 0) {
232
+ if (kind === 1) {
233
+ desc.get = value.get;
234
+ desc.set = value.set;
235
+ } else if (kind === 2) {
236
+ desc.value = value;
237
+ } else if (kind === 3) {
238
+ desc.get = value;
239
+ } else if (kind === 4) {
240
+ desc.set = value;
241
+ }
242
+ if (isPrivate) {
243
+ if (kind === 1) {
244
+ ret.push(function(instance, args) {
245
+ return value.get.call(instance, args);
246
+ });
247
+ ret.push(function(instance, args) {
248
+ return value.set.call(instance, args);
249
+ });
250
+ } else if (kind === 2) {
251
+ ret.push(value);
252
+ } else {
253
+ ret.push(function(instance, args) {
254
+ return value.call(instance, args);
255
+ });
256
+ }
257
+ } else {
258
+ Object.defineProperty(base, name, desc);
259
+ }
260
+ }
261
+ }
262
+ function applyMemberDecs(Class, decInfos, metadata) {
263
+ var ret = [];
264
+ var protoInitializers;
265
+ var staticInitializers;
266
+ var existingProtoNonFields = new Map();
267
+ var existingStaticNonFields = new Map();
268
+ for(var i = 0; i < decInfos.length; i++){
269
+ var decInfo = decInfos[i];
270
+ if (!Array.isArray(decInfo)) continue;
271
+ var kind = decInfo[1];
272
+ var name = decInfo[2];
273
+ var isPrivate = decInfo.length > 3;
274
+ var isStatic = kind >= 5;
275
+ var base;
276
+ var initializers;
277
+ if (isStatic) {
278
+ base = Class;
279
+ kind = kind - 5;
280
+ staticInitializers = staticInitializers || [];
281
+ initializers = staticInitializers;
282
+ } else {
283
+ base = Class.prototype;
284
+ protoInitializers = protoInitializers || [];
285
+ initializers = protoInitializers;
286
+ }
287
+ if (kind !== 0 && !isPrivate) {
288
+ var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
289
+ var existingKind = existingNonFields.get(name) || 0;
290
+ if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) {
291
+ throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
292
+ } else if (!existingKind && kind > 2) {
293
+ existingNonFields.set(name, kind);
294
+ } else {
295
+ existingNonFields.set(name, true);
296
+ }
297
+ }
298
+ applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
299
+ }
300
+ pushInitializers(ret, protoInitializers);
301
+ pushInitializers(ret, staticInitializers);
302
+ return ret;
303
+ }
304
+ function pushInitializers(ret, initializers) {
305
+ if (initializers) {
306
+ ret.push(function(instance) {
307
+ for(var i = 0; i < initializers.length; i++){
308
+ initializers[i].call(instance);
309
+ }
310
+ return instance;
311
+ });
312
+ }
313
+ }
314
+ function applyClassDecs(targetClass, classDecs, metadata) {
315
+ if (classDecs.length > 0) {
316
+ var initializers = [];
317
+ var newClass = targetClass;
318
+ var name = targetClass.name;
319
+ for(var i = classDecs.length - 1; i >= 0; i--){
320
+ var decoratorFinishedRef = {
321
+ v: false
322
+ };
323
+ try {
324
+ var nextNewClass = classDecs[i](newClass, {
325
+ kind: "class",
326
+ name: name,
327
+ addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
328
+ metadata
329
+ });
330
+ } finally{
331
+ decoratorFinishedRef.v = true;
332
+ }
333
+ if (nextNewClass !== undefined) {
334
+ assertValidReturnValue(10, nextNewClass);
335
+ newClass = nextNewClass;
336
+ }
337
+ }
338
+ return [
339
+ defineMetadata(newClass, metadata),
340
+ function() {
341
+ for(var i = 0; i < initializers.length; i++){
342
+ initializers[i].call(newClass);
343
+ }
344
+ }
345
+ ];
346
+ }
347
+ }
348
+ function defineMetadata(Class, metadata) {
349
+ return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
350
+ configurable: true,
351
+ enumerable: true,
352
+ value: metadata
353
+ });
354
+ }
355
+ return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
356
+ if (parentClass !== void 0) {
357
+ var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
358
+ }
359
+ var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
360
+ var e = applyMemberDecs(targetClass, memberDecs, metadata);
361
+ if (!classDecs.length) defineMetadata(targetClass, metadata);
362
+ return {
363
+ e: e,
364
+ get c () {
365
+ return applyClassDecs(targetClass, classDecs, metadata);
366
+ }
367
+ };
368
+ };
369
+ }
370
+ function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
371
+ return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
6
372
  }
373
+ var _initProto;
7
374
  import { CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
375
+ import { Buffer32 } from '@aztec/foundation/buffer';
376
+ import { Fr } from '@aztec/foundation/curves/bn254';
8
377
  import { memoize } from '@aztec/foundation/decorators';
9
378
  import { EthAddress } from '@aztec/foundation/eth-address';
379
+ import { makeBackoff, retry } from '@aztec/foundation/retry';
10
380
  import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
11
381
  import { RollupStorage } from '@aztec/l1-artifacts/RollupStorage';
12
382
  import chunk from 'lodash.chunk';
@@ -24,8 +394,117 @@ export var SlashingProposerType = /*#__PURE__*/ function(SlashingProposerType) {
24
394
  SlashingProposerType[SlashingProposerType["Empire"] = 2] = "Empire";
25
395
  return SlashingProposerType;
26
396
  }({});
397
+ /**
398
+ * Status of a validator/attester in the staking system.
399
+ * Matches the Status enum in StakingLib.sol
400
+ */ export var AttesterStatus = /*#__PURE__*/ function(AttesterStatus) {
401
+ AttesterStatus[AttesterStatus["NONE"] = 0] = "NONE";
402
+ AttesterStatus[AttesterStatus["VALIDATING"] = 1] = "VALIDATING";
403
+ AttesterStatus[AttesterStatus["ZOMBIE"] = 2] = "ZOMBIE";
404
+ AttesterStatus[AttesterStatus["EXITING"] = 3] = "EXITING";
405
+ return AttesterStatus;
406
+ }({});
27
407
  export class RollupContract {
28
408
  client;
409
+ static{
410
+ ({ e: [_initProto] } = _apply_decs_2203_r(this, [
411
+ [
412
+ memoize,
413
+ 2,
414
+ "getL1StartBlock"
415
+ ],
416
+ [
417
+ memoize,
418
+ 2,
419
+ "getL1GenesisTime"
420
+ ],
421
+ [
422
+ memoize,
423
+ 2,
424
+ "getProofSubmissionEpochs"
425
+ ],
426
+ [
427
+ memoize,
428
+ 2,
429
+ "getEpochDuration"
430
+ ],
431
+ [
432
+ memoize,
433
+ 2,
434
+ "getSlotDuration"
435
+ ],
436
+ [
437
+ memoize,
438
+ 2,
439
+ "getTargetCommitteeSize"
440
+ ],
441
+ [
442
+ memoize,
443
+ 2,
444
+ "getEjectionThreshold"
445
+ ],
446
+ [
447
+ memoize,
448
+ 2,
449
+ "getLocalEjectionThreshold"
450
+ ],
451
+ [
452
+ memoize,
453
+ 2,
454
+ "getLagInEpochsForValidatorSet"
455
+ ],
456
+ [
457
+ memoize,
458
+ 2,
459
+ "getLagInEpochsForRandao"
460
+ ],
461
+ [
462
+ memoize,
463
+ 2,
464
+ "getActivationThreshold"
465
+ ],
466
+ [
467
+ memoize,
468
+ 2,
469
+ "getExitDelay"
470
+ ],
471
+ [
472
+ memoize,
473
+ 2,
474
+ "getManaTarget"
475
+ ],
476
+ [
477
+ memoize,
478
+ 2,
479
+ "getProvingCostPerMana"
480
+ ],
481
+ [
482
+ memoize,
483
+ 2,
484
+ "getProvingCostPerManaInFeeAsset"
485
+ ],
486
+ [
487
+ memoize,
488
+ 2,
489
+ "getManaLimit"
490
+ ],
491
+ [
492
+ memoize,
493
+ 2,
494
+ "getVersion"
495
+ ],
496
+ [
497
+ memoize,
498
+ 2,
499
+ "getGenesisArchiveTreeRoot"
500
+ ],
501
+ [
502
+ memoize,
503
+ 2,
504
+ "getRollupConstants"
505
+ ]
506
+ ], []));
507
+ }
29
508
  rollup;
30
509
  static cachedStfStorageSlot;
31
510
  static get checkBlobStorageSlot() {
@@ -49,6 +528,7 @@ export class RollupContract {
49
528
  }
50
529
  constructor(client, address){
51
530
  this.client = client;
531
+ _initProto(this);
52
532
  if (address instanceof EthAddress) {
53
533
  address = address.toString();
54
534
  }
@@ -58,8 +538,8 @@ export class RollupContract {
58
538
  client
59
539
  });
60
540
  }
61
- getGSE() {
62
- return this.rollup.read.getGSE();
541
+ async getGSE() {
542
+ return EthAddress.fromString(await this.rollup.read.getGSE());
63
543
  }
64
544
  get address() {
65
545
  return this.rollup.address;
@@ -108,17 +588,17 @@ export class RollupContract {
108
588
  getL1GenesisTime() {
109
589
  return this.rollup.read.getGenesisTime();
110
590
  }
111
- getProofSubmissionEpochs() {
112
- return this.rollup.read.getProofSubmissionEpochs();
591
+ async getProofSubmissionEpochs() {
592
+ return Number(await this.rollup.read.getProofSubmissionEpochs());
113
593
  }
114
- getEpochDuration() {
115
- return this.rollup.read.getEpochDuration();
594
+ async getEpochDuration() {
595
+ return Number(await this.rollup.read.getEpochDuration());
116
596
  }
117
597
  async getSlotDuration() {
118
598
  return Number(await this.rollup.read.getSlotDuration());
119
599
  }
120
- getTargetCommitteeSize() {
121
- return this.rollup.read.getTargetCommitteeSize();
600
+ async getTargetCommitteeSize() {
601
+ return Number(await this.rollup.read.getTargetCommitteeSize());
122
602
  }
123
603
  getEjectionThreshold() {
124
604
  return this.rollup.read.getEjectionThreshold();
@@ -126,17 +606,17 @@ export class RollupContract {
126
606
  getLocalEjectionThreshold() {
127
607
  return this.rollup.read.getLocalEjectionThreshold();
128
608
  }
129
- getLagInEpochsForValidatorSet() {
130
- return this.rollup.read.getLagInEpochsForValidatorSet();
609
+ async getLagInEpochsForValidatorSet() {
610
+ return Number(await this.rollup.read.getLagInEpochsForValidatorSet());
131
611
  }
132
- getLagInEpochsForRandao() {
133
- return this.rollup.read.getLagInEpochsForRandao();
612
+ async getLagInEpochsForRandao() {
613
+ return Number(await this.rollup.read.getLagInEpochsForRandao());
134
614
  }
135
615
  getActivationThreshold() {
136
616
  return this.rollup.read.getActivationThreshold();
137
617
  }
138
- getExitDelay() {
139
- return this.rollup.read.getExitDelay();
618
+ async getExitDelay() {
619
+ return Number(await this.rollup.read.getExitDelay());
140
620
  }
141
621
  getManaTarget() {
142
622
  return this.rollup.read.getManaTarget();
@@ -154,9 +634,9 @@ export class RollupContract {
154
634
  return this.rollup.read.getVersion();
155
635
  }
156
636
  async getGenesisArchiveTreeRoot() {
157
- return await this.rollup.read.archiveAt([
637
+ return Fr.fromString(await this.rollup.read.archiveAt([
158
638
  0n
159
- ]);
639
+ ]));
160
640
  }
161
641
  /**
162
642
  * Returns rollup constants used for epoch queries.
@@ -178,23 +658,23 @@ export class RollupContract {
178
658
  proofSubmissionEpochs: Number(proofSubmissionEpochs)
179
659
  };
180
660
  }
181
- getSlasherAddress() {
182
- return this.rollup.read.getSlasher();
661
+ async getSlasherAddress() {
662
+ return EthAddress.fromString(await this.rollup.read.getSlasher());
183
663
  }
184
664
  /**
185
665
  * Returns a SlasherContract instance for interacting with the slasher contract.
186
666
  */ async getSlasherContract() {
187
- const slasherAddress = EthAddress.fromString(await this.getSlasherAddress());
667
+ const slasherAddress = await this.getSlasherAddress();
188
668
  if (slasherAddress.isZero()) {
189
669
  return undefined;
190
670
  }
191
671
  return new SlasherContract(this.client, slasherAddress);
192
672
  }
193
- getOwner() {
194
- return this.rollup.read.owner();
673
+ async getOwner() {
674
+ return EthAddress.fromString(await this.rollup.read.owner());
195
675
  }
196
- getActiveAttesterCount() {
197
- return this.rollup.read.getActiveAttesterCount();
676
+ async getActiveAttesterCount() {
677
+ return Number(await this.rollup.read.getActiveAttesterCount());
198
678
  }
199
679
  async getSlashingProposerAddress() {
200
680
  const slasher = await this.getSlasherContract();
@@ -215,10 +695,14 @@ export class RollupContract {
215
695
  async getSlotNumber() {
216
696
  return SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
217
697
  }
218
- getL1FeesAt(timestamp) {
219
- return this.rollup.read.getL1FeesAt([
698
+ async getL1FeesAt(timestamp) {
699
+ const result = await this.rollup.read.getL1FeesAt([
220
700
  timestamp
221
701
  ]);
702
+ return {
703
+ baseFee: result.baseFee,
704
+ blobFee: result.blobFee
705
+ };
222
706
  }
223
707
  getFeeAssetPerEth() {
224
708
  return this.rollup.read.getFeeAssetPerEth();
@@ -239,15 +723,15 @@ export class RollupContract {
239
723
  }
240
724
  throw e;
241
725
  });
242
- return result;
726
+ return result ? result.map((addr)=>EthAddress.fromString(addr)) : undefined;
243
727
  }
244
- getSampleSeedAt(timestamp) {
245
- return this.rollup.read.getSampleSeedAt([
728
+ async getSampleSeedAt(timestamp) {
729
+ return Buffer32.fromBigInt(await this.rollup.read.getSampleSeedAt([
246
730
  timestamp
247
- ]);
731
+ ]));
248
732
  }
249
- getCurrentSampleSeed() {
250
- return this.rollup.read.getCurrentSampleSeed();
733
+ async getCurrentSampleSeed() {
734
+ return Buffer32.fromBigInt(await this.rollup.read.getCurrentSampleSeed());
251
735
  }
252
736
  async getCurrentEpoch() {
253
737
  return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
@@ -266,7 +750,7 @@ export class RollupContract {
266
750
  }
267
751
  throw e;
268
752
  });
269
- return result;
753
+ return result ? result.map((addr)=>EthAddress.fromString(addr)) : undefined;
270
754
  }
271
755
  async getCurrentProposer() {
272
756
  const { result } = await this.client.simulateContract({
@@ -275,7 +759,7 @@ export class RollupContract {
275
759
  functionName: 'getCurrentProposer',
276
760
  args: []
277
761
  });
278
- return result;
762
+ return EthAddress.fromString(result);
279
763
  }
280
764
  async getProposerAt(timestamp) {
281
765
  const { result } = await this.client.simulateContract({
@@ -286,12 +770,40 @@ export class RollupContract {
286
770
  timestamp
287
771
  ]
288
772
  });
289
- return result;
773
+ return EthAddress.fromString(result);
290
774
  }
291
- getCheckpoint(checkpointNumber) {
292
- return this.rollup.read.getCheckpoint([
775
+ async getCheckpoint(checkpointNumber) {
776
+ const result = await this.rollup.read.getCheckpoint([
293
777
  BigInt(checkpointNumber)
294
778
  ]);
779
+ return {
780
+ archive: Fr.fromString(result.archive),
781
+ headerHash: Buffer32.fromString(result.headerHash),
782
+ blobCommitmentsHash: Buffer32.fromString(result.blobCommitmentsHash),
783
+ attestationsHash: Buffer32.fromString(result.attestationsHash),
784
+ payloadDigest: Buffer32.fromString(result.payloadDigest),
785
+ slotNumber: SlotNumber.fromBigInt(result.slotNumber),
786
+ feeHeader: {
787
+ excessMana: result.feeHeader.excessMana,
788
+ manaUsed: result.feeHeader.manaUsed,
789
+ feeAssetPriceNumerator: result.feeHeader.feeAssetPriceNumerator,
790
+ congestionCost: result.feeHeader.congestionCost,
791
+ proverCost: result.feeHeader.proverCost
792
+ }
793
+ };
794
+ }
795
+ /** Returns the pending checkpoint from the rollup contract */ getPendingCheckpoint() {
796
+ // We retry because of race conditions during prunes: we may get a pending checkpoint number which is immediately
797
+ // reorged out due to a prune happening, causing the subsequent getCheckpoint call to fail. So we try again in that case.
798
+ return retry(async ()=>{
799
+ const pendingCheckpointNumber = await this.getCheckpointNumber();
800
+ const pendingCheckpoint = await this.getCheckpoint(pendingCheckpointNumber);
801
+ return pendingCheckpoint;
802
+ }, 'getting pending checkpoint', makeBackoff([
803
+ 0.5,
804
+ 0.5,
805
+ 0.5
806
+ ]));
295
807
  }
296
808
  async getTips() {
297
809
  const { pending, proven } = await this.rollup.read.getTips();
@@ -305,11 +817,11 @@ export class RollupContract {
305
817
  BigInt(slot)
306
818
  ]);
307
819
  }
308
- getEntryQueueLength() {
309
- return this.rollup.read.getEntryQueueLength();
820
+ async getEntryQueueLength() {
821
+ return Number(await this.rollup.read.getEntryQueueLength());
310
822
  }
311
- getAvailableValidatorFlushes() {
312
- return this.rollup.read.getAvailableValidatorFlushes();
823
+ async getAvailableValidatorFlushes() {
824
+ return Number(await this.rollup.read.getAvailableValidatorFlushes());
313
825
  }
314
826
  async getNextFlushableEpoch() {
315
827
  return EpochNumber.fromBigInt(await this.rollup.read.getNextFlushableEpoch());
@@ -351,8 +863,9 @@ export class RollupContract {
351
863
  BigInt(slotNumber)
352
864
  ]));
353
865
  }
354
- getEpochProofPublicInputs(args) {
355
- return this.rollup.read.getEpochProofPublicInputs(args);
866
+ async getEpochProofPublicInputs(args) {
867
+ const result = await this.rollup.read.getEpochProofPublicInputs(args);
868
+ return result.map(Fr.fromString);
356
869
  }
357
870
  async validateHeader(args, account) {
358
871
  try {
@@ -481,9 +994,16 @@ export class RollupContract {
481
994
  }
482
995
  async status(checkpointNumber, options) {
483
996
  await checkBlockTag(options?.blockNumber, this.client);
484
- return this.rollup.read.status([
997
+ const result = await this.rollup.read.status([
485
998
  BigInt(checkpointNumber)
486
999
  ], options);
1000
+ return {
1001
+ provenCheckpointNumber: CheckpointNumber.fromBigInt(result[0]),
1002
+ provenArchive: Fr.fromString(result[1]),
1003
+ pendingCheckpointNumber: CheckpointNumber.fromBigInt(result[2]),
1004
+ pendingArchive: Fr.fromString(result[3]),
1005
+ archiveOfMyCheckpoint: Fr.fromString(result[4])
1006
+ };
487
1007
  }
488
1008
  async canPruneAtTime(timestamp, options) {
489
1009
  await checkBlockTag(options?.blockNumber, this.client);
@@ -491,13 +1011,13 @@ export class RollupContract {
491
1011
  timestamp
492
1012
  ], options);
493
1013
  }
494
- archive() {
495
- return this.rollup.read.archive();
1014
+ async archive() {
1015
+ return Fr.fromString(await this.rollup.read.archive());
496
1016
  }
497
- archiveAt(checkpointNumber) {
498
- return this.rollup.read.archiveAt([
1017
+ async archiveAt(checkpointNumber) {
1018
+ return Fr.fromString(await this.rollup.read.archiveAt([
499
1019
  BigInt(checkpointNumber)
500
- ]);
1020
+ ]));
501
1021
  }
502
1022
  getSequencerRewards(address) {
503
1023
  if (address instanceof EthAddress) {
@@ -521,40 +1041,66 @@ export class RollupContract {
521
1041
  const gse = new GSEContract(this.client, await this.getGSE());
522
1042
  const ts = (await this.client.getBlock()).timestamp;
523
1043
  const indices = Array.from({
524
- length: Number(attesterSize)
1044
+ length: attesterSize
525
1045
  }, (_, i)=>BigInt(i));
526
1046
  const chunks = chunk(indices, 1000);
527
- return (await Promise.all(chunks.map((chunk)=>gse.getAttestersFromIndicesAtTime(this.address, ts, chunk)))).flat();
1047
+ const results = await Promise.all(chunks.map((chunk)=>gse.getAttestersFromIndicesAtTime(this.address, ts, chunk)));
1048
+ return results.flat().map((addr)=>EthAddress.fromString(addr));
528
1049
  }
529
- getAttesterView(address) {
1050
+ async getAttesterView(address) {
530
1051
  if (address instanceof EthAddress) {
531
1052
  address = address.toString();
532
1053
  }
533
- return this.rollup.read.getAttesterView([
1054
+ const result = await this.rollup.read.getAttesterView([
534
1055
  address
535
1056
  ]);
1057
+ return {
1058
+ status: result.status,
1059
+ effectiveBalance: result.effectiveBalance,
1060
+ exit: {
1061
+ withdrawalId: result.exit.withdrawalId,
1062
+ amount: result.exit.amount,
1063
+ exitableAt: result.exit.exitableAt,
1064
+ recipientOrWithdrawer: EthAddress.fromString(result.exit.recipientOrWithdrawer),
1065
+ isRecipient: result.exit.isRecipient,
1066
+ exists: result.exit.exists
1067
+ },
1068
+ config: {
1069
+ publicKey: {
1070
+ x: result.config.publicKey.x,
1071
+ y: result.config.publicKey.y
1072
+ },
1073
+ withdrawer: EthAddress.fromString(result.config.withdrawer)
1074
+ }
1075
+ };
536
1076
  }
537
- getStatus(address) {
1077
+ async getStatus(address) {
538
1078
  if (address instanceof EthAddress) {
539
1079
  address = address.toString();
540
1080
  }
541
- return this.rollup.read.getStatus([
1081
+ return await this.rollup.read.getStatus([
542
1082
  address
543
1083
  ]);
544
1084
  }
545
- getBlobCommitmentsHash(checkpointNumber) {
546
- return this.rollup.read.getBlobCommitmentsHash([
1085
+ async getBlobCommitmentsHash(checkpointNumber) {
1086
+ return Buffer32.fromString(await this.rollup.read.getBlobCommitmentsHash([
547
1087
  BigInt(checkpointNumber)
548
- ]);
1088
+ ]));
549
1089
  }
550
- getCurrentBlobCommitmentsHash() {
551
- return this.rollup.read.getCurrentBlobCommitmentsHash();
1090
+ async getCurrentBlobCommitmentsHash() {
1091
+ return Buffer32.fromString(await this.rollup.read.getCurrentBlobCommitmentsHash());
552
1092
  }
553
- getStakingAsset() {
554
- return this.rollup.read.getStakingAsset();
1093
+ async getStakingAsset() {
1094
+ return EthAddress.fromString(await this.rollup.read.getStakingAsset());
555
1095
  }
556
- getRewardConfig() {
557
- return this.rollup.read.getRewardConfig();
1096
+ async getRewardConfig() {
1097
+ const result = await this.rollup.read.getRewardConfig();
1098
+ return {
1099
+ rewardDistributor: EthAddress.fromString(result.rewardDistributor),
1100
+ sequencerBps: BigInt(result.sequencerBps),
1101
+ booster: EthAddress.fromString(result.booster),
1102
+ checkpointReward: result.checkpointReward
1103
+ };
558
1104
  }
559
1105
  setupEpoch(l1TxUtils) {
560
1106
  return l1TxUtils.sendAndMonitorTransaction({
@@ -629,60 +1175,3 @@ export class RollupContract {
629
1175
  });
630
1176
  }
631
1177
  }
632
- _ts_decorate([
633
- memoize
634
- ], RollupContract.prototype, "getL1StartBlock", null);
635
- _ts_decorate([
636
- memoize
637
- ], RollupContract.prototype, "getL1GenesisTime", null);
638
- _ts_decorate([
639
- memoize
640
- ], RollupContract.prototype, "getProofSubmissionEpochs", null);
641
- _ts_decorate([
642
- memoize
643
- ], RollupContract.prototype, "getEpochDuration", null);
644
- _ts_decorate([
645
- memoize
646
- ], RollupContract.prototype, "getSlotDuration", null);
647
- _ts_decorate([
648
- memoize
649
- ], RollupContract.prototype, "getTargetCommitteeSize", null);
650
- _ts_decorate([
651
- memoize
652
- ], RollupContract.prototype, "getEjectionThreshold", null);
653
- _ts_decorate([
654
- memoize
655
- ], RollupContract.prototype, "getLocalEjectionThreshold", null);
656
- _ts_decorate([
657
- memoize
658
- ], RollupContract.prototype, "getLagInEpochsForValidatorSet", null);
659
- _ts_decorate([
660
- memoize
661
- ], RollupContract.prototype, "getLagInEpochsForRandao", null);
662
- _ts_decorate([
663
- memoize
664
- ], RollupContract.prototype, "getActivationThreshold", null);
665
- _ts_decorate([
666
- memoize
667
- ], RollupContract.prototype, "getExitDelay", null);
668
- _ts_decorate([
669
- memoize
670
- ], RollupContract.prototype, "getManaTarget", null);
671
- _ts_decorate([
672
- memoize
673
- ], RollupContract.prototype, "getProvingCostPerMana", null);
674
- _ts_decorate([
675
- memoize
676
- ], RollupContract.prototype, "getProvingCostPerManaInFeeAsset", null);
677
- _ts_decorate([
678
- memoize
679
- ], RollupContract.prototype, "getManaLimit", null);
680
- _ts_decorate([
681
- memoize
682
- ], RollupContract.prototype, "getVersion", null);
683
- _ts_decorate([
684
- memoize
685
- ], RollupContract.prototype, "getGenesisArchiveTreeRoot", null);
686
- _ts_decorate([
687
- memoize
688
- ], RollupContract.prototype, "getRollupConstants", null);