Skip to content

Commit b1aab5e

Browse files
authored
chore: Accumulated backports to v4-next (#22580)
BEGIN_COMMIT_OVERRIDE fix(pxe): cap event filter toBlock to last synced block (#22573) fix(pxe): round tx expiration timestamp to reduce precision (#22577) fix: eliminate anvil watcher warp race and false success logs (#22584) refactor: aztec new and init creating 2 crates (#20681) test: aztec new scaffold works (#20711) feat(cli): warning if contract crate has tests (#20723) feat(cli): auto-recompiling when aztec test is run (#20729) feat: aztec new supporting multiple contract crates (#21007) feat: asserts that aztec dep version matches cli (#21245) chore: backport aztec CLI improvements to v4-next (#22587) feat: check noir release has nargo binaries before releasing (#22551) chore: cache chainInfo in embeddedwallet (#22592) fix: wrap external getCapsule in transactionAsync (#22595) fix(pxe): throw clear error for invalid comparator in pick_notes (#22585) refactor(aztec-nr): rename conversion fns to encode_/decode_ naming (#22576) feat: infrastructure for testing `[new_contract_artfiacts, old_aztec_stack]` (#22593) chore: fix unnecessary and inconsistent side-effect counter increments (#22245) fix: update FaceID wallet redirects and strip anchors in redirect validation (#22505) docs: add getting started on testnet guide (#22366) docs: add getting started on testnet guide (backport #22366) (#22619) feat(aztec-nr): new BoundedVec emit private log APIs (#22064) END_COMMIT_OVERRIDE
2 parents f249358 + eb4aad8 commit b1aab5e

119 files changed

Lines changed: 3979 additions & 1011 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

aztec-up/bootstrap.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ EOF
104104
}
105105

106106
function test_cmds {
107-
for test in amm_flow bridge_and_claim basic_install counter_contract; do
107+
for test in amm_flow bridge_and_claim basic_install counter_contract default_scaffold; do
108108
echo "$hash:TIMEOUT=15m aztec-up/scripts/run_test.sh $test"
109109
done
110110
}

aztec-up/test/counter_contract.sh

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,38 @@ set -euo pipefail
44
export LOG_LEVEL=silent
55

66
# Execute commands as per: https://docs.aztec.network/tutorials/codealong/contract_tutorials/counter_contract
7-
aztec new counter_contract
8-
if [ ! -f counter_contract/Nargo.toml ] || [ ! -f counter_contract/src/main.nr ]; then
9-
echo "Failed to create contract."
7+
aztec new counter
8+
9+
# Verify workspace structure
10+
if [ ! -f counter/Nargo.toml ]; then
11+
echo "Failed to create workspace Nargo.toml."
12+
exit 1
13+
fi
14+
if [ ! -f counter/counter_contract/Nargo.toml ] || [ ! -f counter/counter_contract/src/main.nr ]; then
15+
echo "Failed to create contract crate."
16+
exit 1
17+
fi
18+
if [ ! -f counter/counter_test/Nargo.toml ] || [ ! -f counter/counter_test/src/lib.nr ]; then
19+
echo "Failed to create test crate."
1020
exit 1
1121
fi
1222

13-
# Check counter_contract dir is owned by aztec-dev.
14-
if [ "$(stat -c %U counter_contract)" != "ubuntu" ]; then
15-
echo "counter_contract dir is not owned by ubuntu."
23+
# Check counter dir is owned by ubuntu.
24+
if [ "$(stat -c %U counter)" != "ubuntu" ]; then
25+
echo "counter dir is not owned by ubuntu."
1626
exit 1
1727
fi
1828

19-
# "Write" our contract.
20-
cp -Rf ./aztec-packages/noir-projects/noir-contracts/contracts/test/counter_contract .
21-
cd counter_contract
22-
sed -i 's|\.\./\.\./\.\./\.\./|/home/ubuntu/aztec-packages/noir-projects/|g' Nargo.toml
29+
# "Write" our contract over the scaffold.
30+
cp -Rf ./aztec-packages/noir-projects/noir-contracts/contracts/test/counter/* counter/
31+
cd counter
32+
sed -i 's|\.\./\.\./\.\./\.\./\.\./|/home/ubuntu/aztec-packages/noir-projects/|g' counter_contract/Nargo.toml counter_test/Nargo.toml
2333

2434
# Compile the contract.
2535
aztec compile
2636
# Codegen
27-
aztec codegen -o src/artifacts target
28-
if [ ! -d src/artifacts ]; then
37+
aztec codegen -o counter_contract/src/artifacts target
38+
if [ ! -d counter_contract/src/artifacts ]; then
2939
echo "Failed to codegen TypeScript."
3040
exit 1
3141
fi

aztec-up/test/default_scaffold.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Tests that the default scaffold generated by `aztec new` compiles and passes its tests without any modifications.
5+
# Also tests that a second contract can be added to the workspace with `aztec new`.
6+
7+
export LOG_LEVEL=silent
8+
9+
aztec new my_workspace
10+
11+
# Verify workspace structure with named crate directories.
12+
if [ ! -f my_workspace/Nargo.toml ]; then
13+
echo "Failed to create workspace Nargo.toml."
14+
exit 1
15+
fi
16+
if [ ! -f my_workspace/my_workspace_contract/Nargo.toml ] || [ ! -f my_workspace/my_workspace_contract/src/main.nr ]; then
17+
echo "Failed to create contract crate."
18+
exit 1
19+
fi
20+
if [ ! -f my_workspace/my_workspace_test/Nargo.toml ] || [ ! -f my_workspace/my_workspace_test/src/lib.nr ]; then
21+
echo "Failed to create test crate."
22+
exit 1
23+
fi
24+
25+
cd my_workspace
26+
27+
# This is unfortunate as it makes the test worse but in CI setting the aztec version is 0.0.1 which doesn't exist as
28+
# a remote git tag, so we need to rewrite dependencies to use local aztec-nr.
29+
sed -i 's|aztec = .*git.*AztecProtocol/aztec-nr.*|aztec = { path="/home/ubuntu/aztec-packages/noir-projects/aztec-nr/aztec" }|' \
30+
my_workspace_contract/Nargo.toml my_workspace_test/Nargo.toml
31+
32+
# Compile the default scaffold contract.
33+
aztec compile
34+
35+
# Run the default scaffold tests.
36+
aztec test
37+
38+
# --- Test adding a second contract to the workspace ---
39+
aztec new token
40+
41+
# Verify token crates were created.
42+
if [ ! -f token_contract/Nargo.toml ] || [ ! -f token_contract/src/main.nr ]; then
43+
echo "Failed to create token contract crate."
44+
exit 1
45+
fi
46+
if [ ! -f token_test/Nargo.toml ] || [ ! -f token_test/src/lib.nr ]; then
47+
echo "Failed to create token test crate."
48+
exit 1
49+
fi
50+
51+
# Verify workspace Nargo.toml contains all four members.
52+
if ! grep -q '"my_workspace_contract"' Nargo.toml || \
53+
! grep -q '"my_workspace_test"' Nargo.toml || \
54+
! grep -q '"token_contract"' Nargo.toml || \
55+
! grep -q '"token_test"' Nargo.toml; then
56+
echo "Workspace Nargo.toml does not contain all expected members."
57+
exit 1
58+
fi
59+
60+
# Rewrite aztec deps for token crates too.
61+
sed -i 's|aztec = .*git.*AztecProtocol/aztec-nr.*|aztec = { path="/home/ubuntu/aztec-packages/noir-projects/aztec-nr/aztec" }|' \
62+
token_contract/Nargo.toml token_test/Nargo.toml
63+
64+
# Compile and test the full workspace (both contracts).
65+
aztec compile
66+
aztec test

barretenberg/cpp/src/barretenberg/api/aztec_process.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,21 @@ bool process_aztec_artifact(const std::string& input_path, const std::string& ou
258258
return true;
259259
}
260260

261+
// Strip __aztec_nr_internals__ prefix from function names.
262+
// The #[aztec] macro generates wrapper functions with this prefix; we strip it so
263+
// the exported ABI exposes the original developer-written names.
264+
const std::string internal_prefix = "__aztec_nr_internals__";
265+
for (auto& function : artifact_json["functions"]) {
266+
auto& name = function["name"];
267+
if (name.is_string()) {
268+
std::string fn_name = name.get<std::string>();
269+
if (fn_name.size() >= internal_prefix.size() &&
270+
fn_name.compare(0, internal_prefix.size(), internal_prefix) == 0) {
271+
name = fn_name.substr(internal_prefix.size());
272+
}
273+
}
274+
}
275+
261276
// Filter to private constrained functions
262277
std::vector<nlohmann::json*> private_functions;
263278
for (auto& function : artifact_json["functions"]) {
@@ -266,14 +281,13 @@ bool process_aztec_artifact(const std::string& input_path, const std::string& ou
266281
}
267282
}
268283

269-
if (private_functions.empty()) {
284+
if (!private_functions.empty()) {
285+
// Generate VKs
286+
generate_vks_for_functions(cache_dir, private_functions, force);
287+
} else {
270288
info("No private constrained functions found");
271-
return true;
272289
}
273290

274-
// Generate VKs
275-
generate_vks_for_functions(cache_dir, private_functions, force);
276-
277291
// Write updated JSON back to file
278292
std::ofstream out_file(output_path);
279293
out_file << artifact_json.dump(2) << std::endl;

boxes/init/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
target/
2+
codegenCache.json

boxes/init/Nargo.toml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
1-
[package]
2-
name = "init"
3-
type = "contract"
4-
5-
[dependencies]
6-
aztec = { path = "../../noir-projects/aztec-nr/aztec" }
1+
[workspace]
2+
members = ["contract", "test"]

boxes/init/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# init
2+
3+
An Aztec Noir contract project.
4+
5+
## Compile
6+
7+
```bash
8+
aztec compile
9+
```
10+
11+
This compiles the contract in `contract/` and outputs artifacts to `target/`.
12+
13+
## Test
14+
15+
```bash
16+
aztec test
17+
```
18+
19+
This runs the tests in `test/`.
20+
21+
## Generate TypeScript bindings
22+
23+
```bash
24+
aztec codegen target -o src/artifacts
25+
```
26+
27+
This generates TypeScript contract artifacts from the compiled output in `target/` into `src/artifacts/`.

boxes/init/contract/Nargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[package]
2+
name = "init"
3+
type = "contract"
4+
5+
[dependencies]
6+
aztec = { path = "../../../noir-projects/aztec-nr/aztec" }

boxes/init/contract/src/main.nr

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}

boxes/init/src/main.nr

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)