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: partial note handling in aztec-nr #11641

Merged
merged 49 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
a124c6a
Sketching out initial approach
nventuro Dec 12, 2024
ec92180
Success!
nventuro Dec 13, 2024
2f52d31
IT LIVES
nventuro Dec 13, 2024
a443446
Misc doc improvements
nventuro Dec 13, 2024
dae83d7
Some more minor comments
nventuro Dec 13, 2024
40d2dae
Remove old ts code
nventuro Dec 14, 2024
893ad80
noir formatting
nventuro Dec 14, 2024
4c88865
Merge branch 'master' into nv/process_note_logs
nventuro Jan 8, 2025
206444f
It works!
nventuro Jan 9, 2025
51a7f0b
Add some docs
nventuro Jan 9, 2025
212219a
Merge branch 'master' into nv/process_note_logs
nventuro Jan 9, 2025
646f5ff
Handle no note contracts
nventuro Jan 9, 2025
b771c98
Fix macro
nventuro Jan 9, 2025
ebf7412
Merge branch 'master' into nv/process_note_logs
nventuro Jan 9, 2025
eccd8b6
Fix import
nventuro Jan 9, 2025
da8408f
Remove extra file
nventuro Jan 10, 2025
d5fe202
Apply suggestions from code review
nventuro Jan 10, 2025
96af47d
Rename foreach
nventuro Jan 10, 2025
48fe292
Move files around
nventuro Jan 10, 2025
7f46d5a
Merge branch 'master' into nv/process_note_logs
nventuro Jan 10, 2025
30cbc8a
If I have to nargo fmt one more time
nventuro Jan 10, 2025
5205cc4
Oh god
nventuro Jan 10, 2025
76bbd1b
zzz
nventuro Jan 10, 2025
d44ec2e
kill me now
nventuro Jan 10, 2025
8b7d508
Add node methods to txe node
nventuro Jan 13, 2025
ff0127c
Merge branch 'master' into nv/process_note_logs
nventuro Jan 13, 2025
8f56981
Add sim prov
nventuro Jan 13, 2025
72ea7c4
Fix build error
nventuro Jan 13, 2025
3b08dcf
wip
nventuro Jan 15, 2025
f6ab8a5
Merge branch 'nv/advanced_note_discovery' into nv/pxe-db-improv
nventuro Jan 16, 2025
a258045
Merge branch 'master' into nv/advanced_note_discovery
nventuro Jan 17, 2025
8e34972
Add oracle
nventuro Jan 28, 2025
b5bfca6
wip
nventuro Jan 28, 2025
67996aa
Merge branch 'nv/get-logs-oracle' into nv/advanced_note_discovery
nventuro Jan 28, 2025
70c75c1
almost there
nventuro Jan 29, 2025
1070360
Merge branch 'master' into nv/advanced_note_discovery
nventuro Jan 29, 2025
061aecd
IT LIVES!
nventuro Jan 30, 2025
e625ad9
Doc improvements
nventuro Jan 30, 2025
49488f3
Doc improvements
nventuro Jan 30, 2025
4d3ada9
Adddress typos
nventuro Feb 5, 2025
84ed736
Address review comments
nventuro Feb 5, 2025
7139223
Rename to aztec::discovery
nventuro Feb 5, 2025
0172f39
Remove archiver and token changes
nventuro Feb 5, 2025
7089282
Fix archiver
nventuro Feb 5, 2025
ecd6811
Merge branch 'master' into nv/advanced_note_discovery
nventuro Feb 5, 2025
774e9ab
remove the final differences
nventuro Feb 5, 2025
26f77a5
Fix log type destructuring
nventuro Feb 6, 2025
3e21aff
Fix TXE tests by forcing syncs when appropriate
nventuro Feb 6, 2025
14ebf3d
Fix simulator tests
nventuro Feb 6, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ where
plaintext_bytes
}

