@aztec/ethereum 0.0.1-commit.6c91f13 → 0.0.1-commit.6d3c34e

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 (56) hide show
  1. package/dest/contracts/fee_asset_handler.d.ts +6 -5
  2. package/dest/contracts/fee_asset_handler.d.ts.map +1 -1
  3. package/dest/contracts/fee_asset_handler.js +9 -9
  4. package/dest/contracts/governance_proposer.js +382 -8
  5. package/dest/contracts/index.d.ts +2 -1
  6. package/dest/contracts/index.d.ts.map +1 -1
  7. package/dest/contracts/index.js +1 -0
  8. package/dest/contracts/outbox.d.ts +41 -0
  9. package/dest/contracts/outbox.d.ts.map +1 -0
  10. package/dest/contracts/outbox.js +86 -0
  11. package/dest/contracts/rollup.d.ts +128 -95
  12. package/dest/contracts/rollup.d.ts.map +1 -1
  13. package/dest/contracts/rollup.js +602 -127
  14. package/dest/deploy_aztec_l1_contracts.d.ts +10 -2
  15. package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
  16. package/dest/deploy_aztec_l1_contracts.js +60 -11
  17. package/dest/l1_artifacts.d.ts +3512 -1082
  18. package/dest/l1_artifacts.d.ts.map +1 -1
  19. package/dest/l1_tx_utils/fee-strategies/index.d.ts +3 -2
  20. package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -1
  21. package/dest/l1_tx_utils/fee-strategies/index.js +2 -1
  22. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +2 -12
  23. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -1
  24. package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +35 -17
  25. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +2 -11
  26. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -1
  27. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +36 -18
  28. package/dest/l1_tx_utils/fee-strategies/types.d.ts +14 -27
  29. package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -1
  30. package/dest/l1_tx_utils/fee-strategies/types.js +0 -21
  31. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +2 -2
  32. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -1
  33. package/dest/l1_tx_utils/l1_fee_analyzer.js +3 -3
  34. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +1 -5
  35. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
  36. package/dest/l1_tx_utils/readonly_l1_tx_utils.js +14 -51
  37. package/dest/queries.js +2 -2
  38. package/dest/test/chain_monitor.js +1 -2
  39. package/dest/test/rollup_cheat_codes.d.ts +2 -1
  40. package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
  41. package/dest/test/rollup_cheat_codes.js +9 -1
  42. package/package.json +5 -5
  43. package/src/contracts/fee_asset_handler.ts +8 -7
  44. package/src/contracts/index.ts +1 -0
  45. package/src/contracts/outbox.ts +98 -0
  46. package/src/contracts/rollup.ts +240 -92
  47. package/src/deploy_aztec_l1_contracts.ts +61 -13
  48. package/src/l1_tx_utils/fee-strategies/index.ts +1 -1
  49. package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +45 -41
  50. package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +48 -44
  51. package/src/l1_tx_utils/fee-strategies/types.ts +14 -46
  52. package/src/l1_tx_utils/l1_fee_analyzer.ts +2 -3
  53. package/src/l1_tx_utils/readonly_l1_tx_utils.ts +20 -59
  54. package/src/queries.ts +2 -2
  55. package/src/test/chain_monitor.ts +1 -1
  56. package/src/test/rollup_cheat_codes.ts +10 -1
