@aztec/ethereum 0.87.2 → 0.87.3-nightly.20250528

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.
@@ -12,6 +12,8 @@ import {
12
12
  FeeJuicePortalBytecode,
13
13
  ForwarderAbi,
14
14
  ForwarderBytecode,
15
+ GSEAbi,
16
+ GSEBytecode,
15
17
  GovernanceAbi,
16
18
  GovernanceBytecode,
17
19
  GovernanceProposerAbi,
@@ -199,6 +201,10 @@ export const l1Artifacts = {
199
201
  contractAbi: MultiAdderAbi,
200
202
  contractBytecode: MultiAdderBytecode as Hex,
201
203
  },
204
+ gse: {
205
+ contractAbi: GSEAbi,
206
+ contractBytecode: GSEBytecode as Hex,
207
+ },
202
208
  };
203
209
 
204
210
  export interface DeployL1ContractsArgs extends L1ContractsConfig {
@@ -211,7 +217,7 @@ export interface DeployL1ContractsArgs extends L1ContractsConfig {
211
217
  /** The salt for CREATE2 deployment. */
212
218
  salt: number | undefined;
213
219
  /** The initial validators for the rollup contract. */
214
- initialValidators?: EthAddress[];
220
+ initialValidators?: Operator[];
215
221
  /** Configuration for the L1 tx utils module. */
216
222
  l1TxConfig?: Partial<L1TxUtilsConfig>;
217
223
  /** Enable fast mode for deployments (fire and forget transactions) */
@@ -242,6 +248,12 @@ export const deploySharedContracts = async (
242
248
  ]);
243
249
  logger.verbose(`Deployed Staking Asset at ${stakingAssetAddress}`);
244
250
 
251
+ const gseAddress = await deployer.deploy(l1Artifacts.gse, [
252
+ l1Client.account.address.toString(),
253
+ stakingAssetAddress.toString(),
254
+ ]);
255
+ logger.verbose(`Deployed GSE at ${gseAddress}`);
256
+
245
257
  const registryAddress = await deployer.deploy(l1Artifacts.registry, [
246
258
  l1Client.account.address.toString(),
247
259
  feeAssetAddress.toString(),
@@ -410,6 +422,7 @@ export const deploySharedContracts = async (
410
422
  stakingAssetAddress,
411
423
  stakingAssetHandlerAddress,
412
424
  registryAddress,
425
+ gseAddress,
413
426
  governanceAddress,
414
427
  governanceProposerAddress,
415
428
  coinIssuerAddress,
@@ -427,7 +440,7 @@ export const deploySharedContracts = async (
427
440
  */
428
441
  export const deployRollupForUpgrade = async (
429
442
  extendedClient: ExtendedViemWalletClient,
430
- args: Omit<DeployL1ContractsArgs, 'governanceProposerQuorum' | 'governanceProposerRoundSize'>,
443
+ args: Omit<DeployL1ContractsArgs, 'governanceProposerQuorum' | 'governanceProposerRoundSize' | 'minimumStake'>,
431
444
  registryAddress: EthAddress,
432
445
  logger: Logger,
433
446
  txUtilsConfig: L1TxUtilsConfig,
@@ -467,13 +480,17 @@ export const deployUpgradePayload = async (
467
480
  export const deployRollup = async (
468
481
  extendedClient: ExtendedViemWalletClient,
469
482
  deployer: L1Deployer,
470
- args: Omit<DeployL1ContractsArgs, 'governanceProposerQuorum' | 'governanceProposerRoundSize'>,
483
+ args: Omit<DeployL1ContractsArgs, 'governanceProposerQuorum' | 'governanceProposerRoundSize' | 'minimumStake'>,
471
484
  addresses: Pick<
472
485
  L1ContractAddresses,
473
- 'feeJuiceAddress' | 'registryAddress' | 'rewardDistributorAddress' | 'stakingAssetAddress'
486
+ 'feeJuiceAddress' | 'registryAddress' | 'rewardDistributorAddress' | 'stakingAssetAddress' | 'gseAddress'
474
487
  >,
475
488
  logger: Logger,
476
489
  ) => {
490
+ if (!addresses.gseAddress) {
491
+ throw new Error('GSE address is required when deploying');
492
+ }
493
+
477
494
  const txHashes: Hex[] = [];
478
495
 
479
496
  const rollupConfigArgs = {
@@ -481,7 +498,6 @@ export const deployRollup = async (
481
498
  aztecEpochDuration: args.aztecEpochDuration,
482
499
  targetCommitteeSize: args.aztecTargetCommitteeSize,
483
500
  aztecProofSubmissionWindow: args.aztecProofSubmissionWindow,
484
- minimumStake: args.minimumStake,
485
501
  slashingQuorum: args.slashingQuorum,
486
502
  slashingRoundSize: args.slashingRoundSize,
487
503
  manaTarget: args.manaTarget,
@@ -497,6 +513,7 @@ export const deployRollup = async (
497
513
  addresses.feeJuiceAddress.toString(),
498
514
  addresses.rewardDistributorAddress.toString(),
499
515
  addresses.stakingAssetAddress.toString(),
516
+ addresses.gseAddress.toString(),
500
517
  extendedClient.account.address.toString(),
501
518
  genesisStateArgs,
502
519
  rollupConfigArgs,
@@ -510,18 +527,6 @@ export const deployRollup = async (
510
527
  await deployer.waitForDeployments();
511
528
  logger.verbose(`All core contracts have been deployed`);
512
529
 
513
- if (args.initialValidators) {
514
- await cheat_initializeValidatorSet(
515
- extendedClient,
516
- deployer,
517
- rollupAddress.toString(),
518
- addresses.stakingAssetAddress.toString(),
519
- args.initialValidators.map(v => v.toString()),
520
- args.acceleratedTestDeployments,
521
- logger,
522
- );
523
- }
524
-
525
530
  if (args.feeJuicePortalInitialBalance && args.feeJuicePortalInitialBalance > 0n) {
526
531
  const feeJuicePortalAddress = await rollupContract.getFeeJuicePortal();
527
532
 
@@ -575,6 +580,44 @@ export const deployRollup = async (
575
580
  logger.verbose(`Not the owner of the registry, skipping rollup addition`);
576
581
  }
577
582
 
583
+ // We need to call a function on the registry to set the various contract addresses.
584
+ const gseContract = getContract({
585
+ address: getAddress(addresses.gseAddress.toString()),
586
+ abi: l1Artifacts.gse.contractAbi,
587
+ client: extendedClient,
588
+ });
589
+ if ((await gseContract.read.owner()) === getAddress(extendedClient.account.address)) {
590
+ if (!(await gseContract.read.isRollupRegistered([rollupContract.address]))) {
591
+ const { txHash: addRollupTxHash } = await deployer.sendTransaction({
592
+ to: addresses.gseAddress.toString(),
593
+ data: encodeFunctionData({
594
+ abi: l1Artifacts.gse.contractAbi,
595
+ functionName: 'addRollup',
596
+ args: [getAddress(rollupContract.address)],
597
+ }),
598
+ });
599
+ logger.verbose(`Adding rollup ${rollupContract.address} to GSE ${addresses.gseAddress} in tx ${addRollupTxHash}`);
600
+
601
+ txHashes.push(addRollupTxHash);
602
+ } else {
603
+ logger.verbose(`Rollup ${rollupContract.address} is already registered in GSE ${addresses.gseAddress}`);
604
+ }
605
+ } else {
606
+ logger.verbose(`Not the owner of the gse, skipping rollup addition`);
607
+ }
608
+
609
+ if (args.initialValidators && (await gseContract.read.isRollupRegistered([rollupContract.address]))) {
610
+ await addMultipleValidators(
611
+ extendedClient,
612
+ deployer,
613
+ rollupAddress.toString(),
614
+ addresses.stakingAssetAddress.toString(),
615
+ args.initialValidators,
616
+ args.acceleratedTestDeployments,
617
+ logger,
618
+ );
619
+ }
620
+
578
621
  await deployer.waitForDeployments();
579
622
  await Promise.all(txHashes.map(txHash => extendedClient.waitForTransactionReceipt({ hash: txHash })));
580
623
  logger.verbose(`Rollup deployed`);
@@ -586,6 +629,7 @@ export const handoverToGovernance = async (
586
629
  extendedClient: ExtendedViemWalletClient,
587
630
  deployer: L1Deployer,
588
631
  registryAddress: EthAddress,
632
+ gseAddress: EthAddress,
589
633
  governanceAddress: EthAddress,
590
634
  logger: Logger,
591
635
  acceleratedTestDeployments: boolean | undefined,
@@ -597,6 +641,12 @@ export const handoverToGovernance = async (
597
641
  client: extendedClient,
598
642
  });
599
643
 
644
+ const gseContract = getContract({
645
+ address: getAddress(gseAddress.toString()),
646
+ abi: l1Artifacts.gse.contractAbi,
647
+ client: extendedClient,
648
+ });
649
+
600
650
  const txHashes: Hex[] = [];
601
651
 
602
652
  // If the owner is not the Governance contract, transfer ownership to the Governance contract
@@ -619,14 +669,36 @@ export const handoverToGovernance = async (
619
669
  txHashes.push(transferOwnershipTxHash);
620
670
  }
621
671
 
672
+ // If the owner is not the Governance contract, transfer ownership to the Governance contract
673
+ if (acceleratedTestDeployments || (await gseContract.read.owner()) !== getAddress(governanceAddress.toString())) {
674
+ // TODO(md): add send transaction to the deployer such that we do not need to manage tx hashes here
675
+ const { txHash: transferOwnershipTxHash } = await deployer.sendTransaction({
676
+ to: gseContract.address,
677
+ data: encodeFunctionData({
678
+ abi: l1Artifacts.gse.contractAbi,
679
+ functionName: 'transferOwnership',
680
+ args: [getAddress(governanceAddress.toString())],
681
+ }),
682
+ });
683
+ logger.verbose(
684
+ `Transferring the ownership of the gse contract at ${gseAddress} to the Governance ${governanceAddress} in tx ${transferOwnershipTxHash}`,
685
+ );
686
+ txHashes.push(transferOwnershipTxHash);
687
+ }
688
+
622
689
  // Wait for all actions to be mined
623
690
  await deployer.waitForDeployments();
624
691
  await Promise.all(txHashes.map(txHash => extendedClient.waitForTransactionReceipt({ hash: txHash })));
625
692
  };
626
693
 
694
+ export type Operator = {
695
+ attester: Hex | EthAddress;
696
+ proposerEOA: Hex | EthAddress;
697
+ withdrawer: Hex | EthAddress;
698
+ };
699
+
627
700
  /*
628
- * Initialize the validator set for the rollup using a cheat function.
629
- * @note This function will only be used when the chain is local anvil node soon (#12050)
701
+ * Adds multiple validators to the rollup
630
702
  *
631
703
  * @param extendedClient - The L1 clients.
632
704
  * @param deployer - The L1 deployer.
@@ -636,13 +708,12 @@ export const handoverToGovernance = async (
636
708
  * @param acceleratedTestDeployments - Whether to use accelerated test deployments.
637
709
  * @param logger - The logger.
638
710
  */
639
- // eslint-disable-next-line camelcase
640
- export const cheat_initializeValidatorSet = async (
711
+ export const addMultipleValidators = async (
641
712
  extendedClient: ExtendedViemWalletClient,
642
713
  deployer: L1Deployer,
643
714
  rollupAddress: Hex,
644
715
  stakingAssetAddress: Hex,
645
- validators: Hex[],
716
+ validators: Operator[],
646
717
  acceleratedTestDeployments: boolean | undefined,
647
718
  logger: Logger,
648
719
  ) => {
@@ -651,22 +722,22 @@ export const cheat_initializeValidatorSet = async (
651
722
  if (validators && validators.length > 0) {
652
723
  // Check if some of the initial validators are already registered, so we support idempotent deployments
653
724
  if (!acceleratedTestDeployments) {
654
- const validatorsInfo = await Promise.all(
655
- validators.map(async address => ({
656
- address,
657
- ...(await rollup.getInfo(address)),
725
+ const enrichedValidators = await Promise.all(
726
+ validators.map(async operator => ({
727
+ operator,
728
+ status: await rollup.getStatus(operator.attester),
658
729
  })),
659
730
  );
660
- const existingValidators = validatorsInfo.filter(v => v.status !== 0);
731
+ const existingValidators = enrichedValidators.filter(v => v.status !== 0);
661
732
  if (existingValidators.length > 0) {
662
733
  logger.warn(
663
734
  `Validators ${existingValidators
664
- .map(v => v.address)
735
+ .map(v => v.operator.attester)
665
736
  .join(', ')} already exist. Skipping from initialization.`,
666
737
  );
667
738
  }
668
739
 
669
- validators = validatorsInfo.filter(v => v.status === 0).map(v => v.address);
740
+ validators = enrichedValidators.filter(v => v.status === 0).map(v => v.operator);
670
741
  }
671
742
 
672
743
  if (validators.length > 0) {
@@ -676,10 +747,14 @@ export const cheat_initializeValidatorSet = async (
676
747
  ]);
677
748
 
678
749
  const validatorsTuples = validators.map(v => ({
679
- attester: v,
680
- proposer: getExpectedAddress(ForwarderAbi, ForwarderBytecode, [v], v).address,
681
- withdrawer: v,
682
- amount: minimumStake,
750
+ attester: getAddress(v.attester.toString()),
751
+ proposer: getExpectedAddress(
752
+ ForwarderAbi,
753
+ ForwarderBytecode,
754
+ [getAddress(v.proposerEOA.toString())],
755
+ getAddress(v.proposerEOA.toString()),
756
+ ).address,
757
+ withdrawer: getAddress(v.withdrawer.toString()),
683
758
  }));
684
759
 
685
760
  // Mint tokens, approve them, use cheat code to initialise validator set without setting up the epoch.
@@ -799,6 +874,7 @@ export const deployL1Contracts = async (
799
874
  stakingAssetAddress,
800
875
  stakingAssetHandlerAddress,
801
876
  registryAddress,
877
+ gseAddress,
802
878
  rewardDistributorAddress,
803
879
  } = await deploySharedContracts(l1Client, deployer, args, logger);
804
880
  const { rollup, slashFactoryAddress } = await deployRollup(
@@ -808,6 +884,7 @@ export const deployL1Contracts = async (
808
884
  {
809
885
  feeJuiceAddress: feeAssetAddress,
810
886
  registryAddress,
887
+ gseAddress,
811
888
  rewardDistributorAddress,
812
889
  stakingAssetAddress,
813
890
  },
@@ -822,6 +899,8 @@ export const deployL1Contracts = async (
822
899
 
823
900
  logger.info(`Aztec L1 contracts initialized`, l1Contracts);
824
901
 
902
+ logger.info(`Handing over to governance`);
903
+
825
904
  if (isAnvilTestChain(chain.id)) {
826
905
  // @note We make a time jump PAST the very first slot to not have to deal with the edge case of the first slot.
827
906
  // The edge case being that the genesis block is already occupying slot 0, so we cannot have another block.
@@ -30,6 +30,7 @@ export type L1ContractAddresses = {
30
30
  slashFactoryAddress?: EthAddress | undefined;
31
31
  feeAssetHandlerAddress?: EthAddress | undefined;
32
32
  stakingAssetHandlerAddress?: EthAddress | undefined;
33
+ gseAddress?: EthAddress | undefined;
33
34
  };
34
35
 
35
36
  export const L1ContractAddressesSchema = z.object({
@@ -47,11 +48,12 @@ export const L1ContractAddressesSchema = z.object({
47
48
  slashFactoryAddress: schemas.EthAddress.optional(),
48
49
  feeAssetHandlerAddress: schemas.EthAddress.optional(),
49
50
  stakingAssetHandlerAddress: schemas.EthAddress.optional(),
51
+ gseAddress: schemas.EthAddress.optional(),
50
52
  }) satisfies ZodFor<L1ContractAddresses>;
51
53
 
52
54
  const parseEnv = (val: string) => EthAddress.fromString(val);
53
55
 
54
- export const l1ContractAddressesMapping: ConfigMappingsType<L1ContractAddresses> = {
56
+ export const l1ContractAddressesMapping: ConfigMappingsType<Omit<L1ContractAddresses, 'gseAddress'>> = {
55
57
  rollupAddress: {
56
58
  env: 'ROLLUP_CONTRACT_ADDRESS',
57
59
  description: 'The deployed L1 rollup contract address.',
@@ -512,7 +512,9 @@ export class ReadOnlyL1TxUtils {
512
512
 
513
513
  public bumpGasLimit(gasLimit: bigint, _gasConfig?: L1TxUtilsConfig): bigint {
514
514
  const gasConfig = { ...this.config, ..._gasConfig };
515
- return gasLimit + (gasLimit * BigInt((gasConfig?.gasLimitBufferPercentage || 0) * 1_00)) / 100_00n;
515
+ const bumpedGasLimit = gasLimit + (gasLimit * BigInt((gasConfig?.gasLimitBufferPercentage || 0) * 1_00)) / 100_00n;
516
+ this.logger?.debug('Bumping gas limit', { gasLimit, gasConfig, bumpedGasLimit });
517
+ return bumpedGasLimit;
516
518
  }
517
519
  }
518
520
 
@@ -560,9 +562,11 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
560
562
  } else if (gasConfig.gasLimit) {
561
563
  gasLimit = gasConfig.gasLimit;
562
564
  } else {
563
- gasLimit = await this.estimateGas(account, request);
565
+ gasLimit = await this.estimateGas(account, request, gasConfig);
564
566
  }
565
567
 
568
+ this.logger?.debug('Gas limit', { gasLimit });
569
+
566
570
  const gasPrice = await this.getGasPrice(gasConfig, !!blobInputs);
567
571
 
568
572
  if (gasConfig.txTimeoutAt && Date.now() > gasConfig.txTimeoutAt.getTime()) {