@aztec/aztec 0.0.1-commit.f504929 → 0.0.1-commit.f5a9928

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/dest/bin/index.js +4 -2
  2. package/dest/cli/aztec_start_action.d.ts +1 -1
  3. package/dest/cli/aztec_start_action.d.ts.map +1 -1
  4. package/dest/cli/aztec_start_action.js +42 -33
  5. package/dest/cli/aztec_start_options.d.ts +2 -2
  6. package/dest/cli/aztec_start_options.d.ts.map +1 -1
  7. package/dest/cli/aztec_start_options.js +22 -18
  8. package/dest/cli/cmds/compile.d.ts +1 -1
  9. package/dest/cli/cmds/compile.d.ts.map +1 -1
  10. package/dest/cli/cmds/compile.js +35 -21
  11. package/dest/cli/cmds/profile.d.ts +1 -1
  12. package/dest/cli/cmds/profile.d.ts.map +1 -1
  13. package/dest/cli/cmds/profile.js +1 -1
  14. package/dest/cli/cmds/profile_flamegraph.d.ts +1 -1
  15. package/dest/cli/cmds/profile_flamegraph.d.ts.map +1 -1
  16. package/dest/cli/cmds/profile_flamegraph.js +2 -1
  17. package/dest/cli/cmds/profile_gates.d.ts +2 -2
  18. package/dest/cli/cmds/profile_gates.d.ts.map +1 -1
  19. package/dest/cli/cmds/profile_gates.js +23 -4
  20. package/dest/cli/cmds/prover.d.ts +4 -0
  21. package/dest/cli/cmds/prover.d.ts.map +1 -0
  22. package/dest/cli/cmds/prover.js +24 -0
  23. package/dest/cli/cmds/standby.d.ts +56 -0
  24. package/dest/cli/cmds/standby.d.ts.map +1 -0
  25. package/dest/cli/cmds/standby.js +140 -0
  26. package/dest/cli/cmds/start_bot.d.ts +1 -1
  27. package/dest/cli/cmds/start_bot.d.ts.map +1 -1
  28. package/dest/cli/cmds/start_bot.js +8 -4
  29. package/dest/cli/cmds/start_node.d.ts +3 -2
  30. package/dest/cli/cmds/start_node.d.ts.map +1 -1
  31. package/dest/cli/cmds/start_node.js +36 -112
  32. package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
  33. package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
  34. package/dest/cli/cmds/start_prover_agent.js +5 -17
  35. package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
  36. package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
  37. package/dest/cli/cmds/start_prover_broker.js +22 -13
  38. package/dest/cli/cmds/start_txe.d.ts +2 -2
  39. package/dest/cli/cmds/start_txe.d.ts.map +1 -1
  40. package/dest/cli/cmds/start_txe.js +6 -5
  41. package/dest/cli/cmds/utils/artifacts.d.ts +6 -1
  42. package/dest/cli/cmds/utils/artifacts.d.ts.map +1 -1
  43. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts +21 -0
  44. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts.map +1 -0
  45. package/dest/cli/cmds/utils/collect_crate_dirs.js +114 -0
  46. package/dest/cli/cmds/utils/needs_recompile.d.ts +10 -0
  47. package/dest/cli/cmds/utils/needs_recompile.d.ts.map +1 -0
  48. package/dest/cli/cmds/utils/needs_recompile.js +90 -0
  49. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +4 -0
  50. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -0
  51. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +61 -0
  52. package/dest/cli/util.d.ts +9 -6
  53. package/dest/cli/util.d.ts.map +1 -1
  54. package/dest/cli/util.js +26 -94
  55. package/dest/deploy/bridging.d.ts +84 -0
  56. package/dest/deploy/bridging.d.ts.map +1 -0
  57. package/dest/deploy/bridging.js +121 -0
  58. package/dest/deploy/fees.d.ts +120 -0
  59. package/dest/deploy/fees.d.ts.map +1 -0
  60. package/dest/deploy/fees.js +278 -0
  61. package/dest/deploy/graph.d.ts +40 -0
  62. package/dest/deploy/graph.d.ts.map +1 -0
  63. package/dest/deploy/graph.js +120 -0
  64. package/dest/deploy/index.d.ts +19 -0
  65. package/dest/deploy/index.d.ts.map +1 -0
  66. package/dest/deploy/index.js +15 -0
  67. package/dest/deploy/reporter.d.ts +106 -0
  68. package/dest/deploy/reporter.d.ts.map +1 -0
  69. package/dest/deploy/reporter.js +76 -0
  70. package/dest/deploy/runner.d.ts +8 -0
  71. package/dest/deploy/runner.d.ts.map +1 -0
  72. package/dest/deploy/runner.js +886 -0
  73. package/dest/deploy/state.d.ts +19 -0
  74. package/dest/deploy/state.d.ts.map +1 -0
  75. package/dest/deploy/state.js +59 -0
  76. package/dest/deploy/types.d.ts +233 -0
  77. package/dest/deploy/types.d.ts.map +1 -0
  78. package/dest/deploy/types.js +9 -0
  79. package/dest/examples/token.js +3 -3
  80. package/dest/local-network/auth_registry.d.ts +5 -0
  81. package/dest/local-network/auth_registry.d.ts.map +1 -0
  82. package/dest/local-network/auth_registry.js +17 -0
  83. package/dest/local-network/banana_fpc.d.ts +3 -2
  84. package/dest/local-network/banana_fpc.d.ts.map +1 -1
  85. package/dest/local-network/banana_fpc.js +11 -7
  86. package/dest/local-network/local-network.d.ts +10 -32
  87. package/dest/local-network/local-network.d.ts.map +1 -1
  88. package/dest/local-network/local-network.js +60 -73
  89. package/dest/testing/cheat_codes.d.ts +17 -23
  90. package/dest/testing/cheat_codes.d.ts.map +1 -1
  91. package/dest/testing/cheat_codes.js +17 -43
  92. package/dest/testing/epoch_test_settler.d.ts +2 -2
  93. package/dest/testing/epoch_test_settler.d.ts.map +1 -1
  94. package/dest/testing/epoch_test_settler.js +6 -26
  95. package/dest/testing/index.d.ts +3 -2
  96. package/dest/testing/index.d.ts.map +1 -1
  97. package/dest/testing/index.js +2 -1
  98. package/dest/testing/local-network.d.ts +51 -0
  99. package/dest/testing/local-network.d.ts.map +1 -0
  100. package/dest/testing/local-network.js +60 -0
  101. package/dest/testing/token_allowed_setup.d.ts +12 -0
  102. package/dest/testing/token_allowed_setup.d.ts.map +1 -0
  103. package/dest/testing/token_allowed_setup.js +24 -0
  104. package/package.json +38 -35
  105. package/scripts/add_crate.sh +11 -60
  106. package/scripts/aztec.sh +9 -2
  107. package/scripts/init.sh +5 -5
  108. package/scripts/new.sh +2 -2
  109. package/scripts/setup_workspace.sh +3 -2
  110. package/scripts/templates/blank/contract/Nargo.toml +6 -0
  111. package/scripts/templates/blank/contract/src/main.nr +10 -0
  112. package/scripts/templates/blank/test/Nargo.toml +7 -0
  113. package/scripts/templates/blank/test/src/lib.nr +11 -0
  114. package/scripts/templates/counter/contract/Nargo.toml +7 -0
  115. package/scripts/templates/counter/contract/src/main.nr +48 -0
  116. package/scripts/templates/counter/test/Nargo.toml +7 -0
  117. package/scripts/templates/counter/test/src/lib.nr +32 -0
  118. package/src/bin/index.ts +4 -2
  119. package/src/cli/aztec_start_action.ts +44 -27
  120. package/src/cli/aztec_start_options.ts +28 -25
  121. package/src/cli/cmds/compile.ts +41 -20
  122. package/src/cli/cmds/profile.ts +2 -1
  123. package/src/cli/cmds/profile_flamegraph.ts +2 -1
  124. package/src/cli/cmds/profile_gates.ts +22 -5
  125. package/src/cli/cmds/prover.ts +42 -0
  126. package/src/cli/cmds/standby.ts +184 -0
  127. package/src/cli/cmds/start_bot.ts +9 -6
  128. package/src/cli/cmds/start_node.ts +46 -131
  129. package/src/cli/cmds/start_prover_agent.ts +5 -8
  130. package/src/cli/cmds/start_prover_broker.ts +23 -24
  131. package/src/cli/cmds/start_txe.ts +7 -5
  132. package/src/cli/cmds/utils/artifacts.ts +5 -0
  133. package/src/cli/cmds/utils/collect_crate_dirs.ts +118 -0
  134. package/src/cli/cmds/utils/needs_recompile.ts +98 -0
  135. package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +76 -0
  136. package/src/cli/util.ts +26 -100
  137. package/src/deploy/bridging.ts +191 -0
  138. package/src/deploy/fees.ts +322 -0
  139. package/src/deploy/graph.ts +137 -0
  140. package/src/deploy/index.ts +41 -0
  141. package/src/deploy/reporter.ts +184 -0
  142. package/src/deploy/runner.ts +936 -0
  143. package/src/deploy/state.ts +66 -0
  144. package/src/deploy/types.ts +244 -0
  145. package/src/examples/token.ts +11 -3
  146. package/src/local-network/auth_registry.ts +19 -0
  147. package/src/local-network/banana_fpc.ts +12 -8
  148. package/src/local-network/local-network.ts +67 -83
  149. package/src/testing/cheat_codes.ts +18 -49
  150. package/src/testing/epoch_test_settler.ts +8 -32
  151. package/src/testing/index.ts +2 -1
  152. package/src/testing/local-network.ts +97 -0
  153. package/src/testing/token_allowed_setup.ts +26 -0
  154. package/dest/cli/cmds/start_archiver.d.ts +0 -9
  155. package/dest/cli/cmds/start_archiver.d.ts.map +0 -1
  156. package/dest/cli/cmds/start_archiver.js +0 -48
  157. package/dest/cli/release_version.d.ts +0 -2
  158. package/dest/cli/release_version.d.ts.map +0 -1
  159. package/dest/cli/release_version.js +0 -14
  160. package/dest/testing/anvil_test_watcher.d.ts +0 -42
  161. package/dest/testing/anvil_test_watcher.d.ts.map +0 -1
  162. package/dest/testing/anvil_test_watcher.js +0 -181
  163. package/src/cli/cmds/start_archiver.ts +0 -50
  164. package/src/cli/release_version.ts +0 -21
  165. package/src/testing/anvil_test_watcher.ts +0 -210
