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

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 +70 -65
  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 +21 -20
  78. package/dest/test/chain_monitor.d.ts.map +1 -1
  79. package/dest/test/chain_monitor.js +33 -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 +11 -10
  89. package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
  90. package/dest/test/rollup_cheat_codes.js +36 -38
  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 +71 -78
  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 +47 -47
  112. package/src/test/eth_cheat_codes.ts +7 -1
  113. package/src/test/rollup_cheat_codes.ts +37 -40
  114. package/src/test/start_anvil.ts +2 -0
@@ -1,3 +1,4 @@
1
+ import { 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
+ getCheckpointNumber() {
330
+ return this.rollup.read.getPendingCheckpointNumber();
340
331
  }
341
332
 
342
- getProvenBlockNumber() {
343
- return this.rollup.read.getProvenBlockNumber();
333
+ getProvenCheckpointNumber() {
334
+ return 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,16 @@ 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: bigint | number) {
420
+ return this.rollup.read.getCheckpoint([BigInt(checkpointNumber)]);
430
421
  }
431
422
 
432
423
  getTips() {
433
424
  return this.rollup.read.getTips();
434
425
  }
435
426
 
436
- getTimestampForSlot(slot: bigint) {
437
- return this.rollup.read.getTimestampForSlot([slot]);
427
+ getTimestampForSlot(slot: SlotNumber) {
428
+ return this.rollup.read.getTimestampForSlot([BigInt(slot)]);
438
429
  }
439
430
 
440
431
  getEntryQueueLength() {
@@ -445,16 +436,16 @@ export class RollupContract {
445
436
  return this.rollup.read.getAvailableValidatorFlushes();
446
437
  }
447
438
 
448
- getNextFlushableEpoch() {
449
- return this.rollup.read.getNextFlushableEpoch();
439
+ async getNextFlushableEpoch(): Promise<EpochNumber> {
440
+ return EpochNumber.fromBigInt(await this.rollup.read.getNextFlushableEpoch());
450
441
  }
451
442
 
452
- getCurrentEpochNumber(): Promise<bigint> {
453
- return this.rollup.read.getCurrentEpoch();
443
+ async getCurrentEpochNumber(): Promise<EpochNumber> {
444
+ return EpochNumber.fromBigInt(await this.rollup.read.getCurrentEpoch());
454
445
  }
455
446
 
456
- getEpochNumberForBlock(blockNumber: bigint) {
457
- return this.rollup.read.getEpochForBlock([BigInt(blockNumber)]);
447
+ async getEpochNumberForCheckpoint(checkpointNumber: bigint): Promise<EpochNumber> {
448
+ return EpochNumber.fromBigInt(await this.rollup.read.getEpochForCheckpoint([BigInt(checkpointNumber)]));
458
449
  }
459
450
 
460
451
  async getRollupAddresses(): Promise<L1RollupContractAddresses> {
@@ -494,8 +485,8 @@ export class RollupContract {
494
485
  return EthAddress.fromString(await this.rollup.read.getFeeAssetPortal());
495
486
  }
496
487
 
497
- public async getEpochNumberForSlotNumber(slotNumber: bigint): Promise<bigint> {
498
- return await this.rollup.read.getEpochAtSlot([slotNumber]);
488
+ public async getEpochNumberForSlotNumber(slotNumber: SlotNumber): Promise<EpochNumber> {
489
+ return EpochNumber.fromBigInt(await this.rollup.read.getEpochAtSlot([BigInt(slotNumber)]));
499
490
  }
500
491
 
501
492
  getEpochProofPublicInputs(
@@ -538,53 +529,53 @@ export class RollupContract {
538
529
  * @dev Throws if unable to propose
539
530
  *
540
531
  * @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,
532
+ * @return [slot, checkpointNumber, timeOfNextL1Slot] - If you can propose, the L2 slot number, checkpoint number and
533
+ * timestamp of the next L1 block
542
534
  * @throws otherwise
543
535
  */
544
536
  public async canProposeAtNextEthBlock(
545
537
  archive: Buffer,
546
538
  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
- }
539
+ slotDuration: number,
540
+ opts: { forcePendingCheckpointNumber?: number } = {},
541
+ ): Promise<{ slot: SlotNumber; checkpointNumber: bigint; timeOfNextL1Slot: bigint }> {
553
542
  const latestBlock = await this.client.getBlock();
554
- const timeOfNextL1Slot = latestBlock.timestamp + slotDuration;
543
+ const timeOfNextL1Slot = latestBlock.timestamp + BigInt(slotDuration);
555
544
  const who = typeof account === 'string' ? account : account.address;
556
545
 
557
546
  try {
558
547
  const {
559
- result: [slot, blockNumber],
548
+ result: [slot, checkpointNumber],
560
549
  } = await this.client.simulateContract({
561
550
  address: this.address,
562
551
  abi: RollupAbi,
563
552
  functionName: 'canProposeAtTime',
564
553
  args: [timeOfNextL1Slot, `0x${archive.toString('hex')}`, who],
565
554
  account,
566
- stateOverride: await this.makePendingBlockNumberOverride(opts.forcePendingBlockNumber),
555
+ stateOverride: await this.makePendingCheckpointNumberOverride(opts.forcePendingCheckpointNumber),
567
556
  });
568
557
 
569
- return { slot, blockNumber, timeOfNextL1Slot };
558
+ return { slot: SlotNumber.fromBigInt(slot), checkpointNumber, timeOfNextL1Slot };
570
559
  } catch (err: unknown) {
571
560
  throw formatViemError(err);
572
561
  }
573
562
  }
574
563
 
575
564
  /**
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
565
+ * Returns a state override that sets the pending checkpoint number to the specified value. Useful for simulations.
566
+ * Requires querying the current state of the contract to get the current proven checkpoint number, as they are both
578
567
  * stored in the same slot. If the argument is undefined, it returns an empty override.
579
568
  */
580
- public async makePendingBlockNumberOverride(forcePendingBlockNumber: number | undefined): Promise<StateOverride> {
581
- if (forcePendingBlockNumber === undefined) {
569
+ public async makePendingCheckpointNumberOverride(
570
+ forcePendingCheckpointNumber: number | undefined,
571
+ ): Promise<StateOverride> {
572
+ if (forcePendingCheckpointNumber === undefined) {
582
573
  return [];
583
574
  }
584
575
  const slot = RollupContract.stfStorageSlot;
585
576
  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;
577
+ const currentProvenCheckpointNumber = currentValue ? hexToBigInt(currentValue) & ((1n << 128n) - 1n) : 0n;
578
+ const newValue = (BigInt(forcePendingCheckpointNumber) << 128n) | currentProvenCheckpointNumber;
588
579
  return [
589
580
  {
590
581
  address: this.address,
@@ -595,7 +586,7 @@ export class RollupContract {
595
586
 
596
587
  /** Creates a request to Rollup#invalidateBadAttestation to be simulated or sent */
597
588
  public buildInvalidateBadAttestationRequest(
598
- blockNumber: number,
589
+ checkpointNumber: number,
599
590
  attestationsAndSigners: ViemCommitteeAttestations,
600
591
  committee: EthAddress[],
601
592
  invalidIndex: number,
@@ -606,7 +597,7 @@ export class RollupContract {
606
597
  abi: RollupAbi,
607
598
  functionName: 'invalidateBadAttestation',
608
599
  args: [
609
- BigInt(blockNumber),
600
+ BigInt(checkpointNumber),
610
601
  attestationsAndSigners,
611
602
  committee.map(addr => addr.toString()),
612
603
  BigInt(invalidIndex),
@@ -617,7 +608,7 @@ export class RollupContract {
617
608
 
618
609
  /** Creates a request to Rollup#invalidateInsufficientAttestations to be simulated or sent */
619
610
  public buildInvalidateInsufficientAttestationsRequest(
620
- blockNumber: number,
611
+ checkpointNumber: number,
621
612
  attestationsAndSigners: ViemCommitteeAttestations,
622
613
  committee: EthAddress[],
623
614
  ): L1TxRequest {
@@ -626,30 +617,30 @@ export class RollupContract {
626
617
  data: encodeFunctionData({
627
618
  abi: RollupAbi,
628
619
  functionName: 'invalidateInsufficientAttestations',
629
- args: [BigInt(blockNumber), attestationsAndSigners, committee.map(addr => addr.toString())],
620
+ args: [BigInt(checkpointNumber), attestationsAndSigners, committee.map(addr => addr.toString())],
630
621
  }),
631
622
  };
632
623
  }
633
624
 
634
625
  /** 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) {
626
+ public getHasSubmittedProof(epochNumber: EpochNumber, numberOfCheckpointsInEpoch: number, prover: Hex | EthAddress) {
636
627
  if (prover instanceof EthAddress) {
637
628
  prover = prover.toString();
638
629
  }
639
- return this.rollup.read.getHasSubmitted([BigInt(epochNumber), BigInt(numberOfBlocksInEpoch), prover]);
630
+ return this.rollup.read.getHasSubmitted([BigInt(epochNumber), BigInt(numberOfCheckpointsInEpoch), prover]);
640
631
  }
641
632
 
642
633
  getManaBaseFeeAt(timestamp: bigint, inFeeAsset: boolean) {
643
634
  return this.rollup.read.getManaBaseFeeAt([timestamp, inFeeAsset]);
644
635
  }
645
636
 
646
- getSlotAt(timestamp: bigint) {
647
- return this.rollup.read.getSlotAt([timestamp]);
637
+ async getSlotAt(timestamp: bigint): Promise<SlotNumber> {
638
+ return SlotNumber.fromBigInt(await this.rollup.read.getSlotAt([timestamp]));
648
639
  }
649
640
 
650
- async status(blockNumber: bigint, options?: { blockNumber?: bigint }) {
641
+ async status(checkpointNumber: bigint, options?: { blockNumber?: bigint }) {
651
642
  await checkBlockTag(options?.blockNumber, this.client);
652
- return this.rollup.read.status([blockNumber], options);
643
+ return this.rollup.read.status([checkpointNumber], options);
653
644
  }
654
645
 
655
646
  async canPruneAtTime(timestamp: bigint, options?: { blockNumber?: bigint }) {
@@ -661,8 +652,8 @@ export class RollupContract {
661
652
  return this.rollup.read.archive();
662
653
  }
663
654
 
664
- archiveAt(blockNumber: bigint) {
665
- return this.rollup.read.archiveAt([blockNumber]);
655
+ archiveAt(checkpointNumber: bigint) {
656
+ return this.rollup.read.archiveAt([checkpointNumber]);
666
657
  }
667
658
 
668
659
  getSequencerRewards(address: Hex | EthAddress) {
@@ -704,8 +695,8 @@ export class RollupContract {
704
695
  return this.rollup.read.getStatus([address]);
705
696
  }
706
697
 
707
- getBlobCommitmentsHash(blockNumber: bigint) {
708
- return this.rollup.read.getBlobCommitmentsHash([blockNumber]);
698
+ getBlobCommitmentsHash(checkpointNumber: bigint) {
699
+ return this.rollup.read.getBlobCommitmentsHash([checkpointNumber]);
709
700
  }
710
701
 
711
702
  getCurrentBlobCommitmentsHash() {
@@ -760,15 +751,17 @@ export class RollupContract {
760
751
  );
761
752
  }
762
753
 
763
- public listenToBlockInvalidated(callback: (args: { blockNumber: bigint }) => unknown): WatchContractEventReturnType {
764
- return this.rollup.watchEvent.BlockInvalidated(
754
+ public listenToCheckpointInvalidated(
755
+ callback: (args: { checkpointNumber: bigint }) => unknown,
756
+ ): WatchContractEventReturnType {
757
+ return this.rollup.watchEvent.CheckpointInvalidated(
765
758
  {},
766
759
  {
767
760
  onLogs: logs => {
768
761
  for (const log of logs) {
769
762
  const args = log.args;
770
- if (args.blockNumber !== undefined) {
771
- callback({ blockNumber: args.blockNumber });
763
+ if (args.checkpointNumber !== undefined) {
764
+ callback({ checkpointNumber: args.checkpointNumber });
772
765
  }
773
766
  }
774
767
  },
@@ -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) {
package/src/queries.ts CHANGED
@@ -33,7 +33,8 @@ export async function getL1ContractsConfig(
33
33
  aztecSlotDuration,
34
34
  aztecProofSubmissionEpochs,
35
35
  aztecTargetCommitteeSize,
36
- lagInEpochs,
36
+ lagInEpochsForValidatorSet,
37
+ lagInEpochsForRandao,
37
38
  activationThreshold,
38
39
  ejectionThreshold,
39
40
  localEjectionThreshold,
@@ -59,7 +60,8 @@ export async function getL1ContractsConfig(
59
60
  rollup.getSlotDuration(),
60
61
  rollup.getProofSubmissionEpochs(),
61
62
  rollup.getTargetCommitteeSize(),
62
- rollup.getLagInEpochs(),
63
+ rollup.getLagInEpochsForValidatorSet(),
64
+ rollup.getLagInEpochsForRandao(),
63
65
  rollup.getActivationThreshold(),
64
66
  rollup.getEjectionThreshold(),
65
67
  rollup.getLocalEjectionThreshold(),
@@ -87,7 +89,8 @@ export async function getL1ContractsConfig(
87
89
  aztecSlotDuration: Number(aztecSlotDuration),
88
90
  aztecProofSubmissionEpochs: Number(aztecProofSubmissionEpochs),
89
91
  aztecTargetCommitteeSize: Number(aztecTargetCommitteeSize),
90
- lagInEpochs: Number(lagInEpochs),
92
+ lagInEpochsForValidatorSet: Number(lagInEpochsForValidatorSet),
93
+ lagInEpochsForRandao: Number(lagInEpochsForRandao),
91
94
  governanceProposerQuorum: Number(governanceProposerQuorum),
92
95
  governanceProposerRoundSize: Number(governanceProposerRoundSize),
93
96
  activationThreshold,