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 warnings from types and rollup lib crates #11269

Merged
merged 2 commits into from
Jan 16, 2025
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 @@ -5,7 +5,7 @@ use dep::types::{
AZTEC_MAX_EPOCH_DURATION, BLOCK_ROOT_OR_BLOCK_MERGE_PUBLIC_INPUTS_LENGTH,
FEE_RECIPIENT_LENGTH,
},
traits::{Deserialize, Empty, Serialize},
traits::{Deserialize, Empty, Serialize, ToField},
utils::reader::Reader,
};
use blob::blob_public_inputs::BlockBlobPublicInputs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use dep::types::{
rollup_recursive_proof::NestedRecursiveProof,
verification_key::{RollupHonkVerificationKey, VerificationKey},
},
traits::Empty,
traits::{Empty, Serialize},
utils::arrays::find_index_hint,
};

Expand All @@ -18,7 +18,7 @@ pub struct PreviousRollupBlockData {
}

impl PreviousRollupBlockData {
fn verify(self, proof_type_id: u32) {
pub fn verify(self, proof_type_id: u32) {
let inputs = BlockRootOrBlockMergePublicInputs::serialize(
self.block_root_or_block_merge_public_inputs,
);
Expand Down Expand Up @@ -48,6 +48,7 @@ impl PreviousRollupBlockData {
self.vk.check_hash();

let leaf_index = self.vk_witness.leaf_index as u32;
/// Safety: This is a hint which is constrained by the asserts below.
let index_hint =
unsafe { find_index_hint(allowed_indices, |index: u32| index == leaf_index) };
assert(index_hint < N, "Invalid vk index");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use dep::types::{
traits::Verifiable,
verification_key::{RollupHonkVerificationKey, VerificationKey},
},
traits::Empty,
traits::{Empty, Serialize},
utils::arrays::find_index_hint,
};

Expand Down Expand Up @@ -48,6 +48,7 @@ impl PreviousRollupData {
self.vk.check_hash();

let leaf_index = self.vk_witness.leaf_index as u32;
/// Safety: This is a hint which is constrained by the asserts below.
let index_hint =
unsafe { find_index_hint(allowed_indices, |index: u32| index == leaf_index) };
assert(index_hint < N, "Invalid vk index");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use types::{
block_header::BlockHeader,
constants::ARCHIVE_HEIGHT,
merkle_tree::membership::{assert_check_membership, MembershipWitness},
traits::Hash,
};

// Check that the block header used is a member of the blocks tree --> since the block header
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub fn compute_transaction_fee(

mod tests {
use super::compute_transaction_fee;
use types::abis::{gas::Gas, gas_fees::GasFees, gas_settings::GasSettings};
use types::{abis::{gas::Gas, gas_fees::GasFees, gas_settings::GasSettings}, traits::Empty};

struct TestBuilder {
gas_fees: GasFees,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use super::validate_tube_data::validate_max_fees_per_gas;
use dep::types::abis::{constant_rollup_data::ConstantRollupData, tube::PrivateTubeData};
use dep::types::{
abis::{constant_rollup_data::ConstantRollupData, tube::PrivateTubeData},
proof::traits::Verifiable,
};

pub struct PrivateTubeDataValidator {
pub data: PrivateTubeData,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use super::validate_tube_data::validate_max_fees_per_gas;
use dep::types::abis::{constant_rollup_data::ConstantRollupData, tube::PublicTubeData};
use dep::types::{
abis::{constant_rollup_data::ConstantRollupData, tube::PublicTubeData},
proof::traits::Verifiable,
};

pub struct PublicTubeDataValidator {
pub data: PublicTubeData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use dep::types::{
},
messaging::l2_to_l1_message::ScopedL2ToL1Message,
partial_state_reference::PartialStateReference,
traits::{Empty, Hash},
};

global ALLOWED_PREVIOUS_CIRCUITS: [u32; 1] = [TUBE_VK_INDEX];
Expand Down Expand Up @@ -231,7 +232,7 @@ mod tests {
constant_rollup_data::ConstantRollupData, gas::Gas, gas_fees::GasFees,
kernel_circuit_public_inputs::PrivateToRollupKernelCircuitPublicInputs,
nullifier_leaf_preimage::NullifierLeafPreimage, public_data_write::PublicDataWrite,
sponge_blob::SpongeBlob,
side_effect::OrderedValue, sponge_blob::SpongeBlob,
},
address::{AztecAddress, EthAddress},
constants::{
Expand All @@ -254,7 +255,7 @@ mod tests {
fixtures::{self, merkle_tree::generate_full_sha_tree},
merkle_tree_utils::NonEmptyMerkleTree,
},
traits::{Empty, is_empty},
traits::{Empty, FromField, Hash, is_empty},
utils::{
arrays::{array_concat, get_sorted_tuple::get_sorted_tuple},
field::{field_from_bytes, full_field_less_than},
Expand Down Expand Up @@ -429,6 +430,7 @@ mod tests {
let mut low_nullifier_membership_witness =
[MembershipWitness::empty(); MAX_NULLIFIERS_PER_TX];

/// Safety: This is a mock for testing only
let sorted_new_nullifier_tuples = unsafe {
get_sorted_tuple(
self.nullifiers.storage().map(|insertion: NullifierInsertion| insertion.value),
Expand Down Expand Up @@ -604,6 +606,7 @@ mod tests {
}

fn execute(self) -> BaseOrMergeRollupPublicInputs {
/// Safety: This is a mock for testing only
let inputs = unsafe { self.build_inputs() };
inputs.execute()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use dep::types::{
},
messaging::l2_to_l1_message::ScopedL2ToL1Message,
partial_state_reference::PartialStateReference,
traits::is_empty,
traits::{Hash, is_empty},
utils::arrays::array_merge,
};

Expand Down Expand Up @@ -285,11 +285,10 @@ mod tests {
use crate::abis::tx_effect::TxEffect;
use dep::types::{
abis::{
accumulated_data::PrivateToRollupAccumulatedData,
append_only_tree_snapshot::AppendOnlyTreeSnapshot,
constant_rollup_data::ConstantRollupData,
nullifier_leaf_preimage::NullifierLeafPreimage, public_data_write::PublicDataWrite,
sponge_blob::SpongeBlob,
side_effect::OrderedValue, sponge_blob::SpongeBlob,
},
address::EthAddress,
constants::{
Expand All @@ -304,7 +303,7 @@ mod tests {
},
data::{PublicDataTreeLeaf, PublicDataTreeLeafPreimage},
hash::silo_l2_to_l1_message,
merkle_tree::MembershipWitness,
merkle_tree::{leaf_preimage::LeafPreimage, MembershipWitness},
messaging::l2_to_l1_message::ScopedL2ToL1Message,
partial_state_reference::PartialStateReference,
tests::{
Expand All @@ -313,7 +312,7 @@ mod tests {
merkle_tree_utils::NonEmptyMerkleTree,
utils::pad_end,
},
traits::{Empty, is_empty},
traits::{Empty, Hash, is_empty},
utils::{
arrays::{array_concat, get_sorted_tuple::get_sorted_tuple},
field::{field_from_bytes, full_field_less_than},
Expand Down Expand Up @@ -476,6 +475,7 @@ mod tests {
let mut low_nullifier_membership_witness =
[MembershipWitness::empty(); MAX_NULLIFIERS_PER_TX];

/// Safety: This is a mock for testing only
let sorted_new_nullifier_tuples = unsafe {
get_sorted_tuple(
self.nullifiers.storage().map(|insertion: NullifierInsertion| insertion.value),
Expand Down Expand Up @@ -702,6 +702,7 @@ mod tests {
}

fn execute(self) -> BaseOrMergeRollupPublicInputs {
/// Safety: This is a mock for testing only
let inputs = unsafe { self.build_inputs() };
inputs.execute()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ pub(crate) mod tests {
},
hash::accumulate_sha256,
tests::{merkle_tree_utils::compute_zero_hashes, utils::assert_array_eq},
traits::Empty,
utils::arrays::array_concat,
};

Expand Down Expand Up @@ -156,6 +157,7 @@ pub(crate) mod tests {
}

pub fn mock_evaluate_blobs(self) -> Self {
/// Safety: This is a mock for testing only
unsafe {
let _ = OracleMock::mock("evaluateBlobs").returns(BlockBlobPublicInputs::empty());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
merge::utils::validate_consecutive_rollups::validate_consecutive_rollups,
};
use parity_lib::root::root_rollup_parity_input::RootRollupParityInput;
use types::abis::sponge_blob::SpongeBlob;
use types::{abis::sponge_blob::SpongeBlob, proof::traits::Verifiable};

pub struct BlockRootRollupInputsValidator<let NUM_ROLLUPS: u32, let N: u32> {
previous_rollups: [PreviousRollupData; NUM_ROLLUPS],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use types::{
merkle_tree::{append_only_tree, calculate_empty_tree_root},
partial_state_reference::PartialStateReference,
state_reference::StateReference,
traits::{Empty, Hash},
};

pub struct BlockRootRollupOutputComposer {
Expand Down Expand Up @@ -188,7 +189,7 @@ impl BlockRootRollupOutputComposer {
self.merged_rollup.end_sponge_blob,
);
} else {
// TODO(#10323): this was added to save simulation time, if/when simulation times of unconstrained are improved, remove this.
/// Safety: TODO(#10323): this was added to save simulation time, if/when simulation times of unconstrained are improved, remove this.
blob_public_inputs[0] = unsafe {
blob::mock_blob_oracle::evaluate_blobs(
self.data.blobs_fields,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use types::{
ARCHIVE_HEIGHT, BLOBS_PER_BLOCK, FIELDS_PER_BLOB, L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH,
},
partial_state_reference::PartialStateReference,
traits::Empty,
};

pub global EMPTY_BLOBS_HASH: Field =
Expand Down Expand Up @@ -101,6 +102,7 @@ mod tests {
},
partial_state_reference::PartialStateReference,
tests::{merkle_tree_utils::compute_zero_hashes, utils::assert_array_eq},
traits::Empty,
};

fn compute_l1_l2_empty_snapshot() -> (AppendOnlyTreeSnapshot, [Field; L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use dep::types::{
},
hash::{accumulate_sha256, silo_unencrypted_log_hash},
merkle_tree::VariableMerkleTree,
traits::is_empty,
traits::{Empty, is_empty},
utils::arrays::{array_length, array_merge},
};
use blob::blob_public_inputs::BlockBlobPublicInputs;
Expand Down Expand Up @@ -208,6 +208,7 @@ fn get_tx_effects_hash_input(
silo_unencrypted_log_hash(log)
});

/// Safety: This constructs the array of effects and is constrained below.
let mut tx_effects_hash_input = unsafe {
get_tx_effects_hash_input_helper(
tx_effect.tx_hash,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::merge::utils::{
};
use dep::types::{
constants::{MERGE_ROLLUP_INDEX, PRIVATE_BASE_ROLLUP_VK_INDEX, PUBLIC_BASE_ROLLUP_VK_INDEX},
proof::traits::Verifiable,
traits::Empty,
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::block_merge::BlockMergeRollupInputs;
use crate::tests::previous_rollup_block_data::default_previous_rollup_block_data;
use dep::types::traits::Empty;

pub fn default_block_merge_rollup_inputs() -> BlockMergeRollupInputs {
let mut inputs = BlockMergeRollupInputs::empty();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use dep::parity_lib::root::root_rollup_parity_input::RootRollupParityInput;
use dep::types::constants::ROOT_PARITY_INDEX;
use dep::types::tests::fixtures;
use dep::types::traits::Empty;
use types::merkle_tree::merkle_tree::MerkleTree;

pub fn default_root_rollup_parity_input() -> RootRollupParityInput {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::merge::MergeRollupInputs;
use crate::tests::previous_rollup_data::default_previous_rollup_data;
use dep::types::traits::Empty;

pub fn default_merge_rollup_inputs() -> MergeRollupInputs {
let mut inputs = MergeRollupInputs::empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use dep::types::abis::append_only_tree_snapshot::AppendOnlyTreeSnapshot;
use dep::types::constants::BLOCK_ROOT_ROLLUP_INDEX;
use dep::types::merkle_tree::MembershipWitness;
use dep::types::tests::fixtures;
use dep::types::traits::Empty;
use types::merkle_tree::merkle_tree::MerkleTree;

pub fn default_previous_rollup_block_data() -> [PreviousRollupBlockData; 2] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use dep::types::abis::append_only_tree_snapshot::AppendOnlyTreeSnapshot;
use dep::types::constants::PUBLIC_BASE_ROLLUP_VK_INDEX;
use dep::types::merkle_tree::MembershipWitness;
use dep::types::tests::fixtures;
use dep::types::traits::Empty;
use types::abis::sponge_blob::SpongeBlob;
use types::merkle_tree::merkle_tree::MerkleTree;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::root::root_rollup_inputs::RootRollupInputs;
use crate::tests::previous_rollup_block_data::default_previous_rollup_block_data;
use dep::types::traits::Empty;

pub fn default_root_rollup_inputs() -> RootRollupInputs {
let mut inputs = RootRollupInputs::empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::{
MAX_ENQUEUED_CALLS_PER_TX,
},
proof::{avm_proof::AvmProof, traits::Verifiable, vk_data::VkData},
traits::{Deserialize, Empty, Serialize},
traits::{Deserialize, Empty, FromField, Serialize, ToField},
utils::reader::Reader,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
abis::function_selector::FunctionSelector,
address::AztecAddress,
constants::CALL_CONTEXT_LENGTH,
traits::{Deserialize, Empty, Serialize},
traits::{Deserialize, Empty, FromField, Serialize, ToField},
utils::reader::Reader,
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::abis::function_selector::FunctionSelector;
use crate::constants::GENERATOR_INDEX__FUNCTION_LEAF;
use crate::hash::poseidon2_hash_with_separator;
use crate::traits::Hash;
use crate::traits::{Hash, ToField};

pub struct ContractClassFunctionLeafPreimage {
pub selector: FunctionSelector,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
abis::function_selector::FunctionSelector,
constants::FUNCTION_DATA_LENGTH,
traits::{Deserialize, Empty, Serialize},
traits::{Deserialize, Empty, FromField, Serialize, ToField},
};

pub struct FunctionData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
abis::gas_fees::GasFees,
address::{AztecAddress, EthAddress},
constants::GLOBAL_VARIABLES_LENGTH,
traits::{Deserialize, Empty, Serialize},
traits::{Deserialize, Empty, FromField, Serialize, ToField},
utils::reader::Reader,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
abis::side_effect::{Ordered, OrderedValue, Scoped},
address::AztecAddress,
constants::{LOG_HASH_LENGTH, SCOPED_LOG_HASH_LENGTH},
traits::{Deserialize, Empty, Serialize},
traits::{Deserialize, Empty, Serialize, ToField},
utils::{arrays::array_concat, reader::Reader},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
abis::{read_request::ScopedReadRequest, side_effect::{Ordered, OrderedValue, Readable, Scoped}},
address::AztecAddress,
constants::{NOTE_HASH_LENGTH, SCOPED_NOTE_HASH_LENGTH},
traits::{Deserialize, Empty, Serialize},
traits::{Deserialize, Empty, Serialize, ToField},
utils::{arrays::array_concat, reader::Reader},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ global NOTE_HASH_LEAF_PREIMAGE_LENGTH: u32 = 1;

use crate::{
abis::{read_request::ScopedReadRequest, side_effect::Readable},
hash::compute_siloed_note_hash,
merkle_tree::leaf_preimage::LeafPreimage,
traits::Empty,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
address::AztecAddress,
constants::{NULLIFIER_LENGTH, SCOPED_NULLIFIER_LENGTH},
hash::compute_siloed_nullifier,
traits::{Deserialize, Empty, Serialize},
traits::{Deserialize, Empty, Serialize, ToField},
utils::{arrays::array_concat, reader::Reader},
};

Expand Down
Loading
Loading