@aztec/aztec 3.0.3 → 3.9.9-nightly.20260312

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.
Files changed (127) hide show
  1. package/dest/bin/index.js +9 -3
  2. package/dest/cli/admin_api_key_store.d.ts +45 -0
  3. package/dest/cli/admin_api_key_store.d.ts.map +1 -0
  4. package/dest/cli/admin_api_key_store.js +98 -0
  5. package/dest/cli/aztec_start_action.d.ts +1 -1
  6. package/dest/cli/aztec_start_action.d.ts.map +1 -1
  7. package/dest/cli/aztec_start_action.js +55 -15
  8. package/dest/cli/aztec_start_options.d.ts +1 -1
  9. package/dest/cli/aztec_start_options.d.ts.map +1 -1
  10. package/dest/cli/aztec_start_options.js +33 -23
  11. package/dest/cli/cli.d.ts +1 -1
  12. package/dest/cli/cli.d.ts.map +1 -1
  13. package/dest/cli/cli.js +7 -52
  14. package/dest/cli/cmds/compile.d.ts +4 -0
  15. package/dest/cli/cmds/compile.d.ts.map +1 -0
  16. package/dest/cli/cmds/compile.js +68 -0
  17. package/dest/cli/cmds/migrate_ha_db.d.ts +3 -0
  18. package/dest/cli/cmds/migrate_ha_db.d.ts.map +1 -0
  19. package/dest/cli/cmds/migrate_ha_db.js +27 -0
  20. package/dest/cli/cmds/profile.d.ts +4 -0
  21. package/dest/cli/cmds/profile.d.ts.map +1 -0
  22. package/dest/cli/cmds/profile.js +8 -0
  23. package/dest/cli/cmds/profile_flamegraph.d.ts +4 -0
  24. package/dest/cli/cmds/profile_flamegraph.d.ts.map +1 -0
  25. package/dest/cli/cmds/profile_flamegraph.js +51 -0
  26. package/dest/cli/cmds/profile_gates.d.ts +4 -0
  27. package/dest/cli/cmds/profile_gates.d.ts.map +1 -0
  28. package/dest/cli/cmds/profile_gates.js +57 -0
  29. package/dest/cli/cmds/profile_utils.d.ts +18 -0
  30. package/dest/cli/cmds/profile_utils.d.ts.map +1 -0
  31. package/dest/cli/cmds/profile_utils.js +50 -0
  32. package/dest/cli/cmds/standby.d.ts +27 -0
  33. package/dest/cli/cmds/standby.d.ts.map +1 -0
  34. package/dest/cli/cmds/standby.js +78 -0
  35. package/dest/cli/cmds/start_archiver.d.ts +1 -1
  36. package/dest/cli/cmds/start_archiver.d.ts.map +1 -1
  37. package/dest/cli/cmds/start_archiver.js +10 -12
  38. package/dest/cli/cmds/start_bot.d.ts +3 -3
  39. package/dest/cli/cmds/start_bot.d.ts.map +1 -1
  40. package/dest/cli/cmds/start_bot.js +9 -5
  41. package/dest/cli/cmds/start_node.d.ts +3 -2
  42. package/dest/cli/cmds/start_node.d.ts.map +1 -1
  43. package/dest/cli/cmds/start_node.js +77 -27
  44. package/dest/cli/cmds/start_p2p_bootstrap.d.ts +2 -2
  45. package/dest/cli/cmds/start_p2p_bootstrap.d.ts.map +1 -1
  46. package/dest/cli/cmds/start_p2p_bootstrap.js +1 -2
  47. package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
  48. package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
  49. package/dest/cli/cmds/start_prover_agent.js +3 -3
  50. package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
  51. package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
  52. package/dest/cli/cmds/start_prover_broker.js +8 -8
  53. package/dest/cli/cmds/utils/artifacts.d.ts +21 -0
  54. package/dest/cli/cmds/utils/artifacts.d.ts.map +1 -0
  55. package/dest/cli/cmds/utils/artifacts.js +24 -0
  56. package/dest/cli/cmds/utils/spawn.d.ts +3 -0
  57. package/dest/cli/cmds/utils/spawn.d.ts.map +1 -0
  58. package/dest/cli/cmds/utils/spawn.js +16 -0
  59. package/dest/cli/util.d.ts +7 -18
  60. package/dest/cli/util.d.ts.map +1 -1
  61. package/dest/cli/util.js +48 -84
  62. package/dest/examples/token.js +9 -9
  63. package/dest/local-network/banana_fpc.d.ts +1 -1
  64. package/dest/local-network/banana_fpc.d.ts.map +1 -1
  65. package/dest/local-network/banana_fpc.js +3 -3
  66. package/dest/local-network/local-network.d.ts +6 -5
  67. package/dest/local-network/local-network.d.ts.map +1 -1
  68. package/dest/local-network/local-network.js +74 -30
  69. package/dest/testing/anvil_test_watcher.d.ts +9 -1
  70. package/dest/testing/anvil_test_watcher.d.ts.map +1 -1
  71. package/dest/testing/anvil_test_watcher.js +52 -15
  72. package/dest/testing/cheat_codes.d.ts +3 -1
  73. package/dest/testing/cheat_codes.d.ts.map +1 -1
  74. package/dest/testing/epoch_test_settler.d.ts +19 -0
  75. package/dest/testing/epoch_test_settler.d.ts.map +1 -0
  76. package/dest/testing/epoch_test_settler.js +62 -0
  77. package/dest/testing/index.d.ts +3 -1
  78. package/dest/testing/index.d.ts.map +1 -1
  79. package/dest/testing/index.js +2 -0
  80. package/dest/testing/token_allowed_setup.d.ts +7 -0
  81. package/dest/testing/token_allowed_setup.d.ts.map +1 -0
  82. package/dest/testing/token_allowed_setup.js +20 -0
  83. package/package.json +37 -35
  84. package/scripts/aztec.sh +67 -0
  85. package/scripts/init.sh +35 -0
  86. package/scripts/new.sh +59 -0
  87. package/scripts/setup_project.sh +31 -0
  88. package/src/bin/index.ts +9 -3
  89. package/src/cli/admin_api_key_store.ts +128 -0
  90. package/src/cli/aztec_start_action.ts +58 -10
  91. package/src/cli/aztec_start_options.ts +34 -21
  92. package/src/cli/cli.ts +11 -56
  93. package/src/cli/cmds/compile.ts +80 -0
  94. package/src/cli/cmds/migrate_ha_db.ts +43 -0
  95. package/src/cli/cmds/profile.ts +25 -0
  96. package/src/cli/cmds/profile_flamegraph.ts +63 -0
  97. package/src/cli/cmds/profile_gates.ts +67 -0
  98. package/src/cli/cmds/profile_utils.ts +58 -0
  99. package/src/cli/cmds/standby.ts +111 -0
  100. package/src/cli/cmds/start_archiver.ts +6 -17
  101. package/src/cli/cmds/start_bot.ts +8 -5
  102. package/src/cli/cmds/start_node.ts +76 -33
  103. package/src/cli/cmds/start_p2p_bootstrap.ts +2 -2
  104. package/src/cli/cmds/start_prover_agent.ts +3 -11
  105. package/src/cli/cmds/start_prover_broker.ts +12 -15
  106. package/src/cli/cmds/utils/artifacts.ts +44 -0
  107. package/src/cli/cmds/utils/spawn.ts +16 -0
  108. package/src/cli/util.ts +56 -94
  109. package/src/examples/token.ts +10 -10
  110. package/src/local-network/banana_fpc.ts +11 -7
  111. package/src/local-network/local-network.ts +90 -39
  112. package/src/testing/anvil_test_watcher.ts +59 -15
  113. package/src/testing/epoch_test_settler.ts +71 -0
  114. package/src/testing/index.ts +2 -0
  115. package/src/testing/token_allowed_setup.ts +19 -0
  116. package/dest/cli/cmds/start_blob_sink.d.ts +0 -3
  117. package/dest/cli/cmds/start_blob_sink.d.ts.map +0 -1
  118. package/dest/cli/cmds/start_blob_sink.js +0 -33
  119. package/dest/cli/cmds/start_prover_node.d.ts +0 -7
  120. package/dest/cli/cmds/start_prover_node.d.ts.map +0 -1
  121. package/dest/cli/cmds/start_prover_node.js +0 -108
  122. package/dest/cli/release_version.d.ts +0 -2
  123. package/dest/cli/release_version.d.ts.map +0 -1
  124. package/dest/cli/release_version.js +0 -14
  125. package/src/cli/cmds/start_blob_sink.ts +0 -57
  126. package/src/cli/cmds/start_prover_node.ts +0 -124
  127. package/src/cli/release_version.ts +0 -21
