@aztec/ethereum 2.1.0-rc.9 → 3.0.0-devnet.2

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 (40) hide show
  1. package/dest/client.d.ts +1 -1
  2. package/dest/client.d.ts.map +1 -1
  3. package/dest/config.d.ts.map +1 -1
  4. package/dest/config.js +13 -3
  5. package/dest/contracts/rollup.d.ts +2 -2
  6. package/dest/contracts/rollup.d.ts.map +1 -1
  7. package/dest/contracts/rollup.js +9 -6
  8. package/dest/contracts/tally_slashing_proposer.d.ts +7 -1
  9. package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -1
  10. package/dest/contracts/tally_slashing_proposer.js +12 -2
  11. package/dest/deploy_l1_contracts.d.ts +4 -3
  12. package/dest/deploy_l1_contracts.d.ts.map +1 -1
  13. package/dest/deploy_l1_contracts.js +241 -205
  14. package/dest/l1_artifacts.d.ts +730 -192
  15. package/dest/l1_artifacts.d.ts.map +1 -1
  16. package/dest/l1_artifacts.js +5 -5
  17. package/dest/l1_reader.d.ts +1 -1
  18. package/dest/l1_reader.d.ts.map +1 -1
  19. package/dest/l1_reader.js +1 -1
  20. package/dest/test/eth_cheat_codes.d.ts +15 -6
  21. package/dest/test/eth_cheat_codes.d.ts.map +1 -1
  22. package/dest/test/eth_cheat_codes.js +17 -9
  23. package/dest/test/rollup_cheat_codes.d.ts +8 -8
  24. package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
  25. package/dest/test/rollup_cheat_codes.js +36 -4
  26. package/dest/test/upgrade_utils.d.ts.map +1 -1
  27. package/dest/test/upgrade_utils.js +2 -1
  28. package/dest/zkPassportVerifierAddress.js +1 -1
  29. package/package.json +6 -6
  30. package/src/client.ts +1 -1
  31. package/src/config.ts +14 -4
  32. package/src/contracts/rollup.ts +9 -8
  33. package/src/contracts/tally_slashing_proposer.ts +12 -3
  34. package/src/deploy_l1_contracts.ts +221 -152
  35. package/src/l1_artifacts.ts +6 -6
  36. package/src/l1_reader.ts +2 -2
  37. package/src/test/eth_cheat_codes.ts +25 -12
  38. package/src/test/rollup_cheat_codes.ts +49 -12
  39. package/src/test/upgrade_utils.ts +2 -1
  40. package/src/zkPassportVerifierAddress.ts +1 -1
@@ -130,6 +130,7 @@ export const deploySharedContracts = async (l1Client, deployer, args, logger)=>{
130
130
  ]);
131
131
  stakingAssetAddress = deployedStaking.address;
132
132
  logger.verbose(`Deployed Staking Asset at ${stakingAssetAddress}`);
133
+ await deployer.waitForDeployments();
133
134
  }
