@aztec/ethereum 1.2.1 → 2.0.0-nightly.20250813

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 (98) hide show
  1. package/dest/config.d.ts +22 -7
  2. package/dest/config.d.ts.map +1 -1
  3. package/dest/config.js +49 -14
  4. package/dest/contracts/empire_base.d.ts +12 -10
  5. package/dest/contracts/empire_base.d.ts.map +1 -1
  6. package/dest/contracts/empire_base.js +21 -16
  7. package/dest/contracts/governance.d.ts +4 -4
  8. package/dest/contracts/governance.js +2 -2
  9. package/dest/contracts/governance_proposer.d.ts +7 -7
  10. package/dest/contracts/governance_proposer.d.ts.map +1 -1
  11. package/dest/contracts/governance_proposer.js +13 -13
  12. package/dest/contracts/gse.d.ts +29 -0
  13. package/dest/contracts/gse.d.ts.map +1 -0
  14. package/dest/contracts/gse.js +56 -0
  15. package/dest/contracts/index.d.ts +1 -0
  16. package/dest/contracts/index.d.ts.map +1 -1
  17. package/dest/contracts/index.js +1 -0
  18. package/dest/contracts/multicall.d.ts +3 -1
  19. package/dest/contracts/multicall.d.ts.map +1 -1
  20. package/dest/contracts/multicall.js +11 -2
  21. package/dest/contracts/registry.d.ts +1 -0
  22. package/dest/contracts/registry.d.ts.map +1 -1
  23. package/dest/contracts/registry.js +3 -0
  24. package/dest/contracts/rollup.d.ts +39 -5
  25. package/dest/contracts/rollup.d.ts.map +1 -1
  26. package/dest/contracts/rollup.js +92 -14
  27. package/dest/contracts/slashing_proposer.d.ts +21 -10
  28. package/dest/contracts/slashing_proposer.d.ts.map +1 -1
  29. package/dest/contracts/slashing_proposer.js +43 -23
  30. package/dest/deploy_l1_contracts.d.ts +11 -36664
  31. package/dest/deploy_l1_contracts.d.ts.map +1 -1
  32. package/dest/deploy_l1_contracts.js +92 -177
  33. package/dest/index.d.ts +1 -1
  34. package/dest/index.d.ts.map +1 -1
  35. package/dest/index.js +1 -1
  36. package/dest/l1_artifacts.d.ts +51869 -0
  37. package/dest/l1_artifacts.d.ts.map +1 -0
  38. package/dest/l1_artifacts.js +141 -0
  39. package/dest/l1_tx_utils.d.ts +4 -2
  40. package/dest/l1_tx_utils.d.ts.map +1 -1
  41. package/dest/l1_tx_utils.js +46 -21
  42. package/dest/queries.d.ts +1 -8
  43. package/dest/queries.d.ts.map +1 -1
  44. package/dest/queries.js +20 -15
  45. package/dest/test/chain_monitor.d.ts +4 -2
  46. package/dest/test/chain_monitor.d.ts.map +1 -1
  47. package/dest/test/chain_monitor.js +12 -3
  48. package/dest/test/delayed_tx_utils.js +2 -2
  49. package/dest/{eth_cheat_codes.d.ts → test/eth_cheat_codes.d.ts} +8 -4
  50. package/dest/test/eth_cheat_codes.d.ts.map +1 -0
  51. package/dest/{eth_cheat_codes.js → test/eth_cheat_codes.js} +27 -11
  52. package/dest/test/eth_cheat_codes_with_state.d.ts +1 -1
  53. package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -1
  54. package/dest/test/eth_cheat_codes_with_state.js +1 -1
  55. package/dest/test/index.d.ts +2 -0
  56. package/dest/test/index.d.ts.map +1 -1
  57. package/dest/test/index.js +2 -0
  58. package/dest/test/rollup_cheat_codes.d.ts +81 -0
  59. package/dest/test/rollup_cheat_codes.d.ts.map +1 -0
  60. package/dest/test/rollup_cheat_codes.js +234 -0
  61. package/dest/test/start_anvil.d.ts +1 -0
  62. package/dest/test/start_anvil.d.ts.map +1 -1
  63. package/dest/test/start_anvil.js +6 -1
  64. package/dest/test/tx_delayer.d.ts +8 -1
  65. package/dest/test/tx_delayer.d.ts.map +1 -1
  66. package/dest/test/tx_delayer.js +51 -11
  67. package/dest/test/upgrade_utils.d.ts.map +1 -1
  68. package/dest/test/upgrade_utils.js +1 -1
  69. package/dest/utils.d.ts +1 -0
  70. package/dest/utils.d.ts.map +1 -1
  71. package/dest/utils.js +1 -1
  72. package/package.json +5 -5
  73. package/src/config.ts +62 -18
  74. package/src/contracts/empire_base.ts +28 -19
  75. package/src/contracts/governance.ts +2 -2
  76. package/src/contracts/governance_proposer.ts +23 -15
  77. package/src/contracts/gse.ts +73 -0
  78. package/src/contracts/index.ts +1 -0
  79. package/src/contracts/multicall.ts +8 -1
  80. package/src/contracts/registry.ts +4 -0
  81. package/src/contracts/rollup.ts +115 -9
  82. package/src/contracts/slashing_proposer.ts +55 -27
  83. package/src/deploy_l1_contracts.ts +151 -238
  84. package/src/index.ts +1 -1
  85. package/src/l1_artifacts.ts +216 -0
  86. package/src/l1_tx_utils.ts +52 -26
  87. package/src/queries.ts +20 -31
  88. package/src/test/chain_monitor.ts +9 -2
  89. package/src/test/delayed_tx_utils.ts +2 -2
  90. package/src/{eth_cheat_codes.ts → test/eth_cheat_codes.ts} +20 -14
  91. package/src/test/eth_cheat_codes_with_state.ts +1 -1
  92. package/src/test/index.ts +2 -0
  93. package/src/test/rollup_cheat_codes.ts +257 -0
  94. package/src/test/start_anvil.ts +9 -1
  95. package/src/test/tx_delayer.ts +55 -9
  96. package/src/test/upgrade_utils.ts +1 -1
  97. package/src/utils.ts +1 -1
  98. package/dest/eth_cheat_codes.d.ts.map +0 -1
