You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BEGIN_COMMIT_OVERRIDE
refactor(aztec-nr): use constructor methods for MessageDelivery variants
(#23596)
docs: update testing_contracts.md for two-crate aztec new layout
(#23617)
fix: drop usage of include and indexof on types that support equals
(#23595)
fix: unused ts expressions in tests (#23621)
feat(aztec-nr): Get tagging index for constrained delivery (#23359)
feat!: demote auth registry to non-protocol contract (#23106)
feat(aztec-nr)!: embed BoundedVec max length in validation requests
(#23622)
fix: regenerate standard contract addresses after auth registry demotion
(#23640)
feat(aztec-nr): encrypt handshake log for indistinguishability (#23638)
feat!: demote public_checks to non-protocol contract (#23217)
fix: noir precommit re-staging inside worktrees (#23628)
END_COMMIT_OVERRIDE
-**`ONCHAIN_CONSTRAINED`** - Constrained encryption with onchain delivery. Slowest proving but provides cryptographic guarantees that recipients can decrypt messages.
65
-
-**`ONCHAIN_UNCONSTRAINED`** - Unconstrained encryption with onchain delivery. Faster proving, but trusts the sender to encrypt correctly.
66
-
-**`OFFCHAIN`** - Unconstrained encryption with offchain delivery. Lowest cost, but requires custom infrastructure to deliver messages to recipients.
64
+
-**`onchain_constrained()`** - Constrained encryption with onchain delivery. Slowest proving but provides cryptographic guarantees that recipients can decrypt messages.
65
+
-**`onchain_unconstrained()`** - Unconstrained encryption with onchain delivery. Faster proving, but trusts the sender to encrypt correctly.
66
+
-**`offchain()`** - Unconstrained encryption with offchain delivery. Lowest cost, but requires custom infrastructure to deliver messages to recipients.
67
67
68
68
:::note
69
69
Emitting private events is optional. Onchain delivery publishes encrypted data to Ethereum blobs, inheriting Ethereum's data availability guarantees. You can choose to share information offchain instead.
**Important:** The recipient (e.g. an `auditor`) can see the note was created but **cannot use it** - only the owner can spend the note (this is authorized by the contract logic). The recipient also cannot see when/if the note is nullified.
Copy file name to clipboardExpand all lines: docs/docs-developers/docs/aztec-nr/framework-description/state_variables.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -273,9 +273,9 @@ When working with private state variables, many operations return a `NoteMessage
273
273
#### Delivery Methods
274
274
275
275
Private notes need to be communicated to their recipients so they know the note exists and can use it. The [`NoteMessage`](pathname:///aztec-nr-api/#api_ref_version/noir_aztec/note/struct.NoteMessage) wrapper forces you to make an explicit choice about how this happens:
276
-
-[`MessageDelivery.ONCHAIN_CONSTRAINED`](pathname:///aztec-nr-api/#api_ref_version/noir_aztec/messages/message_delivery/struct.MessageDeliveryEnum#structfield.ONCHAIN_CONSTRAINED): Verified in the circuit (most secure, but highest cost) - Use when the sender cannot be trusted to deliver correctly (e.g., protocol fees, multisig config updates). **Warning:** Currently [not fully constrained](https://github.com/AztecProtocol/aztec-packages/issues/14565) - the log's tag is unconstrained.
277
-
-[`MessageDelivery.ONCHAIN_UNCONSTRAINED`](pathname:///aztec-nr-api/#api_ref_version/noir_aztec/messages/message_delivery/struct.MessageDeliveryEnum#structfield.ONCHAIN_UNCONSTRAINED): Message stored onchain but no guarantees on content - Use when the sender is incentivized to deliver correctly but may not have an offchain channel to the recipient.
278
-
-[`MessageDelivery.OFFCHAIN`](pathname:///aztec-nr-api/#api_ref_version/noir_aztec/messages/message_delivery/struct.MessageDeliveryEnum#structfield.OFFCHAIN): Lowest cost, no onchain data - Use when the sender and recipient can communicate and the sender is incentivized to deliver correctly.
276
+
-[`MessageDelivery::onchain_constrained()`](pathname:///aztec-nr-api/#api_ref_version/noir_aztec/messages/message_delivery/struct.MessageDelivery#method.onchain_constrained): Verified in the circuit (most secure, but highest cost) - Use when the sender cannot be trusted to deliver correctly (e.g., protocol fees, multisig config updates). **Warning:** Currently [not fully constrained](https://github.com/AztecProtocol/aztec-packages/issues/14565) - the log's tag is unconstrained.
277
+
-[`MessageDelivery::onchain_unconstrained()`](pathname:///aztec-nr-api/#api_ref_version/noir_aztec/messages/message_delivery/struct.MessageDelivery#method.onchain_unconstrained): Message stored onchain but no guarantees on content - Use when the sender is incentivized to deliver correctly but may not have an offchain channel to the recipient.
278
+
-[`MessageDelivery::offchain()`](pathname:///aztec-nr-api/#api_ref_version/noir_aztec/messages/message_delivery/struct.MessageDelivery#method.offchain): Lowest cost, no onchain data - Use when the sender and recipient can communicate and the sender is incentivized to deliver correctly.
`SinglePrivateMutable` uses a nullify-and-recreate pattern when reading. Unless the caller is incentivized to deliver the note message correctly, you should use `MessageDelivery.ONCHAIN_CONSTRAINED` to prevent malicious actors from bricking the contract by failing to deliver the note.
491
+
`SinglePrivateMutable` uses a nullify-and-recreate pattern when reading. Unless the caller is incentivized to deliver the note message correctly, you should use `MessageDelivery::onchain_constrained()` to prevent malicious actors from bricking the contract by failing to deliver the note.
Copy file name to clipboardExpand all lines: docs/docs-developers/docs/aztec-nr/testing_contracts.md
+33-43Lines changed: 33 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,69 +46,59 @@ Always use `aztec test` instead of `nargo test`. The `TestEnvironment` requires
46
46
47
47
## Basic test structure
48
48
49
-
Tests live in the same crate as your contract. `aztec new` creates a single-crate project, and the convention is to place `#[test]` functions in a `mod tests` block alongside the contract (or in submodules of the crate):
49
+
`aztec new my_project` scaffolds a workspace with two crates: a `contract` crate that holds the contract code, and a separate `test` crate that holds your `#[test]` functions:
50
+
51
+
```text
52
+
my_project/
53
+
├── Nargo.toml # [workspace] members = ["my_project_contract", "my_project_test"]
54
+
├── my_project_contract/
55
+
│ ├── Nargo.toml # type = "contract"
56
+
│ └── src/main.nr
57
+
└── my_project_test/
58
+
├── Nargo.toml # type = "lib", depends on my_project_contract
59
+
└── src/lib.nr # #[test] functions go here
60
+
```
50
61
51
-
```rust
52
-
useaztec::macros::aztec;
62
+
The motivation for the split of contract and tests into its own crates is **faster iteration**: editing a test does not invalidate the contract's compiled artifact, so `aztec test` skips contract recompilation when only test code changed.
53
63
54
-
#[aztec]
55
-
pubcontractMyContract {
56
-
// ...contract functions...
57
-
}
64
+
`aztec compile` warns if it finds `#[test]` functions inside a contract crate.
Because tests live in their own crate, we refer to the contract via its crate name using the `@crate_name/ContractName` syntax.
84
+
74
85
:::info Test execution notes
75
86
76
87
- Tests run in parallel by default
77
88
- Use `unconstrained` functions for faster execution
78
89
- See all `TestEnvironment` methods [here](pathname:///aztec-nr-api/#api_ref_version/noir_aztec/test/helpers/test_environment/struct.TestEnvironment)
79
-
90
+
- It is always necessary to deploy a contract in order to test it
80
91
:::
81
92
82
-
:::tip Organizing test files
83
-
For larger test suites, split tests into submodules of your crate rather than keeping them all inside `main.nr`:
84
-
85
-
- Create modules like `src/transfer_tests.nr`, `src/auth_tests.nr`
86
-
- Declare them from `src/main.nr` with `mod transfer_tests;`, `mod auth_tests;`
87
-
- Share setup functions in `src/test_utils.nr`
88
-
89
-
See the [aztec-standards token contract](https://github.com/defi-wonderland/aztec-standards/tree/dev/src/token_contract) for a worked example of this layout.
90
-
:::
91
-
92
-
## Deploying contracts
93
-
94
-
In order to test you'll most likely want to deploy a contract in your testing environment. First, instantiate a deployer:
93
+
If you'll add arguments to your contract's constructor you pass them directly to the constructor function in the test:
It is always necessary to deploy a contract in order to test it. `aztec test` automatically compiles contracts when changes are detected, but you can also manually compile with `aztec compile` to regenerate the bytecode and ABI.
105
-
:::
106
-
107
-
You can then choose whatever you need to initialize by interfacing with your initializer and calling it:
99
+
Since Aztec contracts can be initialized both in private and public or they can be interacted with without any kind of initialization (see [Contract creation](../foundational-topics/contract_creation.md) for how Aztec's deployment model differs from Ethereum's) there are 3 options on the deployer:
0 commit comments