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

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 (114) 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/config.d.ts +7 -4
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +13 -7
  7. package/dest/constants.d.ts +1 -1
  8. package/dest/contracts/empire_base.d.ts +6 -5
  9. package/dest/contracts/empire_base.d.ts.map +1 -1
  10. package/dest/contracts/empire_base.js +1 -1
  11. package/dest/contracts/empire_slashing_proposer.d.ts +5 -4
  12. package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -1
  13. package/dest/contracts/empire_slashing_proposer.js +8 -2
  14. package/dest/contracts/errors.d.ts +1 -1
  15. package/dest/contracts/errors.d.ts.map +1 -1
  16. package/dest/contracts/fee_asset_handler.d.ts +1 -1
  17. package/dest/contracts/fee_asset_handler.d.ts.map +1 -1
  18. package/dest/contracts/fee_juice.d.ts +1 -1
  19. package/dest/contracts/fee_juice.d.ts.map +1 -1
  20. package/dest/contracts/governance.d.ts +16 -16
  21. package/dest/contracts/governance.d.ts.map +1 -1
  22. package/dest/contracts/governance_proposer.d.ts +5 -4
  23. package/dest/contracts/governance_proposer.d.ts.map +1 -1
  24. package/dest/contracts/governance_proposer.js +8 -2
  25. package/dest/contracts/gse.d.ts +1 -1
  26. package/dest/contracts/gse.d.ts.map +1 -1
  27. package/dest/contracts/inbox.d.ts +1 -1
  28. package/dest/contracts/inbox.d.ts.map +1 -1
  29. package/dest/contracts/index.d.ts +1 -1
  30. package/dest/contracts/multicall.d.ts +2 -2
  31. package/dest/contracts/multicall.d.ts.map +1 -1
  32. package/dest/contracts/registry.d.ts +1 -1
  33. package/dest/contracts/registry.d.ts.map +1 -1
  34. package/dest/contracts/rollup.d.ts +55 -64
  35. package/dest/contracts/rollup.d.ts.map +1 -1
  36. package/dest/contracts/rollup.js +76 -67
  37. package/dest/contracts/slasher_contract.d.ts +1 -1
  38. package/dest/contracts/slasher_contract.d.ts.map +1 -1
  39. package/dest/contracts/tally_slashing_proposer.d.ts +7 -6
  40. package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -1
  41. package/dest/contracts/tally_slashing_proposer.js +3 -3
  42. package/dest/contracts/utils.d.ts +1 -1
  43. package/dest/deploy_l1_contracts.d.ts +455 -8
  44. package/dest/deploy_l1_contracts.d.ts.map +1 -1
  45. package/dest/deploy_l1_contracts.js +51 -33
  46. package/dest/eth-signer/eth-signer.d.ts +1 -1
  47. package/dest/eth-signer/index.d.ts +1 -1
  48. package/dest/index.d.ts +1 -1
  49. package/dest/l1_artifacts.d.ts +2020 -860
  50. package/dest/l1_artifacts.d.ts.map +1 -1
  51. package/dest/l1_contract_addresses.d.ts +3 -3
  52. package/dest/l1_reader.d.ts +1 -1
  53. package/dest/l1_tx_utils/config.d.ts +3 -3
  54. package/dest/l1_tx_utils/config.d.ts.map +1 -1
  55. package/dest/l1_tx_utils/config.js +13 -4
  56. package/dest/l1_tx_utils/constants.d.ts +1 -1
  57. package/dest/l1_tx_utils/factory.d.ts +1 -1
  58. package/dest/l1_tx_utils/index.d.ts +1 -1
  59. package/dest/l1_tx_utils/interfaces.d.ts +1 -1
  60. package/dest/l1_tx_utils/l1_tx_utils.d.ts +1 -2
  61. package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
  62. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +1 -1
  63. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +1 -1
  64. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +16 -16
  65. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
  66. package/dest/l1_tx_utils/readonly_l1_tx_utils.js +3 -4
  67. package/dest/l1_tx_utils/signer.d.ts +1 -1
  68. package/dest/l1_tx_utils/types.d.ts +1 -1
  69. package/dest/l1_tx_utils/types.d.ts.map +1 -1
  70. package/dest/l1_tx_utils/utils.d.ts +1 -1
  71. package/dest/l1_types.d.ts +1 -1
  72. package/dest/publisher_manager.d.ts +1 -1
  73. package/dest/publisher_manager.d.ts.map +1 -1
  74. package/dest/queries.d.ts +1 -1
  75. package/dest/queries.d.ts.map +1 -1
  76. package/dest/queries.js +5 -3
  77. package/dest/test/chain_monitor.d.ts +26 -23
  78. package/dest/test/chain_monitor.d.ts.map +1 -1
  79. package/dest/test/chain_monitor.js +32 -34
  80. package/dest/test/delayed_tx_utils.d.ts +1 -1
  81. package/dest/test/delayed_tx_utils.d.ts.map +1 -1
  82. package/dest/test/eth_cheat_codes.d.ts +8 -12
  83. package/dest/test/eth_cheat_codes.d.ts.map +1 -1
  84. package/dest/test/eth_cheat_codes.js +8 -2
  85. package/dest/test/eth_cheat_codes_with_state.d.ts +1 -1
  86. package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -1
  87. package/dest/test/index.d.ts +1 -1
  88. package/dest/test/rollup_cheat_codes.d.ts +13 -12
  89. package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
  90. package/dest/test/rollup_cheat_codes.js +38 -36
  91. package/dest/test/start_anvil.d.ts +2 -1
  92. package/dest/test/start_anvil.d.ts.map +1 -1
  93. package/dest/test/start_anvil.js +2 -1
  94. package/dest/test/tx_delayer.d.ts +1 -1
  95. package/dest/test/upgrade_utils.d.ts +1 -1
  96. package/dest/types.d.ts +1 -1
  97. package/dest/utils.d.ts +1 -1
  98. package/dest/utils.d.ts.map +1 -1
  99. package/dest/zkPassportVerifierAddress.d.ts +1 -1
  100. package/package.json +10 -9
  101. package/src/config.ts +16 -8
  102. package/src/contracts/empire_base.ts +6 -5
  103. package/src/contracts/empire_slashing_proposer.ts +11 -5
  104. package/src/contracts/governance_proposer.ts +11 -5
  105. package/src/contracts/rollup.ts +81 -80
  106. package/src/contracts/tally_slashing_proposer.ts +8 -7
  107. package/src/deploy_l1_contracts.ts +55 -35
  108. package/src/l1_tx_utils/config.ts +9 -6
  109. package/src/l1_tx_utils/readonly_l1_tx_utils.ts +3 -4
  110. package/src/queries.ts +6 -3
  111. package/src/test/chain_monitor.ts +48 -47
  112. package/src/test/eth_cheat_codes.ts +7 -1
  113. package/src/test/rollup_cheat_codes.ts +41 -40
  114. package/src/test/start_anvil.ts +2 -0