@@ -0,0 +1,24 @@
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 the allowlist entries needed for FPC-based fee payments, keyed by the contract class of
6
+ * the `artifact` actually deployed as the fee token (defaults to canonical Token). The setup-phase
7
+ * validator matches these entries by class id, so a test deploying the codegen'd TestToken as its
8
+ * fee vehicle must pass `TestTokenContract.artifact` here -- otherwise the FPC fee calls are matched
9
+ * against the wrong class and rejected. Test-only: FPC fee payment with custom tokens won't work on
10
+ * mainnet alpha.
11
+ */ export async function getTokenAllowedSetupFunctions(artifact = TokenContractArtifact) {
12
+ const tokenClassId = (await getContractClassFromArtifact(artifact)).id;
13
+ const target = {
14
+ classId: tokenClassId
15
+ };
16
+ return Promise.all([
17
+ // needed for private transfers via FPC (transfer_to_public enqueues this)
18
+ buildAllowedElement(artifact, target, '_increase_public_balance', {
19
+ onlySelf: true
20
+ }),
21
+ // needed for public transfers via FPC (fee_entrypoint_public enqueues this)
22
+ buildAllowedElement(artifact, target, 'transfer_in_public')
23
+ ]);
24
+ }
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@aztec/aztec",
3
- "version": "0.0.1-commit.f504929",
3
+ "version": "0.0.1-commit.f5a9928",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
7
+ "./deploy": "./dest/deploy/index.js",
7
8
  "./testing": "./dest/testing/index.js"
