@aztec/aztec 0.0.1-commit.fff30aa → 0.0.1-dev

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 (58) hide show
  1. package/dest/bin/index.js +1 -1
  2. package/dest/cli/aztec_start_action.js +1 -1
  3. package/dest/cli/aztec_start_options.d.ts +1 -1
  4. package/dest/cli/aztec_start_options.d.ts.map +1 -1
  5. package/dest/cli/aztec_start_options.js +1 -7
  6. package/dest/cli/cmds/compile.d.ts +1 -1
  7. package/dest/cli/cmds/compile.d.ts.map +1 -1
  8. package/dest/cli/cmds/compile.js +6 -8
  9. package/dest/cli/cmds/profile.d.ts +1 -1
  10. package/dest/cli/cmds/profile.d.ts.map +1 -1
  11. package/dest/cli/cmds/profile.js +1 -1
  12. package/dest/cli/cmds/profile_gates.d.ts +2 -2
  13. package/dest/cli/cmds/profile_gates.d.ts.map +1 -1
  14. package/dest/cli/cmds/profile_gates.js +21 -3
  15. package/dest/cli/cmds/standby.d.ts +28 -2
  16. package/dest/cli/cmds/standby.d.ts.map +1 -1
  17. package/dest/cli/cmds/standby.js +44 -1
  18. package/dest/cli/cmds/start_node.d.ts +1 -1
  19. package/dest/cli/cmds/start_node.d.ts.map +1 -1
  20. package/dest/cli/cmds/start_node.js +8 -6
  21. package/dest/cli/cmds/start_prover_agent.js +2 -2
  22. package/dest/cli/cmds/start_prover_broker.js +2 -2
  23. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +1 -1
  24. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -1
  25. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +2 -3
  26. package/dest/cli/util.d.ts +10 -5
  27. package/dest/cli/util.d.ts.map +1 -1
  28. package/dest/cli/util.js +19 -48
  29. package/dest/local-network/banana_fpc.d.ts +1 -1
  30. package/dest/local-network/banana_fpc.d.ts.map +1 -1
  31. package/dest/local-network/banana_fpc.js +8 -6
  32. package/package.json +34 -34
  33. package/scripts/add_crate.sh +11 -60
  34. package/scripts/aztec.sh +0 -1
  35. package/scripts/init.sh +5 -5
  36. package/scripts/new.sh +2 -2
  37. package/scripts/setup_workspace.sh +3 -2
  38. package/scripts/templates/blank/contract/Nargo.toml +6 -0
  39. package/scripts/templates/blank/contract/src/main.nr +10 -0
  40. package/scripts/templates/blank/test/Nargo.toml +7 -0
  41. package/scripts/templates/blank/test/src/lib.nr +11 -0
  42. package/scripts/templates/counter/contract/Nargo.toml +7 -0
  43. package/scripts/templates/counter/contract/src/main.nr +48 -0
  44. package/scripts/templates/counter/test/Nargo.toml +7 -0
  45. package/scripts/templates/counter/test/src/lib.nr +32 -0
  46. package/src/bin/index.ts +1 -1
  47. package/src/cli/aztec_start_action.ts +1 -1
  48. package/src/cli/aztec_start_options.ts +2 -10
  49. package/src/cli/cmds/compile.ts +7 -9
  50. package/src/cli/cmds/profile.ts +2 -1
  51. package/src/cli/cmds/profile_gates.ts +20 -4
  52. package/src/cli/cmds/standby.ts +54 -2
  53. package/src/cli/cmds/start_node.ts +8 -15
  54. package/src/cli/cmds/start_prover_agent.ts +2 -2
  55. package/src/cli/cmds/start_prover_broker.ts +2 -2
  56. package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +2 -3
  57. package/src/cli/util.ts +20 -61
  58. package/src/local-network/banana_fpc.ts +4 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/aztec",
3
- "version": "0.0.1-commit.fff30aa",
3
+ "version": "0.0.1-dev",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
@@ -28,39 +28,39 @@
28
28
  "../package.common.json"
29
29
  ],
