@aztec/cli 0.0.0-test.1 → 0.0.1-fake-ceab37513c
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/cmds/contracts/inspect_contract.d.ts.map +1 -1
- package/dest/cmds/contracts/inspect_contract.js +9 -5
- package/dest/cmds/infrastructure/index.d.ts.map +1 -1
- package/dest/cmds/infrastructure/index.js +3 -3
- package/dest/cmds/infrastructure/sequencers.d.ts +2 -1
- package/dest/cmds/infrastructure/sequencers.d.ts.map +1 -1
- package/dest/cmds/infrastructure/sequencers.js +27 -15
- package/dest/cmds/infrastructure/setup_l2_contract.d.ts +1 -1
- package/dest/cmds/infrastructure/setup_l2_contract.d.ts.map +1 -1
- package/dest/cmds/infrastructure/setup_l2_contract.js +14 -12
- package/dest/cmds/l1/advance_epoch.d.ts.map +1 -1
- package/dest/cmds/l1/advance_epoch.js +3 -2
- package/dest/cmds/l1/assume_proven_through.d.ts.map +1 -1
- package/dest/cmds/l1/assume_proven_through.js +3 -3
- package/dest/cmds/l1/bridge_erc20.d.ts +1 -1
- package/dest/cmds/l1/bridge_erc20.d.ts.map +1 -1
- package/dest/cmds/l1/bridge_erc20.js +4 -4
- package/dest/cmds/l1/deploy_l1_contracts.d.ts +2 -2
- package/dest/cmds/l1/deploy_l1_contracts.d.ts.map +1 -1
- package/dest/cmds/l1/deploy_l1_contracts.js +22 -5
- package/dest/cmds/l1/deploy_new_rollup.d.ts +2 -1
- package/dest/cmds/l1/deploy_new_rollup.d.ts.map +1 -1
- package/dest/cmds/l1/deploy_new_rollup.js +16 -7
- package/dest/cmds/l1/governance_utils.d.ts.map +1 -1
- package/dest/cmds/l1/governance_utils.js +17 -17
- package/dest/cmds/l1/index.d.ts +1 -0
- package/dest/cmds/l1/index.d.ts.map +1 -1
- package/dest/cmds/l1/index.js +29 -39
- package/dest/cmds/l1/trigger_seed_snapshot.d.ts +6 -0
- package/dest/cmds/l1/trigger_seed_snapshot.d.ts.map +1 -0
- package/dest/cmds/l1/trigger_seed_snapshot.js +19 -0
- package/dest/cmds/l1/update_l1_validators.d.ts +17 -2
- package/dest/cmds/l1/update_l1_validators.d.ts.map +1 -1
- package/dest/cmds/l1/update_l1_validators.js +156 -101
- package/dest/cmds/misc/generate_bootnode_enr.d.ts +1 -1
- package/dest/cmds/misc/generate_bootnode_enr.d.ts.map +1 -1
- package/dest/cmds/misc/generate_bootnode_enr.js +2 -2
- package/dest/cmds/misc/generate_secret_and_hash.d.ts +1 -1
- package/dest/cmds/misc/generate_secret_and_hash.d.ts.map +1 -1
- package/dest/cmds/misc/generate_secret_and_hash.js +2 -2
- package/dest/cmds/misc/get_canonical_sponsored_fpc_address.d.ts +3 -0
- package/dest/cmds/misc/get_canonical_sponsored_fpc_address.d.ts.map +1 -0
- package/dest/cmds/misc/get_canonical_sponsored_fpc_address.js +4 -0
- package/dest/cmds/misc/index.d.ts.map +1 -1
- package/dest/cmds/misc/index.js +7 -3
- package/dest/cmds/misc/update/github.d.ts +0 -1
- package/dest/cmds/misc/update/github.d.ts.map +1 -1
- package/dest/cmds/misc/update/github.js +0 -1
- package/dest/cmds/misc/update.d.ts.map +1 -1
- package/dest/cmds/misc/update.js +2 -3
- package/dest/cmds/pxe/get_contract_data.js +1 -1
- package/dest/cmds/pxe/get_node_info.d.ts.map +1 -1
- package/dest/cmds/pxe/get_node_info.js +11 -7
- package/dest/cmds/pxe/get_pxe_info.js +2 -2
- package/dest/config/cached_fetch.d.ts +18 -0
- package/dest/config/cached_fetch.d.ts.map +1 -0
- package/dest/config/cached_fetch.js +54 -0
- package/dest/config/chain_l2_config.d.ts +38 -0
- package/dest/config/chain_l2_config.d.ts.map +1 -0
- package/dest/config/chain_l2_config.js +376 -0
- package/dest/config/enrich_env.d.ts +4 -0
- package/dest/config/enrich_env.d.ts.map +1 -0
- package/dest/config/enrich_env.js +12 -0
- package/dest/config/get_l1_config.d.ts +8 -0
- package/dest/config/get_l1_config.d.ts.map +1 -0
- package/dest/config/get_l1_config.js +22 -0
- package/dest/config/index.d.ts +5 -0
- package/dest/config/index.d.ts.map +1 -0
- package/dest/config/index.js +4 -0
- package/dest/config/network_config.d.ts +19 -0
- package/dest/config/network_config.d.ts.map +1 -0
- package/dest/config/network_config.js +79 -0
- package/dest/utils/aztec.d.ts +12 -11
- package/dest/utils/aztec.d.ts.map +1 -1
- package/dest/utils/aztec.js +52 -22
- package/dest/utils/commands.d.ts +1 -1
- package/dest/utils/commands.d.ts.map +1 -1
- package/dest/utils/commands.js +5 -5
- package/dest/utils/encoding.js +1 -1
- package/dest/utils/github.d.ts +0 -1
- package/dest/utils/github.d.ts.map +1 -1
- package/dest/utils/github.js +0 -1
- package/dest/utils/index.d.ts +1 -0
- package/dest/utils/index.d.ts.map +1 -1
- package/dest/utils/index.js +1 -0
- package/dest/utils/inspect.d.ts.map +1 -1
- package/dest/utils/inspect.js +18 -26
- package/dest/utils/setup_contracts.d.ts +5 -0
- package/dest/utils/setup_contracts.d.ts.map +1 -0
- package/dest/utils/setup_contracts.js +36 -0
- package/package.json +38 -32
- package/src/cmds/contracts/inspect_contract.ts +16 -6
- package/src/cmds/infrastructure/index.ts +10 -2
- package/src/cmds/infrastructure/sequencers.ts +32 -15
- package/src/cmds/infrastructure/setup_l2_contract.ts +16 -11
- package/src/cmds/l1/advance_epoch.ts +3 -2
- package/src/cmds/l1/assume_proven_through.ts +3 -3
- package/src/cmds/l1/bridge_erc20.ts +4 -3
- package/src/cmds/l1/deploy_l1_contracts.ts +30 -6
- package/src/cmds/l1/deploy_new_rollup.ts +22 -8
- package/src/cmds/l1/governance_utils.ts +18 -17
- package/src/cmds/l1/index.ts +69 -96
- package/src/cmds/l1/trigger_seed_snapshot.ts +31 -0
- package/src/cmds/l1/update_l1_validators.ts +191 -92
- package/src/cmds/misc/generate_bootnode_enr.ts +3 -2
- package/src/cmds/misc/generate_secret_and_hash.ts +2 -2
- package/src/cmds/misc/get_canonical_sponsored_fpc_address.ts +7 -0
- package/src/cmds/misc/index.ts +13 -4
- package/src/cmds/misc/update/github.ts +0 -1
- package/src/cmds/misc/update.ts +1 -7
- package/src/cmds/pxe/get_contract_data.ts +1 -1
- package/src/cmds/pxe/get_node_info.ts +10 -7
- package/src/cmds/pxe/get_pxe_info.ts +2 -2
- package/src/config/cached_fetch.ts +67 -0
- package/src/config/chain_l2_config.ts +493 -0
- package/src/config/enrich_env.ts +15 -0
- package/src/config/get_l1_config.ts +28 -0
- package/src/config/index.ts +4 -0
- package/src/config/network_config.ts +102 -0
- package/src/utils/aztec.ts +76 -27
- package/src/utils/commands.ts +5 -5
- package/src/utils/encoding.ts +1 -1
- package/src/utils/github.ts +0 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/inspect.ts +18 -25
- package/src/utils/setup_contracts.ts +58 -0
- package/dest/cmds/devnet/bootstrap_network.d.ts +0 -3
- package/dest/cmds/devnet/bootstrap_network.d.ts.map +0 -1
- package/dest/cmds/devnet/bootstrap_network.js +0 -196
- package/dest/cmds/devnet/faucet.d.ts +0 -4
- package/dest/cmds/devnet/faucet.d.ts.map +0 -1
- package/dest/cmds/devnet/faucet.js +0 -26
- package/dest/cmds/devnet/index.d.ts +0 -4
- package/dest/cmds/devnet/index.d.ts.map +0 -1
- package/dest/cmds/devnet/index.js +0 -14
- package/dest/cmds/l1/deploy_l1_verifier.d.ts +0 -5
- package/dest/cmds/l1/deploy_l1_verifier.d.ts.map +0 -1
- package/dest/cmds/l1/deploy_l1_verifier.js +0 -54
- package/dest/cmds/misc/setup_contracts.d.ts +0 -7
- package/dest/cmds/misc/setup_contracts.d.ts.map +0 -1
- package/dest/cmds/misc/setup_contracts.js +0 -27
- package/src/cmds/devnet/bootstrap_network.ts +0 -318
- package/src/cmds/devnet/faucet.ts +0 -33
- package/src/cmds/devnet/index.ts +0 -60
- package/src/cmds/l1/deploy_l1_verifier.ts +0 -105
- package/src/cmds/misc/setup_contracts.ts +0 -40
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
GSEContract,
|
|
3
|
+
RollupContract,
|
|
3
4
|
createEthereumChain,
|
|
4
|
-
|
|
5
|
+
createExtendedL1Client,
|
|
6
|
+
createL1TxUtilsFromViemWallet,
|
|
5
7
|
getL1ContractsConfigEnvVars,
|
|
8
|
+
getPublicClient,
|
|
6
9
|
isAnvilTestChain,
|
|
7
10
|
} from '@aztec/ethereum';
|
|
11
|
+
import { EthCheatCodes } from '@aztec/ethereum/test';
|
|
8
12
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
9
13
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
10
|
-
import {
|
|
14
|
+
import { RollupAbi, StakingAssetHandlerAbi } from '@aztec/l1-artifacts';
|
|
15
|
+
import { ZkPassportProofParams } from '@aztec/stdlib/zkpassport';
|
|
11
16
|
|
|
12
|
-
import {
|
|
17
|
+
import { encodeFunctionData, formatEther, getContract } from 'viem';
|
|
13
18
|
import { generatePrivateKey, mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
|
|
14
19
|
|
|
20
|
+
import { addLeadingHex } from '../../utils/aztec.js';
|
|
21
|
+
|
|
15
22
|
export interface RollupCommandArgs {
|
|
16
23
|
rpcUrls: string[];
|
|
17
24
|
chainId: number;
|
|
@@ -21,6 +28,14 @@ export interface RollupCommandArgs {
|
|
|
21
28
|
withdrawerAddress?: EthAddress;
|
|
22
29
|
}
|
|
23
30
|
|
|
31
|
+
export interface StakingAssetHandlerCommandArgs {
|
|
32
|
+
rpcUrls: string[];
|
|
33
|
+
chainId: number;
|
|
34
|
+
privateKey?: string;
|
|
35
|
+
mnemonic?: string;
|
|
36
|
+
stakingAssetHandlerAddress: EthAddress;
|
|
37
|
+
}
|
|
38
|
+
|
|
24
39
|
export interface LoggerArgs {
|
|
25
40
|
log: LogFn;
|
|
26
41
|
debugLogger: Logger;
|
|
@@ -41,56 +56,151 @@ export async function addL1Validator({
|
|
|
41
56
|
chainId,
|
|
42
57
|
privateKey,
|
|
43
58
|
mnemonic,
|
|
44
|
-
|
|
45
|
-
|
|
59
|
+
attesterAddress,
|
|
60
|
+
stakingAssetHandlerAddress,
|
|
61
|
+
merkleProof,
|
|
62
|
+
proofParams,
|
|
63
|
+
blsSecretKey,
|
|
64
|
+
log,
|
|
65
|
+
debugLogger,
|
|
66
|
+
}: StakingAssetHandlerCommandArgs &
|
|
67
|
+
LoggerArgs & {
|
|
68
|
+
blsSecretKey: bigint; // scalar field element of BN254
|
|
69
|
+
attesterAddress: EthAddress;
|
|
70
|
+
proofParams: Buffer;
|
|
71
|
+
merkleProof: string[];
|
|
72
|
+
}) {
|
|
73
|
+
const dualLog = makeDualLog(log, debugLogger);
|
|
74
|
+
const account = getAccount(privateKey, mnemonic);
|
|
75
|
+
const chain = createEthereumChain(rpcUrls, chainId);
|
|
76
|
+
const l1Client = createExtendedL1Client(rpcUrls, account, chain.chainInfo);
|
|
77
|
+
|
|
78
|
+
const stakingAssetHandler = getContract({
|
|
79
|
+
address: stakingAssetHandlerAddress.toString(),
|
|
80
|
+
abi: StakingAssetHandlerAbi,
|
|
81
|
+
client: l1Client,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const rollupAddress = await stakingAssetHandler.read.getRollup();
|
|
85
|
+
dualLog(`Adding validator ${attesterAddress} to rollup ${rollupAddress.toString()}`);
|
|
86
|
+
|
|
87
|
+
const rollup = getContract({
|
|
88
|
+
address: rollupAddress,
|
|
89
|
+
abi: RollupAbi,
|
|
90
|
+
client: l1Client,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const gseAddress = await rollup.read.getGSE();
|
|
94
|
+
|
|
95
|
+
const gse = new GSEContract(l1Client, gseAddress);
|
|
96
|
+
|
|
97
|
+
const registrationTuple = await gse.makeRegistrationTuple(blsSecretKey);
|
|
98
|
+
|
|
99
|
+
const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client, { logger: debugLogger });
|
|
100
|
+
const proofParamsObj = ZkPassportProofParams.fromBuffer(proofParams);
|
|
101
|
+
const merkleProofArray = merkleProof.map(proof => addLeadingHex(proof));
|
|
102
|
+
|
|
103
|
+
const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
|
|
104
|
+
to: stakingAssetHandlerAddress.toString(),
|
|
105
|
+
data: encodeFunctionData({
|
|
106
|
+
abi: StakingAssetHandlerAbi,
|
|
107
|
+
functionName: 'addValidator',
|
|
108
|
+
args: [
|
|
109
|
+
attesterAddress.toString(),
|
|
110
|
+
merkleProofArray,
|
|
111
|
+
proofParamsObj.toViem(),
|
|
112
|
+
registrationTuple.publicKeyInG1,
|
|
113
|
+
registrationTuple.publicKeyInG2,
|
|
114
|
+
registrationTuple.proofOfPossession,
|
|
115
|
+
],
|
|
116
|
+
}),
|
|
117
|
+
abi: StakingAssetHandlerAbi,
|
|
118
|
+
});
|
|
119
|
+
dualLog(`Transaction hash: ${receipt.transactionHash}`);
|
|
120
|
+
await l1Client.waitForTransactionReceipt({ hash: receipt.transactionHash });
|
|
121
|
+
if (isAnvilTestChain(chainId)) {
|
|
122
|
+
dualLog(`Funding validator on L1`);
|
|
123
|
+
const cheatCodes = new EthCheatCodes(rpcUrls, debugLogger);
|
|
124
|
+
await cheatCodes.setBalance(attesterAddress, 10n ** 20n);
|
|
125
|
+
} else {
|
|
126
|
+
const balance = await l1Client.getBalance({ address: attesterAddress.toString() });
|
|
127
|
+
dualLog(`Validator balance: ${formatEther(balance)} ETH`);
|
|
128
|
+
if (balance === 0n) {
|
|
129
|
+
dualLog(`WARNING: Proposer has no balance. Remember to fund it!`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export async function addL1ValidatorViaRollup({
|
|
135
|
+
rpcUrls,
|
|
136
|
+
chainId,
|
|
137
|
+
privateKey,
|
|
138
|
+
mnemonic,
|
|
139
|
+
attesterAddress,
|
|
46
140
|
withdrawerAddress,
|
|
141
|
+
blsSecretKey,
|
|
142
|
+
moveWithLatestRollup,
|
|
143
|
+
rollupAddress,
|
|
47
144
|
log,
|
|
48
145
|
debugLogger,
|
|
49
|
-
}: RollupCommandArgs &
|
|
50
|
-
|
|
146
|
+
}: RollupCommandArgs &
|
|
147
|
+
LoggerArgs & {
|
|
148
|
+
blsSecretKey: bigint; // scalar field element of BN254
|
|
149
|
+
attesterAddress: EthAddress;
|
|
150
|
+
moveWithLatestRollup: boolean;
|
|
151
|
+
}) {
|
|
51
152
|
const dualLog = makeDualLog(log, debugLogger);
|
|
52
|
-
const
|
|
53
|
-
const
|
|
153
|
+
const account = getAccount(privateKey, mnemonic);
|
|
154
|
+
const chain = createEthereumChain(rpcUrls, chainId);
|
|
155
|
+
const l1Client = createExtendedL1Client(rpcUrls, account, chain.chainInfo);
|
|
156
|
+
|
|
157
|
+
dualLog(`Adding validator ${attesterAddress} to rollup ${rollupAddress.toString()} via direct deposit`);
|
|
158
|
+
|
|
159
|
+
if (!withdrawerAddress) {
|
|
160
|
+
throw new Error(`Withdrawer address required`);
|
|
161
|
+
}
|
|
162
|
+
|
|
54
163
|
const rollup = getContract({
|
|
55
164
|
address: rollupAddress.toString(),
|
|
56
165
|
abi: RollupAbi,
|
|
57
|
-
client:
|
|
166
|
+
client: l1Client,
|
|
58
167
|
});
|
|
59
168
|
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
169
|
+
const gseAddress = await rollup.read.getGSE();
|
|
170
|
+
|
|
171
|
+
const gse = new GSEContract(l1Client, gseAddress);
|
|
172
|
+
|
|
173
|
+
const registrationTuple = await gse.makeRegistrationTuple(blsSecretKey);
|
|
65
174
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
175
|
+
const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client, { logger: debugLogger });
|
|
176
|
+
|
|
177
|
+
const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
|
|
178
|
+
to: rollupAddress.toString(),
|
|
179
|
+
data: encodeFunctionData({
|
|
180
|
+
abi: RollupAbi,
|
|
181
|
+
functionName: 'deposit',
|
|
182
|
+
args: [
|
|
183
|
+
attesterAddress.toString(),
|
|
184
|
+
withdrawerAddress.toString(),
|
|
185
|
+
registrationTuple.publicKeyInG1,
|
|
186
|
+
registrationTuple.publicKeyInG2,
|
|
187
|
+
registrationTuple.proofOfPossession,
|
|
188
|
+
moveWithLatestRollup,
|
|
189
|
+
],
|
|
190
|
+
}),
|
|
191
|
+
abi: StakingAssetHandlerAbi,
|
|
192
|
+
});
|
|
193
|
+
dualLog(`Transaction hash: ${receipt.transactionHash}`);
|
|
194
|
+
await l1Client.waitForTransactionReceipt({ hash: receipt.transactionHash });
|
|
84
195
|
if (isAnvilTestChain(chainId)) {
|
|
85
196
|
dualLog(`Funding validator on L1`);
|
|
86
197
|
const cheatCodes = new EthCheatCodes(rpcUrls, debugLogger);
|
|
87
|
-
await cheatCodes.setBalance(
|
|
198
|
+
await cheatCodes.setBalance(attesterAddress, 10n ** 20n);
|
|
88
199
|
} else {
|
|
89
|
-
const balance = await
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
dualLog(`WARNING: Validator has no balance. Remember to fund it!`);
|
|
200
|
+
const balance = await l1Client.getBalance({ address: attesterAddress.toString() });
|
|
201
|
+
dualLog(`Validator balance: ${formatEther(balance)} ETH`);
|
|
202
|
+
if (balance === 0n) {
|
|
203
|
+
dualLog(`WARNING: Proposer has no balance. Remember to fund it!`);
|
|
94
204
|
}
|
|
95
205
|
}
|
|
96
206
|
}
|
|
@@ -106,18 +216,21 @@ export async function removeL1Validator({
|
|
|
106
216
|
debugLogger,
|
|
107
217
|
}: RollupCommandArgs & LoggerArgs & { validatorAddress: EthAddress }) {
|
|
108
218
|
const dualLog = makeDualLog(log, debugLogger);
|
|
109
|
-
const
|
|
110
|
-
const
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
abi: RollupAbi,
|
|
114
|
-
client: walletClient,
|
|
115
|
-
});
|
|
219
|
+
const account = getAccount(privateKey, mnemonic);
|
|
220
|
+
const chain = createEthereumChain(rpcUrls, chainId);
|
|
221
|
+
const l1Client = createExtendedL1Client(rpcUrls, account, chain.chainInfo);
|
|
222
|
+
const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client, { logger: debugLogger });
|
|
116
223
|
|
|
117
224
|
dualLog(`Removing validator ${validatorAddress.toString()} from rollup ${rollupAddress.toString()}`);
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
225
|
+
const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
|
|
226
|
+
to: rollupAddress.toString(),
|
|
227
|
+
data: encodeFunctionData({
|
|
228
|
+
abi: RollupAbi,
|
|
229
|
+
functionName: 'initiateWithdraw',
|
|
230
|
+
args: [validatorAddress.toString(), validatorAddress.toString()],
|
|
231
|
+
}),
|
|
232
|
+
});
|
|
233
|
+
dualLog(`Transaction hash: ${receipt.transactionHash}`);
|
|
121
234
|
}
|
|
122
235
|
|
|
123
236
|
export async function pruneRollup({
|
|
@@ -130,18 +243,20 @@ export async function pruneRollup({
|
|
|
130
243
|
debugLogger,
|
|
131
244
|
}: RollupCommandArgs & LoggerArgs) {
|
|
132
245
|
const dualLog = makeDualLog(log, debugLogger);
|
|
133
|
-
const
|
|
134
|
-
const
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
abi: RollupAbi,
|
|
138
|
-
client: walletClient,
|
|
139
|
-
});
|
|
246
|
+
const account = getAccount(privateKey, mnemonic);
|
|
247
|
+
const chain = createEthereumChain(rpcUrls, chainId);
|
|
248
|
+
const l1Client = createExtendedL1Client(rpcUrls, account, chain.chainInfo);
|
|
249
|
+
const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client, { logger: debugLogger });
|
|
140
250
|
|
|
141
251
|
dualLog(`Trying prune`);
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
252
|
+
const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
|
|
253
|
+
to: rollupAddress.toString(),
|
|
254
|
+
data: encodeFunctionData({
|
|
255
|
+
abi: RollupAbi,
|
|
256
|
+
functionName: 'prune',
|
|
257
|
+
}),
|
|
258
|
+
});
|
|
259
|
+
dualLog(`Transaction hash: ${receipt.transactionHash}`);
|
|
145
260
|
}
|
|
146
261
|
|
|
147
262
|
export async function fastForwardEpochs({
|
|
@@ -153,7 +268,7 @@ export async function fastForwardEpochs({
|
|
|
153
268
|
debugLogger,
|
|
154
269
|
}: RollupCommandArgs & LoggerArgs & { numEpochs: bigint }) {
|
|
155
270
|
const dualLog = makeDualLog(log, debugLogger);
|
|
156
|
-
const publicClient = getPublicClient(rpcUrls, chainId);
|
|
271
|
+
const publicClient = getPublicClient({ l1RpcUrls: rpcUrls, l1ChainId: chainId });
|
|
157
272
|
const rollup = getContract({
|
|
158
273
|
address: rollupAddress.toString(),
|
|
159
274
|
abi: RollupAbi,
|
|
@@ -166,7 +281,7 @@ export async function fastForwardEpochs({
|
|
|
166
281
|
const timestamp = await rollup.read.getTimestampForSlot([currentSlot + l2SlotsInEpoch * numEpochs]);
|
|
167
282
|
dualLog(`Fast forwarding ${numEpochs} epochs to ${timestamp}`);
|
|
168
283
|
try {
|
|
169
|
-
await cheatCodes.warp(Number(timestamp));
|
|
284
|
+
await cheatCodes.warp(Number(timestamp), { resetBlockInterval: true });
|
|
170
285
|
dualLog(`Fast forwarded ${numEpochs} epochs to ${timestamp}`);
|
|
171
286
|
} catch (error) {
|
|
172
287
|
if (error instanceof Error && error.message.includes("is lower than or equal to previous block's timestamp")) {
|
|
@@ -180,31 +295,27 @@ export async function fastForwardEpochs({
|
|
|
180
295
|
|
|
181
296
|
export async function debugRollup({ rpcUrls, chainId, rollupAddress, log }: RollupCommandArgs & LoggerArgs) {
|
|
182
297
|
const config = getL1ContractsConfigEnvVars();
|
|
183
|
-
const publicClient = getPublicClient(rpcUrls, chainId);
|
|
184
|
-
const rollup =
|
|
185
|
-
address: rollupAddress.toString(),
|
|
186
|
-
abi: RollupAbi,
|
|
187
|
-
client: publicClient,
|
|
188
|
-
});
|
|
298
|
+
const publicClient = getPublicClient({ l1RpcUrls: rpcUrls, l1ChainId: chainId });
|
|
299
|
+
const rollup = new RollupContract(publicClient, rollupAddress);
|
|
189
300
|
|
|
190
|
-
const pendingNum = await rollup.
|
|
301
|
+
const pendingNum = await rollup.getBlockNumber();
|
|
191
302
|
log(`Pending block num: ${pendingNum}`);
|
|
192
|
-
const provenNum = await rollup.
|
|
303
|
+
const provenNum = await rollup.getProvenBlockNumber();
|
|
193
304
|
log(`Proven block num: ${provenNum}`);
|
|
194
|
-
const validators = await rollup.
|
|
305
|
+
const validators = await rollup.getAttesters();
|
|
195
306
|
log(`Validators: ${validators.map(v => v.toString()).join(', ')}`);
|
|
196
|
-
const committee = await rollup.
|
|
197
|
-
log(`Committee: ${committee
|
|
198
|
-
const archive = await rollup.
|
|
307
|
+
const committee = await rollup.getCurrentEpochCommittee();
|
|
308
|
+
log(`Committee: ${committee?.map(v => v.toString()).join(', ')}`);
|
|
309
|
+
const archive = await rollup.archive();
|
|
199
310
|
log(`Archive: ${archive}`);
|
|
200
|
-
const epochNum = await rollup.
|
|
311
|
+
const epochNum = await rollup.getCurrentEpochNumber();
|
|
201
312
|
log(`Current epoch: ${epochNum}`);
|
|
202
|
-
const slot = await rollup.
|
|
313
|
+
const slot = await rollup.getSlotNumber();
|
|
203
314
|
log(`Current slot: ${slot}`);
|
|
204
|
-
const proposerDuringPrevL1Block = await rollup.
|
|
315
|
+
const proposerDuringPrevL1Block = await rollup.getCurrentProposer();
|
|
205
316
|
log(`Proposer during previous L1 block: ${proposerDuringPrevL1Block}`);
|
|
206
317
|
const nextBlockTS = BigInt((await publicClient.getBlock()).timestamp + BigInt(config.ethereumSlotDuration));
|
|
207
|
-
const proposer = await rollup.
|
|
318
|
+
const proposer = await rollup.getProposerAt(nextBlockTS);
|
|
208
319
|
log(`Proposer NOW: ${proposer.toString()}`);
|
|
209
320
|
}
|
|
210
321
|
|
|
@@ -215,24 +326,12 @@ function makeDualLog(log: LogFn, debugLogger: Logger) {
|
|
|
215
326
|
};
|
|
216
327
|
}
|
|
217
328
|
|
|
218
|
-
function
|
|
219
|
-
const chain = createEthereumChain(rpcUrls, chainId);
|
|
220
|
-
return createPublicClient({ chain: chain.chainInfo, transport: fallback(rpcUrls.map(url => http(url))) });
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
function getWalletClient(
|
|
224
|
-
rpcUrls: string[],
|
|
225
|
-
chainId: number,
|
|
226
|
-
privateKey: string | undefined,
|
|
227
|
-
mnemonic: string | undefined,
|
|
228
|
-
) {
|
|
329
|
+
function getAccount(privateKey: string | undefined, mnemonic: string | undefined) {
|
|
229
330
|
if (!privateKey && !mnemonic) {
|
|
230
331
|
throw new Error('Either privateKey or mnemonic must be provided to create a wallet client');
|
|
231
332
|
}
|
|
232
|
-
|
|
233
|
-
const chain = createEthereumChain(rpcUrls, chainId);
|
|
234
333
|
const account = !privateKey
|
|
235
334
|
? mnemonicToAccount(mnemonic!)
|
|
236
335
|
: privateKeyToAccount(`${privateKey.startsWith('0x') ? '' : '0x'}${privateKey}` as `0x${string}`);
|
|
237
|
-
return
|
|
336
|
+
return account;
|
|
238
337
|
}
|
|
@@ -3,10 +3,11 @@ import { createBootnodeENRandPeerId } from '@aztec/p2p/enr';
|
|
|
3
3
|
|
|
4
4
|
export async function generateEncodedBootnodeENR(
|
|
5
5
|
privateKey: string,
|
|
6
|
-
|
|
6
|
+
p2pIp: string,
|
|
7
|
+
p2pPort: number,
|
|
7
8
|
l1ChainId: number,
|
|
8
9
|
log: LogFn,
|
|
9
10
|
) {
|
|
10
|
-
const { enr } = await createBootnodeENRandPeerId(privateKey,
|
|
11
|
+
const { enr } = await createBootnodeENRandPeerId(privateKey, p2pIp, p2pPort, l1ChainId);
|
|
11
12
|
log(`ENR: ${enr.encodeTxt()}`);
|
|
12
13
|
}
|
|
@@ -2,11 +2,11 @@ import { computeSecretHash } from '@aztec/aztec.js';
|
|
|
2
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
3
|
import type { LogFn } from '@aztec/foundation/log';
|
|
4
4
|
|
|
5
|
-
export function generateSecretAndHash(log: LogFn) {
|
|
5
|
+
export async function generateSecretAndHash(log: LogFn) {
|
|
6
6
|
const secret = Fr.random();
|
|
7
7
|
|
|
8
8
|
// We hash this the same way that aztec nr hash does.
|
|
9
|
-
const secretHash = computeSecretHash(secret);
|
|
9
|
+
const secretHash = await computeSecretHash(secret);
|
|
10
10
|
|
|
11
11
|
log(`
|
|
12
12
|
Secret: ${secret}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
2
|
+
|
|
3
|
+
import { getSponsoredFPCAddress } from '../../utils/setup_contracts.js';
|
|
4
|
+
|
|
5
|
+
export async function getCanonicalSponsoredFPCAddress(log: LogFn) {
|
|
6
|
+
log(`Canonical SponsoredFPC Address: ${(await getSponsoredFPCAddress()).toString()}`);
|
|
7
|
+
}
|
package/src/cmds/misc/index.ts
CHANGED
|
@@ -35,11 +35,12 @@ export function injectCommands(program: Command, log: LogFn) {
|
|
|
35
35
|
.summary('Generates the encoded ENR record for a bootnode.')
|
|
36
36
|
.description('Generates the encoded ENR record for a bootnode.')
|
|
37
37
|
.argument('<privateKey>', 'The peer id private key of the bootnode')
|
|
38
|
-
.argument('<
|
|
38
|
+
.argument('<p2pIp>', 'The bootnode P2P IP address')
|
|
39
|
+
.argument('<p2pPort>', 'The bootnode P2P port')
|
|
39
40
|
.addOption(l1ChainIdOption)
|
|
40
|
-
.action(async (privateKey: string,
|
|
41
|
+
.action(async (privateKey: string, p2pIp: string, p2pPort: number, options) => {
|
|
41
42
|
const { generateEncodedBootnodeENR } = await import('./generate_bootnode_enr.js');
|
|
42
|
-
await generateEncodedBootnodeENR(privateKey,
|
|
43
|
+
await generateEncodedBootnodeENR(privateKey, p2pIp, p2pPort, options.l1ChainId, log);
|
|
43
44
|
});
|
|
44
45
|
|
|
45
46
|
program
|
|
@@ -73,7 +74,15 @@ export function injectCommands(program: Command, log: LogFn) {
|
|
|
73
74
|
.description('Generates an arbitrary secret (Fr), and its hash (using aztec-nr defaults)')
|
|
74
75
|
.action(async () => {
|
|
75
76
|
const { generateSecretAndHash } = await import('./generate_secret_and_hash.js');
|
|
76
|
-
generateSecretAndHash(log);
|
|
77
|
+
await generateSecretAndHash(log);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
program
|
|
81
|
+
.command('get-canonical-sponsored-fpc-address')
|
|
82
|
+
.description('Gets the canonical SponsoredFPC address for this any testnet running on the same version as this CLI')
|
|
83
|
+
.action(async () => {
|
|
84
|
+
const { getCanonicalSponsoredFPCAddress } = await import('./get_canonical_sponsored_fpc_address.js');
|
|
85
|
+
await getCanonicalSponsoredFPCAddress(log);
|
|
77
86
|
});
|
|
78
87
|
|
|
79
88
|
program
|
package/src/cmds/misc/update.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
/* eslint-disable jsdoc/require-jsdoc */
|
|
2
1
|
import type { LogFn } from '@aztec/foundation/log';
|
|
3
2
|
|
|
4
3
|
import { relative, resolve } from 'path';
|
|
5
4
|
import { parse } from 'semver';
|
|
6
5
|
|
|
7
6
|
import type { DependencyChanges } from './update/common.js';
|
|
8
|
-
import { GITHUB_TAG_PREFIX } from './update/github.js';
|
|
9
7
|
import { updateAztecNr } from './update/noir.js';
|
|
10
8
|
import { getNewestVersion, updateAztecDeps, updateLockfile } from './update/npm.js';
|
|
11
9
|
|
|
@@ -44,11 +42,7 @@ export async function updateProject(
|
|
|
44
42
|
for (const contract of contracts) {
|
|
45
43
|
try {
|
|
46
44
|
projectDependencyChanges.push(
|
|
47
|
-
await updateAztecNr(
|
|
48
|
-
resolve(process.cwd(), projectPath, contract),
|
|
49
|
-
`${GITHUB_TAG_PREFIX}-v${targetAztecVersion.version}`,
|
|
50
|
-
log,
|
|
51
|
-
),
|
|
45
|
+
await updateAztecNr(resolve(process.cwd(), projectPath, contract), `v${targetAztecVersion.version}`, log),
|
|
52
46
|
);
|
|
53
47
|
} catch (err) {
|
|
54
48
|
if (err instanceof Error && 'code' in err && err.code === 'ENOENT') {
|
|
@@ -13,7 +13,7 @@ export async function getContractData(
|
|
|
13
13
|
const {
|
|
14
14
|
contractInstance: instance,
|
|
15
15
|
isContractInitialized: isInitialized,
|
|
16
|
-
|
|
16
|
+
isContractPublished: isPubliclyDeployed,
|
|
17
17
|
} = await client.getContractMetadata(contractAddress);
|
|
18
18
|
const contractClass =
|
|
19
19
|
includeBytecode &&
|
|
@@ -20,7 +20,7 @@ export async function getNodeInfo(
|
|
|
20
20
|
logJson({
|
|
21
21
|
nodeVersion: info.nodeVersion,
|
|
22
22
|
l1ChainId: info.l1ChainId,
|
|
23
|
-
|
|
23
|
+
rollupVersion: info.rollupVersion,
|
|
24
24
|
enr: info.enr,
|
|
25
25
|
l1ContractAddresses: {
|
|
26
26
|
rollup: info.l1ContractAddresses.rollupAddress.toString(),
|
|
@@ -35,18 +35,20 @@ export async function getNodeInfo(
|
|
|
35
35
|
governanceProposer: info.l1ContractAddresses.governanceProposerAddress.toString(),
|
|
36
36
|
governance: info.l1ContractAddresses.governanceAddress.toString(),
|
|
37
37
|
slashFactory: info.l1ContractAddresses.slashFactoryAddress?.toString(),
|
|
38
|
+
feeAssetHandler: info.l1ContractAddresses.feeAssetHandlerAddress?.toString(),
|
|
39
|
+
stakingAssetHandler: info.l1ContractAddresses.stakingAssetHandlerAddress?.toString(),
|
|
38
40
|
},
|
|
39
41
|
protocolContractAddresses: {
|
|
40
|
-
|
|
42
|
+
classRegistry: info.protocolContractAddresses.classRegistry.toString(),
|
|
41
43
|
feeJuice: info.protocolContractAddresses.feeJuice.toString(),
|
|
42
|
-
|
|
44
|
+
instanceRegistry: info.protocolContractAddresses.instanceRegistry.toString(),
|
|
43
45
|
multiCallEntrypoint: info.protocolContractAddresses.multiCallEntrypoint.toString(),
|
|
44
46
|
},
|
|
45
47
|
});
|
|
46
48
|
} else {
|
|
47
49
|
log(`Node Version: ${info.nodeVersion}`);
|
|
48
50
|
log(`Chain Id: ${info.l1ChainId}`);
|
|
49
|
-
log(`
|
|
51
|
+
log(`Rollup Version: ${info.rollupVersion}`);
|
|
50
52
|
log(`Node ENR: ${info.enr}`);
|
|
51
53
|
log(`L1 Contract Addresses:`);
|
|
52
54
|
log(` Rollup Address: ${info.l1ContractAddresses.rollupAddress.toString()}`);
|
|
@@ -61,11 +63,12 @@ export async function getNodeInfo(
|
|
|
61
63
|
log(` GovernanceProposer Address: ${info.l1ContractAddresses.governanceProposerAddress.toString()}`);
|
|
62
64
|
log(` Governance Address: ${info.l1ContractAddresses.governanceAddress.toString()}`);
|
|
63
65
|
log(` SlashFactory Address: ${info.l1ContractAddresses.slashFactoryAddress?.toString()}`);
|
|
64
|
-
|
|
66
|
+
log(` FeeAssetHandler Address: ${info.l1ContractAddresses.feeAssetHandlerAddress?.toString()}`);
|
|
67
|
+
log(` StakingAssetHandler Address: ${info.l1ContractAddresses.stakingAssetHandlerAddress?.toString()}`);
|
|
65
68
|
log(`L2 Contract Addresses:`);
|
|
66
|
-
log(` Class
|
|
69
|
+
log(` Class Registry: ${info.protocolContractAddresses.classRegistry.toString()}`);
|
|
67
70
|
log(` Fee Juice: ${info.protocolContractAddresses.feeJuice.toString()}`);
|
|
68
|
-
log(` Instance Deployer: ${info.protocolContractAddresses.
|
|
71
|
+
log(` Instance Deployer: ${info.protocolContractAddresses.instanceRegistry.toString()}`);
|
|
69
72
|
log(` MultiCall: ${info.protocolContractAddresses.multiCallEntrypoint.toString()}`);
|
|
70
73
|
}
|
|
71
74
|
}
|
|
@@ -6,8 +6,8 @@ export async function getPXEInfo(rpcUrl: string, debugLogger: Logger, log: LogFn
|
|
|
6
6
|
const info = await client.getPXEInfo();
|
|
7
7
|
log(`PXE Version: ${info.pxeVersion}`);
|
|
8
8
|
log(`Protocol Contract Addresses:`);
|
|
9
|
-
log(` Class
|
|
9
|
+
log(` Class Registry: ${info.protocolContractAddresses.classRegistry.toString()}`);
|
|
10
10
|
log(` Fee Juice: ${info.protocolContractAddresses.feeJuice.toString()}`);
|
|
11
|
-
log(` Instance Deployer: ${info.protocolContractAddresses.
|
|
11
|
+
log(` Instance Deployer: ${info.protocolContractAddresses.instanceRegistry.toString()}`);
|
|
12
12
|
log(` Multi Call Entrypoint: ${info.protocolContractAddresses.multiCallEntrypoint.toString()}`);
|
|
13
13
|
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { createLogger } from '@aztec/aztec.js';
|
|
2
|
+
|
|
3
|
+
import { mkdir, readFile, stat, writeFile } from 'fs/promises';
|
|
4
|
+
import { dirname } from 'path';
|
|
5
|
+
|
|
6
|
+
export interface CachedFetchOptions {
|
|
7
|
+
/** Cache duration in milliseconds */
|
|
8
|
+
cacheDurationMs: number;
|
|
9
|
+
/** The cache file */
|
|
10
|
+
cacheFile?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Fetches data from a URL with file-based caching support.
|
|
15
|
+
* This utility can be used by both remote config and bootnodes fetching.
|
|
16
|
+
*
|
|
17
|
+
* @param url - The URL to fetch from
|
|
18
|
+
* @param networkName - Network name for cache directory structure
|
|
19
|
+
* @param options - Caching and error handling options
|
|
20
|
+
* @param cacheDir - Optional cache directory (defaults to no caching)
|
|
21
|
+
* @returns The fetched and parsed JSON data, or undefined if fetch fails and throwOnError is false
|
|
22
|
+
*/
|
|
23
|
+
export async function cachedFetch<T = any>(
|
|
24
|
+
url: string,
|
|
25
|
+
options: CachedFetchOptions,
|
|
26
|
+
fetch = globalThis.fetch,
|
|
27
|
+
log = createLogger('cached_fetch'),
|
|
28
|
+
): Promise<T | undefined> {
|
|
29
|
+
const { cacheDurationMs, cacheFile } = options;
|
|
30
|
+
|
|
31
|
+
// Try to read from cache first
|
|
32
|
+
try {
|
|
33
|
+
if (cacheFile) {
|
|
34
|
+
const info = await stat(cacheFile);
|
|
35
|
+
if (info.mtimeMs + cacheDurationMs > Date.now()) {
|
|
36
|
+
const cachedData = JSON.parse(await readFile(cacheFile, 'utf-8'));
|
|
37
|
+
return cachedData;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
} catch {
|
|
41
|
+
log.trace('Failed to read data from cache');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
const response = await fetch(url);
|
|
46
|
+
if (!response.ok) {
|
|
47
|
+
log.warn(`Failed to fetch from ${url}: ${response.status} ${response.statusText}`);
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const data = await response.json();
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
if (cacheFile) {
|
|
55
|
+
await mkdir(dirname(cacheFile), { recursive: true });
|
|
56
|
+
await writeFile(cacheFile, JSON.stringify(data), 'utf-8');
|
|
57
|
+
}
|
|
58
|
+
} catch (err) {
|
|
59
|
+
log.warn('Failed to cache data on disk: ' + cacheFile, { cacheFile, err });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return data;
|
|
63
|
+
} catch (err) {
|
|
64
|
+
log.warn(`Failed to fetch from ${url}`, { err });
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
}
|