Skip to content

Commit

Permalink
Merge 800b9e3 into a932153
Browse files Browse the repository at this point in the history
  • Loading branch information
Maddiaa0 authored Feb 28, 2024
2 parents a932153 + 800b9e3 commit fa73842
Show file tree
Hide file tree
Showing 54 changed files with 290 additions and 262 deletions.
1 change: 1 addition & 0 deletions l1-contracts/src/core/libraries/ConstantsGen.sol
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,5 @@ library Constants {
uint256 internal constant CONTRACT_DATA_NUM_BYTES_PER_BASE_ROLLUP_UNPADDED = 52;
uint256 internal constant L2_TO_L1_MSGS_NUM_BYTES_PER_BASE_ROLLUP = 64;
uint256 internal constant LOGS_HASHES_NUM_BYTES_PER_BASE_ROLLUP = 64;
uint256 internal constant APPEND_ONLY_TREE_SNAPSHOT_LENGTH = 2;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ struct L1ToL2MessageGetterData {
leaf_index: Field
}

pub fn l1_to_l2_message_getter_len() -> u64 {
pub fn l1_to_l2_message_getter_len() -> u32 {
L1_TO_L2_MESSAGE_LENGTH + 1 + L1_TO_L2_MSG_TREE_HEIGHT
}

pub fn make_l1_to_l2_message_getter_data<N>(
fields: [Field; N],
start: u64,
start: u32,
secret: Field
) -> L1ToL2MessageGetterData {
L1ToL2MessageGetterData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl<Note, N, FILTER_ARGS> NoteGetterOptions<Note, N, FILTER_ARGS> {
pub fn with_filter(
filter: fn([Option<Note>; MAX_READ_REQUESTS_PER_CALL], FILTER_ARGS) -> [Option<Note>; MAX_READ_REQUESTS_PER_CALL],
filter_args: FILTER_ARGS
) -> Self where Note: NoteInterface<N> {
) -> Self where Note: NoteInterface<N> {
NoteGetterOptions {
selects: BoundedVec::new(),
sorts: BoundedVec::new(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use dep::protocol_types::{
utils::arr_copy_slice
};

global LEAF_PREIMAGE_LENGTH: u64 = 4;
global LEAF_PREIMAGE_LENGTH: u32 = 4;
global PUBLIC_DATA_WITNESS: Field = 45;

struct PublicDataWitness {
Expand All @@ -23,7 +23,7 @@ unconstrained pub fn get_public_data_witness(block_number: u32, leaf_slot: Field
let fields = get_public_data_witness_oracle(block_number, leaf_slot);
PublicDataWitness {
index: fields[0],
leaf_preimage: PublicDataTreeLeafPreimage { slot: fields[1], value: fields[2], next_index: fields[3] as u64, next_slot: fields[4] },
leaf_preimage: PublicDataTreeLeafPreimage { slot: fields[1], value: fields[2], next_index: fields[3] as u32, next_slot: fields[4] },
path: arr_copy_slice(fields, [0; PUBLIC_DATA_TREE_HEIGHT], 1 + LEAF_PREIMAGE_LENGTH)
}
}
10 changes: 5 additions & 5 deletions noir-projects/aztec-nr/aztec/src/oracle/notes.nr
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ unconstrained pub fn get_notes<Note, N, M, S, NS>(
status,
placeholder_fields
);
let num_notes = fields[0] as u64;
let num_notes = fields[0] as u32;
let contract_address = AztecAddress::from_field(fields[1]);
for i in 0..placeholder_opt_notes.len() {
if i < num_notes {
if i as u32 < num_notes {
// lengths named as per typescript.
let return_header_length: u64 = 2; // num_notes & contract_address.
let extra_preimage_length: u64 = 2; // nonce & is_transient.
let read_offset: u64 = return_header_length + i * (N + extra_preimage_length);
let return_header_length: u32 = 2; // num_notes & contract_address.
let extra_preimage_length: u32 = 2; // nonce & is_transient.
let read_offset: u32 = return_header_length + i * (N + extra_preimage_length);
let nonce = fields[read_offset];
let is_transient = fields[read_offset + 1] as bool;
let header = NoteHeader { contract_address, nonce, storage_slot, is_transient };
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
array.len() should return a u64
array.len() should return a u32
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ use dep::types::{
struct PrivateKernelTailCircuitPrivateInputs {
previous_kernel: PrivateKernelInnerData,
sorted_new_note_hashes: [SideEffect; MAX_NEW_NOTE_HASHES_PER_TX],
sorted_new_note_hashes_indexes: [u64; MAX_NEW_NOTE_HASHES_PER_TX],
read_commitment_hints: [u64; MAX_READ_REQUESTS_PER_TX],
sorted_new_note_hashes_indexes: [u32; MAX_NEW_NOTE_HASHES_PER_TX],
read_commitment_hints: [u32; MAX_READ_REQUESTS_PER_TX],
sorted_new_nullifiers: [SideEffectLinkedToNoteHash; MAX_NEW_NULLIFIERS_PER_TX],
sorted_new_nullifiers_indexes: [u64; MAX_NEW_NULLIFIERS_PER_TX],
nullifier_commitment_hints: [u64; MAX_NEW_NULLIFIERS_PER_TX],
sorted_new_nullifiers_indexes: [u32; MAX_NEW_NULLIFIERS_PER_TX],
nullifier_commitment_hints: [u32; MAX_NEW_NULLIFIERS_PER_TX],
master_nullifier_secret_keys: [GrumpkinPrivateKey; MAX_NULLIFIER_KEY_VALIDATION_REQUESTS_PER_TX],
}

Expand Down Expand Up @@ -64,7 +64,7 @@ impl PrivateKernelTailCircuitPrivateInputs {
// match reads to commitments from the previous call(s)
for rr_idx in 0..MAX_READ_REQUESTS_PER_TX {
let read_request = read_requests.get_unchecked(rr_idx);
let read_commitment_hint = self.read_commitment_hints[rr_idx] as u64;
let read_commitment_hint = self.read_commitment_hints[rr_idx] as u32;

if (read_request.value != 0) {
let hash = new_note_hashes.get_unchecked(read_commitment_hint);
Expand All @@ -79,7 +79,7 @@ impl PrivateKernelTailCircuitPrivateInputs {
public_inputs.end.read_requests = BoundedVec::new();
}

fn assert_sorted_counters<T, N>(original: [T; N], sorted: [T; N], indexes: [u64; N]) where T: Eq + Ordered + Empty {
fn assert_sorted_counters<T, N>(original: [T; N], sorted: [T; N], indexes: [u32; N]) where T: Eq + Ordered + Empty {
let mut prev_was_empty = false;

for i in 0..N {
Expand Down Expand Up @@ -126,15 +126,15 @@ impl PrivateKernelTailCircuitPrivateInputs {
let nullifier = new_nullifiers[n_idx];
// TODO - should not be able to squash the first nullifier.
let nullified_note_hash = nullifier.note_hash;
let hint_pos = self.nullifier_commitment_hints[n_idx] as u64;
let hint_pos = self.nullifier_commitment_hints[n_idx] as u32;

// Nullified_commitment of value `0` implies non-transient (persistable)
// nullifier in which case no attempt will be made to match it to a hash.
// Non-empty nullified_note_hash implies transient nullifier which MUST be matched to a hash below!
// 0-valued nullified_note_hash is empty and will be ignored
if nullified_note_hash != 0 {
assert(
hint_pos < MAX_NEW_NOTE_HASHES_PER_TX as u64, "New nullifier is transient but hint is invalid"
hint_pos < MAX_NEW_NOTE_HASHES_PER_TX as u32, "New nullifier is transient but hint is invalid"
);
let hash = new_note_hashes[hint_pos];
assert_eq(nullified_note_hash, hash.value, "Hinted hash does not match");
Expand All @@ -145,7 +145,7 @@ impl PrivateKernelTailCircuitPrivateInputs {
// squash both the nullifier and the hash
// (set to 0 here and then rearrange array after loop)
new_note_hashes[hint_pos] = SideEffect::empty();
new_nullifiers[n_idx as u64] = SideEffectLinkedToNoteHash::empty();
new_nullifiers[n_idx as u32] = SideEffectLinkedToNoteHash::empty();
}
// non-transient (persistable) nullifiers are just kept in new_nullifiers array and forwarded
// to public inputs (used later by base rollup circuit)
Expand Down Expand Up @@ -240,8 +240,8 @@ mod tests {

struct PrivateKernelOrderingInputsBuilder {
previous_kernel: PreviousKernelDataBuilder,
read_commitment_hints: [u64; MAX_READ_REQUESTS_PER_TX],
nullifier_commitment_hints: [u64; MAX_NEW_NULLIFIERS_PER_TX],
read_commitment_hints: [u32; MAX_READ_REQUESTS_PER_TX],
nullifier_commitment_hints: [u32; MAX_NEW_NULLIFIERS_PER_TX],
}

impl PrivateKernelOrderingInputsBuilder {
Expand Down Expand Up @@ -272,32 +272,32 @@ mod tests {
compute_unique_siloed_note_hashes(first_nullifier.value, commitments)
}

pub fn append_transient_commitments(&mut self, num_commitments: u64) {
pub fn append_transient_commitments(&mut self, num_commitments: u32) {
// All new note hashes aggregated in the previous kernel are transient commitments.
self.previous_kernel.append_new_note_hashes(num_commitments);
}

pub fn add_transient_read(&mut self, commitment_index: u64) {
pub fn add_transient_read(&mut self, commitment_index: u32) {
let read_request_index = self.previous_kernel.add_read_request_for_transient_commitment(commitment_index);
self.read_commitment_hints[read_request_index] = commitment_index;
}

pub fn append_nullifiers(&mut self, num_nullifiers: u64) {
pub fn append_nullifiers(&mut self, num_nullifiers: u32) {
self.previous_kernel.append_new_nullifiers_from_private(num_nullifiers);
}

pub fn nullify_transient_commitment(&mut self, nullifier_index: Field, commitment_index: u64) {
pub fn nullify_transient_commitment(&mut self, nullifier_index: Field, commitment_index: u32) {
self.previous_kernel.end.new_nullifiers.storage[nullifier_index].note_hash = self.previous_kernel.end.new_note_hashes.get(commitment_index).value;
self.nullifier_commitment_hints[nullifier_index] = commitment_index;
}

fn sort_sideffects<T, N>(original: [T; N]) -> ([T; N], [u64; N]) where T: Ordered + Eq + Empty {
fn sort_sideffects<T, N>(original: [T; N]) -> ([T; N], [u32; N]) where T: Ordered + Eq + Empty {
let mut indexes = [0; N];
for i in 0..N {
indexes[i] = i;
}
let sorted_indexes = indexes.sort_via(
|a_index: u64, b_index: u64| {
|a_index: u32, b_index: u32| {
let a = original[a_index];
let b = original[b_index];
if is_empty(b) {
Expand All @@ -309,7 +309,7 @@ mod tests {
}
}
);
let sorted_sideffects = sorted_indexes.map(|i: u64| original[i]);
let sorted_sideffects = sorted_indexes.map(|i: u32| original[i]);
let mut reverse_map = [0; N];
for i in 0..N {
reverse_map[sorted_indexes[i]] = i;
Expand Down
Loading

0 comments on commit fa73842

Please sign in to comment.