@aztec/cli 2.1.0-rc.24 → 2.1.0-rc.28
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/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 +70 -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 +26 -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 +20 -0
- package/dest/cmds/validator_keys/new.d.ts +26 -0
- package/dest/cmds/validator_keys/new.d.ts.map +1 -0
- package/dest/cmds/validator_keys/new.js +60 -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 +271 -0
- package/dest/config/chain_l2_config.d.ts.map +1 -1
- package/dest/config/chain_l2_config.js +56 -34
- package/dest/utils/commands.d.ts +10 -1
- package/dest/utils/commands.d.ts.map +1 -1
- package/dest/utils/commands.js +30 -3
- package/package.json +27 -23
- package/src/cmds/validator_keys/add.ts +113 -0
- package/src/cmds/validator_keys/generate_bls_keypair.ts +33 -0
- package/src/cmds/validator_keys/index.ts +96 -0
- package/src/cmds/validator_keys/new.ts +120 -0
- package/src/cmds/validator_keys/shared.ts +321 -0
- package/src/config/chain_l2_config.ts +77 -46
- package/src/utils/commands.ts +41 -3
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
|
|
5
|
+
import { wordlist } from '@scure/bip39/wordlists/english.js';
|
|
6
|
+
import { dirname } from 'path';
|
|
7
|
+
import { generateMnemonic, mnemonicToAccount } from 'viem/accounts';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
buildValidatorEntries,
|
|
11
|
+
logValidatorSummaries,
|
|
12
|
+
maybePrintJson,
|
|
13
|
+
resolveKeystoreOutputPath,
|
|
14
|
+
writeBlsBn254ToFile,
|
|
15
|
+
writeEthJsonV3ToFile,
|
|
16
|
+
writeKeystoreFile,
|
|
17
|
+
} from './shared.js';
|
|
18
|
+
|
|
19
|
+
export type NewValidatorKeystoreOptions = {
|
|
20
|
+
dataDir?: string;
|
|
21
|
+
file?: string;
|
|
22
|
+
count?: number;
|
|
23
|
+
publisherCount?: number;
|
|
24
|
+
mnemonic?: string;
|
|
25
|
+
passphrase?: string;
|
|
26
|
+
accountIndex?: number;
|
|
27
|
+
addressIndex?: number;
|
|
28
|
+
separatePublisher?: boolean;
|
|
29
|
+
ikm?: string;
|
|
30
|
+
blsPath?: string;
|
|
31
|
+
blsOnly?: boolean;
|
|
32
|
+
password?: string;
|
|
33
|
+
outDir?: string;
|
|
34
|
+
json?: boolean;
|
|
35
|
+
feeRecipient: AztecAddress;
|
|
36
|
+
coinbase?: EthAddress;
|
|
37
|
+
remoteSigner?: string;
|
|
38
|
+
fundingAccount?: EthAddress;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export async function newValidatorKeystore(options: NewValidatorKeystoreOptions, log: LogFn) {
|
|
42
|
+
const {
|
|
43
|
+
dataDir,
|
|
44
|
+
file,
|
|
45
|
+
count,
|
|
46
|
+
publisherCount = 0,
|
|
47
|
+
json,
|
|
48
|
+
coinbase,
|
|
49
|
+
accountIndex = 0,
|
|
50
|
+
addressIndex = 0,
|
|
51
|
+
feeRecipient,
|
|
52
|
+
remoteSigner,
|
|
53
|
+
fundingAccount,
|
|
54
|
+
blsOnly,
|
|
55
|
+
blsPath,
|
|
56
|
+
ikm,
|
|
57
|
+
mnemonic: _mnemonic,
|
|
58
|
+
password,
|
|
59
|
+
outDir,
|
|
60
|
+
} = options;
|
|
61
|
+
|
|
62
|
+
if (remoteSigner && !_mnemonic) {
|
|
63
|
+
throw new Error(
|
|
64
|
+
'Using --remote-signer requires a deterministic key source. Provide --mnemonic to derive keys, or omit --remote-signer to write new private keys to keystore.',
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const mnemonic = _mnemonic ?? generateMnemonic(wordlist);
|
|
69
|
+
|
|
70
|
+
const validatorCount = typeof count === 'number' && Number.isFinite(count) && count > 0 ? Math.floor(count) : 1;
|
|
71
|
+
const { outputPath } = await resolveKeystoreOutputPath(dataDir, file);
|
|
72
|
+
|
|
73
|
+
const { validators, summaries } = await buildValidatorEntries({
|
|
74
|
+
validatorCount,
|
|
75
|
+
publisherCount,
|
|
76
|
+
accountIndex,
|
|
77
|
+
baseAddressIndex: addressIndex,
|
|
78
|
+
mnemonic,
|
|
79
|
+
ikm,
|
|
80
|
+
blsPath,
|
|
81
|
+
blsOnly,
|
|
82
|
+
feeRecipient,
|
|
83
|
+
coinbase,
|
|
84
|
+
remoteSigner,
|
|
85
|
+
fundingAccount,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// If password provided, write ETH JSON V3 and BLS BN254 keystores and replace plaintext
|
|
89
|
+
if (password !== undefined) {
|
|
90
|
+
const keystoreOutDir = outDir && outDir.length > 0 ? outDir : dirname(outputPath);
|
|
91
|
+
await writeEthJsonV3ToFile(validators, { outDir: keystoreOutDir, password });
|
|
92
|
+
await writeBlsBn254ToFile(validators, { outDir: keystoreOutDir, password });
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const keystore = {
|
|
96
|
+
schemaVersion: 1,
|
|
97
|
+
validators,
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
await writeKeystoreFile(outputPath, keystore);
|
|
101
|
+
|
|
102
|
+
maybePrintJson(log, json, keystore as unknown as Record<string, any>);
|
|
103
|
+
if (!json) {
|
|
104
|
+
log(`Wrote validator keystore to ${outputPath}`);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Always print a concise summary of public keys (addresses and BLS pubkeys)
|
|
108
|
+
logValidatorSummaries(log, summaries);
|
|
109
|
+
|
|
110
|
+
if (!blsOnly && mnemonic && remoteSigner) {
|
|
111
|
+
for (let i = 0; i < validatorCount; i++) {
|
|
112
|
+
const addrIdx = addressIndex + i;
|
|
113
|
+
const acct = mnemonicToAccount(mnemonic, {
|
|
114
|
+
accountIndex,
|
|
115
|
+
addressIndex: addrIdx,
|
|
116
|
+
});
|
|
117
|
+
log(`attester address: ${acct.address} remoteSignerUrl: ${remoteSigner}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { prettyPrintJSON } from '@aztec/cli/utils';
|
|
2
|
+
import { computeBn254G1PublicKeyCompressed, deriveBlsPrivateKey } from '@aztec/foundation/crypto';
|
|
3
|
+
import { createBn254Keystore } from '@aztec/foundation/crypto/bls/bn254_keystore';
|
|
4
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
5
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
6
|
+
import type { EthAccount, EthPrivateKey, ValidatorKeyStore } from '@aztec/node-keystore/types';
|
|
7
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
|
+
|
|
9
|
+
import { Wallet } from '@ethersproject/wallet';
|
|
10
|
+
import { constants as fsConstants, mkdirSync } from 'fs';
|
|
11
|
+
import { access, writeFile } from 'fs/promises';
|
|
12
|
+
import { homedir } from 'os';
|
|
13
|
+
import { dirname, isAbsolute, join } from 'path';
|
|
14
|
+
import { mnemonicToAccount } from 'viem/accounts';
|
|
15
|
+
|
|
16
|
+
export type ValidatorSummary = { attesterEth?: string; attesterBls?: string; publisherEth?: string[] };
|
|
17
|
+
|
|
18
|
+
export type BuildValidatorsInput = {
|
|
19
|
+
validatorCount: number;
|
|
20
|
+
publisherCount?: number;
|
|
21
|
+
accountIndex: number;
|
|
22
|
+
baseAddressIndex: number;
|
|
23
|
+
mnemonic: string;
|
|
24
|
+
ikm?: string;
|
|
25
|
+
blsPath?: string;
|
|
26
|
+
blsOnly?: boolean;
|
|
27
|
+
feeRecipient: AztecAddress;
|
|
28
|
+
coinbase?: EthAddress;
|
|
29
|
+
remoteSigner?: string;
|
|
30
|
+
fundingAccount?: EthAddress;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export function withValidatorIndex(path: string, index: number) {
|
|
34
|
+
const parts = path.split('/');
|
|
35
|
+
if (parts.length >= 4 && parts[0] === 'm' && parts[1] === '12381' && parts[2] === '3600') {
|
|
36
|
+
parts[3] = String(index);
|
|
37
|
+
return parts.join('/');
|
|
38
|
+
}
|
|
39
|
+
return path;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Compute a compressed BN254 G1 public key from a private key.
|
|
44
|
+
* @param privateKeyHex - Private key as 0x-prefixed hex string
|
|
45
|
+
* @returns Compressed G1 point (32 bytes with sign bit in MSB)
|
|
46
|
+
*/
|
|
47
|
+
export async function computeBlsPublicKeyCompressed(privateKeyHex: string): Promise<string> {
|
|
48
|
+
return await computeBn254G1PublicKeyCompressed(privateKeyHex);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function deriveEthAttester(
|
|
52
|
+
mnemonic: string,
|
|
53
|
+
baseAccountIndex: number,
|
|
54
|
+
addressIndex: number,
|
|
55
|
+
remoteSigner?: string,
|
|
56
|
+
): EthAccount | EthPrivateKey {
|
|
57
|
+
const acct = mnemonicToAccount(mnemonic, { accountIndex: baseAccountIndex, addressIndex });
|
|
58
|
+
return remoteSigner
|
|
59
|
+
? ({ address: acct.address as unknown as EthAddress, remoteSignerUrl: remoteSigner } as EthAccount)
|
|
60
|
+
: (('0x' + Buffer.from(acct.getHdKey().privateKey!).toString('hex')) as EthPrivateKey);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export async function buildValidatorEntries(input: BuildValidatorsInput) {
|
|
64
|
+
const {
|
|
65
|
+
validatorCount,
|
|
66
|
+
publisherCount = 0,
|
|
67
|
+
accountIndex,
|
|
68
|
+
baseAddressIndex,
|
|
69
|
+
mnemonic,
|
|
70
|
+
ikm,
|
|
71
|
+
blsPath,
|
|
72
|
+
blsOnly,
|
|
73
|
+
feeRecipient,
|
|
74
|
+
coinbase,
|
|
75
|
+
remoteSigner,
|
|
76
|
+
fundingAccount,
|
|
77
|
+
} = input;
|
|
78
|
+
|
|
79
|
+
const defaultBlsPath = 'm/12381/3600/0/0/0';
|
|
80
|
+
const summaries: ValidatorSummary[] = [];
|
|
81
|
+
|
|
82
|
+
const validators = await Promise.all(
|
|
83
|
+
Array.from({ length: validatorCount }, async (_unused, i) => {
|
|
84
|
+
const addressIndex = baseAddressIndex + i;
|
|
85
|
+
const basePath = blsPath ?? defaultBlsPath;
|
|
86
|
+
const perValidatorPath = withValidatorIndex(basePath, addressIndex);
|
|
87
|
+
|
|
88
|
+
const blsPrivKey = blsOnly || ikm || mnemonic ? deriveBlsPrivateKey(mnemonic, ikm, perValidatorPath) : undefined;
|
|
89
|
+
const blsPubCompressed = blsPrivKey ? await computeBlsPublicKeyCompressed(blsPrivKey) : undefined;
|
|
90
|
+
|
|
91
|
+
if (blsOnly) {
|
|
92
|
+
const attester = { bls: blsPrivKey! };
|
|
93
|
+
summaries.push({ attesterBls: blsPubCompressed });
|
|
94
|
+
return { attester, feeRecipient } as ValidatorKeyStore;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const ethAttester = deriveEthAttester(mnemonic, accountIndex, addressIndex, remoteSigner);
|
|
98
|
+
const attester = blsPrivKey ? { eth: ethAttester, bls: blsPrivKey } : ethAttester;
|
|
99
|
+
|
|
100
|
+
let publisherField: EthAccount | EthPrivateKey | (EthAccount | EthPrivateKey)[] | undefined;
|
|
101
|
+
const publisherAddresses: string[] = [];
|
|
102
|
+
if (publisherCount > 0) {
|
|
103
|
+
const publishersBaseIndex = baseAddressIndex + validatorCount + i * publisherCount;
|
|
104
|
+
const publisherAccounts = Array.from({ length: publisherCount }, (_unused2, j) => {
|
|
105
|
+
const publisherAddressIndex = publishersBaseIndex + j;
|
|
106
|
+
const pubAcct = mnemonicToAccount(mnemonic, {
|
|
107
|
+
accountIndex,
|
|
108
|
+
addressIndex: publisherAddressIndex,
|
|
109
|
+
});
|
|
110
|
+
publisherAddresses.push(pubAcct.address as unknown as string);
|
|
111
|
+
return remoteSigner
|
|
112
|
+
? ({ address: pubAcct.address as unknown as EthAddress, remoteSignerUrl: remoteSigner } as EthAccount)
|
|
113
|
+
: (('0x' + Buffer.from(pubAcct.getHdKey().privateKey!).toString('hex')) as EthPrivateKey);
|
|
114
|
+
});
|
|
115
|
+
publisherField = publisherCount === 1 ? publisherAccounts[0] : publisherAccounts;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const acct = mnemonicToAccount(mnemonic, {
|
|
119
|
+
accountIndex,
|
|
120
|
+
addressIndex,
|
|
121
|
+
});
|
|
122
|
+
const attesterEthAddress = acct.address as unknown as string;
|
|
123
|
+
summaries.push({
|
|
124
|
+
attesterEth: attesterEthAddress,
|
|
125
|
+
attesterBls: blsPubCompressed,
|
|
126
|
+
publisherEth: publisherAddresses.length > 0 ? publisherAddresses : undefined,
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
attester,
|
|
131
|
+
...(publisherField !== undefined ? { publisher: publisherField } : {}),
|
|
132
|
+
feeRecipient,
|
|
133
|
+
coinbase,
|
|
134
|
+
fundingAccount,
|
|
135
|
+
} as ValidatorKeyStore;
|
|
136
|
+
}),
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
return { validators, summaries };
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export async function resolveKeystoreOutputPath(dataDir?: string, file?: string) {
|
|
143
|
+
const defaultDataDir = join(homedir(), '.aztec', 'keystore');
|
|
144
|
+
const resolvedDir = dataDir && dataDir.length > 0 ? dataDir : defaultDataDir;
|
|
145
|
+
let outputPath: string;
|
|
146
|
+
if (file && file.length > 0) {
|
|
147
|
+
outputPath = isAbsolute(file) ? file : join(resolvedDir, file);
|
|
148
|
+
} else {
|
|
149
|
+
let index = 1;
|
|
150
|
+
while (true) {
|
|
151
|
+
const candidate = join(resolvedDir, `key${index}.json`);
|
|
152
|
+
try {
|
|
153
|
+
await access(candidate, fsConstants.F_OK);
|
|
154
|
+
index += 1;
|
|
155
|
+
} catch {
|
|
156
|
+
outputPath = candidate;
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return { resolvedDir, outputPath: outputPath! };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export async function writeKeystoreFile(path: string, keystore: unknown) {
|
|
165
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
166
|
+
await writeFile(path, JSON.stringify(keystore, null, 2), { encoding: 'utf-8' });
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export function logValidatorSummaries(log: LogFn, summaries: ValidatorSummary[]) {
|
|
170
|
+
const lines: string[] = [];
|
|
171
|
+
for (let i = 0; i < summaries.length; i++) {
|
|
172
|
+
const v = summaries[i];
|
|
173
|
+
lines.push(`acc${i + 1}:`);
|
|
174
|
+
lines.push(` attester:`);
|
|
175
|
+
if (v.attesterEth) {
|
|
176
|
+
lines.push(` eth: ${v.attesterEth}`);
|
|
177
|
+
}
|
|
178
|
+
if (v.attesterBls) {
|
|
179
|
+
lines.push(` bls: ${v.attesterBls}`);
|
|
180
|
+
}
|
|
181
|
+
if (v.publisherEth && v.publisherEth.length > 0) {
|
|
182
|
+
lines.push(` publisher:`);
|
|
183
|
+
for (const addr of v.publisherEth) {
|
|
184
|
+
lines.push(` - ${addr}`);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (lines.length > 0) {
|
|
189
|
+
log(lines.join('\n'));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export function maybePrintJson(log: LogFn, jsonFlag: boolean | undefined, obj: unknown) {
|
|
194
|
+
if (jsonFlag) {
|
|
195
|
+
log(prettyPrintJSON(obj as Record<string, any>));
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Writes a BN254 keystore file for a BN254 BLS private key.
|
|
201
|
+
* Returns the absolute path to the written file.
|
|
202
|
+
*
|
|
203
|
+
* @param outDir - Directory to write the keystore file to
|
|
204
|
+
* @param fileNameBase - Base name for the keystore file (will be sanitized)
|
|
205
|
+
* @param password - Password for encrypting the private key
|
|
206
|
+
* @param privateKeyHex - Private key as 0x-prefixed hex string (32 bytes)
|
|
207
|
+
* @param pubkeyHex - Public key as hex string
|
|
208
|
+
* @param derivationPath - BIP-44 style derivation path
|
|
209
|
+
* @returns Absolute path to the written keystore file
|
|
210
|
+
*/
|
|
211
|
+
export async function writeBn254BlsKeystore(
|
|
212
|
+
outDir: string,
|
|
213
|
+
fileNameBase: string,
|
|
214
|
+
password: string,
|
|
215
|
+
privateKeyHex: string,
|
|
216
|
+
pubkeyHex: string,
|
|
217
|
+
derivationPath: string,
|
|
218
|
+
): Promise<string> {
|
|
219
|
+
mkdirSync(outDir, { recursive: true });
|
|
220
|
+
|
|
221
|
+
const keystore = createBn254Keystore(password, privateKeyHex, pubkeyHex, derivationPath);
|
|
222
|
+
|
|
223
|
+
const safeBase = fileNameBase.replace(/[^a-zA-Z0-9_-]/g, '_');
|
|
224
|
+
const outPath = join(outDir, `keystore-${safeBase}.json`);
|
|
225
|
+
await writeFile(outPath, JSON.stringify(keystore, null, 2), { encoding: 'utf-8' });
|
|
226
|
+
return outPath;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** Replace plaintext BLS keys in validators with { path, password } pointing to BN254 keystore files. */
|
|
230
|
+
export async function writeBlsBn254ToFile(
|
|
231
|
+
validators: ValidatorKeyStore[],
|
|
232
|
+
options: { outDir: string; password: string },
|
|
233
|
+
): Promise<void> {
|
|
234
|
+
for (let i = 0; i < validators.length; i++) {
|
|
235
|
+
const v = validators[i];
|
|
236
|
+
if (!v || typeof v !== 'object' || !('attester' in v)) {
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
const att = (v as any).attester;
|
|
240
|
+
|
|
241
|
+
// Shapes: { bls: <hex> } or { eth: <ethAccount>, bls?: <hex> } or plain EthAccount
|
|
242
|
+
const blsKey: string | undefined = typeof att === 'object' && 'bls' in att ? (att as any).bls : undefined;
|
|
243
|
+
if (!blsKey || typeof blsKey !== 'string') {
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const pub = await computeBlsPublicKeyCompressed(blsKey);
|
|
248
|
+
const path = 'm/12381/3600/0/0/0';
|
|
249
|
+
const fileBase = `${String(i + 1)}_${pub.slice(2, 18)}`;
|
|
250
|
+
const keystorePath = await writeBn254BlsKeystore(options.outDir, fileBase, options.password, blsKey, pub, path);
|
|
251
|
+
|
|
252
|
+
if (typeof att === 'object') {
|
|
253
|
+
(att as any).bls = { path: keystorePath, password: options.password };
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/** Writes an Ethereum JSON V3 keystore using ethers, returns absolute path */
|
|
259
|
+
export async function writeEthJsonV3Keystore(
|
|
260
|
+
outDir: string,
|
|
261
|
+
fileNameBase: string,
|
|
262
|
+
password: string,
|
|
263
|
+
privateKeyHex: string,
|
|
264
|
+
): Promise<string> {
|
|
265
|
+
const safeBase = fileNameBase.replace(/[^a-zA-Z0-9_-]/g, '_');
|
|
266
|
+
mkdirSync(outDir, { recursive: true });
|
|
267
|
+
const wallet = new Wallet(privateKeyHex);
|
|
268
|
+
const json = await wallet.encrypt(password);
|
|
269
|
+
const outPath = join(outDir, `keystore-eth-${safeBase}.json`);
|
|
270
|
+
await writeFile(outPath, json, { encoding: 'utf-8' });
|
|
271
|
+
return outPath;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/** Replace plaintext ETH keys in validators with { path, password } pointing to JSON V3 files. */
|
|
275
|
+
export async function writeEthJsonV3ToFile(
|
|
276
|
+
validators: ValidatorKeyStore[],
|
|
277
|
+
options: { outDir: string; password: string },
|
|
278
|
+
): Promise<void> {
|
|
279
|
+
const maybeEncryptEth = async (account: any, label: string) => {
|
|
280
|
+
if (typeof account === 'string' && account.startsWith('0x') && account.length === 66) {
|
|
281
|
+
const fileBase = `${label}_${account.slice(2, 10)}`;
|
|
282
|
+
const p = await writeEthJsonV3Keystore(options.outDir, fileBase, options.password, account);
|
|
283
|
+
return { path: p, password: options.password };
|
|
284
|
+
}
|
|
285
|
+
return account;
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
for (let i = 0; i < validators.length; i++) {
|
|
289
|
+
const v = validators[i];
|
|
290
|
+
if (!v || typeof v !== 'object') {
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// attester may be string (eth), object with eth, or remote signer
|
|
295
|
+
const att = (v as any).attester;
|
|
296
|
+
if (typeof att === 'string') {
|
|
297
|
+
(v as any).attester = await maybeEncryptEth(att, `attester_${i + 1}`);
|
|
298
|
+
} else if (att && typeof att === 'object' && 'eth' in att) {
|
|
299
|
+
(att as any).eth = await maybeEncryptEth((att as any).eth, `attester_${i + 1}`);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// publisher can be single or array
|
|
303
|
+
if ('publisher' in v) {
|
|
304
|
+
const pub = (v as any).publisher;
|
|
305
|
+
if (Array.isArray(pub)) {
|
|
306
|
+
const out: any[] = [];
|
|
307
|
+
for (let j = 0; j < pub.length; j++) {
|
|
308
|
+
out.push(await maybeEncryptEth(pub[j], `publisher_${i + 1}_${j + 1}`));
|
|
309
|
+
}
|
|
310
|
+
(v as any).publisher = out;
|
|
311
|
+
} else if (pub !== undefined) {
|
|
312
|
+
(v as any).publisher = await maybeEncryptEth(pub, `publisher_${i + 1}`);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// Optional fundingAccount within validator
|
|
317
|
+
if ('fundingAccount' in v) {
|
|
318
|
+
(v as any).fundingAccount = await maybeEncryptEth((v as any).fundingAccount, `funding_${i + 1}`);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
@@ -152,11 +152,10 @@ export const stagingIgnitionL2ChainConfig: L2ChainConfig = {
|
|
|
152
152
|
activationThreshold: 200_000n * 10n ** 18n,
|
|
153
153
|
localEjectionThreshold: 196_000n * 10n ** 18n,
|
|
154
154
|
|
|
155
|
-
governanceProposerRoundSize: 300,
|
|
156
|
-
governanceProposerQuorum: 151,
|
|
155
|
+
governanceProposerRoundSize: 300,
|
|
156
|
+
governanceProposerQuorum: 151,
|
|
157
157
|
|
|
158
158
|
// Node slashing config
|
|
159
|
-
// TODO TMNT-330
|
|
160
159
|
slashMinPenaltyPercentage: 0.5,
|
|
161
160
|
slashMaxPenaltyPercentage: 2.0,
|
|
162
161
|
slashInactivityTargetPercentage: 0.7,
|
|
@@ -252,40 +251,69 @@ export const testnetL2ChainConfig: L2ChainConfig = {
|
|
|
252
251
|
skipArchiverInitialSync: true,
|
|
253
252
|
blobAllowEmptySources: true,
|
|
254
253
|
|
|
255
|
-
// Deployment stuff
|
|
256
254
|
/** How many seconds an L1 slot lasts. */
|
|
257
255
|
ethereumSlotDuration: 12,
|
|
258
256
|
/** How many seconds an L2 slots lasts (must be multiple of ethereum slot duration). */
|
|
259
|
-
aztecSlotDuration:
|
|
257
|
+
aztecSlotDuration: 72,
|
|
260
258
|
/** How many L2 slots an epoch lasts. */
|
|
261
259
|
aztecEpochDuration: 32,
|
|
262
260
|
/** The target validator committee size. */
|
|
263
|
-
aztecTargetCommitteeSize:
|
|
261
|
+
aztecTargetCommitteeSize: 24,
|
|
264
262
|
/** The number of epochs to lag behind the current epoch for validator selection. */
|
|
265
263
|
lagInEpochs: 2,
|
|
266
264
|
/** The number of epochs after an epoch ends that proofs are still accepted. */
|
|
267
265
|
aztecProofSubmissionEpochs: 1,
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
266
|
+
|
|
267
|
+
// This is a diff from mainnet: we have 2-strikes you're out, rather than 3 on mainnet.
|
|
268
|
+
localEjectionThreshold: 198_000n * 10n ** 18n,
|
|
269
|
+
/** How many sequencers must agree with a slash for it to be executed. */
|
|
270
|
+
slashingQuorum: 65,
|
|
271
|
+
slashingRoundSizeInEpochs: 4,
|
|
272
|
+
slashingExecutionDelayInRounds: 28,
|
|
273
|
+
slashingLifetimeInRounds: 34,
|
|
274
|
+
slashingVetoer: EthAddress.fromString('0xBbB4aF368d02827945748b28CD4b2D42e4A37480'),
|
|
275
|
+
slashingOffsetInRounds: 2,
|
|
276
|
+
|
|
277
|
+
slashingDisableDuration: 259_200, // 3 days
|
|
278
|
+
slasherFlavor: 'tally',
|
|
279
|
+
|
|
280
|
+
slashAmountSmall: 2_000n * 10n ** 18n,
|
|
281
|
+
slashAmountMedium: 2_000n * 10n ** 18n,
|
|
282
|
+
slashAmountLarge: 2_000n * 10n ** 18n,
|
|
283
|
+
|
|
278
284
|
/** The mana target for the rollup */
|
|
279
285
|
manaTarget: 0n,
|
|
286
|
+
|
|
280
287
|
/** The proving cost per mana */
|
|
281
|
-
provingCostPerMana:
|
|
282
|
-
/** Exit delay for stakers */
|
|
283
|
-
exitDelaySeconds: DefaultL1ContractsConfig.exitDelaySeconds,
|
|
288
|
+
provingCostPerMana: 0n,
|
|
284
289
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
290
|
+
exitDelaySeconds: 4 * 24 * 60 * 60, // 4 days
|
|
291
|
+
|
|
292
|
+
activationThreshold: 200_000n * 10n ** 18n,
|
|
293
|
+
ejectionThreshold: 100_000n * 10n ** 18n,
|
|
294
|
+
|
|
295
|
+
governanceProposerRoundSize: 300,
|
|
296
|
+
governanceProposerQuorum: 151,
|
|
297
|
+
|
|
298
|
+
// Node slashing config
|
|
299
|
+
slashInactivityTargetPercentage: 0.8,
|
|
300
|
+
slashInactivityConsecutiveEpochThreshold: 2,
|
|
301
|
+
slashInactivityPenalty: 2_000n * 10n ** 18n,
|
|
302
|
+
slashPrunePenalty: 0n, // 2_000n * 10n ** 18n, We disable slashing for prune offenses right now
|
|
303
|
+
slashDataWithholdingPenalty: 0n, // 2_000n * 10n ** 18n, We disable slashing for data withholding offenses right now
|
|
304
|
+
slashProposeInvalidAttestationsPenalty: 2_000n * 10n ** 18n,
|
|
305
|
+
slashAttestDescendantOfInvalidPenalty: 2_000n * 10n ** 18n,
|
|
306
|
+
slashUnknownPenalty: 2_000n * 10n ** 18n,
|
|
307
|
+
slashBroadcastedInvalidBlockPenalty: 2_000n * 10n ** 18n, // 10_000n * 10n ** 18n, Disabled for now until further testing
|
|
308
|
+
slashGracePeriodL2Slots: 1_200, // One day from deployment
|
|
309
|
+
slashOffenseExpirationRounds: 8,
|
|
310
|
+
|
|
311
|
+
slashMinPenaltyPercentage: 0.5,
|
|
312
|
+
slashMaxPenaltyPercentage: 2.0,
|
|
313
|
+
slashMaxPayloadSize: 50,
|
|
314
|
+
slashExecuteRoundsLookBack: 4,
|
|
315
|
+
|
|
316
|
+
sentinelEnabled: true,
|
|
289
317
|
|
|
290
318
|
...DefaultNetworkDBMapSizeConfig,
|
|
291
319
|
};
|
|
@@ -321,54 +349,57 @@ export const mainnetL2ChainConfig: L2ChainConfig = {
|
|
|
321
349
|
lagInEpochs: 2,
|
|
322
350
|
/** The number of epochs after an epoch ends that proofs are still accepted. */
|
|
323
351
|
aztecProofSubmissionEpochs: 1,
|
|
352
|
+
|
|
353
|
+
localEjectionThreshold: 196_000n * 10n ** 18n,
|
|
324
354
|
/** How many sequencers must agree with a slash for it to be executed. */
|
|
325
355
|
slashingQuorum: 65,
|
|
326
|
-
|
|
327
356
|
slashingRoundSizeInEpochs: 4,
|
|
328
|
-
slashingLifetimeInRounds: 40,
|
|
329
357
|
slashingExecutionDelayInRounds: 28,
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
slashAmountMedium: 10_000n * 10n ** 18n,
|
|
333
|
-
slashAmountLarge: 50_000n * 10n ** 18n,
|
|
358
|
+
slashingLifetimeInRounds: 34,
|
|
359
|
+
slashingVetoer: EthAddress.ZERO, // TODO TMNT-329
|
|
334
360
|
slashingOffsetInRounds: 2,
|
|
361
|
+
|
|
362
|
+
slashingDisableDuration: 259_200, // 3 days
|
|
335
363
|
slasherFlavor: 'tally',
|
|
336
|
-
|
|
364
|
+
|
|
365
|
+
slashAmountSmall: 2_000n * 10n ** 18n,
|
|
366
|
+
slashAmountMedium: 2_000n * 10n ** 18n,
|
|
367
|
+
slashAmountLarge: 2_000n * 10n ** 18n,
|
|
337
368
|
|
|
338
369
|
/** The mana target for the rollup */
|
|
339
370
|
manaTarget: 0n,
|
|
340
371
|
|
|
341
|
-
exitDelaySeconds: 5 * 24 * 60 * 60,
|
|
342
|
-
|
|
343
372
|
/** The proving cost per mana */
|
|
344
373
|
provingCostPerMana: 0n,
|
|
345
374
|
|
|
346
|
-
|
|
375
|
+
exitDelaySeconds: 4 * 24 * 60 * 60, // 4 days
|
|
376
|
+
|
|
347
377
|
activationThreshold: 200_000n * 10n ** 18n,
|
|
348
|
-
|
|
378
|
+
ejectionThreshold: 100_000n * 10n ** 18n,
|
|
349
379
|
|
|
350
|
-
governanceProposerRoundSize:
|
|
351
|
-
governanceProposerQuorum:
|
|
380
|
+
governanceProposerRoundSize: 1000,
|
|
381
|
+
governanceProposerQuorum: 600,
|
|
352
382
|
|
|
353
383
|
// Node slashing config
|
|
354
|
-
|
|
355
|
-
slashMinPenaltyPercentage: 0.5,
|
|
356
|
-
slashMaxPenaltyPercentage: 2.0,
|
|
357
|
-
slashInactivityTargetPercentage: 0.7,
|
|
384
|
+
slashInactivityTargetPercentage: 0.8,
|
|
358
385
|
slashInactivityConsecutiveEpochThreshold: 2,
|
|
359
386
|
slashInactivityPenalty: 2_000n * 10n ** 18n,
|
|
360
387
|
slashPrunePenalty: 0n, // 2_000n * 10n ** 18n, We disable slashing for prune offenses right now
|
|
361
388
|
slashDataWithholdingPenalty: 0n, // 2_000n * 10n ** 18n, We disable slashing for data withholding offenses right now
|
|
362
|
-
slashProposeInvalidAttestationsPenalty:
|
|
363
|
-
slashAttestDescendantOfInvalidPenalty:
|
|
389
|
+
slashProposeInvalidAttestationsPenalty: 2_000n * 10n ** 18n,
|
|
390
|
+
slashAttestDescendantOfInvalidPenalty: 2_000n * 10n ** 18n,
|
|
364
391
|
slashUnknownPenalty: 2_000n * 10n ** 18n,
|
|
365
|
-
slashBroadcastedInvalidBlockPenalty:
|
|
366
|
-
|
|
367
|
-
slashGracePeriodL2Slots: 32 * 4, // One round from genesis
|
|
392
|
+
slashBroadcastedInvalidBlockPenalty: 2_000n * 10n ** 18n, // 10_000n * 10n ** 18n, Disabled for now until further testing
|
|
393
|
+
slashGracePeriodL2Slots: 1_200, // One day from deployment
|
|
368
394
|
slashOffenseExpirationRounds: 8,
|
|
369
|
-
|
|
395
|
+
|
|
396
|
+
slashMinPenaltyPercentage: 0.5,
|
|
397
|
+
slashMaxPenaltyPercentage: 2.0,
|
|
398
|
+
slashMaxPayloadSize: 50,
|
|
370
399
|
slashExecuteRoundsLookBack: 4,
|
|
371
400
|
|
|
401
|
+
sentinelEnabled: true,
|
|
402
|
+
|
|
372
403
|
...DefaultNetworkDBMapSizeConfig,
|
|
373
404
|
};
|
|
374
405
|
|