@@ -0,0 +1,20 @@
1
+ import { TokenContractArtifact } from '@aztec/noir-contracts.js/Token';
2
+ import { buildAllowedElement } from '@aztec/p2p/msg_validators';
3
+ import { getContractClassFromArtifact } from '@aztec/stdlib/contract';
4
+ /**
5
+ * Returns Token-specific allowlist entries needed for FPC-based fee payments.
6
+ * These are test-only: FPC-based fee payment with custom tokens won't work on mainnet alpha.
7
+ */ export async function getTokenAllowedSetupFunctions() {
8
+ const tokenClassId = (await getContractClassFromArtifact(TokenContractArtifact)).id;
9
+ const target = {
10
+ classId: tokenClassId
11
+ };
12
+ return Promise.all([
13
+ // Token: needed for private transfers via FPC (transfer_to_public enqueues this)
14
+ buildAllowedElement(TokenContractArtifact, target, '_increase_public_balance', {
15
+ onlySelf: true
16
+ }),
17
+ // Token: needed for public transfers via FPC (fee_entrypoint_public enqueues this)
18
+ buildAllowedElement(TokenContractArtifact, target, 'transfer_in_public')
19
+ ]);
20
+ }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@aztec/aztec",
3
- "version": "3.0.3",
3
+ "version": "3.9.9-nightly.20260312",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
7
7
  "./testing": "./dest/testing/index.js"