134
135
  const gseAddress = (await deployer.deploy(GSEArtifact, [
135
136
  l1Client.account.address,
@@ -194,7 +195,7 @@ export const deploySharedContracts = async (l1Client, deployer, args, logger)=>{
194
195
  }
195
196
  const coinIssuerAddress = (await deployer.deploy(CoinIssuerArtifact, [
196
197
  feeAssetAddress.toString(),
197
- 25_000_000_000n * 10n ** 18n / (60n * 60n * 24n * 365n),
198
+ 2n * 10n ** 17n,
198
199
  l1Client.account.address
199
200
  ])).address;
200
201
  logger.verbose(`Deployed CoinIssuer at ${coinIssuerAddress}`);
@@ -332,6 +333,224 @@ const getZkPassportVerifierAddress = async (deployer, args)=>{
332
333
  scope
333
334
  ];
334
335
  };
336
+ /**
337
+ * Generates verification records for a deployed rollup and its associated contracts (Inbox, Outbox, Slasher, etc).
338
+ * @param rollup - The deployed rollup contract.
339
+ * @param deployer - The L1 deployer instance.
340
+ * @param args - The deployment arguments used for the rollup.
341
+ * @param addresses - The L1 contract addresses.
342
+ * @param extendedClient - The extended viem wallet client.
343
+ * @param logger - The logger.
344
+ */ async function generateRollupVerificationRecords(rollup, deployer, args, addresses, extendedClient, logger) {
345
+ try {
346
+ // Add Inbox / Outbox verification records (constructor args are created inside RollupCore)
347
+ const rollupAddr = rollup.address;
348
+ const rollupAddresses = await rollup.getRollupAddresses();
349
+ const inboxAddr = rollupAddresses.inboxAddress.toString();
350
+ const outboxAddr = rollupAddresses.outboxAddress.toString();
351
+ const feeAsset = rollupAddresses.feeJuiceAddress.toString();
352
+ const version = await rollup.getVersion();
353
+ const inboxCtor = encodeAbiParameters([
354
+ {
355
+ type: 'address'
356
+ },
357
+ {
358
+ type: 'address'
359
+ },
360
+ {
361
+ type: 'uint256'
362
+ },
363
+ {
364
+ type: 'uint256'
365
+ }
366
+ ], [
367
+ rollupAddr,
368
+ feeAsset,
369
+ version,
370
+ BigInt(L1_TO_L2_MSG_SUBTREE_HEIGHT)
371
+ ]);
372
+ const outboxCtor = encodeAbiParameters([
373
+ {
374
+ type: 'address'
375
+ },
376
+ {
377
+ type: 'uint256'
378
+ }
379
+ ], [
380
+ rollupAddr,
381
+ version
382
+ ]);
383
+ deployer.verificationRecords.push({
384
+ name: 'Inbox',
385
+ address: inboxAddr,
386
+ constructorArgsHex: inboxCtor,
387
+ libraries: []
388
+ }, {
389
+ name: 'Outbox',
390
+ address: outboxAddr,
391
+ constructorArgsHex: outboxCtor,
392
+ libraries: []
393
+ });
394
+ // Include Slasher and SlashingProposer (if deployed) in verification data
395
+ try {
396
+ const slasherAddrHex = await rollup.getSlasherAddress();
397
+ const slasherAddr = EthAddress.fromString(slasherAddrHex);
398
+ if (!slasherAddr.isZero()) {
399
+ // Slasher constructor: (address _vetoer, address _governance)
400
+ const slasherCtor = encodeAbiParameters([
401
+ {
402
+ type: 'address'
403
+ },
404
+ {
405
+ type: 'address'
406
+ }
407
+ ], [
408
+ args.slashingVetoer.toString(),
409
+ extendedClient.account.address
410
+ ]);
411
+ deployer.verificationRecords.push({
412
+ name: 'Slasher',
413
+ address: slasherAddr.toString(),
414
+ constructorArgsHex: slasherCtor,
415
+ libraries: []
416
+ });
417
+ // Proposer address is stored in Slasher.PROPOSER()
418
+ const proposerAddr = (await rollup.getSlashingProposerAddress()).toString();
419
+ // Compute constructor args matching deployment path in RollupCore
420
+ const computedRoundSize = BigInt(args.slashingRoundSizeInEpochs * args.aztecEpochDuration);
421
+ const computedQuorum = BigInt(args.slashingQuorum ?? args.slashingRoundSizeInEpochs * args.aztecEpochDuration / 2 + 1);
422
+ const lifetimeInRounds = BigInt(args.slashingLifetimeInRounds);
423
+ const executionDelayInRounds = BigInt(args.slashingExecutionDelayInRounds);
424
+ if (args.slasherFlavor === 'tally') {
425
+ const slashAmounts = [
426
+ args.slashAmountSmall,
427
+ args.slashAmountMedium,
428
+ args.slashAmountLarge
429
+ ];
430
+ const committeeSize = BigInt(args.aztecTargetCommitteeSize);
431
+ const epochDuration = BigInt(args.aztecEpochDuration);
432
+ const slashOffsetInRounds = BigInt(args.slashingOffsetInRounds);
433
+ const proposerCtor = encodeAbiParameters([
434
+ {
435
+ type: 'address'
436
+ },
437
+ {
438
+ type: 'address'
439
+ },
440
+ {
441
+ type: 'uint256'
442
+ },
443
+ {
444
+ type: 'uint256'
445
+ },
446
+ {
447
+ type: 'uint256'
448
+ },
449
+ {
450
+ type: 'uint256'
451
+ },
452
+ {
453
+ type: 'uint256[3]'
454
+ },
455
+ {
456
+ type: 'uint256'
457
+ },
458
+ {
459
+ type: 'uint256'
460
+ },
461
+ {
462
+ type: 'uint256'
463
+ }
464
+ ], [
465
+ rollup.address,
466
+ slasherAddr.toString(),
467
+ computedQuorum,
468
+ computedRoundSize,
469
+ lifetimeInRounds,
470
+ executionDelayInRounds,
471
+ slashAmounts,
472
+ committeeSize,
473
+ epochDuration,
474
+ slashOffsetInRounds
475
+ ]);
476
+ deployer.verificationRecords.push({
477
+ name: 'TallySlashingProposer',
478
+ address: proposerAddr,
479
+ constructorArgsHex: proposerCtor,
480
+ libraries: []
481
+ });
482
+ } else if (args.slasherFlavor === 'empire') {
483
+ const proposerCtor = encodeAbiParameters([
484
+ {
485
+ type: 'address'
486
+ },
487
+ {
488
+ type: 'address'
489
+ },
490
+ {
491
+ type: 'uint256'
492
+ },
493
+ {
494
+ type: 'uint256'
495
+ },
496
+ {
497
+ type: 'uint256'
498
+ },
499
+ {
500
+ type: 'uint256'
501
+ }
502
+ ], [
503
+ rollup.address,
504
+ slasherAddr.toString(),
505
+ computedQuorum,
506
+ computedRoundSize,
507
+ lifetimeInRounds,
508
+ executionDelayInRounds
509
+ ]);
510
+ deployer.verificationRecords.push({
511
+ name: 'EmpireSlashingProposer',
512
+ address: proposerAddr,
513
+ constructorArgsHex: proposerCtor,
514
+ libraries: []
515
+ });
516
+ }
517
+ }
518
+ } catch (e) {
519
+ logger.warn(`Failed to add Slasher/Proposer verification records: ${String(e)}`);
520
+ }
521
+ } catch (e) {
522
+ throw new Error(`Failed to generate rollup verification records: ${String(e)}`);
523
+ }
524
+ }
525
+ /**
526
+ * Writes verification records to a JSON file for later forge verify.
527
+ * @param deployer - The L1 deployer containing verification records.
528
+ * @param outputDirectory - The directory to write the verification file to.
529
+ * @param chainId - The chain ID.
530
+ * @param filenameSuffix - Optional suffix for the filename (e.g., 'upgrade').
531
+ * @param logger - The logger.
532
+ */ async function writeVerificationJson(deployer, outputDirectory, chainId, filenameSuffix = '', logger) {
533
+ try {
534
+ const date = new Date();
535
+ const formattedDate = date.toISOString().slice(2, 19).replace(/[-T:]/g, '');
536
+ // Ensure the verification output directory exists
537
+ await mkdir(outputDirectory, {
538
+ recursive: true
539
+ });
540
+ const suffix = filenameSuffix ? `-${filenameSuffix}` : '';
541
+ const verificationOutputPath = `${outputDirectory}/l1-verify${suffix}-${chainId}-${formattedDate.slice(0, 6)}-${formattedDate.slice(6)}.json`;
542
+ const networkName = getActiveNetworkName();
543
+ const verificationData = {
544
+ chainId: chainId,
545
+ network: networkName,
546
+ records: deployer.verificationRecords
547
+ };
548
+ await writeFile(verificationOutputPath, JSON.stringify(verificationData, null, 2));
549
+ logger.info(`Wrote L1 verification data to ${verificationOutputPath}`);
550
+ } catch (e) {
551
+ logger.warn(`Failed to write L1 verification data file: ${String(e)}`);
552
+ }
553
+ }
335
554
  /**
336
555
  * Deploys a new rollup, using the existing canonical version to derive certain values (addresses of assets etc).
337
556
  * @param clients - The L1 clients.
@@ -339,11 +558,17 @@ const getZkPassportVerifierAddress = async (deployer, args)=>{
339
558
  * @param registryAddress - The address of the registry.
340
559
  * @param logger - The logger.
341
560
  * @param txUtilsConfig - The L1 tx utils config.
342
- */ export const deployRollupForUpgrade = async (extendedClient, args, registryAddress, logger, txUtilsConfig)=>{
343
- const deployer = new L1Deployer(extendedClient, args.salt, undefined, args.acceleratedTestDeployments, logger, txUtilsConfig);
561
+ * @param createVerificationJson - Optional path to write verification data for forge verify.
562
+ */ export const deployRollupForUpgrade = async (extendedClient, args, registryAddress, logger, txUtilsConfig, createVerificationJson = false)=>{
563
+ const deployer = new L1Deployer(extendedClient, args.salt, undefined, args.acceleratedTestDeployments, logger, txUtilsConfig, !!createVerificationJson);
344
564
  const addresses = await RegistryContract.collectAddresses(extendedClient, registryAddress, 'canonical');
345
565
  const { rollup, slashFactoryAddress } = await deployRollup(extendedClient, deployer, args, addresses, logger);
346
566
  await deployer.waitForDeployments();
567
+ // Write verification data (constructor args + linked libraries) to file for later forge verify
568
+ if (createVerificationJson) {
569
+ await generateRollupVerificationRecords(rollup, deployer, args, addresses, extendedClient, logger);
570
+ await writeVerificationJson(deployer, createVerificationJson, extendedClient.chain.id, 'upgrade', logger);
571
+ }
347
572
  return {
348
573
  rollup,
349
574
  slashFactoryAddress
@@ -425,11 +650,12 @@ function slasherFlavorToSolidityEnum(flavor) {
425
650
  args.slashAmountLarge
426
651
  ],
427
652
  localEjectionThreshold: args.localEjectionThreshold,
428
- slashingDisableDuration: BigInt(args.slashingDisableDuration ?? 0n)
653
+ slashingDisableDuration: BigInt(args.slashingDisableDuration ?? 0n),
654
+ earliestRewardsClaimableTimestamp: 0n
429
655
  };
430
656
  const genesisStateArgs = {
431
657
  vkTreeRoot: args.vkTreeRoot.toString(),
432
- protocolContractTreeRoot: args.protocolContractTreeRoot.toString(),
658
+ protocolContractsHash: args.protocolContractsHash.toString(),
433
659
  genesisArchiveRoot: args.genesisArchiveRoot.toString()
434
660
  };
435
661
  // Until there is an actual chain-id for the version, we will just draw a random value.
@@ -763,7 +989,7 @@ export const handoverToGovernance = async (extendedClient, deployer, registryAdd
763
989
  functionName: 'addValidators',
764
990
  args: [
765
991
  c,
766
- BigInt(chunkSize)
992
+ BigInt(0)
767
993
  ]
768
994
  })
769
995
  }, {
@@ -898,199 +1124,8 @@ export const cheat_initializeFeeAssetHandler = async (extendedClient, deployer,
898
1124
  logger.info(`Aztec L1 contracts initialized`, l1Contracts);
899
1125
  // Write verification data (constructor args + linked libraries) to file for later forge verify
900
1126
  if (createVerificationJson) {
901
- try {
902
- // Add Inbox / Outbox verification records (constructor args are created inside RollupCore)
903
- const rollupAddr = l1Contracts.rollupAddress.toString();
904
- const inboxAddr = l1Contracts.inboxAddress.toString();
905
- const outboxAddr = l1Contracts.outboxAddress.toString();
906
- const feeAsset = l1Contracts.feeJuiceAddress.toString();
907
- const version = await rollup.getVersion();
908
- const inboxCtor = encodeAbiParameters([
909
- {
910
- type: 'address'
911
- },
912
- {
913
- type: 'address'
914
- },
915
- {
916
- type: 'uint256'
917
- },
918
- {
919
- type: 'uint256'
920
- }
921
- ], [
922
- rollupAddr,
923
- feeAsset,
924
- version,
925
- BigInt(L1_TO_L2_MSG_SUBTREE_HEIGHT)
926
- ]);
927
- const outboxCtor = encodeAbiParameters([
928
- {
929
- type: 'address'
930
- },
931
- {
932
- type: 'uint256'
933
- }
934
- ], [
935
- rollupAddr,
936
- version
937
- ]);
938
- deployer.verificationRecords.push({
939
- name: 'Inbox',
940
- address: inboxAddr,
941
- constructorArgsHex: inboxCtor,
942
- libraries: []
943
- }, {
944
- name: 'Outbox',
945
- address: outboxAddr,
946
- constructorArgsHex: outboxCtor,
947
- libraries: []
948
- });
949
- // Include Slasher and SlashingProposer (if deployed) in verification data
950
- try {
951
- const slasherAddrHex = await rollup.getSlasherAddress();
952
- const slasherAddr = EthAddress.fromString(slasherAddrHex);
953
- if (!slasherAddr.isZero()) {
954
- // Slasher constructor: (address _vetoer, address _governance)
955
- const slasherCtor = encodeAbiParameters([
956
- {
957
- type: 'address'
958
- },
959
- {
960
- type: 'address'
961
- }
962
- ], [
963
- args.slashingVetoer.toString(),
964
- l1Client.account.address
965
- ]);
966
- deployer.verificationRecords.push({
967
- name: 'Slasher',
968
- address: slasherAddr.toString(),
969
- constructorArgsHex: slasherCtor,
970
- libraries: []
971
- });
972
- // Proposer address is stored in Slasher.PROPOSER()
973
- const proposerAddr = (await rollup.getSlashingProposerAddress()).toString();
974
- // Compute constructor args matching deployment path in RollupCore
975
- const computedRoundSize = BigInt(args.slashingRoundSizeInEpochs * args.aztecEpochDuration);
976
- const computedQuorum = BigInt(args.slashingQuorum ?? args.slashingRoundSizeInEpochs * args.aztecEpochDuration / 2 + 1);
977
- const lifetimeInRounds = BigInt(args.slashingLifetimeInRounds);
978
- const executionDelayInRounds = BigInt(args.slashingExecutionDelayInRounds);
979
- if (args.slasherFlavor === 'tally') {
980
- const slashAmounts = [
981
- args.slashAmountSmall,
982
- args.slashAmountMedium,
983
- args.slashAmountLarge
984
- ];
985
- const committeeSize = BigInt(args.aztecTargetCommitteeSize);
986
- const epochDuration = BigInt(args.aztecEpochDuration);
987
- const slashOffsetInRounds = BigInt(args.slashingOffsetInRounds);
988
- const proposerCtor = encodeAbiParameters([
989
- {
990
- type: 'address'
991
- },
992
- {
993
- type: 'address'
994
- },
995
- {
996
- type: 'uint256'
997
- },
998
- {
999
- type: 'uint256'
1000
- },
1001
- {
1002
- type: 'uint256'
1003
- },
1004
- {
1005
- type: 'uint256'
1006
- },
1007
- {
1008
- type: 'uint256[3]'
1009
- },
1010
- {
1011
- type: 'uint256'
1012
- },
1013
- {
1014
- type: 'uint256'
1015
- },
1016
- {
1017
- type: 'uint256'
1018
- }
1019
- ], [
1020
- rollup.address,
1021
- slasherAddr.toString(),
1022
- computedQuorum,
1023
- computedRoundSize,
1024
- lifetimeInRounds,
1025
- executionDelayInRounds,
1026
- slashAmounts,
1027
- committeeSize,
1028
- epochDuration,
1029
- slashOffsetInRounds
1030
- ]);
1031
- deployer.verificationRecords.push({
1032
- name: 'TallySlashingProposer',
1033
- address: proposerAddr,
1034
- constructorArgsHex: proposerCtor,
1035
- libraries: []
1036
- });
1037
- } else if (args.slasherFlavor === 'empire') {
1038
- const proposerCtor = encodeAbiParameters([
1039
- {
1040
- type: 'address'
1041
- },
1042
- {
1043
- type: 'address'
1044
- },
1045
- {
1046
- type: 'uint256'
1047
- },
1048
- {
1049
- type: 'uint256'
1050
- },
1051
- {
1052
- type: 'uint256'
1053
- },
1054
- {
1055
- type: 'uint256'
1056
- }
1057
- ], [
1058
- rollup.address,
1059
- slasherAddr.toString(),
1060
- computedQuorum,
1061
- computedRoundSize,
1062
- lifetimeInRounds,
1063
- executionDelayInRounds
1064
- ]);
1065
- deployer.verificationRecords.push({
1066
- name: 'EmpireSlashingProposer',
1067
- address: proposerAddr,
1068
- constructorArgsHex: proposerCtor,
1069
- libraries: []
1070
- });
1071
- }
1072
- }
1073
- } catch (e) {
1074
- logger.warn(`Failed to add Slasher/Proposer verification records: ${String(e)}`);
1075
- }
1076
- const date = new Date();
1077
- const formattedDate = date.toISOString().slice(2, 19).replace(/[-T:]/g, '');
1078
- // Ensure the verification output directory exists
1079
- await mkdir(createVerificationJson, {
1080
- recursive: true
1081
- });
1082
- const verificationOutputPath = `${createVerificationJson}/l1-verify-${chain.id}-${formattedDate.slice(0, 6)}-${formattedDate.slice(6)}.json`;
1083
- const networkName = getActiveNetworkName();
1084
- const verificationData = {
1085
- chainId: chain.id,
1086
- network: networkName,
1087
- records: deployer.verificationRecords
1088
- };
1089
- await writeFile(verificationOutputPath, JSON.stringify(verificationData, null, 2));
1090
- logger.info(`Wrote L1 verification data to ${verificationOutputPath}`);
1091
- } catch (e) {
1092
- logger.warn(`Failed to write L1 verification data file: ${String(e)}`);
1093
- }
1127
+ await generateRollupVerificationRecords(rollup, deployer, args, l1Contracts, l1Client, logger);
1128
+ await writeVerificationJson(deployer, createVerificationJson, chain.id, '', logger);
1094
1129
  }
1095
1130
  if (isAnvilTestChain(chain.id)) {
1096
1131
  // @note We make a time jump PAST the very first slot to not have to deal with the edge case of the first slot.
@@ -1235,7 +1270,6 @@ export class L1Deployer {
1235
1270
  }));
1236
1271
  }
1237
1272
  }
1238
- // docs:start:deployL1Contract
1239
1273
  /**
1240
1274
  * Helper function to deploy ETH contracts.
1241
1275
  * @param walletClient - A viem WalletClient.
@@ -1348,9 +1382,8 @@ export class L1Deployer {
1348
1382
  data: concatHex([
1349
1383
  salt,
1350
1384
  calldata
1351
- ])
1352
- }, {
1353
- gasLimit
1385
+ ]),
1386
+ gas: gasLimit
1354
1387
  });
1355
1388
  } catch (err) {
1356
1389
  logger?.error(`Failed to simulate deployment tx using universal deployer`, err);
@@ -1360,7 +1393,8 @@ export class L1Deployer {
1360
1393
  abi,
1361
1394
  bytecode,
1362
1395
  args
1363
- })
1396
+ }),
1397
+ gas: gasLimit
1364
1398
  });
1365
1399
  }
1366
1400
  const res = await l1TxUtils.sendTransaction({
@@ -1387,6 +1421,8 @@ export class L1Deployer {
1387
1421
  const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
1388
1422
  to: null,
1389
1423
  data: deployData
1424
+ }, {
1425
+ gasLimit
1390
1426
  });
1391
1427
  txHash = receipt.transactionHash;
1392
1428
  resultingAddress = receipt.contractAddress;
@@ -1421,4 +1457,4 @@ export function getExpectedAddress(abi, bytecode, args, salt) {
1421
1457
  paddedSalt,
1422
1458
  calldata
1423
1459
  };
1424
- } // docs:end:deployL1Contract
1460
+ }