@@ -1,3 +1,4 @@
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';
@@ -61,6 +62,7 @@ export type EpochProofPublicInputArgs = {
61
62
 
62
63
  export type ViemHeader = {
63
64
  lastArchiveRoot: `0x${string}`;
65
+ blockHeadersHash: `0x${string}`;
64
66
  contentCommitment: ViemContentCommitment;
65
67
  slotNumber: bigint;
66
68
  timestamp: bigint;
@@ -81,22 +83,6 @@ export type ViemGasFees = {
81
83
  feePerL2Gas: bigint;
82
84
  };
83
85
 
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
86
  export enum SlashingProposerType {
101
87
  None = 0,
102
88
  Tally = 1,
@@ -207,8 +193,8 @@ export class RollupContract {
207
193
  }
208
194
 
209
195
  @memoize
210
- getSlotDuration() {
211
- return this.rollup.read.getSlotDuration();
196
+ async getSlotDuration(): Promise<number> {
197
+ return Number(await this.rollup.read.getSlotDuration());
212
198
  }
213
199
 
214
200
  @memoize
@@ -227,8 +213,13 @@ export class RollupContract {
227
213
  }
228
214
 
229
215
  @memoize
230
- getLagInEpochs() {
231
- return this.rollup.read.getLagInEpochs();
216
+ getLagInEpochsForValidatorSet() {
217
+ return this.rollup.read.getLagInEpochsForValidatorSet();
218
+ }
219
+
220
+ @memoize
221
+ getLagInEpochsForRandao() {
222
+ return this.rollup.read.getLagInEpochsForRandao();
232
223
  }
233
224
 
234
225
  @memoize
@@ -294,7 +285,7 @@ export class RollupContract {
294
285
  return {
295
286
  l1StartBlock,
296
287
  l1GenesisTime,
297
- slotDuration: Number(slotDuration),
288
+ slotDuration,
298
289
  epochDuration: Number(epochDuration),
299
290
  proofSubmissionEpochs: Number(proofSubmissionEpochs),
300
291
  };
@@ -331,20 +322,20 @@ export class RollupContract {
331
322
  return await slasher.getProposer();
332
323
  }
333
324
 
334
- getBlockReward() {
335
- return this.rollup.read.getBlockReward();
325
+ getCheckpointReward() {
326
+ return this.rollup.read.getCheckpointReward();
336
327
  }
337
328
 
338
- getBlockNumber() {
339
- return this.rollup.read.getPendingBlockNumber();
329
+ async getCheckpointNumber(): Promise<CheckpointNumber> {
330
+ return CheckpointNumber.fromBigInt(await this.rollup.read.getPendingCheckpointNumber());
340
331
  }
341
332
 
342
- getProvenBlockNumber() {
343
- return this.rollup.read.getProvenBlockNumber();
333
+ async getProvenCheckpointNumber(): Promise<CheckpointNumber> {
334
+ return CheckpointNumber.fromBigInt(await this.rollup.read.getProvenCheckpointNumber());
344
335
  }
345
336
 
346
- getSlotNumber() {
347
- return this.rollup.read.getCurrentSlot();
337
+ async getSlotNumber(): Promise<SlotNumber> {
338
+ return SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
348
339
  }
349
340
 
350
341
  getL1FeesAt(timestamp: bigint) {
@@ -381,8 +372,8 @@ export class RollupContract {
381
372
  return this.rollup.read.getCurrentSampleSeed();
382
373
  }
383
374
 
384
- getCurrentEpoch() {
385
- return this.rollup.read.getCurrentEpoch();
375
+ async getCurrentEpoch(): Promise<EpochNumber> {
376
+ return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
386
377
  }
387
378
 
388
379
  async getCurrentEpochCommittee(): Promise<readonly `0x${string}`[] | undefined> {
@@ -425,16 +416,20 @@ export class RollupContract {
425
416
  return result;
426
417
  }
427
418
 
428
- getBlock(blockNumber: bigint | number) {
429
- return this.rollup.read.getBlock([BigInt(blockNumber)]);
419
+ getCheckpoint(checkpointNumber: CheckpointNumber) {
420
+ return this.rollup.read.getCheckpoint([BigInt(checkpointNumber)]);
430
421
  }
431
422
 
432
- getTips() {
433
- return this.rollup.read.getTips();
423
+ async getTips(): Promise<{ pending: CheckpointNumber; proven: CheckpointNumber }> {
424
+ const { pending, proven } = await this.rollup.read.getTips();
425
+ return {
426
+ pending: CheckpointNumber.fromBigInt(pending),
427
+ proven: CheckpointNumber.fromBigInt(proven),
428
+ };
434
429
  }
435
430
 
436
- getTimestampForSlot(slot: bigint) {
437
- return this.rollup.read.getTimestampForSlot([slot]);
431
+ getTimestampForSlot(slot: SlotNumber) {
432
+ return this.rollup.read.getTimestampForSlot([BigInt(slot)]);
438
433
  }
439
434
 
440
435
  getEntryQueueLength() {
@@ -445,16 +440,16 @@ export class RollupContract {
445
440
  return this.rollup.read.getAvailableValidatorFlushes();
446
441
  }
447
442
 
448
- getNextFlushableEpoch() {
449
- return this.rollup.read.getNextFlushableEpoch();
443
+ async getNextFlushableEpoch(): Promise<EpochNumber> {
444
+ return EpochNumber.fromBigInt(await this.rollup.read.getNextFlushableEpoch());
450
445
  }
451
446
 
452
- getCurrentEpochNumber(): Promise<bigint> {
453
- return this.rollup.read.getCurrentEpoch();
447
+ async getCurrentEpochNumber(): Promise<EpochNumber> {
448
+ return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
454
449
  }
455
450
 
456
- getEpochNumberForBlock(blockNumber: bigint) {
457
- return this.rollup.read.getEpochForBlock([BigInt(blockNumber)]);
451
+ async getEpochNumberForCheckpoint(checkpointNumber: CheckpointNumber): Promise<EpochNumber> {
452
+ return EpochNumber.fromBigInt(await this.rollup.read.getEpochForCheckpoint([BigInt(checkpointNumber)]));
458
453
  }
459
454
 
460
455
  async getRollupAddresses(): Promise<L1RollupContractAddresses> {
@@ -494,8 +489,8 @@ export class RollupContract {
494
489
  return EthAddress.fromString(await this.rollup.read.getFeeAssetPortal());
495
490
  }
496
491
 
497
- public async getEpochNumberForSlotNumber(slotNumber: bigint): Promise<bigint> {
498
- return await this.rollup.read.getEpochAtSlot([slotNumber]);
492
+ public async getEpochNumberForSlotNumber(slotNumber: SlotNumber): Promise<EpochNumber> {
493
+ return EpochNumber.fromBigInt(await this.rollup.read.getEpochAtSlot([BigInt(slotNumber)]));
499
494
  }
500
495
 
501
496
  getEpochProofPublicInputs(
@@ -538,53 +533,57 @@ export class RollupContract {
538
533
  * @dev Throws if unable to propose
539
534
  *
540
535
  * @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,
536
+ * @return [slot, checkpointNumber, timeOfNextL1Slot] - If you can propose, the L2 slot number, checkpoint number and
537
+ * timestamp of the next L1 block
542
538
  * @throws otherwise
543
539
  */
544
540
  public async canProposeAtNextEthBlock(
545
541
  archive: Buffer,
546
542
  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
- }
543
+ slotDuration: number,
544
+ opts: { forcePendingCheckpointNumber?: CheckpointNumber } = {},
545
+ ): Promise<{ slot: SlotNumber; checkpointNumber: CheckpointNumber; timeOfNextL1Slot: bigint }> {
553
546
  const latestBlock = await this.client.getBlock();
554
- const timeOfNextL1Slot = latestBlock.timestamp + slotDuration;
547
+ const timeOfNextL1Slot = latestBlock.timestamp + BigInt(slotDuration);
555
548
  const who = typeof account === 'string' ? account : account.address;
556
549
 
557
550
  try {
558
551
  const {
559
- result: [slot, blockNumber],
552
+ result: [slot, checkpointNumber],
560
553
  } = await this.client.simulateContract({
561
554
  address: this.address,
562
555
  abi: RollupAbi,
563
556
  functionName: 'canProposeAtTime',
564
557
  args: [timeOfNextL1Slot, `0x${archive.toString('hex')}`, who],
565
558
  account,
566
- stateOverride: await this.makePendingBlockNumberOverride(opts.forcePendingBlockNumber),
559
+ stateOverride: await this.makePendingCheckpointNumberOverride(opts.forcePendingCheckpointNumber),
567
560
  });
568
561
 
569
- return { slot, blockNumber, timeOfNextL1Slot };
562
+ return {
563
+ slot: SlotNumber.fromBigInt(slot),
564
+ checkpointNumber: CheckpointNumber.fromBigInt(checkpointNumber),
565
+ timeOfNextL1Slot,
566
+ };
570
567
  } catch (err: unknown) {
571
568
  throw formatViemError(err);
572
569
  }
573
570
  }
574
571
 
575
572
  /**
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
573
+ * Returns a state override that sets the pending checkpoint number to the specified value. Useful for simulations.
574
+ * Requires querying the current state of the contract to get the current proven checkpoint number, as they are both
578
575
  * stored in the same slot. If the argument is undefined, it returns an empty override.
579
576
  */
580
- public async makePendingBlockNumberOverride(forcePendingBlockNumber: number | undefined): Promise<StateOverride> {
581
- if (forcePendingBlockNumber === undefined) {
577
+ public async makePendingCheckpointNumberOverride(
578
+ forcePendingCheckpointNumber: CheckpointNumber | undefined,
579
+ ): Promise<StateOverride> {
580
+ if (forcePendingCheckpointNumber === undefined) {
582
581
  return [];
583
582
  }
584
583
  const slot = RollupContract.stfStorageSlot;
585
584
  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;
585
+ const currentProvenCheckpointNumber = currentValue ? hexToBigInt(currentValue) & ((1n << 128n) - 1n) : 0n;
586
+ const newValue = (BigInt(forcePendingCheckpointNumber) << 128n) | currentProvenCheckpointNumber;
588
587
  return [
589
588
  {
590
589
  address: this.address,
@@ -595,7 +594,7 @@ export class RollupContract {
595
594
 
596
595
  /** Creates a request to Rollup#invalidateBadAttestation to be simulated or sent */
597
596
  public buildInvalidateBadAttestationRequest(
598
- blockNumber: number,
597
+ checkpointNumber: CheckpointNumber,
599
598
  attestationsAndSigners: ViemCommitteeAttestations,
600
599
  committee: EthAddress[],
601
600
  invalidIndex: number,
@@ -606,7 +605,7 @@ export class RollupContract {
606
605
  abi: RollupAbi,
607
606
  functionName: 'invalidateBadAttestation',
608
607
  args: [
609
- BigInt(blockNumber),
608
+ BigInt(checkpointNumber),
610
609
  attestationsAndSigners,
611
610
  committee.map(addr => addr.toString()),
612
611
  BigInt(invalidIndex),
@@ -617,7 +616,7 @@ export class RollupContract {
617
616
 
618
617
  /** Creates a request to Rollup#invalidateInsufficientAttestations to be simulated or sent */
619
618
  public buildInvalidateInsufficientAttestationsRequest(
620
- blockNumber: number,
619
+ checkpointNumber: CheckpointNumber,
621
620
  attestationsAndSigners: ViemCommitteeAttestations,
622
621
  committee: EthAddress[],
623
622
  ): L1TxRequest {
@@ -626,30 +625,30 @@ export class RollupContract {
626
625
  data: encodeFunctionData({
627
626
  abi: RollupAbi,
628
627
  functionName: 'invalidateInsufficientAttestations',
629
- args: [BigInt(blockNumber), attestationsAndSigners, committee.map(addr => addr.toString())],
628
+ args: [BigInt(checkpointNumber), attestationsAndSigners, committee.map(addr => addr.toString())],
630
629
  }),
631
630
  };
632
631
  }
633
632
 
634
633
  /** 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) {
634
+ public getHasSubmittedProof(epochNumber: EpochNumber, numberOfCheckpointsInEpoch: number, prover: Hex | EthAddress) {
636
635
  if (prover instanceof EthAddress) {
637
636
  prover = prover.toString();
638
637
  }
639
- return this.rollup.read.getHasSubmitted([BigInt(epochNumber), BigInt(numberOfBlocksInEpoch), prover]);
638
+ return this.rollup.read.getHasSubmitted([BigInt(epochNumber), BigInt(numberOfCheckpointsInEpoch), prover]);
640
639
  }
641
640
 
642
641
  getManaBaseFeeAt(timestamp: bigint, inFeeAsset: boolean) {
643
642
  return this.rollup.read.getManaBaseFeeAt([timestamp, inFeeAsset]);
644
643
  }
645
644
 
646
- getSlotAt(timestamp: bigint) {
647
- return this.rollup.read.getSlotAt([timestamp]);
645
+ async getSlotAt(timestamp: bigint): Promise<SlotNumber> {
646
+ return SlotNumber.fromBigInt(await this.rollup.read.getSlotAt([timestamp]));
648
647
  }
649
648
 
650
- async status(blockNumber: bigint, options?: { blockNumber?: bigint }) {
649
+ async status(checkpointNumber: CheckpointNumber, options?: { blockNumber?: bigint }) {
651
650
  await checkBlockTag(options?.blockNumber, this.client);
652
- return this.rollup.read.status([blockNumber], options);
651
+ return this.rollup.read.status([BigInt(checkpointNumber)], options);
653
652
  }
654
653
 
655
654
  async canPruneAtTime(timestamp: bigint, options?: { blockNumber?: bigint }) {
@@ -661,8 +660,8 @@ export class RollupContract {
661
660
  return this.rollup.read.archive();
662
661
  }
663
662
 
664
- archiveAt(blockNumber: bigint) {
665
- return this.rollup.read.archiveAt([blockNumber]);
663
+ archiveAt(checkpointNumber: CheckpointNumber) {
664
+ return this.rollup.read.archiveAt([BigInt(checkpointNumber)]);
666
665
  }
667
666
 
668
667
  getSequencerRewards(address: Hex | EthAddress) {
@@ -704,8 +703,8 @@ export class RollupContract {
704
703
  return this.rollup.read.getStatus([address]);
705
704
  }
706
705
 
707
- getBlobCommitmentsHash(blockNumber: bigint) {
708
- return this.rollup.read.getBlobCommitmentsHash([blockNumber]);
706
+ getBlobCommitmentsHash(checkpointNumber: CheckpointNumber) {
707
+ return this.rollup.read.getBlobCommitmentsHash([BigInt(checkpointNumber)]);
709
708
  }
710
709
 
711
710
  getCurrentBlobCommitmentsHash() {
@@ -760,15 +759,17 @@ export class RollupContract {
760
759
  );
761
760
  }
762
761
 
763
- public listenToBlockInvalidated(callback: (args: { blockNumber: bigint }) => unknown): WatchContractEventReturnType {
764
- return this.rollup.watchEvent.BlockInvalidated(
762
+ public listenToCheckpointInvalidated(
763
+ callback: (args: { checkpointNumber: CheckpointNumber }) => unknown,
764
+ ): WatchContractEventReturnType {
765
+ return this.rollup.watchEvent.CheckpointInvalidated(
765
766
  {},
766
767
  {
767
768
  onLogs: logs => {
768
769
  for (const log of logs) {
769
770
  const args = log.args;
770
- if (args.blockNumber !== undefined) {
771
- callback({ blockNumber: args.blockNumber });
771
+ if (args.checkpointNumber !== undefined) {
772
+ callback({ checkpointNumber: CheckpointNumber.fromBigInt(args.checkpointNumber) });
772
773
  }
773
774
  }
774
775
  },
@@ -1,4 +1,5 @@
1
1
  import { type L1TxRequest, type ViemClient, tryExtractEvent } from '@aztec/ethereum';
2
+ import { SlotNumber } from '@aztec/foundation/branded-types';
2
3
  import { Buffer32 } from '@aztec/foundation/buffer';
3
4
  import { EthAddress } from '@aztec/foundation/eth-address';
4
5
  import { Signature } from '@aztec/foundation/eth-signature';
@@ -97,8 +98,8 @@ export class TallySlashingProposerContract {
97
98
  * @param slot - The slot number to check at
98
99
  * @returns Whether the round is ready to execute
99
100
  */
100
- public async isRoundReadyToExecute(round: bigint, slot: bigint): Promise<boolean> {
101
- return await this.contract.read.isRoundReadyToExecute([round, slot]);
101
+ public async isRoundReadyToExecute(round: bigint, slot: SlotNumber): Promise<boolean> {
102
+ return await this.contract.read.isRoundReadyToExecute([round, BigInt(slot)]);
102
103
  }
103
104
 
104
105
  /** Returns the slash actions and payload address for a given round (zero if no slash actions) */
@@ -149,7 +150,7 @@ export class TallySlashingProposerContract {
149
150
  */
150
151
  public async buildVoteRequestFromSigner(
151
152
  votes: Hex,
152
- slot: bigint,
153
+ slot: SlotNumber,
153
154
  signer: (msg: TypedDataDefinition) => Promise<Hex>,
154
155
  ): Promise<L1TxRequest> {
155
156
  const typedData = this.buildVoteTypedData(votes, slot);
@@ -166,7 +167,7 @@ export class TallySlashingProposerContract {
166
167
  }
167
168
 
168
169
  /** Returns the typed data definition to EIP712-sign for voting */
169
- public buildVoteTypedData(votes: Hex, slot: bigint): TypedDataDefinition {
170
+ public buildVoteTypedData(votes: Hex, slot: SlotNumber): TypedDataDefinition {
170
171
  const domain = {
171
172
  name: 'TallySlashingProposer',
172
173
  version: '1',
@@ -187,12 +188,12 @@ export class TallySlashingProposerContract {
187
188
  ],
188
189
  };
189
190
 
190
- return { domain, types, primaryType: 'Vote', message: { votes, slot } };
191
+ return { domain, types, primaryType: 'Vote', message: { votes, slot: BigInt(slot) } };
191
192
  }
192
193
 
193
194
  /** 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]));
195
+ public async getVoteDataDigest(votes: Hex, slot: SlotNumber): Promise<Buffer32> {
196
+ return Buffer32.fromString(await this.contract.read.getVoteSignatureDigest([votes, BigInt(slot)]));
196
197
  }
197
198
 
198
199
  /**
@@ -1,4 +1,5 @@
1
1
  import { L1_TO_L2_MSG_SUBTREE_HEIGHT } from '@aztec/constants';
2
+ import { SlotNumber } from '@aztec/foundation/branded-types';
2
3
  import { SecretValue, getActiveNetworkName } from '@aztec/foundation/config';
3
4
  import { keccak256String } from '@aztec/foundation/crypto';
4
5
  import { EthAddress } from '@aztec/foundation/eth-address';
@@ -277,14 +278,22 @@ export const deploySharedContracts = async (
277
278
  logger.verbose(`Deployed Fee Asset at ${feeAssetAddress}`);
278
279
 
279
280
  // Mint a tiny bit of tokens to satisfy coin-issuer constraints
280
- const { txHash } = await deployer.sendTransaction({
281
- to: feeAssetAddress.toString(),
282
- data: encodeFunctionData({
283
- abi: FeeAssetArtifact.contractAbi,
284
- functionName: 'mint',
285
- args: [l1Client.account.address, 1n * 10n ** 18n],
286
- }),
287
- });
281
+ const { txHash } = await deployer.sendTransaction(
282
+ {
283
+ to: feeAssetAddress.toString(),
284
+ data: encodeFunctionData({
285
+ abi: FeeAssetArtifact.contractAbi,
286
+ functionName: 'mint',
287
+ args: [l1Client.account.address, 1n * 10n ** 18n],
288
+ }),
289
+ },
290
+ {
291
+ // contract may not have been deployed yet (CREATE2 returns address before mining),
292
+ // which causes gas estimation to fail. Hardcode to 100k which is plenty for ERC20 mint.
293
+ gasLimit: 100_000n,
294
+ },
295
+ );
296
+ await l1Client.waitForTransactionReceipt({ hash: txHash });
288
297
  logger.verbose(`Minted tiny bit of tokens to satisfy coin-issuer constraints in ${txHash}`);
289
298
 
290
299
  const deployedStaking = await deployer.deploy(StakingAssetArtifact, ['Staking', 'STK', l1Client.account.address]);
@@ -362,12 +371,19 @@ export const deploySharedContracts = async (
362
371
  txHashes.push(txHash);
363
372
  }
364
373
 
374
+ logger.verbose(`Waiting for deployments to complete`);
375
+ await deployer.waitForDeployments();
376
+
365
377
  const coinIssuerAddress = (
366
- await deployer.deploy(CoinIssuerArtifact, [
367
- feeAssetAddress.toString(),
368
- 2n * 10n ** 17n, // hard cap of 20% per year
369
- l1Client.account.address,
370
- ])
378
+ await deployer.deploy(
379
+ CoinIssuerArtifact,
380
+ [
381
+ feeAssetAddress.toString(),
382
+ 2n * 10n ** 17n, // hard cap of 20% per year
383
+ l1Client.account.address,
384
+ ],
385
+ { gasLimit: 1_000_000n, noSimulation: true },
386
+ )
371
387
  ).address;
372
388
  logger.verbose(`Deployed CoinIssuer at ${coinIssuerAddress}`);
373
389
 
@@ -386,17 +402,16 @@ export const deploySharedContracts = async (
386
402
  /* CHEAT CODES START HERE */
387
403
  /* -------------------------------------------------------------------------- */
388
404
 
389
- feeAssetHandlerAddress = (
390
- await deployer.deploy(FeeAssetHandlerArtifact, [
391
- l1Client.account.address,
392
- feeAssetAddress.toString(),
393
- BigInt(1000n * 10n ** 18n),
394
- ])
395
- ).address;
405
+ const deployedFeeAssetHandler = await deployer.deploy(FeeAssetHandlerArtifact, [
406
+ l1Client.account.address,
407
+ feeAssetAddress.toString(),
408
+ BigInt(1000n * 10n ** 18n),
409
+ ]);
410
+ feeAssetHandlerAddress = deployedFeeAssetHandler.address;
396
411
  logger.verbose(`Deployed FeeAssetHandler at ${feeAssetHandlerAddress}`);
397
412
 
398
- // Only if we are "fresh" will we be adding as a minter, otherwise above will simply get same address
399
- if (needToSetGovernance) {
413
+ // Only add as minter if this is a new deployment (not reusing existing handler from failed previous run)
414
+ if (!deployedFeeAssetHandler.existed) {
400
415
  const { txHash } = await deployer.sendTransaction({
401
416
  to: feeAssetAddress.toString(),
402
417
  data: encodeFunctionData({
@@ -473,9 +488,9 @@ export const deploySharedContracts = async (
473
488
  const rewardDistributorAddress = await registry.getRewardDistributor();
474
489
 
475
490
  if (!args.existingTokenAddress) {
476
- const blockReward = getRewardConfig(networkName).blockReward;
491
+ const checkpointReward = getRewardConfig(networkName).checkpointReward;
477
492
 
478
- const funding = blockReward * 200000n;
493
+ const funding = checkpointReward * 200000n;
479
494
  const { txHash: fundRewardDistributorTxHash } = await deployer.sendTransaction({
480
495
  to: feeAssetAddress.toString(),
481
496
  data: encodeFunctionData({
@@ -849,7 +864,8 @@ export const deployRollup = async (
849
864
  aztecSlotDuration: BigInt(args.aztecSlotDuration),
850
865
  aztecEpochDuration: BigInt(args.aztecEpochDuration),
851
866
  targetCommitteeSize: BigInt(args.aztecTargetCommitteeSize),
852
- lagInEpochs: BigInt(args.lagInEpochs),
867
+ lagInEpochsForValidatorSet: BigInt(args.lagInEpochsForValidatorSet),
868
+ lagInEpochsForRandao: BigInt(args.lagInEpochsForRandao),
853
869
  aztecProofSubmissionEpochs: BigInt(args.aztecProofSubmissionEpochs),
854
870
  slashingQuorum: BigInt(args.slashingQuorum ?? (args.slashingRoundSizeInEpochs * args.aztecEpochDuration) / 2 + 1),
855
871
  slashingRoundSize: BigInt(args.slashingRoundSizeInEpochs * args.aztecEpochDuration),
@@ -1504,13 +1520,13 @@ export const deployL1Contracts = async (
1504
1520
  // Need to get the time
1505
1521
  const currentSlot = await rollup.getSlotNumber();
1506
1522
 
1507
- if (BigInt(currentSlot) === 0n) {
1508
- const ts = Number(await rollup.getTimestampForSlot(1n));
1523
+ if (currentSlot === 0) {
1524
+ const ts = Number(await rollup.getTimestampForSlot(SlotNumber(1)));
1509
1525
  await rpcCall('evm_setNextBlockTimestamp', [ts]);
1510
1526
  await rpcCall('hardhat_mine', [1]);
1511
1527
  const currentSlot = await rollup.getSlotNumber();
1512
1528
 
1513
- if (BigInt(currentSlot) !== 1n) {
1529
+ if (currentSlot !== 1) {
1514
1530
  throw new Error(`Error jumping time: current slot is ${currentSlot}`);
1515
1531
  }
1516
1532
  logger.info(`Jumped to slot 1`);
@@ -1561,7 +1577,7 @@ export class L1Deployer {
1561
1577
  async deploy<const TAbi extends Abi>(
1562
1578
  params: ContractArtifacts<TAbi>,
1563
1579
  args?: ContractConstructorArgs<TAbi>,
1564
- opts: { gasLimit?: bigint } = {},
1580
+ opts: { gasLimit?: bigint; noSimulation?: boolean } = {},
1565
1581
  ): Promise<{ address: EthAddress; existed: boolean }> {
1566
1582
  this.logger.debug(`Deploying ${params.name} contract`, { args });
1567
1583
  try {
@@ -1577,6 +1593,7 @@ export class L1Deployer {
1577
1593
  l1TxUtils: this.l1TxUtils,
1578
1594
  acceleratedTestDeployments: this.acceleratedTestDeployments,
1579
1595
  gasLimit: opts.gasLimit,
1596
+ noSimulation: opts.noSimulation,
1580
1597
  },
1581
1598
  );
1582
1599
  if (txHash) {
@@ -1666,6 +1683,7 @@ export async function deployL1Contract(
1666
1683
  l1TxUtils?: L1TxUtils;
1667
1684
  gasLimit?: bigint;
1668
1685
  acceleratedTestDeployments?: boolean;
1686
+ noSimulation?: boolean;
1669
1687
  } = {},
1670
1688
  ): Promise<{
1671
1689
  address: EthAddress;
@@ -1677,7 +1695,7 @@ export async function deployL1Contract(
1677
1695
  let resultingAddress: Hex | null | undefined = undefined;
1678
1696
  const deployedLibraries: VerificationLibraryEntry[] = [];
1679
1697
 
1680
- const { salt: saltFromOpts, libraries, logger, gasLimit, acceleratedTestDeployments } = opts;
1698
+ const { salt: saltFromOpts, libraries, logger, gasLimit, acceleratedTestDeployments, noSimulation } = opts;
1681
1699
  let { l1TxUtils } = opts;
1682
1700
 
1683
1701
  if (!l1TxUtils) {
@@ -1786,11 +1804,13 @@ export async function deployL1Contract(
1786
1804
  resultingAddress = address;
1787
1805
  const existing = await extendedClient.getCode({ address: resultingAddress });
1788
1806
  if (existing === undefined || existing === '0x') {
1789
- try {
1790
- await l1TxUtils.simulate({ to: DEPLOYER_ADDRESS, data: concatHex([salt, calldata]), gas: gasLimit });
1791
- } catch (err) {
1792
- logger?.error(`Failed to simulate deployment tx using universal deployer`, err);
1793
- await l1TxUtils.simulate({ to: null, data: encodeDeployData({ abi, bytecode, args }), gas: gasLimit });
1807
+ if (!noSimulation) {
1808
+ try {
1809
+ await l1TxUtils.simulate({ to: DEPLOYER_ADDRESS, data: concatHex([salt, calldata]), gas: gasLimit });
1810
+ } catch (err) {
1811
+ logger?.error(`Failed to simulate deployment tx using universal deployer`, err);
1812
+ await l1TxUtils.simulate({ to: null, data: encodeDeployData({ abi, bytecode, args }), gas: gasLimit });
1813
+ }
1794
1814
  }
1795
1815
  const res = await l1TxUtils.sendTransaction(
1796
1816
  { to: DEPLOYER_ADDRESS, data: concatHex([salt, calldata]) },
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  type ConfigMappingsType,
3
- bigintConfigHelper,
4
3
  booleanConfigHelper,
4
+ floatConfigHelper,
5
5
  getConfigFromMappings,
6
6
  getDefaultConfig,
7
7
  numberConfigHelper,
@@ -15,11 +15,11 @@ export interface L1TxUtilsConfig {
15
15
  /**
16
16
  * Maximum gas price in gwei
17
17
  */
18
- maxGwei?: bigint;
18
+ maxGwei?: number;
19
19
  /**
20
20
  * Maximum blob fee per gas in gwei
21
21
  */
22
- maxBlobGwei?: bigint;
22
+ maxBlobGwei?: number;
23
23
  /**
24
24
  * Priority fee bump percentage
25
25
  */
@@ -71,12 +71,14 @@ export const l1TxUtilsConfigMappings: ConfigMappingsType<L1TxUtilsConfig> = {
71
71
  maxGwei: {
72
72
  description: 'Maximum gas price in gwei to be used for transactions.',
73
73
  env: 'L1_GAS_PRICE_MAX',
74
- ...bigintConfigHelper(2000n),
74
+ fallback: ['L1_FEE_PER_GAS_GWEI_MAX'],
75
+ ...floatConfigHelper(2000),
75
76
  },
76
77
  maxBlobGwei: {
77
78
  description: 'Maximum blob fee per gas in gwei',
78
79
  env: 'L1_BLOB_FEE_PER_GAS_MAX',
79
- ...bigintConfigHelper(3000n),
80
+ fallback: ['L1_BLOB_FEE_PER_GAS_GWEI_MAX'],
81
+ ...floatConfigHelper(3000),
80
82
  },
81
83
  priorityFeeBumpPercentage: {
82
84
  description: 'How much to increase priority fee by each attempt (percentage)',
@@ -91,7 +93,8 @@ export const l1TxUtilsConfigMappings: ConfigMappingsType<L1TxUtilsConfig> = {
91
93
  fixedPriorityFeePerGas: {
92
94
  description: 'Fixed priority fee per gas in Gwei. Overrides any priority fee bump percentage',
93
95
  env: 'L1_FIXED_PRIORITY_FEE_PER_GAS',
94
- ...numberConfigHelper(0),
96
+ fallback: ['L1_FIXED_PRIORITY_FEE_PER_GAS_GWEI'],
97
+ ...floatConfigHelper(0),
95
98
  },
96
99
  maxSpeedUpAttempts: {
97
100
  description: 'Maximum number of speed-up attempts',
@@ -248,8 +248,7 @@ export class ReadOnlyL1TxUtils {
248
248
  this.logger?.debug('Using fixed priority fee per L1 gas', {
249
249
  fixedPriorityFeePerGas: gasConfig.fixedPriorityFeePerGas,
250
250
  });
251
- // try to maintain precision up to 1000000 wei
252
- priorityFee = BigInt(gasConfig.fixedPriorityFeePerGas * 1_000_000) * (WEI_CONST / 1_000_000n);
251
+ priorityFee = BigInt(Math.trunc(gasConfig.fixedPriorityFeePerGas * Number(WEI_CONST)));
253
252
  } else {
254
253
  // Get competitive priority fee (includes network estimate + analysis)
255
254
  priorityFee = this.getCompetitivePriorityFee(networkEstimateResult, pendingBlockResult, feeHistoryResult);
@@ -321,8 +320,8 @@ export class ReadOnlyL1TxUtils {
321
320
  }
322
321
 
323
322
  // maxGwei and maxBlobGwei are hard limits
324
- const effectiveMaxGwei = gasConfig.maxGwei! * WEI_CONST;
325
- const effectiveMaxBlobGwei = gasConfig.maxBlobGwei! * WEI_CONST;
323
+ const effectiveMaxGwei = BigInt(Math.trunc(gasConfig.maxGwei! * Number(WEI_CONST)));
324
+ const effectiveMaxBlobGwei = BigInt(Math.trunc(gasConfig.maxBlobGwei! * Number(WEI_CONST)));
326
325
 
327
326
  // Ensure we don't exceed maxGwei
328
327
  if (effectiveMaxGwei > 0n) {