@aztec/ethereum 0.0.1-commit.b655e406 → 0.0.1-commit.c7c42ec

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 (184) hide show
  1. package/dest/account.d.ts +1 -1
  2. package/dest/chain.d.ts +1 -1
  3. package/dest/client.d.ts +1 -1
  4. package/dest/client.js +6 -2
  5. package/dest/config.d.ts +11 -44
  6. package/dest/config.d.ts.map +1 -1
  7. package/dest/config.js +20 -332
  8. package/dest/constants.d.ts +1 -1
  9. package/dest/contracts/empire_base.d.ts +7 -5
  10. package/dest/contracts/empire_base.d.ts.map +1 -1
  11. package/dest/contracts/empire_base.js +1 -1
  12. package/dest/contracts/empire_slashing_proposer.d.ts +6 -4
  13. package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -1
  14. package/dest/contracts/empire_slashing_proposer.js +17 -2
  15. package/dest/contracts/errors.d.ts +1 -1
  16. package/dest/contracts/errors.d.ts.map +1 -1
  17. package/dest/contracts/fee_asset_handler.d.ts +1 -1
  18. package/dest/contracts/fee_asset_handler.d.ts.map +1 -1
  19. package/dest/contracts/fee_juice.d.ts +1 -1
  20. package/dest/contracts/fee_juice.d.ts.map +1 -1
  21. package/dest/contracts/governance.d.ts +16 -16
  22. package/dest/contracts/governance.d.ts.map +1 -1
  23. package/dest/contracts/governance_proposer.d.ts +6 -4
  24. package/dest/contracts/governance_proposer.d.ts.map +1 -1
  25. package/dest/contracts/governance_proposer.js +17 -2
  26. package/dest/contracts/gse.d.ts +1 -1
  27. package/dest/contracts/gse.d.ts.map +1 -1
  28. package/dest/contracts/inbox.d.ts +7 -3
  29. package/dest/contracts/inbox.d.ts.map +1 -1
  30. package/dest/contracts/inbox.js +4 -0
  31. package/dest/contracts/index.d.ts +1 -1
  32. package/dest/contracts/multicall.d.ts +2 -2
  33. package/dest/contracts/multicall.d.ts.map +1 -1
  34. package/dest/contracts/registry.d.ts +1 -1
  35. package/dest/contracts/registry.d.ts.map +1 -1
  36. package/dest/contracts/rollup.d.ts +71 -64
  37. package/dest/contracts/rollup.d.ts.map +1 -1
  38. package/dest/contracts/rollup.js +90 -67
  39. package/dest/contracts/slasher_contract.d.ts +1 -1
  40. package/dest/contracts/slasher_contract.d.ts.map +1 -1
  41. package/dest/contracts/tally_slashing_proposer.d.ts +9 -7
  42. package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -1
  43. package/dest/contracts/tally_slashing_proposer.js +4 -4
  44. package/dest/contracts/utils.d.ts +1 -1
  45. package/dest/deploy_aztec_l1_contracts.d.ts +247 -0
  46. package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -0
  47. package/dest/deploy_aztec_l1_contracts.js +336 -0
  48. package/dest/deploy_l1_contract.d.ts +68 -0
  49. package/dest/deploy_l1_contract.d.ts.map +1 -0
  50. package/dest/deploy_l1_contract.js +312 -0
  51. package/dest/eth-signer/eth-signer.d.ts +1 -1
  52. package/dest/eth-signer/index.d.ts +1 -1
  53. package/dest/forwarder_proxy.d.ts +32 -0
  54. package/dest/forwarder_proxy.d.ts.map +1 -0
  55. package/dest/forwarder_proxy.js +93 -0
  56. package/dest/l1_artifacts.d.ts +2078 -880
  57. package/dest/l1_artifacts.d.ts.map +1 -1
  58. package/dest/l1_contract_addresses.d.ts +3 -3
  59. package/dest/l1_contract_addresses.d.ts.map +1 -1
  60. package/dest/l1_contract_addresses.js +3 -3
  61. package/dest/l1_reader.d.ts +3 -1
  62. package/dest/l1_reader.d.ts.map +1 -1
  63. package/dest/l1_reader.js +6 -0
  64. package/dest/l1_tx_utils/config.d.ts +5 -5
  65. package/dest/l1_tx_utils/config.d.ts.map +1 -1
  66. package/dest/l1_tx_utils/config.js +30 -7
  67. package/dest/l1_tx_utils/constants.d.ts +7 -1
  68. package/dest/l1_tx_utils/constants.d.ts.map +1 -1
  69. package/dest/l1_tx_utils/constants.js +25 -0
  70. package/dest/l1_tx_utils/factory.d.ts +1 -1
  71. package/dest/l1_tx_utils/fee-strategies/index.d.ts +9 -0
  72. package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -0
  73. package/dest/l1_tx_utils/fee-strategies/index.js +11 -0
  74. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +18 -0
  75. package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -0
  76. package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +111 -0
  77. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +32 -0
  78. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -0
  79. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +173 -0
  80. package/dest/l1_tx_utils/fee-strategies/types.d.ts +64 -0
  81. package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -0
  82. package/dest/l1_tx_utils/fee-strategies/types.js +24 -0
  83. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts +41 -0
  84. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -0
  85. package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +48 -0
  86. package/dest/l1_tx_utils/index-blobs.d.ts +3 -0
  87. package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -0
  88. package/dest/l1_tx_utils/index-blobs.js +2 -0
  89. package/dest/l1_tx_utils/index.d.ts +3 -1
  90. package/dest/l1_tx_utils/index.d.ts.map +1 -1
  91. package/dest/l1_tx_utils/index.js +2 -0
  92. package/dest/l1_tx_utils/interfaces.d.ts +2 -2
  93. package/dest/l1_tx_utils/interfaces.d.ts.map +1 -1
  94. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +233 -0
  95. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -0
  96. package/dest/l1_tx_utils/l1_fee_analyzer.js +506 -0
  97. package/dest/l1_tx_utils/l1_tx_utils.d.ts +1 -2
  98. package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
  99. package/dest/l1_tx_utils/l1_tx_utils.js +17 -4
  100. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +1 -1
  101. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +1 -1
  102. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +19 -26
  103. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
  104. package/dest/l1_tx_utils/readonly_l1_tx_utils.js +70 -141
  105. package/dest/l1_tx_utils/signer.d.ts +1 -1
  106. package/dest/l1_tx_utils/types.d.ts +1 -1
  107. package/dest/l1_tx_utils/types.d.ts.map +1 -1
  108. package/dest/l1_tx_utils/utils.d.ts +1 -1
  109. package/dest/l1_types.d.ts +1 -1
  110. package/dest/publisher_manager.d.ts +1 -1
  111. package/dest/publisher_manager.d.ts.map +1 -1
  112. package/dest/queries.d.ts +1 -1
  113. package/dest/queries.d.ts.map +1 -1
  114. package/dest/queries.js +10 -3
  115. package/dest/test/chain_monitor.d.ts +27 -24
  116. package/dest/test/chain_monitor.d.ts.map +1 -1
  117. package/dest/test/chain_monitor.js +32 -34
  118. package/dest/test/delayed_tx_utils.d.ts +1 -1
  119. package/dest/test/delayed_tx_utils.d.ts.map +1 -1
  120. package/dest/test/eth_cheat_codes.d.ts +8 -12
  121. package/dest/test/eth_cheat_codes.d.ts.map +1 -1
  122. package/dest/test/eth_cheat_codes.js +11 -3
  123. package/dest/test/eth_cheat_codes_with_state.d.ts +1 -1
  124. package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -1
  125. package/dest/test/index.d.ts +1 -1
  126. package/dest/test/rollup_cheat_codes.d.ts +14 -13
  127. package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
  128. package/dest/test/rollup_cheat_codes.js +46 -39
  129. package/dest/test/start_anvil.d.ts +4 -1
  130. package/dest/test/start_anvil.d.ts.map +1 -1
  131. package/dest/test/start_anvil.js +2 -1
  132. package/dest/test/tx_delayer.d.ts +1 -1
  133. package/dest/test/tx_delayer.d.ts.map +1 -1
  134. package/dest/test/tx_delayer.js +4 -3
  135. package/dest/test/upgrade_utils.d.ts +1 -1
  136. package/dest/types.d.ts +57 -2
  137. package/dest/types.d.ts.map +1 -1
  138. package/dest/utils.d.ts +15 -3
  139. package/dest/utils.d.ts.map +1 -1
  140. package/dest/utils.js +18 -0
  141. package/dest/zkPassportVerifierAddress.d.ts +1 -1
  142. package/package.json +33 -14
  143. package/src/client.ts +2 -2
  144. package/src/config.ts +24 -412
  145. package/src/contracts/empire_base.ts +6 -5
  146. package/src/contracts/empire_slashing_proposer.ts +16 -5
  147. package/src/contracts/governance_proposer.ts +16 -5
  148. package/src/contracts/inbox.ts +7 -2
  149. package/src/contracts/rollup.ts +99 -82
  150. package/src/contracts/tally_slashing_proposer.ts +11 -8
  151. package/src/deploy_aztec_l1_contracts.ts +557 -0
  152. package/src/deploy_l1_contract.ts +362 -0
  153. package/src/forwarder_proxy.ts +108 -0
  154. package/src/l1_contract_addresses.ts +22 -20
  155. package/src/l1_reader.ts +8 -0
  156. package/src/l1_tx_utils/config.ts +32 -11
  157. package/src/l1_tx_utils/constants.ts +11 -0
  158. package/src/l1_tx_utils/fee-strategies/index.ts +22 -0
  159. package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +159 -0
  160. package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +241 -0
  161. package/src/l1_tx_utils/fee-strategies/types.ts +88 -0
  162. package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +119 -0
  163. package/src/l1_tx_utils/index-blobs.ts +2 -0
  164. package/src/l1_tx_utils/index.ts +2 -0
  165. package/src/l1_tx_utils/interfaces.ts +1 -1
  166. package/src/l1_tx_utils/l1_fee_analyzer.ts +804 -0
  167. package/src/l1_tx_utils/l1_tx_utils.ts +24 -4
  168. package/src/l1_tx_utils/readonly_l1_tx_utils.ts +78 -179
  169. package/src/queries.ts +12 -3
  170. package/src/test/chain_monitor.ts +50 -48
  171. package/src/test/eth_cheat_codes.ts +9 -3
  172. package/src/test/rollup_cheat_codes.ts +45 -43
  173. package/src/test/start_anvil.ts +4 -0
  174. package/src/test/tx_delayer.ts +5 -3
  175. package/src/types.ts +62 -0
  176. package/src/utils.ts +30 -1
  177. package/dest/deploy_l1_contracts.d.ts +0 -226
  178. package/dest/deploy_l1_contracts.d.ts.map +0 -1
  179. package/dest/deploy_l1_contracts.js +0 -1473
  180. package/dest/index.d.ts +0 -18
  181. package/dest/index.d.ts.map +0 -1
  182. package/dest/index.js +0 -17
  183. package/src/deploy_l1_contracts.ts +0 -1849
  184. package/src/index.ts +0 -17