8
9
  },
9
10
  "bin": "./scripts/aztec.sh",
@@ -28,46 +29,48 @@
28
29
  "../package.common.json"
29
30
  ],
30
31
  "dependencies": {
31
- "@aztec/accounts": "0.0.1-commit.f504929",
32
- "@aztec/archiver": "0.0.1-commit.f504929",
33
- "@aztec/aztec-faucet": "0.0.1-commit.f504929",
34
- "@aztec/aztec-node": "0.0.1-commit.f504929",
35
- "@aztec/aztec.js": "0.0.1-commit.f504929",
36
- "@aztec/bb-prover": "0.0.1-commit.f504929",
37
- "@aztec/bb.js": "0.0.1-commit.f504929",
38
- "@aztec/blob-client": "0.0.1-commit.f504929",
39
- "@aztec/bot": "0.0.1-commit.f504929",
40
- "@aztec/builder": "0.0.1-commit.f504929",
41
- "@aztec/cli": "0.0.1-commit.f504929",
42
- "@aztec/constants": "0.0.1-commit.f504929",
43
- "@aztec/entrypoints": "0.0.1-commit.f504929",
44
- "@aztec/ethereum": "0.0.1-commit.f504929",
45
- "@aztec/foundation": "0.0.1-commit.f504929",
46
- "@aztec/kv-store": "0.0.1-commit.f504929",
47
- "@aztec/l1-artifacts": "0.0.1-commit.f504929",
48
- "@aztec/node-lib": "0.0.1-commit.f504929",
49
- "@aztec/noir-contracts.js": "0.0.1-commit.f504929",
50
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.f504929",
51
- "@aztec/p2p": "0.0.1-commit.f504929",
52
- "@aztec/p2p-bootstrap": "0.0.1-commit.f504929",
53
- "@aztec/protocol-contracts": "0.0.1-commit.f504929",
54
- "@aztec/prover-client": "0.0.1-commit.f504929",
55
- "@aztec/prover-node": "0.0.1-commit.f504929",
56
- "@aztec/pxe": "0.0.1-commit.f504929",
57
- "@aztec/sequencer-client": "0.0.1-commit.f504929",
58
- "@aztec/stdlib": "0.0.1-commit.f504929",
59
- "@aztec/telemetry-client": "0.0.1-commit.f504929",
60
- "@aztec/txe": "0.0.1-commit.f504929",
61
- "@aztec/validator-ha-signer": "0.0.1-commit.f504929",
62
- "@aztec/wallets": "0.0.1-commit.f504929",
63
- "@aztec/world-state": "0.0.1-commit.f504929",
32
+ "@aztec/accounts": "0.0.1-commit.f5a9928",
33
+ "@aztec/archiver": "0.0.1-commit.f5a9928",
34
+ "@aztec/aztec-node": "0.0.1-commit.f5a9928",
35
+ "@aztec/aztec.js": "0.0.1-commit.f5a9928",
36
+ "@aztec/bb-prover": "0.0.1-commit.f5a9928",
37
+ "@aztec/bb.js": "0.0.1-commit.f5a9928",
38
+ "@aztec/blob-client": "0.0.1-commit.f5a9928",
39
+ "@aztec/bot": "0.0.1-commit.f5a9928",
40
+ "@aztec/builder": "0.0.1-commit.f5a9928",
41
+ "@aztec/cli": "0.0.1-commit.f5a9928",
42
+ "@aztec/constants": "0.0.1-commit.f5a9928",
43
+ "@aztec/entrypoints": "0.0.1-commit.f5a9928",
44
+ "@aztec/ethereum": "0.0.1-commit.f5a9928",
45
+ "@aztec/foundation": "0.0.1-commit.f5a9928",
46
+ "@aztec/kv-store": "0.0.1-commit.f5a9928",
47
+ "@aztec/l1-artifacts": "0.0.1-commit.f5a9928",
48
+ "@aztec/node-lib": "0.0.1-commit.f5a9928",
49
+ "@aztec/noir-contracts.js": "0.0.1-commit.f5a9928",
50
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.f5a9928",
51
+ "@aztec/p2p": "0.0.1-commit.f5a9928",
52
+ "@aztec/p2p-bootstrap": "0.0.1-commit.f5a9928",
53
+ "@aztec/protocol-contracts": "0.0.1-commit.f5a9928",
54
+ "@aztec/prover-client": "0.0.1-commit.f5a9928",
55
+ "@aztec/prover-node": "0.0.1-commit.f5a9928",
56
+ "@aztec/pxe": "0.0.1-commit.f5a9928",
57
+ "@aztec/sequencer-client": "0.0.1-commit.f5a9928",
58
+ "@aztec/standard-contracts": "0.0.1-commit.f5a9928",
59
+ "@aztec/stdlib": "0.0.1-commit.f5a9928",
60
+ "@aztec/telemetry-client": "0.0.1-commit.f5a9928",
61
+ "@aztec/txe": "0.0.1-commit.f5a9928",
62
+ "@aztec/validator-ha-signer": "0.0.1-commit.f5a9928",
63
+ "@aztec/wallets": "0.0.1-commit.f5a9928",
64
+ "@aztec/world-state": "0.0.1-commit.f5a9928",
65
+ "@iarna/toml": "^2.2.5",
64
66
  "@types/chalk": "^2.2.0",
65
67
  "abitype": "^0.8.11",
66
68
  "chalk": "^5.3.0",
67
69
  "commander": "^12.1.0",
68
70
  "koa": "^2.16.1",
69
71
  "koa-router": "^13.1.1",
70
- "viem": "npm:@aztec/viem@2.38.2"
72
+ "viem": "npm:@aztec/viem@2.38.2",
73
+ "zod": "^4"
71
74
  },