8
8
  },
9
- "bin": "./dest/bin/index.js",
9
+ "bin": "./scripts/aztec.sh",
10
10
  "typedocOptions": {
11
11
  "entryPoints": [
12
12
  "./src/index.ts"
@@ -28,38 +28,39 @@
28
28
  "../package.common.json"
29
29
  ],
30
30
  "dependencies": {
31
- "@aztec/accounts": "3.0.3",
32
- "@aztec/archiver": "3.0.3",
33
- "@aztec/aztec-faucet": "3.0.3",
34
- "@aztec/aztec-node": "3.0.3",
35
- "@aztec/aztec.js": "3.0.3",
36
- "@aztec/bb-prover": "3.0.3",
37
- "@aztec/bb.js": "3.0.3",
38
- "@aztec/blob-sink": "3.0.3",
39
- "@aztec/bot": "3.0.3",
40
- "@aztec/builder": "3.0.3",
41
- "@aztec/cli": "3.0.3",
42
- "@aztec/constants": "3.0.3",
43
- "@aztec/entrypoints": "3.0.3",
44
- "@aztec/ethereum": "3.0.3",
45
- "@aztec/foundation": "3.0.3",
46
- "@aztec/kv-store": "3.0.3",
47
- "@aztec/l1-artifacts": "3.0.3",
48
- "@aztec/node-lib": "3.0.3",
49
- "@aztec/noir-contracts.js": "3.0.3",
50
- "@aztec/noir-protocol-circuits-types": "3.0.3",
51
- "@aztec/p2p": "3.0.3",
52
- "@aztec/p2p-bootstrap": "3.0.3",
53
- "@aztec/protocol-contracts": "3.0.3",
54
- "@aztec/prover-client": "3.0.3",
55
- "@aztec/prover-node": "3.0.3",
56
- "@aztec/pxe": "3.0.3",
57
- "@aztec/sequencer-client": "3.0.3",
58
- "@aztec/stdlib": "3.0.3",
59
- "@aztec/telemetry-client": "3.0.3",
60
- "@aztec/test-wallet": "3.0.3",
61
- "@aztec/txe": "3.0.3",
62
- "@aztec/world-state": "3.0.3",
31
+ "@aztec/accounts": "3.9.9-nightly.20260312",
32
+ "@aztec/archiver": "3.9.9-nightly.20260312",
33
+ "@aztec/aztec-faucet": "3.9.9-nightly.20260312",
34
+ "@aztec/aztec-node": "3.9.9-nightly.20260312",
35
+ "@aztec/aztec.js": "3.9.9-nightly.20260312",
36
+ "@aztec/bb-prover": "3.9.9-nightly.20260312",
37
+ "@aztec/bb.js": "3.9.9-nightly.20260312",
38
+ "@aztec/blob-client": "3.9.9-nightly.20260312",
39
+ "@aztec/bot": "3.9.9-nightly.20260312",
40
+ "@aztec/builder": "3.9.9-nightly.20260312",
41
+ "@aztec/cli": "3.9.9-nightly.20260312",
42
+ "@aztec/constants": "3.9.9-nightly.20260312",
43
+ "@aztec/entrypoints": "3.9.9-nightly.20260312",
44
+ "@aztec/ethereum": "3.9.9-nightly.20260312",
45
+ "@aztec/foundation": "3.9.9-nightly.20260312",
46
+ "@aztec/kv-store": "3.9.9-nightly.20260312",
47
+ "@aztec/l1-artifacts": "3.9.9-nightly.20260312",
48
+ "@aztec/node-lib": "3.9.9-nightly.20260312",
49
+ "@aztec/noir-contracts.js": "3.9.9-nightly.20260312",
50
+ "@aztec/noir-protocol-circuits-types": "3.9.9-nightly.20260312",
51
+ "@aztec/p2p": "3.9.9-nightly.20260312",
52
+ "@aztec/p2p-bootstrap": "3.9.9-nightly.20260312",
53
+ "@aztec/protocol-contracts": "3.9.9-nightly.20260312",
54
+ "@aztec/prover-client": "3.9.9-nightly.20260312",
55
+ "@aztec/prover-node": "3.9.9-nightly.20260312",
56
+ "@aztec/pxe": "3.9.9-nightly.20260312",
57
+ "@aztec/sequencer-client": "3.9.9-nightly.20260312",
58
+ "@aztec/stdlib": "3.9.9-nightly.20260312",
59
+ "@aztec/telemetry-client": "3.9.9-nightly.20260312",
60
+ "@aztec/txe": "3.9.9-nightly.20260312",
61
+ "@aztec/validator-ha-signer": "3.9.9-nightly.20260312",
62
+ "@aztec/wallets": "3.9.9-nightly.20260312",
63
+ "@aztec/world-state": "3.9.9-nightly.20260312",
63
64
  "@types/chalk": "^2.2.0",
64
65
  "abitype": "^0.8.11",
65
66
  "chalk": "^5.3.0",
@@ -70,6 +71,7 @@
70
71
  },
71
72
  "files": [
72
73
  "dest",
74
+ "scripts",
73
75
  "src",
74
76
  "!*.test.*"
75
77
  ],
@@ -78,7 +80,7 @@
78
80
  "@jest/globals": "^30.0.0",
79
81
  "@types/jest": "^30.0.0",
80
82
  "@types/koa": "^2.15.0",
81
- "@typescript/native-preview": "7.0.0-dev.20251126.1",
83
+ "@typescript/native-preview": "7.0.0-dev.20260113.1",
82
84
  "jest": "^30.0.0",
83
85
  "ts-node": "^10.9.1",
84
86
  "typescript": "^5.3.3"
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ shopt -s inherit_errexit
4
+
5
+ # Re-execute using correct version if we have an .aztecrc file.
6
+ if [ "${AZTEC_VERSIONED:-0}" -eq 0 ] && [ -f .aztecrc ] && command -v aztec-up &>/dev/null; then
7
+ env_setup=$(aztec-up env)
8
+ eval "$env_setup"
9
+ AZTEC_VERSIONED=1 exec aztec "$@"
10
+ fi
11
+
12
+ cmd=${1:-}
13
+ [ -n "$cmd" ] && shift
14
+
15
+ script_dir="$(dirname "$(realpath "$0")")"
16
+
17
+ function aztec {
18
+ export AZTEC_SHELL_WRAPPER=1
19
+ exec node --no-warnings $script_dir/../dest/bin/index.js "$@"
20
+ }
21
+
22
+ case $cmd in
23
+ test)
24
+ export LOG_LEVEL="${LOG_LEVEL:-"error;trace:contract_log"}"
25
+ aztec start --txe --port 8081 &
26
+ server_pid=$!
27
+ trap 'kill $server_pid &>/dev/null || true' EXIT
28
+ while ! nc -z 127.0.0.1 8081 &>/dev/null; do sleep 0.2; done
29
+ export NARGO_FOREIGN_CALL_TIMEOUT=300000
30
+ nargo test --silence-warnings --oracle-resolver http://127.0.0.1:8081 --test-threads 16 "$@"
31
+ ;;
32
+ start)
33
+ if [ "${1:-}" == "--local-network" ]; then
34
+ # TODO: Can these just be set in TS?
35
+ export ARCHIVER_POLLING_INTERVAL_MS=500
36
+ export P2P_BLOCK_CHECK_INTERVAL_MS=500
37
+ export SEQ_TX_POLLING_INTERVAL_MS=500
38
+ export WS_BLOCK_CHECK_INTERVAL_MS=500
39
+ export ARCHIVER_VIEM_POLLING_INTERVAL_MS=500
40
+ export TEST_ACCOUNTS=${TEST_ACCOUNTS:-true}
41
+ export LOG_LEVEL=${LOG_LEVEL:-info;silent:sequencer;verbose:debug_log}
42
+ export DEPLOY_AZTEC_CONTRACTS_SALT=${DEPLOY_AZTEC_CONTRACTS_SALT:-$RANDOM}
43
+
44
+ ANVIL_PORT=${ANVIL_PORT:-8545}
45
+
46
+ export L1_CHAIN_ID=${L1_CHAIN_ID:-31337}
47
+ export ETHEREUM_HOSTS=${ETHEREUM_HOSTS:-"http://127.0.0.1:${ANVIL_PORT}"}
48
+
49
+ anvil --version
50
+ anvil --silent &
51
+ anvil_pid=$!
52
+ trap 'kill $anvil_pid &>/dev/null' EXIT
53
+ fi
54
+
55
+ aztec start "$@"
56
+ ;;
57
+ new|init)
58
+ $script_dir/${cmd}.sh "$@"
59
+ ;;
60
+ flamegraph)
61
+ echo "Warning: 'aztec flamegraph' is deprecated. Use 'aztec profile flamegraph' instead." >&2
62
+ aztec profile flamegraph "$@"
63
+ ;;
64
+ *)
65
+ aztec $cmd "$@"
66
+ ;;
67
+ esac
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ NARGO=${NARGO:-nargo}
5
+ script_path=$(realpath $(dirname "$0"))
6
+
7
+ for arg in "$@"; do
8
+ if [ "$arg" == "--help" ] || [ "$arg" == "-h" ]; then
9
+ cat << 'EOF'
10
+ Aztec Init - Create a new Aztec Noir project in the current directory
11
+
12
+ Usage: aztec init [OPTIONS]
13
+
14
+ Options:
15
+ --name <NAME> Name of the package [default: current directory name]
16
+ --lib Use a library template
17
+ -h, --help Print help
18
+
19
+ This command creates a new Aztec Noir project in the current directory using nargo
20
+ and automatically adds the Aztec.nr dependency to your Nargo.toml file.
21
+
22
+ EOF
23
+ exit 0
24
+ fi
25
+ if [ "$arg" == "--lib" ]; then
26
+ is_contract=0
27
+ fi
28
+ done
29
+
30
+ echo "Initializing Noir project..."
31
+ $NARGO init "$@"
32
+
33
+ if [ "${is_contract:-1}" -eq 1 ]; then
34
+ $script_path/setup_project.sh
35
+ fi
package/scripts/new.sh ADDED
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ NARGO=${NARGO:-nargo}
5
+ script_path=$(realpath $(dirname "$0"))
6
+
7
+ type_arg="--contract"
8
+
9
+ while [[ $# -gt 0 ]]; do
10
+ case $1 in
11
+ --help|-h)
12
+ cat << 'EOF'
13
+ Aztec New - Create a new Aztec Noir project in a new directory
14
+
15
+ Usage: aztec new [OPTIONS] <PATH>
16
+
17
+ Arguments:
18
+ <PATH> The path to save the new project
19
+
20
+ Options:
21
+ --name <NAME> Name of the package [default: package directory name]
22
+ --lib Create a library template instead of a contract
23
+ -h, --help Print help
24
+
25
+ This command creates a new Aztec Noir project using nargo and automatically
26
+ adds the Aztec.nr dependency to your Nargo.toml file.
27
+ EOF
28
+ exit 0
29
+ ;;
30
+ --lib)
31
+ type_arg="--lib"
32
+ shift
33
+ ;;
34
+ --name)
35
+ name_arg="--name $2"
36
+ shift 2
37
+ ;;
38
+ *)
39
+ project_path=$1
40
+ shift
41
+ break
42
+ ;;
43
+ esac
44
+ done
45
+
46
+ if [ -z "$project_path" ]; then
47
+ echo "Error: PATH argument is required"
48
+ echo "Usage: aztec new [OPTIONS] <PATH>"
49
+ echo "Run 'aztec new --help' for more information"
50
+ exit 1
51
+ fi
52
+
53
+ echo "Creating new Noir project at $project_path..."
54
+ $NARGO new $type_arg ${name_arg:-} $project_path
55
+
56
+ if [ "$type_arg" == "--contract" ]; then
57
+ cd $project_path
58
+ $script_path/setup_project.sh
59
+ fi
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # Get the actual aztec version for the git tag.
5
+ AZTEC_VERSION=$(jq -r '.version' $(dirname $0)/../package.json)
6
+ NARGO_TOML_PATH="Nargo.toml"
7
+ MAIN_NR_PATH="src/main.nr"
8
+
9
+ if [ ! -f "$NARGO_TOML_PATH" ]; then
10
+ >&2 echo "Warning: Could not find Nargo.toml at $NARGO_TOML_PATH to add aztec dependency"
11
+ exit 1
12
+ fi
13
+
14
+ if [ ! -f "$MAIN_NR_PATH" ]; then
15
+ >&2 echo "Warning: Could not find main.nr at $MAIN_NR_PATH"
16
+ exit 1
17
+ fi
18
+
19
+ # Add aztec dependency to Nargo.toml
20
+ echo "" >> "$NARGO_TOML_PATH"
21
+ echo "aztec = { git=\"https://github.com/AztecProtocol/aztec-nr\", tag=\"v${AZTEC_VERSION}\", directory=\"aztec\" }" >> "$NARGO_TOML_PATH"
22
+ echo "Added aztec dependency (v${AZTEC_VERSION}) to Nargo.toml"
23
+
24
+ # Replace the contents of main.nr with the Aztec contract template
25
+ cat > "$MAIN_NR_PATH" << 'EOF'
26
+ use aztec::macros::aztec;
27
+
28
+ #[aztec]
29
+ contract Main {}
30
+ EOF
31
+ echo "Created main.nr with Aztec contract template"
package/src/bin/index.ts CHANGED
@@ -11,11 +11,14 @@ import { injectCommands as injectMiscCommands } from '@aztec/cli/misc';
11
11
  import { injectCommands as injectValidatorKeysCommands } from '@aztec/cli/validator_keys';
