Skip to content
This repository was archived by the owner on Jul 10, 2026. It is now read-only.

Commit d438559

Browse files
authored
Merge branch 'feat/403' into chore/403v5.0.0
Signed-off-by: ilpepepig <167773062+ilpepepig@users.noreply.github.com>
2 parents a217651 + 7eb029b commit d438559

7 files changed

Lines changed: 51 additions & 42 deletions

File tree

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@
3434
"@aztec/stdlib": "5.0.0-rc.1",
3535
"@aztec/wallet-sdk": "5.0.0-rc.1",
3636
"@aztec/wallets": "5.0.0-rc.1",
37+
<<<<<<< chore/403v5.0.0
3738
"@defi-wonderland/aztec-benchmark": "https://github.com/defi-wonderland/aztec-benchmark/releases/download/prerelease-98d719b/defi-wonderland-aztec-benchmark-5.0.0-rc.1-prerelease.98d719b.tgz",
39+
=======
40+
"@defi-wonderland/aztec-benchmark": "5.0.0-rc.1",
41+
>>>>>>> feat/403
3842
"commander": "14.0.1",
3943
"dotenv": "16.4.7"
4044
},

src/escrow_contract/src/test/test_logic_contract/src/test/withdraw.nr

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
use crate::test::utils as logic_utils;
22
use crate::TestLogic;
3+
use aztec::test::helpers::test_environment::CallPrivateOptions;
34
use escrow_contract::test::utils as escrow_utils;
45
use token::{test::utils as token_utils, Token};
56