72
75
  "files": [
73
76
  "dest",
@@ -2,10 +2,11 @@
2
2
  set -euo pipefail
3
3
 
4
4
  # Creates a contract+test crate pair and adds them to an existing workspace.
5
- # Usage: add_crate.sh <crate_name>
5
+ # Usage: add_crate.sh <crate_name> <template>
6
6
  # Must be called from a workspace root that already has Nargo.toml with [workspace].
7
7
 
8
8
  crate_name=$1
9
+ template=$2
9
10
 
10
11
  if [ -z "$crate_name" ]; then
11
12
  echo "Error: crate name is required"
@@ -31,72 +32,22 @@ fi
31
32
 
32
33
  # Get the actual aztec version for the git tag.
33
34
  AZTEC_VERSION=$(jq -r '.version' $(dirname $0)/../package.json)
35
+ TEMPLATE_DIR="$(dirname $0)/templates/$template"
34
36
 
35
- # Create contract crate
36
- mkdir -p "$contract_dir/src"
37
- cat > "$contract_dir/Nargo.toml" << CEOF
38
- [package]
39
- name = "${crate_name}_contract"
40
- type = "contract"
41
-
42
- [dependencies]
43
- aztec = { git="https://github.com/AztecProtocol/aztec-nr", tag="v${AZTEC_VERSION}", directory="aztec" }
44
- CEOF
45
-
46
- cat > "$contract_dir/src/main.nr" << 'EOF'
47
- use aztec::macros::aztec;
48
-
49
- #[aztec]
50
- pub contract Main {
51
- use aztec::macros::functions::{external, initializer};
52
-
53
- #[initializer]
54
- #[external("private")]
55
- fn constructor() {}
56
- }
57
- EOF
58
-
59
- # Create test crate
60
- mkdir -p "$test_dir/src"
61
- cat > "$test_dir/Nargo.toml" << TEOF
62
- [package]
63
- name = "${crate_name}_test"
64
- type = "lib"
65
-
66
- [dependencies]
67
- aztec = { git="https://github.com/AztecProtocol/aztec-nr", tag="v${AZTEC_VERSION}", directory="aztec" }
68
- ${crate_name}_contract = { path = "../${contract_dir}" }
69
- TEOF
70
-
71
- cat > "$test_dir/src/lib.nr" << 'NOIR'
72
- use aztec::test::helpers::test_environment::TestEnvironment;
73
- use __CRATE_NAME___contract::Main;
74
-
75
- #[test]
76
- unconstrained fn test_constructor() {
77
- let mut env = TestEnvironment::new();
78
- let deployer = env.create_light_account();
79
-
80
- // Deploy the contract with the default constructor:
81
- let contract_address = env.deploy("@__CRATE_NAME___contract/Main").with_private_initializer(
82
- deployer,
83
- Main::interface().constructor(),
84
- );
85
-
86
- // Deploy without an initializer:
87
- let contract_address = env.deploy("@__CRATE_NAME___contract/Main").without_initializer();
88
- }
89
- NOIR
90
-
91
- sed -i "s/__CRATE_NAME__/${crate_name}/g" "$test_dir/src/lib.nr"
37
+ # Copy template crates and substitute placeholders
38
+ cp -r "$TEMPLATE_DIR/contract" "$contract_dir"
39
+ cp -r "$TEMPLATE_DIR/test" "$test_dir"
40
+ # Use perl -i for portability across os.
41
+ find "$contract_dir" "$test_dir" -type f -exec \
42
+ perl -i -pe "s/__CRATE_NAME__/${crate_name}/g; s/__AZTEC_VERSION__/${AZTEC_VERSION}/g" {} +
92
43
 
93
44
  # Add members to workspace Nargo.toml
94
45
  if grep -q 'members\s*=\s*\[\s*\]' Nargo.toml; then
95
46
  # Empty array: members = []
96
- sed -i "s|members\s*=\s*\[\s*\]|members = [\"${contract_dir}\", \"${test_dir}\"]|" Nargo.toml
47
+ perl -i -pe "s|members\s*=\s*\[\s*\]|members = [\"${contract_dir}\", \"${test_dir}\"]|" Nargo.toml
97
48
  else
98
49
  # Non-empty array: add before closing ]
99
- sed -i "s|\(members\s*=\s*\[.*\)\]|\1, \"${contract_dir}\", \"${test_dir}\"]|" Nargo.toml
50
+ perl -i -pe "s|(members\s*=\s*\[.*)\]|\1, \"${contract_dir}\", \"${test_dir}\"]|" Nargo.toml
100
51
  fi
101
52
 
102
53
  echo "Created crates '${contract_dir}' and '${test_dir}'"
package/scripts/aztec.sh CHANGED
@@ -20,13 +20,20 @@ function aztec {
20
20
 
21
21
  case $cmd in
22
22
  test)
23
- export LOG_LEVEL="${LOG_LEVEL:-"error;trace:contract_log"}"
23
+ # Attempt to compile, no-op if there are no changes
24
+ node --no-warnings "$script_dir/../dest/bin/index.js" compile
25
+
26
+ export LOG_LEVEL="${LOG_LEVEL:-"error;trace:^contract:"}"
24
27
  aztec start --txe --port 8081 &
25
28
  server_pid=$!
26
29
  trap 'kill $server_pid &>/dev/null || true' EXIT
30
+ if ! command -v nc &>/dev/null; then
31
+ echo "Error: 'nc' (netcat) is required but not installed." >&2
32
+ exit 1
33
+ fi
27
34
  while ! nc -z 127.0.0.1 8081 &>/dev/null; do sleep 0.2; done
28
35
  export NARGO_FOREIGN_CALL_TIMEOUT=300000
29
- nargo test --silence-warnings --oracle-resolver http://127.0.0.1:8081 --test-threads 16 "$@"
36
+ nargo test --silence-warnings --oracle-resolver http://127.0.0.1:8081 "$@"
30
37
  ;;
31
38
  start)