12
12
  import { getActiveNetworkName } from '@aztec/foundation/config';
13
13
  import { createConsoleLogger, createLogger } from '@aztec/foundation/log';
14
+ import { getPackageVersion } from '@aztec/stdlib/update-checker';
14
15
 
15
16
  import { Command } from 'commander';
16
17
 
18
+ import { injectCompileCommand } from '../cli/cmds/compile.js';
19
+ import { injectMigrateCommand } from '../cli/cmds/migrate_ha_db.js';
20
+ import { injectProfileCommand } from '../cli/cmds/profile.js';
17
21
  import { injectAztecCommands } from '../cli/index.js';
18
- import { getCliVersion } from '../cli/release_version.js';
19
22
 
20
23
  const NETWORK_FLAG = 'network';
21
24
 
@@ -44,9 +47,9 @@ async function main() {
44
47
  await enrichEnvironmentWithNetworkConfig(networkName);
45
48
  enrichEnvironmentWithChainName(networkName);
46
49
 
47
- const cliVersion = getCliVersion();
50
+ const cliVersion = getPackageVersion() ?? 'unknown';
48
51
  let program = new Command('aztec');
49
- program.description('Aztec command line interface').version(cliVersion);
52
+ program.description('Aztec command line interface').version(cliVersion).enablePositionalOptions();
50
53
  program = injectAztecCommands(program, userLog, debugLogger);
51
54
  program = injectBuilderCommands(program);
52
55
  program = injectContractCommands(program, userLog, debugLogger);
@@ -55,6 +58,9 @@ async function main() {
55
58
  program = injectAztecNodeCommands(program, userLog, debugLogger);
56
59
  program = injectMiscCommands(program, userLog);
57
60
  program = injectValidatorKeysCommands(program, userLog);
61
+ program = injectCompileCommand(program, userLog);
62
+ program = injectProfileCommand(program, userLog);
63
+ program = injectMigrateCommand(program, userLog);
58
64
 
59
65
  await program.parseAsync(process.argv);
60
66
  }
@@ -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
10
  import { AztecNodeApiSchema } 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 { getCliVersion } from './release_version.js';
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
 
@@ -23,7 +26,7 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
23
26
  let config: ChainConfig | undefined = undefined;
24
27
 
25
28
  if (options.localNetwork) {
26
- const cliVersion = getCliVersion();
29
+ const cliVersion = getPackageVersion() ?? 'unknown';
27
30
  const localNetwork = extractNamespacedOptions(options, 'local-network');
28
31
  localNetwork.testAccounts = true;
29
32
  userLog(`${splash}\n${github}\n\n`);
@@ -35,6 +38,11 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
35
38
  l1RpcUrls: options.l1RpcUrls,
36
39
  testAccounts: localNetwork.testAccounts,
37
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,
38
46
  },
39
47
  userLog,
40
48
  );
