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 dummy arrays #7246

Merged
merged 3 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mod test;
// is performed via `schedule_change` in order to satisfy ScheduleValueChange constraints: if e.g. we allowed for the
// delay to be decreased immediately then it'd be possible for the state variable to schedule a value change with a
// reduced delay, invalidating prior private reads.
struct ScheduledDelayChange<INITIAL_DELAY> {
struct ScheduledDelayChange<let INITIAL_DELAY: u32> {
// Both pre and post are stored in public storage, so by default they are zeroed. By wrapping them in an Option,
// they default to Option::none(), which we detect and replace with INITIAL_DELAY. The end result is that a
// ScheduledDelayChange that has not been initialized has a delay equal to INITIAL_DELAY, which is the desired
Expand All @@ -18,14 +18,11 @@ struct ScheduledDelayChange<INITIAL_DELAY> {
post: Option<u32>,
// Block at which `post` value is used instead of `pre`
block_of_change: u32,
// The _dummy variable forces INITIAL_DELAY to be interpreted as a numeric value. This is a workaround to
// https://github.com/noir-lang/noir/issues/4633. Remove once resolved.
_dummy: [Field; INITIAL_DELAY],
}

impl<INITIAL_DELAY> ScheduledDelayChange<INITIAL_DELAY> {
impl<let INITIAL_DELAY: u32> ScheduledDelayChange<INITIAL_DELAY> {
pub fn new(pre: Option<u32>, post: Option<u32>, block_of_change: u32) -> Self {
Self { pre, post, block_of_change, _dummy: [0; INITIAL_DELAY] }
Self { pre, post, block_of_change }
}

/// Returns the current value of the delay stored in the data structure.
Expand Down Expand Up @@ -167,7 +164,6 @@ impl<INITIAL_DELAY> Deserialize<1> for ScheduledDelayChange<INITIAL_DELAY> {
pre: if pre_is_some { Option::some(pre_inner) } else { Option::none() },
post: if post_is_some { Option::some(post_inner) } else { Option::none() },
block_of_change,
_dummy: [0; INITIAL_DELAY],
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ struct SharedMutablePrivateGetter<T, INITIAL_DELAY> {
other_contract_address: AztecAddress,
// The storage slot where the SharedMutable is stored on the other contract
storage_slot: Field,
// The _dummy variable forces INITIAL_DELAY to be interpreted as a numberic value. This is a workaround to
// https://github.com/noir-lang/noir/issues/4633. Remove once resolved.
_dummy: [Field; INITIAL_DELAY],
}

// We have this as a view-only interface to reading Shared Mutables in other contracts.
Expand All @@ -33,7 +30,7 @@ impl<T, INITIAL_DELAY> SharedMutablePrivateGetter<T, INITIAL_DELAY> where T: Fr
) -> Self {
assert(storage_slot != 0, "Storage slot 0 not allowed. Storage slots must start from 1.");
assert(other_contract_address.to_field() != 0, "Other contract address cannot be 0");
Self { context, other_contract_address, storage_slot, _dummy: [0; INITIAL_DELAY] }
Self { context, other_contract_address, storage_slot }
}

pub fn get_value_in_private(self, header: Header) -> T {
Expand Down
Loading