@aztec-labs/cli 6.0.0-rc.4 → 6.1.0-nightly.20261023
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/infrastructure/index.d.ts +1 -1
- package/dest/cmds/infrastructure/index.d.ts.map +1 -1
- package/dest/cmds/infrastructure/index.js +1 -16
- package/package.json +21 -21
- package/src/cmds/infrastructure/index.ts +1 -45
- package/dest/cmds/infrastructure/sequencers.d.ts +0 -15
- package/dest/cmds/infrastructure/sequencers.d.ts.map +0 -1
- package/dest/cmds/infrastructure/sequencers.js +0 -120
- package/src/cmds/infrastructure/sequencers.ts +0 -132
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { LogFn } from '@aztec-labs/foundation/log';
|
|
2
2
|
import type { Command } from 'commander';
|
|
3
3
|
export declare function injectCommands(program: Command, log: LogFn): Command;
|
|
4
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9jbWRzL2luZnJhc3RydWN0dXJlL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLDRCQUE0QixDQUFDO0FBQ3hELE9BQU8sS0FBSyxFQUFFLE9BQU8sRUFBRSxNQUFNLFdBQVcsQ0FBQztBQUl6Qyx3QkFBZ0IsY0FBYyxDQUFDLE9BQU8sRUFBRSxPQUFPLEVBQUUsR0FBRyxFQUFFLEtBQUssV0FhMUQifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cmds/infrastructure/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cmds/infrastructure/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,WAa1D"}
|
|
@@ -1,23 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { nodeOption } from '../../utils/commands.js';
|
|
2
2
|
export function injectCommands(program, log) {
|
|
3
3
|
program.command('setup-protocol-contracts').description('Bootstrap the blockchain by initializing all the protocol contracts').addOption(nodeOption).option('--testAccounts', 'Deploy funded test accounts.').option('--json', 'Output the contract addresses in JSON format').action(async (options)=>{
|
|
4
4
|
const { setupL2Contracts } = await import('./setup_l2_contract.js');
|
|
5
5
|
await setupL2Contracts(options.nodeUrl, options.testAccounts, options.json, log);
|
|
6
6
|
});
|
|
7
|
-
program.command('sequencers').argument('<command>', 'Command to run: list, add, remove, who-next').argument('[who]', 'Who to add/remove').option('--recipient <address>', 'For remove (required): address that receives the withdrawn stake; it cannot be changed once set', parseEthereumAddress).description('Manages or queries registered sequencers on the L1 rollup contract.').requiredOption('--l1-rpc-urls <string>', 'List of Ethereum host URLs. Chain identifiers localhost and testnet can be used (comma separated)', (arg)=>arg.split(','), [
|
|
8
|
-
ETHEREUM_HOSTS
|
|
9
|
-
]).option('-m, --mnemonic <string>', 'The mnemonic for the sender of the tx', 'test test test test test test test test test test test junk').option('--block-number <number>', 'Block number to query next sequencer for', parseOptionalInteger).addOption(nodeOption).addOption(l1ChainIdOption).action(async (command, who, options)=>{
|
|
10
|
-
const { sequencers } = await import('./sequencers.js');
|
|
11
|
-
await sequencers({
|
|
12
|
-
command: command,
|
|
13
|
-
who,
|
|
14
|
-
recipient: options.recipient,
|
|
15
|
-
mnemonic: options.mnemonic,
|
|
16
|
-
nodeUrl: options.nodeUrl,
|
|
17
|
-
l1RpcUrls: options.l1RpcUrls,
|
|
18
|
-
chainId: options.l1ChainId,
|
|
19
|
-
log
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
7
|
return program;
|
|
23
8
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec-labs/cli",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.0-nightly.20261023",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./devnet": "./dest/cmds/devnet/index.js",
|
|
@@ -77,18 +77,18 @@
|
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"@aztec-foundation/l1-artifacts": "6.0.0-rc.7",
|
|
80
|
-
"@aztec-labs/accounts": "6.
|
|
81
|
-
"@aztec-labs/archiver": "6.
|
|
82
|
-
"@aztec-labs/aztec.js": "6.
|
|
83
|
-
"@aztec-labs/constants": "6.
|
|
84
|
-
"@aztec-labs/ethereum": "6.
|
|
85
|
-
"@aztec-labs/foundation": "6.
|
|
86
|
-
"@aztec-labs/node-keystore": "6.
|
|
87
|
-
"@aztec-labs/p2p": "6.
|
|
88
|
-
"@aztec-labs/protocol-contracts": "6.
|
|
89
|
-
"@aztec-labs/stdlib": "6.
|
|
90
|
-
"@aztec-labs/wallets": "6.
|
|
91
|
-
"@aztec-labs/world-state": "6.
|
|
80
|
+
"@aztec-labs/accounts": "6.1.0-nightly.20261023",
|
|
81
|
+
"@aztec-labs/archiver": "6.1.0-nightly.20261023",
|
|
82
|
+
"@aztec-labs/aztec.js": "6.1.0-nightly.20261023",
|
|
83
|
+
"@aztec-labs/constants": "6.1.0-nightly.20261023",
|
|
84
|
+
"@aztec-labs/ethereum": "6.1.0-nightly.20261023",
|
|
85
|
+
"@aztec-labs/foundation": "6.1.0-nightly.20261023",
|
|
86
|
+
"@aztec-labs/node-keystore": "6.1.0-nightly.20261023",
|
|
87
|
+
"@aztec-labs/p2p": "6.1.0-nightly.20261023",
|
|
88
|
+
"@aztec-labs/protocol-contracts": "6.1.0-nightly.20261023",
|
|
89
|
+
"@aztec-labs/stdlib": "6.1.0-nightly.20261023",
|
|
90
|
+
"@aztec-labs/wallets": "6.1.0-nightly.20261023",
|
|
91
|
+
"@aztec-labs/world-state": "6.1.0-nightly.20261023",
|
|
92
92
|
"@ethersproject/wallet": "^5.8.0",
|
|
93
93
|
"@iarna/toml": "^2.2.5",
|
|
94
94
|
"@libp2p/peer-id-factory": "^3.0.4",
|
|
@@ -119,14 +119,14 @@
|
|
|
119
119
|
},
|
|
120
120
|
"peerDependencies": {
|
|
121
121
|
"@aztec-foundation/l1-artifacts": "6.0.0-rc.7",
|
|
122
|
-
"@aztec-labs/accounts": "6.
|
|
123
|
-
"@aztec-labs/bb-prover": "6.
|
|
124
|
-
"@aztec-labs/ethereum": "6.
|
|
125
|
-
"@aztec-labs/noir-contracts.js": "6.
|
|
126
|
-
"@aztec-labs/noir-protocol-circuits-types": "6.
|
|
127
|
-
"@aztec-labs/noir-test-contracts.js": "6.
|
|
128
|
-
"@aztec-labs/protocol-contracts": "6.
|
|
129
|
-
"@aztec-labs/stdlib": "6.
|
|
122
|
+
"@aztec-labs/accounts": "6.1.0-nightly.20261023",
|
|
123
|
+
"@aztec-labs/bb-prover": "6.1.0-nightly.20261023",
|
|
124
|
+
"@aztec-labs/ethereum": "6.1.0-nightly.20261023",
|
|
125
|
+
"@aztec-labs/noir-contracts.js": "6.1.0-nightly.20261023",
|
|
126
|
+
"@aztec-labs/noir-protocol-circuits-types": "6.1.0-nightly.20261023",
|
|
127
|
+
"@aztec-labs/noir-test-contracts.js": "6.1.0-nightly.20261023",
|
|
128
|
+
"@aztec-labs/protocol-contracts": "6.1.0-nightly.20261023",
|
|
129
|
+
"@aztec-labs/stdlib": "6.1.0-nightly.20261023"
|
|
130
130
|
},
|
|
131
131
|
"files": [
|
|
132
132
|
"dest",
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import type { LogFn } from '@aztec-labs/foundation/log';
|
|
2
2
|
import type { Command } from 'commander';
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
ETHEREUM_HOSTS,
|
|
6
|
-
l1ChainIdOption,
|
|
7
|
-
nodeOption,
|
|
8
|
-
parseEthereumAddress,
|
|
9
|
-
parseOptionalInteger,
|
|
10
|
-
} from '../../utils/commands.js';
|
|
4
|
+
import { nodeOption } from '../../utils/commands.js';
|
|
11
5
|
|
|
12
6
|
export function injectCommands(program: Command, log: LogFn) {
|
|
13
7
|
program
|
|
@@ -21,43 +15,5 @@ export function injectCommands(program: Command, log: LogFn) {
|
|
|
21
15
|
await setupL2Contracts(options.nodeUrl, options.testAccounts, options.json, log);
|
|
22
16
|
});
|
|
23
17
|
|
|
24
|
-
program
|
|
25
|
-
.command('sequencers')
|
|
26
|
-
.argument('<command>', 'Command to run: list, add, remove, who-next')
|
|
27
|
-
.argument('[who]', 'Who to add/remove')
|
|
28
|
-
.option(
|
|
29
|
-
'--recipient <address>',
|
|
30
|
-
'For remove (required): address that receives the withdrawn stake; it cannot be changed once set',
|
|
31
|
-
parseEthereumAddress,
|
|
32
|
-
)
|
|
33
|
-
.description('Manages or queries registered sequencers on the L1 rollup contract.')
|
|
34
|
-
.requiredOption<string[]>(
|
|
35
|
-
'--l1-rpc-urls <string>',
|
|
36
|
-
'List of Ethereum host URLs. Chain identifiers localhost and testnet can be used (comma separated)',
|
|
37
|
-
(arg: string) => arg.split(','),
|
|
38
|
-
[ETHEREUM_HOSTS],
|
|
39
|
-
)
|
|
40
|
-
.option(
|
|
41
|
-
'-m, --mnemonic <string>',
|
|
42
|
-
'The mnemonic for the sender of the tx',
|
|
43
|
-
'test test test test test test test test test test test junk',
|
|
44
|
-
)
|
|
45
|
-
.option('--block-number <number>', 'Block number to query next sequencer for', parseOptionalInteger)
|
|
46
|
-
.addOption(nodeOption)
|
|
47
|
-
.addOption(l1ChainIdOption)
|
|
48
|
-
.action(async (command, who, options) => {
|
|
49
|
-
const { sequencers } = await import('./sequencers.js');
|
|
50
|
-
await sequencers({
|
|
51
|
-
command: command,
|
|
52
|
-
who,
|
|
53
|
-
recipient: options.recipient,
|
|
54
|
-
mnemonic: options.mnemonic,
|
|
55
|
-
nodeUrl: options.nodeUrl,
|
|
56
|
-
l1RpcUrls: options.l1RpcUrls,
|
|
57
|
-
chainId: options.l1ChainId,
|
|
58
|
-
log,
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
|
|
62
18
|
return program;
|
|
63
19
|
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { EthAddress } from '@aztec-labs/foundation/eth-address';
|
|
2
|
-
import type { LogFn } from '@aztec-labs/foundation/log';
|
|
3
|
-
export declare function sequencers(opts: {
|
|
4
|
-
command: 'list' | 'add' | 'remove' | 'who-next' | 'flush';
|
|
5
|
-
who?: string;
|
|
6
|
-
/** Address that receives the withdrawn stake. Required for `remove`. */
|
|
7
|
-
recipient?: EthAddress;
|
|
8
|
-
mnemonic?: string;
|
|
9
|
-
bn254SecretKey?: bigint;
|
|
10
|
-
nodeUrl: string;
|
|
11
|
-
l1RpcUrls: string[];
|
|
12
|
-
chainId: number;
|
|
13
|
-
log: LogFn;
|
|
14
|
-
}): Promise<void>;
|
|
15
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VxdWVuY2Vycy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NtZHMvaW5mcmFzdHJ1Y3R1cmUvc2VxdWVuY2Vycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFPQSxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSxvQ0FBb0MsQ0FBQztBQUNyRSxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSw0QkFBNEIsQ0FBQztBQUl4RCx3QkFBc0IsVUFBVSxDQUFDLElBQUksRUFBRTtJQUNyQyxPQUFPLEVBQUUsTUFBTSxHQUFHLEtBQUssR0FBRyxRQUFRLEdBQUcsVUFBVSxHQUFHLE9BQU8sQ0FBQztJQUMxRCxHQUFHLENBQUMsRUFBRSxNQUFNLENBQUM7SUFDYix3RUFBd0U7SUFDeEUsU0FBUyxDQUFDLEVBQUUsVUFBVSxDQUFDO0lBQ3ZCLFFBQVEsQ0FBQyxFQUFFLE1BQU0sQ0FBQztJQUNsQixjQUFjLENBQUMsRUFBRSxNQUFNLENBQUM7SUFDeEIsT0FBTyxFQUFFLE1BQU0sQ0FBQztJQUNoQixTQUFTLEVBQUUsTUFBTSxFQUFFLENBQUM7SUFDcEIsT0FBTyxFQUFFLE1BQU0sQ0FBQztJQUNoQixHQUFHLEVBQUUsS0FBSyxDQUFDO0NBQ1osaUJBNEdBIn0=
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sequencers.d.ts","sourceRoot":"","sources":["../../../src/cmds/infrastructure/sequencers.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAIxD,wBAAsB,UAAU,CAAC,IAAI,EAAE;IACrC,OAAO,EAAE,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;IAC1D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,wEAAwE;IACxE,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,KAAK,CAAC;CACZ,iBA4GA"}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { RollupAbi, TestERC20Abi } from '@aztec-foundation/l1-artifacts';
|
|
2
|
-
import { Fr } from '@aztec-labs/aztec.js/fields';
|
|
3
|
-
import { createAztecNodeClient } from '@aztec-labs/aztec.js/node';
|
|
4
|
-
import { createEthereumChain } from '@aztec-labs/ethereum/chain';
|
|
5
|
-
import { getL1ContractsConfigEnvVars } from '@aztec-labs/ethereum/config';
|
|
6
|
-
import { GSEContract, RollupContract } from '@aztec-labs/ethereum/contracts';
|
|
7
|
-
import { createPublicClient, createWalletClient, fallback, getContract, http } from 'viem';
|
|
8
|
-
import { mnemonicToAccount } from 'viem/accounts';
|
|
9
|
-
export async function sequencers(opts) {
|
|
10
|
-
const { command, who: maybeWho, recipient, mnemonic, bn254SecretKey, nodeUrl, l1RpcUrls, chainId, log } = opts;
|
|
11
|
-
const missingRecipient = 'Missing --recipient: the address that receives the withdrawn stake';
|
|
12
|
-
if (command === 'remove' && !recipient) {
|
|
13
|
-
throw new Error(missingRecipient);
|
|
14
|
-
}
|
|
15
|
-
const client = createAztecNodeClient(nodeUrl);
|
|
16
|
-
const { l1ContractAddresses } = await client.getNodeInfo();
|
|
17
|
-
const chain = createEthereumChain(l1RpcUrls, chainId);
|
|
18
|
-
const publicClient = createPublicClient({
|
|
19
|
-
chain: chain.chainInfo,
|
|
20
|
-
transport: fallback(l1RpcUrls.map((url)=>http(url, {
|
|
21
|
-
batch: false
|
|
22
|
-
})))
|
|
23
|
-
});
|
|
24
|
-
const walletClient = mnemonic ? createWalletClient({
|
|
25
|
-
account: mnemonicToAccount(mnemonic),
|
|
26
|
-
chain: chain.chainInfo,
|
|
27
|
-
transport: fallback(l1RpcUrls.map((url)=>http(url, {
|
|
28
|
-
batch: false
|
|
29
|
-
})))
|
|
30
|
-
}) : undefined;
|
|
31
|
-
const rollup = new RollupContract(publicClient, l1ContractAddresses.rollupAddress);
|
|
32
|
-
const writeableRollup = walletClient ? getContract({
|
|
33
|
-
address: l1ContractAddresses.rollupAddress.toString(),
|
|
34
|
-
abi: RollupAbi,
|
|
35
|
-
client: walletClient
|
|
36
|
-
}) : undefined;
|
|
37
|
-
const who = maybeWho ?? walletClient?.account.address.toString();
|
|
38
|
-
if (command === 'list') {
|
|
39
|
-
const sequencers = await rollup.getAttesters();
|
|
40
|
-
if (sequencers.length === 0) {
|
|
41
|
-
log(`No sequencers registered on rollup`);
|
|
42
|
-
} else {
|
|
43
|
-
log(`Registered sequencers on rollup:`);
|
|
44
|
-
for (const sequencer of sequencers){
|
|
45
|
-
log(' ' + sequencer.toString());
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
} else if (command === 'add') {
|
|
49
|
-
if (!who || !writeableRollup || !walletClient) {
|
|
50
|
-
throw new Error(`Missing sequencer address`);
|
|
51
|
-
}
|
|
52
|
-
log(`Adding ${who} as sequencer`);
|
|
53
|
-
const stakingAssetAddress = await rollup.getStakingAsset();
|
|
54
|
-
const stakingAsset = getContract({
|
|
55
|
-
address: stakingAssetAddress.toString(),
|
|
56
|
-
abi: TestERC20Abi,
|
|
57
|
-
client: walletClient
|
|
58
|
-
});
|
|
59
|
-
const config = getL1ContractsConfigEnvVars();
|
|
60
|
-
const bn254SecretKeyFieldElement = bn254SecretKey ? new Fr(bn254SecretKey) : Fr.random();
|
|
61
|
-
const gseAddress = await rollup.getGSE();
|
|
62
|
-
const gseContract = new GSEContract(publicClient, gseAddress);
|
|
63
|
-
const registrationTuple = await gseContract.makeRegistrationTuple(bn254SecretKeyFieldElement.toBigInt());
|
|
64
|
-
await Promise.all([
|
|
65
|
-
await stakingAsset.write.mint([
|
|
66
|
-
walletClient.account.address,
|
|
67
|
-
config.activationThreshold
|
|
68
|
-
], {}),
|
|
69
|
-
await stakingAsset.write.approve([
|
|
70
|
-
rollup.address,
|
|
71
|
-
config.activationThreshold
|
|
72
|
-
], {})
|
|
73
|
-
].map((txHash)=>publicClient.waitForTransactionReceipt({
|
|
74
|
-
hash: txHash
|
|
75
|
-
})));
|
|
76
|
-
const hash = await writeableRollup.write.deposit([
|
|
77
|
-
who,
|
|
78
|
-
who,
|
|
79
|
-
registrationTuple.publicKeyInG1,
|
|
80
|
-
registrationTuple.publicKeyInG2,
|
|
81
|
-
registrationTuple.proofOfPossession,
|
|
82
|
-
true
|
|
83
|
-
]);
|
|
84
|
-
await publicClient.waitForTransactionReceipt({
|
|
85
|
-
hash
|
|
86
|
-
});
|
|
87
|
-
log(`Added in tx ${hash}`);
|
|
88
|
-
} else if (command === 'flush') {
|
|
89
|
-
if (!writeableRollup) {
|
|
90
|
-
throw new Error(`Missing sequencer address`);
|
|
91
|
-
}
|
|
92
|
-
log(`Flushing staking entry queue`);
|
|
93
|
-
const hash = await writeableRollup.write.flushEntryQueue();
|
|
94
|
-
await publicClient.waitForTransactionReceipt({
|
|
95
|
-
hash
|
|
96
|
-
});
|
|
97
|
-
log(`Flushed staking entry queue in tx ${hash}`);
|
|
98
|
-
} else if (command === 'remove') {
|
|
99
|
-
if (!who || !writeableRollup) {
|
|
100
|
-
throw new Error(`Missing sequencer address`);
|
|
101
|
-
}
|
|
102
|
-
if (!recipient) {
|
|
103
|
-
throw new Error(missingRecipient);
|
|
104
|
-
}
|
|
105
|
-
log(`Removing ${who} as sequencer, withdrawing its stake to ${recipient}`);
|
|
106
|
-
const hash = await writeableRollup.write.initiateWithdraw([
|
|
107
|
-
who,
|
|
108
|
-
recipient.toString()
|
|
109
|
-
]);
|
|
110
|
-
await publicClient.waitForTransactionReceipt({
|
|
111
|
-
hash
|
|
112
|
-
});
|
|
113
|
-
log(`Removed in tx ${hash}`);
|
|
114
|
-
} else if (command === 'who-next') {
|
|
115
|
-
const next = await rollup.getCurrentProposer();
|
|
116
|
-
log(`Sequencer expected to build is ${next}`);
|
|
117
|
-
} else {
|
|
118
|
-
throw new Error(`Unknown command ${command}`);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { RollupAbi, TestERC20Abi } from '@aztec-foundation/l1-artifacts';
|
|
2
|
-
|
|
3
|
-
import { Fr } from '@aztec-labs/aztec.js/fields';
|
|
4
|
-
import { createAztecNodeClient } from '@aztec-labs/aztec.js/node';
|
|
5
|
-
import { createEthereumChain } from '@aztec-labs/ethereum/chain';
|
|
6
|
-
import { getL1ContractsConfigEnvVars } from '@aztec-labs/ethereum/config';
|
|
7
|
-
import { GSEContract, RollupContract } from '@aztec-labs/ethereum/contracts';
|
|
8
|
-
import type { EthAddress } from '@aztec-labs/foundation/eth-address';
|
|
9
|
-
import type { LogFn } from '@aztec-labs/foundation/log';
|
|
10
|
-
import { createPublicClient, createWalletClient, fallback, getContract, http } from 'viem';
|
|
11
|
-
import { mnemonicToAccount } from 'viem/accounts';
|
|
12
|
-
|
|
13
|
-
export async function sequencers(opts: {
|
|
14
|
-
command: 'list' | 'add' | 'remove' | 'who-next' | 'flush';
|
|
15
|
-
who?: string;
|
|
16
|
-
/** Address that receives the withdrawn stake. Required for `remove`. */
|
|
17
|
-
recipient?: EthAddress;
|
|
18
|
-
mnemonic?: string;
|
|
19
|
-
bn254SecretKey?: bigint;
|
|
20
|
-
nodeUrl: string;
|
|
21
|
-
l1RpcUrls: string[];
|
|
22
|
-
chainId: number;
|
|
23
|
-
log: LogFn;
|
|
24
|
-
}) {
|
|
25
|
-
const { command, who: maybeWho, recipient, mnemonic, bn254SecretKey, nodeUrl, l1RpcUrls, chainId, log } = opts;
|
|
26
|
-
const missingRecipient = 'Missing --recipient: the address that receives the withdrawn stake';
|
|
27
|
-
if (command === 'remove' && !recipient) {
|
|
28
|
-
throw new Error(missingRecipient);
|
|
29
|
-
}
|
|
30
|
-
const client = createAztecNodeClient(nodeUrl);
|
|
31
|
-
const { l1ContractAddresses } = await client.getNodeInfo();
|
|
32
|
-
|
|
33
|
-
const chain = createEthereumChain(l1RpcUrls, chainId);
|
|
34
|
-
const publicClient = createPublicClient({
|
|
35
|
-
chain: chain.chainInfo,
|
|
36
|
-
transport: fallback(l1RpcUrls.map(url => http(url, { batch: false }))),
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
const walletClient = mnemonic
|
|
40
|
-
? createWalletClient({
|
|
41
|
-
account: mnemonicToAccount(mnemonic),
|
|
42
|
-
chain: chain.chainInfo,
|
|
43
|
-
transport: fallback(l1RpcUrls.map(url => http(url, { batch: false }))),
|
|
44
|
-
})
|
|
45
|
-
: undefined;
|
|
46
|
-
|
|
47
|
-
const rollup = new RollupContract(publicClient, l1ContractAddresses.rollupAddress);
|
|
48
|
-
|
|
49
|
-
const writeableRollup = walletClient
|
|
50
|
-
? getContract({
|
|
51
|
-
address: l1ContractAddresses.rollupAddress.toString(),
|
|
52
|
-
abi: RollupAbi,
|
|
53
|
-
client: walletClient,
|
|
54
|
-
})
|
|
55
|
-
: undefined;
|
|
56
|
-
|
|
57
|
-
const who = (maybeWho as `0x${string}`) ?? walletClient?.account.address.toString();
|
|
58
|
-
|
|
59
|
-
if (command === 'list') {
|
|
60
|
-
const sequencers = await rollup.getAttesters();
|
|
61
|
-
if (sequencers.length === 0) {
|
|
62
|
-
log(`No sequencers registered on rollup`);
|
|
63
|
-
} else {
|
|
64
|
-
log(`Registered sequencers on rollup:`);
|
|
65
|
-
for (const sequencer of sequencers) {
|
|
66
|
-
log(' ' + sequencer.toString());
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
} else if (command === 'add') {
|
|
70
|
-
if (!who || !writeableRollup || !walletClient) {
|
|
71
|
-
throw new Error(`Missing sequencer address`);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
log(`Adding ${who} as sequencer`);
|
|
75
|
-
|
|
76
|
-
const stakingAssetAddress = await rollup.getStakingAsset();
|
|
77
|
-
const stakingAsset = getContract({
|
|
78
|
-
address: stakingAssetAddress.toString(),
|
|
79
|
-
abi: TestERC20Abi,
|
|
80
|
-
client: walletClient,
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
const config = getL1ContractsConfigEnvVars();
|
|
84
|
-
|
|
85
|
-
const bn254SecretKeyFieldElement = bn254SecretKey ? new Fr(bn254SecretKey) : Fr.random();
|
|
86
|
-
const gseAddress = await rollup.getGSE();
|
|
87
|
-
const gseContract = new GSEContract(publicClient, gseAddress);
|
|
88
|
-
const registrationTuple = await gseContract.makeRegistrationTuple(bn254SecretKeyFieldElement.toBigInt());
|
|
89
|
-
|
|
90
|
-
await Promise.all(
|
|
91
|
-
[
|
|
92
|
-
await stakingAsset.write.mint([walletClient.account.address, config.activationThreshold], {} as any),
|
|
93
|
-
await stakingAsset.write.approve([rollup.address, config.activationThreshold], {} as any),
|
|
94
|
-
].map(txHash => publicClient.waitForTransactionReceipt({ hash: txHash })),
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
const hash = await writeableRollup.write.deposit([
|
|
98
|
-
who,
|
|
99
|
-
who,
|
|
100
|
-
registrationTuple.publicKeyInG1,
|
|
101
|
-
registrationTuple.publicKeyInG2,
|
|
102
|
-
registrationTuple.proofOfPossession,
|
|
103
|
-
true,
|
|
104
|
-
]);
|
|
105
|
-
await publicClient.waitForTransactionReceipt({ hash });
|
|
106
|
-
log(`Added in tx ${hash}`);
|
|
107
|
-
} else if (command === 'flush') {
|
|
108
|
-
if (!writeableRollup) {
|
|
109
|
-
throw new Error(`Missing sequencer address`);
|
|
110
|
-
}
|
|
111
|
-
log(`Flushing staking entry queue`);
|
|
112
|
-
const hash = await writeableRollup.write.flushEntryQueue();
|
|
113
|
-
await publicClient.waitForTransactionReceipt({ hash });
|
|
114
|
-
log(`Flushed staking entry queue in tx ${hash}`);
|
|
115
|
-
} else if (command === 'remove') {
|
|
116
|
-
if (!who || !writeableRollup) {
|
|
117
|
-
throw new Error(`Missing sequencer address`);
|
|
118
|
-
}
|
|
119
|
-
if (!recipient) {
|
|
120
|
-
throw new Error(missingRecipient);
|
|
121
|
-
}
|
|
122
|
-
log(`Removing ${who} as sequencer, withdrawing its stake to ${recipient}`);
|
|
123
|
-
const hash = await writeableRollup.write.initiateWithdraw([who, recipient.toString()]);
|
|
124
|
-
await publicClient.waitForTransactionReceipt({ hash });
|
|
125
|
-
log(`Removed in tx ${hash}`);
|
|
126
|
-
} else if (command === 'who-next') {
|
|
127
|
-
const next = await rollup.getCurrentProposer();
|
|
128
|
-
log(`Sequencer expected to build is ${next}`);
|
|
129
|
-
} else {
|
|
130
|
-
throw new Error(`Unknown command ${command}`);
|
|
131
|
-
}
|
|
132
|
-
}
|