Skip to content

Commit

Permalink
feat: do not allow slot 0 in noir-libs (#1884)
Browse files Browse the repository at this point in the history
Fixes #1692
  • Loading branch information
benesjan authored Aug 31, 2023
1 parent 88086e4 commit 54094b4
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct EasyPrivateUint {

impl EasyPrivateUint {
fn new(storage_slot: Field) -> Self {
assert(storage_slot != 0); // Storage slot 0 not allowed. Storage slots must start from 1.
let set = Set {
storage_slot,
note_interface: ValueNoteMethods,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ struct ImmutableSingleton<Note, N> {

impl<Note, N> ImmutableSingleton<Note, N> {
fn new(storage_slot: Field, note_interface: NoteInterface<Note, N>) -> Self {
assert(storage_slot != 0); // Storage slot 0 not allowed. Storage slots must start from 1.
ImmutableSingleton { storage_slot, note_interface }
}

Expand Down
1 change: 1 addition & 0 deletions yarn-project/noir-libs/noir-aztec/src/state_vars/map.nr
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ struct Map<V> {

impl<V> Map<V> {
fn new(storage_slot: Field, state_var_constructor: fn (Field) -> V) -> Map<V> {
assert(storage_slot != 0); // Storage slot 0 not allowed. Storage slots must start from 1.
Map { storage_slot, state_var_constructor }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ struct PublicState<T, T_SERIALISED_LEN> {

impl<T, T_SERIALISED_LEN> PublicState<T, T_SERIALISED_LEN> {
fn new(storage_slot: Field, serialisation_methods: TypeSerialisationInterface<T, T_SERIALISED_LEN>) -> Self {
assert(storage_slot != 0); // Storage slot 0 not allowed. Storage slots must start from 1.
PublicState { storage_slot, serialisation_methods }
}

Expand Down
1 change: 1 addition & 0 deletions yarn-project/noir-libs/noir-aztec/src/state_vars/set.nr
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ struct Set<Note, N> {

impl<Note, N> Set<Note, N> {
fn new(storage_slot: Field, note_interface: NoteInterface<Note, N>) -> Self {
assert(storage_slot != 0); // Storage slot 0 not allowed. Storage slots must start from 1.
Set { storage_slot, note_interface }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ struct Singleton<Note, N> {

impl<Note, N> Singleton<Note, N> {
fn new(storage_slot: Field, note_interface: NoteInterface<Note, N>) -> Self {
assert(storage_slot != 0); // Storage slot 0 not allowed. Storage slots must start from 1.
Singleton { storage_slot, note_interface }
}

Expand Down

0 comments on commit 54094b4

Please sign in to comment.