@aztec/aztec 0.0.1-commit.f504929 → 0.0.1-commit.f5a9928
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/bin/index.js +4 -2
- package/dest/cli/aztec_start_action.d.ts +1 -1
- package/dest/cli/aztec_start_action.d.ts.map +1 -1
- package/dest/cli/aztec_start_action.js +42 -33
- package/dest/cli/aztec_start_options.d.ts +2 -2
- package/dest/cli/aztec_start_options.d.ts.map +1 -1
- package/dest/cli/aztec_start_options.js +22 -18
- package/dest/cli/cmds/compile.d.ts +1 -1
- package/dest/cli/cmds/compile.d.ts.map +1 -1
- package/dest/cli/cmds/compile.js +35 -21
- package/dest/cli/cmds/profile.d.ts +1 -1
- package/dest/cli/cmds/profile.d.ts.map +1 -1
- package/dest/cli/cmds/profile.js +1 -1
- package/dest/cli/cmds/profile_flamegraph.d.ts +1 -1
- package/dest/cli/cmds/profile_flamegraph.d.ts.map +1 -1
- package/dest/cli/cmds/profile_flamegraph.js +2 -1
- package/dest/cli/cmds/profile_gates.d.ts +2 -2
- package/dest/cli/cmds/profile_gates.d.ts.map +1 -1
- package/dest/cli/cmds/profile_gates.js +23 -4
- package/dest/cli/cmds/prover.d.ts +4 -0
- package/dest/cli/cmds/prover.d.ts.map +1 -0
- package/dest/cli/cmds/prover.js +24 -0
- package/dest/cli/cmds/standby.d.ts +56 -0
- package/dest/cli/cmds/standby.d.ts.map +1 -0
- package/dest/cli/cmds/standby.js +140 -0
- package/dest/cli/cmds/start_bot.d.ts +1 -1
- package/dest/cli/cmds/start_bot.d.ts.map +1 -1
- package/dest/cli/cmds/start_bot.js +8 -4
- package/dest/cli/cmds/start_node.d.ts +3 -2
- package/dest/cli/cmds/start_node.d.ts.map +1 -1
- package/dest/cli/cmds/start_node.js +36 -112
- package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
- package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
- package/dest/cli/cmds/start_prover_agent.js +5 -17
- package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
- package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
- package/dest/cli/cmds/start_prover_broker.js +22 -13
- package/dest/cli/cmds/start_txe.d.ts +2 -2
- package/dest/cli/cmds/start_txe.d.ts.map +1 -1
- package/dest/cli/cmds/start_txe.js +6 -5
- package/dest/cli/cmds/utils/artifacts.d.ts +6 -1
- package/dest/cli/cmds/utils/artifacts.d.ts.map +1 -1
- package/dest/cli/cmds/utils/collect_crate_dirs.d.ts +21 -0
- package/dest/cli/cmds/utils/collect_crate_dirs.d.ts.map +1 -0
- package/dest/cli/cmds/utils/collect_crate_dirs.js +114 -0
- package/dest/cli/cmds/utils/needs_recompile.d.ts +10 -0
- package/dest/cli/cmds/utils/needs_recompile.d.ts.map +1 -0
- package/dest/cli/cmds/utils/needs_recompile.js +90 -0
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +4 -0
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -0
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +61 -0
- package/dest/cli/util.d.ts +9 -6
- package/dest/cli/util.d.ts.map +1 -1
- package/dest/cli/util.js +26 -94
- package/dest/deploy/bridging.d.ts +84 -0
- package/dest/deploy/bridging.d.ts.map +1 -0
- package/dest/deploy/bridging.js +121 -0
- package/dest/deploy/fees.d.ts +120 -0
- package/dest/deploy/fees.d.ts.map +1 -0
- package/dest/deploy/fees.js +278 -0
- package/dest/deploy/graph.d.ts +40 -0
- package/dest/deploy/graph.d.ts.map +1 -0
- package/dest/deploy/graph.js +120 -0
- package/dest/deploy/index.d.ts +19 -0
- package/dest/deploy/index.d.ts.map +1 -0
- package/dest/deploy/index.js +15 -0
- package/dest/deploy/reporter.d.ts +106 -0
- package/dest/deploy/reporter.d.ts.map +1 -0
- package/dest/deploy/reporter.js +76 -0
- package/dest/deploy/runner.d.ts +8 -0
- package/dest/deploy/runner.d.ts.map +1 -0
- package/dest/deploy/runner.js +886 -0
- package/dest/deploy/state.d.ts +19 -0
- package/dest/deploy/state.d.ts.map +1 -0
- package/dest/deploy/state.js +59 -0
- package/dest/deploy/types.d.ts +233 -0
- package/dest/deploy/types.d.ts.map +1 -0
- package/dest/deploy/types.js +9 -0
- package/dest/examples/token.js +3 -3
- package/dest/local-network/auth_registry.d.ts +5 -0
- package/dest/local-network/auth_registry.d.ts.map +1 -0
- package/dest/local-network/auth_registry.js +17 -0
- package/dest/local-network/banana_fpc.d.ts +3 -2
- package/dest/local-network/banana_fpc.d.ts.map +1 -1
- package/dest/local-network/banana_fpc.js +11 -7
- package/dest/local-network/local-network.d.ts +10 -32
- package/dest/local-network/local-network.d.ts.map +1 -1
- package/dest/local-network/local-network.js +60 -73
- package/dest/testing/cheat_codes.d.ts +17 -23
- package/dest/testing/cheat_codes.d.ts.map +1 -1
- package/dest/testing/cheat_codes.js +17 -43
- package/dest/testing/epoch_test_settler.d.ts +2 -2
- package/dest/testing/epoch_test_settler.d.ts.map +1 -1
- package/dest/testing/epoch_test_settler.js +6 -26
- package/dest/testing/index.d.ts +3 -2
- package/dest/testing/index.d.ts.map +1 -1
- package/dest/testing/index.js +2 -1
- package/dest/testing/local-network.d.ts +51 -0
- package/dest/testing/local-network.d.ts.map +1 -0
- package/dest/testing/local-network.js +60 -0
- package/dest/testing/token_allowed_setup.d.ts +12 -0
- package/dest/testing/token_allowed_setup.d.ts.map +1 -0
- package/dest/testing/token_allowed_setup.js +24 -0
- package/package.json +38 -35
- package/scripts/add_crate.sh +11 -60
- package/scripts/aztec.sh +9 -2
- package/scripts/init.sh +5 -5
- package/scripts/new.sh +2 -2
- package/scripts/setup_workspace.sh +3 -2
- package/scripts/templates/blank/contract/Nargo.toml +6 -0
- package/scripts/templates/blank/contract/src/main.nr +10 -0
- package/scripts/templates/blank/test/Nargo.toml +7 -0
- package/scripts/templates/blank/test/src/lib.nr +11 -0
- package/scripts/templates/counter/contract/Nargo.toml +7 -0
- package/scripts/templates/counter/contract/src/main.nr +48 -0
- package/scripts/templates/counter/test/Nargo.toml +7 -0
- package/scripts/templates/counter/test/src/lib.nr +32 -0
- package/src/bin/index.ts +4 -2
- package/src/cli/aztec_start_action.ts +44 -27
- package/src/cli/aztec_start_options.ts +28 -25
- package/src/cli/cmds/compile.ts +41 -20
- package/src/cli/cmds/profile.ts +2 -1
- package/src/cli/cmds/profile_flamegraph.ts +2 -1
- package/src/cli/cmds/profile_gates.ts +22 -5
- package/src/cli/cmds/prover.ts +42 -0
- package/src/cli/cmds/standby.ts +184 -0
- package/src/cli/cmds/start_bot.ts +9 -6
- package/src/cli/cmds/start_node.ts +46 -131
- package/src/cli/cmds/start_prover_agent.ts +5 -8
- package/src/cli/cmds/start_prover_broker.ts +23 -24
- package/src/cli/cmds/start_txe.ts +7 -5
- package/src/cli/cmds/utils/artifacts.ts +5 -0
- package/src/cli/cmds/utils/collect_crate_dirs.ts +118 -0
- package/src/cli/cmds/utils/needs_recompile.ts +98 -0
- package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +76 -0
- package/src/cli/util.ts +26 -100
- package/src/deploy/bridging.ts +191 -0
- package/src/deploy/fees.ts +322 -0
- package/src/deploy/graph.ts +137 -0
- package/src/deploy/index.ts +41 -0
- package/src/deploy/reporter.ts +184 -0
- package/src/deploy/runner.ts +936 -0
- package/src/deploy/state.ts +66 -0
- package/src/deploy/types.ts +244 -0
- package/src/examples/token.ts +11 -3
- package/src/local-network/auth_registry.ts +19 -0
- package/src/local-network/banana_fpc.ts +12 -8
- package/src/local-network/local-network.ts +67 -83
- package/src/testing/cheat_codes.ts +18 -49
- package/src/testing/epoch_test_settler.ts +8 -32
- package/src/testing/index.ts +2 -1
- package/src/testing/local-network.ts +97 -0
- package/src/testing/token_allowed_setup.ts +26 -0
- package/dest/cli/cmds/start_archiver.d.ts +0 -9
- package/dest/cli/cmds/start_archiver.d.ts.map +0 -1
- package/dest/cli/cmds/start_archiver.js +0 -48
- package/dest/cli/release_version.d.ts +0 -2
- package/dest/cli/release_version.d.ts.map +0 -1
- package/dest/cli/release_version.js +0 -14
- package/dest/testing/anvil_test_watcher.d.ts +0 -42
- package/dest/testing/anvil_test_watcher.d.ts.map +0 -1
- package/dest/testing/anvil_test_watcher.js +0 -181
- package/src/cli/cmds/start_archiver.ts +0 -50
- package/src/cli/release_version.ts +0 -21
- package/src/testing/anvil_test_watcher.ts +0 -210
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
isBooleanConfigValue,
|
|
13
13
|
omitConfigMappings,
|
|
14
14
|
} from '@aztec/foundation/config';
|
|
15
|
-
import { dataConfigMappings } from '@aztec/kv-store/config';
|
|
16
15
|
import { sharedNodeConfigMappings } from '@aztec/node-lib/config';
|
|
17
16
|
import { bootnodeConfigMappings, p2pConfigMappings } from '@aztec/p2p/config';
|
|
18
17
|
import { proverAgentConfigMappings, proverBrokerConfigMappings } from '@aztec/prover-client/broker/config';
|
|
@@ -20,6 +19,7 @@ import { proverNodeConfigMappings } from '@aztec/prover-node/config';
|
|
|
20
19
|
import { allPxeConfigMappings } from '@aztec/pxe/config';
|
|
21
20
|
import { sequencerClientConfigMappings } from '@aztec/sequencer-client/config';
|
|
22
21
|
import { chainConfigMappings, nodeRpcConfigMappings } from '@aztec/stdlib/config';
|
|
22
|
+
import { dataConfigMappings } from '@aztec/stdlib/kv-store';
|
|
23
23
|
import { telemetryClientConfigMappings } from '@aztec/telemetry-client/config';
|
|
24
24
|
import { worldStateConfigMappings } from '@aztec/world-state/config';
|
|
25
25
|
|
|
@@ -36,7 +36,7 @@ export interface AztecStartOption {
|
|
|
36
36
|
parseVal?: (val: string) => any;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export const getOptions = (namespace: string, configMappings: Record<string, ConfigMapping
|
|
39
|
+
export const getOptions = (namespace: string, configMappings: Record<string, ConfigMapping<unknown>>) => {
|
|
40
40
|
const options: AztecStartOption[] = [];
|
|
41
41
|
for (const [key, { env, defaultValue: def, parseEnv, description, printDefault, fallback }] of Object.entries(
|
|
42
42
|
configMappings,
|
|
@@ -58,7 +58,11 @@ export const getOptions = (namespace: string, configMappings: Record<string, Con
|
|
|
58
58
|
return options;
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
-
const configToFlag = (
|
|
61
|
+
const configToFlag = (
|
|
62
|
+
flag: string,
|
|
63
|
+
configMapping: ConfigMapping<unknown>,
|
|
64
|
+
overrideDefaultValue?: any,
|
|
65
|
+
): AztecStartOption => {
|
|
62
66
|
if (!configMapping.isBoolean) {
|
|
63
67
|
flag += ' <value>';
|
|
64
68
|
}
|
|
@@ -105,8 +109,7 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
|
|
|
105
109
|
env: 'NETWORK',
|
|
106
110
|
},
|
|
107
111
|
|
|
108
|
-
configToFlag('--auto-
|
|
109
|
-
configToFlag('--auto-update-url', sharedNodeConfigMappings.autoUpdateUrl),
|
|
112
|
+
configToFlag('--enable-auto-shutdown', sharedNodeConfigMappings.enableAutoShutdown),
|
|
110
113
|
|
|
111
114
|
configToFlag('--sync-mode', sharedNodeConfigMappings.syncMode),
|
|
112
115
|
configToFlag('--snapshots-urls', sharedNodeConfigMappings.snapshotsUrls),
|
|
@@ -126,6 +129,12 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
|
|
|
126
129
|
defaultValue: DefaultMnemonic,
|
|
127
130
|
env: 'MNEMONIC',
|
|
128
131
|
},
|
|
132
|
+
{
|
|
133
|
+
flag: '--local-network.testAccounts',
|
|
134
|
+
description: 'Deploy test accounts on local network start',
|
|
135
|
+
env: 'TEST_ACCOUNTS',
|
|
136
|
+
...booleanConfigHelper(true),
|
|
137
|
+
},
|
|
129
138
|
],
|
|
130
139
|
API: [
|
|
131
140
|
{
|
|
@@ -166,6 +175,13 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
|
|
|
166
175
|
env: 'AZTEC_RESET_ADMIN_API_KEY',
|
|
167
176
|
parseVal: val => val === 'true' || val === '1',
|
|
168
177
|
},
|
|
178
|
+
{
|
|
179
|
+
flag: '--node-debug',
|
|
180
|
+
description: 'Expose debug endpoints (e.g. mineBlock) on the main RPC port',
|
|
181
|
+
defaultValue: false,
|
|
182
|
+
env: 'AZTEC_NODE_DEBUG',
|
|
183
|
+
parseVal: val => val === undefined || val === 'true' || val === '1',
|
|
184
|
+
},
|
|
169
185
|
{
|
|
170
186
|
flag: '--api-prefix <value>',
|
|
171
187
|
description: 'Prefix for API routes on any service that is started',
|
|
@@ -174,6 +190,11 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
|
|
|
174
190
|
},
|
|
175
191
|
configToFlag('--rpcMaxBatchSize', nodeRpcConfigMappings.rpcMaxBatchSize),
|
|
176
192
|
configToFlag('--rpcMaxBodySize', nodeRpcConfigMappings.rpcMaxBodySize),
|
|
193
|
+
configToFlag('--rpc-http-keep-alive-timeout-ms', nodeRpcConfigMappings.rpcHttpKeepAliveTimeoutMs),
|
|
194
|
+
configToFlag('--rpc-http-headers-timeout-ms', nodeRpcConfigMappings.rpcHttpHeadersTimeoutMs),
|
|
195
|
+
configToFlag('--rpc-cors-allowed-headers', nodeRpcConfigMappings.rpcCorsAllowedHeaders),
|
|
196
|
+
configToFlag('--rpc-cors-allowed-origins', nodeRpcConfigMappings.rpcCorsAllowedOrigins),
|
|
197
|
+
configToFlag('--rpc-cors-allow-any-origin', nodeRpcConfigMappings.rpcCorsAllowAnyOrigin),
|
|
177
198
|
],
|
|
178
199
|
ETHEREUM: [
|
|
179
200
|
configToFlag('--l1-chain-id', l1ReaderConfigMappings.l1ChainId),
|
|
@@ -206,12 +227,6 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
|
|
|
206
227
|
},
|
|
207
228
|
],
|
|
208
229
|
ARCHIVER: [
|
|
209
|
-
{
|
|
210
|
-
flag: '--archiver',
|
|
211
|
-
description: 'Starts Aztec Archiver with options',
|
|
212
|
-
defaultValue: undefined,
|
|
213
|
-
env: undefined,
|
|
214
|
-
},
|
|
215
230
|
...getOptions(
|
|
216
231
|
'archiver',
|
|
217
232
|
omitConfigMappings(archiverConfigMappings, Object.keys(l1ContractsConfigMappings) as (keyof ArchiverConfig)[]),
|
|
@@ -258,11 +273,7 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
|
|
|
258
273
|
defaultValue: undefined,
|
|
259
274
|
env: undefined,
|
|
260
275
|
},
|
|
261
|
-
...getOptions(
|
|
262
|
-
'proverBroker',
|
|
263
|
-
// filter out archiver options from prover node options as they're passed separately in --archiver
|
|
264
|
-
proverBrokerConfigMappings,
|
|
265
|
-
),
|
|
276
|
+
...getOptions('proverBroker', proverBrokerConfigMappings),
|
|
266
277
|
],
|
|
267
278
|
'PROVER AGENT': [
|
|
268
279
|
{
|
|
@@ -310,15 +321,7 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
|
|
|
310
321
|
},
|
|
311
322
|
...getOptions('bot', botConfigMappings),
|
|
312
323
|
],
|
|
313
|
-
PXE: [
|
|
314
|
-
{
|
|
315
|
-
flag: '--pxe',
|
|
316
|
-
description: 'Starts Aztec PXE with options',
|
|
317
|
-
defaultValue: undefined,
|
|
318
|
-
env: undefined,
|
|
319
|
-
},
|
|
320
|
-
...getOptions('pxe', allPxeConfigMappings),
|
|
321
|
-
],
|
|
324
|
+
PXE: [...getOptions('pxe', allPxeConfigMappings)],
|
|
322
325
|
TXE: [
|
|
323
326
|
{
|
|
324
327
|
flag: '--txe',
|
package/src/cli/cmds/compile.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { findBbBinary } from '@aztec/bb.js';
|
|
1
2
|
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
+
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
2
4
|
|
|
3
5
|
import { execFileSync } from 'child_process';
|
|
4
6
|
import type { Command } from 'commander';
|
|
@@ -6,10 +8,12 @@ import { readFile, writeFile } from 'fs/promises';
|
|
|
6
8
|
import { join } from 'path';
|
|
7
9
|
|
|
8
10
|
import { readArtifactFiles } from './utils/artifacts.js';
|
|
11
|
+
import { needsRecompile } from './utils/needs_recompile.js';
|
|
9
12
|
import { run } from './utils/spawn.js';
|
|
13
|
+
import { warnIfAztecVersionMismatch } from './utils/warn_if_aztec_version_mismatch.js';
|
|
10
14
|
|
|
11
|
-
/** Returns
|
|
12
|
-
async function collectContractArtifacts(): Promise<
|
|
15
|
+
/** Returns contract artifacts in the target directory along with whether each has already been postprocessed. */
|
|
16
|
+
async function collectContractArtifacts(): Promise<ContractArtifactInfo[]> {
|
|
13
17
|
let files;
|
|
14
18
|
try {
|
|
15
19
|
files = await readArtifactFiles('target');
|
|
@@ -19,18 +23,18 @@ async function collectContractArtifacts(): Promise<string[]> {
|
|
|
19
23
|
}
|
|
20
24
|
throw err;
|
|
21
25
|
}
|
|
22
|
-
return files
|
|
26
|
+
return files
|
|
27
|
+
.filter(f => Array.isArray(f.content.functions))
|
|
28
|
+
.map(f => ({ filePath: f.filePath, transpiled: f.content.transpiled === true }));
|
|
23
29
|
}
|
|
24
30
|
|
|
25
|
-
/**
|
|
26
|
-
async function
|
|
31
|
+
/** Stamps the Aztec stack version into the contract artifacts. */
|
|
32
|
+
async function stampAztecVersion(artifactPaths: string[]): Promise<void> {
|
|
33
|
+
const version = getPackageVersion();
|
|
27
34
|
for (const path of artifactPaths) {
|
|
28
35
|
const artifact = JSON.parse(await readFile(path, 'utf-8'));
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
fn.name = fn.name.replace(/^__aztec_nr_internals__/, '');
|
|
32
|
-
}
|
|
33
|
-
}
|
|
36
|
+
// eslint-disable-next-line camelcase
|
|
37
|
+
artifact.aztec_version = version;
|
|
34
38
|
await writeFile(path, JSON.stringify(artifact, null, 2) + '\n');
|
|
35
39
|
}
|
|
36
40
|
}
|
|
@@ -137,26 +141,36 @@ async function checkNoTestsInContracts(nargo: string, log: LogFn): Promise<void>
|
|
|
137
141
|
|
|
138
142
|
/** Compiles Aztec Noir contracts and postprocesses artifacts. */
|
|
139
143
|
async function compileAztecContract(nargoArgs: string[], log: LogFn): Promise<void> {
|
|
144
|
+
await warnIfAztecVersionMismatch(log);
|
|
145
|
+
|
|
140
146
|
const nargo = process.env.NARGO ?? 'nargo';
|
|
141
|
-
const bb = process.env.BB ?? 'bb';
|
|
147
|
+
const bb = process.env.BB ?? findBbBinary() ?? 'bb';
|
|
142
148
|
|
|
143
|
-
await
|
|
149
|
+
const shouldRecompile = await needsRecompile();
|
|
150
|
+
if (shouldRecompile) {
|
|
151
|
+
await run(nargo, ['compile', ...nargoArgs]);
|
|
144
152
|
|
|
145
|
-
|
|
146
|
-
|
|
153
|
+
// Ensure contract crates contain no tests (tests belong in the test crate).
|
|
154
|
+
await checkNoTestsInContracts(nargo, log);
|
|
155
|
+
}
|
|
147
156
|
|
|
148
|
-
|
|
157
|
+
// Postprocess any untranspiled artifacts: those just produced by nargo above, and any left behind by a bare
|
|
158
|
+
// `nargo compile` run outside `aztec compile`.
|
|
159
|
+
const unprocessed = (await collectContractArtifacts()).filter(a => !a.transpiled).map(a => a.filePath);
|
|
149
160
|
|
|
150
|
-
if (
|
|
161
|
+
if (unprocessed.length > 0) {
|
|
151
162
|
log('Postprocessing contracts...');
|
|
152
|
-
const bbArgs =
|
|
163
|
+
const bbArgs = unprocessed.flatMap(a => ['-i', a]);
|
|
153
164
|
await run(bb, ['aztec_process', ...bbArgs]);
|
|
154
165
|
|
|
155
|
-
|
|
156
|
-
await stripInternalPrefixes(artifacts);
|
|
166
|
+
await stampAztecVersion(unprocessed);
|
|
157
167
|
}
|
|
158
168
|
|
|
159
|
-
|
|
169
|
+
if (shouldRecompile || unprocessed.length > 0) {
|
|
170
|
+
log('Compilation complete!');
|
|
171
|
+
} else {
|
|
172
|
+
log('No source changes detected, skipping compilation.');
|
|
173
|
+
}
|
|
160
174
|
}
|
|
161
175
|
|
|
162
176
|
export function injectCompileCommand(program: Command, log: LogFn): Command {
|
|
@@ -182,3 +196,10 @@ export function injectCompileCommand(program: Command, log: LogFn): Command {
|
|
|
182
196
|
|
|
183
197
|
return program;
|
|
184
198
|
}
|
|
199
|
+
|
|
200
|
+
interface ContractArtifactInfo {
|
|
201
|
+
/** Path to the artifact JSON in the target directory. */
|
|
202
|
+
filePath: string;
|
|
203
|
+
/** Whether the artifact has already been transpiled and had its verification keys generated. */
|
|
204
|
+
transpiled: boolean;
|
|
205
|
+
}
|
package/src/cli/cmds/profile.ts
CHANGED
|
@@ -11,8 +11,9 @@ export function injectProfileCommand(program: Command, log: LogFn): Command {
|
|
|
11
11
|
profile
|
|
12
12
|
.command('gates')
|
|
13
13
|
.argument('[target-dir]', 'Path to the compiled artifacts directory', './target')
|
|
14
|
+
.option('--json', 'Output gate counts as JSON instead of a table', false)
|
|
14
15
|
.description('Display gate counts for all compiled Aztec artifacts in a target directory.')
|
|
15
|
-
.action((targetDir: string) => profileGates(targetDir, log));
|
|
16
|
+
.action((targetDir: string, options: { json: boolean }) => profileGates(targetDir, options.json, log));
|
|
16
17
|
|
|
17
18
|
profile
|
|
18
19
|
.command('flamegraph')
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { findBbBinary } from '@aztec/bb.js';
|
|
1
2
|
import type { LogFn } from '@aztec/foundation/log';
|
|
2
3
|
|
|
3
4
|
import { readFile, rename, rm, writeFile } from 'fs/promises';
|
|
@@ -33,7 +34,7 @@ export async function profileFlamegraph(artifactPath: string, functionName: stri
|
|
|
33
34
|
await writeFile(functionArtifact, makeFunctionArtifact(artifact, func));
|
|
34
35
|
|
|
35
36
|
const profiler = process.env.PROFILER_PATH ?? 'noir-profiler';
|
|
36
|
-
const bb = process.env.BB ?? 'bb';
|
|
37
|
+
const bb = process.env.BB ?? findBbBinary() ?? 'bb';
|
|
37
38
|
|
|
38
39
|
await run(profiler, [
|
|
39
40
|
'gates',
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { findBbBinary } from '@aztec/bb.js';
|
|
1
2
|
import { asyncPool } from '@aztec/foundation/async-pool';
|
|
2
3
|
import type { LogFn } from '@aztec/foundation/log';
|
|
3
4
|
|
|
@@ -5,12 +6,13 @@ import { execFile as execFileCb } from 'child_process';
|
|
|
5
6
|
import { rm } from 'fs/promises';
|
|
6
7
|
import { promisify } from 'util';
|
|
7
8
|
|
|
8
|
-
import { MAX_CONCURRENT, discoverArtifacts } from './profile_utils.js';
|
|
9
|
+
import { type DiscoveredArtifact, MAX_CONCURRENT, discoverArtifacts } from './profile_utils.js';
|
|
9
10
|
|
|
10
11
|
const execFile = promisify(execFileCb);
|
|
11
12
|
|
|
12
13
|
interface GateCountResult {
|
|
13
14
|
name: string;
|
|
15
|
+
type: DiscoveredArtifact['type'];
|
|
14
16
|
gateCount: number;
|
|
15
17
|
}
|
|
16
18
|
|
|
@@ -31,24 +33,39 @@ async function getGateCount(bb: string, artifactPath: string): Promise<number> {
|
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
/** Profiles all compiled artifacts in a target directory and prints gate counts. */
|
|
34
|
-
export async function profileGates(targetDir: string, log: LogFn): Promise<void> {
|
|
35
|
-
const bb = process.env.BB ?? 'bb';
|
|
36
|
+
export async function profileGates(targetDir: string, json: boolean, log: LogFn): Promise<void> {
|
|
37
|
+
const bb = process.env.BB ?? findBbBinary() ?? 'bb';
|
|
36
38
|
const { artifacts, tmpDir } = await discoverArtifacts(targetDir);
|
|
37
39
|
|
|
38
40
|
if (artifacts.length === 0) {
|
|
39
|
-
|
|
41
|
+
if (json) {
|
|
42
|
+
log('[]');
|
|
43
|
+
} else {
|
|
44
|
+
log('No artifacts found in target directory.');
|
|
45
|
+
}
|
|
40
46
|
return;
|
|
41
47
|
}
|
|
42
48
|
|
|
43
49
|
try {
|
|
44
50
|
const results: GateCountResult[] = await asyncPool(MAX_CONCURRENT, artifacts, async artifact => ({
|
|
45
51
|
name: artifact.name,
|
|
52
|
+
type: artifact.type,
|
|
46
53
|
gateCount: await getGateCount(bb, artifact.filePath),
|
|
47
54
|
}));
|
|
48
55
|
results.sort((a, b) => a.name.localeCompare(b.name));
|
|
49
56
|
|
|
50
57
|
if (results.length === 0) {
|
|
51
|
-
|
|
58
|
+
if (json) {
|
|
59
|
+
log('[]');
|
|
60
|
+
} else {
|
|
61
|
+
log('No constrained circuits found.');
|
|
62
|
+
}
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (json) {
|
|
67
|
+
const entries = results.map(r => ({ name: r.name, type: r.type, gates: r.gateCount }));
|
|
68
|
+
log(JSON.stringify(entries, null, 2));
|
|
52
69
|
return;
|
|
53
70
|
}
|
|
54
71
|
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
2
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
+
import { createProverNodeAdminClient } from '@aztec/stdlib/interfaces/server';
|
|
4
|
+
|
|
5
|
+
import { type Command, InvalidArgumentError } from 'commander';
|
|
6
|
+
|
|
7
|
+
function parseEpoch(value: string): number {
|
|
8
|
+
const parsed = Number(value);
|
|
9
|
+
if (!Number.isInteger(parsed) || parsed < 0) {
|
|
10
|
+
throw new InvalidArgumentError('Epoch must be a non-negative integer.');
|
|
11
|
+
}
|
|
12
|
+
return parsed;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function injectProverCommand(program: Command, log: LogFn): Command {
|
|
16
|
+
const proverCommand = program.command('prover').description('Operate a prover node via its admin JSON-RPC endpoint');
|
|
17
|
+
|
|
18
|
+
proverCommand
|
|
19
|
+
.command('start-proof')
|
|
20
|
+
.description('Schedules proving for the given epoch')
|
|
21
|
+
.requiredOption('--epoch <n>', 'Epoch number to prove', parseEpoch)
|
|
22
|
+
.requiredOption('--admin-url <url>', 'URL of the prover node admin JSON-RPC endpoint')
|
|
23
|
+
.option('--api-key <key>', 'Admin API key', process.env.AZTEC_ADMIN_API_KEY)
|
|
24
|
+
.action(async options => {
|
|
25
|
+
const client = createProverNodeAdminClient(options.adminUrl, {}, undefined, options.apiKey);
|
|
26
|
+
const jobId = await client.startProof(options.epoch);
|
|
27
|
+
log(`Started proving job ${jobId} for epoch ${options.epoch}`);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
proverCommand
|
|
31
|
+
.command('get-jobs')
|
|
32
|
+
.description('Lists the prover node proving jobs')
|
|
33
|
+
.requiredOption('--admin-url <url>', 'URL of the prover node admin JSON-RPC endpoint')
|
|
34
|
+
.option('--api-key <key>', 'Admin API key', process.env.AZTEC_ADMIN_API_KEY)
|
|
35
|
+
.action(async options => {
|
|
36
|
+
const client = createProverNodeAdminClient(options.adminUrl, {}, undefined, options.apiKey);
|
|
37
|
+
const jobs = await client.getJobs();
|
|
38
|
+
log(jsonStringify(jobs, true));
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return program;
|
|
42
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
2
|
+
import type { Fr } from '@aztec/aztec.js/fields';
|
|
3
|
+
import { getSponsoredFPCAddress } from '@aztec/cli/cli-utils';
|
|
4
|
+
import { getPublicClient } from '@aztec/ethereum/client';
|
|
5
|
+
import type { GenesisStateConfig } from '@aztec/ethereum/config';
|
|
6
|
+
import { RegistryContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
7
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
8
|
+
import { startHttpRpcServer } from '@aztec/foundation/json-rpc/server';
|
|
9
|
+
import { type LogFn, createLogger } from '@aztec/foundation/log';
|
|
10
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
11
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
12
|
+
import type { VersionCheck } from '@aztec/stdlib/update-checker';
|
|
13
|
+
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
14
|
+
|
|
15
|
+
import Koa from 'koa';
|
|
16
|
+
|
|
17
|
+
import { isShuttingDown, softShutdown } from '../util.js';
|
|
18
|
+
|
|
19
|
+
const ROLLUP_POLL_INTERVAL_S = 60;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Computes the expected genesis archive root from the genesis state config.
|
|
23
|
+
* Reads test accounts and sponsored FPC addresses as specified, then computes
|
|
24
|
+
* the genesis values including the archive root and prefilled public data.
|
|
25
|
+
*/
|
|
26
|
+
export async function computeExpectedGenesisRoot(config: GenesisStateConfig, userLog: LogFn) {
|
|
27
|
+
const testAccounts = config.testAccounts ? (await getInitialTestAccountsData()).map(a => a.address) : [];
|
|
28
|
+
const sponsoredFPCAccounts = config.sponsoredFPC ? [await getSponsoredFPCAddress()] : [];
|
|
29
|
+
const prefundAddresses = (config.prefundAddresses ?? []).map(a => AztecAddress.fromStringUnsafe(a));
|
|
30
|
+
const initialFundedAccounts = testAccounts.concat(sponsoredFPCAccounts).concat(prefundAddresses);
|
|
31
|
+
|
|
32
|
+
userLog(`Initial funded accounts: ${initialFundedAccounts.map(a => a.toString()).join(', ')}`);
|
|
33
|
+
|
|
34
|
+
const { genesisArchiveRoot, genesis } = await getGenesisValues(initialFundedAccounts);
|
|
35
|
+
|
|
36
|
+
userLog(`Genesis archive root: ${genesisArchiveRoot.toString()}`);
|
|
37
|
+
|
|
38
|
+
return { genesisArchiveRoot, genesis };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Compares the rollup's on-chain protocol constants (genesis archive root, VK tree root, protocol
|
|
43
|
+
* contracts hash) against the node's expected local values. Returns a list of human-readable mismatch
|
|
44
|
+
* descriptions, empty if the rollup is compatible.
|
|
45
|
+
*/
|
|
46
|
+
export async function checkRollupCompatibility(
|
|
47
|
+
rollup: RollupContract,
|
|
48
|
+
expected: { genesisArchiveRoot: Fr; vkTreeRoot: Fr; protocolContractsHash: Fr },
|
|
49
|
+
): Promise<string[]> {
|
|
50
|
+
const mismatches: string[] = [];
|
|
51
|
+
const [l1Genesis, l1Vk, l1Protocol] = await Promise.all([
|
|
52
|
+
rollup.getGenesisArchiveTreeRoot(),
|
|
53
|
+
rollup.getVkTreeRoot(),
|
|
54
|
+
rollup.getProtocolContractsHash(),
|
|
55
|
+
]);
|
|
56
|
+
if (!l1Genesis.equals(expected.genesisArchiveRoot)) {
|
|
57
|
+
mismatches.push(`genesis archive root (expected ${expected.genesisArchiveRoot}, got ${l1Genesis})`);
|
|
58
|
+
}
|
|
59
|
+
if (!l1Vk.equals(expected.vkTreeRoot)) {
|
|
60
|
+
mismatches.push(`VK tree root (expected ${expected.vkTreeRoot}, got ${l1Vk})`);
|
|
61
|
+
}
|
|
62
|
+
if (!l1Protocol.equals(expected.protocolContractsHash)) {
|
|
63
|
+
mismatches.push(`protocol contracts hash (expected ${expected.protocolContractsHash}, got ${l1Protocol})`);
|
|
64
|
+
}
|
|
65
|
+
return mismatches;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Waits until the canonical rollup's genesis archive root, VK tree root, and protocol contracts hash
|
|
70
|
+
* all match the expected local values. If the rollup is not yet compatible (e.g. during L1 contract upgrades),
|
|
71
|
+
* enters standby mode: starts a lightweight HTTP server for K8s liveness probes and polls every 60s
|
|
72
|
+
* until a compatible rollup appears.
|
|
73
|
+
*/
|
|
74
|
+
export async function waitForCompatibleRollup(
|
|
75
|
+
config: {
|
|
76
|
+
l1RpcUrls: string[];
|
|
77
|
+
l1ChainId: number;
|
|
78
|
+
registryAddress: EthAddress;
|
|
79
|
+
rollupVersion?: number;
|
|
80
|
+
},
|
|
81
|
+
expected: { genesisArchiveRoot: Fr; vkTreeRoot: Fr; protocolContractsHash: Fr },
|
|
82
|
+
port: number | undefined,
|
|
83
|
+
userLog: LogFn,
|
|
84
|
+
): Promise<void> {
|
|
85
|
+
const publicClient = getPublicClient(config);
|
|
86
|
+
const rollupVersion: number | 'canonical' = config.rollupVersion ?? 'canonical';
|
|
87
|
+
|
|
88
|
+
const registry = new RegistryContract(publicClient, config.registryAddress);
|
|
89
|
+
const rollupAddress = await registry.getRollupAddress(rollupVersion);
|
|
90
|
+
const rollup = new RollupContract(publicClient, rollupAddress.toString());
|
|
91
|
+
|
|
92
|
+
let mismatches: string[];
|
|
93
|
+
try {
|
|
94
|
+
mismatches = await checkRollupCompatibility(rollup, expected);
|
|
95
|
+
} catch (err: any) {
|
|
96
|
+
throw new Error(`Could not retrieve rollup config from canonical rollup at ${rollupAddress}: ${err.message}`);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (mismatches.length === 0) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
userLog(
|
|
104
|
+
`Rollup at ${rollupAddress} is incompatible: ${mismatches.join('; ')}. ` +
|
|
105
|
+
`Entering standby mode. Will poll every ${ROLLUP_POLL_INTERVAL_S}s for a compatible rollup...`,
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
const standbyServer = await startHttpRpcServer({ getApp: () => new Koa(), isHealthy: () => true }, { port });
|
|
109
|
+
userLog(`Standby status server listening on port ${standbyServer.port}`);
|
|
110
|
+
|
|
111
|
+
try {
|
|
112
|
+
await retryUntil(
|
|
113
|
+
async () => {
|
|
114
|
+
const currentRollupAddress = await registry.getRollupAddress(rollupVersion);
|
|
115
|
+
const currentRollup = new RollupContract(publicClient, currentRollupAddress.toString());
|
|
116
|
+
|
|
117
|
+
let currentMismatches: string[];
|
|
118
|
+
try {
|
|
119
|
+
currentMismatches = await checkRollupCompatibility(currentRollup, expected);
|
|
120
|
+
} catch {
|
|
121
|
+
userLog(`Failed to fetch rollup config from rollup at ${currentRollupAddress}. Retrying...`);
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (currentMismatches.length === 0) {
|
|
126
|
+
userLog(`Compatible rollup found at ${currentRollupAddress}. Exiting standby mode.`);
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
userLog(`Still waiting. Rollup at ${currentRollupAddress}: ${currentMismatches.join('; ')}.`);
|
|
131
|
+
return undefined;
|
|
132
|
+
},
|
|
133
|
+
'compatible rollup',
|
|
134
|
+
0,
|
|
135
|
+
ROLLUP_POLL_INTERVAL_S,
|
|
136
|
+
);
|
|
137
|
+
} finally {
|
|
138
|
+
await new Promise<void>((resolve, reject) => standbyServer.close(err => (err ? reject(err) : resolve())));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Polls the canonical rollup's protocol constants every 10 minutes and soft-shuts-down the node once they
|
|
144
|
+
* diverge from the node's expected local values (i.e. an incompatible rollup has become canonical on L1).
|
|
145
|
+
* The HTTP health server is left running so K8s probes keep passing on the wound-down pod. This is the
|
|
146
|
+
* inverse of {@link waitForCompatibleRollup}; it should only be set up for nodes following the canonical
|
|
147
|
+
* rollup. Reuses the {@link checkRollupCompatibility} diff and the generic VersionChecker poll primitive.
|
|
148
|
+
*/
|
|
149
|
+
export async function setupAutoShutdown(
|
|
150
|
+
config: { l1RpcUrls: string[]; l1ChainId: number },
|
|
151
|
+
registryAddress: EthAddress,
|
|
152
|
+
rollupVersion: number | 'canonical',
|
|
153
|
+
expected: { genesisArchiveRoot: Fr; vkTreeRoot: Fr; protocolContractsHash: Fr },
|
|
154
|
+
signalHandlers: Array<() => Promise<void>>,
|
|
155
|
+
): Promise<void> {
|
|
156
|
+
const { VersionChecker } = await import('@aztec/stdlib/update-checker');
|
|
157
|
+
|
|
158
|
+
const logger = createLogger('auto_shutdown');
|
|
159
|
+
const publicClient = getPublicClient(config);
|
|
160
|
+
const registry = new RegistryContract(publicClient, registryAddress);
|
|
161
|
+
|
|
162
|
+
const check: VersionCheck = {
|
|
163
|
+
name: 'rollup',
|
|
164
|
+
currentVersion: 'compatible',
|
|
165
|
+
getLatestVersion: async () => {
|
|
166
|
+
const rollupAddress = await registry.getRollupAddress(rollupVersion);
|
|
167
|
+
const rollup = new RollupContract(publicClient, rollupAddress.toString());
|
|
168
|
+
const mismatches = await checkRollupCompatibility(rollup, expected);
|
|
169
|
+
return mismatches.length === 0 ? 'compatible' : `incompatible: ${mismatches.join('; ')}`;
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
const checker = new VersionChecker([check], 600_000, logger);
|
|
174
|
+
checker.on('newVersion', ({ latestVersion }) => {
|
|
175
|
+
if (isShuttingDown()) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
logger.warn('Canonical rollup is no longer compatible; auto-shutting down node', { latestVersion });
|
|
179
|
+
// softShutdown never rejects (it awaits handlers via allSettled); fire-and-forget from the listener.
|
|
180
|
+
void softShutdown(logger.info.bind(logger), signalHandlers);
|
|
181
|
+
});
|
|
182
|
+
checker.start();
|
|
183
|
+
signalHandlers.push(() => checker.stop());
|
|
184
|
+
}
|
|
@@ -21,11 +21,9 @@ export async function startBot(
|
|
|
21
21
|
services: NamespacedApiHandlers,
|
|
22
22
|
userLog: LogFn,
|
|
23
23
|
) {
|
|
24
|
-
const { proverNode,
|
|
25
|
-
if (proverNode ||
|
|
26
|
-
userLog(
|
|
27
|
-
`Starting a bot with --prover-node, --prover, --archiver, --sequencer, --p2p-bootstrap, or --txe is not supported.`,
|
|
28
|
-
);
|
|
24
|
+
const { proverNode, sequencer, p2pBootstrap, txe, prover } = options;
|
|
25
|
+
if (proverNode || sequencer || p2pBootstrap || txe || prover) {
|
|
26
|
+
userLog(`Starting a bot with --prover-node, --prover, --sequencer, --p2p-bootstrap, or --txe is not supported.`);
|
|
29
27
|
process.exit(1);
|
|
30
28
|
}
|
|
31
29
|
|
|
@@ -58,6 +56,11 @@ export async function addBot(
|
|
|
58
56
|
const config = extractRelevantOptions<BotConfig>(options, botConfigMappings, 'bot');
|
|
59
57
|
userLog?.(`Starting bot with config ${stringifyConfig(config)}`);
|
|
60
58
|
|
|
59
|
+
// The bot wallet's embedded PXE syncs to this tip (see start_bot.ts/start_node.ts which build the wallet from the
|
|
60
|
+
// same options). L1-to-L2 readiness checks must be evaluated at this tip rather than at 'latest', or the bot can
|
|
61
|
+
// consider a message ready while the PXE simulation anchors to an older block that cannot prove its membership yet.
|
|
62
|
+
const { syncChainTip } = extractRelevantOptions<PXEConfig & CliPXEOptions>(options, allPxeConfigMappings, 'pxe');
|
|
63
|
+
|
|
61
64
|
const db = await (config.dataDirectory
|
|
62
65
|
? createStore('bot', BotStore.SCHEMA_VERSION, config)
|
|
63
66
|
: openTmpStore('bot', true, config.dataStoreMapSizeKb));
|
|
@@ -65,7 +68,7 @@ export async function addBot(
|
|
|
65
68
|
const store = new BotStore(db);
|
|
66
69
|
await store.cleanupOldClaims();
|
|
67
70
|
|
|
68
|
-
const botRunner = new BotRunner(config, wallet, aztecNode, telemetry, aztecNodeAdmin, store);
|
|
71
|
+
const botRunner = new BotRunner(config, wallet, aztecNode, telemetry, aztecNodeAdmin, store, syncChainTip);
|
|
69
72
|
if (!config.noStart) {
|
|
70
73
|
void botRunner.start(); // Do not block since bot setup takes time
|
|
71
74
|
}
|