32
39
  if [ "${1:-}" == "--local-network" ]; then
package/scripts/init.sh CHANGED
@@ -16,11 +16,11 @@ Options:
16
16
  -h, --help Print help
17
17
 
18
18
  This command creates a new Aztec Noir project in the current directory with
19
- a workspace containing a contract crate and a test crate, and automatically
20
- adds the Aztec.nr dependency to both.
19
+ a workspace containing a Counter contract example with tests. The Counter
20
+ demonstrates private state, private functions, and utility reads.
21
21
 
22
- If a workspace already exists in the current directory, use
23
- 'aztec new <name>' instead to add another contract.
22
+ Use 'aztec new <name>' to create a blank contract project, or to add another
23
+ contract to an existing workspace.
24
24
  EOF
25
25
  exit 0
26
26
  ;;
@@ -36,4 +36,4 @@ done
36
36
  package_name="$(basename $(pwd))"
37
37
 
38
38
  echo "Initializing Aztec contract project..."
39
- $script_path/setup_workspace.sh "$package_name"
39
+ $script_path/setup_workspace.sh "$package_name" counter
package/scripts/new.sh CHANGED
@@ -68,7 +68,7 @@ fi
68
68
  if [ -f "Nargo.toml" ] && grep -q '\[workspace\]' Nargo.toml; then
69
69
  # Add crate pair to existing workspace
70
70
  echo "Adding contract '$package_name' to existing workspace..."
71
- $script_path/add_crate.sh "$package_name"
71
+ $script_path/add_crate.sh "$package_name" blank
72
72
  else
73
73
  # Create new workspace
74
74
  if [ -d "$project_path" ] && [ "$(ls -A $project_path 2>/dev/null)" ]; then
@@ -79,5 +79,5 @@ else
79
79
  echo "Creating new Aztec contract project at $project_path..."
80
80
  mkdir -p "$project_path"
81
81
  cd "$project_path"
82
- $script_path/setup_workspace.sh "$package_name"
82
+ $script_path/setup_workspace.sh "$package_name" blank
83
83
  fi
@@ -2,10 +2,11 @@
2
2
  set -euo pipefail
3
3
 
4
4
  # Creates an Aztec contract workspace with a contract crate and a test crate.
5
- # Usage: setup_workspace.sh <package_name>
5
+ # Usage: setup_workspace.sh <package_name> <template>
6
6
  # Must be called from the workspace root directory.
7
7
 
8
8
  package_name=$1
9
+ template=$2
9
10
  script_path=$(realpath $(dirname "$0"))
10
11
 
11
12
  if [ -z "$package_name" ]; then
@@ -26,7 +27,7 @@ members = []
26
27
  EOF
27
28
 
28
29
  # Create the first crate pair
29
- $script_path/add_crate.sh "$package_name"
30
+ $script_path/add_crate.sh "$package_name" "$template"
30
31
 
31
32
  # Create README
32
33
  cat > README.md << REOF
