@aztec/aztec 0.0.1-commit.fce3e4f → 0.0.1-commit.ff7989d6c
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 +8 -3
- 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 +50 -13
- 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 +39 -33
- package/dest/cli/cli.d.ts +1 -1
- package/dest/cli/cli.d.ts.map +1 -1
- package/dest/cli/cli.js +4 -37
- 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 +95 -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/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 +1 -1
- package/dest/cli/cmds/start_node.d.ts.map +1 -1
- package/dest/cli/cmds/start_node.js +64 -12
- 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 +4 -4
- 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 +4 -4
- package/dest/cli/util.d.ts +8 -17
- package/dest/cli/util.d.ts.map +1 -1
- package/dest/cli/util.js +13 -8
- package/dest/examples/token.js +5 -5
- 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 +3 -3
- 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 +68 -38
- 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 +53 -16
- package/dest/testing/cheat_codes.d.ts +3 -1
- package/dest/testing/cheat_codes.d.ts.map +1 -1
- 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 +62 -0
- package/dest/testing/index.d.ts +2 -1
- package/dest/testing/index.d.ts.map +1 -1
- package/dest/testing/index.js +1 -0
- package/package.json +37 -35
- package/scripts/aztec.sh +14 -8
- package/src/bin/index.ts +9 -3
- package/src/cli/admin_api_key_store.ts +128 -0
- package/src/cli/aztec_start_action.ts +53 -8
- package/src/cli/aztec_start_options.ts +40 -32
- package/src/cli/cli.ts +4 -37
- package/src/cli/cmds/compile.ts +107 -0
- package/src/cli/cmds/migrate_ha_db.ts +43 -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 +53 -11
- package/src/cli/cmds/start_p2p_bootstrap.ts +3 -3
- package/src/cli/cmds/start_prover_agent.ts +4 -12
- package/src/cli/cmds/start_prover_broker.ts +7 -3
- package/src/cli/util.ts +20 -25
- package/src/examples/token.ts +5 -7
- package/src/examples/util.ts +1 -1
- package/src/local-network/banana_fpc.ts +11 -7
- package/src/local-network/local-network.ts +107 -82
- package/src/testing/anvil_test_watcher.ts +61 -17
- package/src/testing/cheat_codes.ts +3 -2
- package/src/testing/epoch_test_settler.ts +71 -0
- package/src/testing/index.ts +1 -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/scripts/compile.sh +0 -44
- package/src/cli/cmds/start_blob_sink.ts +0 -57
- package/src/cli/cmds/start_prover_node.ts +0 -124
package/dest/bin/index.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
//
|
|
3
3
|
import { injectCommands as injectBuilderCommands } from '@aztec/builder';
|
|
4
4
|
import { injectCommands as injectAztecNodeCommands } from '@aztec/cli/aztec_node';
|
|
5
|
-
import { enrichEnvironmentWithChainName
|
|
5
|
+
import { enrichEnvironmentWithChainName } from '@aztec/cli/config/chain';
|
|
6
|
+
import { enrichEnvironmentWithNetworkConfig } from '@aztec/cli/config/network';
|
|
6
7
|
import { injectCommands as injectContractCommands } from '@aztec/cli/contracts';
|
|
7
8
|
import { injectCommands as injectInfrastructureCommands } from '@aztec/cli/infrastructure';
|
|
8
9
|
import { injectCommands as injectL1Commands } from '@aztec/cli/l1';
|
|
@@ -11,9 +12,11 @@ import { injectCommands as injectValidatorKeysCommands } from '@aztec/cli/valida
|
|
|
11
12
|
import { getActiveNetworkName } from '@aztec/foundation/config';
|
|
12
13
|
import { createConsoleLogger, createLogger } from '@aztec/foundation/log';
|
|
13
14
|
import { Command } from 'commander';
|
|
14
|
-
import {
|
|
15
|
+
import { injectCompileCommand } from '../cli/cmds/compile.js';
|
|
16
|
+
import { injectMigrateCommand } from '../cli/cmds/migrate_ha_db.js';
|
|
15
17
|
import { injectAztecCommands } from '../cli/index.js';
|
|
16
18
|
import { getCliVersion } from '../cli/release_version.js';
|
|
19
|
+
const NETWORK_FLAG = 'network';
|
|
17
20
|
const userLog = createConsoleLogger();
|
|
18
21
|
const debugLogger = createLogger('cli');
|
|
19
22
|
/** CLI & full node main entrypoint */ async function main() {
|
|
@@ -34,7 +37,7 @@ const debugLogger = createLogger('cli');
|
|
|
34
37
|
enrichEnvironmentWithChainName(networkName);
|
|
35
38
|
const cliVersion = getCliVersion();
|
|
36
39
|
let program = new Command('aztec');
|
|
37
|
-
program.description('Aztec command line interface').version(cliVersion);
|
|
40
|
+
program.description('Aztec command line interface').version(cliVersion).enablePositionalOptions();
|
|
38
41
|
program = injectAztecCommands(program, userLog, debugLogger);
|
|
39
42
|
program = injectBuilderCommands(program);
|
|
40
43
|
program = injectContractCommands(program, userLog, debugLogger);
|
|
@@ -43,6 +46,8 @@ const debugLogger = createLogger('cli');
|
|
|
43
46
|
program = injectAztecNodeCommands(program, userLog, debugLogger);
|
|
44
47
|
program = injectMiscCommands(program, userLog);
|
|
45
48
|
program = injectValidatorKeysCommands(program, userLog);
|
|
49
|
+
program = injectCompileCommand(program, userLog);
|
|
50
|
+
program = injectMigrateCommand(program, userLog);
|
|
46
51
|
await program.parseAsync(process.argv);
|
|
47
52
|
}
|
|
48
53
|
main().catch((err)=>{
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
2
|
+
/**
|
|
3
|
+
* Result of resolving the admin API key.
|
|
4
|
+
* Contains the SHA-256 hex hash of the API key to be used by the auth middleware,
|
|
5
|
+
* and optionally the raw key when newly generated (so the caller can display it).
|
|
6
|
+
*/
|
|
7
|
+
export interface AdminApiKeyResolution {
|
|
8
|
+
/** The SHA-256 hash of the API key. */
|
|
9
|
+
apiKeyHash: Buffer;
|
|
10
|
+
/**
|
|
11
|
+
* The raw API key, only present when a new key was generated during this call.
|
|
12
|
+
* The caller MUST display this to the operator — it will not be stored or returned again.
|
|
13
|
+
*/
|
|
14
|
+
rawKey?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ResolveAdminApiKeyOptions {
|
|
17
|
+
/** SHA-256 hex hash of a pre-generated API key. When set, the node uses this hash directly. */
|
|
18
|
+
adminApiKeyHash?: string;
|
|
19
|
+
/** If true, disable admin API key auth entirely. */
|
|
20
|
+
disableAdminApiKey?: boolean;
|
|
21
|
+
/** If true, force-generate a new key even if one is already persisted. */
|
|
22
|
+
resetAdminApiKey?: boolean;
|
|
23
|
+
/** Root data directory for persistent storage. */
|
|
24
|
+
dataDirectory?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Resolves the admin API key for the admin RPC endpoint.
|
|
28
|
+
*
|
|
29
|
+
* Strategy:
|
|
30
|
+
* 1. If opt-out flag is set (`disableAdminApiKey`), return undefined (no auth).
|
|
31
|
+
* 2. If a pre-generated hash is provided (`adminApiKeyHash`), use it directly.
|
|
32
|
+
* 3. If a data directory exists, look for a persisted hash file
|
|
33
|
+
* at `<dataDirectory>/admin/api_key_hash`:
|
|
34
|
+
* - If `resetAdminApiKey` is set, skip loading and force-generate a new key.
|
|
35
|
+
* - Found: use the stored hash (operator already saved the key from first run).
|
|
36
|
+
* - Not found: auto-generate a random key, display it once, persist the hash.
|
|
37
|
+
* 3. If no data directory: generate a random key
|
|
38
|
+
* each run and display it (cannot persist).
|
|
39
|
+
*
|
|
40
|
+
* @param options - The options for resolving the admin API key.
|
|
41
|
+
* @param log - Logger for outputting the key and status messages.
|
|
42
|
+
* @returns The resolved API key hash, or undefined if auth is disabled.
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveAdminApiKey(options: ResolveAdminApiKeyOptions, log: Logger): Promise<AdminApiKeyResolution | undefined>;
|
|
45
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWRtaW5fYXBpX2tleV9zdG9yZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NsaS9hZG1pbl9hcGlfa2V5X3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBU3BEOzs7O0dBSUc7QUFDSCxNQUFNLFdBQVcscUJBQXFCO0lBQ3BDLHVDQUF1QztJQUN2QyxVQUFVLEVBQUUsTUFBTSxDQUFDO0lBQ25COzs7T0FHRztJQUNILE1BQU0sQ0FBQyxFQUFFLE1BQU0sQ0FBQztDQUNqQjtBQUVELE1BQU0sV0FBVyx5QkFBeUI7SUFDeEMsK0ZBQStGO0lBQy9GLGVBQWUsQ0FBQyxFQUFFLE1BQU0sQ0FBQztJQUN6QixvREFBb0Q7SUFDcEQsa0JBQWtCLENBQUMsRUFBRSxPQUFPLENBQUM7SUFDN0IsMEVBQTBFO0lBQzFFLGdCQUFnQixDQUFDLEVBQUUsT0FBTyxDQUFDO0lBQzNCLGtEQUFrRDtJQUNsRCxhQUFhLENBQUMsRUFBRSxNQUFNLENBQUM7Q0FDeEI7QUFFRDs7Ozs7Ozs7Ozs7Ozs7Ozs7R0FpQkc7QUFDSCx3QkFBc0Isa0JBQWtCLENBQ3RDLE9BQU8sRUFBRSx5QkFBeUIsRUFDbEMsR0FBRyxFQUFFLE1BQU0sR0FDVixPQUFPLENBQUMscUJBQXFCLEdBQUcsU0FBUyxDQUFDLENBMkQ1QyJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin_api_key_store.d.ts","sourceRoot":"","sources":["../../src/cli/admin_api_key_store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AASpD;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,yBAAyB;IACxC,+FAA+F;IAC/F,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oDAAoD;IACpD,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,0EAA0E;IAC1E,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,kDAAkD;IAClD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,yBAAyB,EAClC,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CA2D5C"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
2
|
+
import { sha256Hash } from '@aztec/foundation/json-rpc/server';
|
|
3
|
+
import { promises as fs } from 'fs';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
/** Subdirectory under dataDirectory for admin API key storage. */ const ADMIN_STORE_DIR = 'admin';
|
|
6
|
+
const HASH_FILE_NAME = 'api_key_hash';
|
|
7
|
+
/**
|
|
8
|
+
* Resolves the admin API key for the admin RPC endpoint.
|
|
9
|
+
*
|
|
10
|
+
* Strategy:
|
|
11
|
+
* 1. If opt-out flag is set (`disableAdminApiKey`), return undefined (no auth).
|
|
12
|
+
* 2. If a pre-generated hash is provided (`adminApiKeyHash`), use it directly.
|
|
13
|
+
* 3. If a data directory exists, look for a persisted hash file
|
|
14
|
+
* at `<dataDirectory>/admin/api_key_hash`:
|
|
15
|
+
* - If `resetAdminApiKey` is set, skip loading and force-generate a new key.
|
|
16
|
+
* - Found: use the stored hash (operator already saved the key from first run).
|
|
17
|
+
* - Not found: auto-generate a random key, display it once, persist the hash.
|
|
18
|
+
* 3. If no data directory: generate a random key
|
|
19
|
+
* each run and display it (cannot persist).
|
|
20
|
+
*
|
|
21
|
+
* @param options - The options for resolving the admin API key.
|
|
22
|
+
* @param log - Logger for outputting the key and status messages.
|
|
23
|
+
* @returns The resolved API key hash, or undefined if auth is disabled.
|
|
24
|
+
*/ export async function resolveAdminApiKey(options, log) {
|
|
25
|
+
// Operator explicitly opted out of admin auth
|
|
26
|
+
if (options.disableAdminApiKey) {
|
|
27
|
+
log.warn('Admin API key authentication is DISABLED (--disable-admin-api-key / AZTEC_DISABLE_ADMIN_API_KEY)');
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
// Operator provided a pre-generated hash (e.g. via AZTEC_ADMIN_API_KEY_HASH env var)
|
|
31
|
+
if (options.adminApiKeyHash) {
|
|
32
|
+
const hex = options.adminApiKeyHash.trim();
|
|
33
|
+
if (hex.length !== 64 || !/^[0-9a-f]{64}$/.test(hex)) {
|
|
34
|
+
throw new Error(`Invalid admin API key hash: expected 64-char hex string, got "${hex}"`);
|
|
35
|
+
}
|
|
36
|
+
log.info('Admin API key authentication enabled (using pre-configured key hash)');
|
|
37
|
+
return {
|
|
38
|
+
apiKeyHash: Buffer.from(hex, 'hex')
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
// Persistent storage available, load or generate key
|
|
42
|
+
if (options.dataDirectory) {
|
|
43
|
+
const adminDir = join(options.dataDirectory, ADMIN_STORE_DIR);
|
|
44
|
+
const hashFilePath = join(adminDir, HASH_FILE_NAME);
|
|
45
|
+
// Unless a reset is forced, try to load the existing hash from disk
|
|
46
|
+
if (!options.resetAdminApiKey) {
|
|
47
|
+
try {
|
|
48
|
+
const storedHash = (await fs.readFile(hashFilePath, 'utf-8')).trim();
|
|
49
|
+
if (storedHash.length === 64) {
|
|
50
|
+
log.info('Admin API key authentication enabled (loaded stored key hash from disk)');
|
|
51
|
+
return {
|
|
52
|
+
apiKeyHash: Buffer.from(storedHash, 'hex')
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
log.warn(`Invalid stored admin API key hash at ${hashFilePath}, regenerating...`);
|
|
56
|
+
} catch (err) {
|
|
57
|
+
if (err.code !== 'ENOENT') {
|
|
58
|
+
log.warn(`Failed to read admin API key hash from ${hashFilePath}: ${err.message}`);
|
|
59
|
+
}
|
|
60
|
+
// File doesn't exist — fall through to generate
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
log.warn('Admin API key reset requested — generating a new key');
|
|
64
|
+
}
|
|
65
|
+
// Generate a new key, persist the hash, and return the raw key for the caller to display
|
|
66
|
+
const { rawKey, hash } = generateApiKey();
|
|
67
|
+
await fs.mkdir(adminDir, {
|
|
68
|
+
recursive: true
|
|
69
|
+
});
|
|
70
|
+
await fs.writeFile(hashFilePath, hash.toString('hex'), 'utf-8');
|
|
71
|
+
// Set restrictive permissions (owner read/write only)
|
|
72
|
+
await fs.chmod(hashFilePath, 0o600);
|
|
73
|
+
log.info('Admin API key authentication enabled (new key generated and hash persisted to disk)');
|
|
74
|
+
return {
|
|
75
|
+
apiKeyHash: hash,
|
|
76
|
+
rawKey
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
// No data directory, generate a temporary key per session
|
|
80
|
+
const { rawKey, hash } = generateApiKey();
|
|
81
|
+
log.warn('No data directory configured — admin API key cannot be persisted.');
|
|
82
|
+
log.warn('A temporary key has been generated for this session only.');
|
|
83
|
+
return {
|
|
84
|
+
apiKeyHash: hash,
|
|
85
|
+
rawKey
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Generates a cryptographically random API key and its SHA-256 hash.
|
|
90
|
+
* @returns The raw key (hex string) and its SHA-256 hash as a Buffer.
|
|
91
|
+
*/ function generateApiKey() {
|
|
92
|
+
const rawKey = randomBytes(32).toString('hex');
|
|
93
|
+
const hash = sha256Hash(rawKey);
|
|
94
|
+
return {
|
|
95
|
+
rawKey,
|
|
96
|
+
hash
|
|
97
|
+
};
|
|
98
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
2
2
|
export declare function aztecStart(options: any, userLog: LogFn, debugLogger: Logger): Promise<void>;
|
|
3
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXp0ZWNfc3RhcnRfYWN0aW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY2xpL2F6dGVjX3N0YXJ0X2FjdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFNQSxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFhM0Qsd0JBQXNCLFVBQVUsQ0FBQyxPQUFPLEVBQUUsR0FBRyxFQUFFLE9BQU8sRUFBRSxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0saUJBd0lqRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aztec_start_action.d.ts","sourceRoot":"","sources":["../../src/cli/aztec_start_action.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"aztec_start_action.d.ts","sourceRoot":"","sources":["../../src/cli/aztec_start_action.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAa3D,wBAAsB,UAAU,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,iBAwIjF"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { createNamespacedSafeJsonRpcServer, startHttpRpcServer } from '@aztec/foundation/json-rpc/server';
|
|
1
|
+
import { createNamespacedSafeJsonRpcServer, getApiKeyAuthMiddleware, startHttpRpcServer } from '@aztec/foundation/json-rpc/server';
|
|
2
2
|
import { AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
|
|
3
3
|
import { getVersioningMiddleware } from '@aztec/stdlib/versioning';
|
|
4
4
|
import { getOtelJsonRpcPropagationMiddleware } from '@aztec/telemetry-client';
|
|
5
5
|
import { createLocalNetwork } from '../local-network/index.js';
|
|
6
6
|
import { github, splash } from '../splash.js';
|
|
7
|
+
import { resolveAdminApiKey } from './admin_api_key_store.js';
|
|
7
8
|
import { getCliVersion } from './release_version.js';
|
|
8
9
|
import { extractNamespacedOptions, installSignalHandlers } from './util.js';
|
|
9
10
|
import { getVersions } from './versioning.js';
|
|
@@ -22,9 +23,13 @@ export async function aztecStart(options, userLog, debugLogger) {
|
|
|
22
23
|
const { node, stop } = await createLocalNetwork({
|
|
23
24
|
l1Mnemonic: localNetwork.l1Mnemonic,
|
|
24
25
|
l1RpcUrls: options.l1RpcUrls,
|
|
25
|
-
deployAztecContractsSalt: localNetwork.deployAztecContractsSalt,
|
|
26
26
|
testAccounts: localNetwork.testAccounts,
|
|
27
|
-
realProofs: false
|
|
27
|
+
realProofs: false,
|
|
28
|
+
// Setting the epoch duration to 2 by default for local network. This allows the epoch to be "proven" faster, so
|
|
29
|
+
// the users can consume out hash without having to wait for a long time.
|
|
30
|
+
// Note: We are not proving anything in the local network (realProofs == false). But in `createLocalNetwork`,
|
|
31
|
+
// the EpochTestSettler will set the out hash to the outbox when an epoch is complete.
|
|
32
|
+
aztecEpochDuration: 2
|
|
28
33
|
}, userLog);
|
|
29
34
|
// Start Node and PXE JSON-RPC server
|
|
30
35
|
signalHandlers.push(stop);
|
|
@@ -33,18 +38,16 @@ export async function aztecStart(options, userLog, debugLogger) {
|
|
|
33
38
|
AztecNodeApiSchema
|
|
34
39
|
];
|
|
35
40
|
} else {
|
|
41
|
+
// Route --prover-node through startNode
|
|
42
|
+
if (options.proverNode && !options.node) {
|
|
43
|
+
options.node = true;
|
|
44
|
+
}
|
|
36
45
|
if (options.node) {
|
|
37
46
|
const { startNode } = await import('./cmds/start_node.js');
|
|
38
47
|
({ config } = await startNode(options, signalHandlers, services, adminServices, userLog));
|
|
39
48
|
} else if (options.bot) {
|
|
40
49
|
const { startBot } = await import('./cmds/start_bot.js');
|
|
41
50
|
await startBot(options, signalHandlers, services, userLog);
|
|
42
|
-
} else if (options.proverNode) {
|
|
43
|
-
const { startProverNode } = await import('./cmds/start_prover_node.js');
|
|
44
|
-
({ config } = await startProverNode(options, signalHandlers, services, userLog));
|
|
45
|
-
} else if (options.blobSink) {
|
|
46
|
-
const { startBlobSink } = await import('./cmds/start_blob_sink.js');
|
|
47
|
-
await startBlobSink(options, signalHandlers, userLog);
|
|
48
51
|
} else if (options.archiver) {
|
|
49
52
|
const { startArchiver } = await import('./cmds/start_archiver.js');
|
|
50
53
|
({ config } = await startArchiver(options, signalHandlers, services));
|
|
@@ -89,13 +92,26 @@ export async function aztecStart(options, userLog, debugLogger) {
|
|
|
89
92
|
}
|
|
90
93
|
// If there are any admin services, start a separate JSON-RPC server for them
|
|
91
94
|
if (Object.entries(adminServices).length > 0) {
|
|
95
|
+
const adminMiddlewares = [
|
|
96
|
+
getOtelJsonRpcPropagationMiddleware(),
|
|
97
|
+
getVersioningMiddleware(versions)
|
|
98
|
+
];
|
|
99
|
+
// Resolve the admin API key (auto-generated and persisted, or opt-out)
|
|
100
|
+
const apiKeyResolution = await resolveAdminApiKey({
|
|
101
|
+
adminApiKeyHash: options.adminApiKeyHash,
|
|
102
|
+
disableAdminApiKey: options.disableAdminApiKey,
|
|
103
|
+
resetAdminApiKey: options.resetAdminApiKey,
|
|
104
|
+
dataDirectory: options.dataDirectory
|
|
105
|
+
}, debugLogger);
|
|
106
|
+
if (apiKeyResolution) {
|
|
107
|
+
adminMiddlewares.unshift(getApiKeyAuthMiddleware(apiKeyResolution.apiKeyHash));
|
|
108
|
+
} else {
|
|
109
|
+
debugLogger.warn('No admin API key set — admin endpoint is unauthenticated');
|
|
110
|
+
}
|
|
92
111
|
const rpcServer = createNamespacedSafeJsonRpcServer(adminServices, {
|
|
93
112
|
http200OnError: false,
|
|
94
113
|
log: debugLogger,
|
|
95
|
-
middlewares:
|
|
96
|
-
getOtelJsonRpcPropagationMiddleware(),
|
|
97
|
-
getVersioningMiddleware(versions)
|
|
98
|
-
],
|
|
114
|
+
middlewares: adminMiddlewares,
|
|
99
115
|
maxBatchSize: options.rpcMaxBatchSize,
|
|
100
116
|
maxBodySizeBytes: options.rpcMaxBodySize
|
|
101
117
|
});
|
|
@@ -103,5 +119,26 @@ export async function aztecStart(options, userLog, debugLogger) {
|
|
|
103
119
|
port: options.adminPort
|
|
104
120
|
});
|
|
105
121
|
debugLogger.info(`Aztec Server admin API listening on port ${port}`, versions);
|
|
122
|
+
// Display the API key after the server has started
|
|
123
|
+
// Uses userLog which is never filtered by LOG_LEVEL.
|
|
124
|
+
if (apiKeyResolution?.rawKey) {
|
|
125
|
+
const separator = '='.repeat(70);
|
|
126
|
+
userLog('');
|
|
127
|
+
userLog(separator);
|
|
128
|
+
userLog(' ADMIN API KEY (save this — it will NOT be shown again)');
|
|
129
|
+
userLog('');
|
|
130
|
+
userLog(` ${apiKeyResolution.rawKey}`);
|
|
131
|
+
userLog('');
|
|
132
|
+
userLog(` Use via header: x-api-key: <key>`);
|
|
133
|
+
userLog(` Or via header: Authorization: Bearer <key>`);
|
|
134
|
+
if (options.dataDirectory) {
|
|
135
|
+
userLog('');
|
|
136
|
+
userLog(' The key hash has been persisted — on next restart, the same key will be used.');
|
|
137
|
+
}
|
|
138
|
+
userLog('');
|
|
139
|
+
userLog(' To disable admin auth: --disable-admin-api-key or AZTEC_DISABLE_ADMIN_API_KEY=true');
|
|
140
|
+
userLog(separator);
|
|
141
|
+
userLog('');
|
|
142
|
+
}
|
|
106
143
|
}
|
|
107
144
|
}
|
|
@@ -14,4 +14,4 @@ export declare const NETWORK_FLAG = "network";
|
|
|
14
14
|
export declare const aztecStartOptions: {
|
|
15
15
|
[key: string]: AztecStartOption[];
|
|
16
16
|
};
|
|
17
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXp0ZWNfc3RhcnRfb3B0aW9ucy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NsaS9henRlY19zdGFydF9vcHRpb25zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQU9BLE9BQU8sRUFDTCxLQUFLLGFBQWEsRUFDbEIsS0FBSyxNQUFNLEVBSVosTUFBTSwwQkFBMEIsQ0FBQztBQWVsQyxNQUFNLFdBQVcsZ0JBQWdCO0lBQy9CLElBQUksRUFBRSxNQUFNLENBQUM7SUFDYixXQUFXLEVBQUUsTUFBTSxDQUFDO0lBQ3BCLFlBQVksRUFBRSxHQUFHLENBQUM7SUFDbEIsWUFBWSxDQUFDLEVBQUUsQ0FBQyxHQUFHLEVBQUUsR0FBRyxLQUFLLE1BQU0sQ0FBQztJQUNwQyxHQUFHLEVBQUUsTUFBTSxHQUFHLFNBQVMsQ0FBQztJQUN4QixRQUFRLENBQUMsRUFBRSxNQUFNLEVBQUUsQ0FBQztJQUNwQixRQUFRLENBQUMsRUFBRSxDQUFDLEdBQUcsRUFBRSxNQUFNLEtBQUssR0FBRyxDQUFDO0NBQ2pDO0FBRUQsZUFBTyxNQUFNLFVBQVUsMEZBb0J0QixDQUFDO0FBdUJGLGVBQU8sTUFBTSxnQkFBZ0IsVUFZNUIsQ0FBQztBQUVGLGVBQU8sTUFBTSxZQUFZLFlBQVksQ0FBQztBQUd0QyxlQUFPLE1BQU0saUJBQWlCLEVBQUU7SUFBRSxDQUFDLEdBQUcsRUFBRSxNQUFNLEdBQUcsZ0JBQWdCLEVBQUUsQ0FBQTtDQXVPbEUsQ0FBQyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aztec_start_options.d.ts","sourceRoot":"","sources":["../../src/cli/aztec_start_options.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"aztec_start_options.d.ts","sourceRoot":"","sources":["../../src/cli/aztec_start_options.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,MAAM,EAIZ,MAAM,0BAA0B,CAAC;AAelC,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,GAAG,CAAC;IAClB,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM,CAAC;IACpC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,GAAG,CAAC;CACjC;AAED,eAAO,MAAM,UAAU,0FAoBtB,CAAC;AAuBF,eAAO,MAAM,gBAAgB,UAY5B,CAAC;AAEF,eAAO,MAAM,YAAY,YAAY,CAAC;AAGtC,eAAO,MAAM,iBAAiB,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAAA;CAuOlE,CAAC"}
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { 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 { booleanConfigHelper, isBooleanConfigValue, omitConfigMappings } from '@aztec/foundation/config';
|
|
8
9
|
import { dataConfigMappings } from '@aztec/kv-store/config';
|
|
9
10
|
import { sharedNodeConfigMappings } from '@aztec/node-lib/config';
|
|
10
11
|
import { bootnodeConfigMappings, p2pConfigMappings } from '@aztec/p2p/config';
|
|
11
|
-
import { proverAgentConfigMappings, proverBrokerConfigMappings } from '@aztec/prover-client/broker';
|
|
12
|
+
import { proverAgentConfigMappings, proverBrokerConfigMappings } from '@aztec/prover-client/broker/config';
|
|
12
13
|
import { proverNodeConfigMappings } from '@aztec/prover-node/config';
|
|
13
14
|
import { allPxeConfigMappings } from '@aztec/pxe/config';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
15
|
+
import { sequencerClientConfigMappings } from '@aztec/sequencer-client/config';
|
|
16
|
+
import { chainConfigMappings, nodeRpcConfigMappings } from '@aztec/stdlib/config';
|
|
17
|
+
import { telemetryClientConfigMappings } from '@aztec/telemetry-client/config';
|
|
18
|
+
import { worldStateConfigMappings } from '@aztec/world-state/config';
|
|
17
19
|
import { DefaultMnemonic } from '../mnemonic.js';
|
|
18
20
|
export const getOptions = (namespace, configMappings)=>{
|
|
19
21
|
const options = [];
|
|
@@ -92,13 +94,6 @@ export const aztecStartOptions = {
|
|
|
92
94
|
description: 'Mnemonic for L1 accounts. Will be used ',
|
|
93
95
|
defaultValue: DefaultMnemonic,
|
|
94
96
|
env: 'MNEMONIC'
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
flag: '--local-network.deployAztecContractsSalt <value>',
|
|
98
|
-
description: 'Numeric salt for deploying L1 Aztec contracts before starting the local network. Needs mnemonic or private key to be set.',
|
|
99
|
-
env: 'DEPLOY_AZTEC_CONTRACTS_SALT',
|
|
100
|
-
defaultValue: undefined,
|
|
101
|
-
parseVal: (val)=>val ? parseInt(val) : undefined
|
|
102
97
|
}
|
|
103
98
|
],
|
|
104
99
|
API: [
|
|
@@ -116,12 +111,35 @@ export const aztecStartOptions = {
|
|
|
116
111
|
env: 'AZTEC_ADMIN_PORT',
|
|
117
112
|
parseVal: (val)=>parseInt(val, 10)
|
|
118
113
|
},
|
|
114
|
+
{
|
|
115
|
+
flag: '--admin-api-key-hash <value>',
|
|
116
|
+
description: '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.',
|
|
117
|
+
defaultValue: undefined,
|
|
118
|
+
env: 'AZTEC_ADMIN_API_KEY_HASH'
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
flag: '--disable-admin-api-key',
|
|
122
|
+
description: 'Disable API key authentication on the admin RPC endpoint. By default, a key is auto-generated, displayed once, and its hash is persisted.',
|
|
123
|
+
defaultValue: false,
|
|
124
|
+
env: 'AZTEC_DISABLE_ADMIN_API_KEY',
|
|
125
|
+
// undefined means the flag was passed without a value (boolean toggle), treat as true.
|
|
126
|
+
parseVal: (val)=>val === undefined || val === 'true' || val === '1'
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
flag: '--reset-admin-api-key',
|
|
130
|
+
description: 'Force-generate a new admin API key, replacing any previously persisted key hash. The new key is displayed once at startup.',
|
|
131
|
+
defaultValue: false,
|
|
132
|
+
env: 'AZTEC_RESET_ADMIN_API_KEY',
|
|
133
|
+
parseVal: (val)=>val === 'true' || val === '1'
|
|
134
|
+
},
|
|
119
135
|
{
|
|
120
136
|
flag: '--api-prefix <value>',
|
|
121
137
|
description: 'Prefix for API routes on any service that is started',
|
|
122
138
|
defaultValue: '',
|
|
123
139
|
env: 'API_PREFIX'
|
|
124
|
-
}
|
|
140
|
+
},
|
|
141
|
+
configToFlag('--rpcMaxBatchSize', nodeRpcConfigMappings.rpcMaxBatchSize),
|
|
142
|
+
configToFlag('--rpcMaxBodySize', nodeRpcConfigMappings.rpcMaxBodySize)
|
|
125
143
|
],
|
|
126
144
|
ETHEREUM: [
|
|
127
145
|
configToFlag('--l1-chain-id', l1ReaderConfigMappings.l1ChainId),
|
|
@@ -130,9 +148,9 @@ export const aztecStartOptions = {
|
|
|
130
148
|
...l1ReaderConfigMappings.l1RpcUrls,
|
|
131
149
|
defaultValue: undefined
|
|
132
150
|
}),
|
|
133
|
-
configToFlag('--l1-consensus-host-urls',
|
|
134
|
-
configToFlag('--l1-consensus-host-api-keys',
|
|
135
|
-
configToFlag('--l1-consensus-host-api-key-headers',
|
|
151
|
+
configToFlag('--l1-consensus-host-urls', blobClientConfigMapping.l1ConsensusHostUrls),
|
|
152
|
+
configToFlag('--l1-consensus-host-api-keys', blobClientConfigMapping.l1ConsensusHostApiKeys),
|
|
153
|
+
configToFlag('--l1-consensus-host-api-key-headers', blobClientConfigMapping.l1ConsensusHostApiKeyHeaders)
|
|
136
154
|
],
|
|
137
155
|
'L1 CONTRACTS': [
|
|
138
156
|
configToFlag('--registry-address', l1ContractAddressesMapping.registryAddress),
|
|
@@ -145,7 +163,7 @@ export const aztecStartOptions = {
|
|
|
145
163
|
'WORLD STATE': [
|
|
146
164
|
configToFlag('--world-state-data-directory', worldStateConfigMappings.worldStateDataDirectory),
|
|
147
165
|
configToFlag('--world-state-db-map-size-kb', worldStateConfigMappings.worldStateDbMapSizeKb),
|
|
148
|
-
configToFlag('--world-state-
|
|
166
|
+
configToFlag('--world-state-checkpoint-history', worldStateConfigMappings.worldStateCheckpointHistory)
|
|
149
167
|
],
|
|
150
168
|
// We can't easily auto-generate node options as they're parts of modules defined below
|
|
151
169
|
'AZTEC NODE': [
|
|
@@ -174,20 +192,12 @@ export const aztecStartOptions = {
|
|
|
174
192
|
},
|
|
175
193
|
...getOptions('sequencer', omitConfigMappings(sequencerClientConfigMappings, [
|
|
176
194
|
'fakeProcessingDelayPerTxMs',
|
|
195
|
+
'fakeThrowAfterProcessingTxCount',
|
|
177
196
|
'skipCollectingAttestations',
|
|
178
197
|
'skipInvalidateBlockAsProposer',
|
|
179
198
|
'blobSinkMapSizeKb'
|
|
180
199
|
]))
|
|
181
200
|
],
|
|
182
|
-
'BLOB SINK': [
|
|
183
|
-
{
|
|
184
|
-
flag: '--blob-sink',
|
|
185
|
-
description: 'Starts Aztec Blob Sink with options',
|
|
186
|
-
defaultValue: undefined,
|
|
187
|
-
env: undefined
|
|
188
|
-
},
|
|
189
|
-
...getOptions('blobSink', blobSinkConfigMappings)
|
|
190
|
-
],
|
|
191
201
|
'PROVER NODE': [
|
|
192
202
|
{
|
|
193
203
|
flag: '--prover-node',
|
|
@@ -197,12 +207,8 @@ export const aztecStartOptions = {
|
|
|
197
207
|
},
|
|
198
208
|
...getOptions('proverNode', omitConfigMappings(proverNodeConfigMappings, [
|
|
199
209
|
// filter out options passed separately
|
|
200
|
-
...getKeys(archiverConfigMappings),
|
|
201
210
|
...getKeys(proverBrokerConfigMappings),
|
|
202
|
-
...getKeys(proverAgentConfigMappings)
|
|
203
|
-
...getKeys(p2pConfigMappings),
|
|
204
|
-
...getKeys(worldStateConfigMappings),
|
|
205
|
-
...getKeys(sharedNodeConfigMappings)
|
|
211
|
+
...getKeys(proverAgentConfigMappings)
|
|
206
212
|
]))
|
|
207
213
|
],
|
|
208
214
|
'PROVER BROKER': [
|
package/dest/cli/cli.d.ts
CHANGED
|
@@ -6,4 +6,4 @@ import { Command } from 'commander';
|
|
|
6
6
|
* @param debugLogger - logger for logging debug messages.
|
|
7
7
|
*/
|
|
8
8
|
export declare function injectAztecCommands(program: Command, userLog: LogFn, debugLogger: Logger): Command;
|
|
9
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xpLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY2xpL2NsaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFFM0QsT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLFdBQVcsQ0FBQztBQUtwQzs7OztHQUlHO0FBQ0gsd0JBQWdCLG1CQUFtQixDQUFDLE9BQU8sRUFBRSxPQUFPLEVBQUUsT0FBTyxFQUFFLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0EyQ2xHIn0=
|
package/dest/cli/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli/cli.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli/cli.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CA2ClG"}
|
package/dest/cli/cli.js
CHANGED
|
@@ -22,44 +22,11 @@ import { addOptions, printAztecStartHelpText } from './util.js';
|
|
|
22
22
|
});
|
|
23
23
|
if (process.env.AZTEC_SHELL_WRAPPER) {
|
|
24
24
|
program.addHelpText('after', `
|
|
25
|
+
Additional commands:
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Options:
|
|
30
|
-
--name <name> Name of the package
|
|
31
|
-
--contract Use a contract template (default)
|
|
32
|
-
--lib Use a library template
|
|
33
|
-
--bin Use a binary template
|
|
34
|
-
Examples:
|
|
35
|
-
$ aztec init # creates a contract project in current directory
|
|
36
|
-
$ aztec init --lib # creates a library project
|
|
37
|
-
|
|
38
|
-
new <path> [options]: creates a new Noir project in a new directory
|
|
39
|
-
Options:
|
|
40
|
-
--name <name> Name of the package
|
|
41
|
-
--contract Use a contract template (default)
|
|
42
|
-
--lib Use a library template
|
|
43
|
-
--bin Use a binary template
|
|
44
|
-
Examples:
|
|
45
|
-
$ aztec new my-project # creates a contract project in ./my-project
|
|
46
|
-
$ aztec new my-lib --lib # creates a library project in ./my-lib
|
|
47
|
-
|
|
48
|
-
compile [options]: compiles Aztec Noir contracts
|
|
49
|
-
Compiles contracts with nargo compile and then postprocesses them to generate Aztec-specific artifacts including:
|
|
50
|
-
- Transpiled contract artifacts
|
|
51
|
-
- Verification keys
|
|
52
|
-
The compiled contracts will be placed in the target/ directory by default.
|
|
53
|
-
Supports standard nargo compile options.
|
|
54
|
-
|
|
55
|
-
test [options]: starts a dockerized TXE node via
|
|
56
|
-
$ aztec start --txe
|
|
57
|
-
then runs
|
|
58
|
-
$ aztec test --silence-warnings --oracle-resolver=<TXE_ADDRESS> [options]
|
|
59
|
-
|
|
60
|
-
preload-crs: Downloads and caches the Common Reference String (CRS) data required for zero-knowledge proofs.
|
|
61
|
-
Example:
|
|
62
|
-
$ aztec preload-crs # preloads CRS data
|
|
27
|
+
init [folder] [options] creates a new Aztec Noir project.
|
|
28
|
+
new <path> [options] creates a new Aztec Noir project in a new directory.
|
|
29
|
+
test [options] starts a TXE and runs "nargo test" using it as the oracle resolver.
|
|
63
30
|
`);
|
|
64
31
|
}
|
|
65
32
|
program.command('preload-crs').description('Preload the points data needed for proving and verifying').action(async (options)=>{
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
2
|
+
import type { Command } from 'commander';
|
|
3
|
+
export declare function injectCompileCommand(program: Command, log: LogFn): Command;
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tcGlsZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbWRzL2NvbXBpbGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFHbkQsT0FBTyxLQUFLLEVBQUUsT0FBTyxFQUFFLE1BQU0sV0FBVyxDQUFDO0FBaUZ6Qyx3QkFBZ0Isb0JBQW9CLENBQUMsT0FBTyxFQUFFLE9BQU8sRUFBRSxHQUFHLEVBQUUsS0FBSyxHQUFHLE9BQU8sQ0FzQjFFIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/compile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiFzC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,GAAG,OAAO,CAsB1E"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { execFileSync, spawn } from 'child_process';
|
|
2
|
+
import { readFile, readdir, writeFile } from 'fs/promises';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
/** Spawns a command with inherited stdio and rejects on non-zero exit. */ function run(cmd, args) {
|
|
5
|
+
return new Promise((resolve, reject)=>{
|
|
6
|
+
const child = spawn(cmd, args, {
|
|
7
|
+
stdio: 'inherit'
|
|
8
|
+
});
|
|
9
|
+
child.on('error', reject);
|
|
10
|
+
child.on('close', (code)=>{
|
|
11
|
+
if (code !== 0) {
|
|
12
|
+
reject(new Error(`${cmd} exited with code ${code}`));
|
|
13
|
+
} else {
|
|
14
|
+
resolve();
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
/** Returns paths to contract artifacts in the target directory.
|
|
20
|
+
* Contract artifacts are identified by having a `functions` array in the JSON.
|
|
21
|
+
*/ async function collectContractArtifacts() {
|
|
22
|
+
let files;
|
|
23
|
+
try {
|
|
24
|
+
files = await readdir('target');
|
|
25
|
+
} catch (err) {
|
|
26
|
+
if (err?.code === 'ENOENT') {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
throw new Error(`Failed to read target directory: ${err.message}`);
|
|
30
|
+
}
|
|
31
|
+
const artifacts = [];
|
|
32
|
+
for (const file of files){
|
|
33
|
+
if (!file.endsWith('.json')) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const filePath = join('target', file);
|
|
37
|
+
const content = JSON.parse(await readFile(filePath, 'utf-8'));
|
|
38
|
+
if (Array.isArray(content.functions)) {
|
|
39
|
+
artifacts.push(filePath);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return artifacts;
|
|
43
|
+
}
|
|
44
|
+
/** Strips the `__aztec_nr_internals__` prefix from function names in contract artifacts. */ async function stripInternalPrefixes(artifactPaths) {
|
|
45
|
+
for (const path of artifactPaths){
|
|
46
|
+
const artifact = JSON.parse(await readFile(path, 'utf-8'));
|
|
47
|
+
for (const fn of artifact.functions){
|
|
48
|
+
if (typeof fn.name === 'string') {
|
|
49
|
+
fn.name = fn.name.replace(/^__aztec_nr_internals__/, '');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
await writeFile(path, JSON.stringify(artifact, null, 2) + '\n');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** Compiles Aztec Noir contracts and postprocesses artifacts. */ async function compileAztecContract(nargoArgs, log) {
|
|
56
|
+
const nargo = process.env.NARGO ?? 'nargo';
|
|
57
|
+
const bb = process.env.BB ?? 'bb';
|
|
58
|
+
await run(nargo, [
|
|
59
|
+
'compile',
|
|
60
|
+
...nargoArgs
|
|
61
|
+
]);
|
|
62
|
+
const artifacts = await collectContractArtifacts();
|
|
63
|
+
if (artifacts.length > 0) {
|
|
64
|
+
log('Postprocessing contracts...');
|
|
65
|
+
const bbArgs = artifacts.flatMap((a)=>[
|
|
66
|
+
'-i',
|
|
67
|
+
a
|
|
68
|
+
]);
|
|
69
|
+
await run(bb, [
|
|
70
|
+
'aztec_process',
|
|
71
|
+
...bbArgs
|
|
72
|
+
]);
|
|
73
|
+
// TODO: This should be part of bb aztec_process!
|
|
74
|
+
await stripInternalPrefixes(artifacts);
|
|
75
|
+
}
|
|
76
|
+
log('Compilation complete!');
|
|
77
|
+
}
|
|
78
|
+
export function injectCompileCommand(program, log) {
|
|
79
|
+
program.command('compile').argument('[nargo-args...]').passThroughOptions().allowUnknownOption().description('Compile Aztec Noir contracts using nargo and postprocess them to generate transpiled artifacts and verification keys. All options are forwarded to nargo compile.').addHelpText('after', ()=>{
|
|
80
|
+
// Show nargo's own compile options so users see all available flags in one place.
|
|
81
|
+
const nargo = process.env.NARGO ?? 'nargo';
|
|
82
|
+
try {
|
|
83
|
+
const output = execFileSync(nargo, [
|
|
84
|
+
'compile',
|
|
85
|
+
'--help'
|
|
86
|
+
], {
|
|
87
|
+
encoding: 'utf-8'
|
|
88
|
+
});
|
|
89
|
+
return `\nUnderlying nargo compile options:\n\n${output}`;
|
|
90
|
+
} catch {
|
|
91
|
+
return '\n(Run "nargo compile --help" to see available nargo options)';
|
|
92
|
+
}
|
|
93
|
+
}).action((nargoArgs)=>compileAztecContract(nargoArgs, log));
|
|
94
|
+
return program;
|
|
95
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
export declare function injectMigrateCommand(program: Command, log: (msg: string) => void): Command;
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWlncmF0ZV9oYV9kYi5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbWRzL21pZ3JhdGVfaGFfZGIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxLQUFLLEVBQUUsT0FBTyxFQUFFLE1BQU0sV0FBVyxDQUFDO0FBRXpDLHdCQUFnQixvQkFBb0IsQ0FBQyxPQUFPLEVBQUUsT0FBTyxFQUFFLEdBQUcsRUFBRSxDQUFDLEdBQUcsRUFBRSxNQUFNLEtBQUssSUFBSSxHQUFHLE9BQU8sQ0FzQzFGIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate_ha_db.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/migrate_ha_db.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAsC1F"}
|