@aztec/aztec 0.0.1-commit.fcb71a6 → 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 +5 -1
- 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 -9
- 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 +27 -8
- 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 +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 +5 -7
- 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 +9 -5
- 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 +62 -10
- 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 +1 -2
- 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 +3 -3
- 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 +2 -2
- package/dest/cli/util.d.ts +5 -14
- package/dest/cli/util.d.ts.map +1 -1
- package/dest/cli/util.js +11 -6
- package/dest/examples/token.js +5 -5
- 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 +2 -2
- package/dest/local-network/local-network.d.ts +4 -3
- package/dest/local-network/local-network.d.ts.map +1 -1
- package/dest/local-network/local-network.js +51 -20
- package/dest/testing/anvil_test_watcher.d.ts +9 -1
- package/dest/testing/anvil_test_watcher.d.ts.map +1 -1
- package/dest/testing/anvil_test_watcher.js +52 -15
- 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 +62 -0
- package/scripts/extract_function.js +47 -0
- package/scripts/flamegraph.sh +59 -0
- package/scripts/init.sh +35 -0
- package/scripts/new.sh +59 -0
- package/scripts/setup_project.sh +31 -0
- package/src/bin/index.ts +5 -1
- package/src/cli/admin_api_key_store.ts +128 -0
- package/src/cli/aztec_start_action.ts +53 -4
- package/src/cli/aztec_start_options.ts +28 -6
- package/src/cli/cli.ts +11 -56
- 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 +2 -13
- package/src/cli/cmds/start_bot.ts +8 -5
- package/src/cli/cmds/start_node.ts +51 -9
- package/src/cli/cmds/start_p2p_bootstrap.ts +2 -2
- package/src/cli/cmds/start_prover_agent.ts +3 -11
- package/src/cli/cmds/start_prover_broker.ts +5 -1
- package/src/cli/util.ts +15 -20
- package/src/examples/token.ts +5 -7
- package/src/local-network/banana_fpc.ts +10 -6
- package/src/local-network/local-network.ts +72 -27
- package/src/testing/anvil_test_watcher.ts +59 -15
- package/src/testing/epoch_test_settler.ts +71 -0
- package/src/testing/index.ts +1 -0
- 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/src/cli/cmds/start_prover_node.ts +0 -124
package/dest/bin/index.js
CHANGED
|
@@ -12,6 +12,8 @@ import { injectCommands as injectValidatorKeysCommands } from '@aztec/cli/valida
|
|
|
12
12
|
import { getActiveNetworkName } from '@aztec/foundation/config';
|
|
13
13
|
import { createConsoleLogger, createLogger } from '@aztec/foundation/log';
|
|
14
14
|
import { Command } from 'commander';
|
|
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';
|
|
17
19
|
const NETWORK_FLAG = 'network';
|
|
@@ -35,7 +37,7 @@ const debugLogger = createLogger('cli');
|
|
|
35
37
|
enrichEnvironmentWithChainName(networkName);
|
|
36
38
|
const cliVersion = getCliVersion();
|
|
37
39
|
let program = new Command('aztec');
|
|
38
|
-
program.description('Aztec command line interface').version(cliVersion);
|
|
40
|
+
program.description('Aztec command line interface').version(cliVersion).enablePositionalOptions();
|
|
39
41
|
program = injectAztecCommands(program, userLog, debugLogger);
|
|
40
42
|
program = injectBuilderCommands(program);
|
|
41
43
|
program = injectContractCommands(program, userLog, debugLogger);
|
|
@@ -44,6 +46,8 @@ const debugLogger = createLogger('cli');
|
|
|
44
46
|
program = injectAztecNodeCommands(program, userLog, debugLogger);
|
|
45
47
|
program = injectMiscCommands(program, userLog);
|
|
46
48
|
program = injectValidatorKeysCommands(program, userLog);
|
|
49
|
+
program = injectCompileCommand(program, userLog);
|
|
50
|
+
program = injectMigrateCommand(program, userLog);
|
|
47
51
|
await program.parseAsync(process.argv);
|
|
48
52
|
}
|
|
49
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';
|
|
@@ -23,7 +24,12 @@ export async function aztecStart(options, userLog, debugLogger) {
|
|
|
23
24
|
l1Mnemonic: localNetwork.l1Mnemonic,
|
|
24
25
|
l1RpcUrls: options.l1RpcUrls,
|
|
25
26
|
testAccounts: localNetwork.testAccounts,
|
|
26
|
-
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
|
|
27
33
|
}, userLog);
|
|
28
34
|
// Start Node and PXE JSON-RPC server
|
|
29
35
|
signalHandlers.push(stop);
|
|
@@ -32,15 +38,16 @@ export async function aztecStart(options, userLog, debugLogger) {
|
|
|
32
38
|
AztecNodeApiSchema
|
|
33
39
|
];
|
|
34
40
|
} else {
|
|
41
|
+
// Route --prover-node through startNode
|
|
42
|
+
if (options.proverNode && !options.node) {
|
|
43
|
+
options.node = true;
|
|
44
|
+
}
|
|
35
45
|
if (options.node) {
|
|
36
46
|
const { startNode } = await import('./cmds/start_node.js');
|
|
37
47
|
({ config } = await startNode(options, signalHandlers, services, adminServices, userLog));
|
|
38
48
|
} else if (options.bot) {
|
|
39
49
|
const { startBot } = await import('./cmds/start_bot.js');
|
|
40
50
|
await startBot(options, signalHandlers, services, userLog);
|
|
41
|
-
} else if (options.proverNode) {
|
|
42
|
-
const { startProverNode } = await import('./cmds/start_prover_node.js');
|
|
43
|
-
({ config } = await startProverNode(options, signalHandlers, services, userLog));
|
|
44
51
|
} else if (options.archiver) {
|
|
45
52
|
const { startArchiver } = await import('./cmds/start_archiver.js');
|
|
46
53
|
({ config } = await startArchiver(options, signalHandlers, services));
|
|
@@ -85,13 +92,26 @@ export async function aztecStart(options, userLog, debugLogger) {
|
|
|
85
92
|
}
|
|
86
93
|
// If there are any admin services, start a separate JSON-RPC server for them
|
|
87
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
|
+
}
|
|
88
111
|
const rpcServer = createNamespacedSafeJsonRpcServer(adminServices, {
|
|
89
112
|
http200OnError: false,
|
|
90
113
|
log: debugLogger,
|
|
91
|
-
middlewares:
|
|
92
|
-
getOtelJsonRpcPropagationMiddleware(),
|
|
93
|
-
getVersioningMiddleware(versions)
|
|
94
|
-
],
|
|
114
|
+
middlewares: adminMiddlewares,
|
|
95
115
|
maxBatchSize: options.rpcMaxBatchSize,
|
|
96
116
|
maxBodySizeBytes: options.rpcMaxBodySize
|
|
97
117
|
});
|
|
@@ -99,5 +119,26 @@ export async function aztecStart(options, userLog, debugLogger) {
|
|
|
99
119
|
port: options.adminPort
|
|
100
120
|
});
|
|
101
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
|
+
}
|
|
102
143
|
}
|
|
103
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":"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;
|
|
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"}
|
|
@@ -13,7 +13,7 @@ import { proverAgentConfigMappings, proverBrokerConfigMappings } from '@aztec/pr
|
|
|
13
13
|
import { proverNodeConfigMappings } from '@aztec/prover-node/config';
|
|
14
14
|
import { allPxeConfigMappings } from '@aztec/pxe/config';
|
|
15
15
|
import { sequencerClientConfigMappings } from '@aztec/sequencer-client/config';
|
|
16
|
-
import { chainConfigMappings } from '@aztec/stdlib/config';
|
|
16
|
+
import { chainConfigMappings, nodeRpcConfigMappings } from '@aztec/stdlib/config';
|
|
17
17
|
import { telemetryClientConfigMappings } from '@aztec/telemetry-client/config';
|
|
18
18
|
import { worldStateConfigMappings } from '@aztec/world-state/config';
|
|
19
19
|
import { DefaultMnemonic } from '../mnemonic.js';
|
|
@@ -111,12 +111,35 @@ export const aztecStartOptions = {
|
|
|
111
111
|
env: 'AZTEC_ADMIN_PORT',
|
|
112
112
|
parseVal: (val)=>parseInt(val, 10)
|
|
113
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
|
+
},
|
|
114
135
|
{
|
|
115
136
|
flag: '--api-prefix <value>',
|
|
116
137
|
description: 'Prefix for API routes on any service that is started',
|
|
117
138
|
defaultValue: '',
|
|
118
139
|
env: 'API_PREFIX'
|
|
119
|
-
}
|
|
140
|
+
},
|
|
141
|
+
configToFlag('--rpcMaxBatchSize', nodeRpcConfigMappings.rpcMaxBatchSize),
|
|
142
|
+
configToFlag('--rpcMaxBodySize', nodeRpcConfigMappings.rpcMaxBodySize)
|
|
120
143
|
],
|
|
121
144
|
ETHEREUM: [
|
|
122
145
|
configToFlag('--l1-chain-id', l1ReaderConfigMappings.l1ChainId),
|
|
@@ -140,7 +163,7 @@ export const aztecStartOptions = {
|
|
|
140
163
|
'WORLD STATE': [
|
|
141
164
|
configToFlag('--world-state-data-directory', worldStateConfigMappings.worldStateDataDirectory),
|
|
142
165
|
configToFlag('--world-state-db-map-size-kb', worldStateConfigMappings.worldStateDbMapSizeKb),
|
|
143
|
-
configToFlag('--world-state-
|
|
166
|
+
configToFlag('--world-state-checkpoint-history', worldStateConfigMappings.worldStateCheckpointHistory)
|
|
144
167
|
],
|
|
145
168
|
// We can't easily auto-generate node options as they're parts of modules defined below
|
|
146
169
|
'AZTEC NODE': [
|
|
@@ -184,12 +207,8 @@ export const aztecStartOptions = {
|
|
|
184
207
|
},
|
|
185
208
|
...getOptions('proverNode', omitConfigMappings(proverNodeConfigMappings, [
|
|
186
209
|
// filter out options passed separately
|
|
187
|
-
...getKeys(archiverConfigMappings),
|
|
188
210
|
...getKeys(proverBrokerConfigMappings),
|
|
189
|
-
...getKeys(proverAgentConfigMappings)
|
|
190
|
-
...getKeys(p2pConfigMappings),
|
|
191
|
-
...getKeys(worldStateConfigMappings),
|
|
192
|
-
...getKeys(sharedNodeConfigMappings)
|
|
211
|
+
...getKeys(proverAgentConfigMappings)
|
|
193
212
|
]))
|
|
194
213
|
],
|
|
195
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
|
@@ -20,60 +20,15 @@ import { addOptions, printAztecStartHelpText } from './util.js';
|
|
|
20
20
|
program.configureHelp({
|
|
21
21
|
sortSubcommands: true
|
|
22
22
|
});
|
|
23
|
-
|
|
23
|
+
if (process.env.AZTEC_SHELL_WRAPPER) {
|
|
24
|
+
program.addHelpText('after', `
|
|
25
|
+
Additional commands:
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
Options:
|
|
29
|
-
--name <name> Name of the package
|
|
30
|
-
--contract Use a contract template (default)
|
|
31
|
-
--lib Use a library template
|
|
32
|
-
--bin Use a binary template
|
|
33
|
-
Examples:
|
|
34
|
-
$ aztec init # creates a contract project in current directory
|
|
35
|
-
$ aztec init --lib # creates a library project
|
|
36
|
-
|
|
37
|
-
new <path> [options]: creates a new Noir project in a new directory
|
|
38
|
-
Options:
|
|
39
|
-
--name <name> Name of the package
|
|
40
|
-
--contract Use a contract template (default)
|
|
41
|
-
--lib Use a library template
|
|
42
|
-
--bin Use a binary template
|
|
43
|
-
Examples:
|
|
44
|
-
$ aztec new my-project # creates a contract project in ./my-project
|
|
45
|
-
$ aztec new my-lib --lib # creates a library project in ./my-lib
|
|
46
|
-
|
|
47
|
-
compile [options]: compiles Aztec Noir contracts
|
|
48
|
-
Compiles contracts with nargo compile and then postprocesses them to generate Aztec-specific artifacts including:
|
|
49
|
-
- Transpiled contract artifacts
|
|
50
|
-
- Verification keys
|
|
51
|
-
The compiled contracts will be placed in the target/ directory by default.
|
|
52
|
-
Supports standard nargo compile options.
|
|
53
|
-
|
|
54
|
-
fmt [options]: formats Noir code using nargo fmt
|
|
55
|
-
Example:
|
|
56
|
-
$ aztec fmt # formats all Noir files in the project
|
|
57
|
-
|
|
58
|
-
check [options]: type-checks Noir code without compiling using nargo check
|
|
59
|
-
Example:
|
|
60
|
-
$ aztec check # checks all Noir files in the project
|
|
61
|
-
|
|
62
|
-
test [options]: starts a dockerized TXE node via
|
|
63
|
-
$ aztec start --txe
|
|
64
|
-
then runs
|
|
65
|
-
$ aztec test --silence-warnings --oracle-resolver=<TXE_ADDRESS> [options]
|
|
66
|
-
|
|
67
|
-
lsp: starts the Nargo Language Server Protocol server
|
|
68
|
-
Runs nargo lsp in a Docker container for IDE integration with Noir.
|
|
69
|
-
This command is typically used by IDE extensions and not called directly by users.
|
|
70
|
-
Example:
|
|
71
|
-
$ aztec lsp # starts the LSP server
|
|
72
|
-
|
|
73
|
-
preload-crs: Downloads and caches the Common Reference String (CRS) data required for zero-knowledge proofs.
|
|
74
|
-
Example:
|
|
75
|
-
$ 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.
|
|
76
30
|
`);
|
|
31
|
+
}
|
|
77
32
|
program.command('preload-crs').description('Preload the points data needed for proving and verifying').action(async (options)=>{
|
|
78
33
|
const { preloadCrs } = await import('./preload_crs.js');
|
|
79
34
|
return await preloadCrs(options, userLog, debugLogger);
|
|
@@ -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"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { runMigrations } from '@aztec/validator-ha-signer/migrations';
|
|
2
|
+
export function injectMigrateCommand(program, log) {
|
|
3
|
+
const migrateCommand = program.command('migrate-ha-db').description('Run validator-ha-signer database migrations');
|
|
4
|
+
migrateCommand.command('up').description('Apply pending migrations').requiredOption('--database-url <string>', 'PostgreSQL connection string', process.env.DATABASE_URL).option('--verbose', 'Enable verbose output', false).action(async (options)=>{
|
|
5
|
+
const migrations = await runMigrations(options.databaseUrl, {
|
|
6
|
+
direction: 'up',
|
|
7
|
+
verbose: options.verbose
|
|
8
|
+
});
|
|
9
|
+
if (migrations.length > 0) {
|
|
10
|
+
log(`Applied migrations: ${migrations.join(', ')}`);
|
|
11
|
+
} else {
|
|
12
|
+
log('No migrations to apply - schema is up to date');
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
migrateCommand.command('down').description('Rollback the last migration').requiredOption('--database-url <string>', 'PostgreSQL connection string', process.env.DATABASE_URL).option('--verbose', 'Enable verbose output', false).action(async (options)=>{
|
|
16
|
+
const migrations = await runMigrations(options.databaseUrl, {
|
|
17
|
+
direction: 'down',
|
|
18
|
+
verbose: options.verbose
|
|
19
|
+
});
|
|
20
|
+
if (migrations.length > 0) {
|
|
21
|
+
log(`Rolled back migrations: ${migrations.join(', ')}`);
|
|
22
|
+
} else {
|
|
23
|
+
log('No migrations to rollback');
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
return program;
|
|
27
|
+
}
|
|
@@ -6,4 +6,4 @@ export type { ArchiverConfig, DataStoreConfig };
|
|
|
6
6
|
export declare function startArchiver(options: any, signalHandlers: (() => Promise<void>)[], services: NamespacedApiHandlers): Promise<{
|
|
7
7
|
config: ArchiverConfig & DataStoreConfig;
|
|
8
8
|
}>;
|
|
9
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhcnRfYXJjaGl2ZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9jbGkvY21kcy9zdGFydF9hcmNoaXZlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsS0FBSyxjQUFjLEVBQW9FLE1BQU0saUJBQWlCLENBQUM7QUFJeEgsT0FBTyxLQUFLLEVBQUUscUJBQXFCLEVBQUUsTUFBTSxtQ0FBbUMsQ0FBQztBQUMvRSxPQUFPLEVBQUUsS0FBSyxlQUFlLEVBQXNCLE1BQU0sd0JBQXdCLENBQUM7QUFNbEYsWUFBWSxFQUFFLGNBQWMsRUFBRSxlQUFlLEVBQUUsQ0FBQztBQUVoRCxvQ0FBb0M7QUFDcEMsd0JBQXNCLGFBQWEsQ0FDakMsT0FBTyxFQUFFLEdBQUcsRUFDWixjQUFjLEVBQUUsQ0FBQyxNQUFNLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQyxFQUFFLEVBQ3ZDLFFBQVEsRUFBRSxxQkFBcUIsR0FDOUIsT0FBTyxDQUFDO0lBQUUsTUFBTSxFQUFFLGNBQWMsR0FBRyxlQUFlLENBQUE7Q0FBRSxDQUFDLENBK0J2RCJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start_archiver.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_archiver.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"start_archiver.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_archiver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAoE,MAAM,iBAAiB,CAAC;AAIxH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,wBAAwB,CAAC;AAMlF,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,CAAC;AAEhD,oCAAoC;AACpC,wBAAsB,aAAa,CACjC,OAAO,EAAE,GAAG,EACZ,cAAc,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EACvC,QAAQ,EAAE,qBAAqB,GAC9B,OAAO,CAAC;IAAE,MAAM,EAAE,cAAc,GAAG,eAAe,CAAA;CAAE,CAAC,CA+BvD"}
|