@@ -0,0 +1,6 @@
1
+ [package]
2
+ name = "__CRATE_NAME___contract"
3
+ type = "contract"
4
+
5
+ [dependencies]
6
+ aztec = { git="https://github.com/AztecProtocol/aztec-nr", tag="v__AZTEC_VERSION__", directory="aztec" }
@@ -0,0 +1,10 @@
1
+ use aztec::macros::aztec;
2
+
3
+ #[aztec]
4
+ pub contract Main {
5
+ use aztec::macros::functions::{external, initializer};
6
+
7
+ #[initializer]
8
+ #[external("private")]
9
+ fn constructor() {}
10
+ }
@@ -0,0 +1,7 @@
1
+ [package]
2
+ name = "__CRATE_NAME___test"
3
+ type = "lib"
4
+
5
+ [dependencies]
6
+ aztec = { git="https://github.com/AztecProtocol/aztec-nr", tag="v__AZTEC_VERSION__", directory="aztec" }
7
+ __CRATE_NAME___contract = { path = "../__CRATE_NAME___contract" }
@@ -0,0 +1,11 @@
1
+ use aztec::test::helpers::test_environment::TestEnvironment;
2
+ use __CRATE_NAME___contract::Main;
3
+
4
+ #[test]
5
+ unconstrained fn test_constructor() {
6
+ let mut env = TestEnvironment::new();
7
+ let deployer = env.create_light_account();
8
+
9
+ let _contract_address = env.deploy("@__CRATE_NAME___contract/Main")
10
+ .with_private_initializer(deployer, Main::interface().constructor());
11
+ }
@@ -0,0 +1,7 @@
1
+ [package]
2
+ name = "__CRATE_NAME___contract"
3
+ type = "contract"
4
+
5
+ [dependencies]
6
+ aztec = { git="https://github.com/AztecProtocol/aztec-nr", tag="v__AZTEC_VERSION__", directory="aztec" }
7
+ balance_set = { git="https://github.com/AztecProtocol/aztec-nr", tag="v__AZTEC_VERSION__", directory="balance-set" }
@@ -0,0 +1,48 @@
1
+ use aztec::macros::aztec;
2
+
3
+ #[aztec]
4
+ pub contract Counter {
5
+ use aztec::{
6
+ macros::{functions::{external, initializer}, storage::storage},
7
+ messages::delivery::MessageDelivery,
8
+ protocol::address::AztecAddress,
9
+ state_vars::Owned,
10
+ };
11
+ use balance_set::BalanceSet;
12
+
13
+ #[storage]
14
+ struct Storage<Context> {
15
+ // Each owner has their own counter, stored as private encrypted notes.
16
+ // Owned: dictates who will receive the encrypted notes.
17
+ // BalanceSet: manages the underlying notes, providing add/sub/balance_of.
18
+ counters: Owned<BalanceSet<Context>, Context>,
19
+ }
20
+
21
+ // Sets the owner's counter to an initial value.
22
+ //
23
+ // #[external("private")]: executes on the user's device, inputs are hidden from everyone.
24
+ #[initializer]
25
+ #[external("private")]
26
+ fn constructor(initial_value: u128, owner: AztecAddress) {
27
+ // Delivers the note to the recipient onchain.
28
+ // Without delivery, the recipient can't find or decrypt the note.
29
+ self.storage.counters.at(owner).add(initial_value).deliver(
30
+ MessageDelivery::onchain_unconstrained(),
31
+ );
32
+ }
33
+
34
+ // Adds 1 to the owner's counter.
35
+ #[external("private")]
36
+ fn increment(owner: AztecAddress) {
37
+ self.storage.counters.at(owner).add(1).deliver(MessageDelivery::onchain_unconstrained());
38
+ }
39
+
40
+ // Returns the current value of the owner's counter.
41
+ //
42
+ // #[external("utility")]: runs off-chain, no transaction created, no cost.
43
+ // Only the owner can decrypt and read their own counter.
44
+ #[external("utility")]
45
+ unconstrained fn get_counter(owner: AztecAddress) -> u128 {
46
+ self.storage.counters.at(owner).balance_of()
47
+ }
48
+ }
@@ -0,0 +1,7 @@
1
+ [package]
2
+ name = "__CRATE_NAME___test"
3
+ type = "lib"
4
+
5
+ [dependencies]
6
+ aztec = { git="https://github.com/AztecProtocol/aztec-nr", tag="v__AZTEC_VERSION__", directory="aztec" }
7
+ __CRATE_NAME___contract = { path = "../__CRATE_NAME___contract" }
@@ -0,0 +1,32 @@
1
+ use aztec::{protocol::address::AztecAddress, test::helpers::test_environment::TestEnvironment};
2
+ use __CRATE_NAME___contract::Counter;
3
+
4
+ unconstrained fn setup(initial_value: u128) -> (TestEnvironment, AztecAddress, AztecAddress) {
5
+ let mut env = TestEnvironment::new();
6
+ let owner = env.create_light_account();
7
+
8
+ let contract_address = env.deploy("@__CRATE_NAME___contract/Counter")
9
+ .with_private_initializer(owner, Counter::interface().constructor(initial_value, owner));
10
+
11
+ (env, contract_address, owner)
12
+ }
13
+
14
+ #[test]
15
+ unconstrained fn test_constructor() {
16
+ let initial_value = 5;
17
+ let (env, contract_address, owner) = setup(initial_value);
18
+
19
+ let counter = env.execute_utility(Counter::at(contract_address).get_counter(owner));
20
+ assert_eq(counter, initial_value);
21
+ }
22
+
23
+ #[test]
24
+ unconstrained fn test_increment() {
25
+ let initial_value = 5;
26
+ let (mut env, contract_address, owner) = setup(initial_value);
27
+
28
+ env.call_private(owner, Counter::at(contract_address).increment(owner));
29
+
30
+ let counter = env.execute_utility(Counter::at(contract_address).get_counter(owner));
31
+ assert_eq(counter, initial_value + 1);
32
+ }
package/src/bin/index.ts CHANGED
@@ -11,14 +11,15 @@ 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
 
