Skip to content
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

feat!: delete field note #5959

Merged
merged 4 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/docs/developers/contracts/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
6 changes: 6 additions & 0 deletions docs/docs/misc/migration_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

## [Aztec.nr & js] Portal addresses

Deployments have been modified. No longer are portal addresses treated as a special class, being immutably set on creation of a contract. They are no longer passed in differently compared to the other variables and instead should be implemented using usual storage by those who require it. One should use the storage that matches the usecase - likely shared storage to support private and public.
Expand Down
1 change: 0 additions & 1 deletion noir-projects/aztec-nr/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ members = [
"aztec",
"compressed-string",
"easy-private-state",
"field-note",
"slow-updates-tree",
"value-note",
"tests",
Expand Down
8 changes: 0 additions & 8 deletions noir-projects/aztec-nr/field-note/Nargo.toml

This file was deleted.

1 change: 0 additions & 1 deletion noir-projects/aztec-nr/field-note/src/lib.nr

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
19 changes: 10 additions & 9 deletions noir-projects/noir-contracts/contracts/test_contract/src/main.nr
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -25,18 +28,19 @@ 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,
}

#[aztec(storage)]
struct Storage {
example_constant: PrivateImmutable<FieldNote>,
example_set: PrivateSet<FieldNote>,
example_constant: PrivateImmutable<TestNote>,
example_set: PrivateSet<TestNote>,
}

#[aztec(private)]
Expand Down Expand Up @@ -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"
);
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ use dep::aztec::{
context::PrivateContext
};

global FIELD_NOTE_LEN: Field = 1;
global Test_NOTE_LEN: Field = 1;
nventuro marked this conversation as resolved.
Show resolved Hide resolved

// 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<FIELD_NOTE_LEN> for FieldNote {
impl NoteInterface<Test_NOTE_LEN> 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.
Expand All @@ -27,14 +28,13 @@ impl NoteInterface<FIELD_NOTE_LEN> 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() }
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ type = "contract"

[dependencies]
aztec = { path = "../../../aztec-nr/aztec" }
field_note = { path = "../../../aztec-nr/field-note" }
authwit = { path = "../../../aztec-nr/authwit" }
slow_tree = { path = "../slow_tree_contract" }
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ contract TokenBlacklist {
hash::compute_secret_hash, state_vars::{Map, PublicMutable, PrivateSet, 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};
Expand Down
Loading