diff --git a/docs/docs/developers/contracts/main.md b/docs/docs/developers/contracts/main.md index 2507154c6ba..b2ac8781286 100644 --- a/docs/docs/developers/contracts/main.md +++ b/docs/docs/developers/contracts/main.md @@ -2,7 +2,7 @@ title: Smart Contracts --- -This section is a collection of how-to guides and references for building smart contracts with Aztec.nr. +This section is a collection of how-to guides and references for building smart contracts with Aztec.nr. If you are looking for an overview of how smart contracts work, head to the [Concepts section](../../learn/concepts/smart_contracts/main.md). diff --git a/docs/docs/misc/migration_notes.md b/docs/docs/misc/migration_notes.md index ed02683b00b..9848ff58b55 100644 --- a/docs/docs/misc/migration_notes.md +++ b/docs/docs/misc/migration_notes.md @@ -8,6 +8,12 @@ Aztec is in full-speed development. Literally every version breaks compatibility ## 0.36.0 +## `FieldNote` removed + +`FieldNote` only existed for testing purposes, and was not a note type that should be used in any real application. Its name unfortunately led users to think that it was a note type suitable to store a `Field` value, which it wasn't. + +If using `FieldNote`, you most likely want to use `ValueNote` instead, which has both randomness for privacy and an owner for proper nullification. + ## `SlowUpdatesTree` replaced for `SharedMutable` The old `SlowUpdatesTree` contract and libraries have been removed from the codebase, use the new `SharedMutable` library instead. This will require that you add a global variable specifying a delay in blocks for updates, and replace the slow updates tree state variable with `SharedMutable` variables. diff --git a/noir-projects/aztec-nr/Nargo.toml b/noir-projects/aztec-nr/Nargo.toml index e3d50c4968d..144579450f1 100644 --- a/noir-projects/aztec-nr/Nargo.toml +++ b/noir-projects/aztec-nr/Nargo.toml @@ -5,7 +5,6 @@ members = [ "aztec", "compressed-string", "easy-private-state", - "field-note", "value-note", "tests", ] diff --git a/noir-projects/aztec-nr/field-note/Nargo.toml b/noir-projects/aztec-nr/field-note/Nargo.toml deleted file mode 100644 index 908a532b295..00000000000 --- a/noir-projects/aztec-nr/field-note/Nargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "field_note" -authors = ["aztec-labs"] -compiler_version = ">=0.18.0" -type = "lib" - -[dependencies] -aztec = { path = "../aztec" } \ No newline at end of file diff --git a/noir-projects/aztec-nr/field-note/src/lib.nr b/noir-projects/aztec-nr/field-note/src/lib.nr deleted file mode 100644 index 71523fc462b..00000000000 --- a/noir-projects/aztec-nr/field-note/src/lib.nr +++ /dev/null @@ -1 +0,0 @@ -mod field_note; diff --git a/noir-projects/noir-contracts/contracts/import_test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/import_test_contract/src/main.nr index 9224c0c2a3e..92636928014 100644 --- a/noir-projects/noir-contracts/contracts/import_test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/import_test_contract/src/main.nr @@ -5,7 +5,6 @@ contract ImportTest { use dep::test::{Test, Test::DeepStruct, Test::DummyNote}; - use dep::test::Test::FieldNote; use dep::test::Test::ValueNote; // Calls the test_code_gen on the Test contract at the target address diff --git a/noir-projects/noir-contracts/contracts/test_contract/Nargo.toml b/noir-projects/noir-contracts/contracts/test_contract/Nargo.toml index c1e9abeb6a9..8ddc423b451 100644 --- a/noir-projects/noir-contracts/contracts/test_contract/Nargo.toml +++ b/noir-projects/noir-contracts/contracts/test_contract/Nargo.toml @@ -6,6 +6,5 @@ type = "contract" [dependencies] aztec = { path = "../../../aztec-nr/aztec" } -field_note = { path = "../../../aztec-nr/field-note" } value_note = { path = "../../../aztec-nr/value-note" } token_portal_content_hash_lib = { path = "../token_portal_content_hash_lib" } diff --git a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr index a7e897ad564..f7a40cf41a8 100644 --- a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr @@ -1,5 +1,8 @@ +mod test_note; + // A contract used for testing a random hodgepodge of small features from simulator and end-to-end tests. contract Test { + use dep::aztec::prelude::{ AztecAddress, EthAddress, FunctionSelector, NoteHeader, NoteGetterOptions, NoteViewerOptions, PrivateContext, PrivateImmutable, PrivateSet, SharedImmutable @@ -25,9 +28,10 @@ contract Test { oracle::{get_public_key::get_public_key as get_public_key_oracle, unsafe_rand::unsafe_rand} }; use dep::token_portal_content_hash_lib::{get_mint_private_content_hash, get_mint_public_content_hash}; - use dep::field_note::field_note::FieldNote; use dep::value_note::value_note::ValueNote; + use crate::test_note::TestNote; + #[aztec(event)] struct ExampleEvent { value: Field, @@ -35,8 +39,8 @@ contract Test { #[aztec(storage)] struct Storage { - example_constant: PrivateImmutable, - example_set: PrivateSet, + example_constant: PrivateImmutable, + example_set: PrivateSet, } #[aztec(private)] @@ -122,10 +126,7 @@ contract Test { opt_notes[0].unwrap().value } - unconstrained fn call_view_notes_many( - storage_slot: Field, - active_or_nullified: bool - ) -> pub [Field; 2] { + unconstrained fn call_view_notes_many(storage_slot: Field, active_or_nullified: bool) -> pub [Field; 2] { assert( storage_slot != storage.example_constant.get_storage_slot(), "this storage slot is reserved for example_constant" ); @@ -298,7 +299,7 @@ contract Test { #[aztec(private)] fn set_constant(value: Field) { - let mut note = FieldNote::new(value); + let mut note = TestNote::new(value); storage.example_constant.initialize(&mut note, false); } @@ -352,7 +353,7 @@ contract Test { let notes_set = storage.example_set; let secret_hash = compute_secret_hash(secret); let mut options = NoteGetterOptions::new(); - options = options.select(FieldNote::properties().value, secret_hash, Option::none()).set_limit(1); + options = options.select(TestNote::properties().value, secret_hash, Option::none()).set_limit(1); let notes = notes_set.get_notes(options); let note = notes[0].unwrap_unchecked(); notes_set.remove(note); diff --git a/noir-projects/aztec-nr/field-note/src/field_note.nr b/noir-projects/noir-contracts/contracts/test_contract/src/test_note.nr similarity index 63% rename from noir-projects/aztec-nr/field-note/src/field_note.nr rename to noir-projects/noir-contracts/contracts/test_contract/src/test_note.nr index f6350ddd613..17f2d2d244d 100644 --- a/noir-projects/aztec-nr/field-note/src/field_note.nr +++ b/noir-projects/noir-contracts/contracts/test_contract/src/test_note.nr @@ -3,17 +3,18 @@ use dep::aztec::{ context::PrivateContext }; -global FIELD_NOTE_LEN: Field = 1; +global TEST_NOTE_LEN: Field = 1; // A note which stores a field and is expected to be passed around using the `addNote` function. -// WARNING: This Note is not private as it does not contain randomness and hence it can be easy to perform serialized_note -// attack on it. +// WARNING: This Note is not private as it does not contain randomness and hence it can be easy to perform +// serialized_note attack on it. This note has been developed purely for testing purposes so that it can easily be +// manually added to PXE. Do not use for real applications. #[aztec(note)] -struct FieldNote { +struct TestNote { value: Field, } -impl NoteInterface for FieldNote { +impl NoteInterface for TestNote { fn compute_nullifier(self, _context: &mut PrivateContext) -> Field { // This note is expected to be shared between users and for this reason can't be nullified using a secret. @@ -27,14 +28,13 @@ impl NoteInterface for FieldNote { fn broadcast(self, context: &mut PrivateContext, slot: Field) { assert( - false, "FieldNote does not support broadcast. Add it to PXE directly using the `.addNote` function." + false, "TestNote does not support broadcast. Add it to PXE directly using the `.addNote` function." ); } } -impl FieldNote { +impl TestNote { pub fn new(value: Field) -> Self { - FieldNote { value, header: NoteHeader::empty() } + TestNote { value, header: NoteHeader::empty() } } } - diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/Nargo.toml b/noir-projects/noir-contracts/contracts/token_blacklist_contract/Nargo.toml index ee4f8aa622b..f5800913173 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/Nargo.toml +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/Nargo.toml @@ -6,5 +6,4 @@ type = "contract" [dependencies] aztec = { path = "../../../aztec-nr/aztec" } -field_note = { path = "../../../aztec-nr/field-note" } -authwit = { path = "../../../aztec-nr/authwit" } \ No newline at end of file +authwit = { path = "../../../aztec-nr/authwit" } 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 5ec01d4f26a..a6572b4e54c 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 @@ -18,8 +18,6 @@ contract TokenBlacklist { state_vars::{Map, PublicMutable, PrivateSet, SharedMutable, SharedImmutable} }; - use dep::field_note::field_note::FieldNote; - use dep::authwit::{auth::{assert_current_call_valid_authwit, assert_current_call_valid_authwit_public}}; use crate::types::{transparent_note::TransparentNote, token_note::TokenNote, balances_map::BalancesMap, roles::UserFlags}; diff --git a/yarn-project/end-to-end/src/e2e_non_contract_account.test.ts b/yarn-project/end-to-end/src/e2e_non_contract_account.test.ts index 100ad4c7646..8b08c8fa4fc 100644 --- a/yarn-project/end-to-end/src/e2e_non_contract_account.test.ts +++ b/yarn-project/end-to-end/src/e2e_non_contract_account.test.ts @@ -65,7 +65,7 @@ describe('e2e_non_contract_account', () => { }, 120_000); // Note: This test doesn't really belong here as it doesn't have anything to do with non-contract accounts. I needed - // to test the FieldNote functionality and it doesn't really fit anywhere else. Creating a separate e2e test for this + // to test the TestNote functionality and it doesn't really fit anywhere else. Creating a separate e2e test for this // seems wasteful. Move this test if a better place is found. it('can set and get a constant', async () => { const value = 123n; @@ -86,7 +86,7 @@ describe('e2e_non_contract_account', () => { wallet.getCompleteAddress().address, contract.address, TestContract.storage.example_constant.slot, - TestContract.notes.FieldNote.id, + TestContract.notes.TestNote.id, txHash, ); await wallet.addNote(extendedNote);