fn compute_log<Note, let N: u32>(
pub fn compute_log<Note, let N: u32>(
context: PrivateContext,
note: Note,
recipient: AztecAddress,
Expand Down
53 changes: 50 additions & 3 deletions noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
pub mod interfaces;
pub mod initialization_utils;

use super::utils::{
add_to_hasher, fn_has_noinitcheck, get_fn_visibility, is_fn_initializer, is_fn_internal,
is_fn_private, is_fn_view, modify_fn_body, module_has_initializer, module_has_storage,
use super::{
notes::NOTES,
utils::{
add_to_hasher, fn_has_noinitcheck, get_fn_visibility, is_fn_initializer, is_fn_internal,
is_fn_private, is_fn_view, modify_fn_body, module_has_initializer, module_has_storage,
},
};
use protocol_types::meta::generate_serialize_to_fields;
use std::meta::type_of;
Expand Down Expand Up @@ -81,6 +84,31 @@ comptime fn create_init_check(f: FunctionDefinition) -> Quoted {
.quoted_contents()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't comment on the line, and it's completely unrelated to this PR, but what does this empty-bodied function do? (I know what an internal function is for; I just don't understand this function).
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's two paragraphs one line immediate above this that explain it. Searchin for 'marker attribute' also gets you to the right place.

}

/// Injects a call to `aztec::note::discovery::discover_new_notes`, causing for new notes to be added to PXE and made
/// available for the current execution.
comptime fn create_note_discovery_call() -> Quoted {
quote {
/// Safety: note discovery returns nothing and is performed solely for its side-effects. It is therefore always
/// safe to call.
unsafe {
dep::aztec::note::discovery::discover_new_notes(
context.this_address(),
|serialized_note_content: BoundedVec<Field, _>, contract_address: aztec::protocol_types::address::AztecAddress, nonce: Field, storage_slot: Field, note_type_id: Field| {
nventuro marked this conversation as resolved.
Show resolved Hide resolved
// _compute_note_hash_and_optionally_a_nullifier is a contract library method injected by `generate_contract_library_method_compute_note_hash_and_optionally_a_nullifier`
let hashes = _compute_note_hash_and_optionally_a_nullifier(contract_address, nonce, storage_slot, note_type_id, true, serialized_note_content);
nventuro marked this conversation as resolved.
Show resolved Hide resolved

Option::some(
nventuro marked this conversation as resolved.
Show resolved Hide resolved
aztec::note::discovery::NoteHashAndNullifier {
note_hash: hashes[0],
inner_nullifier: hashes[3],
},
)
},
)
};
}
}

/// Private functions are executed client-side and preserve privacy.
pub comptime fn private(f: FunctionDefinition) -> Quoted {
let fn_abi = create_fn_abi_export(f);
Expand Down Expand Up @@ -160,6 +188,14 @@ pub comptime fn private(f: FunctionDefinition) -> Quoted {
quote {}
};

// All private functions perform note discovery, since they may need to access notes. This is slightly inefficient
// and could be improved by only doing it once we actually attempt to read any.
nventuro marked this conversation as resolved.
Show resolved Hide resolved
let note_discovery_call = if NOTES.len() > 0 {
create_note_discovery_call()
} else {
quote {}
};

// Finally, we need to change the return type to be `PrivateCircuitPublicInputs`, which is what the Private Kernel
// circuit expects.
let return_value_var_name = quote { macro__returned__values };
Expand Down Expand Up @@ -211,6 +247,7 @@ pub comptime fn private(f: FunctionDefinition) -> Quoted {
$internal_check
$view_check
$storage_init
$note_discovery_call
};

let to_append = quote {
Expand Down Expand Up @@ -336,9 +373,19 @@ pub comptime fn transform_unconstrained(f: FunctionDefinition) {
} else {
quote {}
};

// All unconstrained functions perform note discovery, since they may need to access notes. This is slightly
// inefficient and could be improved by only doing it once we actually attempt to read any.
let note_discovery_call = if NOTES.len() > 0 {
create_note_discovery_call()
} else {
quote {}
};

let to_prepend = quote {
$context_creation
$storage_init
$note_discovery_call
};
let body = f.body().as_block().unwrap();
let modified_body = modify_fn_body(body, to_prepend, quote {});
Expand Down
Loading