Skip to content

Commit

Permalink
chore: add some pub use and remove unused imports (#8521)
Browse files Browse the repository at this point in the history
Fixes all of the "unused ..." warnings.
  • Loading branch information
asterite authored Sep 12, 2024
1 parent 00146fa commit 8bd0755
Show file tree
Hide file tree
Showing 62 changed files with 102 additions and 164 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use dep::protocol_types::{

use crate::context::{
private_context::PrivateContext, public_context::PublicContext, gas::GasOpts,
public_context::FunctionReturns, inputs::{PrivateContextInputs, PublicContextInputs}
inputs::{PrivateContextInputs, PublicContextInputs}
};

use crate::oracle::arguments::pack_arguments;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// protocl global vars are equal to the private ones so we just re-export them here under a different name
use dep::protocol_types::abis::global_variables::GlobalVariables as PublicGlobalVariables;
pub use dep::protocol_types::abis::global_variables::GlobalVariables as PublicGlobalVariables;
4 changes: 2 additions & 2 deletions noir-projects/aztec-nr/aztec/src/context/inputs/mod.nr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mod private_context_inputs;
mod public_context_inputs;

use crate::context::inputs::private_context_inputs::PrivateContextInputs;
use crate::context::inputs::public_context_inputs::PublicContextInputs;
pub use crate::context::inputs::private_context_inputs::PrivateContextInputs;
pub use crate::context::inputs::public_context_inputs::PublicContextInputs;
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use dep::protocol_types::{
transaction::tx_context::TxContext, abis::{call_context::CallContext, gas_settings::GasSettings},
header::Header, traits::Empty
};
use dep::protocol_types::{transaction::tx_context::TxContext, abis::{call_context::CallContext}, header::Header, traits::Empty};

// PrivateContextInputs are expected to be provided to each private function
// docs:start:private-context-inputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use dep::protocol_types::{
max_block_number::MaxBlockNumber,
validation_requests::{KeyValidationRequest, KeyValidationRequestAndGenerator},
private_call_request::PrivateCallRequest, private_circuit_public_inputs::PrivateCircuitPublicInputs,
public_call_request::PublicCallRequest, public_call_stack_item::PublicCallStackItem,
public_call_request::PublicCallRequest,
public_call_stack_item_compressed::PublicCallStackItemCompressed, read_request::ReadRequest,
note_hash::NoteHash, nullifier::Nullifier, log_hash::{LogHash, NoteLogHash, EncryptedLogHash}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
use dep::protocol_types::{address::AztecAddress, traits::Deserialize};
use crate::oracle::{
execution::{get_chain_id, get_version, get_contract_address, get_block_number},
storage::{raw_storage_read, storage_read}
};
use crate::oracle::{execution::{get_chain_id, get_version, get_contract_address, get_block_number}, storage::storage_read};

struct UnconstrainedContext {
block_number: u32,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ use crate::{
keys::{getters::get_current_public_keys, public_keys::{OvpkM, IvpkM}},
encrypted_logs::payload::compute_encrypted_note_log, oracle::logs_traits::LensForEncryptedLog
};
use dep::protocol_types::{
hash::sha256_to_field, address::AztecAddress, point::Point, abis::note_hash::NoteHash,
constants::MAX_NOTE_HASHES_PER_CALL
};
use dep::protocol_types::{hash::sha256_to_field, address::AztecAddress, abis::note_hash::NoteHash};

unconstrained fn compute_unconstrained<Note, let N: u32, let NB: u32, let M: u32>(
contract_address: AztecAddress,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::note::note_interface::NoteInterface;
use crate::event::event_interface::EventInterface;
use dep::protocol_types::{scalar::Scalar, point::Point};
use dep::protocol_types::{scalar::Scalar};

use std::aes128::aes128_encrypt;
use crate::keys::{point_to_symmetric_key::point_to_symmetric_key, public_keys::IvpkM};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,9 @@ impl EncryptedLogOutgoingBody {

mod test {
use crate::{encrypted_logs::outgoing_body::EncryptedLogOutgoingBody, keys::public_keys::IvpkM};
use dep::protocol_types::{
address::AztecAddress, traits::Empty, constants::GENERATOR_INDEX__NOTE_NULLIFIER,
scalar::Scalar, point::Point, hash::poseidon2_hash_with_separator
};
use dep::protocol_types::{address::AztecAddress, scalar::Scalar};
use std::embedded_curve_ops::fixed_base_scalar_mul as derive_public_key;

use crate::context::PrivateContext;

#[test]
fn test_encrypted_log_outgoing_body_matches_typescript() {
let eph_sk = Scalar {
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/aztec/src/history/public_storage.nr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use dep::protocol_types::{
};
use dep::protocol_types::merkle_tree::root::root_from_sibling_path;

use crate::{context::PrivateContext, oracle::get_public_data_witness::get_public_data_witness};
use crate::{oracle::get_public_data_witness::get_public_data_witness};

trait PublicStorageHistoricalRead {
fn public_storage_historical_read(header: Header, storage_slot: Field, contract_address: AztecAddress) -> Field;
Expand Down
15 changes: 4 additions & 11 deletions noir-projects/aztec-nr/aztec/src/keys/getters/mod.nr
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
use dep::protocol_types::{
header::Header, abis::validation_requests::KeyValidationRequest, address::AztecAddress,
constants::CANONICAL_KEY_REGISTRY_ADDRESS, point::Point, storage::map::derive_storage_slot_in_map,
traits::is_empty
header::Header, address::AztecAddress, constants::CANONICAL_KEY_REGISTRY_ADDRESS,
storage::map::derive_storage_slot_in_map
};
use crate::{
context::{PrivateContext, UnconstrainedContext},
oracle::{keys::get_public_keys_and_partial_address, key_validation_request::get_key_validation_request},
keys::{
public_keys::{PublicKeys, PUBLIC_KEYS_LENGTH}, stored_keys::StoredKeys,
constants::{NULLIFIER_INDEX, INCOMING_INDEX, OUTGOING_INDEX, TAGGING_INDEX}
},
state_vars::{
shared_mutable::shared_mutable_private_getter::SharedMutablePrivateGetter,
public_mutable::PublicMutable, map::Map
}
keys::{public_keys::{PublicKeys, PUBLIC_KEYS_LENGTH}, stored_keys::StoredKeys, constants::NULLIFIER_INDEX},
state_vars::{public_mutable::PublicMutable, map::Map}
};

mod test;
Expand Down
1 change: 0 additions & 1 deletion noir-projects/aztec-nr/aztec/src/keys/getters/test.nr
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::keys::getters::{get_current_public_keys, get_historical_public_keys, KEY_REGISTRY_UPDATE_BLOCKS};
use crate::context::PrivateContext;
use dep::protocol_types::address::AztecAddress;

use crate::test::helpers::{cheatcodes, test_environment::TestEnvironment, utils::TestAccount};
use dep::std::test::OracleMock;
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/aztec/src/keys/mod.nr
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ mod point_to_symmetric_key;
mod public_keys;
mod stored_keys;

use crate::keys::public_keys::{PublicKeys, PUBLIC_KEYS_LENGTH};
pub use crate::keys::public_keys::{PublicKeys, PUBLIC_KEYS_LENGTH};
1 change: 0 additions & 1 deletion noir-projects/aztec-nr/aztec/src/keys/public_keys.nr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use dep::protocol_types::{
hash::poseidon2_hash_with_separator, point::{Point, POINT_LENGTH},
traits::{Deserialize, Serialize, Empty, is_empty, Hash}
};
use crate::keys::constants::{NULLIFIER_INDEX, INCOMING_INDEX, OUTGOING_INDEX};

global PUBLIC_KEYS_LENGTH: u32 = 12;

Expand Down
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/aztec/src/lib.nr
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mod state_vars;
mod prelude;
mod encrypted_logs;
mod unencrypted_logs;
use dep::protocol_types;
pub use dep::protocol_types;
mod utils;

mod test;
4 changes: 3 additions & 1 deletion noir-projects/aztec-nr/aztec/src/note/note_getter/mod.nr
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
use dep::protocol_types::{constants::{MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, GET_NOTES_ORACLE_RETURN_LENGTH}};
use crate::context::PrivateContext;
use crate::note::{
constants::{GET_NOTE_ORACLE_RETURN_LENGTH, MAX_NOTES_PER_PAGE, VIEW_NOTE_ORACLE_RETURN_LENGTH},
constants::{GET_NOTE_ORACLE_RETURN_LENGTH, VIEW_NOTE_ORACLE_RETURN_LENGTH},
note_getter_options::{NoteGetterOptions, Select, Sort, SortOrder, NoteStatus, PropertySelector},
note_interface::NoteInterface, note_viewer_options::NoteViewerOptions,
utils::compute_note_hash_for_read_request
};
use crate::oracle;
use crate::utils::comparison::compare;

pub use crate::note::constants::MAX_NOTES_PER_PAGE;

mod test;

fn extract_property_value_from_selector<let N: u32>(
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/aztec/src/note/note_header.nr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use dep::protocol_types::{address::AztecAddress, traits::{Empty, Eq, Serialize}};
use dep::protocol_types::{address::AztecAddress, traits::{Empty, Serialize}};

global NOTE_HEADER_LENGTH: Field = 4;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use dep::protocol_types::{
address::AztecAddress, contract_instance::ContractInstance, utils::arr_copy_slice,
constants::CONTRACT_INSTANCE_LENGTH, utils::reader::Reader
address::AztecAddress, contract_instance::ContractInstance, constants::CONTRACT_INSTANCE_LENGTH,
utils::reader::Reader
};

#[oracle(getContractInstance)]
Expand Down
14 changes: 6 additions & 8 deletions noir-projects/aztec-nr/aztec/src/oracle/get_sibling_path.nr
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
use dep::protocol_types::constants::PUBLIC_DATA_TREE_HEIGHT;

#[oracle(getSiblingPath)]
unconstrained fn get_sibling_path_oracle<let N: u32>(_block_number: u32, _tree_id: Field, _leaf_index: Field) -> [Field; N] {}
unconstrained fn get_sibling_path_oracle<let N: u32>(
_block_number: u32,
_tree_id: Field,
_leaf_index: Field
) -> [Field; N] {}

unconstrained pub fn get_sibling_path<let N: u32>(
block_number: u32,
tree_id: Field,
leaf_index: Field
) -> [Field; N] {
unconstrained pub fn get_sibling_path<let N: u32>(block_number: u32, tree_id: Field, leaf_index: Field) -> [Field; N] {
let value: [Field; N] = get_sibling_path_oracle(block_number, tree_id, leaf_index);
value
}
18 changes: 9 additions & 9 deletions noir-projects/aztec-nr/aztec/src/state_vars/mod.nr
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ mod shared_immutable;
mod shared_mutable;
mod storage;

use crate::state_vars::map::Map;
use crate::state_vars::private_immutable::PrivateImmutable;
use crate::state_vars::private_mutable::PrivateMutable;
use crate::state_vars::public_immutable::PublicImmutable;
use crate::state_vars::public_mutable::PublicMutable;
use crate::state_vars::private_set::PrivateSet;
use crate::state_vars::shared_immutable::SharedImmutable;
use crate::state_vars::shared_mutable::SharedMutable;
use crate::state_vars::storage::Storage;
pub use crate::state_vars::map::Map;
pub use crate::state_vars::private_immutable::PrivateImmutable;
pub use crate::state_vars::private_mutable::PrivateMutable;
pub use crate::state_vars::public_immutable::PublicImmutable;
pub use crate::state_vars::public_mutable::PublicMutable;
pub use crate::state_vars::private_set::PrivateSet;
pub use crate::state_vars::shared_immutable::SharedImmutable;
pub use crate::state_vars::shared_mutable::SharedMutable;
pub use crate::state_vars::storage::Storage;
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use dep::protocol_types::{
address::AztecAddress, constants::GENERATOR_INDEX__INITIALIZATION_NULLIFIER,
hash::poseidon2_hash_with_separator
};
use dep::protocol_types::{constants::GENERATOR_INDEX__INITIALIZATION_NULLIFIER, hash::poseidon2_hash_with_separator};

use crate::context::{PrivateContext, UnconstrainedContext};
use crate::note::{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use dep::protocol_types::{address::AztecAddress, point::Point};
use crate::{
context::PrivateContext, state_vars::private_mutable::PrivateMutable,
oracle::execution::get_contract_address
};
use crate::test::{mocks::mock_note::MockNote, helpers::{cheatcodes, test_environment::TestEnvironment}};
use crate::test::{mocks::mock_note::MockNote, helpers::{test_environment::TestEnvironment}};
use std::test::OracleMock;

global storage_slot = 17;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::context::{PublicContext, UnconstrainedContext};
use crate::oracle::storage::storage_read;
use dep::protocol_types::traits::{Deserialize, Serialize};
use crate::state_vars::storage::Storage;

Expand Down
4 changes: 2 additions & 2 deletions noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable.nr
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ mod scheduled_delay_change;
mod scheduled_value_change;
mod shared_mutable_private_getter;

use shared_mutable::SharedMutable;
use shared_mutable_private_getter::SharedMutablePrivateGetter;
pub use shared_mutable::SharedMutable;
pub use shared_mutable_private_getter::SharedMutablePrivateGetter;
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use crate::{
test::helpers::test_environment::TestEnvironment
};

use dep::protocol_types::address::AztecAddress;
use dep::std::{test::OracleMock, mem::zeroed};

global new_value = 17;
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/aztec/src/test/helpers/keys.nr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use dep::protocol_types::{
address::AztecAddress, storage::map::derive_storage_slot_in_map,
constants::CANONICAL_KEY_REGISTRY_ADDRESS, point::Point
constants::CANONICAL_KEY_REGISTRY_ADDRESS
};

use crate::{test::helpers::cheatcodes, keys::public_keys::ToPoint};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
use dep::protocol_types::{
abis::{function_selector::FunctionSelector, private_circuit_public_inputs::PrivateCircuitPublicInputs},
address::{AztecAddress, PartialAddress}, storage::map::derive_storage_slot_in_map,
constants::CANONICAL_KEY_REGISTRY_ADDRESS, traits::Deserialize
address::AztecAddress, traits::Deserialize
};

use crate::context::inputs::{PublicContextInputs, PrivateContextInputs};
use crate::context::{packed_returns::PackedReturns, call_interfaces::CallInterface};

use crate::context::{PrivateContext, PublicContext, UnconstrainedContext, PrivateVoidCallInterface};
use crate::test::helpers::{cheatcodes, utils::{apply_side_effects_private, Deployer, TestAccount}, keys};
use crate::context::{PrivateContext, PublicContext, UnconstrainedContext};
use crate::test::helpers::{cheatcodes, utils::{apply_side_effects_private, Deployer}, keys};
use crate::keys::constants::{NULLIFIER_INDEX, INCOMING_INDEX, OUTGOING_INDEX, TAGGING_INDEX};
use crate::hash::{hash_args, hash_args_array};
use crate::hash::hash_args;

use crate::note::{note_header::NoteHeader, note_interface::NoteInterface};
use crate::oracle::{execution::{get_block_number, get_contract_address}, notes::notify_created_note};
Expand Down
5 changes: 2 additions & 3 deletions noir-projects/aztec-nr/aztec/src/test/helpers/utils.nr
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
use dep::protocol_types::{
traits::{Deserialize, Serialize}, address::AztecAddress,
abis::{function_selector::FunctionSelector, private_circuit_public_inputs::PrivateCircuitPublicInputs},
abis::{private_circuit_public_inputs::PrivateCircuitPublicInputs},
contract_instance::ContractInstance
};

use crate::context::inputs::{PublicContextInputs, PrivateContextInputs};
use crate::context::call_interfaces::CallInterface;
use crate::test::helpers::cheatcodes;
use crate::keys::public_keys::{PUBLIC_KEYS_LENGTH, PublicKeys};
use crate::hash::hash_args;

use crate::oracle::{execution::{get_block_number, get_contract_address}, notes::notify_nullified_note};
use crate::oracle::{execution::{get_block_number, get_contract_address}};

pub fn apply_side_effects_private(contract_address: AztecAddress, public_inputs: PrivateCircuitPublicInputs) {
let mut nullifiers = &[];
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/aztec/src/test/mocks/mock_note.nr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
note::{note_header::NoteHeader, note_interface::NoteInterface, utils::compute_note_hash_for_nullify}
};

use dep::protocol_types::{address::AztecAddress, constants::GENERATOR_INDEX__NOTE_NULLIFIER, point::Point, traits::Eq};
use dep::protocol_types::{address::AztecAddress, constants::GENERATOR_INDEX__NOTE_NULLIFIER, point::Point};
use dep::std::{embedded_curve_ops::multi_scalar_mul, hash::from_field_unsafe};

global MOCK_NOTE_LENGTH = 1;
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/aztec/src/test/mocks/mock_struct.nr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use dep::protocol_types::traits::{Eq, Serialize, Deserialize};
use dep::protocol_types::traits::{Serialize, Deserialize};

struct MockStruct {
a: Field,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
use crate::{
context::{PrivateContext, PublicContext}, event::event_interface::EventInterface,
encrypted_logs::payload::compute_encrypted_event_log, oracle::logs_traits::LensForEncryptedEvent
};
use dep::protocol_types::{address::AztecAddress, traits::Serialize};
use crate::{context::PublicContext, event::event_interface::EventInterface};
use dep::protocol_types::{traits::Serialize};

fn emit<Event, let NB: u32, let MB: u32, let N: u32, let M: u32>(
context: &mut PublicContext,
Expand Down
4 changes: 1 addition & 3 deletions noir-projects/aztec-nr/aztec/src/utils/collapse_array.nr
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use dep::protocol_types::traits::Eq;

// Collapses an array of Options with sparse Some values into a BoundedVec, essentially unwrapping the Options and
// removing the None values. For example, given:
// input: [some(3), none(), some(1)]
Expand All @@ -18,7 +16,7 @@ pub fn collapse_array<T, let N: u32>(input: [Option<T>; N]) -> BoundedVec<T, N>
collapsed
}

fn verify_collapse_hints<T, let N: u32>(
pub(crate) fn verify_collapse_hints<T, let N: u32>(
input: [Option<T>; N],
collapsed: BoundedVec<T, N>,
collapsed_to_input_index_mapping: BoundedVec<u32, N>
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/aztec/src/utils/mod.nr
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ mod comparison;
mod point;
mod test;

use crate::utils::collapse_array::collapse_array;
pub use crate::utils::collapse_array::collapse_array;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use dep::aztec::protocol_types::{utils::field::field_from_bytes, traits::{Eq, Serialize, Deserialize}};
use dep::aztec::protocol_types::{utils::field::field_from_bytes, traits::{Serialize, Deserialize}};

// The general Compressed String.
// Compresses M bytes into N fields.
Expand Down
4 changes: 2 additions & 2 deletions noir-projects/aztec-nr/compressed-string/src/lib.nr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mod compressed_string;
mod field_compressed_string;

use crate::compressed_string::CompressedString;
use crate::field_compressed_string::FieldCompressedString;
pub use crate::compressed_string::CompressedString;
pub use crate::field_compressed_string::FieldCompressedString;
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/easy-private-state/src/lib.nr
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
mod easy_private_uint;

use crate::easy_private_uint::EasyPrivateUint;
pub use crate::easy_private_uint::EasyPrivateUint;
10 changes: 5 additions & 5 deletions noir-projects/aztec-nr/value-note/src/balance_utils.nr
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use dep::aztec::{
context::UnconstrainedContext, state_vars::PrivateSet,
note::{note_getter::view_notes, note_viewer_options::NoteViewerOptions}
};
use dep::aztec::{context::UnconstrainedContext, state_vars::PrivateSet, note::{note_viewer_options::NoteViewerOptions}};
use crate::value_note::ValueNote;

unconstrained pub fn get_balance(set: PrivateSet<ValueNote, UnconstrainedContext>) -> Field {
get_balance_with_offset(set, 0)
}

unconstrained pub fn get_balance_with_offset(set: PrivateSet<ValueNote, UnconstrainedContext>, offset: u32) -> Field {
unconstrained pub fn get_balance_with_offset(
set: PrivateSet<ValueNote, UnconstrainedContext>,
offset: u32
) -> Field {
let mut balance = 0;
// docs:start:view_notes
let mut options = NoteViewerOptions::new();
Expand Down
Loading

0 comments on commit 8bd0755

Please sign in to comment.