6-
// TODO (reenable test): TXE scope enforcement means only the `from` address's notes are accessible during
7-
// private execution. The escrow's token notes are not in scope when called from the logic contract.
8-
// The TS tests handle this via `additionalScopes: [escrow.address]`, but TXE doesn't support it yet.
9-
// See: https://github.com/AztecProtocol/aztec-packages/blob/v4.2.0-aztecnr-rc.2/noir-projects/aztec-nr/aztec/src/test/helpers/test_environment.nr#L953-L954
10-
#[allow(dead_code)]
7+
#[test]
118
unconstrained fn withdraw_success() {
129
let (mut env, token, _owner, recipient, minter) = token_utils::setup_with_minter(false);
1310

@@ -23,7 +20,11 @@ unconstrained fn withdraw_success() {
2320
token_utils::check_private_balance(env, token, escrow, amount);
2421

2522
let caller = env.create_light_account();
26-
env.call_private(caller, TestLogic::at(logic).withdraw(escrow, recipient, token, amount));
23+
env.call_private_opts(
24+
caller,
25+
CallPrivateOptions::new().with_additional_scopes([escrow]),
26+
TestLogic::at(logic).withdraw(escrow, recipient, token, amount),
27+
);
2728

2829
// Check recipient got tokens
2930
token_utils::check_private_balance(env, token, recipient, amount);

src/escrow_contract/src/test/test_logic_contract/src/test/withdraw_nft.nr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
use crate::test::utils as logic_utils;
22
use crate::TestLogic;
3-
use aztec::test::helpers::test_environment::TestEnvironment;
3+
use aztec::test::helpers::test_environment::{CallPrivateOptions, TestEnvironment};
44
use escrow_contract::test::utils as escrow_utils;
55
use nft::{NFT, test::utils as nft_utils};
66

7-
// TODO (reenable test): TXE scope enforcement means only the `from` address's notes are accessible during
8-
// private execution. The escrow's NFT notes are not in scope when called from the logic contract.
9-
// The TS tests handle this via `additionalScopes: [escrow.address]`, but TXE doesn't support it yet.
10-
// See: https://github.com/AztecProtocol/aztec-packages/blob/v4.2.0-aztecnr-rc.2/noir-projects/aztec-nr/aztec/src/test/helpers/test_environment.nr#L953-L954
11-
#[allow(dead_code)]
7+
#[test]
128
unconstrained fn withdraw_nft_success() {
139
let mut env = TestEnvironment::new();
1410
let owner = env.create_light_account();
@@ -29,7 +25,11 @@ unconstrained fn withdraw_nft_success() {
2925
nft_utils::assert_owns_private_nft(env, nft, escrow, token_id);
3026

3127
let caller = env.create_light_account();
32-
env.call_private(caller, TestLogic::at(logic).withdraw_nft(escrow, recipient, nft, token_id));
28+
env.call_private_opts(
29+
caller,
30+
CallPrivateOptions::new().with_additional_scopes([escrow]),
31+
TestLogic::at(logic).withdraw_nft(escrow, recipient, nft, token_id),
32+
);
3333

3434
// Check recipient got NFT
3535
nft_utils::assert_owns_private_nft(env, nft, recipient, token_id);

src/escrow_contract/src/test/withdraw.nr

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
use crate::Escrow;
22
use crate::test::utils as escrow_utils;
3+
use aztec::test::helpers::test_environment::CallPrivateOptions;
34
use token::{test::utils as token_utils, Token};
45

5-
// TODO (reenable test): TXE scope enforcement means only the `from` address's notes are accessible during
6-
// private execution. The escrow's token notes are not in scope when called from logic_contract_address.
7-
// The TS tests handle this via `additionalScopes: [escrow.address]`, but TXE doesn't support it yet.
8-
// See: https://github.com/AztecProtocol/aztec-packages/blob/v4.2.0-aztecnr-rc.2/noir-projects/aztec-nr/aztec/src/test/helpers/test_environment.nr#L953-L954
9-
#[allow(dead_code)]
6+
#[test]
107
unconstrained fn escrow_withdraw_success() {
118
let escrow_secret: Field = 123456;
129
let (mut env, escrow_contract_address, token_contract_address, _, _, recipient, minter, logic_contract_address) =
@@ -27,17 +24,17 @@ unconstrained fn escrow_withdraw_success() {
2724
amount,
2825
);
2926

30-
env.call_private(
27+
env.call_private_opts(
3128
logic_contract_address,
29+
CallPrivateOptions::new().with_additional_scopes([escrow_contract_address]),
3230
Escrow::at(escrow_contract_address).withdraw(token_contract_address, amount, recipient),
3331
);
3432

3533
// Check recipient got tokens
3634
token_utils::check_private_balance(env, token_contract_address, recipient, amount);
3735
}
3836

39-
// TODO (reenable test): same TXE scope enforcement issue as escrow_withdraw_success (see comment above).
40-
#[allow(dead_code)]
37+
#[test]
4138
unconstrained fn escrow_withdraw_twice_success() {
4239
let escrow_secret: Field = 123456;
4340
let (mut env, escrow_contract_address, token_contract_address, _, _, recipient, minter, logic_contract_address) =
@@ -60,8 +57,9 @@ unconstrained fn escrow_withdraw_twice_success() {
6057

6158
let amount: u128 = token_utils::mint_amount;
6259
// Partial withdrawal
63-
env.call_private(
60+
env.call_private_opts(
6461
logic_contract_address,
62+
CallPrivateOptions::new().with_additional_scopes([escrow_contract_address]),
6563
Escrow::at(escrow_contract_address).withdraw(token_contract_address, amount, recipient),
6664
);
6765

@@ -75,8 +73,9 @@ unconstrained fn escrow_withdraw_twice_success() {
7573
);
7674

7775
// Complete withdrawal
78-
env.call_private(
76+
env.call_private_opts(
7977
logic_contract_address,
78+
CallPrivateOptions::new().with_additional_scopes([escrow_contract_address]),
8079
Escrow::at(escrow_contract_address).withdraw(token_contract_address, amount, recipient),
8180
);
8281

src/escrow_contract/src/test/withdraw_nft.nr

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
use crate::Escrow;
22
use crate::test::utils as escrow_utils;
3+
use aztec::test::helpers::test_environment::CallPrivateOptions;
34
use nft::{NFT, test::utils as nft_utils};
45

5-
// TODO (reenable test): TXE scope enforcement means only the `from` address's notes are accessible during
6-
// private execution. The escrow's NFT notes are not in scope when called from logic_contract_address.
7-
// The TS tests handle this via `additionalScopes: [escrow.address]`, but TXE doesn't support it yet.
8-
// See: https://github.com/AztecProtocol/aztec-packages/blob/v4.2.0-aztecnr-rc.2/noir-projects/aztec-nr/aztec/src/test/helpers/test_environment.nr#L953-L954
9-
#[allow(dead_code)]
6+
#[test]
107
unconstrained fn escrow_withdraw_nft_success() {
118
let escrow_secret: Field = 123456;
129
let (mut env, escrow_contract_address, _, nft_contract_address, _, recipient, minter, logic_contract_address) =
@@ -27,8 +24,9 @@ unconstrained fn escrow_withdraw_nft_success() {
2724
token_id,
2825
);
2926

30-
env.call_private(
27+
env.call_private_opts(
3128
logic_contract_address,
29+
CallPrivateOptions::new().with_additional_scopes([escrow_contract_address]),
3230
Escrow::at(escrow_contract_address).withdraw_nft(nft_contract_address, token_id, recipient),
3331
);
3432

src/token_contract/src/main.nr

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ pub contract Token {
128128
amount: u128,
129129
_nonce: Field,
130130
) {
131-
self.internal._call_auth_private(from, amount, self.context.selector().to_field());
131+
self.internal._call_auth_private(from, amount);
132132

133133
self.internal._decrease_private_balance(from, amount, INITIAL_TRANSFER_CALL_MAX_NOTES);
134134

@@ -151,7 +151,7 @@ pub contract Token {
151151
amount: u128,
152152
_nonce: Field,
153153
) -> Field {
154-
self.internal._call_auth_private(from, amount, self.context.selector().to_field());
154+
self.internal._call_auth_private(from, amount);
155155

156156
self.internal._decrease_private_balance(from, amount, INITIAL_TRANSFER_CALL_MAX_NOTES);
157157

@@ -177,7 +177,7 @@ pub contract Token {
177177
amount: u128,
178178
_nonce: Field,
179179
) {
180-
self.internal._call_auth_private(from, amount, self.context.selector().to_field());
180+
self.internal._call_auth_private(from, amount);
181181

182182
self.internal._decrease_private_balance(from, amount, INITIAL_TRANSFER_CALL_MAX_NOTES);
183183

@@ -199,7 +199,7 @@ pub contract Token {
199199
amount: u128,
200200
_nonce: Field,
201201
) {
202-
self.internal._call_auth_private(from, amount, self.context.selector().to_field());
202+
self.internal._call_auth_private(from, amount);
203203

204204
self.internal._decrease_private_balance(from, amount, INITIAL_TRANSFER_CALL_MAX_NOTES);
205205

@@ -226,7 +226,7 @@ pub contract Token {
226226
amount: u128,
227227
_nonce: Field,
228228
) {
229-
self.internal._call_auth_private(from, amount, self.context.selector().to_field());
229+
self.internal._call_auth_private(from, amount);
230230

231231
self.enqueue_self.decrease_public_balance_internal(from, amount);
232232

@@ -273,7 +273,7 @@ pub contract Token {
273273
amount: u128,
274274
_nonce: Field,
275275
) {
276-
self.internal._call_auth_public(from, amount, self.context.selector().to_field());
276+
self.internal._call_auth_public(from, amount);
277277

278278
self.internal._decrease_public_balance(from, amount);
279279
self.internal._increase_public_balance(to, amount);
@@ -297,7 +297,7 @@ pub contract Token {
297297
amount: u128,
298298
_nonce: Field,
299299
) {
300-
self.internal._call_auth_public(from, amount, self.context.selector().to_field());
300+
self.internal._call_auth_public(from, amount);
301301

302302
self.internal._decrease_public_balance(from, amount);
303303

@@ -464,7 +464,7 @@ pub contract Token {
464464
#[authorize_once("from", "_nonce")]
465465
#[external("private")]
466466
fn burn_private(from: AztecAddress, amount: u128, _nonce: Field) {
467-
self.internal._call_auth_private(from, amount, self.context.selector().to_field());
467+
self.internal._call_auth_private(from, amount);
468468

469469
self.internal._burn_private(from, amount);
470470
}
@@ -477,7 +477,7 @@ pub contract Token {
477477
#[authorize_once("from", "_nonce")]
478478
#[external("public")]
479479
fn burn_public(from: AztecAddress, amount: u128, _nonce: Field) {
480-
self.internal._call_auth_public(from, amount, self.context.selector().to_field());
480+
self.internal._call_auth_public(from, amount);
481481

482482
self.internal._burn_public(from, amount);
483483
}
@@ -500,11 +500,11 @@ pub contract Token {
500500
/// @dev Invoked from external public functions; no-ops when auth_contract is zero
501501
/// @param from The address tokens are moved from (zero address for mints)
502502
/// @param amount The amount of tokens being moved
503-
/// @param selector The selector passed is the calling function's own selector
504503
#[internal("public")]
505-
fn _call_auth_public(from: AztecAddress, amount: u128, selector: Field) {
504+
fn _call_auth_public(from: AztecAddress, amount: u128) {
506505
let auth = self.storage.auth_contract.read();
507506
if !auth.eq(AztecAddress::zero()) {
507+
let selector = self.context.selector().to_field();
508508
self.call(AuthorizationContract::at(auth).authorize_public(from, amount, selector));
509509
}
510510
}
@@ -515,11 +515,11 @@ pub contract Token {
515515
/// side effects (e.g., via enqueued public calls or public events).
516516
/// @param from The address tokens are moved from (zero address for mints)
517517
/// @param amount The amount of tokens being moved
518-
/// @param selector The selector passed is the calling function's own selector
519518
#[internal("private")]
520-
fn _call_auth_private(from: AztecAddress, amount: u128, selector: Field) {
519+
fn _call_auth_private(from: AztecAddress, amount: u128) {
521520
let auth = self.storage.auth_contract.read();
522521
if !auth.eq(AztecAddress::zero()) {
522+
let selector = self.context.selector().to_field();
523523
self.call(AuthorizationContract::at(auth).authorize_private(from, amount, selector));
524524
}
525525
}

yarn.lock

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,9 +1211,16 @@
12111211
"@crate-crypto/node-eth-kzg-win32-arm64-msvc" "0.10.0"
12121212
"@crate-crypto/node-eth-kzg-win32-x64-msvc" "0.10.0"
12131213

1214+
<<<<<<< chore/403v5.0.0
12141215
"@defi-wonderland/aztec-benchmark@https://github.com/defi-wonderland/aztec-benchmark/releases/download/prerelease-98d719b/defi-wonderland-aztec-benchmark-5.0.0-rc.1-prerelease.98d719b.tgz":
12151216
version "5.0.0-rc.1-prerelease.98d719b"
12161217
resolved "https://github.com/defi-wonderland/aztec-benchmark/releases/download/prerelease-98d719b/defi-wonderland-aztec-benchmark-5.0.0-rc.1-prerelease.98d719b.tgz#093046d654c168231eaa979a2c81c6dfddde3cb2"
1218+
=======
1219+
"@defi-wonderland/aztec-benchmark@5.0.0-rc.1":
1220+
version "5.0.0-rc.1"
1221+
resolved "https://registry.yarnpkg.com/@defi-wonderland/aztec-benchmark/-/aztec-benchmark-5.0.0-rc.1.tgz#4e7f3ee2b9aa6fbbd55a23c7d983bbce4e9b28ee"
1222+
integrity sha512-3rxSjxg1vrkpUD/gL84KLdAooG0RLthYLl6+dHCX5E7+JV/fgpf5pAgqR4IhM41DkiZEOMtngM09zkgxYMLKnA==
1223+
>>>>>>> feat/403
12171224
dependencies:
12181225
"@actions/core" "1.10.1"
12191226
"@actions/exec" "1.1.1"

0 commit comments

Comments
 (0)