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

chore: remove hardcoded storage slot values #4398

Merged
merged 2 commits into from
Feb 5, 2024
Merged
Changes from all commits
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
24 changes: 18 additions & 6 deletions yarn-project/noir-contracts/contracts/test_contract/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,19 @@ contract Test {

#[aztec(private)]
fn call_create_note(value: Field, owner: AztecAddress, storage_slot: Field) {
assert(storage_slot != 1, "storage slot 1 is reserved for example_constant");
assert(
storage_slot != storage.example_constant.get_storage_slot(), "this storage slot is reserved for example_constant"
);

let mut note = ValueNote::new(value, owner);
create_note(&mut context, storage_slot, &mut note, true);
}

#[aztec(private)]
fn call_get_notes(storage_slot: Field, active_or_nullified: bool) {
assert(storage_slot != 1, "storage slot 1 is reserved for example_constant");
assert(
storage_slot != storage.example_constant.get_storage_slot(), "this storage slot is reserved for example_constant"
);

let mut options = NoteGetterOptions::new();
if (active_or_nullified) {
Expand All @@ -112,7 +116,9 @@ contract Test {

#[aztec(private)]
fn call_get_notes_many(storage_slot: Field, active_or_nullified: bool) {
assert(storage_slot != 1, "storage slot 1 is reserved for example_constant");
assert(
storage_slot != storage.example_constant.get_storage_slot(), "this storage slot is reserved for example_constant"
);

let mut options = NoteGetterOptions::new();
if (active_or_nullified) {
Expand All @@ -128,7 +134,9 @@ contract Test {
}

unconstrained fn call_view_notes(storage_slot: Field, active_or_nullified: bool) -> pub Field {
assert(storage_slot != 1, "storage slot 1 is reserved for example_constant");
assert(
storage_slot != storage.example_constant.get_storage_slot(), "this storage slot is reserved for example_constant"
);

let mut options = NoteViewerOptions::new();
if (active_or_nullified) {
Expand All @@ -144,7 +152,9 @@ contract Test {
storage_slot: Field,
active_or_nullified: bool
) -> pub [Field; 2] {
assert(storage_slot != 1, "storage slot 1 is reserved for example_constant");
assert(
storage_slot != storage.example_constant.get_storage_slot(), "this storage slot is reserved for example_constant"
);

let mut options = NoteViewerOptions::new();
if (active_or_nullified) {
Expand All @@ -158,7 +168,9 @@ contract Test {

#[aztec(private)]
fn call_destroy_note(storage_slot: Field) {
assert(storage_slot != 1, "storage slot 1 is reserved for example_constant");
assert(
storage_slot != storage.example_constant.get_storage_slot(), "this storage slot is reserved for example_constant"
);

let options = NoteGetterOptions::new();
let opt_notes: [Option<ValueNote>; MAX_READ_REQUESTS_PER_CALL] = get_notes(&mut context, storage_slot, options);
Expand Down
Loading