-
Notifications
You must be signed in to change notification settings - Fork 598
refactor: Make get notes return all notes at beginning of array #4991 #5321
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
Merged
sklppy88
merged 46 commits into
master
from
ek/refactor/get-notes-returns-non-sparse-array
Mar 28, 2024
Merged
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
1f033aa
Fix
42ca60a
fix
da6378a
fix
a313ca2
asdf
b57c607
add test
fd364f3
add test
ce18eef
Merge branch 'master' into ek/refactor/get-notes-returns-non-sparse-a…
sklppy88 7b5929f
fix
5473fd1
formatting fix
fdd0219
Add comments
717eb4a
tweak
276dc0c
feat: truncate SHA hashes inside circuits (#5160)
MirandaWood fb897db
feat: simplified bb Honk interface (#5319)
ledwards2225 8cf742d
feat: ZeroMorph working with IPA and integration with ECCVM (#5246)
ece6d82
chore: Remove unused FunctionLeafPreimage struct (#5354)
spalladino 0ef7367
fix: Generate noir interface for constructors (#5352)
spalladino 5d1a478
chore: Name change: gen perm sort to delta range constraint (#5378)
ledwards2225 424401c
git subrepo push --branch=master barretenberg
4447aa9
chore: replace relative paths to noir-protocol-circuits
08c9358
git_subrepo.sh: Fix parent in .gitrepo file. [skip ci]
86a63f7
git subrepo push --branch=master noir-projects/aztec-nr
565f59b
refactor: make get_notes fail if returning no notes #4988 (#5320)
sklppy88 784585a
feat(AuthWit): chain_id and version in hash (#5331)
LHerskind a9d22ff
chore: skip slither in docker (#5384)
LHerskind 9ea8186
feat: Dynamic proving (#5346)
PhilWindle 9bc4249
refactor: messaging naming fixes (#5383)
benesjan 0a3ec3d
fix
eb0d71c
Merge branch 'master' into ek/refactor/get-notes-returns-non-sparse-a…
sklppy88 a4c86a0
Update note_getter.nr
sklppy88 2e8e51b
Merge branch 'master' into ek/refactor/get-notes-returns-non-sparse-a…
sklppy88 a1d8b9a
Merge branch 'master' into ek/refactor/get-notes-returns-non-sparse-a…
sklppy88 c7955f2
Merge branch 'master' into ek/refactor/get-notes-returns-non-sparse-a…
sklppy88 8a2ecdf
Merge branch 'master' into ek/refactor/get-notes-returns-non-sparse-a…
sklppy88 ed51191
fix
a8f2634
cleanup
0c71058
cleanup
86b573a
Merge branch 'master' into ek/refactor/get-notes-returns-non-sparse-a…
sklppy88 52ec4f6
addressing comments
a3a34a3
Update noir-projects/aztec-nr/tests/src/note_getter_test.nr
sklppy88 1c3fc6e
fmt
ed9d9fd
Merge branch 'master' into ek/refactor/get-notes-returns-non-sparse-a…
sklppy88 dae4641
address comments
0ce7455
fix
7c8abc8
Merge branch 'master' into ek/refactor/get-notes-returns-non-sparse-a…
sklppy88 c55a9cd
Merge branch 'master' into ek/refactor/get-notes-returns-non-sparse-a…
sklppy88 b6b4f96
why
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,4 +8,5 @@ members = [ | |
| "field-note", | ||
| "slow-updates-tree", | ||
| "value-note", | ||
| "tests", | ||
| ] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| [package] | ||
| name = "tests" | ||
| authors = ["aztec-labs"] | ||
| compiler_version = ">=0.18.0" | ||
| type = "lib" | ||
|
|
||
| [dependencies] | ||
| aztec = { path = "../aztec" } | ||
| protocol_types = { path = "../../noir-protocol-circuits/crates/types" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| mod note_getter_test; | ||
| mod mock; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| mod test_note; | ||
|
|
||
| use test_note::TestNote; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| use dep::aztec::context::PrivateContext; | ||
| use dep::aztec::note::{ | ||
| note_header::NoteHeader, | ||
| note_interface::NoteInterface, | ||
| }; | ||
|
|
||
| global TEST_NOTE_LENGTH = 1; | ||
|
|
||
| struct TestNote { | ||
| header: NoteHeader, | ||
| value: Field, | ||
| } | ||
|
|
||
| impl NoteInterface<TEST_NOTE_LENGTH> for TestNote { | ||
| fn serialize_content(self) -> [Field; TEST_NOTE_LENGTH] { | ||
| [self.value] | ||
| } | ||
|
|
||
| fn deserialize_content(fields: [Field; TEST_NOTE_LENGTH]) -> Self { | ||
| Self { | ||
| value: fields[0], | ||
| header: NoteHeader::empty(), | ||
| } | ||
| } | ||
|
|
||
| fn compute_note_content_hash(self) -> Field { | ||
| 0 | ||
| } | ||
|
|
||
| fn get_header(self) -> NoteHeader { | ||
| self.header | ||
| } | ||
|
|
||
| fn set_header(&mut self, header: NoteHeader) -> () { | ||
| self.header = header; | ||
| } | ||
|
|
||
| fn get_note_type_id() -> Field { | ||
| 0 | ||
| } | ||
|
|
||
| fn compute_nullifier(self, _context: &mut PrivateContext) -> Field { | ||
| 0 | ||
| } | ||
|
|
||
| fn compute_nullifier_without_context(self) -> Field { | ||
| 0 | ||
| } | ||
|
|
||
| fn broadcast(self, context: &mut PrivateContext, slot: Field) { | ||
| assert( | ||
| false, "TestNote does not support broadcast." | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| impl TestNote { | ||
| pub fn new(value: Field) -> Self { | ||
| TestNote { value, header: NoteHeader::empty() } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| use dep::protocol_types::constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL; | ||
| use dep::aztec::context::PrivateContext; | ||
| use dep::aztec::note::{ | ||
| note_header::NoteHeader, | ||
| note_getter_options::{NoteGetterOptions, Sort, SortOrder, Comparator, PropertySelector}, | ||
| note_getter::_get_notes_constrain_get_notes_internal | ||
| }; | ||
| use dep::aztec::protocol_types::address::AztecAddress; | ||
| use crate::mock::test_note::TestNote; | ||
|
|
||
| #[test] | ||
| fn sets_note_manually_and_fetches_it() { | ||
| let mut context: PrivateContext = dep::std::unsafe::zeroed(); | ||
| context.inputs.call_context.storage_contract_address = AztecAddress::from_field(69); | ||
|
|
||
| let mut test_note = TestNote::new(1337); | ||
| test_note.header = NoteHeader::new(AztecAddress::from_field(69), 0, 42); | ||
|
|
||
| let mut opt_notes = [Option::none(); MAX_NOTE_HASH_READ_REQUESTS_PER_CALL]; | ||
| opt_notes[0] = Option::some(test_note); | ||
|
|
||
| let storage_slot: Field = 42; | ||
|
|
||
| let mut options = NoteGetterOptions::new(); | ||
| let returned = _get_notes_constrain_get_notes_internal(&mut context, storage_slot, opt_notes, options); | ||
| assert_eq(returned[0].unwrap().value, 1337); | ||
| } | ||
|
|
||
| #[test(should_fail)] | ||
| fn cannot_return_zero_notes() { | ||
| let mut context: PrivateContext = dep::std::unsafe::zeroed(); | ||
| let storage_slot: Field = 0; | ||
| let mut opt_notes: [Option<TestNote>; MAX_NOTE_HASH_READ_REQUESTS_PER_CALL] = [Option::none(); MAX_NOTE_HASH_READ_REQUESTS_PER_CALL]; | ||
|
|
||
| let mut options = NoteGetterOptions::new(); | ||
| let returned = _get_notes_constrain_get_notes_internal(&mut context, storage_slot, opt_notes, options); | ||
| } | ||
|
|
||
| #[test(should_fail)] | ||
| fn mismatched_address() { | ||
| let mut context: PrivateContext = dep::std::unsafe::zeroed(); | ||
| context.inputs.call_context.storage_contract_address = AztecAddress::from_field(1); | ||
|
|
||
| let storage_slot: Field = 0; | ||
| let mut opt_notes: [Option<TestNote>; MAX_NOTE_HASH_READ_REQUESTS_PER_CALL] = [Option::none(); MAX_NOTE_HASH_READ_REQUESTS_PER_CALL]; | ||
| opt_notes[0] = Option::some(TestNote::new(1)); | ||
|
|
||
| let mut options = NoteGetterOptions::new(); | ||
| let returned = _get_notes_constrain_get_notes_internal(&mut context, storage_slot, opt_notes, options); | ||
| } | ||
|
|
||
| #[test(should_fail)] | ||
| fn mismatched_storage_slot() { | ||
| let mut context: PrivateContext = dep::std::unsafe::zeroed(); | ||
| context.inputs.call_context.storage_contract_address = AztecAddress::from_field(1); | ||
|
|
||
| let mut test_note = TestNote::new(1); | ||
| test_note.header = NoteHeader::new(AztecAddress::from_field(1), 0, 1); | ||
|
|
||
| let mut opt_notes: [Option<TestNote>; MAX_NOTE_HASH_READ_REQUESTS_PER_CALL] = [Option::none(); MAX_NOTE_HASH_READ_REQUESTS_PER_CALL]; | ||
| opt_notes[0] = Option::some(test_note); | ||
|
|
||
| let storage_slot: Field = 0; | ||
|
|
||
| let mut options = NoteGetterOptions::new(); | ||
| let returned = _get_notes_constrain_get_notes_internal(&mut context, storage_slot, opt_notes, options); | ||
| } | ||
|
|
||
| #[test(should_fail)] | ||
| fn invalid_selector() { | ||
| let mut context: PrivateContext = dep::std::unsafe::zeroed(); | ||
| context.inputs.call_context.storage_contract_address = AztecAddress::from_field(1); | ||
|
|
||
| let mut test_note = TestNote::new(1); | ||
| test_note.header = NoteHeader::new(AztecAddress::from_field(1), 0, 0); | ||
|
|
||
| let mut opt_notes: [Option<TestNote>; MAX_NOTE_HASH_READ_REQUESTS_PER_CALL] = [Option::none(); MAX_NOTE_HASH_READ_REQUESTS_PER_CALL]; | ||
| opt_notes[0] = Option::some(test_note); | ||
|
|
||
| let storage_slot: Field = 0; | ||
|
|
||
| let mut options = NoteGetterOptions::new().select( | ||
| PropertySelector { index: 0, offset: 0, length: 32 }, | ||
| 10, | ||
| Option::some(Comparator.EQ) | ||
| ); | ||
| let returned = _get_notes_constrain_get_notes_internal(&mut context, storage_slot, opt_notes, options); | ||
| } | ||
|
|
||
| #[test(should_fail)] | ||
| fn invalid_note_order() { | ||
| let mut context: PrivateContext = dep::std::unsafe::zeroed(); | ||
|
|
||
| let mut opt_notes: [Option<TestNote>; MAX_NOTE_HASH_READ_REQUESTS_PER_CALL] = [Option::none(); MAX_NOTE_HASH_READ_REQUESTS_PER_CALL]; | ||
| opt_notes[0] = Option::some(TestNote::new(1)); | ||
| opt_notes[1] = Option::some(TestNote::new(2)); | ||
|
|
||
| let storage_slot: Field = 0; | ||
|
|
||
| let mut options = NoteGetterOptions::new().sort( | ||
| PropertySelector { index: 0, offset: 0, length: 32 }, | ||
| SortOrder.DESC | ||
| ); | ||
| let returned = _get_notes_constrain_get_notes_internal(&mut context, storage_slot, opt_notes, options); | ||
| } | ||
|
|
||
| #[test] | ||
| fn sparse_notes_array() { | ||
| let mut context: PrivateContext = dep::std::unsafe::zeroed(); | ||
|
|
||
| let mut opt_notes: [Option<TestNote>; MAX_NOTE_HASH_READ_REQUESTS_PER_CALL] = [Option::none(); MAX_NOTE_HASH_READ_REQUESTS_PER_CALL]; | ||
| opt_notes[1] = Option::some(TestNote::new(0)); | ||
| opt_notes[2] = Option::some(TestNote::new(1)); | ||
| opt_notes[3] = Option::some(TestNote::new(2)); | ||
| opt_notes[5] = Option::some(TestNote::new(3)); | ||
| opt_notes[8] = Option::some(TestNote::new(4)); | ||
| opt_notes[13] = Option::some(TestNote::new(5)); | ||
| opt_notes[21] = Option::some(TestNote::new(6)); | ||
|
|
||
| let storage_slot: Field = 0; | ||
|
|
||
| let mut options = NoteGetterOptions::new(); | ||
| let returned = _get_notes_constrain_get_notes_internal(&mut context, storage_slot, opt_notes, options); | ||
|
|
||
| for i in 0..7 { | ||
| assert(returned[i].unwrap().value == i as Field); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.