@@ -1,147 +1,51 @@
1
1
  import { getActiveNetworkName } from '@aztec/foundation/config';
2
2
  import { EthAddress } from '@aztec/foundation/eth-address';
3
3
  import { createLogger } from '@aztec/foundation/log';
4
- import { CoinIssuerAbi, CoinIssuerBytecode, ExtRollupLib2Abi, ExtRollupLib2Bytecode, ExtRollupLibAbi, ExtRollupLibBytecode, FeeAssetHandlerAbi, FeeAssetHandlerBytecode, FeeJuicePortalAbi, FeeJuicePortalBytecode, GSEAbi, GSEBytecode, GovernanceAbi, GovernanceBytecode, GovernanceProposerAbi, GovernanceProposerBytecode, HonkVerifierAbi, HonkVerifierBytecode, InboxAbi, InboxBytecode, MockVerifierAbi, MockVerifierBytecode, MockZKPassportVerifierAbi, MockZKPassportVerifierBytecode, MultiAdderAbi, MultiAdderBytecode, OutboxAbi, OutboxBytecode, RegisterNewRollupVersionPayloadAbi, RegisterNewRollupVersionPayloadBytecode, RegistryAbi, RegistryBytecode, RewardDistributorAbi, RewardDistributorBytecode, RollupAbi, RollupBytecode, RollupLinkReferences, SlashFactoryAbi, SlashFactoryBytecode, StakingAssetHandlerAbi, StakingAssetHandlerBytecode, TestERC20Abi, TestERC20Bytecode, ValidatorSelectionLibAbi, ValidatorSelectionLibBytecode } from '@aztec/l1-artifacts';
4
+ import { DateProvider } from '@aztec/foundation/timer';
5
5
  import { concatHex, encodeDeployData, encodeFunctionData, getAddress, getContract, getContractAddress, numberToHex, padHex } from 'viem';
6
6
  import { foundry } from 'viem/chains';
7
7
  import { isAnvilTestChain } from './chain.js';
8
8
  import { createExtendedL1Client } from './client.js';
9
- import { getEntryQueueConfig, getGovernanceConfiguration, getRewardBoostConfig, getRewardConfig } from './config.js';
9
+ import { getEntryQueueConfig, getGSEConfiguration, getGovernanceConfiguration, getRewardBoostConfig, getRewardConfig } from './config.js';
10
+ import { GSEContract } from './contracts/gse.js';
11
+ import { deployMulticall3 } from './contracts/multicall.js';
10
12
  import { RegistryContract } from './contracts/registry.js';
11
13
  import { RollupContract } from './contracts/rollup.js';
14
+ import { CoinIssuerArtifact, FeeAssetArtifact, FeeAssetHandlerArtifact, GSEArtifact, GovernanceArtifact, GovernanceProposerArtifact, MultiAdderArtifact, RegisterNewRollupVersionPayloadArtifact, RegistryArtifact, RollupArtifact, SlashFactoryArtifact, StakingAssetArtifact, StakingAssetHandlerArtifact, l1ArtifactsVerifiers, mockVerifiers } from './l1_artifacts.js';
12
15
  import { L1TxUtils, getL1TxUtilsConfigEnvVars } from './l1_tx_utils.js';
16
+ import { formatViemError } from './utils.js';
13
17
  import { ZK_PASSPORT_DOMAIN, ZK_PASSPORT_SCOPE, ZK_PASSPORT_VERIFIER_ADDRESS } from './zkPassportVerifierAddress.js';
14
18
  export const DEPLOYER_ADDRESS = '0x4e59b44847b379578588920cA78FbF26c0B4956C';
15
19
  const networkName = getActiveNetworkName();
