From a7c1f0fbb3ba900856ac2d14445a97a0cfce88be Mon Sep 17 00:00:00 2001 From: benesjan Date: Fri, 3 Jan 2025 16:59:45 +0000 Subject: [PATCH] WIP --- .../encrypted_logs/encrypted_note_emission.nr | 3 -- .../token_blacklist_contract/src/main.nr | 34 ++++++++++--------- .../contracts/token_contract/src/main.nr | 24 ++++--------- .../src/composed/e2e_sandbox_example.test.ts | 3 ++ .../transfer_in_private.test.ts | 4 +-- .../src/guides/dapp_testing.test.ts | 4 +++ .../src/guides/up_quick_start.test.ts | 3 ++ yarn-project/end-to-end/src/shared/browser.ts | 3 ++ 8 files changed, 39 insertions(+), 39 deletions(-) diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr index 9695a3edb66e..f7f6f7cf52f6 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr @@ -47,9 +47,6 @@ where compute_payload(context, note, recipient, sender) } -// This function seems to be affected by the following Noir bug: -// https://github.com/noir-lang/noir/issues/5771 -// If you get weird behavior it might be because of it. pub fn encode_and_encrypt_note( context: &mut PrivateContext, recipient: AztecAddress, diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr index ec66fd865906..f6ca73e99fe0 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr @@ -14,7 +14,9 @@ use dep::aztec::macros::aztec; contract TokenBlacklist { // Libs use dep::aztec::{ - encrypted_logs::encrypted_note_emission::encode_and_encrypt_note_unconstrained, + encrypted_logs::encrypted_note_emission::{ + encode_and_encrypt_note, encode_and_encrypt_note_unconstrained, + }, hash::compute_secret_hash, macros::{functions::{initializer, internal, private, public, view}, storage::storage}, prelude::{AztecAddress, Map, NoteGetterOptions, PrivateSet, PublicMutable, SharedMutable}, @@ -186,11 +188,11 @@ contract TokenBlacklist { assert(notes.len() == 1, "note not popped"); // Add the token note to user's balances set - // TODO: constrain encryption below - we are using unconstrained here only because of the following Noir issue - // https://github.com/noir-lang/noir/issues/5771 - storage.balances.add(to, U128::from_integer(amount)).emit( - encode_and_encrypt_note_unconstrained(&mut context, to, context.msg_sender()), - ); + storage.balances.add(to, U128::from_integer(amount)).emit(encode_and_encrypt_note( + &mut context, + to, + context.msg_sender(), + )); } #[private] @@ -206,11 +208,11 @@ contract TokenBlacklist { assert(nonce == 0, "invalid nonce"); } - // TODO: constrain encryption below - we are using unconstrained here only becuase of the following Noir issue - // https://github.com/noir-lang/noir/issues/5771 - storage.balances.sub(from, U128::from_integer(amount)).emit( - encode_and_encrypt_note_unconstrained(&mut context, from, from), - ); + storage.balances.sub(from, U128::from_integer(amount)).emit(encode_and_encrypt_note( + &mut context, + from, + from, + )); TokenBlacklist::at(context.this_address())._increase_public_balance(to, amount).enqueue( &mut context, @@ -255,11 +257,11 @@ contract TokenBlacklist { assert(nonce == 0, "invalid nonce"); } - // TODO: constrain encryption below - we are using unconstrained here only because of the following Noir issue - // https://github.com/noir-lang/noir/issues/5771 - storage.balances.sub(from, U128::from_integer(amount)).emit( - encode_and_encrypt_note_unconstrained(&mut context, from, from), - ); + storage.balances.sub(from, U128::from_integer(amount)).emit(encode_and_encrypt_note( + &mut context, + from, + from, + )); TokenBlacklist::at(context.this_address())._reduce_total_supply(amount).enqueue(&mut context); } diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_contract/src/main.nr index f1ec6266f7e1..d0e0f6f758ac 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/main.nr @@ -22,7 +22,9 @@ contract Token { context::{PrivateCallInterface, PrivateContext}, encrypted_logs::{ encrypted_event_emission::encode_and_encrypt_event_unconstrained, - encrypted_note_emission::encode_and_encrypt_note_unconstrained, + encrypted_note_emission::{ + encode_and_encrypt_note, encode_and_encrypt_note_unconstrained, + }, }, macros::{ events::event, @@ -250,10 +252,8 @@ contract Token { assert(nonce == 0, "invalid nonce"); } - // TODO: constrain encryption below - we are using unconstrained here only because of the following Noir issue - // https://github.com/noir-lang/noir/issues/5771 storage.balances.at(from).sub(from, U128::from_integer(amount)).emit( - encode_and_encrypt_note_unconstrained(&mut context, from, from), + encode_and_encrypt_note(&mut context, from, from), ); Token::at(context.this_address())._increase_public_balance(to, amount).enqueue(&mut context); } @@ -376,22 +376,14 @@ contract Token { let amount = U128::from_integer(amount); // docs:start:increase_private_balance // docs:start:encrypted - // TODO: constrain encryption below - we are using unconstrained here only becuase of the following Noir issue - // https://github.com/noir-lang/noir/issues/5771 - storage.balances.at(from).sub(from, amount).emit(encode_and_encrypt_note_unconstrained( + storage.balances.at(from).sub(from, amount).emit(encode_and_encrypt_note( &mut context, from, from, )); // docs:end:encrypted // docs:end:increase_private_balance - // TODO: constrain encryption below - we are using unconstrained here only becuase of the following Noir issue - // https://github.com/noir-lang/noir/issues/5771 - storage.balances.at(to).add(to, amount).emit(encode_and_encrypt_note_unconstrained( - &mut context, - to, - from, - )); + storage.balances.at(to).add(to, amount).emit(encode_and_encrypt_note(&mut context, to, from)); } // docs:end:transfer_in_private @@ -403,10 +395,8 @@ contract Token { } else { assert(nonce == 0, "invalid nonce"); } - // TODO: constrain encryption below - we are using unconstrained here only becuase of the following Noir issue - // https://github.com/noir-lang/noir/issues/5771 storage.balances.at(from).sub(from, U128::from_integer(amount)).emit( - encode_and_encrypt_note_unconstrained(&mut context, from, from), + encode_and_encrypt_note(&mut context, from, from), ); Token::at(context.this_address())._reduce_total_supply(amount).enqueue(&mut context); } diff --git a/yarn-project/end-to-end/src/composed/e2e_sandbox_example.test.ts b/yarn-project/end-to-end/src/composed/e2e_sandbox_example.test.ts index 4b7b34e47a61..faeaaba65292 100644 --- a/yarn-project/end-to-end/src/composed/e2e_sandbox_example.test.ts +++ b/yarn-project/end-to-end/src/composed/e2e_sandbox_example.test.ts @@ -56,6 +56,7 @@ import { getSchnorrAccount } from '@aztec/accounts/schnorr'; import { getDeployedTestAccountsWallets } from '@aztec/accounts/testing'; import { Fr, GrumpkinScalar, type PXE, createLogger, createPXEClient, waitForPXE } from '@aztec/aztec.js'; +import { jest } from '@jest/globals'; import { format } from 'util'; // docs:end:imports @@ -64,6 +65,8 @@ import { deployToken, mintTokensToPrivate } from '../fixtures/token_utils.js'; const { PXE_URL = 'http://localhost:8080' } = process.env; describe('e2e_sandbox_example', () => { + jest.setTimeout(60_000); + it('sandbox example works', async () => { // docs:start:setup ////////////// CREATE THE CLIENT INTERFACE AND CONTACT THE SANDBOX ////////////// diff --git a/yarn-project/end-to-end/src/e2e_token_contract/transfer_in_private.test.ts b/yarn-project/end-to-end/src/e2e_token_contract/transfer_in_private.test.ts index d2cf242aff0d..7b1aedfef2fc 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/transfer_in_private.test.ts +++ b/yarn-project/end-to-end/src/e2e_token_contract/transfer_in_private.test.ts @@ -196,9 +196,7 @@ describe('e2e_token_contract transfer private', () => { .withWallet(wallets[1]) .methods.transfer_in_private(badAccount.address, accounts[1].address, 0, nonce) .send(); - await expect(txCancelledAuthwit.wait()).rejects.toThrow( - "Assertion failed: Message not authorized by account 'result == IS_VALID_SELECTOR'", - ); + await expect(txCancelledAuthwit.wait()).rejects.toThrow('Assertion failed: Message not authorized by account'); }); }); }); diff --git a/yarn-project/end-to-end/src/guides/dapp_testing.test.ts b/yarn-project/end-to-end/src/guides/dapp_testing.test.ts index 6364517d2231..0448544372a2 100644 --- a/yarn-project/end-to-end/src/guides/dapp_testing.test.ts +++ b/yarn-project/end-to-end/src/guides/dapp_testing.test.ts @@ -7,12 +7,16 @@ import { TestContract } from '@aztec/noir-contracts.js/Test'; // docs:end:import_contract import { TokenContract } from '@aztec/noir-contracts.js/Token'; +import { jest } from '@jest/globals'; + import { U128_UNDERFLOW_ERROR } from '../fixtures/fixtures.js'; import { mintTokensToPrivate } from '../fixtures/token_utils.js'; const { PXE_URL = 'http://localhost:8080', ETHEREUM_HOST = 'http://localhost:8545' } = process.env; describe('guides/dapp/testing', () => { + jest.setTimeout(60_000); + describe('on local sandbox', () => { beforeAll(async () => { // docs:start:create_pxe_client diff --git a/yarn-project/end-to-end/src/guides/up_quick_start.test.ts b/yarn-project/end-to-end/src/guides/up_quick_start.test.ts index 1fc6920a1f91..e530b850fd40 100644 --- a/yarn-project/end-to-end/src/guides/up_quick_start.test.ts +++ b/yarn-project/end-to-end/src/guides/up_quick_start.test.ts @@ -1,11 +1,14 @@ import { createAztecNodeClient, waitForNode } from '@aztec/aztec.js'; +import { jest } from '@jest/globals'; import { execSync } from 'child_process'; const { AZTEC_NODE_URL = '' } = process.env; // Entrypoint for running the up-quick-start script on the CI describe('guides/up_quick_start', () => { + jest.setTimeout(60_000); + // TODO: update to not use CLI it('works', async () => { await waitForNode(createAztecNodeClient(AZTEC_NODE_URL)); diff --git a/yarn-project/end-to-end/src/shared/browser.ts b/yarn-project/end-to-end/src/shared/browser.ts index b1b2f3fd8634..f55dd85275ed 100644 --- a/yarn-project/end-to-end/src/shared/browser.ts +++ b/yarn-project/end-to-end/src/shared/browser.ts @@ -6,6 +6,7 @@ import * as AztecJs from '@aztec/aztec.js'; import { TokenContractArtifact } from '@aztec/noir-contracts.js/Token'; import { contractArtifactToBuffer } from '@aztec/types/abi'; +import { jest } from '@jest/globals'; import getPort from 'get-port'; import { type Server } from 'http'; import Koa from 'koa'; @@ -55,6 +56,8 @@ export const browserTestSuite = ( pageLogger: AztecJs.Logger, ) => describe('e2e_aztec.js_browser', () => { + jest.setTimeout(60_000); + const initialBalance = 33n; const transferAmount = 3n;