@@ -1,6 +1,8 @@
1
+ import { CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
1
2
  import { memoize } from '@aztec/foundation/decorators';
2
3
  import { EthAddress } from '@aztec/foundation/eth-address';
3
4
  import type { ViemSignature } from '@aztec/foundation/eth-signature';
5
+ import { makeBackoff, retry } from '@aztec/foundation/retry';
4
6
  import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
5
7
  import { RollupStorage } from '@aztec/l1-artifacts/RollupStorage';
6
8
 
@@ -18,7 +20,7 @@ import {
18
20
  } from 'viem';
19
21
 
20
22
  import { getPublicClient } from '../client.js';
21
- import type { DeployL1ContractsReturnType } from '../deploy_l1_contracts.js';
23
+ import type { DeployAztecL1ContractsReturnType } from '../deploy_aztec_l1_contracts.js';
22
24
  import type { L1ContractAddresses } from '../l1_contract_addresses.js';
23
25
  import type { L1ReaderConfig } from '../l1_reader.js';
24
26
  import type { L1TxRequest, L1TxUtils } from '../l1_tx_utils/index.js';
@@ -61,6 +63,7 @@ export type EpochProofPublicInputArgs = {
61
63
 
62
64
  export type ViemHeader = {
63
65
  lastArchiveRoot: `0x${string}`;
66
+ blockHeadersHash: `0x${string}`;
64
67
  contentCommitment: ViemContentCommitment;
65
68
  slotNumber: bigint;
66
69
  timestamp: bigint;
@@ -81,22 +84,6 @@ export type ViemGasFees = {
81
84
  feePerL2Gas: bigint;
82
85
  };
83
86
 
84
- export type ViemStateReference = {
85
- l1ToL2MessageTree: ViemAppendOnlyTreeSnapshot;
86
- partialStateReference: ViemPartialStateReference;
87
- };
88
-
89
- export type ViemPartialStateReference = {
90
- noteHashTree: ViemAppendOnlyTreeSnapshot;
91
- nullifierTree: ViemAppendOnlyTreeSnapshot;
92
- publicDataTree: ViemAppendOnlyTreeSnapshot;
93
- };
94
-
95
- export type ViemAppendOnlyTreeSnapshot = {
96
- root: `0x${string}`;
97
- nextAvailableLeafIndex: number;
98
- };
99
-
100
87
  export enum SlashingProposerType {
101
88
  None = 0,
102
89
  Tally = 1,
@@ -120,7 +107,7 @@ export class RollupContract {
120
107
  return (RollupContract.cachedStfStorageSlot ??= keccak256(Buffer.from('aztec.stf.storage', 'utf-8')));
121
108
  }
122
109
 
123
- static getFromL1ContractsValues(deployL1ContractsValues: DeployL1ContractsReturnType) {
110
+ static getFromL1ContractsValues(deployL1ContractsValues: DeployAztecL1ContractsReturnType) {
124
111
  const {
125
112
  l1Client,
126
113
  l1ContractAddresses: { rollupAddress },
@@ -207,8 +194,8 @@ export class RollupContract {
207
194
  }
208
195
 
209
196
  @memoize
210
- getSlotDuration() {
211
- return this.rollup.read.getSlotDuration();
197
+ async getSlotDuration(): Promise<number> {
198
+ return Number(await this.rollup.read.getSlotDuration());
212
199
  }
213
200
 
214
201
  @memoize
@@ -227,8 +214,13 @@ export class RollupContract {
227
214
  }
228
215
 
229
216
  @memoize
230
- getLagInEpochs() {
231
- return this.rollup.read.getLagInEpochs();
217
+ getLagInEpochsForValidatorSet() {
218
+ return this.rollup.read.getLagInEpochsForValidatorSet();
219
+ }
220
+
221
+ @memoize
222
+ getLagInEpochsForRandao() {
223
+ return this.rollup.read.getLagInEpochsForRandao();
232
224
  }
233
225
 
234
226
  @memoize
@@ -294,7 +286,7 @@ export class RollupContract {
294
286
  return {
295
287
  l1StartBlock,
296
288
  l1GenesisTime,
297
- slotDuration: Number(slotDuration),
289
+ slotDuration,
298
290
  epochDuration: Number(epochDuration),
299
291
  proofSubmissionEpochs: Number(proofSubmissionEpochs),
300
292
  };
@@ -331,20 +323,20 @@ export class RollupContract {
331
323
  return await slasher.getProposer();
332
324
  }
333
325
 
334
- getBlockReward() {
335
- return this.rollup.read.getBlockReward();
326
+ getCheckpointReward() {
327
+ return this.rollup.read.getCheckpointReward();
336
328
  }
337
329
 
338
- getBlockNumber() {
339
- return this.rollup.read.getPendingBlockNumber();
330
+ async getCheckpointNumber(): Promise<CheckpointNumber> {
331
+ return CheckpointNumber.fromBigInt(await this.rollup.read.getPendingCheckpointNumber());
340
332
  }
341
333
 
342
- getProvenBlockNumber() {
343
- return this.rollup.read.getProvenBlockNumber();
334
+ async getProvenCheckpointNumber(): Promise<CheckpointNumber> {
335
+ return CheckpointNumber.fromBigInt(await this.rollup.read.getProvenCheckpointNumber());
344
336
  }
345
337
 
346
- getSlotNumber() {
347
- return this.rollup.read.getCurrentSlot();
338
+ async getSlotNumber(): Promise<SlotNumber> {
339
+ return SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
348
340
  }
349
341
 
350
342
  getL1FeesAt(timestamp: bigint) {
@@ -381,8 +373,8 @@ export class RollupContract {
381
373
  return this.rollup.read.getCurrentSampleSeed();
382
374
  }
383
375
 
384
- getCurrentEpoch() {
385
- return this.rollup.read.getCurrentEpoch();
376
+ async getCurrentEpoch(): Promise<EpochNumber> {
377
+ return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
386
378
  }
387
379
 
388
380
  async getCurrentEpochCommittee(): Promise<readonly `0x${string}`[] | undefined> {
@@ -425,16 +417,35 @@ export class RollupContract {
425
417
  return result;
426
418
  }
427
419
 
428
- getBlock(blockNumber: bigint | number) {
429
- return this.rollup.read.getBlock([BigInt(blockNumber)]);
420
+ getCheckpoint(checkpointNumber: CheckpointNumber) {
421
+ return this.rollup.read.getCheckpoint([BigInt(checkpointNumber)]);
430
422
  }
431
423
 
432
- getTips() {
433
- return this.rollup.read.getTips();
424
+ /** Returns the pending checkpoint from the rollup contract */
425
+ getPendingCheckpoint() {
426
+ // We retry because of race conditions during prunes: we may get a pending checkpoint number which is immediately
427
+ // reorged out due to a prune happening, causing the subsequent getCheckpoint call to fail. So we try again in that case.
428
+ return retry(
429
+ async () => {
430
+ const pendingCheckpointNumber = await this.getCheckpointNumber();
431
+ const pendingCheckpoint = await this.getCheckpoint(pendingCheckpointNumber);
432
+ return pendingCheckpoint;
433
+ },
434
+ 'getting pending checkpoint',
435
+ makeBackoff([0.5, 0.5, 0.5]),
436
+ );
437
+ }
438
+
439
+ async getTips(): Promise<{ pending: CheckpointNumber; proven: CheckpointNumber }> {
440
+ const { pending, proven } = await this.rollup.read.getTips();
441
+ return {
442
+ pending: CheckpointNumber.fromBigInt(pending),
443
+ proven: CheckpointNumber.fromBigInt(proven),
444
+ };
434
445
  }
435
446
 
436
- getTimestampForSlot(slot: bigint) {
437
- return this.rollup.read.getTimestampForSlot([slot]);
447
+ getTimestampForSlot(slot: SlotNumber) {
448
+ return this.rollup.read.getTimestampForSlot([BigInt(slot)]);
438
449
  }
439
450
 
440
451
  getEntryQueueLength() {
@@ -445,16 +456,16 @@ export class RollupContract {
445
456
  return this.rollup.read.getAvailableValidatorFlushes();
446
457
  }
447
458
 
448
- getNextFlushableEpoch() {
449
- return this.rollup.read.getNextFlushableEpoch();
459
+ async getNextFlushableEpoch(): Promise<EpochNumber> {
460
+ return EpochNumber.fromBigInt(await this.rollup.read.getNextFlushableEpoch());
450
461
  }
451
462
 
452
- getCurrentEpochNumber(): Promise<bigint> {
453
- return this.rollup.read.getCurrentEpoch();
463
+ async getCurrentEpochNumber(): Promise<EpochNumber> {
464
+ return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
454
465
  }
455
466
 
456
- getEpochNumberForBlock(blockNumber: bigint) {
457
- return this.rollup.read.getEpochForBlock([BigInt(blockNumber)]);
467
+ async getEpochNumberForCheckpoint(checkpointNumber: CheckpointNumber): Promise<EpochNumber> {
468
+ return EpochNumber.fromBigInt(await this.rollup.read.getEpochForCheckpoint([BigInt(checkpointNumber)]));
458
469
  }
459
470
 
460
471
  async getRollupAddresses(): Promise<L1RollupContractAddresses> {
@@ -494,8 +505,8 @@ export class RollupContract {
494
505
  return EthAddress.fromString(await this.rollup.read.getFeeAssetPortal());
495
506
  }
496
507
 
497
- public async getEpochNumberForSlotNumber(slotNumber: bigint): Promise<bigint> {
498
- return await this.rollup.read.getEpochAtSlot([slotNumber]);
508
+ public async getEpochNumberForSlotNumber(slotNumber: SlotNumber): Promise<EpochNumber> {
509
+ return EpochNumber.fromBigInt(await this.rollup.read.getEpochAtSlot([BigInt(slotNumber)]));
499
510
  }
500
511
 
501
512
  getEpochProofPublicInputs(
@@ -538,53 +549,57 @@ export class RollupContract {
538
549
  * @dev Throws if unable to propose
539
550
  *
540
551
  * @param archive - The archive that we expect to be current state
541
- * @return [slot, blockNumber] - If you can propose, the L2 slot number and L2 block number of the next Ethereum block,
552
+ * @return [slot, checkpointNumber, timeOfNextL1Slot] - If you can propose, the L2 slot number, checkpoint number and
553
+ * timestamp of the next L1 block
542
554
  * @throws otherwise
543
555
  */
544
556
  public async canProposeAtNextEthBlock(
545
557
  archive: Buffer,
546
558
  account: `0x${string}` | Account,
547
- slotDuration: bigint | number,
548
- opts: { forcePendingBlockNumber?: number } = {},
549
- ): Promise<{ slot: bigint; blockNumber: bigint; timeOfNextL1Slot: bigint }> {
550
- if (typeof slotDuration === 'number') {
551
- slotDuration = BigInt(slotDuration);
552
- }
559
+ slotDuration: number,
560
+ opts: { forcePendingCheckpointNumber?: CheckpointNumber } = {},
561
+ ): Promise<{ slot: SlotNumber; checkpointNumber: CheckpointNumber; timeOfNextL1Slot: bigint }> {
553
562
  const latestBlock = await this.client.getBlock();
554
- const timeOfNextL1Slot = latestBlock.timestamp + slotDuration;
563
+ const timeOfNextL1Slot = latestBlock.timestamp + BigInt(slotDuration);
555
564
  const who = typeof account === 'string' ? account : account.address;
556
565
 
557
566
  try {
558
567
  const {
559
- result: [slot, blockNumber],
568
+ result: [slot, checkpointNumber],
560
569
  } = await this.client.simulateContract({
561
570
  address: this.address,
562
571
  abi: RollupAbi,
563
572
  functionName: 'canProposeAtTime',
564
573
  args: [timeOfNextL1Slot, `0x${archive.toString('hex')}`, who],
565
574
  account,
566
- stateOverride: await this.makePendingBlockNumberOverride(opts.forcePendingBlockNumber),
575
+ stateOverride: await this.makePendingCheckpointNumberOverride(opts.forcePendingCheckpointNumber),
567
576
  });
568
577
 
569
- return { slot, blockNumber, timeOfNextL1Slot };
578
+ return {
579
+ slot: SlotNumber.fromBigInt(slot),
580
+ checkpointNumber: CheckpointNumber.fromBigInt(checkpointNumber),
581
+ timeOfNextL1Slot,
582
+ };
570
583
  } catch (err: unknown) {
571
584
  throw formatViemError(err);
572
585
  }
573
586
  }
574
587
 
575
588
  /**
576
- * Returns a state override that sets the pending block number to the specified value. Useful for simulations.
577
- * Requires querying the current state of the contract to get the current proven block number, as they are both
589
+ * Returns a state override that sets the pending checkpoint number to the specified value. Useful for simulations.
590
+ * Requires querying the current state of the contract to get the current proven checkpoint number, as they are both
578
591
  * stored in the same slot. If the argument is undefined, it returns an empty override.
579
592
  */
580
- public async makePendingBlockNumberOverride(forcePendingBlockNumber: number | undefined): Promise<StateOverride> {
581
- if (forcePendingBlockNumber === undefined) {
593
+ public async makePendingCheckpointNumberOverride(
594
+ forcePendingCheckpointNumber: CheckpointNumber | undefined,
595
+ ): Promise<StateOverride> {
596
+ if (forcePendingCheckpointNumber === undefined) {
582
597
  return [];
583
598
  }
584
599
  const slot = RollupContract.stfStorageSlot;
585
600
  const currentValue = await this.client.getStorageAt({ address: this.address, slot });
586
- const currentProvenBlockNumber = currentValue ? hexToBigInt(currentValue) & ((1n << 128n) - 1n) : 0n;
587
- const newValue = (BigInt(forcePendingBlockNumber) << 128n) | currentProvenBlockNumber;
601
+ const currentProvenCheckpointNumber = currentValue ? hexToBigInt(currentValue) & ((1n << 128n) - 1n) : 0n;
602
+ const newValue = (BigInt(forcePendingCheckpointNumber) << 128n) | currentProvenCheckpointNumber;
588
603
  return [
589
604
  {
590
605
  address: this.address,
@@ -595,7 +610,7 @@ export class RollupContract {
595
610
 
596
611
  /** Creates a request to Rollup#invalidateBadAttestation to be simulated or sent */
597
612
  public buildInvalidateBadAttestationRequest(
598
- blockNumber: number,
613
+ checkpointNumber: CheckpointNumber,
599
614
  attestationsAndSigners: ViemCommitteeAttestations,
600
615
  committee: EthAddress[],
601
616
  invalidIndex: number,
@@ -606,7 +621,7 @@ export class RollupContract {
606
621
  abi: RollupAbi,
607
622
  functionName: 'invalidateBadAttestation',
608
623
  args: [
609
- BigInt(blockNumber),
624
+ BigInt(checkpointNumber),
610
625
  attestationsAndSigners,
611
626
  committee.map(addr => addr.toString()),
612
627
  BigInt(invalidIndex),
@@ -617,7 +632,7 @@ export class RollupContract {
617
632
 
618
633
  /** Creates a request to Rollup#invalidateInsufficientAttestations to be simulated or sent */
619
634
  public buildInvalidateInsufficientAttestationsRequest(
620
- blockNumber: number,
635
+ checkpointNumber: CheckpointNumber,
621
636
  attestationsAndSigners: ViemCommitteeAttestations,
622
637
  committee: EthAddress[],
623
638
  ): L1TxRequest {
@@ -626,30 +641,30 @@ export class RollupContract {
626
641
  data: encodeFunctionData({
627
642
  abi: RollupAbi,
628
643
  functionName: 'invalidateInsufficientAttestations',
629
- args: [BigInt(blockNumber), attestationsAndSigners, committee.map(addr => addr.toString())],
644
+ args: [BigInt(checkpointNumber), attestationsAndSigners, committee.map(addr => addr.toString())],
630
645
  }),
631
646
  };
632
647
  }
633
648
 
634
649
  /** Calls getHasSubmitted directly. Returns whether the given prover has submitted a proof with the given length for the given epoch. */
635
- public getHasSubmittedProof(epochNumber: number, numberOfBlocksInEpoch: number, prover: Hex | EthAddress) {
650
+ public getHasSubmittedProof(epochNumber: EpochNumber, numberOfCheckpointsInEpoch: number, prover: Hex | EthAddress) {
636
651
  if (prover instanceof EthAddress) {
637
652
  prover = prover.toString();
638
653
  }
639
- return this.rollup.read.getHasSubmitted([BigInt(epochNumber), BigInt(numberOfBlocksInEpoch), prover]);
654
+ return this.rollup.read.getHasSubmitted([BigInt(epochNumber), BigInt(numberOfCheckpointsInEpoch), prover]);
640
655
  }
641
656
 
642
657
  getManaBaseFeeAt(timestamp: bigint, inFeeAsset: boolean) {
643
658
  return this.rollup.read.getManaBaseFeeAt([timestamp, inFeeAsset]);
644
659
  }
645
660
 
646
- getSlotAt(timestamp: bigint) {
647
- return this.rollup.read.getSlotAt([timestamp]);
661
+ async getSlotAt(timestamp: bigint): Promise<SlotNumber> {
662
+ return SlotNumber.fromBigInt(await this.rollup.read.getSlotAt([timestamp]));
648
663
  }
649
664
 
650
- async status(blockNumber: bigint, options?: { blockNumber?: bigint }) {
665
+ async status(checkpointNumber: CheckpointNumber, options?: { blockNumber?: bigint }) {
651
666
  await checkBlockTag(options?.blockNumber, this.client);
652
- return this.rollup.read.status([blockNumber], options);
667
+ return this.rollup.read.status([BigInt(checkpointNumber)], options);
653
668
  }
654
669
 
655
670
  async canPruneAtTime(timestamp: bigint, options?: { blockNumber?: bigint }) {
@@ -661,8 +676,8 @@ export class RollupContract {
661
676
  return this.rollup.read.archive();
662
677
  }
663
678
 
664
- archiveAt(blockNumber: bigint) {
665
- return this.rollup.read.archiveAt([blockNumber]);
679
+ archiveAt(checkpointNumber: CheckpointNumber) {
680
+ return this.rollup.read.archiveAt([BigInt(checkpointNumber)]);
666
681
  }
667
682
 
668
683
  getSequencerRewards(address: Hex | EthAddress) {
@@ -704,8 +719,8 @@ export class RollupContract {
704
719
  return this.rollup.read.getStatus([address]);
705
720
  }
706
721
 
707
- getBlobCommitmentsHash(blockNumber: bigint) {
708
- return this.rollup.read.getBlobCommitmentsHash([blockNumber]);
722
+ getBlobCommitmentsHash(checkpointNumber: CheckpointNumber) {
723
+ return this.rollup.read.getBlobCommitmentsHash([BigInt(checkpointNumber)]);
709
724
  }
710
725
 
711
726
  getCurrentBlobCommitmentsHash() {
@@ -760,15 +775,17 @@ export class RollupContract {
760
775
  );
761
776
  }
762
777
 
763
- public listenToBlockInvalidated(callback: (args: { blockNumber: bigint }) => unknown): WatchContractEventReturnType {
764
- return this.rollup.watchEvent.BlockInvalidated(
778
+ public listenToCheckpointInvalidated(
779
+ callback: (args: { checkpointNumber: CheckpointNumber }) => unknown,
780
+ ): WatchContractEventReturnType {
781
+ return this.rollup.watchEvent.CheckpointInvalidated(
765
782
  {},
766
783
  {
767
784
  onLogs: logs => {
768
785
  for (const log of logs) {
769
786
  const args = log.args;
770
- if (args.blockNumber !== undefined) {
771
- callback({ blockNumber: args.blockNumber });
787
+ if (args.checkpointNumber !== undefined) {
788
+ callback({ checkpointNumber: CheckpointNumber.fromBigInt(args.checkpointNumber) });
772
789
  }
773
790
  }
774
791
  },
@@ -1,4 +1,7 @@
1
- import { type L1TxRequest, type ViemClient, tryExtractEvent } from '@aztec/ethereum';
1
+ import type { L1TxRequest } from '@aztec/ethereum/l1-tx-utils';
2
+ import type { ViemClient } from '@aztec/ethereum/types';
3
+ import { tryExtractEvent } from '@aztec/ethereum/utils';
4
+ import { SlotNumber } from '@aztec/foundation/branded-types';
2
5
  import { Buffer32 } from '@aztec/foundation/buffer';
3
6
  import { EthAddress } from '@aztec/foundation/eth-address';
4
7
  import { Signature } from '@aztec/foundation/eth-signature';
@@ -97,8 +100,8 @@ export class TallySlashingProposerContract {
97
100
  * @param slot - The slot number to check at
98
101
  * @returns Whether the round is ready to execute
99
102
  */
100
- public async isRoundReadyToExecute(round: bigint, slot: bigint): Promise<boolean> {
101
- return await this.contract.read.isRoundReadyToExecute([round, slot]);
103
+ public async isRoundReadyToExecute(round: bigint, slot: SlotNumber): Promise<boolean> {
104
+ return await this.contract.read.isRoundReadyToExecute([round, BigInt(slot)]);
102
105
  }
103
106
 
104
107
  /** Returns the slash actions and payload address for a given round (zero if no slash actions) */
@@ -149,7 +152,7 @@ export class TallySlashingProposerContract {
149
152
  */
150
153
  public async buildVoteRequestFromSigner(
151
154
  votes: Hex,
152
- slot: bigint,
155
+ slot: SlotNumber,
153
156
  signer: (msg: TypedDataDefinition) => Promise<Hex>,
154
157
  ): Promise<L1TxRequest> {
155
158
  const typedData = this.buildVoteTypedData(votes, slot);
@@ -166,7 +169,7 @@ export class TallySlashingProposerContract {
166
169
  }
167
170
 
168
171
  /** Returns the typed data definition to EIP712-sign for voting */
169
- public buildVoteTypedData(votes: Hex, slot: bigint): TypedDataDefinition {
172
+ public buildVoteTypedData(votes: Hex, slot: SlotNumber): TypedDataDefinition {
170
173
  const domain = {
171
174
  name: 'TallySlashingProposer',
172
175
  version: '1',
@@ -187,12 +190,12 @@ export class TallySlashingProposerContract {
187
190
  ],
188
191
  };
189
192
 
190
- return { domain, types, primaryType: 'Vote', message: { votes, slot } };
193
+ return { domain, types, primaryType: 'Vote', message: { votes, slot: BigInt(slot) } };
191
194
  }
192
195
 
193
196
  /** Gets the digest to sign for voting directly from the contract */
194
- public async getVoteDataDigest(votes: Hex, slot: bigint): Promise<Buffer32> {
195
- return Buffer32.fromString(await this.contract.read.getVoteSignatureDigest([votes, slot]));
197
+ public async getVoteDataDigest(votes: Hex, slot: SlotNumber): Promise<Buffer32> {
198
+ return Buffer32.fromString(await this.contract.read.getVoteSignatureDigest([votes, BigInt(slot)]));
196
199
  }
197
200
 
198
201
  /**