16
- export const l1Artifacts = {
17
- registry: {
18
- contractAbi: RegistryAbi,
19
- contractBytecode: RegistryBytecode
20
- },
21
- inbox: {
22
- contractAbi: InboxAbi,
23
- contractBytecode: InboxBytecode
24
- },
25
- outbox: {
26
- contractAbi: OutboxAbi,
27
- contractBytecode: OutboxBytecode
28
- },
29
- rollup: {
30
- contractAbi: RollupAbi,
31
- contractBytecode: RollupBytecode,
32
- libraries: {
33
- linkReferences: RollupLinkReferences,
34
- libraryCode: {
35
- ValidatorSelectionLib: {
36
- contractAbi: ValidatorSelectionLibAbi,
37
- contractBytecode: ValidatorSelectionLibBytecode
38
- },
39
- ExtRollupLib: {
40
- contractAbi: ExtRollupLibAbi,
41
- contractBytecode: ExtRollupLibBytecode
42
- },
43
- ExtRollupLib2: {
44
- contractAbi: ExtRollupLib2Abi,
45
- contractBytecode: ExtRollupLib2Bytecode
46
- }
47
- }
48
- }
49
- },
50
- stakingAsset: {
51
- contractAbi: TestERC20Abi,
52
- contractBytecode: TestERC20Bytecode
53
- },
54
- feeAsset: {
55
- contractAbi: TestERC20Abi,
56
- contractBytecode: TestERC20Bytecode
57
- },
58
- feeJuicePortal: {
59
- contractAbi: FeeJuicePortalAbi,
60
- contractBytecode: FeeJuicePortalBytecode
61
- },
62
- rewardDistributor: {
63
- contractAbi: RewardDistributorAbi,
64
- contractBytecode: RewardDistributorBytecode
65
- },
66
- coinIssuer: {
67
- contractAbi: CoinIssuerAbi,
68
- contractBytecode: CoinIssuerBytecode
69
- },
70
- governanceProposer: {
71
- contractAbi: GovernanceProposerAbi,
72
- contractBytecode: GovernanceProposerBytecode
73
- },
74
- governance: {
75
- contractAbi: GovernanceAbi,
76
- contractBytecode: GovernanceBytecode
77
- },
78
- slashFactory: {
79
- contractAbi: SlashFactoryAbi,
80
- contractBytecode: SlashFactoryBytecode
81
- },
82
- registerNewRollupVersionPayload: {
83
- contractAbi: RegisterNewRollupVersionPayloadAbi,
84
- contractBytecode: RegisterNewRollupVersionPayloadBytecode
85
- },
86
- feeAssetHandler: {
87
- contractAbi: FeeAssetHandlerAbi,
88
- contractBytecode: FeeAssetHandlerBytecode
89
- },
90
- stakingAssetHandler: {
91
- contractAbi: StakingAssetHandlerAbi,
92
- contractBytecode: StakingAssetHandlerBytecode
93
- },
94
- multiAdder: {
95
- contractAbi: MultiAdderAbi,
96
- contractBytecode: MultiAdderBytecode
97
- },
98
- gse: {
99
- contractAbi: GSEAbi,
100
- contractBytecode: GSEBytecode
101
- }
102
- };
103
- export const l1ArtifactsVerifiers = {
104
- honkVerifier: {
105
- contractAbi: HonkVerifierAbi,
106
- contractBytecode: HonkVerifierBytecode
107
- }
108
- };
109
- const mockVerifiers = {
110
- mockVerifier: {
111
- contractAbi: MockVerifierAbi,
112
- contractBytecode: MockVerifierBytecode
113
- },
114
- mockZkPassportVerifier: {
115
- contractAbi: MockZKPassportVerifierAbi,
116
- contractBytecode: MockZKPassportVerifierBytecode
117
- }
118
- };
119
20
  export const deploySharedContracts = async (l1Client, deployer, args, logger)=>{
120
- logger.info(`Deploying shared contracts. Network configration: ${networkName}`);
21
+ logger.info(`Deploying shared contracts for network configration: ${networkName}`);
121
22
  const txHashes = [];
122
- const feeAssetAddress = await deployer.deploy(l1Artifacts.feeAsset, [
23
+ const feeAssetAddress = await deployer.deploy(FeeAssetArtifact, [
123
24
  'FeeJuice',
124
25
  'FEE',
125
26
  l1Client.account.address.toString()
126
27
  ]);
127
28
  logger.verbose(`Deployed Fee Asset at ${feeAssetAddress}`);
128
- const stakingAssetAddress = await deployer.deploy(l1Artifacts.stakingAsset, [
29
+ const stakingAssetAddress = await deployer.deploy(StakingAssetArtifact, [
129
30
  'Staking',
130
31
  'STK',
131
32
  l1Client.account.address.toString()
132
33
  ]);
133
34
  logger.verbose(`Deployed Staking Asset at ${stakingAssetAddress}`);
134
- const gseAddress = await deployer.deploy(l1Artifacts.gse, [
35
+ const gseConfiguration = getGSEConfiguration(networkName);
36
+ const gseAddress = await deployer.deploy(GSEArtifact, [
135
37
  l1Client.account.address.toString(),
136
- stakingAssetAddress.toString()
38
+ stakingAssetAddress.toString(),
39
+ gseConfiguration.activationThreshold,
40
+ gseConfiguration.ejectionThreshold
137
41
  ]);
138
42
  logger.verbose(`Deployed GSE at ${gseAddress}`);
139
- const registryAddress = await deployer.deploy(l1Artifacts.registry, [
43
+ const registryAddress = await deployer.deploy(RegistryArtifact, [
140
44
  l1Client.account.address.toString(),
141
45
  feeAssetAddress.toString()
142
46
  ]);
143
47
  logger.verbose(`Deployed Registry at ${registryAddress}`);
144
- const governanceProposerAddress = await deployer.deploy(l1Artifacts.governanceProposer, [
48
+ const governanceProposerAddress = await deployer.deploy(GovernanceProposerArtifact, [
145
49
  registryAddress.toString(),
146
50
  gseAddress.toString(),
147
51
  args.governanceProposerQuorum,
@@ -150,7 +54,7 @@ export const deploySharedContracts = async (l1Client, deployer, args, logger)=>{
150
54
  logger.verbose(`Deployed GovernanceProposer at ${governanceProposerAddress}`);
151
55
  // @note @LHerskind the assets are expected to be the same at some point, but for better
152
56
  // configurability they are different for now.
153
- const governanceAddress = await deployer.deploy(l1Artifacts.governance, [
57
+ const governanceAddress = await deployer.deploy(GovernanceArtifact, [
154
58
  stakingAssetAddress.toString(),
155
59
  governanceProposerAddress.toString(),
156
60
  gseAddress.toString(),
@@ -166,7 +70,7 @@ export const deploySharedContracts = async (l1Client, deployer, args, logger)=>{
166
70
  } else {
167
71
  const gseContract = getContract({
168
72
  address: getAddress(gseAddress.toString()),
169
- abi: l1Artifacts.gse.contractAbi,
73
+ abi: GSEArtifact.contractAbi,
170
74
  client: l1Client
171
75
  });
172
76
  const existingGovernance = await gseContract.read.getGovernance();
@@ -178,7 +82,7 @@ export const deploySharedContracts = async (l1Client, deployer, args, logger)=>{
178
82
  const { txHash } = await deployer.sendTransaction({
179
83
  to: gseAddress.toString(),
180
84
  data: encodeFunctionData({
181
- abi: l1Artifacts.gse.contractAbi,
85
+ abi: GSEArtifact.contractAbi,
182
86
  functionName: 'setGovernance',
183
87
  args: [
184
88
  governanceAddress.toString()
@@ -190,7 +94,7 @@ export const deploySharedContracts = async (l1Client, deployer, args, logger)=>{
190
94
  logger.verbose(`Set governance on GSE in ${txHash}`);
191
95
  txHashes.push(txHash);
192
96
  }
193
- const coinIssuerAddress = await deployer.deploy(l1Artifacts.coinIssuer, [
97
+ const coinIssuerAddress = await deployer.deploy(CoinIssuerArtifact, [
194
98
  feeAssetAddress.toString(),
195
99
  1n * 10n ** 18n,
196
100
  governanceAddress.toString()
@@ -198,7 +102,7 @@ export const deploySharedContracts = async (l1Client, deployer, args, logger)=>{
198
102
  logger.verbose(`Deployed CoinIssuer at ${coinIssuerAddress}`);
199
103
  const feeAsset = getContract({
200
104
  address: feeAssetAddress.toString(),
201
- abi: l1Artifacts.feeAsset.contractAbi,
105
+ abi: FeeAssetArtifact.contractAbi,
202
106
  client: l1Client
203
107
  });
204
108
  logger.verbose(`Waiting for deployments to complete`);
@@ -209,7 +113,7 @@ export const deploySharedContracts = async (l1Client, deployer, args, logger)=>{
209
113
  const { txHash } = await deployer.sendTransaction({
210
114
  to: feeAssetAddress.toString(),
211
115
  data: encodeFunctionData({
212
- abi: l1Artifacts.feeAsset.contractAbi,
116
+ abi: FeeAssetArtifact.contractAbi,
213
117
  functionName: 'addMinter',
214
118
  args: [
215
119
  coinIssuerAddress.toString()
@@ -221,23 +125,13 @@ export const deploySharedContracts = async (l1Client, deployer, args, logger)=>{
221
125
  logger.verbose(`Added coin issuer ${coinIssuerAddress} as minter on fee asset in ${txHash}`);
222
126
  txHashes.push(txHash);
223
127
  }
224
- const { txHash: setGovernanceTxHash } = await deployer.sendTransaction({
225
- to: registryAddress.toString(),
226
- data: encodeFunctionData({
227
- abi: l1Artifacts.registry.contractAbi,
228
- functionName: 'updateGovernance',
229
- args: [
230
- governanceAddress.toString()
231
- ]
232
- })
233
- });
234
- txHashes.push(setGovernanceTxHash);
128
+ // Registry ownership will be transferred to governance later, after rollup is added
235
129
  let feeAssetHandlerAddress = undefined;
236
130
  let stakingAssetHandlerAddress = undefined;
237
131
  let zkPassportVerifierAddress = undefined;
238
132
  // Only if not on mainnet will we deploy the handlers
239
133
  if (l1Client.chain.id !== 1) {
240
- /* -------------------------------------------------------------------------- */ /* CHEAT CODES START HERE */ /* -------------------------------------------------------------------------- */ feeAssetHandlerAddress = await deployer.deploy(l1Artifacts.feeAssetHandler, [
134
+ /* -------------------------------------------------------------------------- */ /* CHEAT CODES START HERE */ /* -------------------------------------------------------------------------- */ feeAssetHandlerAddress = await deployer.deploy(FeeAssetHandlerArtifact, [
241
135
  l1Client.account.address,
242
136
  feeAssetAddress.toString(),
243
137
  BigInt(1e18)
@@ -246,7 +140,7 @@ export const deploySharedContracts = async (l1Client, deployer, args, logger)=>{
246
140
  const { txHash } = await deployer.sendTransaction({
247
141
  to: feeAssetAddress.toString(),
248
142
  data: encodeFunctionData({
249
- abi: l1Artifacts.feeAsset.contractAbi,
143
+ abi: FeeAssetArtifact.contractAbi,
250
144
  functionName: 'addMinter',
251
145
  args: [
252
146
  feeAssetHandlerAddress.toString()
@@ -283,14 +177,14 @@ export const deploySharedContracts = async (l1Client, deployer, args, logger)=>{
283
177
  skipBindCheck: args.zkPassportArgs?.mockZkPassportVerifier ?? false,
284
178
  skipMerkleCheck: true
285
179
  };
286
- stakingAssetHandlerAddress = await deployer.deploy(l1Artifacts.stakingAssetHandler, [
180
+ stakingAssetHandlerAddress = await deployer.deploy(StakingAssetHandlerArtifact, [
287
181
  stakingAssetHandlerDeployArgs
288
182
  ]);
289
183
  logger.verbose(`Deployed StakingAssetHandler at ${stakingAssetHandlerAddress}`);
290
184
  const { txHash: stakingMinterTxHash } = await deployer.sendTransaction({
291
185
  to: stakingAssetAddress.toString(),
292
186
  data: encodeFunctionData({
293
- abi: l1Artifacts.stakingAsset.contractAbi,
187
+ abi: StakingAssetArtifact.contractAbi,
294
188
  functionName: 'addMinter',
295
189
  args: [
296
190
  stakingAssetHandlerAddress.toString()
@@ -309,17 +203,12 @@ export const deploySharedContracts = async (l1Client, deployer, args, logger)=>{
309
203
  logger.verbose(`Deployed shared contracts`);
310
204
  const registry = new RegistryContract(l1Client, registryAddress);
311
205
  /* -------------------------------------------------------------------------- */ /* FUND REWARD DISTRIBUTOR START */ /* -------------------------------------------------------------------------- */ const rewardDistributorAddress = await registry.getRewardDistributor();
312
- const rewardDistributor = getContract({
313
- address: rewardDistributorAddress.toString(),
314
- abi: l1Artifacts.rewardDistributor.contractAbi,
315
- client: l1Client
316
- });
317
- const blockReward = await rewardDistributor.read.BLOCK_REWARD();
206
+ const blockReward = getRewardConfig(networkName).blockReward;
318
207
  const funding = blockReward * 200000n;
319
208
  const { txHash: fundRewardDistributorTxHash } = await deployer.sendTransaction({
320
209
  to: feeAssetAddress.toString(),
321
210
  data: encodeFunctionData({
322
- abi: l1Artifacts.feeAsset.contractAbi,
211
+ abi: FeeAssetArtifact.contractAbi,
323
212
  functionName: 'mint',
324
213
  args: [
325
214
  rewardDistributorAddress.toString(),
@@ -368,7 +257,7 @@ const getZkPassportVerifierAddress = async (deployer, args)=>{
368
257
  * @param logger - The logger.
369
258
  * @param txUtilsConfig - The L1 tx utils config.
370
259
  */ export const deployRollupForUpgrade = async (extendedClient, args, registryAddress, logger, txUtilsConfig)=>{
371
- const deployer = new L1Deployer(extendedClient, args.salt, args.acceleratedTestDeployments, logger, txUtilsConfig);
260
+ const deployer = new L1Deployer(extendedClient, args.salt, undefined, args.acceleratedTestDeployments, logger, txUtilsConfig);
372
261
  const addresses = await RegistryContract.collectAddresses(extendedClient, registryAddress, 'canonical');
373
262
  const { rollup, slashFactoryAddress } = await deployRollup(extendedClient, deployer, args, addresses, logger);
374
263
  await deployer.waitForDeployments();
@@ -378,14 +267,14 @@ const getZkPassportVerifierAddress = async (deployer, args)=>{
378
267
  };
379
268
  };
380
269
  export const deploySlashFactory = async (deployer, rollupAddress, logger)=>{
381
- const slashFactoryAddress = await deployer.deploy(l1Artifacts.slashFactory, [
270
+ const slashFactoryAddress = await deployer.deploy(SlashFactoryArtifact, [
382
271
  rollupAddress
383
272
  ]);
384
273
  logger.verbose(`Deployed SlashFactory at ${slashFactoryAddress}`);
385
274
  return slashFactoryAddress;
386
275
  };
387
276
  export const deployUpgradePayload = async (deployer, addresses)=>{
388
- const payloadAddress = await deployer.deploy(l1Artifacts.registerNewRollupVersionPayload, [
277
+ const payloadAddress = await deployer.deploy(RegisterNewRollupVersionPayloadArtifact, [
389
278
  addresses.registryAddress.toString(),
390
279
  addresses.rollupAddress.toString()
391
280
  ]);
@@ -418,6 +307,9 @@ export const deployUpgradePayload = async (deployer, addresses)=>{
418
307
  aztecProofSubmissionEpochs: args.aztecProofSubmissionEpochs,
419
308
  slashingQuorum: args.slashingQuorum,
420
309
  slashingRoundSize: args.slashingRoundSize,
310
+ slashingLifetimeInRounds: args.slashingLifetimeInRounds,
311
+ slashingExecutionDelayInRounds: args.slashingExecutionDelayInRounds,
312
+ slashingVetoer: args.slashingVetoer.toString(),
421
313
  manaTarget: args.manaTarget,
422
314
  provingCostPerMana: args.provingCostPerMana,
423
315
  rewardConfig: rewardConfig,
@@ -440,7 +332,7 @@ export const deployUpgradePayload = async (deployer, addresses)=>{
440
332
  genesisStateArgs,
441
333
  rollupConfigArgs
442
334
  ];
443
- const rollupAddress = await deployer.deploy(l1Artifacts.rollup, rollupArgs);
335
+ const rollupAddress = await deployer.deploy(RollupArtifact, rollupArgs);
444
336
  logger.verbose(`Deployed Rollup at ${rollupAddress}`, rollupConfigArgs);
445
337
  const rollupContract = new RollupContract(extendedClient, rollupAddress);
446
338
  await deployer.waitForDeployments();
@@ -451,7 +343,7 @@ export const deployUpgradePayload = async (deployer, addresses)=>{
451
343
  const { txHash: mintTxHash } = await deployer.sendTransaction({
452
344
  to: addresses.feeJuiceAddress.toString(),
453
345
  data: encodeFunctionData({
454
- abi: l1Artifacts.feeAsset.contractAbi,
346
+ abi: FeeAssetArtifact.contractAbi,
455
347
  functionName: 'mint',
456
348
  args: [
457
349
  feeJuicePortalAddress.toString(),
@@ -462,14 +354,14 @@ export const deployUpgradePayload = async (deployer, addresses)=>{
462
354
  logger.verbose(`Funding fee juice portal with ${args.feeJuicePortalInitialBalance} fee juice in ${mintTxHash} (accelerated test deployments)`);
463
355
  txHashes.push(mintTxHash);
464
356
  }
465
- const slashFactoryAddress = await deployer.deploy(l1Artifacts.slashFactory, [
357
+ const slashFactoryAddress = await deployer.deploy(SlashFactoryArtifact, [
466
358
  rollupAddress.toString()
467
359
  ]);
468
360
  logger.verbose(`Deployed SlashFactory at ${slashFactoryAddress}`);
469
361
  // We need to call a function on the registry to set the various contract addresses.
470
362
  const registryContract = getContract({
471
363
  address: getAddress(addresses.registryAddress.toString()),
472
- abi: l1Artifacts.registry.contractAbi,
364
+ abi: RegistryArtifact.contractAbi,
473
365
  client: extendedClient
474
366
  });
475
367
  // Only if we are the owner will we be sending these transactions
@@ -484,7 +376,7 @@ export const deployUpgradePayload = async (deployer, addresses)=>{
484
376
  const { txHash: addRollupTxHash } = await deployer.sendTransaction({
485
377
  to: addresses.registryAddress.toString(),
486
378
  data: encodeFunctionData({
487
- abi: l1Artifacts.registry.contractAbi,
379
+ abi: RegistryArtifact.contractAbi,
488
380
  functionName: 'addRollup',
489
381
  args: [
490
382
  getAddress(rollupContract.address)
@@ -500,7 +392,7 @@ export const deployUpgradePayload = async (deployer, addresses)=>{
500
392
  // We need to call a function on the registry to set the various contract addresses.
501
393
  const gseContract = getContract({
502
394
  address: getAddress(addresses.gseAddress.toString()),
503
- abi: l1Artifacts.gse.contractAbi,
395
+ abi: GSEArtifact.contractAbi,
504
396
  client: extendedClient
505
397
  });
506
398
  if (await gseContract.read.owner() === getAddress(extendedClient.account.address)) {
@@ -510,7 +402,7 @@ export const deployUpgradePayload = async (deployer, addresses)=>{
510
402
  const { txHash: addRollupTxHash } = await deployer.sendTransaction({
511
403
  to: addresses.gseAddress.toString(),
512
404
  data: encodeFunctionData({
513
- abi: l1Artifacts.gse.contractAbi,
405
+ abi: GSEArtifact.contractAbi,
514
406
  functionName: 'addRollup',
515
407
  args: [
516
408
  getAddress(rollupContract.address)
@@ -531,7 +423,7 @@ export const deployUpgradePayload = async (deployer, addresses)=>{
531
423
  if (args.initialValidators && await gseContract.read.isRollupRegistered([
532
424
  rollupContract.address
533
425
  ])) {
534
- await addMultipleValidators(extendedClient, deployer, rollupAddress.toString(), addresses.stakingAssetAddress.toString(), args.initialValidators, args.acceleratedTestDeployments, logger);
426
+ await addMultipleValidators(extendedClient, deployer, addresses.gseAddress.toString(), rollupAddress.toString(), addresses.stakingAssetAddress.toString(), args.initialValidators, args.acceleratedTestDeployments, logger);
535
427
  }
536
428
  await deployer.waitForDeployments();
537
429
  await Promise.all(txHashes.map((txHash)=>extendedClient.waitForTransactionReceipt({
@@ -547,12 +439,12 @@ export const handoverToGovernance = async (extendedClient, deployer, registryAdd
547
439
  // We need to call a function on the registry to set the various contract addresses.
548
440
  const registryContract = getContract({
549
441
  address: getAddress(registryAddress.toString()),
550
- abi: l1Artifacts.registry.contractAbi,
442
+ abi: RegistryArtifact.contractAbi,
551
443
  client: extendedClient
552
444
  });
553
445
  const gseContract = getContract({
554
446
  address: getAddress(gseAddress.toString()),
555
- abi: l1Artifacts.gse.contractAbi,
447
+ abi: GSEArtifact.contractAbi,
556
448
  client: extendedClient
557
449
  });
558
450
  const txHashes = [];
@@ -562,7 +454,7 @@ export const handoverToGovernance = async (extendedClient, deployer, registryAdd
562
454
  const { txHash: transferOwnershipTxHash } = await deployer.sendTransaction({
563
455
  to: registryAddress.toString(),
564
456
  data: encodeFunctionData({
565
- abi: l1Artifacts.registry.contractAbi,
457
+ abi: RegistryArtifact.contractAbi,
566
458
  functionName: 'transferOwnership',
567
459
  args: [
568
460
  getAddress(governanceAddress.toString())
@@ -578,7 +470,7 @@ export const handoverToGovernance = async (extendedClient, deployer, registryAdd
578
470
  const { txHash: transferOwnershipTxHash } = await deployer.sendTransaction({
579
471
  to: gseContract.address,
580
472
  data: encodeFunctionData({
581
- abi: l1Artifacts.gse.contractAbi,
473
+ abi: GSEArtifact.contractAbi,
582
474
  functionName: 'transferOwnership',
583
475
  args: [
584
476
  getAddress(governanceAddress.toString())
@@ -604,9 +496,9 @@ export const handoverToGovernance = async (extendedClient, deployer, registryAdd
604
496
  * @param validators - The validators to initialize.
605
497
  * @param acceleratedTestDeployments - Whether to use accelerated test deployments.
606
498
  * @param logger - The logger.
607
- */ export const addMultipleValidators = async (extendedClient, deployer, rollupAddress, stakingAssetAddress, validators, acceleratedTestDeployments, logger)=>{
499
+ */ export const addMultipleValidators = async (extendedClient, deployer, gseAddress, rollupAddress, stakingAssetAddress, validators, acceleratedTestDeployments, logger)=>{
608
500
  const rollup = new RollupContract(extendedClient, rollupAddress);
609
- const depositAmount = await rollup.getDepositAmount();
501
+ const activationThreshold = await rollup.getActivationThreshold();
610
502
  if (validators && validators.length > 0) {
611
503
  // Check if some of the initial validators are already registered, so we support idempotent deployments
612
504
  if (!acceleratedTestDeployments) {
@@ -621,20 +513,26 @@ export const handoverToGovernance = async (extendedClient, deployer, registryAdd
621
513
  validators = enrichedValidators.filter((v)=>v.status === 0).map((v)=>v.operator);
622
514
  }
623
515
  if (validators.length > 0) {
624
- const multiAdder = await deployer.deploy(l1Artifacts.multiAdder, [
516
+ const gseContract = new GSEContract(extendedClient, gseAddress);
517
+ const multiAdder = await deployer.deploy(MultiAdderArtifact, [
625
518
  rollupAddress,
626
519
  deployer.client.account.address
627
520
  ]);
628
- const validatorsTuples = validators.map((v)=>({
629
- attester: getAddress(v.attester.toString()),
630
- withdrawer: getAddress(v.withdrawer.toString())
631
- }));
521
+ const makeValidatorTuples = async (validator)=>{
522
+ const registrationTuple = await gseContract.makeRegistrationTuple(validator.bn254SecretKey.getValue());
523
+ return {
524
+ attester: getAddress(validator.attester.toString()),
525
+ withdrawer: getAddress(validator.withdrawer.toString()),
526
+ ...registrationTuple
527
+ };
528
+ };
529
+ const validatorsTuples = await Promise.all(validators.map(makeValidatorTuples));
632
530
  // Mint tokens, approve them, use cheat code to initialise validator set without setting up the epoch.
633
- const stakeNeeded = depositAmount * BigInt(validators.length);
531
+ const stakeNeeded = activationThreshold * BigInt(validators.length);
634
532
  const { txHash } = await deployer.sendTransaction({
635
533
  to: stakingAssetAddress,
636
534
  data: encodeFunctionData({
637
- abi: l1Artifacts.stakingAsset.contractAbi,
535
+ abi: StakingAssetArtifact.contractAbi,
638
536
  functionName: 'mint',
639
537
  args: [
640
538
  multiAdder.toString(),
@@ -650,7 +548,7 @@ export const handoverToGovernance = async (extendedClient, deployer, registryAdd
650
548
  }
651
549
  const addValidatorsTxHash = await deployer.client.writeContract({
652
550
  address: multiAdder.toString(),
653
- abi: l1Artifacts.multiAdder.contractAbi,
551
+ abi: MultiAdderArtifact.contractAbi,
654
552
  functionName: 'addValidators',
655
553
  args: [
656
554
  validatorsTuples
@@ -676,7 +574,7 @@ export const handoverToGovernance = async (extendedClient, deployer, registryAdd
676
574
  * @param logger - The logger.
677
575
  */ // eslint-disable-next-line camelcase
678
576
  export const cheat_initializeFeeAssetHandler = async (extendedClient, deployer, feeAssetAddress, logger)=>{
679
- const feeAssetHandlerAddress = await deployer.deploy(l1Artifacts.feeAssetHandler, [
577
+ const feeAssetHandlerAddress = await deployer.deploy(FeeAssetHandlerArtifact, [
680
578
  extendedClient.account.address,
681
579
  feeAssetAddress.toString(),
682
580
  BigInt(1e18)
@@ -685,7 +583,7 @@ export const cheat_initializeFeeAssetHandler = async (extendedClient, deployer,
685
583
  const { txHash } = await deployer.sendTransaction({
686
584
  to: feeAssetAddress.toString(),
687
585
  data: encodeFunctionData({
688
- abi: l1Artifacts.feeAsset.contractAbi,
586
+ abi: FeeAssetArtifact.contractAbi,
689
587
  functionName: 'addMinter',
690
588
  args: [
691
589
  feeAssetHandlerAddress.toString()
@@ -708,6 +606,8 @@ export const cheat_initializeFeeAssetHandler = async (extendedClient, deployer,
708
606
  * @returns A list of ETH addresses of the deployed contracts.
709
607
  */ export const deployL1Contracts = async (rpcUrls, account, chain, logger, args, txUtilsConfig = getL1TxUtilsConfigEnvVars())=>{
710
608
  const l1Client = createExtendedL1Client(rpcUrls, account, chain);
609
+ // Deploy multicall3 if it does not exist in this network
610
+ await deployMulticall3(l1Client, logger);
711
611
  // We are assuming that you are running this on a local anvil node which have 1s block times
712
612
  // To align better with actual deployment, we update the block interval to 12s
713
613
  const rpcCall = async (method, params)=>{
@@ -728,8 +628,9 @@ export const cheat_initializeFeeAssetHandler = async (extendedClient, deployer,
728
628
  }
729
629
  }
730
630
  logger.verbose(`Deploying contracts from ${account.address.toString()}`);
731
- const deployer = new L1Deployer(l1Client, args.salt, args.acceleratedTestDeployments, logger, txUtilsConfig);
732
- const { feeAssetAddress, feeAssetHandlerAddress, stakingAssetAddress, stakingAssetHandlerAddress, registryAddress, gseAddress, rewardDistributorAddress, zkPassportVerifierAddress } = await deploySharedContracts(l1Client, deployer, args, logger);
631
+ const dateProvider = new DateProvider();
632
+ const deployer = new L1Deployer(l1Client, args.salt, dateProvider, args.acceleratedTestDeployments, logger, txUtilsConfig);
633
+ const { feeAssetAddress, feeAssetHandlerAddress, stakingAssetAddress, stakingAssetHandlerAddress, registryAddress, gseAddress, governanceAddress, rewardDistributorAddress, zkPassportVerifierAddress } = await deploySharedContracts(l1Client, deployer, args, logger);
733
634
  const { rollup, slashFactoryAddress } = await deployRollup(l1Client, deployer, args, {
734
635
  feeJuiceAddress: feeAssetAddress,
735
636
  registryAddress,
@@ -739,10 +640,12 @@ export const cheat_initializeFeeAssetHandler = async (extendedClient, deployer,
739
640
  }, logger);
740
641
  logger.verbose('Waiting for rollup and slash factory to be deployed');
741
642
  await deployer.waitForDeployments();
643
+ // Now that the rollup has been deployed and added to the registry, transfer ownership to governance
644
+ await handoverToGovernance(l1Client, deployer, registryAddress, gseAddress, governanceAddress, logger, args.acceleratedTestDeployments);
645
+ logger.info(`Handing over to governance complete`);
742
646
  logger.verbose(`All transactions for L1 deployment have been mined`);
743
647
  const l1Contracts = await RegistryContract.collectAddresses(l1Client, registryAddress, 'canonical');
744
648
  logger.info(`Aztec L1 contracts initialized`, l1Contracts);
745
- logger.info(`Handing over to governance`);
746
649
  if (isAnvilTestChain(chain.id)) {
747
650
  // @note We make a time jump PAST the very first slot to not have to deal with the edge case of the first slot.
748
651
  // The edge case being that the genesis block is already occupying slot 0, so we cannot have another block.
@@ -787,7 +690,7 @@ export class L1Deployer {
787
690
  salt;
788
691
  txHashes;
789
692
  l1TxUtils;
790
- constructor(client, maybeSalt, acceleratedTestDeployments = false, logger = createLogger('L1Deployer'), txUtilsConfig){
693
+ constructor(client, maybeSalt, dateProvider = new DateProvider(), acceleratedTestDeployments = false, logger = createLogger('L1Deployer'), txUtilsConfig){
791
694
  this.client = client;
792
695
  this.acceleratedTestDeployments = acceleratedTestDeployments;
793
696
  this.logger = logger;
@@ -796,14 +699,26 @@ export class L1Deployer {
796
699
  this.salt = maybeSalt ? padHex(numberToHex(maybeSalt), {
797
700
  size: 32
798
701
  }) : undefined;
799
- this.l1TxUtils = new L1TxUtils(this.client, this.logger, this.txUtilsConfig, this.acceleratedTestDeployments);
702
+ this.l1TxUtils = new L1TxUtils(this.client, this.logger, dateProvider, this.txUtilsConfig, this.acceleratedTestDeployments);
800
703
  }
801
704
  async deploy(params, args = []) {
802
- const { txHash, address } = await deployL1Contract(this.client, params.contractAbi, params.contractBytecode, args, this.salt, params.libraries, this.logger, this.l1TxUtils, this.acceleratedTestDeployments);
803
- if (txHash) {
804
- this.txHashes.push(txHash);
705
+ this.logger.debug(`Deploying ${params.name} contract`, {
706
+ args
707
+ });
708
+ try {
709
+ const { txHash, address } = await deployL1Contract(this.client, params.contractAbi, params.contractBytecode, args, this.salt, params.libraries, this.logger, this.l1TxUtils, this.acceleratedTestDeployments);
710
+ if (txHash) {
711
+ this.txHashes.push(txHash);
712
+ }
713
+ this.logger.debug(`Deployed ${params.name} at ${address}`, {
714
+ args
715
+ });
716
+ return address;
717
+ } catch (error) {
718
+ throw new Error(`Failed to deploy ${params.name}`, {
719
+ cause: formatViemError(error)
720
+ });
805
721
  }
806
- return address;
807
722
  }
808
723
  async waitForDeployments() {
809
724
  if (this.acceleratedTestDeployments) {
@@ -838,7 +753,7 @@ export class L1Deployer {
838
753
  let resultingAddress = undefined;
839
754
  if (!l1TxUtils) {
840
755
  const config = getL1TxUtilsConfigEnvVars();
841
- l1TxUtils = new L1TxUtils(extendedClient, logger, config, acceleratedTestDeployments);
756
+ l1TxUtils = new L1TxUtils(extendedClient, logger, undefined, config, acceleratedTestDeployments);
842
757
  }
843
758
  if (libraries) {
844
759
  // Note that this does NOT work well for linked libraries having linked libraries.
package/dest/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  export * from './constants.js';
2
2
  export * from './deploy_l1_contracts.js';
3
3
  export * from './chain.js';
4
- export * from './eth_cheat_codes.js';
5
4
  export * from './l1_tx_utils.js';
6
5
  export * from './l1_contract_addresses.js';
7
6
  export * from './l1_reader.js';
@@ -13,4 +12,5 @@ export * from './queries.js';
13
12
  export * from './client.js';
14
13
  export * from './account.js';
15
14
  export * from './l1_types.js';
15
+ export * from './l1_artifacts.js';
16
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC"}
package/dest/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  export * from './constants.js';
2
2
  export * from './deploy_l1_contracts.js';
3
3
  export * from './chain.js';
4
- export * from './eth_cheat_codes.js';
5
4
  export * from './l1_tx_utils.js';
6
5
  export * from './l1_contract_addresses.js';
7
6
  export * from './l1_reader.js';
@@ -13,3 +12,4 @@ export * from './queries.js';
13
12
  export * from './client.js';
14
13
  export * from './account.js';
15
14
  export * from './l1_types.js';
15
+ export * from './l1_artifacts.js';