@@ -43,18 +51,18 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
43
51
  signalHandlers.push(stop);
44
52
  services.node = [node, AztecNodeApiSchema];
45
53
  } else {
54
+ // Route --prover-node through startNode
55
+ if (options.proverNode && !options.node) {
56
+ options.node = true;
57
+ }
58
+
46
59
  if (options.node) {
47
60
  const { startNode } = await import('./cmds/start_node.js');
48
- ({ config } = await startNode(options, signalHandlers, services, adminServices, userLog));
61
+ const networkName = getActiveNetworkName(options.network);
62
+ ({ config } = await startNode(options, signalHandlers, services, adminServices, userLog, networkName));
49
63
  } else if (options.bot) {
50
64
  const { startBot } = await import('./cmds/start_bot.js');
51
65
  await startBot(options, signalHandlers, services, userLog);
52
- } else if (options.proverNode) {
53
- const { startProverNode } = await import('./cmds/start_prover_node.js');
54
- ({ config } = await startProverNode(options, signalHandlers, services, userLog));
55
- } else if (options.blobSink) {
56
- const { startBlobSink } = await import('./cmds/start_blob_sink.js');
57
- await startBlobSink(options, signalHandlers, userLog);
58
66
  } else if (options.archiver) {
59
67
  const { startArchiver } = await import('./cmds/start_archiver.js');
60
68
  ({ config } = await startArchiver(options, signalHandlers, services));
@@ -97,14 +105,54 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
97
105
 
98
106
  // If there are any admin services, start a separate JSON-RPC server for them
99
107
  if (Object.entries(adminServices).length > 0) {
108
+ const adminMiddlewares = [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions)];
109
+
110
+ // Resolve the admin API key (auto-generated and persisted, or opt-out)
111
+ const apiKeyResolution = await resolveAdminApiKey(
112
+ {
113
+ adminApiKeyHash: options.adminApiKeyHash,
114
+ disableAdminApiKey: options.disableAdminApiKey,
115
+ resetAdminApiKey: options.resetAdminApiKey,
116
+ dataDirectory: options.dataDirectory,
117
+ },
118
+ debugLogger,
119
+ );
120
+ if (apiKeyResolution) {
121
+ adminMiddlewares.unshift(getApiKeyAuthMiddleware(apiKeyResolution.apiKeyHash));
122
+ } else {
123
+ debugLogger.warn('No admin API key set — admin endpoint is unauthenticated');
124
+ }
125
+
100
126
  const rpcServer = createNamespacedSafeJsonRpcServer(adminServices, {
101
127
  http200OnError: false,
102
128
  log: debugLogger,
103
- middlewares: [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions)],
129
+ middlewares: adminMiddlewares,
104
130
  maxBatchSize: options.rpcMaxBatchSize,
105
131
  maxBodySizeBytes: options.rpcMaxBodySize,
106
132
  });
107
133
  const { port } = await startHttpRpcServer(rpcServer, { port: options.adminPort });
108
134
  debugLogger.info(`Aztec Server admin API listening on port ${port}`, versions);
135
+
136
+ // Display the API key after the server has started
137
+ // Uses userLog which is never filtered by LOG_LEVEL.
138
+ if (apiKeyResolution?.rawKey) {
139
+ const separator = '='.repeat(70);
140
+ userLog('');
141
+ userLog(separator);
142
+ userLog(' ADMIN API KEY (save this — it will NOT be shown again)');
143
+ userLog('');
144
+ userLog(` ${apiKeyResolution.rawKey}`);
145
+ userLog('');
146
+ userLog(` Use via header: x-api-key: <key>`);
147
+ userLog(` Or via header: Authorization: Bearer <key>`);
148
+ if (options.dataDirectory) {
149
+ userLog('');
150
+ userLog(' The key hash has been persisted — on next restart, the same key will be used.');
151
+ }
152
+ userLog('');
153
+ userLog(' To disable admin auth: --disable-admin-api-key or AZTEC_DISABLE_ADMIN_API_KEY=true');
154
+ userLog(separator);
155
+ userLog('');
156
+ }
109
157
  }
110
158
  }