@aztec/aztec 0.0.1-commit.5476d83 → 0.0.1-commit.5914bae
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 +12 -5
- package/dest/cli/admin_api_key_store.d.ts +45 -0
- package/dest/cli/admin_api_key_store.d.ts.map +1 -0
- package/dest/cli/admin_api_key_store.js +98 -0
- 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 +75 -19
- package/dest/cli/aztec_start_options.d.ts +1 -1
- package/dest/cli/aztec_start_options.d.ts.map +1 -1
- package/dest/cli/aztec_start_options.js +47 -35
- package/dest/cli/cli.d.ts +1 -1
- package/dest/cli/cli.d.ts.map +1 -1
- package/dest/cli/cli.js +7 -52
- package/dest/cli/cmds/compile.d.ts +4 -0
- package/dest/cli/cmds/compile.d.ts.map +1 -0
- package/dest/cli/cmds/compile.js +168 -0
- package/dest/cli/cmds/migrate_ha_db.d.ts +3 -0
- package/dest/cli/cmds/migrate_ha_db.d.ts.map +1 -0
- package/dest/cli/cmds/migrate_ha_db.js +27 -0
- package/dest/cli/cmds/profile.d.ts +4 -0
- package/dest/cli/cmds/profile.d.ts.map +1 -0
- package/dest/cli/cmds/profile.js +8 -0
- package/dest/cli/cmds/profile_flamegraph.d.ts +4 -0
- package/dest/cli/cmds/profile_flamegraph.d.ts.map +1 -0
- package/dest/cli/cmds/profile_flamegraph.js +52 -0
- package/dest/cli/cmds/profile_gates.d.ts +4 -0
- package/dest/cli/cmds/profile_gates.d.ts.map +1 -0
- package/dest/cli/cmds/profile_gates.js +58 -0
- package/dest/cli/cmds/profile_utils.d.ts +18 -0
- package/dest/cli/cmds/profile_utils.d.ts.map +1 -0
- package/dest/cli/cmds/profile_utils.js +50 -0
- package/dest/cli/cmds/standby.d.ts +32 -0
- package/dest/cli/cmds/standby.d.ts.map +1 -0
- package/dest/cli/cmds/standby.js +97 -0
- package/dest/cli/cmds/start_archiver.d.ts +1 -1
- package/dest/cli/cmds/start_archiver.d.ts.map +1 -1
- package/dest/cli/cmds/start_archiver.js +11 -13
- package/dest/cli/cmds/start_bot.d.ts +3 -3
- package/dest/cli/cmds/start_bot.d.ts.map +1 -1
- package/dest/cli/cmds/start_bot.js +10 -6
- 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 +73 -29
- package/dest/cli/cmds/start_p2p_bootstrap.d.ts +2 -2
- package/dest/cli/cmds/start_p2p_bootstrap.d.ts.map +1 -1
- package/dest/cli/cmds/start_p2p_bootstrap.js +2 -3
- 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 +6 -18
- 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 +15 -9
- package/dest/cli/cmds/utils/artifacts.d.ts +21 -0
- package/dest/cli/cmds/utils/artifacts.d.ts.map +1 -0
- package/dest/cli/cmds/utils/artifacts.js +24 -0
- 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/spawn.d.ts +3 -0
- package/dest/cli/cmds/utils/spawn.d.ts.map +1 -0
- package/dest/cli/cmds/utils/spawn.js +16 -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 +41 -0
- package/dest/cli/util.d.ts +9 -20
- package/dest/cli/util.d.ts.map +1 -1
- package/dest/cli/util.js +48 -84
- package/dest/examples/token.js +9 -9
- package/dest/examples/util.d.ts +2 -2
- package/dest/examples/util.d.ts.map +1 -1
- package/dest/local-network/banana_fpc.d.ts +1 -1
- package/dest/local-network/banana_fpc.d.ts.map +1 -1
- package/dest/local-network/banana_fpc.js +4 -4
- package/dest/local-network/local-network.d.ts +13 -14
- package/dest/local-network/local-network.d.ts.map +1 -1
- package/dest/local-network/local-network.js +86 -43
- package/dest/testing/anvil_test_watcher.d.ts +10 -2
- package/dest/testing/anvil_test_watcher.d.ts.map +1 -1
- package/dest/testing/anvil_test_watcher.js +82 -19
- package/dest/testing/cheat_codes.d.ts +13 -15
- package/dest/testing/cheat_codes.d.ts.map +1 -1
- package/dest/testing/cheat_codes.js +34 -32
- package/dest/testing/epoch_test_settler.d.ts +19 -0
- package/dest/testing/epoch_test_settler.d.ts.map +1 -0
- package/dest/testing/epoch_test_settler.js +61 -0
- package/dest/testing/index.d.ts +3 -1
- package/dest/testing/index.d.ts.map +1 -1
- package/dest/testing/index.js +2 -0
- package/dest/testing/token_allowed_setup.d.ts +7 -0
- package/dest/testing/token_allowed_setup.d.ts.map +1 -0
- package/dest/testing/token_allowed_setup.js +20 -0
- package/package.json +40 -36
- package/scripts/add_crate.sh +102 -0
- package/scripts/aztec.sh +70 -0
- package/scripts/init.sh +39 -0
- package/scripts/new.sh +83 -0
- package/scripts/setup_workspace.sh +68 -0
- package/src/bin/index.ts +13 -5
- package/src/cli/admin_api_key_store.ts +128 -0
- package/src/cli/aztec_start_action.ts +67 -14
- package/src/cli/aztec_start_options.ts +48 -34
- package/src/cli/cli.ts +11 -56
- package/src/cli/cmds/compile.ts +194 -0
- package/src/cli/cmds/migrate_ha_db.ts +43 -0
- package/src/cli/cmds/profile.ts +25 -0
- package/src/cli/cmds/profile_flamegraph.ts +64 -0
- package/src/cli/cmds/profile_gates.ts +68 -0
- package/src/cli/cmds/profile_utils.ts +58 -0
- package/src/cli/cmds/standby.ts +132 -0
- package/src/cli/cmds/start_archiver.ts +7 -18
- package/src/cli/cmds/start_bot.ts +9 -6
- package/src/cli/cmds/start_node.ts +85 -35
- package/src/cli/cmds/start_p2p_bootstrap.ts +3 -3
- package/src/cli/cmds/start_prover_agent.ts +7 -18
- package/src/cli/cmds/start_prover_broker.ts +20 -16
- package/src/cli/cmds/utils/artifacts.ts +44 -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/spawn.ts +16 -0
- package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +54 -0
- package/src/cli/util.ts +58 -96
- package/src/examples/token.ts +10 -10
- package/src/examples/util.ts +1 -1
- package/src/local-network/banana_fpc.ts +12 -8
- package/src/local-network/local-network.ts +120 -85
- package/src/testing/anvil_test_watcher.ts +87 -20
- package/src/testing/cheat_codes.ts +42 -35
- package/src/testing/epoch_test_settler.ts +70 -0
- package/src/testing/index.ts +2 -0
- package/src/testing/token_allowed_setup.ts +19 -0
- package/dest/cli/cmds/start_blob_sink.d.ts +0 -3
- package/dest/cli/cmds/start_blob_sink.d.ts.map +0 -1
- package/dest/cli/cmds/start_blob_sink.js +0 -33
- package/dest/cli/cmds/start_prover_node.d.ts +0 -7
- package/dest/cli/cmds/start_prover_node.d.ts.map +0 -1
- package/dest/cli/cmds/start_prover_node.js +0 -108
- 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/src/cli/cmds/start_blob_sink.ts +0 -57
- package/src/cli/cmds/start_prover_node.ts +0 -124
- package/src/cli/release_version.ts +0 -21
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
2
|
+
import { sha256Hash } from '@aztec/foundation/json-rpc/server';
|
|
3
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
4
|
+
|
|
5
|
+
import { promises as fs } from 'fs';
|
|
6
|
+
import { join } from 'path';
|
|
7
|
+
|
|
8
|
+
/** Subdirectory under dataDirectory for admin API key storage. */
|
|
9
|
+
const ADMIN_STORE_DIR = 'admin';
|
|
10
|
+
const HASH_FILE_NAME = 'api_key_hash';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Result of resolving the admin API key.
|
|
14
|
+
* Contains the SHA-256 hex hash of the API key to be used by the auth middleware,
|
|
15
|
+
* and optionally the raw key when newly generated (so the caller can display it).
|
|
16
|
+
*/
|
|
17
|
+
export interface AdminApiKeyResolution {
|
|
18
|
+
/** The SHA-256 hash of the API key. */
|
|
19
|
+
apiKeyHash: Buffer;
|
|
20
|
+
/**
|
|
21
|
+
* The raw API key, only present when a new key was generated during this call.
|
|
22
|
+
* The caller MUST display this to the operator — it will not be stored or returned again.
|
|
23
|
+
*/
|
|
24
|
+
rawKey?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ResolveAdminApiKeyOptions {
|
|
28
|
+
/** SHA-256 hex hash of a pre-generated API key. When set, the node uses this hash directly. */
|
|
29
|
+
adminApiKeyHash?: string;
|
|
30
|
+
/** If true, disable admin API key auth entirely. */
|
|
31
|
+
disableAdminApiKey?: boolean;
|
|
32
|
+
/** If true, force-generate a new key even if one is already persisted. */
|
|
33
|
+
resetAdminApiKey?: boolean;
|
|
34
|
+
/** Root data directory for persistent storage. */
|
|
35
|
+
dataDirectory?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Resolves the admin API key for the admin RPC endpoint.
|
|
40
|
+
*
|
|
41
|
+
* Strategy:
|
|
42
|
+
* 1. If opt-out flag is set (`disableAdminApiKey`), return undefined (no auth).
|
|
43
|
+
* 2. If a pre-generated hash is provided (`adminApiKeyHash`), use it directly.
|
|
44
|
+
* 3. If a data directory exists, look for a persisted hash file
|
|
45
|
+
* at `<dataDirectory>/admin/api_key_hash`:
|
|
46
|
+
* - If `resetAdminApiKey` is set, skip loading and force-generate a new key.
|
|
47
|
+
* - Found: use the stored hash (operator already saved the key from first run).
|
|
48
|
+
* - Not found: auto-generate a random key, display it once, persist the hash.
|
|
49
|
+
* 3. If no data directory: generate a random key
|
|
50
|
+
* each run and display it (cannot persist).
|
|
51
|
+
*
|
|
52
|
+
* @param options - The options for resolving the admin API key.
|
|
53
|
+
* @param log - Logger for outputting the key and status messages.
|
|
54
|
+
* @returns The resolved API key hash, or undefined if auth is disabled.
|
|
55
|
+
*/
|
|
56
|
+
export async function resolveAdminApiKey(
|
|
57
|
+
options: ResolveAdminApiKeyOptions,
|
|
58
|
+
log: Logger,
|
|
59
|
+
): Promise<AdminApiKeyResolution | undefined> {
|
|
60
|
+
// Operator explicitly opted out of admin auth
|
|
61
|
+
if (options.disableAdminApiKey) {
|
|
62
|
+
log.warn('Admin API key authentication is DISABLED (--disable-admin-api-key / AZTEC_DISABLE_ADMIN_API_KEY)');
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Operator provided a pre-generated hash (e.g. via AZTEC_ADMIN_API_KEY_HASH env var)
|
|
67
|
+
if (options.adminApiKeyHash) {
|
|
68
|
+
const hex = options.adminApiKeyHash.trim();
|
|
69
|
+
if (hex.length !== 64 || !/^[0-9a-f]{64}$/.test(hex)) {
|
|
70
|
+
throw new Error(`Invalid admin API key hash: expected 64-char hex string, got "${hex}"`);
|
|
71
|
+
}
|
|
72
|
+
log.info('Admin API key authentication enabled (using pre-configured key hash)');
|
|
73
|
+
return { apiKeyHash: Buffer.from(hex, 'hex') };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Persistent storage available, load or generate key
|
|
77
|
+
if (options.dataDirectory) {
|
|
78
|
+
const adminDir = join(options.dataDirectory, ADMIN_STORE_DIR);
|
|
79
|
+
const hashFilePath = join(adminDir, HASH_FILE_NAME);
|
|
80
|
+
|
|
81
|
+
// Unless a reset is forced, try to load the existing hash from disk
|
|
82
|
+
if (!options.resetAdminApiKey) {
|
|
83
|
+
try {
|
|
84
|
+
const storedHash = (await fs.readFile(hashFilePath, 'utf-8')).trim();
|
|
85
|
+
if (storedHash.length === 64) {
|
|
86
|
+
log.info('Admin API key authentication enabled (loaded stored key hash from disk)');
|
|
87
|
+
return { apiKeyHash: Buffer.from(storedHash, 'hex') };
|
|
88
|
+
}
|
|
89
|
+
log.warn(`Invalid stored admin API key hash at ${hashFilePath}, regenerating...`);
|
|
90
|
+
} catch (err: any) {
|
|
91
|
+
if (err.code !== 'ENOENT') {
|
|
92
|
+
log.warn(`Failed to read admin API key hash from ${hashFilePath}: ${err.message}`);
|
|
93
|
+
}
|
|
94
|
+
// File doesn't exist — fall through to generate
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
log.warn('Admin API key reset requested — generating a new key');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Generate a new key, persist the hash, and return the raw key for the caller to display
|
|
101
|
+
const { rawKey, hash } = generateApiKey();
|
|
102
|
+
await fs.mkdir(adminDir, { recursive: true });
|
|
103
|
+
await fs.writeFile(hashFilePath, hash.toString('hex'), 'utf-8');
|
|
104
|
+
// Set restrictive permissions (owner read/write only)
|
|
105
|
+
await fs.chmod(hashFilePath, 0o600);
|
|
106
|
+
|
|
107
|
+
log.info('Admin API key authentication enabled (new key generated and hash persisted to disk)');
|
|
108
|
+
return { apiKeyHash: hash, rawKey };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// No data directory, generate a temporary key per session
|
|
112
|
+
const { rawKey, hash } = generateApiKey();
|
|
113
|
+
|
|
114
|
+
log.warn('No data directory configured — admin API key cannot be persisted.');
|
|
115
|
+
log.warn('A temporary key has been generated for this session only.');
|
|
116
|
+
|
|
117
|
+
return { apiKeyHash: hash, rawKey };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Generates a cryptographically random API key and its SHA-256 hash.
|
|
122
|
+
* @returns The raw key (hex string) and its SHA-256 hash as a Buffer.
|
|
123
|
+
*/
|
|
124
|
+
function generateApiKey(): { rawKey: string; hash: Buffer } {
|
|
125
|
+
const rawKey = randomBytes(32).toString('hex');
|
|
126
|
+
const hash = sha256Hash(rawKey);
|
|
127
|
+
return { rawKey, hash };
|
|
128
|
+
}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
+
import { getActiveNetworkName } from '@aztec/foundation/config';
|
|
1
2
|
import {
|
|
2
3
|
type NamespacedApiHandlers,
|
|
3
4
|
createNamespacedSafeJsonRpcServer,
|
|
5
|
+
getApiKeyAuthMiddleware,
|
|
4
6
|
startHttpRpcServer,
|
|
5
7
|
} from '@aztec/foundation/json-rpc/server';
|
|
6
8
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
7
9
|
import type { ChainConfig } from '@aztec/stdlib/config';
|
|
8
|
-
import { AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
|
|
10
|
+
import { AztecNodeAdminApiSchema, AztecNodeApiSchema, AztecNodeDebugApiSchema } from '@aztec/stdlib/interfaces/client';
|
|
11
|
+
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
9
12
|
import { getVersioningMiddleware } from '@aztec/stdlib/versioning';
|
|
10
13
|
import { getOtelJsonRpcPropagationMiddleware } from '@aztec/telemetry-client';
|
|
11
14
|
|
|
12
15
|
import { createLocalNetwork } from '../local-network/index.js';
|
|
13
16
|
import { github, splash } from '../splash.js';
|
|
14
|
-
import {
|
|
17
|
+
import { resolveAdminApiKey } from './admin_api_key_store.js';
|
|
15
18
|
import { extractNamespacedOptions, installSignalHandlers } from './util.js';
|
|
16
19
|
import { getVersions } from './versioning.js';
|
|
17
20
|
|
|
@@ -20,22 +23,26 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
|
|
|
20
23
|
const signalHandlers: Array<() => Promise<void>> = [];
|
|
21
24
|
const services: NamespacedApiHandlers = {};
|
|
22
25
|
const adminServices: NamespacedApiHandlers = {};
|
|
26
|
+
const packageVersion = getPackageVersion();
|
|
23
27
|
let config: ChainConfig | undefined = undefined;
|
|
24
28
|
|
|
25
29
|
if (options.localNetwork) {
|
|
26
|
-
const cliVersion = getCliVersion();
|
|
27
30
|
const localNetwork = extractNamespacedOptions(options, 'local-network');
|
|
28
31
|
localNetwork.testAccounts = true;
|
|
29
32
|
userLog(`${splash}\n${github}\n\n`);
|
|
30
|
-
userLog(`Setting up Aztec local network ${
|
|
33
|
+
userLog(`Setting up Aztec local network ${packageVersion ?? 'unknown'}, please stand by...`);
|
|
31
34
|
|
|
32
35
|
const { node, stop } = await createLocalNetwork(
|
|
33
36
|
{
|
|
34
37
|
l1Mnemonic: localNetwork.l1Mnemonic,
|
|
35
38
|
l1RpcUrls: options.l1RpcUrls,
|
|
36
|
-
deployAztecContractsSalt: localNetwork.deployAztecContractsSalt,
|
|
37
39
|
testAccounts: localNetwork.testAccounts,
|
|
38
40
|
realProofs: false,
|
|
41
|
+
// Setting the epoch duration to 2 by default for local network. This allows the epoch to be "proven" faster, so
|
|
42
|
+
// the users can consume out hash without having to wait for a long time.
|
|
43
|
+
// Note: We are not proving anything in the local network (realProofs == false). But in `createLocalNetwork`,
|
|
44
|
+
// the EpochTestSettler will set the out hash to the outbox when an epoch is complete.
|
|
45
|
+
aztecEpochDuration: 2,
|
|
39
46
|
},
|
|
40
47
|
userLog,
|
|
41
48
|
);
|
|
@@ -43,19 +50,24 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
|
|
|
43
50
|
// Start Node and PXE JSON-RPC server
|
|
44
51
|
signalHandlers.push(stop);
|
|
45
52
|
services.node = [node, AztecNodeApiSchema];
|
|
53
|
+
adminServices.node = [node, AztecNodeAdminApiSchema];
|
|
54
|
+
services.nodeDebug = [node, AztecNodeDebugApiSchema];
|
|
46
55
|
} else {
|
|
56
|
+
// Route --prover-node through startNode
|
|
57
|
+
if (options.proverNode && !options.node) {
|
|
58
|
+
options.node = true;
|
|
59
|
+
}
|
|
60
|
+
|
|
47
61
|
if (options.node) {
|
|
48
62
|
const { startNode } = await import('./cmds/start_node.js');
|
|
49
|
-
|
|
63
|
+
const networkName = getActiveNetworkName(options.network);
|
|
64
|
+
({ config } = await startNode(options, signalHandlers, services, adminServices, userLog, networkName));
|
|
65
|
+
if (options.nodeDebug && services.node) {
|
|
66
|
+
services.nodeDebug = [services.node[0], AztecNodeDebugApiSchema];
|
|
67
|
+
}
|
|
50
68
|
} else if (options.bot) {
|
|
51
69
|
const { startBot } = await import('./cmds/start_bot.js');
|
|
52
70
|
await startBot(options, signalHandlers, services, userLog);
|
|
53
|
-
} else if (options.proverNode) {
|
|
54
|
-
const { startProverNode } = await import('./cmds/start_prover_node.js');
|
|
55
|
-
({ config } = await startProverNode(options, signalHandlers, services, userLog));
|
|
56
|
-
} else if (options.blobSink) {
|
|
57
|
-
const { startBlobSink } = await import('./cmds/start_blob_sink.js');
|
|
58
|
-
await startBlobSink(options, signalHandlers, userLog);
|
|
59
71
|
} else if (options.archiver) {
|
|
60
72
|
const { startArchiver } = await import('./cmds/start_archiver.js');
|
|
61
73
|
({ config } = await startArchiver(options, signalHandlers, services));
|
|
@@ -82,13 +94,14 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
|
|
|
82
94
|
|
|
83
95
|
installSignalHandlers(debugLogger.info, signalHandlers);
|
|
84
96
|
const versions = getVersions(config);
|
|
97
|
+
const versioningOpts = { packageVersion };
|
|
85
98
|
|
|
86
99
|
// Start the main JSON-RPC server
|
|
87
100
|
if (Object.entries(services).length > 0) {
|
|
88
101
|
const rpcServer = createNamespacedSafeJsonRpcServer(services, {
|
|
89
102
|
http200OnError: false,
|
|
90
103
|
log: debugLogger,
|
|
91
|
-
middlewares: [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions)],
|
|
104
|
+
middlewares: [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions, versioningOpts)],
|
|
92
105
|
maxBatchSize: options.rpcMaxBatchSize,
|
|
93
106
|
maxBodySizeBytes: options.rpcMaxBodySize,
|
|
94
107
|
});
|
|
@@ -98,14 +111,54 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
|
|
|
98
111
|
|
|
99
112
|
// If there are any admin services, start a separate JSON-RPC server for them
|
|
100
113
|
if (Object.entries(adminServices).length > 0) {
|
|
114
|
+
const adminMiddlewares = [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions, versioningOpts)];
|
|
115
|
+
|
|
116
|
+
// Resolve the admin API key (auto-generated and persisted, or opt-out)
|
|
117
|
+
const apiKeyResolution = await resolveAdminApiKey(
|
|
118
|
+
{
|
|
119
|
+
adminApiKeyHash: options.adminApiKeyHash,
|
|
120
|
+
disableAdminApiKey: options.disableAdminApiKey,
|
|
121
|
+
resetAdminApiKey: options.resetAdminApiKey,
|
|
122
|
+
dataDirectory: options.dataDirectory,
|
|
123
|
+
},
|
|
124
|
+
debugLogger,
|
|
125
|
+
);
|
|
126
|
+
if (apiKeyResolution) {
|
|
127
|
+
adminMiddlewares.unshift(getApiKeyAuthMiddleware(apiKeyResolution.apiKeyHash));
|
|
128
|
+
} else {
|
|
129
|
+
debugLogger.warn('No admin API key set — admin endpoint is unauthenticated');
|
|
130
|
+
}
|
|
131
|
+
|
|
101
132
|
const rpcServer = createNamespacedSafeJsonRpcServer(adminServices, {
|
|
102
133
|
http200OnError: false,
|
|
103
134
|
log: debugLogger,
|
|
104
|
-
middlewares:
|
|
135
|
+
middlewares: adminMiddlewares,
|
|
105
136
|
maxBatchSize: options.rpcMaxBatchSize,
|
|
106
137
|
maxBodySizeBytes: options.rpcMaxBodySize,
|
|
107
138
|
});
|
|
108
139
|
const { port } = await startHttpRpcServer(rpcServer, { port: options.adminPort });
|
|
109
140
|
debugLogger.info(`Aztec Server admin API listening on port ${port}`, versions);
|
|
141
|
+
|
|
142
|
+
// Display the API key after the server has started
|
|
143
|
+
// Uses userLog which is never filtered by LOG_LEVEL.
|
|
144
|
+
if (apiKeyResolution?.rawKey) {
|
|
145
|
+
const separator = '='.repeat(70);
|
|
146
|
+
userLog('');
|
|
147
|
+
userLog(separator);
|
|
148
|
+
userLog(' ADMIN API KEY (save this — it will NOT be shown again)');
|
|
149
|
+
userLog('');
|
|
150
|
+
userLog(` ${apiKeyResolution.rawKey}`);
|
|
151
|
+
userLog('');
|
|
152
|
+
userLog(` Use via header: x-api-key: <key>`);
|
|
153
|
+
userLog(` Or via header: Authorization: Bearer <key>`);
|
|
154
|
+
if (options.dataDirectory) {
|
|
155
|
+
userLog('');
|
|
156
|
+
userLog(' The key hash has been persisted — on next restart, the same key will be used.');
|
|
157
|
+
}
|
|
158
|
+
userLog('');
|
|
159
|
+
userLog(' To disable admin auth: --disable-admin-api-key or AZTEC_DISABLE_ADMIN_API_KEY=true');
|
|
160
|
+
userLog(separator);
|
|
161
|
+
userLog('');
|
|
162
|
+
}
|
|
110
163
|
}
|
|
111
164
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { type ArchiverConfig, archiverConfigMappings } from '@aztec/archiver/config';
|
|
2
|
-
import {
|
|
3
|
-
import { blobSinkConfigMappings } from '@aztec/blob-sink/server';
|
|
2
|
+
import { blobClientConfigMapping } from '@aztec/blob-client/client/config';
|
|
4
3
|
import { botConfigMappings } from '@aztec/bot/config';
|
|
5
|
-
import {
|
|
4
|
+
import { l1ContractsConfigMappings } from '@aztec/ethereum/config';
|
|
5
|
+
import { l1ContractAddressesMapping } from '@aztec/ethereum/l1-contract-addresses';
|
|
6
|
+
import { l1ReaderConfigMappings } from '@aztec/ethereum/l1-reader';
|
|
6
7
|
import { getKeys } from '@aztec/foundation/collection';
|
|
7
8
|
import {
|
|
8
9
|
type ConfigMapping,
|
|
@@ -14,12 +15,13 @@ import {
|
|
|
14
15
|
import { dataConfigMappings } from '@aztec/kv-store/config';
|
|
15
16
|
import { sharedNodeConfigMappings } from '@aztec/node-lib/config';
|
|
16
17
|
import { bootnodeConfigMappings, p2pConfigMappings } from '@aztec/p2p/config';
|
|
17
|
-
import { proverAgentConfigMappings, proverBrokerConfigMappings } from '@aztec/prover-client/broker';
|
|
18
|
+
import { proverAgentConfigMappings, proverBrokerConfigMappings } from '@aztec/prover-client/broker/config';
|
|
18
19
|
import { proverNodeConfigMappings } from '@aztec/prover-node/config';
|
|
19
20
|
import { allPxeConfigMappings } from '@aztec/pxe/config';
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
21
|
+
import { sequencerClientConfigMappings } from '@aztec/sequencer-client/config';
|
|
22
|
+
import { chainConfigMappings, nodeRpcConfigMappings } from '@aztec/stdlib/config';
|
|
23
|
+
import { telemetryClientConfigMappings } from '@aztec/telemetry-client/config';
|
|
24
|
+
import { worldStateConfigMappings } from '@aztec/world-state/config';
|
|
23
25
|
|
|
24
26
|
import { DefaultMnemonic } from '../mnemonic.js';
|
|
25
27
|
|
|
@@ -103,8 +105,7 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
|
|
|
103
105
|
env: 'NETWORK',
|
|
104
106
|
},
|
|
105
107
|
|
|
106
|
-
configToFlag('--
|
|
107
|
-
configToFlag('--auto-update-url', sharedNodeConfigMappings.autoUpdateUrl),
|
|
108
|
+
configToFlag('--enable-version-check', sharedNodeConfigMappings.enableVersionCheck),
|
|
108
109
|
|
|
109
110
|
configToFlag('--sync-mode', sharedNodeConfigMappings.syncMode),
|
|
110
111
|
configToFlag('--snapshots-urls', sharedNodeConfigMappings.snapshotsUrls),
|
|
@@ -124,14 +125,6 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
|
|
|
124
125
|
defaultValue: DefaultMnemonic,
|
|
125
126
|
env: 'MNEMONIC',
|
|
126
127
|
},
|
|
127
|
-
{
|
|
128
|
-
flag: '--local-network.deployAztecContractsSalt <value>',
|
|
129
|
-
description:
|
|
130
|
-
'Numeric salt for deploying L1 Aztec contracts before starting the local network. Needs mnemonic or private key to be set.',
|
|
131
|
-
env: 'DEPLOY_AZTEC_CONTRACTS_SALT',
|
|
132
|
-
defaultValue: undefined,
|
|
133
|
-
parseVal: (val: string) => (val ? parseInt(val) : undefined),
|
|
134
|
-
},
|
|
135
128
|
],
|
|
136
129
|
API: [
|
|
137
130
|
{
|
|
@@ -148,20 +141,53 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
|
|
|
148
141
|
env: 'AZTEC_ADMIN_PORT',
|
|
149
142
|
parseVal: val => parseInt(val, 10),
|
|
150
143
|
},
|
|
144
|
+
{
|
|
145
|
+
flag: '--admin-api-key-hash <value>',
|
|
146
|
+
description:
|
|
147
|
+
'SHA-256 hex hash of a pre-generated admin API key. When set, the node uses this hash for authentication instead of auto-generating a key.',
|
|
148
|
+
defaultValue: undefined,
|
|
149
|
+
env: 'AZTEC_ADMIN_API_KEY_HASH',
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
flag: '--disable-admin-api-key',
|
|
153
|
+
description:
|
|
154
|
+
'Disable API key authentication on the admin RPC endpoint. By default, a key is auto-generated, displayed once, and its hash is persisted.',
|
|
155
|
+
defaultValue: false,
|
|
156
|
+
env: 'AZTEC_DISABLE_ADMIN_API_KEY',
|
|
157
|
+
// undefined means the flag was passed without a value (boolean toggle), treat as true.
|
|
158
|
+
parseVal: val => val === undefined || val === 'true' || val === '1',
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
flag: '--reset-admin-api-key',
|
|
162
|
+
description:
|
|
163
|
+
'Force-generate a new admin API key, replacing any previously persisted key hash. The new key is displayed once at startup.',
|
|
164
|
+
defaultValue: false,
|
|
165
|
+
env: 'AZTEC_RESET_ADMIN_API_KEY',
|
|
166
|
+
parseVal: val => val === 'true' || val === '1',
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
flag: '--node-debug',
|
|
170
|
+
description: 'Expose debug endpoints (e.g. mineBlock) on the main RPC port',
|
|
171
|
+
defaultValue: false,
|
|
172
|
+
env: 'AZTEC_NODE_DEBUG',
|
|
173
|
+
parseVal: val => val === undefined || val === 'true' || val === '1',
|
|
174
|
+
},
|
|
151
175
|
{
|
|
152
176
|
flag: '--api-prefix <value>',
|
|
153
177
|
description: 'Prefix for API routes on any service that is started',
|
|
154
178
|
defaultValue: '',
|
|
155
179
|
env: 'API_PREFIX',
|
|
156
180
|
},
|
|
181
|
+
configToFlag('--rpcMaxBatchSize', nodeRpcConfigMappings.rpcMaxBatchSize),
|
|
182
|
+
configToFlag('--rpcMaxBodySize', nodeRpcConfigMappings.rpcMaxBodySize),
|
|
157
183
|
],
|
|
158
184
|
ETHEREUM: [
|
|
159
185
|
configToFlag('--l1-chain-id', l1ReaderConfigMappings.l1ChainId),
|
|
160
186
|
// Do not set default for CLI: keep undefined unless provided via flag or env
|
|
161
187
|
configToFlag('--l1-rpc-urls', { ...l1ReaderConfigMappings.l1RpcUrls, defaultValue: undefined }),
|
|
162
|
-
configToFlag('--l1-consensus-host-urls',
|
|
163
|
-
configToFlag('--l1-consensus-host-api-keys',
|
|
164
|
-
configToFlag('--l1-consensus-host-api-key-headers',
|
|
188
|
+
configToFlag('--l1-consensus-host-urls', blobClientConfigMapping.l1ConsensusHostUrls),
|
|
189
|
+
configToFlag('--l1-consensus-host-api-keys', blobClientConfigMapping.l1ConsensusHostApiKeys),
|
|
190
|
+
configToFlag('--l1-consensus-host-api-key-headers', blobClientConfigMapping.l1ConsensusHostApiKeyHeaders),
|
|
165
191
|
],
|
|
166
192
|
'L1 CONTRACTS': [
|
|
167
193
|
configToFlag('--registry-address', l1ContractAddressesMapping.registryAddress),
|
|
@@ -174,7 +200,7 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
|
|
|
174
200
|
'WORLD STATE': [
|
|
175
201
|
configToFlag('--world-state-data-directory', worldStateConfigMappings.worldStateDataDirectory),
|
|
176
202
|
configToFlag('--world-state-db-map-size-kb', worldStateConfigMappings.worldStateDbMapSizeKb),
|
|
177
|
-
configToFlag('--world-state-
|
|
203
|
+
configToFlag('--world-state-checkpoint-history', worldStateConfigMappings.worldStateCheckpointHistory),
|
|
178
204
|
],
|
|
179
205
|
// We can't easily auto-generate node options as they're parts of modules defined below
|
|
180
206
|
'AZTEC NODE': [
|
|
@@ -208,21 +234,13 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
|
|
|
208
234
|
'sequencer',
|
|
209
235
|
omitConfigMappings(sequencerClientConfigMappings, [
|
|
210
236
|
'fakeProcessingDelayPerTxMs',
|
|
237
|
+
'fakeThrowAfterProcessingTxCount',
|
|
211
238
|
'skipCollectingAttestations',
|
|
212
239
|
'skipInvalidateBlockAsProposer',
|
|
213
240
|
'blobSinkMapSizeKb',
|
|
214
241
|
]),
|
|
215
242
|
),
|
|
216
243
|
],
|
|
217
|
-
'BLOB SINK': [
|
|
218
|
-
{
|
|
219
|
-
flag: '--blob-sink',
|
|
220
|
-
description: 'Starts Aztec Blob Sink with options',
|
|
221
|
-
defaultValue: undefined,
|
|
222
|
-
env: undefined,
|
|
223
|
-
},
|
|
224
|
-
...getOptions('blobSink', blobSinkConfigMappings),
|
|
225
|
-
],
|
|
226
244
|
'PROVER NODE': [
|
|
227
245
|
{
|
|
228
246
|
flag: '--prover-node',
|
|
@@ -234,12 +252,8 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
|
|
|
234
252
|
'proverNode',
|
|
235
253
|
omitConfigMappings(proverNodeConfigMappings, [
|
|
236
254
|
// filter out options passed separately
|
|
237
|
-
...getKeys(archiverConfigMappings),
|
|
238
255
|
...getKeys(proverBrokerConfigMappings),
|
|
239
256
|
...getKeys(proverAgentConfigMappings),
|
|
240
|
-
...getKeys(p2pConfigMappings),
|
|
241
|
-
...getKeys(worldStateConfigMappings),
|
|
242
|
-
...getKeys(sharedNodeConfigMappings),
|
|
243
257
|
]),
|
|
244
258
|
),
|
|
245
259
|
],
|
package/src/cli/cli.ts
CHANGED
|
@@ -31,63 +31,18 @@ export function injectAztecCommands(program: Command, userLog: LogFn, debugLogge
|
|
|
31
31
|
|
|
32
32
|
program.configureHelp({ sortSubcommands: true });
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
--contract Use a contract template (default)
|
|
44
|
-
--lib Use a library template
|
|
45
|
-
--bin Use a binary template
|
|
46
|
-
Examples:
|
|
47
|
-
$ aztec init # creates a contract project in current directory
|
|
48
|
-
$ aztec init --lib # creates a library project
|
|
49
|
-
|
|
50
|
-
new <path> [options]: creates a new Noir project in a new directory
|
|
51
|
-
Options:
|
|
52
|
-
--name <name> Name of the package
|
|
53
|
-
--contract Use a contract template (default)
|
|
54
|
-
--lib Use a library template
|
|
55
|
-
--bin Use a binary template
|
|
56
|
-
Examples:
|
|
57
|
-
$ aztec new my-project # creates a contract project in ./my-project
|
|
58
|
-
$ aztec new my-lib --lib # creates a library project in ./my-lib
|
|
59
|
-
|
|
60
|
-
compile [options]: compiles Aztec Noir contracts
|
|
61
|
-
Compiles contracts with nargo compile and then postprocesses them to generate Aztec-specific artifacts including:
|
|
62
|
-
- Transpiled contract artifacts
|
|
63
|
-
- Verification keys
|
|
64
|
-
The compiled contracts will be placed in the target/ directory by default.
|
|
65
|
-
Supports standard nargo compile options.
|
|
66
|
-
|
|
67
|
-
fmt [options]: formats Noir code using nargo fmt
|
|
68
|
-
Example:
|
|
69
|
-
$ aztec fmt # formats all Noir files in the project
|
|
70
|
-
|
|
71
|
-
check [options]: type-checks Noir code without compiling using nargo check
|
|
72
|
-
Example:
|
|
73
|
-
$ aztec check # checks all Noir files in the project
|
|
74
|
-
|
|
75
|
-
test [options]: starts a dockerized TXE node via
|
|
76
|
-
$ aztec start --txe
|
|
77
|
-
then runs
|
|
78
|
-
$ aztec test --silence-warnings --oracle-resolver=<TXE_ADDRESS> [options]
|
|
79
|
-
|
|
80
|
-
lsp: starts the Nargo Language Server Protocol server
|
|
81
|
-
Runs nargo lsp in a Docker container for IDE integration with Noir.
|
|
82
|
-
This command is typically used by IDE extensions and not called directly by users.
|
|
83
|
-
Example:
|
|
84
|
-
$ aztec lsp # starts the LSP server
|
|
85
|
-
|
|
86
|
-
preload-crs: Downloads and caches the Common Reference String (CRS) data required for zero-knowledge proofs.
|
|
87
|
-
Example:
|
|
88
|
-
$ aztec preload-crs # preloads CRS data
|
|
34
|
+
if (process.env.AZTEC_SHELL_WRAPPER) {
|
|
35
|
+
program.addHelpText(
|
|
36
|
+
'after',
|
|
37
|
+
`
|
|
38
|
+
Additional commands:
|
|
39
|
+
|
|
40
|
+
init creates a new Aztec Noir workspace in the current directory.
|
|
41
|
+
new <name> creates a new Aztec Noir workspace in its own directory (or creates a new contract-test crates pair and adds it to the current workspace if run in workspace).
|
|
42
|
+
test [options] starts a TXE and runs "nargo test" using it as the oracle resolver.
|
|
89
43
|
`,
|
|
90
|
-
|
|
44
|
+
);
|
|
45
|
+
}
|
|
91
46
|
|
|
92
47
|
program
|
|
93
48
|
.command('preload-crs')
|