30
30
  "dependencies": {
31
- "@aztec/accounts": "0.0.1-commit.fff30aa",
32
- "@aztec/archiver": "0.0.1-commit.fff30aa",
33
- "@aztec/aztec-faucet": "0.0.1-commit.fff30aa",
34
- "@aztec/aztec-node": "0.0.1-commit.fff30aa",
35
- "@aztec/aztec.js": "0.0.1-commit.fff30aa",
36
- "@aztec/bb-prover": "0.0.1-commit.fff30aa",
37
- "@aztec/bb.js": "0.0.1-commit.fff30aa",
38
- "@aztec/blob-client": "0.0.1-commit.fff30aa",
39
- "@aztec/bot": "0.0.1-commit.fff30aa",
40
- "@aztec/builder": "0.0.1-commit.fff30aa",
41
- "@aztec/cli": "0.0.1-commit.fff30aa",
42
- "@aztec/constants": "0.0.1-commit.fff30aa",
43
- "@aztec/entrypoints": "0.0.1-commit.fff30aa",
44
- "@aztec/ethereum": "0.0.1-commit.fff30aa",
45
- "@aztec/foundation": "0.0.1-commit.fff30aa",
46
- "@aztec/kv-store": "0.0.1-commit.fff30aa",
47
- "@aztec/l1-artifacts": "0.0.1-commit.fff30aa",
48
- "@aztec/node-lib": "0.0.1-commit.fff30aa",
49
- "@aztec/noir-contracts.js": "0.0.1-commit.fff30aa",
50
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.fff30aa",
51
- "@aztec/p2p": "0.0.1-commit.fff30aa",
52
- "@aztec/p2p-bootstrap": "0.0.1-commit.fff30aa",
53
- "@aztec/protocol-contracts": "0.0.1-commit.fff30aa",
54
- "@aztec/prover-client": "0.0.1-commit.fff30aa",
55
- "@aztec/prover-node": "0.0.1-commit.fff30aa",
56
- "@aztec/pxe": "0.0.1-commit.fff30aa",
57
- "@aztec/sequencer-client": "0.0.1-commit.fff30aa",
58
- "@aztec/stdlib": "0.0.1-commit.fff30aa",
59
- "@aztec/telemetry-client": "0.0.1-commit.fff30aa",
60
- "@aztec/txe": "0.0.1-commit.fff30aa",
61
- "@aztec/validator-ha-signer": "0.0.1-commit.fff30aa",
62
- "@aztec/wallets": "0.0.1-commit.fff30aa",
63
- "@aztec/world-state": "0.0.1-commit.fff30aa",
31
+ "@aztec/accounts": "0.0.1-dev",
32
+ "@aztec/archiver": "0.0.1-dev",
33
+ "@aztec/aztec-faucet": "0.0.1-dev",
34
+ "@aztec/aztec-node": "0.0.1-dev",
35
+ "@aztec/aztec.js": "0.0.1-dev",
36
+ "@aztec/bb-prover": "0.0.1-dev",
37
+ "@aztec/bb.js": "0.0.1-dev",
38
+ "@aztec/blob-client": "0.0.1-dev",
39
+ "@aztec/bot": "0.0.1-dev",
40
+ "@aztec/builder": "0.0.1-dev",
41
+ "@aztec/cli": "0.0.1-dev",
42
+ "@aztec/constants": "0.0.1-dev",
43
+ "@aztec/entrypoints": "0.0.1-dev",
44
+ "@aztec/ethereum": "0.0.1-dev",
45
+ "@aztec/foundation": "0.0.1-dev",
46
+ "@aztec/kv-store": "0.0.1-dev",
47
+ "@aztec/l1-artifacts": "0.0.1-dev",
48
+ "@aztec/node-lib": "0.0.1-dev",
49
+ "@aztec/noir-contracts.js": "0.0.1-dev",
50
+ "@aztec/noir-protocol-circuits-types": "0.0.1-dev",
51
+ "@aztec/p2p": "0.0.1-dev",
52
+ "@aztec/p2p-bootstrap": "0.0.1-dev",
53
+ "@aztec/protocol-contracts": "0.0.1-dev",
54
+ "@aztec/prover-client": "0.0.1-dev",
55
+ "@aztec/prover-node": "0.0.1-dev",
56
+ "@aztec/pxe": "0.0.1-dev",
57
+ "@aztec/sequencer-client": "0.0.1-dev",
58
+ "@aztec/stdlib": "0.0.1-dev",
59
+ "@aztec/telemetry-client": "0.0.1-dev",
60
+ "@aztec/txe": "0.0.1-dev",
61
+ "@aztec/validator-ha-signer": "0.0.1-dev",
62
+ "@aztec/wallets": "0.0.1-dev",
63
+ "@aztec/world-state": "0.0.1-dev",
64
64
  "@iarna/toml": "^2.2.5",
65
65
  "@types/chalk": "^2.2.0",
66
66
  "abitype": "^0.8.11",
@@ -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
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
- shopt -s inherit_errexit
4
3
 
5
4
  # Re-execute using correct version if we have an .aztecrc file.
6
5
  if [ "${AZTEC_VERSIONED:-0}" -eq 0 ] && [ -f .aztecrc ] && command -v aztec-up &>/dev/null; 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::message_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 with provable correctness.
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_CONSTRAINED,
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_CONSTRAINED);
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
@@ -47,7 +47,7 @@ async function main() {
47
47
  await enrichEnvironmentWithNetworkConfig(networkName);
48
48
  enrichEnvironmentWithChainName(networkName);
49
49
 
50
- const cliVersion = getPackageVersion() ?? 'unknown';
50
+ const cliVersion = getPackageVersion();
51
51
  let program = new Command('aztec');
52
52
  program.description('Aztec command line interface').version(cliVersion).enablePositionalOptions();
53
53
  program = injectAztecCommands(program, userLog, debugLogger);
@@ -29,7 +29,7 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
29
29
  if (options.localNetwork) {
30
30
  const localNetwork = extractNamespacedOptions(options, 'localNetwork');
31
31
  userLog(`${splash}\n${github}\n\n`);
32
- userLog(`Setting up Aztec local network ${packageVersion ?? 'unknown'}, please stand by...`);
32
+ userLog(`Setting up Aztec local network ${packageVersion}, please stand by...`);
33
33
 
34
34
  const { node, stop } = await createLocalNetwork(
35
35
  {
@@ -105,7 +105,7 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
105
105
  env: 'NETWORK',
106
106
  },
107
107
 
108
- configToFlag('--enable-version-check', sharedNodeConfigMappings.enableVersionCheck),
108
+ configToFlag('--enable-auto-shutdown', sharedNodeConfigMappings.enableAutoShutdown),
109
109
 
110
110
  configToFlag('--sync-mode', sharedNodeConfigMappings.syncMode),
111
111
  configToFlag('--snapshots-urls', sharedNodeConfigMappings.snapshotsUrls),
@@ -322,15 +322,7 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
322
322
  },
323
323
  ...getOptions('bot', botConfigMappings),
324
324
  ],
325
- PXE: [
326
- {
327
- flag: '--pxe',
328
- description: 'Starts Aztec PXE with options',
329
- defaultValue: undefined,
330
- env: undefined,
331
- },
332
- ...getOptions('pxe', allPxeConfigMappings),
333
- ],
325
+ PXE: [...getOptions('pxe', allPxeConfigMappings)],
334
326
  TXE: [
335
327
  {
336
328
  flag: '--txe',
@@ -1,5 +1,6 @@
1
1
  import { findBbBinary } from '@aztec/bb.js';
2
2
  import type { LogFn } from '@aztec/foundation/log';
3
+ import { getPackageVersion } from '@aztec/stdlib/update-checker';
3
4
 
4
5
  import { execFileSync } from 'child_process';
5
6
  import type { Command } from 'commander';
@@ -25,15 +26,13 @@ async function collectContractArtifacts(): Promise<string[]> {
25
26
  return files.filter(f => Array.isArray(f.content.functions)).map(f => f.filePath);
26
27
  }
27
28
 
28
- /** Strips the `__aztec_nr_internals__` prefix from function names in contract artifacts. */
29
- async function stripInternalPrefixes(artifactPaths: string[]): Promise<void> {
29
+ /** Stamps the Aztec stack version into the contract artifacts. */
30
+ async function stampAztecVersion(artifactPaths: string[]): Promise<void> {
31
+ const version = getPackageVersion();
30
32
  for (const path of artifactPaths) {
31
33
  const artifact = JSON.parse(await readFile(path, 'utf-8'));
32
- for (const fn of artifact.functions) {
33
- if (typeof fn.name === 'string') {
34
- fn.name = fn.name.replace(/^__aztec_nr_internals__/, '');
35
- }
36
- }
34
+ // eslint-disable-next-line camelcase
35
+ artifact.aztec_version = version;
37
36
  await writeFile(path, JSON.stringify(artifact, null, 2) + '\n');
38
37
  }
39
38
  }
@@ -162,8 +161,7 @@ async function compileAztecContract(nargoArgs: string[], log: LogFn): Promise<vo
162
161
  const bbArgs = artifacts.flatMap(a => ['-i', a]);
163
162
  await run(bb, ['aztec_process', ...bbArgs]);
164
163
 
165
- // TODO: This should be part of bb aztec_process!
166
- await stripInternalPrefixes(artifacts);
164
+ await stampAztecVersion(artifacts);
167
165
  }
168
166
 
169
167
  log('Compilation complete!');
@@ -11,8 +11,9 @@ export function injectProfileCommand(program: Command, log: LogFn): Command {
11
11
  profile
12
12
  .command('gates')
13
13
  .argument('[target-dir]', 'Path to the compiled artifacts directory', './target')
14
+ .option('--json', 'Output gate counts as JSON instead of a table', false)
14
15
  .description('Display gate counts for all compiled Aztec artifacts in a target directory.')
15
- .action((targetDir: string) => profileGates(targetDir, log));
16
+ .action((targetDir: string, options: { json: boolean }) => profileGates(targetDir, options.json, log));
16
17
 
17
18
  profile
18
19
  .command('flamegraph')
@@ -6,12 +6,13 @@ import { execFile as execFileCb } from 'child_process';
6
6
  import { rm } from 'fs/promises';
7
7
  import { promisify } from 'util';
8
8
 
9
- import { MAX_CONCURRENT, discoverArtifacts } from './profile_utils.js';
9
+ import { type DiscoveredArtifact, MAX_CONCURRENT, discoverArtifacts } from './profile_utils.js';
10
10
 
11
11
  const execFile = promisify(execFileCb);
12
12
 
13
13
  interface GateCountResult {
14
14
  name: string;
15
+ type: DiscoveredArtifact['type'];
15
16
  gateCount: number;
16
17
  }
17
18
 
@@ -32,24 +33,39 @@ async function getGateCount(bb: string, artifactPath: string): Promise<number> {
32
33
  }
33
34
 
34
35
  /** Profiles all compiled artifacts in a target directory and prints gate counts. */
35
- export async function profileGates(targetDir: string, log: LogFn): Promise<void> {
36
+ export async function profileGates(targetDir: string, json: boolean, log: LogFn): Promise<void> {
36
37
  const bb = process.env.BB ?? findBbBinary() ?? 'bb';
37
38
  const { artifacts, tmpDir } = await discoverArtifacts(targetDir);
38
39
 
39
40
  if (artifacts.length === 0) {
40
- log('No artifacts found in target directory.');
41
+ if (json) {
42
+ log('[]');
43
+ } else {
44
+ log('No artifacts found in target directory.');
45
+ }
41
46
  return;
42
47
  }
43
48
 
44
49
  try {
45
50
  const results: GateCountResult[] = await asyncPool(MAX_CONCURRENT, artifacts, async artifact => ({
46
51
  name: artifact.name,
52
+ type: artifact.type,
47
53
  gateCount: await getGateCount(bb, artifact.filePath),
48
54
  }));
49
55
  results.sort((a, b) => a.name.localeCompare(b.name));
50
56
 
51
57
  if (results.length === 0) {
52
- log('No constrained circuits found.');
58
+ if (json) {
59
+ log('[]');
60
+ } else {
61
+ log('No constrained circuits found.');
62
+ }
63
+ return;
64
+ }
65
+
66
+ if (json) {
67
+ const entries = results.map(r => ({ name: r.name, type: r.type, gates: r.gateCount }));
68
+ log(JSON.stringify(entries, null, 2));
53
69
  return;
54
70
  }
55
71
 
@@ -6,13 +6,16 @@ import type { GenesisStateConfig } from '@aztec/ethereum/config';
6
6
  import { RegistryContract, RollupContract } from '@aztec/ethereum/contracts';
7
7
  import type { EthAddress } from '@aztec/foundation/eth-address';
8
8
  import { startHttpRpcServer } from '@aztec/foundation/json-rpc/server';
9
- import type { LogFn } from '@aztec/foundation/log';
9
+ import { type LogFn, createLogger } from '@aztec/foundation/log';
10
10
  import { retryUntil } from '@aztec/foundation/retry';
11
11
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
12
+ import type { VersionCheck } from '@aztec/stdlib/update-checker';
12
13
  import { getGenesisValues } from '@aztec/world-state/testing';
13
14
 
14
15
  import Koa from 'koa';
15
16
 
17
+ import { isShuttingDown, softShutdown } from '../util.js';
18
+
16
19
  const ROLLUP_POLL_INTERVAL_S = 60;
17
20
 
18
21
  /**
@@ -35,7 +38,12 @@ export async function computeExpectedGenesisRoot(config: GenesisStateConfig, use
35
38
  return { genesisArchiveRoot, prefilledPublicData };
36
39
  }
37
40
 
38
- async function checkRollupCompatibility(
41
+ /**
42
+ * Compares the rollup's on-chain protocol constants (genesis archive root, VK tree root, protocol
43
+ * contracts hash) against the node's expected local values. Returns a list of human-readable mismatch
44
+ * descriptions, empty if the rollup is compatible.
45
+ */
46
+ export async function checkRollupCompatibility(
39
47
  rollup: RollupContract,
40
48
  expected: { genesisArchiveRoot: Fr; vkTreeRoot: Fr; protocolContractsHash: Fr },
41
49
  ): Promise<string[]> {
@@ -130,3 +138,47 @@ export async function waitForCompatibleRollup(
130
138
  await new Promise<void>((resolve, reject) => standbyServer.close(err => (err ? reject(err) : resolve())));
131
139
  }
132
140
  }
141
+
142
+ /**
143
+ * Polls the canonical rollup's protocol constants every 10 minutes and soft-shuts-down the node once they
144
+ * diverge from the node's expected local values (i.e. an incompatible rollup has become canonical on L1).
145
+ * The HTTP health server is left running so K8s probes keep passing on the wound-down pod. This is the
146
+ * inverse of {@link waitForCompatibleRollup}; it should only be set up for nodes following the canonical
147
+ * rollup. Reuses the {@link checkRollupCompatibility} diff and the generic VersionChecker poll primitive.
148
+ */
149
+ export async function setupAutoShutdown(
150
+ config: { l1RpcUrls: string[]; l1ChainId: number },
151
+ registryAddress: EthAddress,
152
+ rollupVersion: number | 'canonical',
153
+ expected: { genesisArchiveRoot: Fr; vkTreeRoot: Fr; protocolContractsHash: Fr },
154
+ signalHandlers: Array<() => Promise<void>>,
155
+ ): Promise<void> {
156
+ const { VersionChecker } = await import('@aztec/stdlib/update-checker');
157
+
158
+ const logger = createLogger('auto_shutdown');
159
+ const publicClient = getPublicClient(config);
160
+ const registry = new RegistryContract(publicClient, registryAddress);
161
+
162
+ const check: VersionCheck = {
163
+ name: 'rollup',
164
+ currentVersion: 'compatible',
165
+ getLatestVersion: async () => {
166
+ const rollupAddress = await registry.getRollupAddress(rollupVersion);
167
+ const rollup = new RollupContract(publicClient, rollupAddress.toString());
168
+ const mismatches = await checkRollupCompatibility(rollup, expected);
169
+ return mismatches.length === 0 ? 'compatible' : `incompatible: ${mismatches.join('; ')}`;
170
+ },
171
+ };
172
+
173
+ const checker = new VersionChecker([check], 600_000, logger);
174
+ checker.on('newVersion', ({ latestVersion }) => {
175
+ if (isShuttingDown()) {
176
+ return;
177
+ }
178
+ logger.warn('Canonical rollup is no longer compatible; auto-shutting down node', { latestVersion });
179
+ // softShutdown never rejects (it awaits handlers via allSettled); fire-and-forget from the listener.
180
+ void softShutdown(logger.info.bind(logger), signalHandlers);
181
+ });
182
+ checker.start();
183
+ signalHandlers.push(() => checker.stop());
184
+ }