-
Notifications
You must be signed in to change notification settings - Fork 598
feat(aztec-nr): do not compile functions with a private public macro and unconstrained #11815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
noir-projects/aztec-nr/macro_compilation_failure_tests/.gitignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| target/ |
55 changes: 55 additions & 0 deletions
55
noir-projects/aztec-nr/macro_compilation_failure_tests/assert_macro_compilation_failure.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| #!/bin/bash | ||
| # Within failure_contracts, we have contracts that should fail compilation due to code in the macros | ||
| # This script will test that compilation fails for each of the contracts in failure_contracts | ||
|
|
||
| REPO=$(git rev-parse --show-toplevel) | ||
| NARGO=${NARGO:-"$REPO/noir/noir-repo/target/release/nargo"} | ||
|
|
||
| # Colors for output | ||
| RED='\033[0;31m' | ||
| GREEN='\033[0;32m' | ||
| NC='\033[0m' # No Color | ||
|
|
||
| # Initialize counters | ||
| total_tests=0 | ||
| passed_tests=0 | ||
|
|
||
| # Function to test compilation failure | ||
| test_compilation_failure() { | ||
| local contract_dir=$1 | ||
| ((total_tests++)) | ||
|
|
||
| echo "Testing compilation failure for: $contract_dir" | ||
|
|
||
| # Try to compile the contract | ||
| if cd "$contract_dir" && $NARGO compile 2>/dev/null; then | ||
| echo -e "${RED}❌ Test failed: Compilation succeeded when it should have failed for $contract_dir${NC}" | ||
| cd - > /dev/null | ||
| return 1 | ||
| else | ||
| echo -e "${GREEN}✓ Test passed: Compilation failed as expected for $contract_dir${NC}" | ||
| cd - > /dev/null | ||
| ((passed_tests++)) | ||
| return 0 | ||
| fi | ||
| } | ||
|
|
||
| # Get the directory where the script is located | ||
| SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
| FAILURE_CONTRACTS_DIR="$SCRIPT_DIR/failure_contracts" | ||
|
|
||
| # Test each contract in the failure_contracts directory | ||
| for contract in "$FAILURE_CONTRACTS_DIR"/*; do | ||
| if [ -d "$contract" ]; then | ||
| test_compilation_failure "$contract" | ||
| fi | ||
| done | ||
|
|
||
| # Print summary | ||
| echo -e "\nTest Summary:" | ||
| echo -e "Total tests: $total_tests" | ||
| echo -e "Passed tests: $passed_tests" | ||
| echo -e "Failed tests: $((total_tests - passed_tests))" | ||
|
|
||
| # Exit with failure if any test didn't pass | ||
| [ "$total_tests" -eq "$passed_tests" ] || exit 1 |
7 changes: 7 additions & 0 deletions
7
...macro_compilation_failure_tests/failure_contracts/marked_private_unconstrained/Nargo.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| [package] | ||
| name = "marked_private_unconstrained" | ||
| type = "contract" | ||
| authors = [""] | ||
|
|
||
| [dependencies] | ||
| aztec = { path = "../../../aztec" } |
14 changes: 14 additions & 0 deletions
14
...acro_compilation_failure_tests/failure_contracts/marked_private_unconstrained/src/main.nr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| /// Private functions that are also marked as unconstrained are not allowed. | ||
| /// | ||
| use aztec::macros::aztec; | ||
|
|
||
|
|
||
| #[aztec] | ||
| contract MarkedPrivateUnconstrained { | ||
| use aztec::macros::functions::private; | ||
|
|
||
|
|
||
| #[private] | ||
| unconstrained fn unconstrained_private_function() {} | ||
| } | ||
|
|
7 changes: 7 additions & 0 deletions
7
.../macro_compilation_failure_tests/failure_contracts/marked_public_unconstrained/Nargo.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| [package] | ||
| name = "marked_public_unconstrained" | ||
| type = "contract" | ||
| authors = [""] | ||
|
|
||
| [dependencies] | ||
| aztec = { path = "../../../aztec" } |
14 changes: 14 additions & 0 deletions
14
...macro_compilation_failure_tests/failure_contracts/marked_public_unconstrained/src/main.nr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| /// Public functions that are also marked as unconstrained are not allowed. | ||
| /// | ||
| use aztec::macros::aztec; | ||
|
|
||
|
|
||
| #[aztec] | ||
| contract MarkedPublicUnconstrained { | ||
| use aztec::macros::functions::public; | ||
|
|
||
|
|
||
| #[public] | ||
| unconstrained fn unconstrained_public_function() {} | ||
| } | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not using a function to marry these as the error message is different and its simple enough