@aztec/ethereum 4.0.0-nightly.20250907 → 4.0.0-nightly.20260108
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.
- package/dest/account.d.ts +1 -1
- package/dest/chain.d.ts +1 -1
- package/dest/client.d.ts +2 -2
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +6 -2
- package/dest/config.d.ts +18 -46
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +40 -285
- package/dest/constants.d.ts +1 -1
- package/dest/contracts/empire_base.d.ts +8 -6
- package/dest/contracts/empire_base.d.ts.map +1 -1
- package/dest/contracts/empire_base.js +1 -1
- package/dest/contracts/empire_slashing_proposer.d.ts +8 -6
- package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/empire_slashing_proposer.js +18 -3
- package/dest/contracts/errors.d.ts +1 -1
- package/dest/contracts/errors.d.ts.map +1 -1
- package/dest/contracts/fee_asset_handler.d.ts +4 -4
- package/dest/contracts/fee_asset_handler.d.ts.map +1 -1
- package/dest/contracts/fee_juice.d.ts +1 -1
- package/dest/contracts/fee_juice.d.ts.map +1 -1
- package/dest/contracts/governance.d.ts +16 -16
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +7 -3
- package/dest/contracts/governance_proposer.d.ts +7 -6
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +400 -12
- package/dest/contracts/gse.d.ts +1 -1
- package/dest/contracts/gse.d.ts.map +1 -1
- package/dest/contracts/inbox.d.ts +7 -3
- package/dest/contracts/inbox.d.ts.map +1 -1
- package/dest/contracts/inbox.js +4 -0
- package/dest/contracts/index.d.ts +1 -1
- package/dest/contracts/multicall.d.ts +5 -7
- package/dest/contracts/multicall.d.ts.map +1 -1
- package/dest/contracts/multicall.js +6 -4
- package/dest/contracts/registry.d.ts +1 -1
- package/dest/contracts/registry.d.ts.map +1 -1
- package/dest/contracts/rollup.d.ts +169 -118
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +714 -243
- package/dest/contracts/slasher_contract.d.ts +11 -1
- package/dest/contracts/slasher_contract.d.ts.map +1 -1
- package/dest/contracts/slasher_contract.js +18 -0
- package/dest/contracts/tally_slashing_proposer.d.ts +15 -7
- package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/tally_slashing_proposer.js +15 -5
- package/dest/contracts/utils.d.ts +1 -1
- package/dest/deploy_aztec_l1_contracts.d.ts +247 -0
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -0
- package/dest/deploy_aztec_l1_contracts.js +336 -0
- package/dest/deploy_l1_contract.d.ts +68 -0
- package/dest/deploy_l1_contract.d.ts.map +1 -0
- package/dest/deploy_l1_contract.js +312 -0
- package/dest/eth-signer/eth-signer.d.ts +1 -1
- package/dest/eth-signer/index.d.ts +1 -1
- package/dest/forwarder_proxy.d.ts +32 -0
- package/dest/forwarder_proxy.d.ts.map +1 -0
- package/dest/forwarder_proxy.js +93 -0
- package/dest/l1_artifacts.d.ts +17733 -6280
- package/dest/l1_artifacts.d.ts.map +1 -1
- package/dest/l1_artifacts.js +10 -5
- package/dest/l1_contract_addresses.d.ts +8 -4
- package/dest/l1_contract_addresses.d.ts.map +1 -1
- package/dest/l1_contract_addresses.js +5 -4
- package/dest/l1_reader.d.ts +4 -2
- package/dest/l1_reader.d.ts.map +1 -1
- package/dest/l1_reader.js +7 -1
- package/dest/l1_tx_utils/config.d.ts +59 -0
- package/dest/l1_tx_utils/config.d.ts.map +1 -0
- package/dest/l1_tx_utils/config.js +96 -0
- package/dest/l1_tx_utils/constants.d.ts +12 -0
- package/dest/l1_tx_utils/constants.d.ts.map +1 -0
- package/dest/l1_tx_utils/constants.js +39 -0
- package/dest/l1_tx_utils/factory.d.ts +24 -0
- package/dest/l1_tx_utils/factory.d.ts.map +1 -0
- package/dest/l1_tx_utils/factory.js +12 -0
- package/dest/l1_tx_utils/fee-strategies/index.d.ts +10 -0
- package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/index.js +12 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +8 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +129 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +23 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +191 -0
- package/dest/l1_tx_utils/fee-strategies/types.d.ts +51 -0
- package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/types.js +3 -0
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts +41 -0
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +48 -0
- package/dest/l1_tx_utils/index-blobs.d.ts +3 -0
- package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -0
- package/dest/l1_tx_utils/index-blobs.js +2 -0
- package/dest/l1_tx_utils/index.d.ts +12 -0
- package/dest/l1_tx_utils/index.d.ts.map +1 -0
- package/dest/l1_tx_utils/index.js +12 -0
- package/dest/l1_tx_utils/interfaces.d.ts +76 -0
- package/dest/l1_tx_utils/interfaces.d.ts.map +1 -0
- package/dest/l1_tx_utils/interfaces.js +4 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +233 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.js +506 -0
- package/dest/l1_tx_utils/l1_tx_utils.d.ts +94 -0
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/l1_tx_utils.js +623 -0
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +26 -0
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +1 -0
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.js +26 -0
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +83 -0
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +323 -0
- package/dest/l1_tx_utils/signer.d.ts +4 -0
- package/dest/l1_tx_utils/signer.d.ts.map +1 -0
- package/dest/l1_tx_utils/signer.js +16 -0
- package/dest/l1_tx_utils/types.d.ts +67 -0
- package/dest/l1_tx_utils/types.d.ts.map +1 -0
- package/dest/l1_tx_utils/types.js +26 -0
- package/dest/l1_tx_utils/utils.d.ts +4 -0
- package/dest/l1_tx_utils/utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/utils.js +14 -0
- package/dest/l1_types.d.ts +1 -1
- package/dest/publisher_manager.d.ts +8 -3
- package/dest/publisher_manager.d.ts.map +1 -1
- package/dest/publisher_manager.js +36 -8
- package/dest/queries.d.ts +1 -1
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +20 -14
- package/dest/test/chain_monitor.d.ts +29 -22
- package/dest/test/chain_monitor.d.ts.map +1 -1
- package/dest/test/chain_monitor.js +81 -38
- package/dest/test/delayed_tx_utils.d.ts +3 -3
- package/dest/test/delayed_tx_utils.d.ts.map +1 -1
- package/dest/test/delayed_tx_utils.js +2 -2
- package/dest/test/eth_cheat_codes.d.ts +36 -14
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes.js +126 -31
- package/dest/test/eth_cheat_codes_with_state.d.ts +1 -1
- package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -1
- package/dest/test/index.d.ts +1 -1
- package/dest/test/rollup_cheat_codes.d.ts +23 -20
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +82 -43
- package/dest/test/start_anvil.d.ts +4 -1
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +2 -1
- package/dest/test/tx_delayer.d.ts +1 -1
- package/dest/test/tx_delayer.d.ts.map +1 -1
- package/dest/test/tx_delayer.js +4 -3
- package/dest/test/upgrade_utils.d.ts +1 -1
- package/dest/test/upgrade_utils.d.ts.map +1 -1
- package/dest/test/upgrade_utils.js +3 -2
- package/dest/types.d.ts +57 -2
- package/dest/types.d.ts.map +1 -1
- package/dest/utils.d.ts +15 -3
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +28 -161
- package/dest/zkPassportVerifierAddress.d.ts +1 -1
- package/dest/zkPassportVerifierAddress.js +1 -1
- package/package.json +33 -14
- package/src/client.ts +3 -3
- package/src/config.ts +49 -358
- package/src/contracts/empire_base.ts +7 -6
- package/src/contracts/empire_slashing_proposer.ts +23 -8
- package/src/contracts/fee_asset_handler.ts +1 -1
- package/src/contracts/governance.ts +3 -3
- package/src/contracts/governance_proposer.ts +19 -9
- package/src/contracts/inbox.ts +7 -2
- package/src/contracts/multicall.ts +12 -10
- package/src/contracts/rollup.ts +374 -236
- package/src/contracts/slasher_contract.ts +22 -0
- package/src/contracts/tally_slashing_proposer.ts +21 -9
- package/src/deploy_aztec_l1_contracts.ts +557 -0
- package/src/deploy_l1_contract.ts +362 -0
- package/src/forwarder_proxy.ts +108 -0
- package/src/l1_artifacts.ts +14 -6
- package/src/l1_contract_addresses.ts +24 -20
- package/src/l1_reader.ts +10 -2
- package/src/l1_tx_utils/README.md +177 -0
- package/src/l1_tx_utils/config.ts +161 -0
- package/src/l1_tx_utils/constants.ts +29 -0
- package/src/l1_tx_utils/factory.ts +64 -0
- package/src/l1_tx_utils/fee-strategies/index.ts +22 -0
- package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +163 -0
- package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +245 -0
- package/src/l1_tx_utils/fee-strategies/types.ts +56 -0
- package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +119 -0
- package/src/l1_tx_utils/index-blobs.ts +2 -0
- package/src/l1_tx_utils/index.ts +14 -0
- package/src/l1_tx_utils/interfaces.ts +86 -0
- package/src/l1_tx_utils/l1_fee_analyzer.ts +803 -0
- package/src/l1_tx_utils/l1_tx_utils.ts +738 -0
- package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +77 -0
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +419 -0
- package/src/l1_tx_utils/signer.ts +28 -0
- package/src/l1_tx_utils/types.ts +85 -0
- package/src/l1_tx_utils/utils.ts +16 -0
- package/src/publisher_manager.ts +51 -9
- package/src/queries.ts +24 -10
- package/src/test/chain_monitor.ts +102 -44
- package/src/test/delayed_tx_utils.ts +2 -2
- package/src/test/eth_cheat_codes.ts +150 -31
- package/src/test/rollup_cheat_codes.ts +95 -53
- package/src/test/start_anvil.ts +4 -0
- package/src/test/tx_delayer.ts +5 -3
- package/src/test/upgrade_utils.ts +3 -2
- package/src/types.ts +62 -0
- package/src/utils.ts +41 -184
- package/src/zkPassportVerifierAddress.ts +1 -1
- package/dest/deploy_l1_contracts.d.ts +0 -211
- package/dest/deploy_l1_contracts.d.ts.map +0 -1
- package/dest/deploy_l1_contracts.js +0 -1267
- package/dest/index.d.ts +0 -18
- package/dest/index.d.ts.map +0 -1
- package/dest/index.js +0 -17
- package/dest/l1_tx_utils.d.ts +0 -250
- package/dest/l1_tx_utils.d.ts.map +0 -1
- package/dest/l1_tx_utils.js +0 -826
- package/dest/l1_tx_utils_with_blobs.d.ts +0 -19
- package/dest/l1_tx_utils_with_blobs.d.ts.map +0 -1
- package/dest/l1_tx_utils_with_blobs.js +0 -85
- package/src/deploy_l1_contracts.ts +0 -1596
- package/src/index.ts +0 -17
- package/src/l1_tx_utils.ts +0 -1105
- package/src/l1_tx_utils_with_blobs.ts +0 -144
|
@@ -38,6 +38,19 @@ export class SlasherContract {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Checks if slashing is currently enabled. Slashing can be disabled by the vetoer.
|
|
43
|
+
* @returns True if slashing is enabled, false otherwise
|
|
44
|
+
*/
|
|
45
|
+
public async isSlashingEnabled(): Promise<boolean> {
|
|
46
|
+
try {
|
|
47
|
+
return await this.contract.read.isSlashingEnabled();
|
|
48
|
+
} catch (error) {
|
|
49
|
+
this.log.error(`Error checking if slashing is enabled`, error);
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
41
54
|
/**
|
|
42
55
|
* Gets the current vetoer address.
|
|
43
56
|
* @returns The vetoer address
|
|
@@ -47,6 +60,15 @@ export class SlasherContract {
|
|
|
47
60
|
return EthAddress.fromString(vetoer);
|
|
48
61
|
}
|
|
49
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Gets the disable duration by the vetoer.
|
|
65
|
+
* @returns The disable duration in seconds
|
|
66
|
+
*/
|
|
67
|
+
public async getSlashingDisableDuration(): Promise<number> {
|
|
68
|
+
const duration = await this.contract.read.SLASHING_DISABLE_DURATION();
|
|
69
|
+
return Number(duration);
|
|
70
|
+
}
|
|
71
|
+
|
|
50
72
|
/**
|
|
51
73
|
* Gets the current governance address.
|
|
52
74
|
* @returns The governance address
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { L1TxRequest } from '@aztec/ethereum/l1-tx-utils';
|
|
2
|
+
import type { ViemClient } from '@aztec/ethereum/types';
|
|
3
|
+
import { tryExtractEvent } from '@aztec/ethereum/utils';
|
|
4
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
5
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
3
6
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
7
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
@@ -85,11 +88,20 @@ export class TallySlashingProposerContract {
|
|
|
85
88
|
*/
|
|
86
89
|
public async getRound(round: bigint): Promise<{
|
|
87
90
|
isExecuted: boolean;
|
|
88
|
-
readyToExecute: boolean;
|
|
89
91
|
voteCount: bigint;
|
|
90
92
|
}> {
|
|
91
|
-
const [isExecuted,
|
|
92
|
-
return { isExecuted,
|
|
93
|
+
const [isExecuted, voteCount] = await this.contract.read.getRound([round]);
|
|
94
|
+
return { isExecuted, voteCount };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Check if a round is ready to execute at a given slot
|
|
99
|
+
* @param round - The round number to check
|
|
100
|
+
* @param slot - The slot number to check at
|
|
101
|
+
* @returns Whether the round is ready to execute
|
|
102
|
+
*/
|
|
103
|
+
public async isRoundReadyToExecute(round: bigint, slot: SlotNumber): Promise<boolean> {
|
|
104
|
+
return await this.contract.read.isRoundReadyToExecute([round, BigInt(slot)]);
|
|
93
105
|
}
|
|
94
106
|
|
|
95
107
|
/** Returns the slash actions and payload address for a given round (zero if no slash actions) */
|
|
@@ -140,7 +152,7 @@ export class TallySlashingProposerContract {
|
|
|
140
152
|
*/
|
|
141
153
|
public async buildVoteRequestFromSigner(
|
|
142
154
|
votes: Hex,
|
|
143
|
-
slot:
|
|
155
|
+
slot: SlotNumber,
|
|
144
156
|
signer: (msg: TypedDataDefinition) => Promise<Hex>,
|
|
145
157
|
): Promise<L1TxRequest> {
|
|
146
158
|
const typedData = this.buildVoteTypedData(votes, slot);
|
|
@@ -157,7 +169,7 @@ export class TallySlashingProposerContract {
|
|
|
157
169
|
}
|
|
158
170
|
|
|
159
171
|
/** Returns the typed data definition to EIP712-sign for voting */
|
|
160
|
-
public buildVoteTypedData(votes: Hex, slot:
|
|
172
|
+
public buildVoteTypedData(votes: Hex, slot: SlotNumber): TypedDataDefinition {
|
|
161
173
|
const domain = {
|
|
162
174
|
name: 'TallySlashingProposer',
|
|
163
175
|
version: '1',
|
|
@@ -178,12 +190,12 @@ export class TallySlashingProposerContract {
|
|
|
178
190
|
],
|
|
179
191
|
};
|
|
180
192
|
|
|
181
|
-
return { domain, types, primaryType: 'Vote', message: { votes, slot } };
|
|
193
|
+
return { domain, types, primaryType: 'Vote', message: { votes, slot: BigInt(slot) } };
|
|
182
194
|
}
|
|
183
195
|
|
|
184
196
|
/** Gets the digest to sign for voting directly from the contract */
|
|
185
|
-
public async getVoteDataDigest(votes: Hex, slot:
|
|
186
|
-
return Buffer32.fromString(await this.contract.read.getVoteSignatureDigest([votes, slot]));
|
|
197
|
+
public async getVoteDataDigest(votes: Hex, slot: SlotNumber): Promise<Buffer32> {
|
|
198
|
+
return Buffer32.fromString(await this.contract.read.getVoteSignatureDigest([votes, BigInt(slot)]));
|
|
187
199
|
}
|
|
188
200
|
|
|
189
201
|
/**
|
|
@@ -0,0 +1,557 @@
|
|
|
1
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { SecretValue, getActiveNetworkName } from '@aztec/foundation/config';
|
|
3
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
+
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
5
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
6
|
+
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
7
|
+
import type { Fr } from '@aztec/foundation/schemas';
|
|
8
|
+
import { fileURLToPath } from '@aztec/foundation/url';
|
|
9
|
+
|
|
10
|
+
import { bn254 } from '@noble/curves/bn254';
|
|
11
|
+
import type { Abi, Narrow } from 'abitype';
|
|
12
|
+
import { spawn } from 'child_process';
|
|
13
|
+
import { dirname, resolve } from 'path';
|
|
14
|
+
import readline from 'readline';
|
|
15
|
+
import type { Hex } from 'viem';
|
|
16
|
+
import { foundry, mainnet, sepolia } from 'viem/chains';
|
|
17
|
+
|
|
18
|
+
import { createEthereumChain, isAnvilTestChain } from './chain.js';
|
|
19
|
+
import { createExtendedL1Client } from './client.js';
|
|
20
|
+
import type { L1ContractsConfig } from './config.js';
|
|
21
|
+
import { deployMulticall3 } from './contracts/multicall.js';
|
|
22
|
+
import { RollupContract } from './contracts/rollup.js';
|
|
23
|
+
import type { L1ContractAddresses } from './l1_contract_addresses.js';
|
|
24
|
+
import type { L1TxUtilsConfig } from './l1_tx_utils/config.js';
|
|
25
|
+
import type { ExtendedViemWalletClient } from './types.js';
|
|
26
|
+
|
|
27
|
+
const logger = createLogger('ethereum:deploy_aztec_l1_contracts');
|
|
28
|
+
|
|
29
|
+
const JSON_DEPLOY_RESULT_PREFIX = 'JSON DEPLOY RESULT:';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Runs a process with the given command, arguments, and environment.
|
|
33
|
+
* If the process outputs a line starting with JSON_DEPLOY_RESULT_PREFIX,
|
|
34
|
+
* the JSON is parsed and returned.
|
|
35
|
+
*/
|
|
36
|
+
function runProcess<T>(
|
|
37
|
+
command: string,
|
|
38
|
+
args: string[],
|
|
39
|
+
env: Record<string, string | undefined>,
|
|
40
|
+
cwd: string,
|
|
41
|
+
): Promise<T | undefined> {
|
|
42
|
+
const { promise, resolve, reject } = promiseWithResolvers<T | undefined>();
|
|
43
|
+
const proc = spawn(command, args, {
|
|
44
|
+
cwd,
|
|
45
|
+
env: { ...process.env, ...env },
|
|
46
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
let result: T | undefined;
|
|
50
|
+
|
|
51
|
+
readline.createInterface({ input: proc.stdout }).on('line', line => {
|
|
52
|
+
const trimmedLine = line.trim();
|
|
53
|
+
if (trimmedLine.startsWith(JSON_DEPLOY_RESULT_PREFIX)) {
|
|
54
|
+
const jsonStr = trimmedLine.slice(JSON_DEPLOY_RESULT_PREFIX.length).trim();
|
|
55
|
+
// TODO(AD): should this be a zod parse?
|
|
56
|
+
result = JSON.parse(jsonStr);
|
|
57
|
+
} else {
|
|
58
|
+
logger.info(line);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
readline.createInterface({ input: proc.stderr }).on('line', logger.error.bind(logger));
|
|
62
|
+
|
|
63
|
+
proc.on('error', error => {
|
|
64
|
+
reject(new Error(`Failed to spawn ${command}: ${error.message}`));
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
proc.on('close', code => {
|
|
68
|
+
if (code !== 0) {
|
|
69
|
+
reject(new Error(`${command} exited with code ${code}. See logs for details.\n`));
|
|
70
|
+
} else {
|
|
71
|
+
resolve(result);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
return promise;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Covers an edge where where we may have a cached BlobLib that is not meant for production.
|
|
79
|
+
// Despite the profile apparently sometimes cached code remains (so says Lasse after his ignition-monorepo arc).
|
|
80
|
+
async function maybeForgeForceProductionBuild(l1ContractsPath: string, script: string, chainId: number) {
|
|
81
|
+
if (chainId === mainnet.id) {
|
|
82
|
+
logger.info(`Recompiling ${script} with production profile for mainnet deployment`);
|
|
83
|
+
logger.info('This may take a minute but ensures production BlobLib is used.');
|
|
84
|
+
await runProcess('forge', ['build', script, '--force'], { FOUNDRY_PROFILE: 'production' }, l1ContractsPath);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Validator types for initial validator setup
|
|
89
|
+
export interface G2PointJson {
|
|
90
|
+
x0: string;
|
|
91
|
+
x1: string;
|
|
92
|
+
y0: string;
|
|
93
|
+
y1: string;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Validator data passed to Solidity for registration.
|
|
98
|
+
* Solidity will derive publicKeyG1 and proofOfPossession from the privateKey.
|
|
99
|
+
*/
|
|
100
|
+
export interface ValidatorJson {
|
|
101
|
+
attester: string;
|
|
102
|
+
withdrawer: string;
|
|
103
|
+
/** BN254 secret key (private key) */
|
|
104
|
+
privateKey: string;
|
|
105
|
+
/** Pre-computed G2 public key (cannot be computed in Solidity) */
|
|
106
|
+
publicKeyInG2: G2PointJson;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Gets the path to the l1-contracts directory.
|
|
111
|
+
*/
|
|
112
|
+
export function getL1ContractsPath(): string {
|
|
113
|
+
// Try to find l1-contracts relative to this file
|
|
114
|
+
const currentDir = dirname(fileURLToPath(import.meta.url));
|
|
115
|
+
|
|
116
|
+
// Go up from yarn-project/ethereum/src to yarn-project, then to repo root, then to l1-contracts
|
|
117
|
+
const l1ContractsPath = resolve(currentDir, '..', '..', '..', 'l1-contracts');
|
|
118
|
+
return l1ContractsPath;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Computes the validator data for passing to Solidity.
|
|
123
|
+
* Only computes the G2 public key (which requires scalar multiplication on G2, not available in EVM).
|
|
124
|
+
* Solidity will derive G1 public key and proof of possession from the private key.
|
|
125
|
+
*/
|
|
126
|
+
export function computeValidatorData(operator: Operator): ValidatorJson {
|
|
127
|
+
const privateKey = operator.bn254SecretKey.getValue();
|
|
128
|
+
|
|
129
|
+
// Compute G2 public key: pk2 = privateKey * G2
|
|
130
|
+
// This is the only computation we need to do in TypeScript since G2 scalar mul
|
|
131
|
+
// is not available as an EVM precompile
|
|
132
|
+
const publicKeyG2 = bn254.G2.ProjectivePoint.BASE.multiply(privateKey);
|
|
133
|
+
const publicKeyG2Affine = publicKeyG2.toAffine();
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
attester: operator.attester.toString(),
|
|
137
|
+
withdrawer: operator.withdrawer.toString(),
|
|
138
|
+
privateKey: privateKey.toString(),
|
|
139
|
+
publicKeyInG2: {
|
|
140
|
+
x0: publicKeyG2Affine.x.c0.toString(),
|
|
141
|
+
x1: publicKeyG2Affine.x.c1.toString(),
|
|
142
|
+
y0: publicKeyG2Affine.y.c0.toString(),
|
|
143
|
+
y1: publicKeyG2Affine.y.c1.toString(),
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Deployed addresses from the rollup upgrade deployment.
|
|
150
|
+
*/
|
|
151
|
+
export interface RollupUpgradeAddresses {
|
|
152
|
+
rollupAddress: string;
|
|
153
|
+
verifierAddress: string;
|
|
154
|
+
slashFactoryAddress: string;
|
|
155
|
+
inboxAddress: string;
|
|
156
|
+
outboxAddress: string;
|
|
157
|
+
feeJuicePortalAddress: string;
|
|
158
|
+
rollupVersion: number;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Return type for rollup upgrade via forge.
|
|
163
|
+
*/
|
|
164
|
+
export interface ForgeRollupUpgradeResult {
|
|
165
|
+
rollupAddress: Hex;
|
|
166
|
+
verifierAddress: Hex;
|
|
167
|
+
slashFactoryAddress: Hex;
|
|
168
|
+
inboxAddress: Hex;
|
|
169
|
+
outboxAddress: Hex;
|
|
170
|
+
feeJuicePortalAddress: Hex;
|
|
171
|
+
rollupVersion: number;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export interface ForgeL1ContractsDeployResult extends ForgeRollupUpgradeResult {
|
|
175
|
+
registryAddress: Hex;
|
|
176
|
+
feeAssetAddress: Hex;
|
|
177
|
+
stakingAssetAddress: Hex;
|
|
178
|
+
gseAddress?: Hex;
|
|
179
|
+
rewardDistributorAddress: Hex;
|
|
180
|
+
coinIssuerAddress: Hex;
|
|
181
|
+
governanceProposerAddress: Hex;
|
|
182
|
+
governanceAddress: Hex;
|
|
183
|
+
dateGatedRelayerAddress?: Hex;
|
|
184
|
+
feeAssetHandlerAddress?: Hex;
|
|
185
|
+
stakingAssetHandlerAddress?: Hex;
|
|
186
|
+
zkPassportVerifierAddress?: Hex;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Deploys L1 contracts using forge and returns a result compatible with the TypeScript deployAztecL1Contracts function.
|
|
191
|
+
* This queries the Rollup contract to get the inbox, outbox, and feeJuicePortal addresses.
|
|
192
|
+
*
|
|
193
|
+
* All configuration is passed via environment variables to the forge script. The DeploymentConfiguration.sol
|
|
194
|
+
* contract reads these values and applies defaults for any unspecified parameters.
|
|
195
|
+
*
|
|
196
|
+
* @param rpcUrl - The RPC URL to use
|
|
197
|
+
* @param privateKey - The private key for the deployer (with 0x prefix)
|
|
198
|
+
* @param options - Additional deployment options (all optional with sensible defaults)
|
|
199
|
+
* @returns The deployment result with all contract addresses and an l1Client
|
|
200
|
+
*/
|
|
201
|
+
export async function deployAztecL1Contracts(
|
|
202
|
+
rpcUrl: string,
|
|
203
|
+
privateKey: `0x${string}`,
|
|
204
|
+
chainId: number,
|
|
205
|
+
args: DeployAztecL1ContractsArgs,
|
|
206
|
+
): Promise<DeployAztecL1ContractsReturnType> {
|
|
207
|
+
logger.info(`Deploying L1 contracts with config: ${jsonStringify(args)}`);
|
|
208
|
+
if (args.initialValidators && args.initialValidators.length > 0 && args.existingTokenAddress) {
|
|
209
|
+
throw new Error(
|
|
210
|
+
'Cannot deploy with both initialValidators and existingTokenAddress. ' +
|
|
211
|
+
'Initial validator funding requires minting tokens, which is not possible with an external token.',
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
const currentDir = dirname(fileURLToPath(import.meta.url));
|
|
215
|
+
const chain = createEthereumChain([rpcUrl], chainId);
|
|
216
|
+
|
|
217
|
+
const l1Client = createExtendedL1Client([rpcUrl], privateKey, chain.chainInfo);
|
|
218
|
+
const rpcCall = async (method: string, params: any[]) => {
|
|
219
|
+
logger.info(`Calling ${method} with params: ${JSON.stringify(params)}`);
|
|
220
|
+
return (await l1Client.transport.request({
|
|
221
|
+
method,
|
|
222
|
+
params,
|
|
223
|
+
})) as any;
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
logger.verbose(`Deploying contracts from ${l1Client.account.address.toString()}`);
|
|
227
|
+
|
|
228
|
+
// Deploy multicall3 if it does not exist in this network
|
|
229
|
+
// Sepolia and mainnet will have this.
|
|
230
|
+
await deployMulticall3(l1Client, logger);
|
|
231
|
+
|
|
232
|
+
if (isAnvilTestChain(chainId)) {
|
|
233
|
+
try {
|
|
234
|
+
// We are assuming that you are running this on a local anvil node which have 1s block times
|
|
235
|
+
// To align better with actual deployment, we update the block interval to 12s
|
|
236
|
+
await rpcCall('anvil_setBlockTimestampInterval', [args.ethereumSlotDuration]);
|
|
237
|
+
logger.warn(`Set block interval to ${args.ethereumSlotDuration}`);
|
|
238
|
+
} catch (e) {
|
|
239
|
+
logger.error(`Error setting block interval: ${e}`);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// Relative location of l1-contracts in monorepo or docker image.
|
|
244
|
+
const l1ContractsPath = resolve(currentDir, '..', '..', '..', 'l1-contracts');
|
|
245
|
+
|
|
246
|
+
const FORGE_SCRIPT = 'script/deploy/DeployAztecL1Contracts.s.sol';
|
|
247
|
+
await maybeForgeForceProductionBuild(l1ContractsPath, FORGE_SCRIPT, chainId);
|
|
248
|
+
|
|
249
|
+
// Verify contracts on Etherscan when on mainnet/sepolia and ETHERSCAN_API_KEY is available.
|
|
250
|
+
const isVerifiableChain = chainId === mainnet.id || chainId === sepolia.id;
|
|
251
|
+
const shouldVerify = isVerifiableChain && !!process.env.ETHERSCAN_API_KEY;
|
|
252
|
+
|
|
253
|
+
if (isVerifiableChain && !process.env.ETHERSCAN_API_KEY) {
|
|
254
|
+
logger.warn(
|
|
255
|
+
`Deploying to chain ${chainId} (${chainId === mainnet.id ? 'mainnet' : 'sepolia'}) without ETHERSCAN_API_KEY. ` +
|
|
256
|
+
`Contracts will NOT be verified on Etherscan. Set ETHERSCAN_API_KEY environment variable to enable verification.`,
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// From heuristic testing. More caused issues with anvil.
|
|
261
|
+
const MAGIC_ANVIL_BATCH_SIZE = 12;
|
|
262
|
+
// Anvil seems to stall with unbounded batch size. Otherwise no max batch size is desirable.
|
|
263
|
+
const forgeArgs = [
|
|
264
|
+
'script',
|
|
265
|
+
FORGE_SCRIPT,
|
|
266
|
+
'--sig',
|
|
267
|
+
'run()',
|
|
268
|
+
'--private-key',
|
|
269
|
+
privateKey,
|
|
270
|
+
'--rpc-url',
|
|
271
|
+
rpcUrl,
|
|
272
|
+
'--broadcast',
|
|
273
|
+
...(chainId === foundry.id ? ['--batch-size', MAGIC_ANVIL_BATCH_SIZE.toString()] : []),
|
|
274
|
+
...(shouldVerify ? ['--verify'] : []),
|
|
275
|
+
];
|
|
276
|
+
const forgeEnv = {
|
|
277
|
+
// Env vars required by l1-contracts/script/deploy/DeploymentConfiguration.sol.
|
|
278
|
+
NETWORK: getActiveNetworkName(),
|
|
279
|
+
FOUNDRY_PROFILE: chainId === mainnet.id ? 'production' : undefined,
|
|
280
|
+
...getDeployAztecL1ContractsEnvVars(args),
|
|
281
|
+
};
|
|
282
|
+
const result = await runProcess<ForgeL1ContractsDeployResult>('forge', forgeArgs, forgeEnv, l1ContractsPath);
|
|
283
|
+
if (!result) {
|
|
284
|
+
throw new Error('Forge script did not output deployment result');
|
|
285
|
+
}
|
|
286
|
+
logger.info(`Deployed L1 contracts with L1 addresses: ${jsonStringify(result)}`);
|
|
287
|
+
|
|
288
|
+
const rollup = new RollupContract(l1Client, result.rollupAddress);
|
|
289
|
+
|
|
290
|
+
if (isAnvilTestChain(chainId)) {
|
|
291
|
+
// @note We make a time jump PAST the very first slot to not have to deal with the edge case of the first slot.
|
|
292
|
+
// The edge case being that the genesis block is already occupying slot 0, so we cannot have another block.
|
|
293
|
+
try {
|
|
294
|
+
// Need to get the time
|
|
295
|
+
const currentSlot = await rollup.getSlotNumber();
|
|
296
|
+
|
|
297
|
+
if (currentSlot === 0) {
|
|
298
|
+
const ts = Number(await rollup.getTimestampForSlot(SlotNumber(1)));
|
|
299
|
+
await rpcCall('evm_setNextBlockTimestamp', [ts]);
|
|
300
|
+
await rpcCall('hardhat_mine', [1]);
|
|
301
|
+
const currentSlot = await rollup.getSlotNumber();
|
|
302
|
+
|
|
303
|
+
if (currentSlot !== 1) {
|
|
304
|
+
throw new Error(`Error jumping time: current slot is ${currentSlot}`);
|
|
305
|
+
}
|
|
306
|
+
logger.info(`Jumped to slot 1`);
|
|
307
|
+
}
|
|
308
|
+
} catch (e) {
|
|
309
|
+
throw new Error(`Error jumping time: ${e}`);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
return {
|
|
314
|
+
l1Client,
|
|
315
|
+
rollupVersion: result.rollupVersion,
|
|
316
|
+
l1ContractAddresses: {
|
|
317
|
+
rollupAddress: EthAddress.fromString(result.rollupAddress),
|
|
318
|
+
registryAddress: EthAddress.fromString(result.registryAddress),
|
|
319
|
+
inboxAddress: EthAddress.fromString(result.inboxAddress),
|
|
320
|
+
outboxAddress: EthAddress.fromString(result.outboxAddress),
|
|
321
|
+
feeJuiceAddress: EthAddress.fromString(result.feeAssetAddress),
|
|
322
|
+
feeJuicePortalAddress: EthAddress.fromString(result.feeJuicePortalAddress),
|
|
323
|
+
coinIssuerAddress: EthAddress.fromString(result.coinIssuerAddress),
|
|
324
|
+
rewardDistributorAddress: EthAddress.fromString(result.rewardDistributorAddress),
|
|
325
|
+
governanceProposerAddress: EthAddress.fromString(result.governanceProposerAddress),
|
|
326
|
+
governanceAddress: EthAddress.fromString(result.governanceAddress),
|
|
327
|
+
stakingAssetAddress: EthAddress.fromString(result.stakingAssetAddress),
|
|
328
|
+
slashFactoryAddress: result.slashFactoryAddress ? EthAddress.fromString(result.slashFactoryAddress) : undefined,
|
|
329
|
+
feeAssetHandlerAddress: result.feeAssetHandlerAddress
|
|
330
|
+
? EthAddress.fromString(result.feeAssetHandlerAddress)
|
|
331
|
+
: undefined,
|
|
332
|
+
stakingAssetHandlerAddress: result.stakingAssetHandlerAddress
|
|
333
|
+
? EthAddress.fromString(result.stakingAssetHandlerAddress)
|
|
334
|
+
: undefined,
|
|
335
|
+
zkPassportVerifierAddress: result.zkPassportVerifierAddress
|
|
336
|
+
? EthAddress.fromString(result.zkPassportVerifierAddress)
|
|
337
|
+
: undefined,
|
|
338
|
+
gseAddress: result.gseAddress ? EthAddress.fromString(result.gseAddress) : undefined,
|
|
339
|
+
dateGatedRelayerAddress: result.dateGatedRelayerAddress
|
|
340
|
+
? EthAddress.fromString(result.dateGatedRelayerAddress)
|
|
341
|
+
: undefined,
|
|
342
|
+
},
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export const DEPLOYER_ADDRESS: Hex = '0x4e59b44847b379578588920cA78FbF26c0B4956C';
|
|
347
|
+
|
|
348
|
+
export type Operator = {
|
|
349
|
+
attester: EthAddress;
|
|
350
|
+
withdrawer: EthAddress;
|
|
351
|
+
bn254SecretKey: SecretValue<bigint>;
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Return type of the deployAztecL1Contracts function.
|
|
356
|
+
*/
|
|
357
|
+
export type DeployAztecL1ContractsReturnType = {
|
|
358
|
+
/** Extended Wallet Client Type. */
|
|
359
|
+
l1Client: ExtendedViemWalletClient;
|
|
360
|
+
/** The currently deployed l1 contract addresses */
|
|
361
|
+
l1ContractAddresses: L1ContractAddresses;
|
|
362
|
+
/** Version of the current rollup contract. */
|
|
363
|
+
rollupVersion: number;
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
export interface LinkReferences {
|
|
367
|
+
[fileName: string]: {
|
|
368
|
+
[contractName: string]: ReadonlyArray<{
|
|
369
|
+
start: number;
|
|
370
|
+
length: number;
|
|
371
|
+
}>;
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
export interface Libraries {
|
|
376
|
+
linkReferences: LinkReferences;
|
|
377
|
+
libraryCode: Record<string, ContractArtifacts>;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Contract artifacts
|
|
382
|
+
*/
|
|
383
|
+
export interface ContractArtifacts<TAbi extends Abi | readonly unknown[] = Abi> {
|
|
384
|
+
/**
|
|
385
|
+
* The contract name.
|
|
386
|
+
*/
|
|
387
|
+
name: string;
|
|
388
|
+
/**
|
|
389
|
+
* The contract abi.
|
|
390
|
+
*/
|
|
391
|
+
contractAbi: Narrow<TAbi>;
|
|
392
|
+
/**
|
|
393
|
+
* The contract bytecode
|
|
394
|
+
*/
|
|
395
|
+
contractBytecode: Hex;
|
|
396
|
+
/**
|
|
397
|
+
* The contract libraries
|
|
398
|
+
*/
|
|
399
|
+
libraries?: Libraries;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
export type VerificationLibraryEntry = {
|
|
403
|
+
file: string;
|
|
404
|
+
contract: string;
|
|
405
|
+
address: string;
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
export type VerificationRecord = {
|
|
409
|
+
name: string;
|
|
410
|
+
address: string;
|
|
411
|
+
constructorArgsHex: Hex;
|
|
412
|
+
libraries: VerificationLibraryEntry[];
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
export interface DeployAztecL1ContractsArgs extends Omit<L1ContractsConfig, keyof L1TxUtilsConfig> {
|
|
416
|
+
/** The vk tree root. */
|
|
417
|
+
vkTreeRoot: Fr;
|
|
418
|
+
/** The hash of the protocol contracts. */
|
|
419
|
+
protocolContractsHash: Fr;
|
|
420
|
+
/** The genesis root of the archive tree. */
|
|
421
|
+
genesisArchiveRoot: Fr;
|
|
422
|
+
/** The initial validators for the rollup contract. */
|
|
423
|
+
initialValidators?: Operator[];
|
|
424
|
+
/** The initial balance of the fee juice portal. This is the amount of fee juice that is prefunded to accounts */
|
|
425
|
+
feeJuicePortalInitialBalance?: bigint;
|
|
426
|
+
/** Whether to deploy the real verifier or the mock verifier */
|
|
427
|
+
realVerifier?: boolean;
|
|
428
|
+
/** The zk passport args */
|
|
429
|
+
zkPassportArgs?: ZKPassportArgs;
|
|
430
|
+
/** If provided, use this token for BOTH fee and staking assets (skip deployments) */
|
|
431
|
+
existingTokenAddress?: EthAddress;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
export interface ZKPassportArgs {
|
|
435
|
+
/** The domain of the zk passport (url) */
|
|
436
|
+
zkPassportDomain?: string;
|
|
437
|
+
/** The scope of the zk passport (personhood, etc) */
|
|
438
|
+
zkPassportScope?: string;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// picked up by l1-contracts DeploymentConfiguration.sol
|
|
442
|
+
export function getDeployAztecL1ContractsEnvVars(args: DeployAztecL1ContractsArgs) {
|
|
443
|
+
return {
|
|
444
|
+
...getDeployRollupForUpgradeEnvVars(args), // parsed by RollupConfiguration.sol
|
|
445
|
+
EXISTING_TOKEN_ADDRESS: args.existingTokenAddress?.toString(),
|
|
446
|
+
AZTEC_ACTIVATION_THRESHOLD: args.activationThreshold?.toString(),
|
|
447
|
+
AZTEC_EJECTION_THRESHOLD: args.ejectionThreshold?.toString(),
|
|
448
|
+
AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE: args.governanceProposerRoundSize?.toString(),
|
|
449
|
+
AZTEC_GOVERNANCE_PROPOSER_QUORUM: args.governanceProposerQuorum?.toString(),
|
|
450
|
+
ZKPASSPORT_DOMAIN: args.zkPassportArgs?.zkPassportDomain,
|
|
451
|
+
ZKPASSPORT_SCOPE: args.zkPassportArgs?.zkPassportScope,
|
|
452
|
+
} as const;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// picked up by l1-contracts RollupConfiguration.sol
|
|
456
|
+
export function getDeployRollupForUpgradeEnvVars(
|
|
457
|
+
args: Omit<
|
|
458
|
+
DeployAztecL1ContractsArgs,
|
|
459
|
+
| 'governanceProposerQuorum'
|
|
460
|
+
| 'governanceProposerRoundSize'
|
|
461
|
+
| 'ejectionThreshold'
|
|
462
|
+
| 'activationThreshold'
|
|
463
|
+
| 'getZkPassportArgs'
|
|
464
|
+
>,
|
|
465
|
+
) {
|
|
466
|
+
return {
|
|
467
|
+
INITIAL_VALIDATORS: JSON.stringify((args.initialValidators ?? []).map(computeValidatorData)),
|
|
468
|
+
REAL_VERIFIER: args.realVerifier ? 'true' : 'false',
|
|
469
|
+
FEE_JUICE_PORTAL_INITIAL_BALANCE: (args.feeJuicePortalInitialBalance ?? 0n).toString(),
|
|
470
|
+
// Genesis state
|
|
471
|
+
VK_TREE_ROOT: args.vkTreeRoot.toString(),
|
|
472
|
+
PROTOCOL_CONTRACTS_HASH: args.protocolContractsHash.toString(),
|
|
473
|
+
GENESIS_ARCHIVE_ROOT: args.genesisArchiveRoot.toString(),
|
|
474
|
+
// Rollup config
|
|
475
|
+
AZTEC_SLOT_DURATION: args.aztecSlotDuration.toString(),
|
|
476
|
+
AZTEC_EPOCH_DURATION: args.aztecEpochDuration.toString(),
|
|
477
|
+
AZTEC_TARGET_COMMITTEE_SIZE: args.aztecTargetCommitteeSize.toString(),
|
|
478
|
+
AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET: args.lagInEpochsForValidatorSet.toString(),
|
|
479
|
+
AZTEC_LAG_IN_EPOCHS_FOR_RANDAO: args.lagInEpochsForRandao.toString(),
|
|
480
|
+
AZTEC_INBOX_LAG: args.inboxLag?.toString(),
|
|
481
|
+
AZTEC_PROOF_SUBMISSION_EPOCHS: args.aztecProofSubmissionEpochs.toString(),
|
|
482
|
+
AZTEC_LOCAL_EJECTION_THRESHOLD: args.localEjectionThreshold.toString(),
|
|
483
|
+
AZTEC_SLASHING_LIFETIME_IN_ROUNDS: args.slashingLifetimeInRounds.toString(),
|
|
484
|
+
AZTEC_SLASHING_VETOER: args.slashingVetoer.toString(),
|
|
485
|
+
AZTEC_SLASHING_DISABLE_DURATION: args.slashingDisableDuration.toString(),
|
|
486
|
+
AZTEC_MANA_TARGET: args.manaTarget.toString(),
|
|
487
|
+
AZTEC_EXIT_DELAY_SECONDS: args.exitDelaySeconds.toString(),
|
|
488
|
+
AZTEC_PROVING_COST_PER_MANA: args.provingCostPerMana.toString(),
|
|
489
|
+
AZTEC_SLASHER_FLAVOR: args.slasherFlavor,
|
|
490
|
+
AZTEC_SLASHING_ROUND_SIZE_IN_EPOCHS: args.slashingRoundSizeInEpochs.toString(),
|
|
491
|
+
AZTEC_SLASHING_QUORUM: args.slashingQuorum?.toString(),
|
|
492
|
+
AZTEC_SLASHING_OFFSET_IN_ROUNDS: args.slashingOffsetInRounds.toString(),
|
|
493
|
+
AZTEC_SLASH_AMOUNT_SMALL: args.slashAmountSmall.toString(),
|
|
494
|
+
AZTEC_SLASH_AMOUNT_MEDIUM: args.slashAmountMedium.toString(),
|
|
495
|
+
AZTEC_SLASH_AMOUNT_LARGE: args.slashAmountLarge.toString(),
|
|
496
|
+
} as const;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Deploys a new rollup, using the existing canonical version to derive certain values (addresses of assets etc).
|
|
501
|
+
*/
|
|
502
|
+
export const deployRollupForUpgrade = async (
|
|
503
|
+
privateKey: `0x${string}`,
|
|
504
|
+
rpcUrl: string,
|
|
505
|
+
chainId: number,
|
|
506
|
+
registryAddress: EthAddress,
|
|
507
|
+
args: Omit<
|
|
508
|
+
DeployAztecL1ContractsArgs,
|
|
509
|
+
| 'governanceProposerQuorum'
|
|
510
|
+
| 'governanceProposerRoundSize'
|
|
511
|
+
| 'ejectionThreshold'
|
|
512
|
+
| 'activationThreshold'
|
|
513
|
+
| 'zkPassportArgs'
|
|
514
|
+
>,
|
|
515
|
+
) => {
|
|
516
|
+
const currentDir = dirname(fileURLToPath(import.meta.url));
|
|
517
|
+
|
|
518
|
+
// Relative location of l1-contracts in monorepo or docker image.
|
|
519
|
+
const l1ContractsPath = resolve(currentDir, '..', '..', '..', 'l1-contracts');
|
|
520
|
+
|
|
521
|
+
const FORGE_SCRIPT = 'script/deploy/DeployRollupForUpgrade.s.sol';
|
|
522
|
+
await maybeForgeForceProductionBuild(l1ContractsPath, FORGE_SCRIPT, chainId);
|
|
523
|
+
|
|
524
|
+
const forgeArgs = [
|
|
525
|
+
'script',
|
|
526
|
+
FORGE_SCRIPT,
|
|
527
|
+
'--sig',
|
|
528
|
+
'run()',
|
|
529
|
+
'--private-key',
|
|
530
|
+
privateKey,
|
|
531
|
+
'--rpc-url',
|
|
532
|
+
rpcUrl,
|
|
533
|
+
'--broadcast',
|
|
534
|
+
];
|
|
535
|
+
const forgeEnv = {
|
|
536
|
+
FOUNDRY_PROFILE: chainId === mainnet.id ? 'production' : undefined,
|
|
537
|
+
// Env vars required by l1-contracts/script/deploy/RollupConfiguration.sol.
|
|
538
|
+
REGISTRY_ADDRESS: registryAddress.toString(),
|
|
539
|
+
NETWORK: getActiveNetworkName(),
|
|
540
|
+
...getDeployRollupForUpgradeEnvVars(args),
|
|
541
|
+
};
|
|
542
|
+
|
|
543
|
+
const result = await runProcess<ForgeRollupUpgradeResult>('forge', forgeArgs, forgeEnv, l1ContractsPath);
|
|
544
|
+
if (!result) {
|
|
545
|
+
throw new Error('Forge script did not output deployment result');
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
const extendedClient = createExtendedL1Client([rpcUrl], privateKey);
|
|
549
|
+
|
|
550
|
+
// Create RollupContract wrapper for the deployed rollup
|
|
551
|
+
const rollup = new RollupContract(extendedClient, result.rollupAddress);
|
|
552
|
+
|
|
553
|
+
return {
|
|
554
|
+
rollup,
|
|
555
|
+
slashFactoryAddress: result.slashFactoryAddress,
|
|
556
|
+
};
|
|
557
|
+
};
|