@aztec/ethereum 0.0.1-commit.9593d84 → 0.0.1-commit.96bb3f7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/dest/client.js +6 -2
  2. package/dest/config.d.ts +6 -42
  3. package/dest/config.d.ts.map +1 -1
  4. package/dest/config.js +9 -327
  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/fee_asset_handler.d.ts +6 -5
  11. package/dest/contracts/fee_asset_handler.d.ts.map +1 -1
  12. package/dest/contracts/fee_asset_handler.js +9 -9
  13. package/dest/contracts/governance_proposer.d.ts +2 -1
  14. package/dest/contracts/governance_proposer.d.ts.map +1 -1
  15. package/dest/contracts/governance_proposer.js +391 -8
  16. package/dest/contracts/inbox.d.ts +7 -3
  17. package/dest/contracts/inbox.d.ts.map +1 -1
  18. package/dest/contracts/inbox.js +4 -0
  19. package/dest/contracts/index.d.ts +2 -1
  20. package/dest/contracts/index.d.ts.map +1 -1
  21. package/dest/contracts/index.js +1 -0
  22. package/dest/contracts/outbox.d.ts +41 -0
  23. package/dest/contracts/outbox.d.ts.map +1 -0
  24. package/dest/contracts/outbox.js +86 -0
  25. package/dest/contracts/rollup.d.ts +144 -95
  26. package/dest/contracts/rollup.d.ts.map +1 -1
  27. package/dest/contracts/rollup.js +632 -139
  28. package/dest/contracts/tally_slashing_proposer.d.ts +3 -2
  29. package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -1
  30. package/dest/contracts/tally_slashing_proposer.js +1 -1
  31. package/dest/deploy_aztec_l1_contracts.d.ts +255 -0
  32. package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -0
  33. package/dest/deploy_aztec_l1_contracts.js +385 -0
  34. package/dest/deploy_l1_contract.d.ts +68 -0
  35. package/dest/deploy_l1_contract.d.ts.map +1 -0
  36. package/dest/deploy_l1_contract.js +312 -0
  37. package/dest/forwarder_proxy.d.ts +32 -0
  38. package/dest/forwarder_proxy.d.ts.map +1 -0
  39. package/dest/forwarder_proxy.js +93 -0
  40. package/dest/l1_artifacts.d.ts +3814 -1346
  41. package/dest/l1_artifacts.d.ts.map +1 -1
  42. package/dest/l1_contract_addresses.d.ts +1 -1
  43. package/dest/l1_contract_addresses.d.ts.map +1 -1
  44. package/dest/l1_contract_addresses.js +3 -3
  45. package/dest/l1_reader.d.ts +3 -1
  46. package/dest/l1_reader.d.ts.map +1 -1
  47. package/dest/l1_reader.js +6 -0
  48. package/dest/l1_tx_utils/config.d.ts +3 -3
  49. package/dest/l1_tx_utils/config.d.ts.map +1 -1
  50. package/dest/l1_tx_utils/config.js +17 -3
  51. package/dest/l1_tx_utils/constants.d.ts +7 -1
  52. package/dest/l1_tx_utils/constants.d.ts.map +1 -1
  53. package/dest/l1_tx_utils/constants.js +25 -0
  54. package/dest/l1_tx_utils/fee-strategies/index.d.ts +10 -0
  55. package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -0
  56. package/dest/l1_tx_utils/fee-strategies/index.js +12 -0
  57. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +8 -0
  58. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -0
  59. package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +129 -0
  60. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +23 -0
  61. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -0
  62. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +191 -0
  63. package/dest/l1_tx_utils/fee-strategies/types.d.ts +51 -0
  64. package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -0
  65. package/dest/l1_tx_utils/fee-strategies/types.js +3 -0
  66. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts +41 -0
  67. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -0
  68. package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +48 -0
  69. package/dest/l1_tx_utils/index-blobs.d.ts +3 -0
  70. package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -0
  71. package/dest/l1_tx_utils/index-blobs.js +2 -0
  72. package/dest/l1_tx_utils/index.d.ts +3 -1
  73. package/dest/l1_tx_utils/index.d.ts.map +1 -1
  74. package/dest/l1_tx_utils/index.js +2 -0
  75. package/dest/l1_tx_utils/interfaces.d.ts +2 -2
  76. package/dest/l1_tx_utils/interfaces.d.ts.map +1 -1
  77. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +233 -0
  78. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -0
  79. package/dest/l1_tx_utils/l1_fee_analyzer.js +506 -0
  80. package/dest/l1_tx_utils/l1_tx_utils.d.ts +1 -1
  81. package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
  82. package/dest/l1_tx_utils/l1_tx_utils.js +17 -4
  83. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +4 -15
  84. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
  85. package/dest/l1_tx_utils/readonly_l1_tx_utils.js +52 -159
  86. package/dest/queries.d.ts +1 -1
  87. package/dest/queries.d.ts.map +1 -1
  88. package/dest/queries.js +8 -3
  89. package/dest/test/chain_monitor.d.ts +15 -13
  90. package/dest/test/chain_monitor.d.ts.map +1 -1
  91. package/dest/test/chain_monitor.js +7 -9
  92. package/dest/test/eth_cheat_codes.js +4 -2
  93. package/dest/test/rollup_cheat_codes.d.ts +6 -5
  94. package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
  95. package/dest/test/rollup_cheat_codes.js +22 -5
  96. package/dest/test/start_anvil.d.ts +3 -1
  97. package/dest/test/start_anvil.d.ts.map +1 -1
  98. package/dest/test/tx_delayer.d.ts +1 -1
  99. package/dest/test/tx_delayer.d.ts.map +1 -1
  100. package/dest/test/tx_delayer.js +4 -3
  101. package/dest/types.d.ts +57 -2
  102. package/dest/types.d.ts.map +1 -1
  103. package/dest/utils.d.ts +15 -3
  104. package/dest/utils.d.ts.map +1 -1
  105. package/dest/utils.js +18 -0
  106. package/package.json +30 -12
  107. package/src/client.ts +2 -2
  108. package/src/config.ts +10 -406
  109. package/src/contracts/empire_base.ts +1 -1
  110. package/src/contracts/empire_slashing_proposer.ts +6 -1
  111. package/src/contracts/fee_asset_handler.ts +8 -7
  112. package/src/contracts/governance_proposer.ts +6 -1
  113. package/src/contracts/inbox.ts +7 -2
  114. package/src/contracts/index.ts +1 -0
  115. package/src/contracts/outbox.ts +98 -0
  116. package/src/contracts/rollup.ts +282 -110
  117. package/src/contracts/tally_slashing_proposer.ts +3 -1
  118. package/src/deploy_aztec_l1_contracts.ts +605 -0
  119. package/src/deploy_l1_contract.ts +362 -0
  120. package/src/forwarder_proxy.ts +108 -0
  121. package/src/l1_contract_addresses.ts +22 -20
  122. package/src/l1_reader.ts +8 -0
  123. package/src/l1_tx_utils/config.ts +24 -6
  124. package/src/l1_tx_utils/constants.ts +11 -0
  125. package/src/l1_tx_utils/fee-strategies/index.ts +22 -0
  126. package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +163 -0
  127. package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +245 -0
  128. package/src/l1_tx_utils/fee-strategies/types.ts +56 -0
  129. package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +119 -0
  130. package/src/l1_tx_utils/index-blobs.ts +2 -0
  131. package/src/l1_tx_utils/index.ts +2 -0
  132. package/src/l1_tx_utils/interfaces.ts +1 -1
  133. package/src/l1_tx_utils/l1_fee_analyzer.ts +803 -0
  134. package/src/l1_tx_utils/l1_tx_utils.ts +24 -4
  135. package/src/l1_tx_utils/readonly_l1_tx_utils.ts +65 -204
  136. package/src/queries.ts +8 -2
  137. package/src/test/chain_monitor.ts +18 -16
  138. package/src/test/eth_cheat_codes.ts +2 -2
  139. package/src/test/rollup_cheat_codes.ts +21 -7
  140. package/src/test/start_anvil.ts +2 -0
  141. package/src/test/tx_delayer.ts +5 -3
  142. package/src/types.ts +62 -0
  143. package/src/utils.ts +30 -1
  144. package/dest/deploy_l1_contracts.d.ts +0 -673
  145. package/dest/deploy_l1_contracts.d.ts.map +0 -1
  146. package/dest/deploy_l1_contracts.js +0 -1491
  147. package/dest/index.d.ts +0 -18
  148. package/dest/index.d.ts.map +0 -1
  149. package/dest/index.js +0 -17
  150. package/src/deploy_l1_contracts.ts +0 -1869
  151. package/src/index.ts +0 -17
