@aztec/cli 0.0.0-test.0 → 0.0.1-fake-c83136db25
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/README.md +1 -427
- package/dest/cmds/aztec_node/block_number.d.ts +3 -0
- package/dest/cmds/aztec_node/block_number.d.ts.map +1 -0
- package/dest/cmds/aztec_node/block_number.js +10 -0
- package/dest/cmds/aztec_node/get_block.d.ts +3 -0
- package/dest/cmds/aztec_node/get_block.d.ts.map +1 -0
- package/dest/cmds/aztec_node/get_block.js +9 -0
- package/dest/cmds/aztec_node/get_current_base_fee.d.ts +3 -0
- package/dest/cmds/aztec_node/get_current_base_fee.d.ts.map +1 -0
- package/dest/cmds/aztec_node/get_current_base_fee.js +7 -0
- package/dest/cmds/aztec_node/get_l1_to_l2_message_witness.d.ts +5 -0
- package/dest/cmds/aztec_node/get_l1_to_l2_message_witness.d.ts.map +1 -0
- package/dest/cmds/aztec_node/get_l1_to_l2_message_witness.js +12 -0
- package/dest/cmds/aztec_node/get_logs.d.ts +6 -0
- package/dest/cmds/aztec_node/get_logs.d.ts.map +1 -0
- package/dest/cmds/{pxe → aztec_node}/get_logs.js +4 -4
- package/dest/cmds/aztec_node/get_node_info.d.ts +3 -0
- package/dest/cmds/aztec_node/get_node_info.d.ts.map +1 -0
- package/dest/cmds/{pxe → aztec_node}/get_node_info.js +14 -15
- package/dest/cmds/aztec_node/index.d.ts.map +1 -0
- package/dest/cmds/aztec_node/index.js +28 -0
- 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 +2 -2
- package/dest/cmds/infrastructure/index.d.ts.map +1 -1
- package/dest/cmds/infrastructure/index.js +8 -9
- package/dest/cmds/infrastructure/sequencers.d.ts +4 -4
- package/dest/cmds/infrastructure/sequencers.d.ts.map +1 -1
- package/dest/cmds/infrastructure/sequencers.js +29 -16
- 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 +11 -24
- package/dest/cmds/l1/advance_epoch.d.ts +1 -1
- package/dest/cmds/l1/advance_epoch.d.ts.map +1 -1
- package/dest/cmds/l1/advance_epoch.js +8 -6
- package/dest/cmds/l1/assume_proven_through.d.ts +1 -1
- package/dest/cmds/l1/assume_proven_through.d.ts.map +1 -1
- package/dest/cmds/l1/assume_proven_through.js +9 -8
- package/dest/cmds/l1/bridge_erc20.d.ts +2 -2
- package/dest/cmds/l1/bridge_erc20.d.ts.map +1 -1
- package/dest/cmds/l1/bridge_erc20.js +5 -5
- 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 +23 -6
- 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 +17 -8
- package/dest/cmds/l1/get_l1_addresses.d.ts +1 -1
- package/dest/cmds/l1/get_l1_addresses.d.ts.map +1 -1
- 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 +33 -43
- 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 +159 -103
- 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 +3 -3
- package/dest/cmds/misc/generate_secret_key.d.ts +1 -1
- package/dest/cmds/misc/generate_secret_key.d.ts.map +1 -1
- package/dest/cmds/misc/generate_secret_key.js +1 -1
- 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/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 +39 -0
- package/dest/config/chain_l2_config.d.ts.map +1 -0
- package/dest/config/chain_l2_config.js +452 -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 -17
- package/dest/utils/aztec.d.ts.map +1 -1
- package/dest/utils/aztec.js +54 -49
- package/dest/utils/commands.d.ts +7 -8
- package/dest/utils/commands.d.ts.map +1 -1
- package/dest/utils/commands.js +10 -11
- 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 +3 -10
- package/dest/utils/inspect.d.ts.map +1 -1
- package/dest/utils/inspect.js +19 -109
- package/dest/utils/setup_contracts.d.ts +3 -0
- package/dest/utils/setup_contracts.d.ts.map +1 -0
- package/dest/utils/setup_contracts.js +16 -0
- package/package.json +40 -33
- package/src/cmds/aztec_node/block_number.ts +9 -0
- package/src/cmds/aztec_node/get_block.ts +10 -0
- package/src/cmds/aztec_node/get_current_base_fee.ts +9 -0
- package/src/cmds/aztec_node/get_l1_to_l2_message_witness.ts +27 -0
- package/src/cmds/{pxe → aztec_node}/get_logs.ts +8 -7
- package/src/cmds/{pxe → aztec_node}/get_node_info.ts +15 -23
- package/src/cmds/aztec_node/index.ts +87 -0
- package/src/cmds/contracts/inspect_contract.ts +16 -6
- package/src/cmds/infrastructure/index.ts +8 -10
- package/src/cmds/infrastructure/sequencers.ts +36 -19
- package/src/cmds/infrastructure/setup_l2_contract.ts +13 -25
- package/src/cmds/l1/advance_epoch.ts +7 -5
- package/src/cmds/l1/assume_proven_through.ts +8 -7
- package/src/cmds/l1/bridge_erc20.ts +7 -4
- package/src/cmds/l1/deploy_l1_contracts.ts +32 -7
- package/src/cmds/l1/deploy_new_rollup.ts +23 -9
- package/src/cmds/l1/get_l1_addresses.ts +1 -1
- package/src/cmds/l1/governance_utils.ts +18 -17
- package/src/cmds/l1/index.ts +74 -101
- package/src/cmds/l1/trigger_seed_snapshot.ts +31 -0
- package/src/cmds/l1/update_l1_validators.ts +194 -94
- package/src/cmds/misc/generate_bootnode_enr.ts +3 -2
- package/src/cmds/misc/generate_secret_and_hash.ts +3 -3
- package/src/cmds/misc/generate_secret_key.ts +1 -1
- 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/config/cached_fetch.ts +67 -0
- package/src/config/chain_l2_config.ts +597 -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 +78 -65
- package/src/utils/commands.ts +13 -15
- 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 +23 -123
- package/src/utils/setup_contracts.ts +19 -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.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/dest/cmds/pxe/add_contract.d.ts +0 -5
- package/dest/cmds/pxe/add_contract.d.ts.map +0 -1
- package/dest/cmds/pxe/add_contract.js +0 -29
- package/dest/cmds/pxe/block_number.d.ts +0 -3
- package/dest/cmds/pxe/block_number.d.ts.map +0 -1
- package/dest/cmds/pxe/block_number.js +0 -10
- package/dest/cmds/pxe/get_account.d.ts +0 -4
- package/dest/cmds/pxe/get_account.d.ts.map +0 -1
- package/dest/cmds/pxe/get_account.js +0 -10
- package/dest/cmds/pxe/get_accounts.d.ts +0 -3
- package/dest/cmds/pxe/get_accounts.d.ts.map +0 -1
- package/dest/cmds/pxe/get_accounts.js +0 -25
- package/dest/cmds/pxe/get_block.d.ts +0 -3
- package/dest/cmds/pxe/get_block.d.ts.map +0 -1
- package/dest/cmds/pxe/get_block.js +0 -9
- package/dest/cmds/pxe/get_contract_data.d.ts +0 -4
- package/dest/cmds/pxe/get_contract_data.d.ts.map +0 -1
- package/dest/cmds/pxe/get_contract_data.js +0 -31
- package/dest/cmds/pxe/get_current_base_fee.d.ts +0 -3
- package/dest/cmds/pxe/get_current_base_fee.d.ts.map +0 -1
- package/dest/cmds/pxe/get_current_base_fee.js +0 -7
- package/dest/cmds/pxe/get_l1_to_l2_message_witness.d.ts +0 -4
- package/dest/cmds/pxe/get_l1_to_l2_message_witness.d.ts.map +0 -1
- package/dest/cmds/pxe/get_l1_to_l2_message_witness.js +0 -11
- package/dest/cmds/pxe/get_logs.d.ts +0 -4
- package/dest/cmds/pxe/get_logs.d.ts.map +0 -1
- package/dest/cmds/pxe/get_node_info.d.ts +0 -3
- package/dest/cmds/pxe/get_node_info.d.ts.map +0 -1
- package/dest/cmds/pxe/get_pxe_info.d.ts +0 -3
- package/dest/cmds/pxe/get_pxe_info.d.ts.map +0 -1
- package/dest/cmds/pxe/get_pxe_info.js +0 -11
- package/dest/cmds/pxe/index.d.ts +0 -4
- package/dest/cmds/pxe/index.d.ts.map +0 -1
- package/dest/cmds/pxe/index.js +0 -55
- 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
- package/src/cmds/pxe/add_contract.ts +0 -41
- package/src/cmds/pxe/block_number.ts +0 -9
- package/src/cmds/pxe/get_account.ts +0 -16
- package/src/cmds/pxe/get_accounts.ts +0 -35
- package/src/cmds/pxe/get_block.ts +0 -10
- package/src/cmds/pxe/get_contract_data.ts +0 -51
- package/src/cmds/pxe/get_current_base_fee.ts +0 -9
- package/src/cmds/pxe/get_l1_to_l2_message_witness.ts +0 -25
- package/src/cmds/pxe/get_pxe_info.ts +0 -13
- package/src/cmds/pxe/index.ts +0 -170
- /package/dest/cmds/{devnet → aztec_node}/index.d.ts +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createEthereumChain, createExtendedL1Client } from '@aztec/ethereum';
|
|
2
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
+
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
4
|
+
|
|
5
|
+
import { getContract } from 'viem';
|
|
6
|
+
|
|
7
|
+
import type { RollupCommandArgs } from './update_l1_validators.js';
|
|
8
|
+
|
|
9
|
+
export async function triggerSeedSnapshot({
|
|
10
|
+
rpcUrls,
|
|
11
|
+
chainId,
|
|
12
|
+
privateKey,
|
|
13
|
+
mnemonic,
|
|
14
|
+
rollupAddress,
|
|
15
|
+
log,
|
|
16
|
+
}: RollupCommandArgs & { log: LogFn }) {
|
|
17
|
+
const chain = createEthereumChain(rpcUrls, chainId);
|
|
18
|
+
const client = createExtendedL1Client(rpcUrls, privateKey ?? mnemonic!, chain.chainInfo);
|
|
19
|
+
|
|
20
|
+
const rollup = getContract({
|
|
21
|
+
address: rollupAddress.toString(),
|
|
22
|
+
abi: RollupAbi,
|
|
23
|
+
client,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
log('Triggering seed snapshot for next epoch');
|
|
27
|
+
const txHash = await rollup.write.checkpointRandao();
|
|
28
|
+
log(`Sent! | Seed snapshot setup for next epoch | tx hash: ${txHash}`);
|
|
29
|
+
const receipt = await client.waitForTransactionReceipt({ hash: txHash });
|
|
30
|
+
log(`Done! | Seed snapshot setup for next epoch | tx hash: ${txHash} | status: ${receipt.status}`);
|
|
31
|
+
}
|
|
@@ -1,17 +1,25 @@
|
|
|
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 { DateProvider } from '@aztec/foundation/timer';
|
|
15
|
+
import { RollupAbi, StakingAssetHandlerAbi } from '@aztec/l1-artifacts';
|
|
16
|
+
import { ZkPassportProofParams } from '@aztec/stdlib/zkpassport';
|
|
11
17
|
|
|
12
|
-
import {
|
|
18
|
+
import { encodeFunctionData, formatEther, getContract } from 'viem';
|
|
13
19
|
import { generatePrivateKey, mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
|
|
14
20
|
|
|
21
|
+
import { addLeadingHex } from '../../utils/aztec.js';
|
|
22
|
+
|
|
15
23
|
export interface RollupCommandArgs {
|
|
16
24
|
rpcUrls: string[];
|
|
17
25
|
chainId: number;
|
|
@@ -21,6 +29,14 @@ export interface RollupCommandArgs {
|
|
|
21
29
|
withdrawerAddress?: EthAddress;
|
|
22
30
|
}
|
|
23
31
|
|
|
32
|
+
export interface StakingAssetHandlerCommandArgs {
|
|
33
|
+
rpcUrls: string[];
|
|
34
|
+
chainId: number;
|
|
35
|
+
privateKey?: string;
|
|
36
|
+
mnemonic?: string;
|
|
37
|
+
stakingAssetHandlerAddress: EthAddress;
|
|
38
|
+
}
|
|
39
|
+
|
|
24
40
|
export interface LoggerArgs {
|
|
25
41
|
log: LogFn;
|
|
26
42
|
debugLogger: Logger;
|
|
@@ -41,56 +57,151 @@ export async function addL1Validator({
|
|
|
41
57
|
chainId,
|
|
42
58
|
privateKey,
|
|
43
59
|
mnemonic,
|
|
44
|
-
|
|
45
|
-
|
|
60
|
+
attesterAddress,
|
|
61
|
+
stakingAssetHandlerAddress,
|
|
62
|
+
merkleProof,
|
|
63
|
+
proofParams,
|
|
64
|
+
blsSecretKey,
|
|
65
|
+
log,
|
|
66
|
+
debugLogger,
|
|
67
|
+
}: StakingAssetHandlerCommandArgs &
|
|
68
|
+
LoggerArgs & {
|
|
69
|
+
blsSecretKey: bigint; // scalar field element of BN254
|
|
70
|
+
attesterAddress: EthAddress;
|
|
71
|
+
proofParams: Buffer;
|
|
72
|
+
merkleProof: string[];
|
|
73
|
+
}) {
|
|
74
|
+
const dualLog = makeDualLog(log, debugLogger);
|
|
75
|
+
const account = getAccount(privateKey, mnemonic);
|
|
76
|
+
const chain = createEthereumChain(rpcUrls, chainId);
|
|
77
|
+
const l1Client = createExtendedL1Client(rpcUrls, account, chain.chainInfo);
|
|
78
|
+
|
|
79
|
+
const stakingAssetHandler = getContract({
|
|
80
|
+
address: stakingAssetHandlerAddress.toString(),
|
|
81
|
+
abi: StakingAssetHandlerAbi,
|
|
82
|
+
client: l1Client,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const rollupAddress = await stakingAssetHandler.read.getRollup();
|
|
86
|
+
dualLog(`Adding validator ${attesterAddress} to rollup ${rollupAddress.toString()}`);
|
|
87
|
+
|
|
88
|
+
const rollup = getContract({
|
|
89
|
+
address: rollupAddress,
|
|
90
|
+
abi: RollupAbi,
|
|
91
|
+
client: l1Client,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const gseAddress = await rollup.read.getGSE();
|
|
95
|
+
|
|
96
|
+
const gse = new GSEContract(l1Client, gseAddress);
|
|
97
|
+
|
|
98
|
+
const registrationTuple = await gse.makeRegistrationTuple(blsSecretKey);
|
|
99
|
+
|
|
100
|
+
const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client, { logger: debugLogger });
|
|
101
|
+
const proofParamsObj = ZkPassportProofParams.fromBuffer(proofParams);
|
|
102
|
+
const merkleProofArray = merkleProof.map(proof => addLeadingHex(proof));
|
|
103
|
+
|
|
104
|
+
const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
|
|
105
|
+
to: stakingAssetHandlerAddress.toString(),
|
|
106
|
+
data: encodeFunctionData({
|
|
107
|
+
abi: StakingAssetHandlerAbi,
|
|
108
|
+
functionName: 'addValidator',
|
|
109
|
+
args: [
|
|
110
|
+
attesterAddress.toString(),
|
|
111
|
+
merkleProofArray,
|
|
112
|
+
proofParamsObj.toViem(),
|
|
113
|
+
registrationTuple.publicKeyInG1,
|
|
114
|
+
registrationTuple.publicKeyInG2,
|
|
115
|
+
registrationTuple.proofOfPossession,
|
|
116
|
+
],
|
|
117
|
+
}),
|
|
118
|
+
abi: StakingAssetHandlerAbi,
|
|
119
|
+
});
|
|
120
|
+
dualLog(`Transaction hash: ${receipt.transactionHash}`);
|
|
121
|
+
await l1Client.waitForTransactionReceipt({ hash: receipt.transactionHash });
|
|
122
|
+
if (isAnvilTestChain(chainId)) {
|
|
123
|
+
dualLog(`Funding validator on L1`);
|
|
124
|
+
const cheatCodes = new EthCheatCodes(rpcUrls, new DateProvider(), debugLogger);
|
|
125
|
+
await cheatCodes.setBalance(attesterAddress, 10n ** 20n);
|
|
126
|
+
} else {
|
|
127
|
+
const balance = await l1Client.getBalance({ address: attesterAddress.toString() });
|
|
128
|
+
dualLog(`Validator balance: ${formatEther(balance)} ETH`);
|
|
129
|
+
if (balance === 0n) {
|
|
130
|
+
dualLog(`WARNING: Proposer has no balance. Remember to fund it!`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export async function addL1ValidatorViaRollup({
|
|
136
|
+
rpcUrls,
|
|
137
|
+
chainId,
|
|
138
|
+
privateKey,
|
|
139
|
+
mnemonic,
|
|
140
|
+
attesterAddress,
|
|
46
141
|
withdrawerAddress,
|
|
142
|
+
blsSecretKey,
|
|
143
|
+
moveWithLatestRollup,
|
|
144
|
+
rollupAddress,
|
|
47
145
|
log,
|
|
48
146
|
debugLogger,
|
|
49
|
-
}: RollupCommandArgs &
|
|
50
|
-
|
|
147
|
+
}: RollupCommandArgs &
|
|
148
|
+
LoggerArgs & {
|
|
149
|
+
blsSecretKey: bigint; // scalar field element of BN254
|
|
150
|
+
attesterAddress: EthAddress;
|
|
151
|
+
moveWithLatestRollup: boolean;
|
|
152
|
+
}) {
|
|
51
153
|
const dualLog = makeDualLog(log, debugLogger);
|
|
52
|
-
const
|
|
53
|
-
const
|
|
154
|
+
const account = getAccount(privateKey, mnemonic);
|
|
155
|
+
const chain = createEthereumChain(rpcUrls, chainId);
|
|
156
|
+
const l1Client = createExtendedL1Client(rpcUrls, account, chain.chainInfo);
|
|
157
|
+
|
|
158
|
+
dualLog(`Adding validator ${attesterAddress} to rollup ${rollupAddress.toString()} via direct deposit`);
|
|
159
|
+
|
|
160
|
+
if (!withdrawerAddress) {
|
|
161
|
+
throw new Error(`Withdrawer address required`);
|
|
162
|
+
}
|
|
163
|
+
|
|
54
164
|
const rollup = getContract({
|
|
55
165
|
address: rollupAddress.toString(),
|
|
56
166
|
abi: RollupAbi,
|
|
57
|
-
client:
|
|
167
|
+
client: l1Client,
|
|
58
168
|
});
|
|
59
169
|
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
170
|
+
const gseAddress = await rollup.read.getGSE();
|
|
171
|
+
|
|
172
|
+
const gse = new GSEContract(l1Client, gseAddress);
|
|
173
|
+
|
|
174
|
+
const registrationTuple = await gse.makeRegistrationTuple(blsSecretKey);
|
|
65
175
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
176
|
+
const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client, { logger: debugLogger });
|
|
177
|
+
|
|
178
|
+
const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
|
|
179
|
+
to: rollupAddress.toString(),
|
|
180
|
+
data: encodeFunctionData({
|
|
181
|
+
abi: RollupAbi,
|
|
182
|
+
functionName: 'deposit',
|
|
183
|
+
args: [
|
|
184
|
+
attesterAddress.toString(),
|
|
185
|
+
withdrawerAddress.toString(),
|
|
186
|
+
registrationTuple.publicKeyInG1,
|
|
187
|
+
registrationTuple.publicKeyInG2,
|
|
188
|
+
registrationTuple.proofOfPossession,
|
|
189
|
+
moveWithLatestRollup,
|
|
190
|
+
],
|
|
191
|
+
}),
|
|
192
|
+
abi: StakingAssetHandlerAbi,
|
|
193
|
+
});
|
|
194
|
+
dualLog(`Transaction hash: ${receipt.transactionHash}`);
|
|
195
|
+
await l1Client.waitForTransactionReceipt({ hash: receipt.transactionHash });
|
|
84
196
|
if (isAnvilTestChain(chainId)) {
|
|
85
197
|
dualLog(`Funding validator on L1`);
|
|
86
|
-
const cheatCodes = new EthCheatCodes(rpcUrls, debugLogger);
|
|
87
|
-
await cheatCodes.setBalance(
|
|
198
|
+
const cheatCodes = new EthCheatCodes(rpcUrls, new DateProvider(), debugLogger);
|
|
199
|
+
await cheatCodes.setBalance(attesterAddress, 10n ** 20n);
|
|
88
200
|
} else {
|
|
89
|
-
const balance = await
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
dualLog(`WARNING: Validator has no balance. Remember to fund it!`);
|
|
201
|
+
const balance = await l1Client.getBalance({ address: attesterAddress.toString() });
|
|
202
|
+
dualLog(`Validator balance: ${formatEther(balance)} ETH`);
|
|
203
|
+
if (balance === 0n) {
|
|
204
|
+
dualLog(`WARNING: Proposer has no balance. Remember to fund it!`);
|
|
94
205
|
}
|
|
95
206
|
}
|
|
96
207
|
}
|
|
@@ -106,18 +217,21 @@ export async function removeL1Validator({
|
|
|
106
217
|
debugLogger,
|
|
107
218
|
}: RollupCommandArgs & LoggerArgs & { validatorAddress: EthAddress }) {
|
|
108
219
|
const dualLog = makeDualLog(log, debugLogger);
|
|
109
|
-
const
|
|
110
|
-
const
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
abi: RollupAbi,
|
|
114
|
-
client: walletClient,
|
|
115
|
-
});
|
|
220
|
+
const account = getAccount(privateKey, mnemonic);
|
|
221
|
+
const chain = createEthereumChain(rpcUrls, chainId);
|
|
222
|
+
const l1Client = createExtendedL1Client(rpcUrls, account, chain.chainInfo);
|
|
223
|
+
const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client, { logger: debugLogger });
|
|
116
224
|
|
|
117
225
|
dualLog(`Removing validator ${validatorAddress.toString()} from rollup ${rollupAddress.toString()}`);
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
226
|
+
const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
|
|
227
|
+
to: rollupAddress.toString(),
|
|
228
|
+
data: encodeFunctionData({
|
|
229
|
+
abi: RollupAbi,
|
|
230
|
+
functionName: 'initiateWithdraw',
|
|
231
|
+
args: [validatorAddress.toString(), validatorAddress.toString()],
|
|
232
|
+
}),
|
|
233
|
+
});
|
|
234
|
+
dualLog(`Transaction hash: ${receipt.transactionHash}`);
|
|
121
235
|
}
|
|
122
236
|
|
|
123
237
|
export async function pruneRollup({
|
|
@@ -130,18 +244,20 @@ export async function pruneRollup({
|
|
|
130
244
|
debugLogger,
|
|
131
245
|
}: RollupCommandArgs & LoggerArgs) {
|
|
132
246
|
const dualLog = makeDualLog(log, debugLogger);
|
|
133
|
-
const
|
|
134
|
-
const
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
abi: RollupAbi,
|
|
138
|
-
client: walletClient,
|
|
139
|
-
});
|
|
247
|
+
const account = getAccount(privateKey, mnemonic);
|
|
248
|
+
const chain = createEthereumChain(rpcUrls, chainId);
|
|
249
|
+
const l1Client = createExtendedL1Client(rpcUrls, account, chain.chainInfo);
|
|
250
|
+
const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client, { logger: debugLogger });
|
|
140
251
|
|
|
141
252
|
dualLog(`Trying prune`);
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
253
|
+
const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
|
|
254
|
+
to: rollupAddress.toString(),
|
|
255
|
+
data: encodeFunctionData({
|
|
256
|
+
abi: RollupAbi,
|
|
257
|
+
functionName: 'prune',
|
|
258
|
+
}),
|
|
259
|
+
});
|
|
260
|
+
dualLog(`Transaction hash: ${receipt.transactionHash}`);
|
|
145
261
|
}
|
|
146
262
|
|
|
147
263
|
export async function fastForwardEpochs({
|
|
@@ -153,20 +269,20 @@ export async function fastForwardEpochs({
|
|
|
153
269
|
debugLogger,
|
|
154
270
|
}: RollupCommandArgs & LoggerArgs & { numEpochs: bigint }) {
|
|
155
271
|
const dualLog = makeDualLog(log, debugLogger);
|
|
156
|
-
const publicClient = getPublicClient(rpcUrls, chainId);
|
|
272
|
+
const publicClient = getPublicClient({ l1RpcUrls: rpcUrls, l1ChainId: chainId });
|
|
157
273
|
const rollup = getContract({
|
|
158
274
|
address: rollupAddress.toString(),
|
|
159
275
|
abi: RollupAbi,
|
|
160
276
|
client: publicClient,
|
|
161
277
|
});
|
|
162
278
|
|
|
163
|
-
const cheatCodes = new EthCheatCodes(rpcUrls, debugLogger);
|
|
279
|
+
const cheatCodes = new EthCheatCodes(rpcUrls, new DateProvider(), debugLogger);
|
|
164
280
|
const currentSlot = await rollup.read.getCurrentSlot();
|
|
165
281
|
const l2SlotsInEpoch = await rollup.read.getEpochDuration();
|
|
166
282
|
const timestamp = await rollup.read.getTimestampForSlot([currentSlot + l2SlotsInEpoch * numEpochs]);
|
|
167
283
|
dualLog(`Fast forwarding ${numEpochs} epochs to ${timestamp}`);
|
|
168
284
|
try {
|
|
169
|
-
await cheatCodes.warp(Number(timestamp));
|
|
285
|
+
await cheatCodes.warp(Number(timestamp), { resetBlockInterval: true });
|
|
170
286
|
dualLog(`Fast forwarded ${numEpochs} epochs to ${timestamp}`);
|
|
171
287
|
} catch (error) {
|
|
172
288
|
if (error instanceof Error && error.message.includes("is lower than or equal to previous block's timestamp")) {
|
|
@@ -180,31 +296,27 @@ export async function fastForwardEpochs({
|
|
|
180
296
|
|
|
181
297
|
export async function debugRollup({ rpcUrls, chainId, rollupAddress, log }: RollupCommandArgs & LoggerArgs) {
|
|
182
298
|
const config = getL1ContractsConfigEnvVars();
|
|
183
|
-
const publicClient = getPublicClient(rpcUrls, chainId);
|
|
184
|
-
const rollup =
|
|
185
|
-
address: rollupAddress.toString(),
|
|
186
|
-
abi: RollupAbi,
|
|
187
|
-
client: publicClient,
|
|
188
|
-
});
|
|
299
|
+
const publicClient = getPublicClient({ l1RpcUrls: rpcUrls, l1ChainId: chainId });
|
|
300
|
+
const rollup = new RollupContract(publicClient, rollupAddress);
|
|
189
301
|
|
|
190
|
-
const pendingNum = await rollup.
|
|
302
|
+
const pendingNum = await rollup.getBlockNumber();
|
|
191
303
|
log(`Pending block num: ${pendingNum}`);
|
|
192
|
-
const provenNum = await rollup.
|
|
304
|
+
const provenNum = await rollup.getProvenBlockNumber();
|
|
193
305
|
log(`Proven block num: ${provenNum}`);
|
|
194
|
-
const validators = await rollup.
|
|
306
|
+
const validators = await rollup.getAttesters();
|
|
195
307
|
log(`Validators: ${validators.map(v => v.toString()).join(', ')}`);
|
|
196
|
-
const committee = await rollup.
|
|
197
|
-
log(`Committee: ${committee
|
|
198
|
-
const archive = await rollup.
|
|
308
|
+
const committee = await rollup.getCurrentEpochCommittee();
|
|
309
|
+
log(`Committee: ${committee?.map(v => v.toString()).join(', ')}`);
|
|
310
|
+
const archive = await rollup.archive();
|
|
199
311
|
log(`Archive: ${archive}`);
|
|
200
|
-
const epochNum = await rollup.
|
|
312
|
+
const epochNum = await rollup.getCurrentEpochNumber();
|
|
201
313
|
log(`Current epoch: ${epochNum}`);
|
|
202
|
-
const slot = await rollup.
|
|
314
|
+
const slot = await rollup.getSlotNumber();
|
|
203
315
|
log(`Current slot: ${slot}`);
|
|
204
|
-
const proposerDuringPrevL1Block = await rollup.
|
|
316
|
+
const proposerDuringPrevL1Block = await rollup.getCurrentProposer();
|
|
205
317
|
log(`Proposer during previous L1 block: ${proposerDuringPrevL1Block}`);
|
|
206
318
|
const nextBlockTS = BigInt((await publicClient.getBlock()).timestamp + BigInt(config.ethereumSlotDuration));
|
|
207
|
-
const proposer = await rollup.
|
|
319
|
+
const proposer = await rollup.getProposerAt(nextBlockTS);
|
|
208
320
|
log(`Proposer NOW: ${proposer.toString()}`);
|
|
209
321
|
}
|
|
210
322
|
|
|
@@ -215,24 +327,12 @@ function makeDualLog(log: LogFn, debugLogger: Logger) {
|
|
|
215
327
|
};
|
|
216
328
|
}
|
|
217
329
|
|
|
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
|
-
) {
|
|
330
|
+
function getAccount(privateKey: string | undefined, mnemonic: string | undefined) {
|
|
229
331
|
if (!privateKey && !mnemonic) {
|
|
230
332
|
throw new Error('Either privateKey or mnemonic must be provided to create a wallet client');
|
|
231
333
|
}
|
|
232
|
-
|
|
233
|
-
const chain = createEthereumChain(rpcUrls, chainId);
|
|
234
334
|
const account = !privateKey
|
|
235
335
|
? mnemonicToAccount(mnemonic!)
|
|
236
336
|
: privateKeyToAccount(`${privateKey.startsWith('0x') ? '' : '0x'}${privateKey}` as `0x${string}`);
|
|
237
|
-
return
|
|
337
|
+
return account;
|
|
238
338
|
}
|
|
@@ -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
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { computeSecretHash } from '@aztec/aztec.js';
|
|
1
|
+
import { computeSecretHash } from '@aztec/aztec.js/crypto';
|
|
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') {
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { createLogger } from '@aztec/aztec.js/log';
|
|
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
|
+
}
|