@aztec/ethereum 2.1.0-rc.20 → 2.1.0-rc.22

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.
@@ -279,6 +279,8 @@ export const deploySharedContracts = async (
279
279
  const deployedStaking = await deployer.deploy(StakingAssetArtifact, ['Staking', 'STK', l1Client.account.address]);
280
280
  stakingAssetAddress = deployedStaking.address;
281
281
  logger.verbose(`Deployed Staking Asset at ${stakingAssetAddress}`);
282
+
283
+ await deployer.waitForDeployments();
282
284
  }
283
285
 
284
286
  const gseAddress = (
@@ -352,7 +354,7 @@ export const deploySharedContracts = async (
352
354
  const coinIssuerAddress = (
353
355
  await deployer.deploy(CoinIssuerArtifact, [
354
356
  feeAssetAddress.toString(),
355
- (25_000_000_000n * 10n ** 18n) / (60n * 60n * 24n * 365n),
357
+ 2n * 10n ** 17n, // hard cap of 20% per year
356
358
  l1Client.account.address,
357
359
  ])
358
360
  ).address;
@@ -514,6 +516,199 @@ const getZkPassportScopes = (args: DeployL1ContractsArgs): [string, string] => {
514
516
  return [domain, scope];
515
517
  };
516
518
 
519
+ /**
520
+ * Generates verification records for a deployed rollup and its associated contracts (Inbox, Outbox, Slasher, etc).
521
+ * @param rollup - The deployed rollup contract.
522
+ * @param deployer - The L1 deployer instance.
523
+ * @param args - The deployment arguments used for the rollup.
524
+ * @param addresses - The L1 contract addresses.
525
+ * @param extendedClient - The extended viem wallet client.
526
+ * @param logger - The logger.
527
+ */
528
+ async function generateRollupVerificationRecords(
529
+ rollup: RollupContract,
530
+ deployer: L1Deployer,
531
+ args: {
532
+ slashingVetoer: EthAddress;
533
+ slashingRoundSizeInEpochs: number;
534
+ aztecEpochDuration: number;
535
+ slashingQuorum?: number;
536
+ slashingLifetimeInRounds: number;
537
+ slashingExecutionDelayInRounds: number;
538
+ slasherFlavor: 'none' | 'tally' | 'empire';
539
+ slashAmountSmall: bigint;
540
+ slashAmountMedium: bigint;
541
+ slashAmountLarge: bigint;
542
+ aztecTargetCommitteeSize: number;
543
+ slashingOffsetInRounds: number;
544
+ },
545
+ addresses: Pick<L1ContractAddresses, 'feeJuiceAddress'>,
546
+ extendedClient: ExtendedViemWalletClient,
547
+ logger: Logger,
548
+ ): Promise<void> {
549
+ try {
550
+ // Add Inbox / Outbox verification records (constructor args are created inside RollupCore)
551
+ const rollupAddr = rollup.address;
552
+ const rollupAddresses = await rollup.getRollupAddresses();
553
+ const inboxAddr = rollupAddresses.inboxAddress.toString();
554
+ const outboxAddr = rollupAddresses.outboxAddress.toString();
555
+ const feeAsset = rollupAddresses.feeJuiceAddress.toString();
556
+ const version = await rollup.getVersion();
557
+
558
+ const inboxCtor = encodeAbiParameters(
559
+ [{ type: 'address' }, { type: 'address' }, { type: 'uint256' }, { type: 'uint256' }],
560
+ [rollupAddr, feeAsset, version, BigInt(L1_TO_L2_MSG_SUBTREE_HEIGHT)],
561
+ );
562
+
563
+ const outboxCtor = encodeAbiParameters([{ type: 'address' }, { type: 'uint256' }], [rollupAddr, version]);
564
+
565
+ deployer.verificationRecords.push(
566
+ { name: 'Inbox', address: inboxAddr, constructorArgsHex: inboxCtor, libraries: [] },
567
+ { name: 'Outbox', address: outboxAddr, constructorArgsHex: outboxCtor, libraries: [] },
568
+ );
569
+
570
+ // Include Slasher and SlashingProposer (if deployed) in verification data
571
+ try {
572
+ const slasherAddrHex = await rollup.getSlasherAddress();
573
+ const slasherAddr = EthAddress.fromString(slasherAddrHex);
574
+ if (!slasherAddr.isZero()) {
575
+ // Slasher constructor: (address _vetoer, address _governance)
576
+ const slasherCtor = encodeAbiParameters(
577
+ [{ type: 'address' }, { type: 'address' }],
578
+ [args.slashingVetoer.toString(), extendedClient.account.address],
579
+ );
580
+ deployer.verificationRecords.push({
581
+ name: 'Slasher',
582
+ address: slasherAddr.toString(),
583
+ constructorArgsHex: slasherCtor,
584
+ libraries: [],
585
+ });
586
+
587
+ // Proposer address is stored in Slasher.PROPOSER()
588
+ const proposerAddr = (await rollup.getSlashingProposerAddress()).toString();
589
+
590
+ // Compute constructor args matching deployment path in RollupCore
591
+ const computedRoundSize = BigInt(args.slashingRoundSizeInEpochs * args.aztecEpochDuration);
592
+ const computedQuorum = BigInt(
593
+ args.slashingQuorum ?? (args.slashingRoundSizeInEpochs * args.aztecEpochDuration) / 2 + 1,
594
+ );
595
+ const lifetimeInRounds = BigInt(args.slashingLifetimeInRounds);
596
+ const executionDelayInRounds = BigInt(args.slashingExecutionDelayInRounds);
597
+
598
+ if (args.slasherFlavor === 'tally') {
599
+ const slashAmounts: readonly [bigint, bigint, bigint] = [
600
+ args.slashAmountSmall,
601
+ args.slashAmountMedium,
602
+ args.slashAmountLarge,
603
+ ];
604
+ const committeeSize = BigInt(args.aztecTargetCommitteeSize);
605
+ const epochDuration = BigInt(args.aztecEpochDuration);
606
+ const slashOffsetInRounds = BigInt(args.slashingOffsetInRounds);
607
+
608
+ const proposerCtor = encodeAbiParameters(
609
+ [
610
+ { type: 'address' },
611
+ { type: 'address' },
612
+ { type: 'uint256' },
613
+ { type: 'uint256' },
614
+ { type: 'uint256' },
615
+ { type: 'uint256' },
616
+ { type: 'uint256[3]' },
617
+ { type: 'uint256' },
618
+ { type: 'uint256' },
619
+ { type: 'uint256' },
620
+ ],
621
+ [
622
+ rollup.address,
623
+ slasherAddr.toString(),
624
+ computedQuorum,
625
+ computedRoundSize,
626
+ lifetimeInRounds,
627
+ executionDelayInRounds,
628
+ slashAmounts,
629
+ committeeSize,
630
+ epochDuration,
631
+ slashOffsetInRounds,
632
+ ],
633
+ );
634
+
635
+ deployer.verificationRecords.push({
636
+ name: 'TallySlashingProposer',
637
+ address: proposerAddr,
638
+ constructorArgsHex: proposerCtor,
639
+ libraries: [],
640
+ });
641
+ } else if (args.slasherFlavor === 'empire') {
642
+ const proposerCtor = encodeAbiParameters(
643
+ [
644
+ { type: 'address' },
645
+ { type: 'address' },
646
+ { type: 'uint256' },
647
+ { type: 'uint256' },
648
+ { type: 'uint256' },
649
+ { type: 'uint256' },
650
+ ],
651
+ [
652
+ rollup.address,
653
+ slasherAddr.toString(),
654
+ computedQuorum,
655
+ computedRoundSize,
656
+ lifetimeInRounds,
657
+ executionDelayInRounds,
658
+ ],
659
+ );
660
+
661
+ deployer.verificationRecords.push({
662
+ name: 'EmpireSlashingProposer',
663
+ address: proposerAddr,
664
+ constructorArgsHex: proposerCtor,
665
+ libraries: [],
666
+ });
667
+ }
668
+ }
669
+ } catch (e) {
670
+ logger.warn(`Failed to add Slasher/Proposer verification records: ${String(e)}`);
671
+ }
672
+ } catch (e) {
673
+ throw new Error(`Failed to generate rollup verification records: ${String(e)}`);
674
+ }
675
+ }
676
+
677
+ /**
678
+ * Writes verification records to a JSON file for later forge verify.
679
+ * @param deployer - The L1 deployer containing verification records.
680
+ * @param outputDirectory - The directory to write the verification file to.
681
+ * @param chainId - The chain ID.
682
+ * @param filenameSuffix - Optional suffix for the filename (e.g., 'upgrade').
683
+ * @param logger - The logger.
684
+ */
685
+ async function writeVerificationJson(
686
+ deployer: L1Deployer,
687
+ outputDirectory: string,
688
+ chainId: number,
689
+ filenameSuffix: string = '',
690
+ logger: Logger,
691
+ ): Promise<void> {
692
+ try {
693
+ const date = new Date();
694
+ const formattedDate = date.toISOString().slice(2, 19).replace(/[-T:]/g, '');
695
+ // Ensure the verification output directory exists
696
+ await mkdir(outputDirectory, { recursive: true });
697
+ const suffix = filenameSuffix ? `-${filenameSuffix}` : '';
698
+ const verificationOutputPath = `${outputDirectory}/l1-verify${suffix}-${chainId}-${formattedDate.slice(0, 6)}-${formattedDate.slice(6)}.json`;
699
+ const networkName = getActiveNetworkName();
700
+ const verificationData = {
701
+ chainId: chainId,
702
+ network: networkName,
703
+ records: deployer.verificationRecords,
704
+ };
705
+ await writeFile(verificationOutputPath, JSON.stringify(verificationData, null, 2));
706
+ logger.info(`Wrote L1 verification data to ${verificationOutputPath}`);
707
+ } catch (e) {
708
+ logger.warn(`Failed to write L1 verification data file: ${String(e)}`);
709
+ }
710
+ }
711
+
517
712
  /**
518
713
  * Deploys a new rollup, using the existing canonical version to derive certain values (addresses of assets etc).
519
714
  * @param clients - The L1 clients.
@@ -521,6 +716,7 @@ const getZkPassportScopes = (args: DeployL1ContractsArgs): [string, string] => {
521
716
  * @param registryAddress - The address of the registry.
522
717
  * @param logger - The logger.
523
718
  * @param txUtilsConfig - The L1 tx utils config.
719
+ * @param createVerificationJson - Optional path to write verification data for forge verify.
524
720
  */
525
721
  export const deployRollupForUpgrade = async (
526
722
  extendedClient: ExtendedViemWalletClient,
@@ -531,6 +727,7 @@ export const deployRollupForUpgrade = async (
531
727
  registryAddress: EthAddress,
532
728
  logger: Logger,
533
729
  txUtilsConfig: L1TxUtilsConfig,
730
+ createVerificationJson: string | false = false,
534
731
  ) => {
535
732
  const deployer = new L1Deployer(
536
733
  extendedClient,
@@ -539,6 +736,7 @@ export const deployRollupForUpgrade = async (
539
736
  args.acceleratedTestDeployments,
540
737
  logger,
541
738
  txUtilsConfig,
739
+ !!createVerificationJson,
542
740
  );
543
741
 
544
742
  const addresses = await RegistryContract.collectAddresses(extendedClient, registryAddress, 'canonical');
@@ -547,6 +745,12 @@ export const deployRollupForUpgrade = async (
547
745
 
548
746
  await deployer.waitForDeployments();
549
747
 
748
+ // Write verification data (constructor args + linked libraries) to file for later forge verify
749
+ if (createVerificationJson) {
750
+ await generateRollupVerificationRecords(rollup, deployer, args, addresses, extendedClient, logger);
751
+ await writeVerificationJson(deployer, createVerificationJson, extendedClient.chain.id, 'upgrade', logger);
752
+ }
753
+
550
754
  return { rollup, slashFactoryAddress };
551
755
  };
552
756
 
@@ -1278,144 +1482,8 @@ export const deployL1Contracts = async (
1278
1482
 
1279
1483
  // Write verification data (constructor args + linked libraries) to file for later forge verify
1280
1484
  if (createVerificationJson) {
1281
- try {
1282
- // Add Inbox / Outbox verification records (constructor args are created inside RollupCore)
1283
- const rollupAddr = l1Contracts.rollupAddress.toString();
1284
- const inboxAddr = l1Contracts.inboxAddress.toString();
1285
- const outboxAddr = l1Contracts.outboxAddress.toString();
1286
- const feeAsset = l1Contracts.feeJuiceAddress.toString();
1287
- const version = await rollup.getVersion();
1288
-
1289
- const inboxCtor = encodeAbiParameters(
1290
- [{ type: 'address' }, { type: 'address' }, { type: 'uint256' }, { type: 'uint256' }],
1291
- [rollupAddr, feeAsset, version, BigInt(L1_TO_L2_MSG_SUBTREE_HEIGHT)],
1292
- );
1293
-
1294
- const outboxCtor = encodeAbiParameters([{ type: 'address' }, { type: 'uint256' }], [rollupAddr, version]);
1295
-
1296
- deployer.verificationRecords.push(
1297
- { name: 'Inbox', address: inboxAddr, constructorArgsHex: inboxCtor, libraries: [] },
1298
- { name: 'Outbox', address: outboxAddr, constructorArgsHex: outboxCtor, libraries: [] },
1299
- );
1300
-
1301
- // Include Slasher and SlashingProposer (if deployed) in verification data
1302
- try {
1303
- const slasherAddrHex = await rollup.getSlasherAddress();
1304
- const slasherAddr = EthAddress.fromString(slasherAddrHex);
1305
- if (!slasherAddr.isZero()) {
1306
- // Slasher constructor: (address _vetoer, address _governance)
1307
- const slasherCtor = encodeAbiParameters(
1308
- [{ type: 'address' }, { type: 'address' }],
1309
- [args.slashingVetoer.toString(), l1Client.account.address],
1310
- );
1311
- deployer.verificationRecords.push({
1312
- name: 'Slasher',
1313
- address: slasherAddr.toString(),
1314
- constructorArgsHex: slasherCtor,
1315
- libraries: [],
1316
- });
1317
-
1318
- // Proposer address is stored in Slasher.PROPOSER()
1319
- const proposerAddr = (await rollup.getSlashingProposerAddress()).toString();
1320
-
1321
- // Compute constructor args matching deployment path in RollupCore
1322
- const computedRoundSize = BigInt(args.slashingRoundSizeInEpochs * args.aztecEpochDuration);
1323
- const computedQuorum = BigInt(
1324
- args.slashingQuorum ?? (args.slashingRoundSizeInEpochs * args.aztecEpochDuration) / 2 + 1,
1325
- );
1326
- const lifetimeInRounds = BigInt(args.slashingLifetimeInRounds);
1327
- const executionDelayInRounds = BigInt(args.slashingExecutionDelayInRounds);
1328
-
1329
- if (args.slasherFlavor === 'tally') {
1330
- const slashAmounts: readonly [bigint, bigint, bigint] = [
1331
- args.slashAmountSmall,
1332
- args.slashAmountMedium,
1333
- args.slashAmountLarge,
1334
- ];
1335
- const committeeSize = BigInt(args.aztecTargetCommitteeSize);
1336
- const epochDuration = BigInt(args.aztecEpochDuration);
1337
- const slashOffsetInRounds = BigInt(args.slashingOffsetInRounds);
1338
-
1339
- const proposerCtor = encodeAbiParameters(
1340
- [
1341
- { type: 'address' },
1342
- { type: 'address' },
1343
- { type: 'uint256' },
1344
- { type: 'uint256' },
1345
- { type: 'uint256' },
1346
- { type: 'uint256' },
1347
- { type: 'uint256[3]' },
1348
- { type: 'uint256' },
1349
- { type: 'uint256' },
1350
- { type: 'uint256' },
1351
- ],
1352
- [
1353
- rollup.address,
1354
- slasherAddr.toString(),
1355
- computedQuorum,
1356
- computedRoundSize,
1357
- lifetimeInRounds,
1358
- executionDelayInRounds,
1359
- slashAmounts,
1360
- committeeSize,
1361
- epochDuration,
1362
- slashOffsetInRounds,
1363
- ],
1364
- );
1365
-
1366
- deployer.verificationRecords.push({
1367
- name: 'TallySlashingProposer',
1368
- address: proposerAddr,
1369
- constructorArgsHex: proposerCtor,
1370
- libraries: [],
1371
- });
1372
- } else if (args.slasherFlavor === 'empire') {
1373
- const proposerCtor = encodeAbiParameters(
1374
- [
1375
- { type: 'address' },
1376
- { type: 'address' },
1377
- { type: 'uint256' },
1378
- { type: 'uint256' },
1379
- { type: 'uint256' },
1380
- { type: 'uint256' },
1381
- ],
1382
- [
1383
- rollup.address,
1384
- slasherAddr.toString(),
1385
- computedQuorum,
1386
- computedRoundSize,
1387
- lifetimeInRounds,
1388
- executionDelayInRounds,
1389
- ],
1390
- );
1391
-
1392
- deployer.verificationRecords.push({
1393
- name: 'EmpireSlashingProposer',
1394
- address: proposerAddr,
1395
- constructorArgsHex: proposerCtor,
1396
- libraries: [],
1397
- });
1398
- }
1399
- }
1400
- } catch (e) {
1401
- logger.warn(`Failed to add Slasher/Proposer verification records: ${String(e)}`);
1402
- }
1403
- const date = new Date();
1404
- const formattedDate = date.toISOString().slice(2, 19).replace(/[-T:]/g, '');
1405
- // Ensure the verification output directory exists
1406
- await mkdir(createVerificationJson, { recursive: true });
1407
- const verificationOutputPath = `${createVerificationJson}/l1-verify-${chain.id}-${formattedDate.slice(0, 6)}-${formattedDate.slice(6)}.json`;
1408
- const networkName = getActiveNetworkName();
1409
- const verificationData = {
1410
- chainId: chain.id,
1411
- network: networkName,
1412
- records: deployer.verificationRecords,
1413
- };
1414
- await writeFile(verificationOutputPath, JSON.stringify(verificationData, null, 2));
1415
- logger.info(`Wrote L1 verification data to ${verificationOutputPath}`);
1416
- } catch (e) {
1417
- logger.warn(`Failed to write L1 verification data file: ${String(e)}`);
1418
- }
1485
+ await generateRollupVerificationRecords(rollup, deployer, args, l1Contracts, l1Client, logger);
1486
+ await writeVerificationJson(deployer, createVerificationJson, chain.id, '', logger);
1419
1487
  }
1420
1488
 
1421
1489
  if (isAnvilTestChain(chain.id)) {
@@ -4,7 +4,7 @@ import { EthAddress } from '@aztec/foundation/eth-address';
4
4
  * The address of the zk passport verifier on sepolia
5
5
  * get address from: ROOT/l1-contracts/lib/circuits/src/solidity/deployments/deployment-11155111.json
6
6
  */
7
- export const ZK_PASSPORT_VERIFIER_ADDRESS = EthAddress.fromString('0xBec82dec0747C9170D760D5aba9cc44929B17C05');
7
+ export const ZK_PASSPORT_VERIFIER_ADDRESS = EthAddress.fromString('0x3101Bad9eA5fACadA5554844a1a88F7Fe48D4DE0');
8
8
  /**
9
9
  * The default domain of the zk passport site
10
10
  */