@aztec/cli 3.0.0-devnet.2 → 3.0.0-devnet.2-patch.1
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 -1
- package/dest/cmds/aztec_node/block_number.d.ts +1 -1
- package/dest/cmds/aztec_node/get_block.d.ts +1 -1
- package/dest/cmds/aztec_node/get_block.d.ts.map +1 -1
- package/dest/cmds/aztec_node/get_block.js +2 -1
- package/dest/cmds/aztec_node/get_current_base_fee.d.ts +1 -1
- package/dest/cmds/aztec_node/get_l1_to_l2_message_witness.d.ts +1 -1
- package/dest/cmds/aztec_node/get_logs.d.ts +3 -2
- package/dest/cmds/aztec_node/get_logs.d.ts.map +1 -1
- package/dest/cmds/aztec_node/get_node_info.d.ts +1 -1
- package/dest/cmds/aztec_node/index.d.ts +1 -1
- package/dest/cmds/contracts/index.d.ts +1 -1
- package/dest/cmds/contracts/inspect_contract.d.ts +1 -1
- package/dest/cmds/contracts/inspect_contract.d.ts.map +1 -1
- package/dest/cmds/contracts/inspect_contract.js +4 -10
- package/dest/cmds/contracts/parse_parameter_struct.d.ts +1 -1
- package/dest/cmds/infrastructure/index.d.ts +1 -1
- package/dest/cmds/infrastructure/index.d.ts.map +1 -1
- package/dest/cmds/infrastructure/index.js +0 -1
- package/dest/cmds/infrastructure/sequencers.d.ts +1 -2
- package/dest/cmds/infrastructure/sequencers.d.ts.map +1 -1
- package/dest/cmds/infrastructure/sequencers.js +3 -1
- package/dest/cmds/infrastructure/setup_l2_contract.d.ts +1 -1
- package/dest/cmds/l1/advance_epoch.d.ts +1 -1
- 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 +2 -1
- 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 +2 -1
- package/dest/cmds/l1/create_l1_account.d.ts +1 -1
- package/dest/cmds/l1/deploy_l1_contracts.d.ts +1 -1
- package/dest/cmds/l1/deploy_l1_contracts.js +1 -1
- package/dest/cmds/l1/deploy_new_rollup.d.ts +2 -2
- package/dest/cmds/l1/deploy_new_rollup.d.ts.map +1 -1
- package/dest/cmds/l1/deploy_new_rollup.js +1 -1
- 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/get_l1_addresses.js +2 -1
- package/dest/cmds/l1/get_l1_balance.d.ts +1 -1
- package/dest/cmds/l1/get_l1_balance.js +1 -1
- package/dest/cmds/l1/governance_utils.d.ts +5 -5
- package/dest/cmds/l1/governance_utils.d.ts.map +1 -1
- package/dest/cmds/l1/governance_utils.js +3 -1
- package/dest/cmds/l1/index.d.ts +1 -1
- package/dest/cmds/l1/prover_stats.d.ts +1 -1
- package/dest/cmds/l1/prover_stats.d.ts.map +1 -1
- package/dest/cmds/l1/prover_stats.js +29 -29
- package/dest/cmds/l1/trigger_seed_snapshot.d.ts +2 -2
- package/dest/cmds/l1/trigger_seed_snapshot.d.ts.map +1 -1
- package/dest/cmds/l1/trigger_seed_snapshot.js +2 -1
- package/dest/cmds/l1/update_l1_validators.d.ts +6 -6
- package/dest/cmds/l1/update_l1_validators.d.ts.map +1 -1
- package/dest/cmds/l1/update_l1_validators.js +7 -3
- package/dest/cmds/misc/compute_selector.d.ts +1 -1
- package/dest/cmds/misc/example_contracts.d.ts +1 -1
- package/dest/cmds/misc/generate_bootnode_enr.d.ts +1 -1
- package/dest/cmds/misc/generate_p2p_private_key.d.ts +1 -1
- package/dest/cmds/misc/generate_secret_and_hash.d.ts +1 -1
- package/dest/cmds/misc/generate_secret_and_hash.js +1 -1
- package/dest/cmds/misc/generate_secret_key.d.ts +1 -1
- package/dest/cmds/misc/get_canonical_sponsored_fpc_address.d.ts +1 -1
- package/dest/cmds/misc/index.d.ts +1 -1
- package/dest/cmds/misc/update/common.d.ts +1 -1
- package/dest/cmds/misc/update/github.d.ts +1 -1
- package/dest/cmds/misc/update/noir.d.ts +1 -1
- package/dest/cmds/misc/update/npm.d.ts +1 -1
- package/dest/cmds/misc/update/npm.js +1 -1
- package/dest/cmds/misc/update/utils.d.ts +1 -1
- package/dest/cmds/misc/update.d.ts +1 -1
- package/dest/cmds/validator_keys/add.d.ts +5 -0
- package/dest/cmds/validator_keys/add.d.ts.map +1 -0
- package/dest/cmds/validator_keys/add.js +83 -0
- package/dest/cmds/validator_keys/generate_bls_keypair.d.ts +12 -0
- package/dest/cmds/validator_keys/generate_bls_keypair.d.ts.map +1 -0
- package/dest/cmds/validator_keys/generate_bls_keypair.js +27 -0
- package/dest/cmds/validator_keys/index.d.ts +4 -0
- package/dest/cmds/validator_keys/index.d.ts.map +1 -0
- package/dest/cmds/validator_keys/index.js +32 -0
- package/dest/cmds/validator_keys/new.d.ts +29 -0
- package/dest/cmds/validator_keys/new.d.ts.map +1 -0
- package/dest/cmds/validator_keys/new.js +132 -0
- package/dest/cmds/validator_keys/shared.d.ts +68 -0
- package/dest/cmds/validator_keys/shared.d.ts.map +1 -0
- package/dest/cmds/validator_keys/shared.js +274 -0
- package/dest/cmds/validator_keys/staker.d.ts +38 -0
- package/dest/cmds/validator_keys/staker.d.ts.map +1 -0
- package/dest/cmds/validator_keys/staker.js +208 -0
- package/dest/cmds/validator_keys/utils.d.ts +25 -0
- package/dest/cmds/validator_keys/utils.d.ts.map +1 -0
- package/dest/cmds/validator_keys/utils.js +52 -0
- package/dest/config/cached_fetch.d.ts +1 -1
- package/dest/config/chain_l2_config.d.ts +14 -10
- package/dest/config/chain_l2_config.d.ts.map +1 -1
- package/dest/config/chain_l2_config.js +128 -67
- package/dest/config/enrich_env.d.ts +1 -1
- package/dest/config/get_l1_config.d.ts +3 -2
- package/dest/config/get_l1_config.d.ts.map +1 -1
- package/dest/config/get_l1_config.js +3 -1
- package/dest/config/index.d.ts +1 -1
- package/dest/config/network_config.d.ts +6 -3
- package/dest/config/network_config.d.ts.map +1 -1
- package/dest/config/network_config.js +58 -28
- package/dest/utils/aztec.d.ts +5 -3
- package/dest/utils/aztec.d.ts.map +1 -1
- package/dest/utils/aztec.js +6 -3
- package/dest/utils/commands.d.ts +12 -3
- package/dest/utils/commands.d.ts.map +1 -1
- package/dest/utils/commands.js +30 -3
- package/dest/utils/encoding.d.ts +1 -1
- package/dest/utils/encoding.js +1 -1
- package/dest/utils/github.d.ts +1 -1
- package/dest/utils/index.d.ts +1 -1
- package/dest/utils/inspect.d.ts +3 -2
- package/dest/utils/inspect.d.ts.map +1 -1
- package/dest/utils/setup_contracts.d.ts +1 -1
- package/package.json +37 -28
- package/public_include_metric_prefixes.json +1 -0
- package/src/cmds/aztec_node/get_block.ts +2 -1
- package/src/cmds/aztec_node/get_logs.ts +3 -2
- package/src/cmds/contracts/inspect_contract.ts +4 -11
- package/src/cmds/infrastructure/index.ts +0 -1
- package/src/cmds/infrastructure/sequencers.ts +3 -2
- package/src/cmds/l1/assume_proven_through.ts +4 -1
- package/src/cmds/l1/bridge_erc20.ts +2 -1
- package/src/cmds/l1/deploy_l1_contracts.ts +1 -1
- package/src/cmds/l1/deploy_new_rollup.ts +2 -1
- package/src/cmds/l1/get_l1_addresses.ts +3 -1
- package/src/cmds/l1/get_l1_balance.ts +1 -1
- package/src/cmds/l1/governance_utils.ts +3 -8
- package/src/cmds/l1/prover_stats.ts +38 -30
- package/src/cmds/l1/trigger_seed_snapshot.ts +2 -1
- package/src/cmds/l1/update_l1_validators.ts +7 -12
- package/src/cmds/misc/generate_secret_and_hash.ts +1 -1
- package/src/cmds/misc/update/npm.ts +1 -1
- package/src/cmds/validator_keys/add.ts +123 -0
- package/src/cmds/validator_keys/generate_bls_keypair.ts +34 -0
- package/src/cmds/validator_keys/index.ts +142 -0
- package/src/cmds/validator_keys/new.ts +207 -0
- package/src/cmds/validator_keys/shared.ts +326 -0
- package/src/cmds/validator_keys/staker.ts +301 -0
- package/src/cmds/validator_keys/utils.ts +80 -0
- package/src/config/chain_l2_config.ts +176 -92
- package/src/config/get_l1_config.ts +4 -1
- package/src/config/network_config.ts +67 -29
- package/src/utils/aztec.ts +9 -9
- package/src/utils/commands.ts +41 -3
- package/src/utils/encoding.ts +1 -1
- package/src/utils/inspect.ts +2 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
2
|
-
import {
|
|
2
|
+
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
|
|
3
|
+
import type { Operator } from '@aztec/ethereum/deploy-l1-contracts';
|
|
3
4
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
5
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
5
6
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
-
import {
|
|
2
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
3
|
+
import { RegistryContract } from '@aztec/ethereum/contracts';
|
|
4
|
+
import type { ViemPublicClient } from '@aztec/ethereum/types';
|
|
3
5
|
import type { LogFn } from '@aztec/foundation/log';
|
|
4
6
|
|
|
5
7
|
import { createPublicClient, fallback, http } from 'viem';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createEthereumChain } from '@aztec/ethereum';
|
|
1
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
2
2
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
3
|
import type { LogFn } from '@aztec/foundation/log';
|
|
4
4
|
import { TestERC20Abi } from '@aztec/l1-artifacts';
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
ProposalState,
|
|
5
|
-
RegistryContract,
|
|
6
|
-
createEthereumChain,
|
|
7
|
-
createExtendedL1Client,
|
|
8
|
-
} from '@aztec/ethereum';
|
|
1
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
2
|
+
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
3
|
+
import { FeeJuiceContract, GovernanceContract, ProposalState, RegistryContract } from '@aztec/ethereum/contracts';
|
|
9
4
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
10
5
|
|
|
11
6
|
export async function depositGovernanceTokens({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { retrieveL2ProofVerifiedEvents } from '@aztec/archiver';
|
|
2
|
-
import {
|
|
2
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
3
|
+
import type { ViemPublicClient } from '@aztec/ethereum/types';
|
|
3
4
|
import { compactArray, mapValues, unique } from '@aztec/foundation/collection';
|
|
4
5
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
5
6
|
import { type LogFn, type Logger, createLogger } from '@aztec/foundation/log';
|
|
@@ -55,33 +56,40 @@ export async function proverStats(opts: {
|
|
|
55
56
|
|
|
56
57
|
// If we only care for raw logs, output them
|
|
57
58
|
if (rawLogs && !provingTimeout) {
|
|
58
|
-
log(`l1_block_number,
|
|
59
|
+
log(`l1_block_number, checkpoint_number, prover_id, tx_hash`);
|
|
59
60
|
for (const event of events) {
|
|
60
|
-
const { l1BlockNumber,
|
|
61
|
-
log(`${l1BlockNumber}, ${
|
|
61
|
+
const { l1BlockNumber, checkpointNumber, proverId, txHash } = event;
|
|
62
|
+
log(`${l1BlockNumber}, ${checkpointNumber}, ${proverId}, ${txHash}`);
|
|
62
63
|
}
|
|
63
64
|
return;
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
// If we don't have a proving timeout, we can just count the number of unique
|
|
67
|
+
// If we don't have a proving timeout, we can just count the number of unique checkpoints per prover
|
|
67
68
|
if (!provingTimeout) {
|
|
68
69
|
const stats = groupBy(events, 'proverId');
|
|
69
|
-
log(`prover_id,
|
|
70
|
+
log(`prover_id, total_checkpoints_proven`);
|
|
70
71
|
for (const proverId in stats) {
|
|
71
|
-
const
|
|
72
|
-
log(`${proverId}, ${
|
|
72
|
+
const uniqueCheckpoints = new Set(stats[proverId].map(e => e.checkpointNumber));
|
|
73
|
+
log(`${proverId}, ${uniqueCheckpoints.size}`);
|
|
73
74
|
}
|
|
74
75
|
return;
|
|
75
76
|
}
|
|
76
77
|
|
|
77
|
-
// But if we do, fetch the events for each
|
|
78
|
-
const
|
|
78
|
+
// But if we do, fetch the events for each checkpoint submitted, so we can look up their timestamp
|
|
79
|
+
const checkpointEvents = await getCheckpointProposedEvents(
|
|
80
|
+
startBlock,
|
|
81
|
+
lastBlockNum,
|
|
82
|
+
batchSize,
|
|
83
|
+
debugLog,
|
|
84
|
+
publicClient,
|
|
85
|
+
rollup,
|
|
86
|
+
);
|
|
79
87
|
debugLog.verbose(
|
|
80
|
-
`First
|
|
88
|
+
`First checkpoint within range is ${checkpointEvents[0]?.args.checkpointNumber} at L1 block ${checkpointEvents[0]?.blockNumber}`,
|
|
81
89
|
);
|
|
82
90
|
|
|
83
91
|
// Get the timestamps for every block on every log, both for proof and block submissions
|
|
84
|
-
const l1BlockNumbers = unique([...events.map(e => e.l1BlockNumber), ...
|
|
92
|
+
const l1BlockNumbers = unique([...events.map(e => e.l1BlockNumber), ...checkpointEvents.map(e => e.blockNumber)]);
|
|
85
93
|
const l1BlockTimestamps: Record<string, bigint> = {};
|
|
86
94
|
for (const l1Batch of chunk(l1BlockNumbers, Number(batchSize))) {
|
|
87
95
|
const blocks = await Promise.all(
|
|
@@ -93,44 +101,44 @@ export async function proverStats(opts: {
|
|
|
93
101
|
}
|
|
94
102
|
}
|
|
95
103
|
|
|
96
|
-
// Map from
|
|
97
|
-
const
|
|
98
|
-
for (const
|
|
99
|
-
|
|
104
|
+
// Map from checkpoint number to the l1 block in which it was submitted
|
|
105
|
+
const checkpointSubmissions: Record<string, bigint> = {};
|
|
106
|
+
for (const checkpointEvent of checkpointEvents) {
|
|
107
|
+
checkpointSubmissions[checkpointEvent.args.checkpointNumber!.toString()] = checkpointEvent.blockNumber;
|
|
100
108
|
}
|
|
101
109
|
|
|
102
110
|
// If we want raw logs, output them
|
|
103
111
|
if (rawLogs) {
|
|
104
|
-
log(`l1_block_number,
|
|
112
|
+
log(`l1_block_number, checkpoint_number, checkpoint_submission_timestamp, proof_timestamp, prover_id, tx_hash`);
|
|
105
113
|
for (const event of events) {
|
|
106
|
-
const { l1BlockNumber,
|
|
107
|
-
const uploadedBlockNumber =
|
|
114
|
+
const { l1BlockNumber, checkpointNumber, proverId, txHash } = event;
|
|
115
|
+
const uploadedBlockNumber = checkpointSubmissions[checkpointNumber.toString()];
|
|
108
116
|
if (!uploadedBlockNumber) {
|
|
109
117
|
continue;
|
|
110
118
|
}
|
|
111
119
|
const uploadedTimestamp = l1BlockTimestamps[uploadedBlockNumber.toString()];
|
|
112
120
|
const provenTimestamp = l1BlockTimestamps[l1BlockNumber.toString()];
|
|
113
|
-
log(`${l1BlockNumber}, ${
|
|
121
|
+
log(`${l1BlockNumber}, ${checkpointNumber}, ${uploadedTimestamp}, ${provenTimestamp}, ${proverId}, ${txHash}`);
|
|
114
122
|
}
|
|
115
123
|
return;
|
|
116
124
|
}
|
|
117
125
|
|
|
118
126
|
// Or calculate stats per prover
|
|
119
|
-
const stats = mapValues(groupBy(events, 'proverId'), (
|
|
127
|
+
const stats = mapValues(groupBy(events, 'proverId'), (checkpoints, proverId) =>
|
|
120
128
|
compactArray(
|
|
121
|
-
|
|
129
|
+
checkpoints.map(e => {
|
|
122
130
|
const provenTimestamp = l1BlockTimestamps[e.l1BlockNumber.toString()];
|
|
123
|
-
const uploadedBlockNumber =
|
|
131
|
+
const uploadedBlockNumber = checkpointSubmissions[e.checkpointNumber.toString()];
|
|
124
132
|
if (!uploadedBlockNumber) {
|
|
125
133
|
debugLog.verbose(
|
|
126
|
-
`Skipping ${proverId}'s proof for
|
|
134
|
+
`Skipping ${proverId}'s proof for checkpoint ${e.checkpointNumber} as it was before the start block`,
|
|
127
135
|
);
|
|
128
136
|
return undefined;
|
|
129
137
|
}
|
|
130
138
|
const uploadedTimestamp = l1BlockTimestamps[uploadedBlockNumber.toString()];
|
|
131
139
|
const provingTime = provenTimestamp - uploadedTimestamp;
|
|
132
140
|
debugLog.debug(
|
|
133
|
-
`prover=${e.proverId}
|
|
141
|
+
`prover=${e.proverId} checkpointNumber=${e.checkpointNumber} uploaded=${uploadedTimestamp} proven=${provenTimestamp} time=${provingTime}`,
|
|
134
142
|
);
|
|
135
143
|
return { provenTimestamp, uploadedTimestamp, provingTime, ...e };
|
|
136
144
|
}),
|
|
@@ -141,8 +149,8 @@ export async function proverStats(opts: {
|
|
|
141
149
|
for (const proverId in stats) {
|
|
142
150
|
const blocks = stats[proverId];
|
|
143
151
|
const withinTimeout = blocks.filter(b => b.provingTime <= provingTimeout);
|
|
144
|
-
const uniqueBlocksWithinTimeout = new Set(withinTimeout.map(e => e.
|
|
145
|
-
const uniqueBlocks = new Set(blocks.map(e => e.
|
|
152
|
+
const uniqueBlocksWithinTimeout = new Set(withinTimeout.map(e => e.checkpointNumber));
|
|
153
|
+
const uniqueBlocks = new Set(blocks.map(e => e.checkpointNumber));
|
|
146
154
|
const avgProvingTime =
|
|
147
155
|
blocks.length === 0 ? 0 : Math.ceil(Number(blocks.reduce((acc, b) => acc + b.provingTime, 0n)) / blocks.length);
|
|
148
156
|
|
|
@@ -171,7 +179,7 @@ async function getL2ProofVerifiedEvents(
|
|
|
171
179
|
return events;
|
|
172
180
|
}
|
|
173
181
|
|
|
174
|
-
async function
|
|
182
|
+
async function getCheckpointProposedEvents(
|
|
175
183
|
startBlock: bigint,
|
|
176
184
|
lastBlockNum: bigint,
|
|
177
185
|
batchSize: bigint,
|
|
@@ -188,14 +196,14 @@ async function getL2BlockEvents(
|
|
|
188
196
|
address: getAddress(rollup.toString()),
|
|
189
197
|
event: getAbiItem({
|
|
190
198
|
abi: RollupAbi,
|
|
191
|
-
name: '
|
|
199
|
+
name: 'CheckpointProposed',
|
|
192
200
|
}),
|
|
193
201
|
fromBlock: blockNum,
|
|
194
202
|
toBlock: end,
|
|
195
203
|
});
|
|
196
204
|
|
|
197
205
|
events.push(...newEvents);
|
|
198
|
-
debugLog.verbose(`Got ${newEvents.length} events querying
|
|
206
|
+
debugLog.verbose(`Got ${newEvents.length} events querying checkpoints submitted from block ${blockNum} to ${end}`);
|
|
199
207
|
blockNum += batchSize;
|
|
200
208
|
}
|
|
201
209
|
return events;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createEthereumChain
|
|
1
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
2
|
+
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
2
3
|
import type { LogFn } from '@aztec/foundation/log';
|
|
3
4
|
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
4
5
|
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
createL1TxUtilsFromViemWallet,
|
|
7
|
-
getL1ContractsConfigEnvVars,
|
|
8
|
-
getPublicClient,
|
|
9
|
-
isAnvilTestChain,
|
|
10
|
-
} from '@aztec/ethereum';
|
|
1
|
+
import { createEthereumChain, isAnvilTestChain } from '@aztec/ethereum/chain';
|
|
2
|
+
import { createExtendedL1Client, getPublicClient } from '@aztec/ethereum/client';
|
|
3
|
+
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
|
|
4
|
+
import { GSEContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
5
|
+
import { createL1TxUtilsFromViemWallet } from '@aztec/ethereum/l1-tx-utils';
|
|
11
6
|
import { EthCheatCodes } from '@aztec/ethereum/test';
|
|
12
7
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
13
8
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
@@ -299,9 +294,9 @@ export async function debugRollup({ rpcUrls, chainId, rollupAddress, log }: Roll
|
|
|
299
294
|
const publicClient = getPublicClient({ l1RpcUrls: rpcUrls, l1ChainId: chainId });
|
|
300
295
|
const rollup = new RollupContract(publicClient, rollupAddress);
|
|
301
296
|
|
|
302
|
-
const pendingNum = await rollup.
|
|
297
|
+
const pendingNum = await rollup.getCheckpointNumber();
|
|
303
298
|
log(`Pending block num: ${pendingNum}`);
|
|
304
|
-
const provenNum = await rollup.
|
|
299
|
+
const provenNum = await rollup.getProvenCheckpointNumber();
|
|
305
300
|
log(`Proven block num: ${provenNum}`);
|
|
306
301
|
const validators = await rollup.getAttesters();
|
|
307
302
|
log(`Validators: ${validators.map(v => v.toString()).join(', ')}`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { computeSecretHash } from '@aztec/aztec.js/crypto';
|
|
2
|
-
import { Fr } from '@aztec/foundation/
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import type { LogFn } from '@aztec/foundation/log';
|
|
4
4
|
|
|
5
5
|
export async function generateSecretAndHash(log: LogFn) {
|
|
@@ -9,7 +9,7 @@ import { type SemVer, parse } from 'semver';
|
|
|
9
9
|
import type { DependencyChanges } from './common.js';
|
|
10
10
|
import { atomicUpdateFile } from './utils.js';
|
|
11
11
|
|
|
12
|
-
const deprecatedNpmPackages = new Set<string>(['@aztec/cli', '@aztec/aztec-
|
|
12
|
+
const deprecatedNpmPackages = new Set<string>(['@aztec/cli', '@aztec/aztec-local-network']);
|
|
13
13
|
const npmDeprecationMessage = `
|
|
14
14
|
The following packages have been deprecated and will no longer be updated on the npm registry:
|
|
15
15
|
${Array.from(deprecatedNpmPackages)
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
+
import { loadKeystoreFile } from '@aztec/node-keystore/loader';
|
|
4
|
+
import type { KeyStore } from '@aztec/node-keystore/types';
|
|
5
|
+
|
|
6
|
+
import { wordlist } from '@scure/bip39/wordlists/english.js';
|
|
7
|
+
import { dirname, isAbsolute, join } from 'path';
|
|
8
|
+
import { generateMnemonic } from 'viem/accounts';
|
|
9
|
+
|
|
10
|
+
import type { NewValidatorKeystoreOptions } from './new.js';
|
|
11
|
+
import {
|
|
12
|
+
buildValidatorEntries,
|
|
13
|
+
logValidatorSummaries,
|
|
14
|
+
maybePrintJson,
|
|
15
|
+
writeBlsBn254ToFile,
|
|
16
|
+
writeEthJsonV3ToFile,
|
|
17
|
+
writeKeystoreFile,
|
|
18
|
+
} from './shared.js';
|
|
19
|
+
import { validateBlsPathOptions, validatePublisherOptions, validateRemoteSignerOptions } from './utils.js';
|
|
20
|
+
|
|
21
|
+
export type AddValidatorKeysOptions = NewValidatorKeystoreOptions;
|
|
22
|
+
|
|
23
|
+
export async function addValidatorKeys(existing: string, options: AddValidatorKeysOptions, log: LogFn) {
|
|
24
|
+
// validate bls-path inputs before proceeding with key generation
|
|
25
|
+
validateBlsPathOptions(options);
|
|
26
|
+
// validate publisher options
|
|
27
|
+
validatePublisherOptions(options);
|
|
28
|
+
// validate remote signer options
|
|
29
|
+
validateRemoteSignerOptions(options);
|
|
30
|
+
|
|
31
|
+
const {
|
|
32
|
+
dataDir,
|
|
33
|
+
file,
|
|
34
|
+
count,
|
|
35
|
+
publisherCount = 0,
|
|
36
|
+
publishers,
|
|
37
|
+
mnemonic,
|
|
38
|
+
accountIndex = 0,
|
|
39
|
+
addressIndex,
|
|
40
|
+
ikm,
|
|
41
|
+
blsPath,
|
|
42
|
+
json,
|
|
43
|
+
feeRecipient: feeRecipientOpt,
|
|
44
|
+
coinbase: coinbaseOpt,
|
|
45
|
+
remoteSigner: remoteSignerOpt,
|
|
46
|
+
password,
|
|
47
|
+
encryptedKeystoreDir,
|
|
48
|
+
} = options;
|
|
49
|
+
|
|
50
|
+
const validatorCount = typeof count === 'number' && Number.isFinite(count) && count > 0 ? Math.floor(count) : 1;
|
|
51
|
+
const baseAddressIndex = addressIndex ?? 0;
|
|
52
|
+
|
|
53
|
+
const keystore: KeyStore = loadKeystoreFile(existing);
|
|
54
|
+
|
|
55
|
+
if (!keystore.validators || !Array.isArray(keystore.validators)) {
|
|
56
|
+
throw new Error('Invalid keystore: missing validators array');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const first = keystore.validators[0] ?? {};
|
|
60
|
+
const feeRecipient = feeRecipientOpt ?? first.feeRecipient;
|
|
61
|
+
if (!feeRecipient) {
|
|
62
|
+
throw new Error('feeRecipient is required (either present in existing file or via --fee-recipient)');
|
|
63
|
+
}
|
|
64
|
+
const coinbase = (coinbaseOpt as EthAddress | undefined) ?? (first.coinbase as EthAddress | undefined);
|
|
65
|
+
const derivedRemoteSigner = (first.attester as any)?.remoteSignerUrl || (first.attester as any)?.eth?.remoteSignerUrl;
|
|
66
|
+
const remoteSigner = remoteSignerOpt ?? derivedRemoteSigner;
|
|
67
|
+
|
|
68
|
+
// Ensure we always have a mnemonic for key derivation if none was provided
|
|
69
|
+
const mnemonicToUse = mnemonic ?? generateMnemonic(wordlist);
|
|
70
|
+
|
|
71
|
+
// If user explicitly provided --address-index, use it as-is. Otherwise, append after existing validators.
|
|
72
|
+
const effectiveBaseAddressIndex =
|
|
73
|
+
addressIndex === undefined ? baseAddressIndex + keystore.validators.length : baseAddressIndex;
|
|
74
|
+
|
|
75
|
+
const { validators, summaries } = await buildValidatorEntries({
|
|
76
|
+
validatorCount,
|
|
77
|
+
publisherCount,
|
|
78
|
+
publishers,
|
|
79
|
+
accountIndex,
|
|
80
|
+
baseAddressIndex: effectiveBaseAddressIndex,
|
|
81
|
+
mnemonic: mnemonicToUse,
|
|
82
|
+
ikm,
|
|
83
|
+
blsPath,
|
|
84
|
+
feeRecipient,
|
|
85
|
+
coinbase,
|
|
86
|
+
remoteSigner,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
keystore.validators.push(...validators);
|
|
90
|
+
|
|
91
|
+
// If password provided, write ETH JSON V3 and BLS BN254 keystores and replace plaintext
|
|
92
|
+
if (password !== undefined) {
|
|
93
|
+
let targetDir: string;
|
|
94
|
+
if (encryptedKeystoreDir && encryptedKeystoreDir.length > 0) {
|
|
95
|
+
targetDir = encryptedKeystoreDir;
|
|
96
|
+
} else if (dataDir && dataDir.length > 0) {
|
|
97
|
+
targetDir = dataDir;
|
|
98
|
+
} else {
|
|
99
|
+
targetDir = dirname(existing);
|
|
100
|
+
}
|
|
101
|
+
await writeEthJsonV3ToFile(keystore.validators, { outDir: targetDir, password });
|
|
102
|
+
await writeBlsBn254ToFile(keystore.validators, { outDir: targetDir, password, blsPath });
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
let outputPath = existing;
|
|
106
|
+
if (file && file.length > 0) {
|
|
107
|
+
if (isAbsolute(file)) {
|
|
108
|
+
outputPath = file;
|
|
109
|
+
} else if (dataDir && dataDir.length > 0) {
|
|
110
|
+
outputPath = join(dataDir, file);
|
|
111
|
+
} else {
|
|
112
|
+
outputPath = join(dirname(existing), file);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
await writeKeystoreFile(outputPath, keystore);
|
|
117
|
+
|
|
118
|
+
if (!json) {
|
|
119
|
+
log(`Updated keystore ${outputPath} with ${validators.length} new validator(s)`);
|
|
120
|
+
logValidatorSummaries(log, summaries);
|
|
121
|
+
}
|
|
122
|
+
maybePrintJson(log, !!json, keystore as unknown as Record<string, any>);
|
|
123
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { deriveBlsPrivateKey } from '@aztec/foundation/crypto/bls';
|
|
2
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
+
|
|
4
|
+
import { writeFile } from 'fs/promises';
|
|
5
|
+
|
|
6
|
+
import { computeBlsPublicKeyCompressed, withValidatorIndex } from './shared.js';
|
|
7
|
+
import { defaultBlsPath } from './utils.js';
|
|
8
|
+
|
|
9
|
+
export type GenerateBlsKeypairOptions = {
|
|
10
|
+
mnemonic?: string;
|
|
11
|
+
ikm?: string;
|
|
12
|
+
blsPath?: string;
|
|
13
|
+
g2?: boolean;
|
|
14
|
+
compressed?: boolean;
|
|
15
|
+
json?: boolean;
|
|
16
|
+
out?: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export async function generateBlsKeypair(options: GenerateBlsKeypairOptions, log: LogFn) {
|
|
20
|
+
const { mnemonic, ikm, blsPath, compressed = true, json, out } = options;
|
|
21
|
+
const path = withValidatorIndex(blsPath ?? defaultBlsPath, 0);
|
|
22
|
+
const priv = deriveBlsPrivateKey(mnemonic, ikm, path);
|
|
23
|
+
const pub = await computeBlsPublicKeyCompressed(priv);
|
|
24
|
+
const result = { path, privateKey: priv, publicKey: pub, format: compressed ? 'compressed' : 'uncompressed' };
|
|
25
|
+
if (out) {
|
|
26
|
+
await writeFile(out, JSON.stringify(result, null, 2), { encoding: 'utf-8' });
|
|
27
|
+
if (!json) {
|
|
28
|
+
log(`Wrote BLS keypair to ${out}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (json || !out) {
|
|
32
|
+
log(JSON.stringify(result, null, 2));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
2
|
+
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
|
|
5
|
+
import { parseAztecAddress, parseEthereumAddress, parseHex, parseOptionalInteger } from '../../utils/commands.js';
|
|
6
|
+
import { defaultBlsPath } from './utils.js';
|
|
7
|
+
|
|
8
|
+
export function injectCommands(program: Command, log: LogFn) {
|
|
9
|
+
const group = program
|
|
10
|
+
.command('validator-keys')
|
|
11
|
+
.aliases(['valKeys', 'valkeys'])
|
|
12
|
+
.description('Manage validator keystores for node operators');
|
|
13
|
+
|
|
14
|
+
group
|
|
15
|
+
.command('new')
|
|
16
|
+
.summary('Generate a new validator keystore JSON')
|
|
17
|
+
.description('Generates a new validator keystore with ETH secp256k1 accounts and optional BLS accounts')
|
|
18
|
+
.option('--data-dir <path>', 'Directory to store keystore(s). Defaults to ~/.aztec/keystore')
|
|
19
|
+
.option('--file <name>', 'Keystore file name. Defaults to key1.json (or keyN.json if key1.json exists)')
|
|
20
|
+
.option('--count <N>', 'Number of validators to generate', parseOptionalInteger)
|
|
21
|
+
.option('--publisher-count <N>', 'Number of publisher accounts per validator (default 0)', value =>
|
|
22
|
+
parseOptionalInteger(value, 0),
|
|
23
|
+
)
|
|
24
|
+
.option('--publishers <privateKeys>', 'Comma-separated list of publisher private keys for all validators.', value =>
|
|
25
|
+
value.split(',').map((key: string) => key.trim()),
|
|
26
|
+
)
|
|
27
|
+
.option('--mnemonic <mnemonic>', 'Mnemonic for ETH/BLS derivation')
|
|
28
|
+
.option('--passphrase <str>', 'Optional passphrase for mnemonic')
|
|
29
|
+
.option('--account-index <N>', 'Base account index for ETH/BLS derivation', parseOptionalInteger)
|
|
30
|
+
.option('--address-index <N>', 'Base address index for ETH/BLS derivation', parseOptionalInteger)
|
|
31
|
+
.option(
|
|
32
|
+
'--coinbase <address>',
|
|
33
|
+
'Coinbase ETH address to use when proposing. Defaults to attester address.',
|
|
34
|
+
parseEthereumAddress,
|
|
35
|
+
)
|
|
36
|
+
// TODO: add funding account back in when implemented
|
|
37
|
+
// .option('--funding-account <privateKey|address>', 'ETH private key (or address for remote signer setup) to fund publishers')
|
|
38
|
+
.option('--remote-signer <url>', 'Default remote signer URL for accounts in this file')
|
|
39
|
+
.option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', value => parseHex(value, 32))
|
|
40
|
+
.option('--bls-path <path>', `EIP-2334 path (default ${defaultBlsPath})`)
|
|
41
|
+
.option(
|
|
42
|
+
'--password <str>',
|
|
43
|
+
'Password for writing keystore files (ETH JSON V3 and BLS EIP-2335). Empty string allowed',
|
|
44
|
+
)
|
|
45
|
+
.option('--encrypted-keystore-dir <dir>', 'Output directory for encrypted keystore file(s)')
|
|
46
|
+
.option('--json', 'Echo resulting JSON to stdout')
|
|
47
|
+
.option('--staker-output', 'Generate a single staker output JSON file with an array of validator entries')
|
|
48
|
+
.option('--gse-address <address>', 'GSE contract address (required with --staker-output)', parseEthereumAddress)
|
|
49
|
+
.option('--l1-rpc-urls <urls>', 'L1 RPC URLs (comma-separated, required with --staker-output)', value =>
|
|
50
|
+
value.split(','),
|
|
51
|
+
)
|
|
52
|
+
.option(
|
|
53
|
+
'-c, --l1-chain-id <number>',
|
|
54
|
+
'L1 chain ID (required with --staker-output)',
|
|
55
|
+
value => parseInt(value),
|
|
56
|
+
31337,
|
|
57
|
+
)
|
|
58
|
+
.requiredOption('--fee-recipient <address>', 'Aztec address that will receive fees', parseAztecAddress)
|
|
59
|
+
.action(async options => {
|
|
60
|
+
const { newValidatorKeystore } = await import('./new.js');
|
|
61
|
+
|
|
62
|
+
await newValidatorKeystore(options, log);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
group
|
|
66
|
+
.command('add')
|
|
67
|
+
.summary('Augment an existing validator keystore JSON')
|
|
68
|
+
.description('Adds attester/publisher/BLS entries to an existing keystore using the same flags as new')
|
|
69
|
+
.argument('<existing>', 'Path to existing keystore JSON')
|
|
70
|
+
.option('--data-dir <path>', 'Directory where keystore(s) live. (default: ~/.aztec/keystore)')
|
|
71
|
+
.option('--file <name>', 'Override output file name. (default: key<N>.json)')
|
|
72
|
+
.option('--count <N>', 'Number of validators to add. (default: 1)', parseOptionalInteger)
|
|
73
|
+
.option('--publisher-count <N>', 'Number of publisher accounts per validator (default 0)', value =>
|
|
74
|
+
parseOptionalInteger(value, 0),
|
|
75
|
+
)
|
|
76
|
+
.option('--publishers <privateKeys>', 'Comma-separated list of publisher private keys for all validators.', value =>
|
|
77
|
+
value.split(',').map((key: string) => key.trim()),
|
|
78
|
+
)
|
|
79
|
+
.option('--mnemonic <mnemonic>', 'Mnemonic for ETH/BLS derivation')
|
|
80
|
+
.option('--passphrase <str>', 'Optional passphrase for mnemonic')
|
|
81
|
+
.option('--account-index <N>', 'Base account index for ETH/BLS derivation', parseOptionalInteger)
|
|
82
|
+
.option('--address-index <N>', 'Base address index for ETH/BLS derivation', parseOptionalInteger)
|
|
83
|
+
.option(
|
|
84
|
+
'--coinbase <address>',
|
|
85
|
+
'Coinbase ETH address to use when proposing. Defaults to attester address.',
|
|
86
|
+
parseEthereumAddress,
|
|
87
|
+
)
|
|
88
|
+
// TODO: add funding account back in when implemented
|
|
89
|
+
// .option('--funding-account <privateKey|address>', 'ETH private key (or address for remote signer setup) to fund publishers')
|
|
90
|
+
.option('--remote-signer <url>', 'Default remote signer URL for accounts in this file')
|
|
91
|
+
.option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', value => parseHex(value, 32))
|
|
92
|
+
.option('--bls-path <path>', `EIP-2334 path (default ${defaultBlsPath})`)
|
|
93
|
+
.option('--empty', 'Generate an empty skeleton without keys')
|
|
94
|
+
.option(
|
|
95
|
+
'--password <str>',
|
|
96
|
+
'Password for writing keystore files (ETH JSON V3 and BLS EIP-2335). Empty string allowed',
|
|
97
|
+
)
|
|
98
|
+
.option('--encrypted-keystore-dir <dir>', 'Output directory for encrypted keystore file(s)')
|
|
99
|
+
.option('--json', 'Echo resulting JSON to stdout')
|
|
100
|
+
.requiredOption('--fee-recipient <address>', 'Aztec address that will receive fees', parseAztecAddress)
|
|
101
|
+
.action(async (existing: string, options) => {
|
|
102
|
+
const { addValidatorKeys } = await import('./add.js');
|
|
103
|
+
await addValidatorKeys(existing, options, log);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
group
|
|
107
|
+
.command('staker')
|
|
108
|
+
.summary('Generate staking JSON from keystore')
|
|
109
|
+
.description(
|
|
110
|
+
'Reads a validator keystore and outputs staking data with BLS public keys for each attester (skips mnemonics)',
|
|
111
|
+
)
|
|
112
|
+
.requiredOption('--from <keystore>', 'Path to keystore JSON file')
|
|
113
|
+
.option('--password <password>', 'Password for decrypting encrypted keystores (if not specified in keystore file)')
|
|
114
|
+
.requiredOption('--gse-address <address>', 'GSE contract address', parseEthereumAddress)
|
|
115
|
+
.option('--l1-rpc-urls <urls>', 'L1 RPC URLs (comma-separated)', value => value.split(','), [
|
|
116
|
+
'http://localhost:8545',
|
|
117
|
+
])
|
|
118
|
+
.option('-c, --l1-chain-id <number>', 'L1 chain ID', value => parseInt(value), 31337)
|
|
119
|
+
.option('--output <file>', 'Output file path (if not specified, JSON is written to stdout)')
|
|
120
|
+
.action(async options => {
|
|
121
|
+
const { generateStakerJson } = await import('./staker.js');
|
|
122
|
+
await generateStakerJson(options, log);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// top-level convenience: aztec generate-bls-keypair
|
|
126
|
+
program
|
|
127
|
+
.command('generate-bls-keypair')
|
|
128
|
+
.description('Generate a BLS keypair with convenience flags')
|
|
129
|
+
.option('--mnemonic <mnemonic>', 'Mnemonic for BLS derivation')
|
|
130
|
+
.option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', value => parseHex(value, 32))
|
|
131
|
+
.option('--bls-path <path>', `EIP-2334 path (default ${defaultBlsPath})`)
|
|
132
|
+
.option('--g2', 'Derive on G2 subgroup')
|
|
133
|
+
.option('--compressed', 'Output compressed public key')
|
|
134
|
+
.option('--json', 'Print JSON output to stdout')
|
|
135
|
+
.option('--out <file>', 'Write output to file')
|
|
136
|
+
.action(async options => {
|
|
137
|
+
const { generateBlsKeypair } = await import('./generate_bls_keypair.js');
|
|
138
|
+
await generateBlsKeypair(options, log);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
return program;
|
|
142
|
+
}
|