@@ -0,0 +1,98 @@
1
+ import type { EpochNumber } from '@aztec/foundation/branded-types';
2
+ import { EthAddress } from '@aztec/foundation/eth-address';
3
+ import { OutboxAbi } from '@aztec/l1-artifacts/OutboxAbi';
4
+
5
+ import { type GetContractReturnType, type Hex, encodeAbiParameters, getContract, hexToBigInt, keccak256 } from 'viem';
6
+
7
+ import { getPublicClient } from '../client.js';
8
+ import type { DeployAztecL1ContractsReturnType } from '../deploy_aztec_l1_contracts.js';
9
+ import type { L1ReaderConfig } from '../l1_reader.js';
10
+ import { type ExtendedViemWalletClient, type ViemClient, isExtendedClient } from '../types.js';
11
+
12
+ export type ViemL1Actor = {
13
+ actor: Hex;
14
+ chainId: bigint;
15
+ };
16
+
17
+ export type ViemL2Actor = {
18
+ actor: Hex;
19
+ version: bigint;
20
+ };
21
+
22
+ export type ViemL2ToL1Msg = {
23
+ sender: ViemL2Actor;
24
+ recipient: ViemL1Actor;
25
+ content: Hex;
26
+ };
27
+
28
+ export class OutboxContract {
29
+ private readonly outbox: GetContractReturnType<typeof OutboxAbi, ViemClient>;
30
+
31
+ static getFromL1ContractsValues(deployL1ContractsValues: DeployAztecL1ContractsReturnType) {
32
+ const {
33
+ l1Client,
34
+ l1ContractAddresses: { outboxAddress },
35
+ } = deployL1ContractsValues;
36
+ return new OutboxContract(l1Client, outboxAddress.toString());
37
+ }
38
+
39
+ static getFromConfig(config: L1ReaderConfig) {
40
+ const client = getPublicClient(config);
41
+ const address = config.l1Contracts.outboxAddress.toString();
42
+ return new OutboxContract(client, address);
43
+ }
44
+
45
+ static getEpochRootStorageSlot(epoch: EpochNumber) {
46
+ return hexToBigInt(keccak256(encodeAbiParameters([{ type: 'uint256' }, { type: 'uint256' }], [BigInt(epoch), 0n])));
47
+ }
48
+
49
+ constructor(
50
+ public readonly client: ViemClient,
51
+ address: Hex | EthAddress,
52
+ ) {
53
+ if (address instanceof EthAddress) {
54
+ address = address.toString();
55
+ }
56
+ this.outbox = getContract({ address, abi: OutboxAbi, client });
57
+ }
58
+
59
+ public get address() {
60
+ return this.outbox.address;
61
+ }
62
+
63
+ public getContract(): GetContractReturnType<typeof OutboxAbi, ViemClient> {
64
+ return this.outbox;
65
+ }
66
+
67
+ public hasMessageBeenConsumedAtEpoch(epoch: EpochNumber, leafId: bigint) {
68
+ return this.outbox.read.hasMessageBeenConsumedAtEpoch([BigInt(epoch), leafId]);
69
+ }
70
+
71
+ public getRootData(epoch: EpochNumber) {
72
+ return this.outbox.read.getRootData([BigInt(epoch)]);
73
+ }
74
+
75
+ public consume(message: ViemL2ToL1Msg, epoch: EpochNumber, leafIndex: bigint, path: Hex[]) {
76
+ const wallet = this.assertWallet();
77
+ return wallet.write.consume([message, BigInt(epoch), leafIndex, path]);
78
+ }
79
+
80
+ public async getMessageConsumedEvents(
81
+ l1BlockHash: Hex,
82
+ ): Promise<{ epoch: bigint; root: Hex; messageHash: Hex; leafId: bigint }[]> {
83
+ const events = await this.outbox.getEvents.MessageConsumed({}, { blockHash: l1BlockHash, strict: true });
84
+ return events.map(event => ({
85
+ epoch: event.args.epoch!,
86
+ root: event.args.root!,
87
+ messageHash: event.args.messageHash!,
88
+ leafId: event.args.leafId!,
89
+ }));
90
+ }
91
+
92
+ private assertWallet(): GetContractReturnType<typeof OutboxAbi, ExtendedViemWalletClient> {
93
+ if (!isExtendedClient(this.client)) {
94
+ throw new Error('Wallet client is required for this operation');
95
+ }
96
+ return this.outbox as GetContractReturnType<typeof OutboxAbi, ExtendedViemWalletClient>;
97
+ }
98
+ }
@@ -1,4 +1,6 @@
1
1
  import { CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
2
+ import { Buffer32 } from '@aztec/foundation/buffer';
3
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
4
  import { memoize } from '@aztec/foundation/decorators';
3
5
  import { EthAddress } from '@aztec/foundation/eth-address';
4
6
  import type { ViemSignature } from '@aztec/foundation/eth-signature';
@@ -58,13 +60,15 @@ export type L1RollupContractAddresses = Pick<
58
60
  export type EpochProofPublicInputArgs = {
59
61
  previousArchive: `0x${string}`;
60
62
  endArchive: `0x${string}`;
63
+ outHash: `0x${string}`;
61
64
  proverId: `0x${string}`;
62
65
  };
63
66
 
64
67
  export type ViemHeader = {
65
68
  lastArchiveRoot: `0x${string}`;
66
69
  blockHeadersHash: `0x${string}`;
67
- contentCommitment: ViemContentCommitment;
70
+ blobsHash: `0x${string}`;
71
+ inHash: `0x${string}`;
68
72
  slotNumber: bigint;
69
73
  timestamp: bigint;
70
74
  coinbase: `0x${string}`;
@@ -73,12 +77,6 @@ export type ViemHeader = {
73
77
  totalManaUsed: bigint;
74
78
  };
75
79
 
76
- export type ViemContentCommitment = {
77
- blobsHash: `0x${string}`;
78
- inHash: `0x${string}`;
79
- outHash: `0x${string}`;
80
- };
81
-
82
80
  export type ViemGasFees = {
83
81
  feePerDaGas: bigint;
84
82
  feePerL2Gas: bigint;
@@ -90,6 +88,103 @@ export enum SlashingProposerType {
90
88
  Empire = 2,
91
89
  }
92
90
 
91
+ /**
92
+ * Status of a validator/attester in the staking system.
93
+ * Matches the Status enum in StakingLib.sol
94
+ */
95
+ export enum AttesterStatus {
96
+ NONE = 0,
97
+ VALIDATING = 1,
98
+ ZOMBIE = 2,
99
+ EXITING = 3,
100
+ }
101
+
102
+ /**
103
+ * Fee header data for a checkpoint
104
+ */
105
+ export type FeeHeader = {
106
+ excessMana: bigint;
107
+ manaUsed: bigint;
108
+ feeAssetPriceNumerator: bigint;
109
+ congestionCost: bigint;
110
+ proverCost: bigint;
111
+ };
112
+
113
+ /**
114
+ * Checkpoint log data returned from the rollup contract
115
+ */
116
+ export type CheckpointLog = {
117
+ archive: Fr;
118
+ headerHash: Buffer32;
119
+ blobCommitmentsHash: Buffer32;
120
+ attestationsHash: Buffer32;
121
+ payloadDigest: Buffer32;
122
+ slotNumber: SlotNumber;
123
+ feeHeader: FeeHeader;
124
+ };
125
+
126
+ /**
127
+ * L1 fee data (base fee and blob fee)
128
+ */
129
+ export type L1FeeData = {
130
+ baseFee: bigint;
131
+ blobFee: bigint;
132
+ };
133
+
134
+ /**
135
+ * Reward configuration for the rollup
136
+ */
137
+ export type RewardConfig = {
138
+ rewardDistributor: EthAddress;
139
+ sequencerBps: bigint;
140
+ booster: EthAddress;
141
+ checkpointReward: bigint;
142
+ };
143
+
144
+ /**
145
+ * Exit information for a validator
146
+ */
147
+ export type Exit = {
148
+ withdrawalId: bigint;
149
+ amount: bigint;
150
+ exitableAt: bigint;
151
+ recipientOrWithdrawer: EthAddress;
152
+ isRecipient: boolean;
153
+ exists: boolean;
154
+ };
155
+
156
+ /**
157
+ * Attester configuration including public key and withdrawer
158
+ */
159
+ export type AttesterConfig = {
160
+ publicKey: {
161
+ x: bigint;
162
+ y: bigint;
163
+ };
164
+ withdrawer: EthAddress;
165
+ };
166
+
167
+ /**
168
+ * Complete view of an attester's state
169
+ */
170
+ export type AttesterView = {
171
+ status: AttesterStatus;
172
+ effectiveBalance: bigint;
173
+ exit: Exit;
174
+ config: AttesterConfig;
175
+ };
176
+
177
+ /**
178
+ * Return for a status call
179
+ */
180
+ export type RollupStatusResponse = {
181
+ provenCheckpointNumber: CheckpointNumber;
182
+ provenArchive: Fr;
183
+ pendingCheckpointNumber: CheckpointNumber;
184
+ pendingArchive: Fr;
185
+ archiveOfMyCheckpoint: Fr;
186
+ };
187
+
93
188
  export class RollupContract {
94
189
  private readonly rollup: GetContractReturnType<typeof RollupAbi, ViemClient>;
95
190
 
@@ -131,8 +226,8 @@ export class RollupContract {
131
226
  this.rollup = getContract({ address, abi: RollupAbi, client });
132
227
  }
133
228
 
134
- getGSE() {
135
- return this.rollup.read.getGSE();
229
+ async getGSE(): Promise<EthAddress> {
230
+ return EthAddress.fromString(await this.rollup.read.getGSE());
136
231
  }
137
232
 
138
233
  public get address() {
@@ -174,23 +269,23 @@ export class RollupContract {
174
269
  }
175
270
 
176
271
  @memoize
177
- getL1StartBlock() {
272
+ getL1StartBlock(): Promise<bigint> {
178
273
  return this.rollup.read.L1_BLOCK_AT_GENESIS();
179
274
  }
180
275
 
181
276
  @memoize
182
- getL1GenesisTime() {
277
+ getL1GenesisTime(): Promise<bigint> {
183
278
  return this.rollup.read.getGenesisTime();
184
279
  }
185
280
 
186
281
  @memoize
187
- getProofSubmissionEpochs() {
188
- return this.rollup.read.getProofSubmissionEpochs();
282
+ async getProofSubmissionEpochs(): Promise<number> {
283
+ return Number(await this.rollup.read.getProofSubmissionEpochs());
189
284
  }
190
285
 
191
286
  @memoize
192
- getEpochDuration() {
193
- return this.rollup.read.getEpochDuration();
287
+ async getEpochDuration(): Promise<number> {
288
+ return Number(await this.rollup.read.getEpochDuration());
194
289
  }
195
290
 
196
291
  @memoize
@@ -199,68 +294,68 @@ export class RollupContract {
199
294
  }
200
295
 
201
296
  @memoize
202
- getTargetCommitteeSize() {
203
- return this.rollup.read.getTargetCommitteeSize();
297
+ async getTargetCommitteeSize(): Promise<number> {
298
+ return Number(await this.rollup.read.getTargetCommitteeSize());
204
299
  }
205
300
 
206
301
  @memoize
207
- getEjectionThreshold() {
302
+ getEjectionThreshold(): Promise<bigint> {
208
303
  return this.rollup.read.getEjectionThreshold();
209
304
  }
210
305
 
211
306
  @memoize
212
- getLocalEjectionThreshold() {
307
+ getLocalEjectionThreshold(): Promise<bigint> {
213
308
  return this.rollup.read.getLocalEjectionThreshold();
214
309
  }
215
310
 
216
311
  @memoize
217
- getLagInEpochsForValidatorSet() {
218
- return this.rollup.read.getLagInEpochsForValidatorSet();
312
+ async getLagInEpochsForValidatorSet(): Promise<number> {
313
+ return Number(await this.rollup.read.getLagInEpochsForValidatorSet());
219
314
  }
220
315
 
221
316
  @memoize
222
- getLagInEpochsForRandao() {
223
- return this.rollup.read.getLagInEpochsForRandao();
317
+ async getLagInEpochsForRandao(): Promise<number> {
318
+ return Number(await this.rollup.read.getLagInEpochsForRandao());
224
319
  }
225
320
 
226
321
  @memoize
227
- getActivationThreshold() {
322
+ getActivationThreshold(): Promise<bigint> {
228
323
  return this.rollup.read.getActivationThreshold();
229
324
  }
230
325
 
231
326
  @memoize
232
- getExitDelay() {
233
- return this.rollup.read.getExitDelay();
327
+ async getExitDelay(): Promise<number> {
328
+ return Number(await this.rollup.read.getExitDelay());
234
329
  }
235
330
 
236
331
  @memoize
237
- getManaTarget() {
332
+ getManaTarget(): Promise<bigint> {
238
333
  return this.rollup.read.getManaTarget();
239
334
  }
240
335
 
241
336
  @memoize
242
- getProvingCostPerMana() {
337
+ getProvingCostPerMana(): Promise<bigint> {
243
338
  return this.rollup.read.getProvingCostPerManaInEth();
244
339
  }
245
340
 
246
341
  @memoize
247
- getProvingCostPerManaInFeeAsset() {
342
+ getProvingCostPerManaInFeeAsset(): Promise<bigint> {
248
343
  return this.rollup.read.getProvingCostPerManaInFeeAsset();
249
344
  }
250
345
 
251
346
  @memoize
252
- getManaLimit() {
347
+ getManaLimit(): Promise<bigint> {
253
348
  return this.rollup.read.getManaLimit();
254
349
  }
255
350
 
256
351
  @memoize
257
- getVersion() {
352
+ getVersion(): Promise<bigint> {
258
353
  return this.rollup.read.getVersion();
259
354
  }
260
355
 
261
356
  @memoize
262
- async getGenesisArchiveTreeRoot(): Promise<`0x${string}`> {
263
- return await this.rollup.read.archiveAt([0n]);
357
+ async getGenesisArchiveTreeRoot(): Promise<Fr> {
358
+ return Fr.fromString(await this.rollup.read.archiveAt([0n]));
264
359
  }
265
360
 
266
361
  /**
@@ -292,27 +387,27 @@ export class RollupContract {
292
387
  };
293
388
  }
294
389
 
295
- getSlasherAddress() {
296
- return this.rollup.read.getSlasher();
390
+ async getSlasherAddress(): Promise<EthAddress> {
391
+ return EthAddress.fromString(await this.rollup.read.getSlasher());
297
392
  }
298
393
 
299
394
  /**
300
395
  * Returns a SlasherContract instance for interacting with the slasher contract.
301
396
  */
302
397
  async getSlasherContract(): Promise<SlasherContract | undefined> {
303
- const slasherAddress = EthAddress.fromString(await this.getSlasherAddress());
398
+ const slasherAddress = await this.getSlasherAddress();
304
399
  if (slasherAddress.isZero()) {
305
400
  return undefined;
306
401
  }
307
402
  return new SlasherContract(this.client, slasherAddress);
308
403
  }
309
404
 
310
- getOwner() {
311
- return this.rollup.read.owner();
405
+ async getOwner(): Promise<EthAddress> {
406
+ return EthAddress.fromString(await this.rollup.read.owner());
312
407
  }
313
408
 
314
- getActiveAttesterCount() {
315
- return this.rollup.read.getActiveAttesterCount();
409
+ async getActiveAttesterCount(): Promise<number> {
410
+ return Number(await this.rollup.read.getActiveAttesterCount());
316
411
  }
317
412
 
318
413
  public async getSlashingProposerAddress() {
@@ -323,7 +418,7 @@ export class RollupContract {
323
418
  return await slasher.getProposer();
324
419
  }
325
420
 
326
- getCheckpointReward() {
421
+ getCheckpointReward(): Promise<bigint> {
327
422
  return this.rollup.read.getCheckpointReward();
328
423
  }
329
424
 
@@ -339,15 +434,19 @@ export class RollupContract {
339
434
  return SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
340
435
  }
341
436
 
342
- getL1FeesAt(timestamp: bigint) {
343
- return this.rollup.read.getL1FeesAt([timestamp]);
437
+ async getL1FeesAt(timestamp: bigint): Promise<L1FeeData> {
438
+ const result = await this.rollup.read.getL1FeesAt([timestamp]);
439
+ return {
440
+ baseFee: result.baseFee,
441
+ blobFee: result.blobFee,
442
+ };
344
443
  }
345
444
 
346
- getFeeAssetPerEth() {
445
+ getFeeAssetPerEth(): Promise<bigint> {
347
446
  return this.rollup.read.getFeeAssetPerEth();
348
447
  }
349
448
 
350
- async getCommitteeAt(timestamp: bigint): Promise<readonly `0x${string}`[] | undefined> {
449
+ async getCommitteeAt(timestamp: bigint): Promise<EthAddress[] | undefined> {
351
450
  const { result } = await this.client
352
451
  .simulateContract({
353
452
  address: this.address,
@@ -362,22 +461,22 @@ export class RollupContract {
362
461
  throw e;
363
462
  });
364
463
 
365
- return result;
464
+ return result ? result.map(addr => EthAddress.fromString(addr)) : undefined;
366
465
  }
367
466
 
368
- getSampleSeedAt(timestamp: bigint) {
369
- return this.rollup.read.getSampleSeedAt([timestamp]);
467
+ async getSampleSeedAt(timestamp: bigint): Promise<Buffer32> {
468
+ return Buffer32.fromBigInt(await this.rollup.read.getSampleSeedAt([timestamp]));
370
469
  }
371
470
 
372
- getCurrentSampleSeed() {
373
- return this.rollup.read.getCurrentSampleSeed();
471
+ async getCurrentSampleSeed(): Promise<Buffer32> {
472
+ return Buffer32.fromBigInt(await this.rollup.read.getCurrentSampleSeed());
374
473
  }
375
474
 
376
475
  async getCurrentEpoch(): Promise<EpochNumber> {
377
476
  return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
378
477
  }
379
478
 
380
- async getCurrentEpochCommittee(): Promise<readonly `0x${string}`[] | undefined> {
479
+ async getCurrentEpochCommittee(): Promise<EthAddress[] | undefined> {
381
480
  const { result } = await this.client
382
481
  .simulateContract({
383
482
  address: this.address,
@@ -392,10 +491,10 @@ export class RollupContract {
392
491
  throw e;
393
492
  });
394
493
 
395
- return result;
494
+ return result ? result.map(addr => EthAddress.fromString(addr)) : undefined;
396
495
  }
397
496
 
398
- async getCurrentProposer() {
497
+ async getCurrentProposer(): Promise<EthAddress> {
399
498
  const { result } = await this.client.simulateContract({
400
499
  address: this.address,
401
500
  abi: RollupAbi,
@@ -403,10 +502,10 @@ export class RollupContract {
403
502
  args: [],
404
503
  });
405
504
 
406
- return result;
505
+ return EthAddress.fromString(result);
407
506
  }
408
507
 
409
- async getProposerAt(timestamp: bigint) {
508
+ async getProposerAt(timestamp: bigint): Promise<EthAddress> {
410
509
  const { result } = await this.client.simulateContract({
411
510
  address: this.address,
412
511
  abi: RollupAbi,
@@ -414,11 +513,26 @@ export class RollupContract {
414
513
  args: [timestamp],
415
514
  });
416
515
 
417
- return result;
516
+ return EthAddress.fromString(result);
418
517
  }
419
518
 
420
- getCheckpoint(checkpointNumber: CheckpointNumber) {
421
- return this.rollup.read.getCheckpoint([BigInt(checkpointNumber)]);
519
+ async getCheckpoint(checkpointNumber: CheckpointNumber): Promise<CheckpointLog> {
520
+ const result = await this.rollup.read.getCheckpoint([BigInt(checkpointNumber)]);
521
+ return {
522
+ archive: Fr.fromString(result.archive),
523
+ headerHash: Buffer32.fromString(result.headerHash),
524
+ blobCommitmentsHash: Buffer32.fromString(result.blobCommitmentsHash),
525
+ attestationsHash: Buffer32.fromString(result.attestationsHash),
526
+ payloadDigest: Buffer32.fromString(result.payloadDigest),
527
+ slotNumber: SlotNumber.fromBigInt(result.slotNumber),
528
+ feeHeader: {
529
+ excessMana: result.feeHeader.excessMana,
530
+ manaUsed: result.feeHeader.manaUsed,
531
+ feeAssetPriceNumerator: result.feeHeader.feeAssetPriceNumerator,
532
+ congestionCost: result.feeHeader.congestionCost,
533
+ proverCost: result.feeHeader.proverCost,
534
+ },
535
+ };
422
536
  }
423
537
 
424
538
  /** Returns the pending checkpoint from the rollup contract */
@@ -444,16 +558,16 @@ export class RollupContract {
444
558
  };
445
559
  }
446
560
 
447
- getTimestampForSlot(slot: SlotNumber) {
561
+ getTimestampForSlot(slot: SlotNumber): Promise<bigint> {
448
562
  return this.rollup.read.getTimestampForSlot([BigInt(slot)]);
449
563
  }
450
564
 
451
- getEntryQueueLength() {
452
- return this.rollup.read.getEntryQueueLength();
565
+ async getEntryQueueLength(): Promise<number> {
566
+ return Number(await this.rollup.read.getEntryQueueLength());
453
567
  }
454
568
 
455
- getAvailableValidatorFlushes() {
456
- return this.rollup.read.getAvailableValidatorFlushes();
569
+ async getAvailableValidatorFlushes(): Promise<number> {
570
+ return Number(await this.rollup.read.getAvailableValidatorFlushes());
457
571
  }
458
572
 
459
573
  async getNextFlushableEpoch(): Promise<EpochNumber> {
@@ -509,10 +623,11 @@ export class RollupContract {
509
623
  return EpochNumber.fromBigInt(await this.rollup.read.getEpochAtSlot([BigInt(slotNumber)]));
510
624
  }
511
625
 
512
- getEpochProofPublicInputs(
626
+ async getEpochProofPublicInputs(
513
627
  args: readonly [bigint, bigint, EpochProofPublicInputArgs, readonly `0x${string}`[], `0x${string}`],
514
- ) {
515
- return this.rollup.read.getEpochProofPublicInputs(args);
628
+ ): Promise<Fr[]> {
629
+ const result = await this.rollup.read.getEpochProofPublicInputs(args);
630
+ return result.map(Fr.fromString);
516
631
  }
517
632
 
518
633
  public async validateHeader(
@@ -654,85 +769,118 @@ export class RollupContract {
654
769
  return this.rollup.read.getHasSubmitted([BigInt(epochNumber), BigInt(numberOfCheckpointsInEpoch), prover]);
655
770
  }
656
771
 
657
- getManaBaseFeeAt(timestamp: bigint, inFeeAsset: boolean) {
658
- return this.rollup.read.getManaBaseFeeAt([timestamp, inFeeAsset]);
772
+ getManaMinFeeAt(timestamp: bigint, inFeeAsset: boolean): Promise<bigint> {
773
+ return this.rollup.read.getManaMinFeeAt([timestamp, inFeeAsset]);
659
774
  }
660
775
 
661
776
  async getSlotAt(timestamp: bigint): Promise<SlotNumber> {
662
777
  return SlotNumber.fromBigInt(await this.rollup.read.getSlotAt([timestamp]));
663
778
  }
664
779
 
665
- async status(checkpointNumber: CheckpointNumber, options?: { blockNumber?: bigint }) {
780
+ async status(checkpointNumber: CheckpointNumber, options?: { blockNumber?: bigint }): Promise<RollupStatusResponse> {
666
781
  await checkBlockTag(options?.blockNumber, this.client);
667
- return this.rollup.read.status([BigInt(checkpointNumber)], options);
782
+ const result = await this.rollup.read.status([BigInt(checkpointNumber)], options);
783
+ return {
784
+ provenCheckpointNumber: CheckpointNumber.fromBigInt(result[0]),
785
+ provenArchive: Fr.fromString(result[1]),
786
+ pendingCheckpointNumber: CheckpointNumber.fromBigInt(result[2]),
787
+ pendingArchive: Fr.fromString(result[3]),
788
+ archiveOfMyCheckpoint: Fr.fromString(result[4]),
789
+ };
668
790
  }
669
791
 
670
- async canPruneAtTime(timestamp: bigint, options?: { blockNumber?: bigint }) {
792
+ async canPruneAtTime(timestamp: bigint, options?: { blockNumber?: bigint }): Promise<boolean> {
671
793
  await checkBlockTag(options?.blockNumber, this.client);
672
794
  return this.rollup.read.canPruneAtTime([timestamp], options);
673
795
  }
674
796
 
675
- archive() {
676
- return this.rollup.read.archive();
797
+ async archive(): Promise<Fr> {
798
+ return Fr.fromString(await this.rollup.read.archive());
677
799
  }
678
800
 
679
- archiveAt(checkpointNumber: CheckpointNumber) {
680
- return this.rollup.read.archiveAt([BigInt(checkpointNumber)]);
801
+ async archiveAt(checkpointNumber: CheckpointNumber): Promise<Fr> {
802
+ return Fr.fromString(await this.rollup.read.archiveAt([BigInt(checkpointNumber)]));
681
803
  }
682
804
 
683
- getSequencerRewards(address: Hex | EthAddress) {
805
+ getSequencerRewards(address: Hex | EthAddress): Promise<bigint> {
684
806
  if (address instanceof EthAddress) {
685
807
  address = address.toString();
686
808
  }
687
809
  return this.rollup.read.getSequencerRewards([address]);
688
810
  }
689
811
 
690
- getSpecificProverRewardsForEpoch(epoch: bigint, prover: Hex | EthAddress) {
812
+ getSpecificProverRewardsForEpoch(epoch: bigint, prover: Hex | EthAddress): Promise<bigint> {
691
813
  if (prover instanceof EthAddress) {
692
814
  prover = prover.toString();
693
815
  }
694
816
  return this.rollup.read.getSpecificProverRewardsForEpoch([epoch, prover]);
695
817
  }
696
818
 
697
- async getAttesters() {
819
+ async getAttesters(): Promise<EthAddress[]> {
698
820
  const attesterSize = await this.getActiveAttesterCount();
699
821
  const gse = new GSEContract(this.client, await this.getGSE());
700
822
  const ts = (await this.client.getBlock()).timestamp;
701
823
 
702
- const indices = Array.from({ length: Number(attesterSize) }, (_, i) => BigInt(i));
824
+ const indices = Array.from({ length: attesterSize }, (_, i) => BigInt(i));
703
825
  const chunks = chunk(indices, 1000);
704
826
 
705
- return (await Promise.all(chunks.map(chunk => gse.getAttestersFromIndicesAtTime(this.address, ts, chunk)))).flat();
827
+ const results = await Promise.all(chunks.map(chunk => gse.getAttestersFromIndicesAtTime(this.address, ts, chunk)));
828
+ return results.flat().map(addr => EthAddress.fromString(addr));
706
829
  }
707
830
 
708
- getAttesterView(address: Hex | EthAddress) {
831
+ async getAttesterView(address: Hex | EthAddress): Promise<AttesterView> {
709
832
  if (address instanceof EthAddress) {
710
833
  address = address.toString();
711
834
  }
712
- return this.rollup.read.getAttesterView([address]);
835
+ const result = await this.rollup.read.getAttesterView([address]);
836
+ return {
837
+ status: result.status as AttesterStatus,
838
+ effectiveBalance: result.effectiveBalance,
839
+ exit: {
840
+ withdrawalId: result.exit.withdrawalId,
841
+ amount: result.exit.amount,
842
+ exitableAt: result.exit.exitableAt,
843
+ recipientOrWithdrawer: EthAddress.fromString(result.exit.recipientOrWithdrawer),
844
+ isRecipient: result.exit.isRecipient,
845
+ exists: result.exit.exists,
846
+ },
847
+ config: {
848
+ publicKey: {
849
+ x: result.config.publicKey.x,
850
+ y: result.config.publicKey.y,
851
+ },
852
+ withdrawer: EthAddress.fromString(result.config.withdrawer),
853
+ },
854
+ };
713
855
  }
714
856
 
715
- getStatus(address: Hex | EthAddress) {
857
+ async getStatus(address: Hex | EthAddress): Promise<AttesterStatus> {
716
858
  if (address instanceof EthAddress) {
717
859
  address = address.toString();
718
860
  }
719
- return this.rollup.read.getStatus([address]);
861
+ return (await this.rollup.read.getStatus([address])) as AttesterStatus;
720
862
  }
721
863
 
722
- getBlobCommitmentsHash(checkpointNumber: CheckpointNumber) {
723
- return this.rollup.read.getBlobCommitmentsHash([BigInt(checkpointNumber)]);
864
+ async getBlobCommitmentsHash(checkpointNumber: CheckpointNumber): Promise<Buffer32> {
865
+ return Buffer32.fromString(await this.rollup.read.getBlobCommitmentsHash([BigInt(checkpointNumber)]));
724
866
  }
725
867
 
726
- getCurrentBlobCommitmentsHash() {
727
- return this.rollup.read.getCurrentBlobCommitmentsHash();
868
+ async getCurrentBlobCommitmentsHash(): Promise<Buffer32> {
869
+ return Buffer32.fromString(await this.rollup.read.getCurrentBlobCommitmentsHash());
728
870
  }
729
871
 
730
- getStakingAsset() {
731
- return this.rollup.read.getStakingAsset();
872
+ async getStakingAsset(): Promise<EthAddress> {
873
+ return EthAddress.fromString(await this.rollup.read.getStakingAsset());
732
874
  }
733
875
 
734
- getRewardConfig() {
735
- return this.rollup.read.getRewardConfig();
876
+ async getRewardConfig(): Promise<RewardConfig> {
877
+ const result = await this.rollup.read.getRewardConfig();
878
+ return {
879
+ rewardDistributor: EthAddress.fromString(result.rewardDistributor),
880
+ sequencerBps: BigInt(result.sequencerBps),
881
+ booster: EthAddress.fromString(result.booster),
882
+ checkpointReward: result.checkpointReward,
883
+ };
736
884
  }
737
885
 
738
886
  setupEpoch(l1TxUtils: L1TxUtils) {