@@ -1,7 +1,10 @@
1
- import { EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
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';
7
+ import { makeBackoff, retry } from '@aztec/foundation/retry';
5
8
  import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
6
9
  import { RollupStorage } from '@aztec/l1-artifacts/RollupStorage';
7
10
 
@@ -19,7 +22,7 @@ import {
19
22
  } from 'viem';
20
23
 
21
24
  import { getPublicClient } from '../client.js';
22
- import type { DeployL1ContractsReturnType } from '../deploy_l1_contracts.js';
25
+ import type { DeployAztecL1ContractsReturnType } from '../deploy_aztec_l1_contracts.js';
23
26
  import type { L1ContractAddresses } from '../l1_contract_addresses.js';
24
27
  import type { L1ReaderConfig } from '../l1_reader.js';
25
28
  import type { L1TxRequest, L1TxUtils } from '../l1_tx_utils/index.js';
@@ -57,13 +60,15 @@ export type L1RollupContractAddresses = Pick<
57
60
  export type EpochProofPublicInputArgs = {
58
61
  previousArchive: `0x${string}`;
59
62
  endArchive: `0x${string}`;
63
+ outHash: `0x${string}`;
60
64
  proverId: `0x${string}`;
61
65
  };
62
66
 
63
67
  export type ViemHeader = {
64
68
  lastArchiveRoot: `0x${string}`;
65
69
  blockHeadersHash: `0x${string}`;
66
- contentCommitment: ViemContentCommitment;
70
+ blobsHash: `0x${string}`;
71
+ inHash: `0x${string}`;
67
72
  slotNumber: bigint;
68
73
  timestamp: bigint;
69
74
  coinbase: `0x${string}`;
@@ -72,12 +77,6 @@ export type ViemHeader = {
72
77
  totalManaUsed: bigint;
73
78
  };
74
79
 
75
- export type ViemContentCommitment = {
76
- blobsHash: `0x${string}`;
77
- inHash: `0x${string}`;
78
- outHash: `0x${string}`;
79
- };
80
-
81
80
  export type ViemGasFees = {
82
81
  feePerDaGas: bigint;
83
82
  feePerL2Gas: bigint;
@@ -89,6 +88,103 @@ export enum SlashingProposerType {
89
88
  Empire = 2,
90
89
  }
91
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
+
92
188
  export class RollupContract {
93
189
  private readonly rollup: GetContractReturnType<typeof RollupAbi, ViemClient>;
94
190
 
@@ -106,7 +202,7 @@ export class RollupContract {
106
202
  return (RollupContract.cachedStfStorageSlot ??= keccak256(Buffer.from('aztec.stf.storage', 'utf-8')));
107
203
  }
108
204
 
109
- static getFromL1ContractsValues(deployL1ContractsValues: DeployL1ContractsReturnType) {
205
+ static getFromL1ContractsValues(deployL1ContractsValues: DeployAztecL1ContractsReturnType) {
110
206
  const {
111
207
  l1Client,
112
208
  l1ContractAddresses: { rollupAddress },
@@ -130,8 +226,8 @@ export class RollupContract {
130
226
  this.rollup = getContract({ address, abi: RollupAbi, client });
131
227
  }
132
228
 
133
- getGSE() {
134
- return this.rollup.read.getGSE();
229
+ async getGSE(): Promise<EthAddress> {
230
+ return EthAddress.fromString(await this.rollup.read.getGSE());
135
231
  }
136
232
 
137
233
  public get address() {
@@ -173,23 +269,23 @@ export class RollupContract {
173
269
  }
174
270
 
175
271
  @memoize
176
- getL1StartBlock() {
272
+ getL1StartBlock(): Promise<bigint> {
177
273
  return this.rollup.read.L1_BLOCK_AT_GENESIS();
178
274
  }
179
275
 
180
276
  @memoize
181
- getL1GenesisTime() {
277
+ getL1GenesisTime(): Promise<bigint> {
182
278
  return this.rollup.read.getGenesisTime();
183
279
  }
184
280
 
185
281
  @memoize
186
- getProofSubmissionEpochs() {
187
- return this.rollup.read.getProofSubmissionEpochs();
282
+ async getProofSubmissionEpochs(): Promise<number> {
283
+ return Number(await this.rollup.read.getProofSubmissionEpochs());
188
284
  }
189
285
 
190
286
  @memoize
191
- getEpochDuration() {
192
- return this.rollup.read.getEpochDuration();
287
+ async getEpochDuration(): Promise<number> {
288
+ return Number(await this.rollup.read.getEpochDuration());
193
289
  }
194
290
 
195
291
  @memoize
@@ -198,68 +294,68 @@ export class RollupContract {
198
294
  }
199
295
 
200
296
  @memoize
201
- getTargetCommitteeSize() {
202
- return this.rollup.read.getTargetCommitteeSize();
297
+ async getTargetCommitteeSize(): Promise<number> {
298
+ return Number(await this.rollup.read.getTargetCommitteeSize());
203
299
  }
204
300
 
205
301
  @memoize
206
- getEjectionThreshold() {
302
+ getEjectionThreshold(): Promise<bigint> {
207
303
  return this.rollup.read.getEjectionThreshold();
208
304
  }
209
305
 
210
306
  @memoize
211
- getLocalEjectionThreshold() {
307
+ getLocalEjectionThreshold(): Promise<bigint> {
212
308
  return this.rollup.read.getLocalEjectionThreshold();
213
309
  }
214
310
 
215
311
  @memoize
216
- getLagInEpochsForValidatorSet() {
217
- return this.rollup.read.getLagInEpochsForValidatorSet();
312
+ async getLagInEpochsForValidatorSet(): Promise<number> {
313
+ return Number(await this.rollup.read.getLagInEpochsForValidatorSet());
218
314
  }
219
315
 
220
316
  @memoize
221
- getLagInEpochsForRandao() {
222
- return this.rollup.read.getLagInEpochsForRandao();
317
+ async getLagInEpochsForRandao(): Promise<number> {
318
+ return Number(await this.rollup.read.getLagInEpochsForRandao());
223
319
  }
224
320
 
225
321
  @memoize
226
- getActivationThreshold() {
322
+ getActivationThreshold(): Promise<bigint> {
227
323
  return this.rollup.read.getActivationThreshold();
228
324
  }
229
325
 
230
326
  @memoize
231
- getExitDelay() {
232
- return this.rollup.read.getExitDelay();
327
+ async getExitDelay(): Promise<number> {
328
+ return Number(await this.rollup.read.getExitDelay());
233
329
  }
234
330
 
235
331
  @memoize
236
- getManaTarget() {
332
+ getManaTarget(): Promise<bigint> {
237
333
  return this.rollup.read.getManaTarget();
238
334
  }
239
335
 
240
336
  @memoize
241
- getProvingCostPerMana() {
337
+ getProvingCostPerMana(): Promise<bigint> {
242
338
  return this.rollup.read.getProvingCostPerManaInEth();
243
339
  }
244
340
 
245
341
  @memoize
246
- getProvingCostPerManaInFeeAsset() {
342
+ getProvingCostPerManaInFeeAsset(): Promise<bigint> {
247
343
  return this.rollup.read.getProvingCostPerManaInFeeAsset();
248
344
  }
249
345
 
250
346
  @memoize
251
- getManaLimit() {
347
+ getManaLimit(): Promise<bigint> {
252
348
  return this.rollup.read.getManaLimit();
253
349
  }
254
350
 
255
351
  @memoize
256
- getVersion() {
352
+ getVersion(): Promise<bigint> {
257
353
  return this.rollup.read.getVersion();
258
354
  }
259
355
 
260
356
  @memoize
261
- async getGenesisArchiveTreeRoot(): Promise<`0x${string}`> {
262
- return await this.rollup.read.archiveAt([0n]);
357
+ async getGenesisArchiveTreeRoot(): Promise<Fr> {
358
+ return Fr.fromString(await this.rollup.read.archiveAt([0n]));
263
359
  }
264
360
 
265
361
  /**
@@ -291,27 +387,27 @@ export class RollupContract {
291
387
  };
292
388
  }
293
389
 
294
- getSlasherAddress() {
295
- return this.rollup.read.getSlasher();
390
+ async getSlasherAddress(): Promise<EthAddress> {
391
+ return EthAddress.fromString(await this.rollup.read.getSlasher());
296
392
  }
297
393
 
298
394
  /**
299
395
  * Returns a SlasherContract instance for interacting with the slasher contract.
300
396
  */
301
397
  async getSlasherContract(): Promise<SlasherContract | undefined> {
302
- const slasherAddress = EthAddress.fromString(await this.getSlasherAddress());
398
+ const slasherAddress = await this.getSlasherAddress();
303
399
  if (slasherAddress.isZero()) {
304
400
  return undefined;
305
401
  }
306
402
  return new SlasherContract(this.client, slasherAddress);
307
403
  }
308
404
 
309
- getOwner() {
310
- return this.rollup.read.owner();
405
+ async getOwner(): Promise<EthAddress> {
406
+ return EthAddress.fromString(await this.rollup.read.owner());
311
407
  }
312
408
 
313
- getActiveAttesterCount() {
314
- return this.rollup.read.getActiveAttesterCount();
409
+ async getActiveAttesterCount(): Promise<number> {
410
+ return Number(await this.rollup.read.getActiveAttesterCount());
315
411
  }
316
412
 
317
413
  public async getSlashingProposerAddress() {
@@ -322,31 +418,35 @@ export class RollupContract {
322
418
  return await slasher.getProposer();
323
419
  }
324
420
 
325
- getCheckpointReward() {
421
+ getCheckpointReward(): Promise<bigint> {
326
422
  return this.rollup.read.getCheckpointReward();
327
423
  }
328
424
 
329
- getCheckpointNumber() {
330
- return this.rollup.read.getPendingCheckpointNumber();
425
+ async getCheckpointNumber(): Promise<CheckpointNumber> {
426
+ return CheckpointNumber.fromBigInt(await this.rollup.read.getPendingCheckpointNumber());
331
427
  }
332
428
 
333
- getProvenCheckpointNumber() {
334
- return this.rollup.read.getProvenCheckpointNumber();
429
+ async getProvenCheckpointNumber(): Promise<CheckpointNumber> {
430
+ return CheckpointNumber.fromBigInt(await this.rollup.read.getProvenCheckpointNumber());
335
431
  }
336
432
 
337
433
  async getSlotNumber(): Promise<SlotNumber> {
338
434
  return SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
339
435
  }
340
436
 
341
- getL1FeesAt(timestamp: bigint) {
342
- 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
+ };
343
443
  }
344
444
 
345
- getFeeAssetPerEth() {
445
+ getFeeAssetPerEth(): Promise<bigint> {
346
446
  return this.rollup.read.getFeeAssetPerEth();
347
447
  }
348
448
 
349
- async getCommitteeAt(timestamp: bigint): Promise<readonly `0x${string}`[] | undefined> {
449
+ async getCommitteeAt(timestamp: bigint): Promise<EthAddress[] | undefined> {
350
450
  const { result } = await this.client
351
451
  .simulateContract({
352
452
  address: this.address,
@@ -361,22 +461,22 @@ export class RollupContract {
361
461
  throw e;
362
462
  });
363
463
 
364
- return result;
464
+ return result ? result.map(addr => EthAddress.fromString(addr)) : undefined;
365
465
  }
366
466
 
367
- getSampleSeedAt(timestamp: bigint) {
368
- return this.rollup.read.getSampleSeedAt([timestamp]);
467
+ async getSampleSeedAt(timestamp: bigint): Promise<Buffer32> {
468
+ return Buffer32.fromBigInt(await this.rollup.read.getSampleSeedAt([timestamp]));
369
469
  }
370
470
 
371
- getCurrentSampleSeed() {
372
- return this.rollup.read.getCurrentSampleSeed();
471
+ async getCurrentSampleSeed(): Promise<Buffer32> {
472
+ return Buffer32.fromBigInt(await this.rollup.read.getCurrentSampleSeed());
373
473
  }
374
474
 
375
475
  async getCurrentEpoch(): Promise<EpochNumber> {
376
476
  return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
377
477
  }
378
478
 
379
- async getCurrentEpochCommittee(): Promise<readonly `0x${string}`[] | undefined> {
479
+ async getCurrentEpochCommittee(): Promise<EthAddress[] | undefined> {
380
480
  const { result } = await this.client
381
481
  .simulateContract({
382
482
  address: this.address,
@@ -391,10 +491,10 @@ export class RollupContract {
391
491
  throw e;
392
492
  });
393
493
 
394
- return result;
494
+ return result ? result.map(addr => EthAddress.fromString(addr)) : undefined;
395
495
  }
396
496
 
397
- async getCurrentProposer() {
497
+ async getCurrentProposer(): Promise<EthAddress> {
398
498
  const { result } = await this.client.simulateContract({
399
499
  address: this.address,
400
500
  abi: RollupAbi,
@@ -402,10 +502,10 @@ export class RollupContract {
402
502
  args: [],
403
503
  });
404
504
 
405
- return result;
505
+ return EthAddress.fromString(result);
406
506
  }
407
507
 
408
- async getProposerAt(timestamp: bigint) {
508
+ async getProposerAt(timestamp: bigint): Promise<EthAddress> {
409
509
  const { result } = await this.client.simulateContract({
410
510
  address: this.address,
411
511
  abi: RollupAbi,
@@ -413,27 +513,61 @@ export class RollupContract {
413
513
  args: [timestamp],
414
514
  });
415
515
 
416
- return result;
516
+ return EthAddress.fromString(result);
417
517
  }
418
518
 
419
- getCheckpoint(checkpointNumber: bigint | number) {
420
- 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
+ };
421
536
  }
422
537
 
423
- getTips() {
424
- return this.rollup.read.getTips();
538
+ /** Returns the pending checkpoint from the rollup contract */
539
+ getPendingCheckpoint() {
540
+ // We retry because of race conditions during prunes: we may get a pending checkpoint number which is immediately
541
+ // reorged out due to a prune happening, causing the subsequent getCheckpoint call to fail. So we try again in that case.
542
+ return retry(
543
+ async () => {
544
+ const pendingCheckpointNumber = await this.getCheckpointNumber();
545
+ const pendingCheckpoint = await this.getCheckpoint(pendingCheckpointNumber);
546
+ return pendingCheckpoint;
547
+ },
548
+ 'getting pending checkpoint',
549
+ makeBackoff([0.5, 0.5, 0.5]),
550
+ );
425
551
  }
426
552
 
427
- getTimestampForSlot(slot: SlotNumber) {
553
+ async getTips(): Promise<{ pending: CheckpointNumber; proven: CheckpointNumber }> {
554
+ const { pending, proven } = await this.rollup.read.getTips();
555
+ return {
556
+ pending: CheckpointNumber.fromBigInt(pending),
557
+ proven: CheckpointNumber.fromBigInt(proven),
558
+ };
559
+ }
560
+
561
+ getTimestampForSlot(slot: SlotNumber): Promise<bigint> {
428
562
  return this.rollup.read.getTimestampForSlot([BigInt(slot)]);
429
563
  }
430
564
 
431
- getEntryQueueLength() {
432
- return this.rollup.read.getEntryQueueLength();
565
+ async getEntryQueueLength(): Promise<number> {
566
+ return Number(await this.rollup.read.getEntryQueueLength());
433
567
  }
434
568
 
435
- getAvailableValidatorFlushes() {
436
- return this.rollup.read.getAvailableValidatorFlushes();
569
+ async getAvailableValidatorFlushes(): Promise<number> {
570
+ return Number(await this.rollup.read.getAvailableValidatorFlushes());
437
571
  }
438
572
 
439
573
  async getNextFlushableEpoch(): Promise<EpochNumber> {
@@ -444,7 +578,7 @@ export class RollupContract {
444
578
  return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
445
579
  }
446
580
 
447
- async getEpochNumberForCheckpoint(checkpointNumber: bigint): Promise<EpochNumber> {
581
+ async getEpochNumberForCheckpoint(checkpointNumber: CheckpointNumber): Promise<EpochNumber> {
448
582
  return EpochNumber.fromBigInt(await this.rollup.read.getEpochForCheckpoint([BigInt(checkpointNumber)]));
449
583
  }
450
584
 
@@ -489,10 +623,11 @@ export class RollupContract {
489
623
  return EpochNumber.fromBigInt(await this.rollup.read.getEpochAtSlot([BigInt(slotNumber)]));
490
624
  }
491
625
 
492
- getEpochProofPublicInputs(
626
+ async getEpochProofPublicInputs(
493
627
  args: readonly [bigint, bigint, EpochProofPublicInputArgs, readonly `0x${string}`[], `0x${string}`],
494
- ) {
495
- return this.rollup.read.getEpochProofPublicInputs(args);
628
+ ): Promise<Fr[]> {
629
+ const result = await this.rollup.read.getEpochProofPublicInputs(args);
630
+ return result.map(Fr.fromString);
496
631
  }
497
632
 
498
633
  public async validateHeader(
@@ -537,8 +672,8 @@ export class RollupContract {
537
672
  archive: Buffer,
538
673
  account: `0x${string}` | Account,
539
674
  slotDuration: number,
540
- opts: { forcePendingCheckpointNumber?: number } = {},
541
- ): Promise<{ slot: SlotNumber; checkpointNumber: bigint; timeOfNextL1Slot: bigint }> {
675
+ opts: { forcePendingCheckpointNumber?: CheckpointNumber } = {},
676
+ ): Promise<{ slot: SlotNumber; checkpointNumber: CheckpointNumber; timeOfNextL1Slot: bigint }> {
542
677
  const latestBlock = await this.client.getBlock();
543
678
  const timeOfNextL1Slot = latestBlock.timestamp + BigInt(slotDuration);
544
679
  const who = typeof account === 'string' ? account : account.address;
@@ -555,7 +690,11 @@ export class RollupContract {
555
690
  stateOverride: await this.makePendingCheckpointNumberOverride(opts.forcePendingCheckpointNumber),
556
691
  });
557
692
 
558
- return { slot: SlotNumber.fromBigInt(slot), checkpointNumber, timeOfNextL1Slot };
693
+ return {
694
+ slot: SlotNumber.fromBigInt(slot),
695
+ checkpointNumber: CheckpointNumber.fromBigInt(checkpointNumber),
696
+ timeOfNextL1Slot,
697
+ };
559
698
  } catch (err: unknown) {
560
699
  throw formatViemError(err);
561
700
  }
@@ -567,7 +706,7 @@ export class RollupContract {
567
706
  * stored in the same slot. If the argument is undefined, it returns an empty override.
568
707
  */
569
708
  public async makePendingCheckpointNumberOverride(
570
- forcePendingCheckpointNumber: number | undefined,
709
+ forcePendingCheckpointNumber: CheckpointNumber | undefined,
571
710
  ): Promise<StateOverride> {
572
711
  if (forcePendingCheckpointNumber === undefined) {
573
712
  return [];
@@ -586,7 +725,7 @@ export class RollupContract {
586
725
 
587
726
  /** Creates a request to Rollup#invalidateBadAttestation to be simulated or sent */
588
727
  public buildInvalidateBadAttestationRequest(
589
- checkpointNumber: number,
728
+ checkpointNumber: CheckpointNumber,
590
729
  attestationsAndSigners: ViemCommitteeAttestations,
591
730
  committee: EthAddress[],
592
731
  invalidIndex: number,
@@ -608,7 +747,7 @@ export class RollupContract {
608
747
 
609
748
  /** Creates a request to Rollup#invalidateInsufficientAttestations to be simulated or sent */
610
749
  public buildInvalidateInsufficientAttestationsRequest(
611
- checkpointNumber: number,
750
+ checkpointNumber: CheckpointNumber,
612
751
  attestationsAndSigners: ViemCommitteeAttestations,
613
752
  committee: EthAddress[],
614
753
  ): L1TxRequest {
@@ -630,85 +769,118 @@ export class RollupContract {
630
769
  return this.rollup.read.getHasSubmitted([BigInt(epochNumber), BigInt(numberOfCheckpointsInEpoch), prover]);
631
770
  }
632
771
 
633
- getManaBaseFeeAt(timestamp: bigint, inFeeAsset: boolean) {
634
- return this.rollup.read.getManaBaseFeeAt([timestamp, inFeeAsset]);
772
+ getManaMinFeeAt(timestamp: bigint, inFeeAsset: boolean): Promise<bigint> {
773
+ return this.rollup.read.getManaMinFeeAt([timestamp, inFeeAsset]);
635
774
  }
636
775
 
637
776
  async getSlotAt(timestamp: bigint): Promise<SlotNumber> {
638
777
  return SlotNumber.fromBigInt(await this.rollup.read.getSlotAt([timestamp]));
639
778
  }
640
779
 
641
- async status(checkpointNumber: bigint, options?: { blockNumber?: bigint }) {
780
+ async status(checkpointNumber: CheckpointNumber, options?: { blockNumber?: bigint }): Promise<RollupStatusResponse> {
642
781
  await checkBlockTag(options?.blockNumber, this.client);
643
- return this.rollup.read.status([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
+ };
644
790
  }
645
791
 
646
- async canPruneAtTime(timestamp: bigint, options?: { blockNumber?: bigint }) {
792
+ async canPruneAtTime(timestamp: bigint, options?: { blockNumber?: bigint }): Promise<boolean> {
647
793
  await checkBlockTag(options?.blockNumber, this.client);
648
794
  return this.rollup.read.canPruneAtTime([timestamp], options);
649
795
  }
650
796
 
651
- archive() {
652
- return this.rollup.read.archive();
797
+ async archive(): Promise<Fr> {
798
+ return Fr.fromString(await this.rollup.read.archive());
653
799
  }
654
800
 
655
- archiveAt(checkpointNumber: bigint) {
656
- return this.rollup.read.archiveAt([checkpointNumber]);
801
+ async archiveAt(checkpointNumber: CheckpointNumber): Promise<Fr> {
802
+ return Fr.fromString(await this.rollup.read.archiveAt([BigInt(checkpointNumber)]));
657
803
  }
658
804
 
659
- getSequencerRewards(address: Hex | EthAddress) {
805
+ getSequencerRewards(address: Hex | EthAddress): Promise<bigint> {
660
806
  if (address instanceof EthAddress) {
661
807
  address = address.toString();
662
808
  }
663
809
  return this.rollup.read.getSequencerRewards([address]);
664
810
  }
665
811
 
666
- getSpecificProverRewardsForEpoch(epoch: bigint, prover: Hex | EthAddress) {
812
+ getSpecificProverRewardsForEpoch(epoch: bigint, prover: Hex | EthAddress): Promise<bigint> {
667
813
  if (prover instanceof EthAddress) {
668
814
  prover = prover.toString();
669
815
  }
670
816
  return this.rollup.read.getSpecificProverRewardsForEpoch([epoch, prover]);
671
817
  }
672
818
 
673
- async getAttesters() {
819
+ async getAttesters(): Promise<EthAddress[]> {
674
820
  const attesterSize = await this.getActiveAttesterCount();
675
821
  const gse = new GSEContract(this.client, await this.getGSE());
676
822
  const ts = (await this.client.getBlock()).timestamp;
677
823
 
678
- const indices = Array.from({ length: Number(attesterSize) }, (_, i) => BigInt(i));
824
+ const indices = Array.from({ length: attesterSize }, (_, i) => BigInt(i));
679
825
  const chunks = chunk(indices, 1000);
680
826
 
681
- 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));
682
829
  }
683
830
 
684
- getAttesterView(address: Hex | EthAddress) {
831
+ async getAttesterView(address: Hex | EthAddress): Promise<AttesterView> {
685
832
  if (address instanceof EthAddress) {
686
833
  address = address.toString();
687
834
  }
688
- 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
+ };
689
855
  }
690
856
 
691
- getStatus(address: Hex | EthAddress) {
857
+ async getStatus(address: Hex | EthAddress): Promise<AttesterStatus> {
692
858
  if (address instanceof EthAddress) {
693
859
  address = address.toString();
694
860
  }
695
- return this.rollup.read.getStatus([address]);
861
+ return (await this.rollup.read.getStatus([address])) as AttesterStatus;
696
862
  }
697
863
 
698
- getBlobCommitmentsHash(checkpointNumber: bigint) {
699
- return this.rollup.read.getBlobCommitmentsHash([checkpointNumber]);
864
+ async getBlobCommitmentsHash(checkpointNumber: CheckpointNumber): Promise<Buffer32> {
865
+ return Buffer32.fromString(await this.rollup.read.getBlobCommitmentsHash([BigInt(checkpointNumber)]));
700
866
  }
701
867
 
702
- getCurrentBlobCommitmentsHash() {
703
- return this.rollup.read.getCurrentBlobCommitmentsHash();
868
+ async getCurrentBlobCommitmentsHash(): Promise<Buffer32> {
869
+ return Buffer32.fromString(await this.rollup.read.getCurrentBlobCommitmentsHash());
704
870
  }
705
871
 
706
- getStakingAsset() {
707
- return this.rollup.read.getStakingAsset();
872
+ async getStakingAsset(): Promise<EthAddress> {
873
+ return EthAddress.fromString(await this.rollup.read.getStakingAsset());
708
874
  }
709
875
 
710
- getRewardConfig() {
711
- 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
+ };
712
884
  }
713
885
 
714
886
  setupEpoch(l1TxUtils: L1TxUtils) {
@@ -752,7 +924,7 @@ export class RollupContract {
752
924
  }
753
925
 
754
926
  public listenToCheckpointInvalidated(
755
- callback: (args: { checkpointNumber: bigint }) => unknown,
927
+ callback: (args: { checkpointNumber: CheckpointNumber }) => unknown,
756
928
  ): WatchContractEventReturnType {
757
929
  return this.rollup.watchEvent.CheckpointInvalidated(
758
930
  {},
@@ -761,7 +933,7 @@ export class RollupContract {
761
933
  for (const log of logs) {
762
934
  const args = log.args;
763
935
  if (args.checkpointNumber !== undefined) {
764
- callback({ checkpointNumber: args.checkpointNumber });
936
+ callback({ checkpointNumber: CheckpointNumber.fromBigInt(args.checkpointNumber) });
765
937
  }
766
938
  }
767
939
  },