17
18
  import { injectCompileCommand } from '../cli/cmds/compile.js';
18
19
  import { injectMigrateCommand } from '../cli/cmds/migrate_ha_db.js';
19
20
  import { injectProfileCommand } from '../cli/cmds/profile.js';
21
+ import { injectProverCommand } from '../cli/cmds/prover.js';
20
22
  import { injectAztecCommands } from '../cli/index.js';
21
- import { getCliVersion } from '../cli/release_version.js';
22
23
 
23
24
  const NETWORK_FLAG = 'network';
24
25
 
@@ -47,7 +48,7 @@ async function main() {
47
48
  await enrichEnvironmentWithNetworkConfig(networkName);
48
49
  enrichEnvironmentWithChainName(networkName);
49
50
 
50
- const cliVersion = getCliVersion();
51
+ const cliVersion = getPackageVersion();
51
52
  let program = new Command('aztec');
52
53
  program.description('Aztec command line interface').version(cliVersion).enablePositionalOptions();
53
54
  program = injectAztecCommands(program, userLog, debugLogger);
@@ -61,6 +62,7 @@ async function main() {
61
62
  program = injectCompileCommand(program, userLog);
62
63
  program = injectProfileCommand(program, userLog);
63
64
  program = injectMigrateCommand(program, userLog);
65
+ program = injectProverCommand(program, userLog);
64
66
 
65
67
  await program.parseAsync(process.argv);
66
68
  }
@@ -1,3 +1,5 @@
1
+ import { registerAztecNodeRpcHandlers } from '@aztec/aztec-node';
2
+ import { getActiveNetworkName } from '@aztec/foundation/config';
1
3
  import {
2
4
  type NamespacedApiHandlers,
3
5
  createNamespacedSafeJsonRpcServer,
@@ -5,15 +7,18 @@ import {
5
7
  startHttpRpcServer,
6
8
  } from '@aztec/foundation/json-rpc/server';
7
9
  import type { LogFn, Logger } from '@aztec/foundation/log';
8
- import type { ChainConfig } from '@aztec/stdlib/config';
9
- import { AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
10
+ import { type ChainConfig, getRpcCorsAllowedOrigins } from '@aztec/stdlib/config';
11
+ import { getPackageVersion } from '@aztec/stdlib/update-checker';
10
12
  import { getVersioningMiddleware } from '@aztec/stdlib/versioning';
11
- import { getOtelJsonRpcPropagationMiddleware } from '@aztec/telemetry-client';
13
+ import {
14
+ getOtelJsonRpcDiagnosticsMiddleware,
15
+ getOtelJsonRpcPropagationMiddleware,
16
+ getOtelJsonRpcServerMetricsMiddleware,
17
+ } from '@aztec/telemetry-client';
12
18
 
13
19
  import { createLocalNetwork } from '../local-network/index.js';
14
20
  import { github, splash } from '../splash.js';
15
21
  import { resolveAdminApiKey } from './admin_api_key_store.js';
16
- import { getCliVersion } from './release_version.js';
17
22
  import { extractNamespacedOptions, installSignalHandlers } from './util.js';
18
23
  import { getVersions } from './versioning.js';
19
24
 
@@ -22,33 +27,26 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
22
27
  const signalHandlers: Array<() => Promise<void>> = [];
23
28
  const services: NamespacedApiHandlers = {};
24
29
  const adminServices: NamespacedApiHandlers = {};
30
+ const packageVersion = getPackageVersion();
25
31
  let config: ChainConfig | undefined = undefined;
26
32
 
27
33
  if (options.localNetwork) {
28
- const cliVersion = getCliVersion();
29
- const localNetwork = extractNamespacedOptions(options, 'local-network');
30
- localNetwork.testAccounts = true;
34
+ const localNetwork = extractNamespacedOptions(options, 'localNetwork');
31
35
  userLog(`${splash}\n${github}\n\n`);
32
- userLog(`Setting up Aztec local network ${cliVersion}, please stand by...`);
36
+ userLog(`Setting up Aztec local network ${packageVersion}, please stand by...`);
33
37
 
34
38
  const { node, stop } = await createLocalNetwork(
35
39
  {
36
40
  l1Mnemonic: localNetwork.l1Mnemonic,
37
41
  l1RpcUrls: options.l1RpcUrls,
38
42
  testAccounts: localNetwork.testAccounts,
39
- realProofs: false,
40
- // Setting the epoch duration to 2 by default for local network. This allows the epoch to be "proven" faster, so
41
- // the users can consume out hash without having to wait for a long time.
42
- // Note: We are not proving anything in the local network (realProofs == false). But in `createLocalNetwork`,
43
- // the EpochTestSettler will set the out hash to the outbox when an epoch is complete.
44
- aztecEpochDuration: 2,
45
43
  },
46
44
  userLog,
47
45
  );
48
46
 
49
47
  // Start Node and PXE JSON-RPC server
50
48
  signalHandlers.push(stop);
51
- services.node = [node, AztecNodeApiSchema];
49
+ registerAztecNodeRpcHandlers(node, services, adminServices, { debug: true });
52
50
  } else {
53
51
  // Route --prover-node through startNode
54
52
  if (options.proverNode && !options.node) {
@@ -57,13 +55,11 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
57
55
 
58
56
  if (options.node) {
59
57
  const { startNode } = await import('./cmds/start_node.js');
60
- ({ config } = await startNode(options, signalHandlers, services, adminServices, userLog));
58
+ const networkName = getActiveNetworkName(options.network);
59
+ ({ config } = await startNode(options, signalHandlers, services, adminServices, userLog, networkName));
61
60
  } else if (options.bot) {
62
61
  const { startBot } = await import('./cmds/start_bot.js');
63
62
  await startBot(options, signalHandlers, services, userLog);
64
- } else if (options.archiver) {
65
- const { startArchiver } = await import('./cmds/start_archiver.js');
66
- ({ config } = await startArchiver(options, signalHandlers, services));
67
63
  } else if (options.p2pBootstrap) {
68
64
  const { startP2PBootstrap } = await import('./cmds/start_p2p_bootstrap.js');
69
65
  ({ config } = await startP2PBootstrap(options, signalHandlers, services, userLog));
@@ -75,7 +71,7 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
75
71
  await startProverBroker(options, signalHandlers, services, userLog);
76
72
  } else if (options.txe) {
77
73
  const { startTXE } = await import('./cmds/start_txe.js');
78
- await startTXE(options, debugLogger);
74
+ await startTXE(options, signalHandlers, debugLogger);
79
75
  } else if (options.sequencer) {
80
76
  userLog(`Cannot run a standalone sequencer without a node`);
81
77
  process.exit(1);
@@ -87,24 +83,40 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
87
83
 
88
84
  installSignalHandlers(debugLogger.info, signalHandlers);
89
85
  const versions = getVersions(config);
86
+ const versioningOpts = { packageVersion };
90
87
 
91
88
  // Start the main JSON-RPC server
92
89
  if (Object.entries(services).length > 0) {
90
+ if (services.aztec) {
91
+ const { BarretenbergSync } = await import('@aztec/bb.js');
92
+ // JSON-RPC schema parsing may decompress compressed Chonk proofs before the node handler runs.
93
+ await BarretenbergSync.initSingleton();
94
+ }
95
+
93
96
  const rpcServer = createNamespacedSafeJsonRpcServer(services, {
97
+ diagnostic: getOtelJsonRpcDiagnosticsMiddleware(),
94
98
  http200OnError: false,
95
99
  log: debugLogger,
96
- middlewares: [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions)],
100
+ middlewares: [
101
+ getOtelJsonRpcServerMetricsMiddleware(),
102
+ getOtelJsonRpcPropagationMiddleware(),
103
+ getVersioningMiddleware(versions, versioningOpts),
104
+ ],
97
105
  maxBatchSize: options.rpcMaxBatchSize,
98
106
  maxBodySizeBytes: options.rpcMaxBodySize,
107
+ corsAllowedHeaders: options.rpcCorsAllowedHeaders ?? [],
108
+ corsAllowedOrigins: getRpcCorsAllowedOrigins(options),
109
+ });
110
+ const { port } = await startHttpRpcServer(rpcServer, {
111
+ port: options.port,
112
+ keepAliveTimeoutMs: options.rpcHttpKeepAliveTimeoutMs,
113
+ headersTimeoutMs: options.rpcHttpHeadersTimeoutMs,
99
114
  });
100
- const { port } = await startHttpRpcServer(rpcServer, { port: options.port });
101
115
  debugLogger.info(`Aztec Server listening on port ${port}`, versions);
102
116
  }
103
117
 
104
118
  // If there are any admin services, start a separate JSON-RPC server for them
105
119
  if (Object.entries(adminServices).length > 0) {
106
- const adminMiddlewares = [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions)];
107
-
108
120
  // Resolve the admin API key (auto-generated and persisted, or opt-out)
109
121
  const apiKeyResolution = await resolveAdminApiKey(
110
122
  {
@@ -115,13 +127,18 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
115
127
  },
116
128
  debugLogger,
117
129
  );
118
- if (apiKeyResolution) {
119
- adminMiddlewares.unshift(getApiKeyAuthMiddleware(apiKeyResolution.apiKeyHash));
120
- } else {
130
+ if (!apiKeyResolution) {
121
131
  debugLogger.warn('No admin API key set — admin endpoint is unauthenticated');
122
132
  }
133
+ const adminMiddlewares = [
134
+ getOtelJsonRpcServerMetricsMiddleware(),
135
+ ...(apiKeyResolution ? [getApiKeyAuthMiddleware(apiKeyResolution.apiKeyHash)] : []),
136
+ getOtelJsonRpcPropagationMiddleware(),
137
+ getVersioningMiddleware(versions, versioningOpts),
138
+ ];
123
139
 
124
140
  const rpcServer = createNamespacedSafeJsonRpcServer(adminServices, {
141
+ diagnostic: getOtelJsonRpcDiagnosticsMiddleware(),
125
142
  http200OnError: false,
126
143
  log: debugLogger,
127
144
  middlewares: adminMiddlewares,