Skip to content

Commit

Permalink
refactor: removing redundant utilities (AztecProtocol#4532)
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan authored Feb 9, 2024
1 parent 7d5e056 commit 79bf445
Show file tree
Hide file tree
Showing 17 changed files with 198 additions and 181 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
use dep::std::merkle::compute_merkle_root;
use dep::protocol_types::header::Header;

use dep::protocol_types::{
header::Header,
utils::field::{
full_field_less_than,
full_field_greater_than,
},
};
use crate::{
context::PrivateContext,
note::{
utils::compute_siloed_nullifier,
note_interface::NoteInterface,
},
oracle::get_nullifier_membership_witness::get_low_nullifier_membership_witness,
utils::{
full_field_less_than,
full_field_greater_than,
},
};

pub fn _nullifier_non_inclusion(nullifier: Field, header: Header) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use dep::protocol_types::{
constants::GENERATOR_INDEX__PUBLIC_LEAF_INDEX,
header::Header,
hash::pedersen_hash,
address::{
AztecAddress
},
header::Header,
utils::field::full_field_less_than,
};
use dep::std::merkle::compute_merkle_root;

Expand All @@ -13,9 +14,6 @@ use crate::{
oracle::get_public_data_witness::{
get_public_data_witness,
},
utils::{
full_field_less_than,
},
};

fn _public_value_inclusion(
Expand Down
1 change: 0 additions & 1 deletion yarn-project/aztec-nr/aztec/src/lib.nr
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ mod messaging;
mod note;
mod oracle;
mod state_vars;
mod utils;
use dep::protocol_types;
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use crate::messaging::l1_to_l2_message::L1ToL2Message;
use dep::protocol_types::constants::{
L1_TO_L2_MSG_TREE_HEIGHT,
L1_TO_L2_MESSAGE_LENGTH,
use dep::protocol_types::{
constants::{
L1_TO_L2_MSG_TREE_HEIGHT,
L1_TO_L2_MESSAGE_LENGTH,
},
utils::arr_copy_slice,
};
use crate::utils::arr_copy_slice;

struct L1ToL2MessageGetterData {
message: L1ToL2Message,
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec-nr/aztec/src/note/utils.nr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::{
note_header::NoteHeader,
note_interface::NoteInterface,
},
utils::arr_copy_slice,
};

use dep::protocol_types::{
Expand All @@ -15,6 +14,7 @@ use dep::protocol_types::{
GENERATOR_INDEX__SILOED_COMMITMENT,
},
hash::pedersen_hash,
utils::arr_copy_slice,
};

fn compute_siloed_hash(contract_address: AztecAddress, inner_note_hash: Field) -> Field {
Expand Down
12 changes: 7 additions & 5 deletions yarn-project/aztec-nr/aztec/src/oracle/get_membership_witness.nr
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use dep::protocol_types::constants::{
ARCHIVE_HEIGHT,
CONTRACT_TREE_HEIGHT,
NOTE_HASH_TREE_HEIGHT,
use dep::protocol_types::{
constants::{
ARCHIVE_HEIGHT,
CONTRACT_TREE_HEIGHT,
NOTE_HASH_TREE_HEIGHT,
},
utils::arr_copy_slice,
};
use crate::utils::arr_copy_slice;

global CONTRACT_TREE_ID = 0;
global NOTE_HASH_TREE_ID = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use dep::protocol_types::{
},
constants::NULLIFIER_TREE_HEIGHT,
hash::pedersen_hash,
utils::arr_copy_slice,
};
use crate::utils::arr_copy_slice;

// INDEX_LENGTH + NULLIFIER_LEAF_PREIMAGE_LENGTH + NULLIFIER_TREE_HEIGHT
global NULLIFIER_MEMBERSHIP_WITNESS: Field = 24;
Expand Down
30 changes: 6 additions & 24 deletions yarn-project/aztec-nr/aztec/src/oracle/get_public_data_witness.nr
Original file line number Diff line number Diff line change
@@ -1,35 +1,17 @@
use dep::protocol_types::{
constants::PUBLIC_DATA_TREE_HEIGHT,
hash::pedersen_hash,
traits::{Hash, Serialize}
public_data_tree_leaf_preimage::PublicDataTreeLeafPreimage,
traits::{
Hash,
Serialize,
},
utils::arr_copy_slice,
};
use crate::utils::arr_copy_slice;

global LEAF_PREIMAGE_LENGTH: Field = 4;
// TODO: move this to constants_gen.nr so that it gets computed as INDEX_LENGTH + LEAF_DATA_LENGTH + PUBLIC_DATA_TREE_HEIGHT
global PUBLIC_DATA_WITNESS: Field = 45;

// TODO(#3470) replace with /mnt/user-data/jan/aztec-packages/yarn-project/noir-protocol-circuits/src/crates/rollup-lib/src/abis/public_data_tree_leaf.nr
struct PublicDataTreeLeafPreimage {
slot : Field,
value: Field,
next_index : u32,
next_slot :Field,
}

impl Serialize<LEAF_PREIMAGE_LENGTH> for PublicDataTreeLeafPreimage {
fn serialize(self) -> [Field; LEAF_PREIMAGE_LENGTH] {
[self.slot, self.value, self.next_index as Field, self.next_slot]
}
}

impl Hash for PublicDataTreeLeafPreimage {
fn hash(self) -> Field {
// Performs the same hashing as StandardIndexedTree::encodeLeaf(...)
pedersen_hash(self.serialize(), 0)
}
}

struct PublicDataWitness {
index: Field,
leaf_preimage: PublicDataTreeLeafPreimage,
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec-nr/aztec/src/oracle/notes.nr
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use crate::note::{
note_header::NoteHeader,
note_interface::NoteInterface,
};
use crate::utils::arr_copy_slice;

use dep::protocol_types::{
address::AztecAddress,
utils::arr_copy_slice,
};

#[oracle(notifyCreatedNote)]
Expand Down
18 changes: 0 additions & 18 deletions yarn-project/aztec-nr/aztec/src/utils.nr

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
mod public_data_tree_leaf;
mod constant_rollup_data;
mod base_or_merge_rollup_public_inputs;
mod previous_rollup_data;
Loading

0 comments on commit 79bf445

Please sign in to comment.