diff --git a/.noir-sync-commit b/.noir-sync-commit index a646a9d9f7a..8bf1f2ff4b0 100644 --- a/.noir-sync-commit +++ b/.noir-sync-commit @@ -1 +1 @@ -b82032888819eac82b2bfce8300c2c8b66507c64 +598230d9427cf988fc6da8fe9e1eb2b7c00a2fa6 diff --git a/noir-projects/aztec-nr/address-note/src/address_note.nr b/noir-projects/aztec-nr/address-note/src/address_note.nr index 62786dd4b0b..a1207e21603 100644 --- a/noir-projects/aztec-nr/address-note/src/address_note.nr +++ b/noir-projects/aztec-nr/address-note/src/address_note.nr @@ -1,13 +1,16 @@ use dep::aztec::{ + context::PrivateContext, + keys::getters::get_nsk_app, + macros::notes::note, + note::{ + note_header::NoteHeader, note_interface::NullifiableNote, + utils::compute_note_hash_for_nullify, + }, + oracle::random::random, protocol_types::{ address::AztecAddress, constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash_with_separator, }, - note::{ - note_header::NoteHeader, note_interface::NullifiableNote, - utils::compute_note_hash_for_nullify, - }, oracle::random::random, keys::getters::get_nsk_app, context::PrivateContext, - macros::notes::note, }; // docs:start:address_note_def diff --git a/noir-projects/aztec-nr/authwit/src/account.nr b/noir-projects/aztec-nr/authwit/src/account.nr index 55f0e7918d8..93c8ce72666 100644 --- a/noir-projects/aztec-nr/authwit/src/account.nr +++ b/noir-projects/aztec-nr/authwit/src/account.nr @@ -1,11 +1,11 @@ use dep::aztec::{ context::PrivateContext, - protocol_types::constants::{GENERATOR_INDEX__COMBINED_PAYLOAD, GENERATOR_INDEX__TX_NULLIFIER}, hash::poseidon2_hash_with_separator, + protocol_types::constants::{GENERATOR_INDEX__COMBINED_PAYLOAD, GENERATOR_INDEX__TX_NULLIFIER}, }; +use crate::auth::{compute_authwit_message_hash, IS_VALID_SELECTOR}; use crate::entrypoint::{app::AppPayload, fee::FeePayload}; -use crate::auth::{IS_VALID_SELECTOR, compute_authwit_message_hash}; pub struct AccountActions { context: Context, diff --git a/noir-projects/aztec-nr/authwit/src/auth.nr b/noir-projects/aztec-nr/authwit/src/auth.nr index 88b8f3ea9b4..a3f15076f98 100644 --- a/noir-projects/aztec-nr/authwit/src/auth.nr +++ b/noir-projects/aztec-nr/authwit/src/auth.nr @@ -1,11 +1,13 @@ +use dep::aztec::{context::{gas::GasOpts, PrivateContext, PublicContext}, hash::hash_args_array}; use dep::aztec::protocol_types::{ - abis::function_selector::FunctionSelector, address::AztecAddress, + abis::function_selector::FunctionSelector, + address::AztecAddress, constants::{ - GENERATOR_INDEX__AUTHWIT_INNER, GENERATOR_INDEX__AUTHWIT_OUTER, - GENERATOR_INDEX__AUTHWIT_NULLIFIER, CANONICAL_AUTH_REGISTRY_ADDRESS, - }, hash::poseidon2_hash_with_separator, + CANONICAL_AUTH_REGISTRY_ADDRESS, GENERATOR_INDEX__AUTHWIT_INNER, + GENERATOR_INDEX__AUTHWIT_NULLIFIER, GENERATOR_INDEX__AUTHWIT_OUTER, + }, + hash::poseidon2_hash_with_separator, }; -use dep::aztec::{context::{PrivateContext, PublicContext, gas::GasOpts}, hash::hash_args_array}; /** * Authenticaion witness helper library diff --git a/noir-projects/aztec-nr/authwit/src/cheatcodes.nr b/noir-projects/aztec-nr/authwit/src/cheatcodes.nr index a61c1f24d5c..7b2192fefd2 100644 --- a/noir-projects/aztec-nr/authwit/src/cheatcodes.nr +++ b/noir-projects/aztec-nr/authwit/src/cheatcodes.nr @@ -1,11 +1,12 @@ use dep::aztec::{ - protocol_types::address::AztecAddress, - context::{public_context::PublicContext, call_interfaces::CallInterface}, - test::helpers::cheatcodes, oracle::execution::{get_block_number, get_contract_address}, + context::{call_interfaces::CallInterface, public_context::PublicContext}, hash::hash_args, + oracle::execution::{get_block_number, get_contract_address}, + protocol_types::address::AztecAddress, + test::helpers::cheatcodes, }; -use crate::auth::{compute_inner_authwit_hash, compute_authwit_message_hash, set_authorized}; +use crate::auth::{compute_authwit_message_hash, compute_inner_authwit_hash, set_authorized}; pub fn add_private_authwit_from_call_interface( on_behalf_of: AztecAddress, diff --git a/noir-projects/aztec-nr/authwit/src/entrypoint/app.nr b/noir-projects/aztec-nr/authwit/src/entrypoint/app.nr index 1aac89e567f..3b1c1be2b53 100644 --- a/noir-projects/aztec-nr/authwit/src/entrypoint/app.nr +++ b/noir-projects/aztec-nr/authwit/src/entrypoint/app.nr @@ -1,6 +1,7 @@ use dep::aztec::prelude::PrivateContext; use dep::aztec::protocol_types::{ - constants::GENERATOR_INDEX__SIGNATURE_PAYLOAD, hash::poseidon2_hash_with_separator, + constants::GENERATOR_INDEX__SIGNATURE_PAYLOAD, + hash::poseidon2_hash_with_separator, traits::{Hash, Serialize}, }; diff --git a/noir-projects/aztec-nr/authwit/src/entrypoint/fee.nr b/noir-projects/aztec-nr/authwit/src/entrypoint/fee.nr index 7033b8e97d3..2adddbff69b 100644 --- a/noir-projects/aztec-nr/authwit/src/entrypoint/fee.nr +++ b/noir-projects/aztec-nr/authwit/src/entrypoint/fee.nr @@ -1,9 +1,10 @@ +use crate::entrypoint::function_call::FunctionCall; use dep::aztec::prelude::PrivateContext; use dep::aztec::protocol_types::{ - constants::GENERATOR_INDEX__FEE_PAYLOAD, hash::poseidon2_hash_with_separator, + constants::GENERATOR_INDEX__FEE_PAYLOAD, + hash::poseidon2_hash_with_separator, traits::{Hash, Serialize}, }; -use crate::entrypoint::function_call::FunctionCall; // 2 * 5 (FUNCTION_CALL_SIZE) + 2 global FEE_PAYLOAD_SIZE: u32 = 12; diff --git a/noir-projects/aztec-nr/aztec/src/context/call_interfaces.nr b/noir-projects/aztec-nr/aztec/src/context/call_interfaces.nr index c888c7b490a..b4e55f61288 100644 --- a/noir-projects/aztec-nr/aztec/src/context/call_interfaces.nr +++ b/noir-projects/aztec-nr/aztec/src/context/call_interfaces.nr @@ -3,12 +3,12 @@ use dep::protocol_types::{ }; use crate::context::{ - private_context::PrivateContext, public_context::PublicContext, gas::GasOpts, - inputs::PrivateContextInputs, + gas::GasOpts, inputs::PrivateContextInputs, private_context::PrivateContext, + public_context::PublicContext, }; -use crate::oracle::arguments::pack_arguments; use crate::hash::hash_args; +use crate::oracle::arguments::pack_arguments; pub trait CallInterface { fn get_args(self) -> [Field] { diff --git a/noir-projects/aztec-nr/aztec/src/context/inputs/private_context_inputs.nr b/noir-projects/aztec-nr/aztec/src/context/inputs/private_context_inputs.nr index d41648e4983..926450aa970 100644 --- a/noir-projects/aztec-nr/aztec/src/context/inputs/private_context_inputs.nr +++ b/noir-projects/aztec-nr/aztec/src/context/inputs/private_context_inputs.nr @@ -1,6 +1,6 @@ use dep::protocol_types::{ - transaction::tx_context::TxContext, abis::call_context::CallContext, header::Header, - traits::Empty, + abis::call_context::CallContext, header::Header, traits::Empty, + transaction::tx_context::TxContext, }; // PrivateContextInputs are expected to be provided to each private function diff --git a/noir-projects/aztec-nr/aztec/src/context/mod.nr b/noir-projects/aztec-nr/aztec/src/context/mod.nr index f4cf63fd925..62347debff9 100644 --- a/noir-projects/aztec-nr/aztec/src/context/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/context/mod.nr @@ -10,12 +10,12 @@ mod call_interfaces; mod gas; pub use call_interfaces::{ - PrivateCallInterface, PrivateStaticCallInterface, PublicCallInterface, - PublicStaticCallInterface, PrivateVoidCallInterface, PrivateStaticVoidCallInterface, - PublicVoidCallInterface, PublicStaticVoidCallInterface, + PrivateCallInterface, PrivateStaticCallInterface, PrivateStaticVoidCallInterface, + PrivateVoidCallInterface, PublicCallInterface, PublicStaticCallInterface, + PublicStaticVoidCallInterface, PublicVoidCallInterface, }; -pub use private_context::PrivateContext; pub use packed_returns::PackedReturns; -pub use public_context::PublicContext; +pub use private_context::PrivateContext; pub use public_context::FunctionReturns; +pub use public_context::PublicContext; pub use unconstrained_context::UnconstrainedContext; diff --git a/noir-projects/aztec-nr/aztec/src/context/private_context.nr b/noir-projects/aztec-nr/aztec/src/context/private_context.nr index 049a828acd2..1465b61e8c6 100644 --- a/noir-projects/aztec-nr/aztec/src/context/private_context.nr +++ b/noir-projects/aztec-nr/aztec/src/context/private_context.nr @@ -1,34 +1,47 @@ use crate::{ context::{inputs::PrivateContextInputs, packed_returns::PackedReturns}, - messaging::process_l1_to_l2_message, hash::{hash_args_array, ArgsHasher}, - keys::constants::{NULLIFIER_INDEX, OUTGOING_INDEX, NUM_KEY_TYPES, sk_generators}, + hash::{ArgsHasher, hash_args_array}, + keys::constants::{NULLIFIER_INDEX, NUM_KEY_TYPES, OUTGOING_INDEX, sk_generators}, + messaging::process_l1_to_l2_message, oracle::{ - key_validation_request::get_key_validation_request, arguments, returns::pack_returns, - call_private_function::call_private_function_internal, header::get_header_at, - logs::{emit_encrypted_note_log, emit_encrypted_event_log}, + arguments, + call_private_function::call_private_function_internal, enqueue_public_function_call::{ enqueue_public_function_call_internal, notify_set_min_revertible_side_effect_counter, set_public_teardown_function_call_internal, }, + header::get_header_at, + key_validation_request::get_key_validation_request, + logs::{emit_encrypted_event_log, emit_encrypted_note_log}, + returns::pack_returns, }, }; use dep::protocol_types::{ abis::{ - call_context::CallContext, function_selector::FunctionSelector, + call_context::CallContext, + function_selector::FunctionSelector, + log_hash::{EncryptedLogHash, LogHash, NoteLogHash}, max_block_number::MaxBlockNumber, - validation_requests::{KeyValidationRequest, KeyValidationRequestAndGenerator}, + note_hash::NoteHash, + nullifier::Nullifier, private_call_request::PrivateCallRequest, private_circuit_public_inputs::PrivateCircuitPublicInputs, - public_call_request::PublicCallRequest, read_request::ReadRequest, note_hash::NoteHash, - nullifier::Nullifier, log_hash::{LogHash, NoteLogHash, EncryptedLogHash}, - }, address::{AztecAddress, EthAddress}, + public_call_request::PublicCallRequest, + read_request::ReadRequest, + validation_requests::{KeyValidationRequest, KeyValidationRequestAndGenerator}, + }, + address::{AztecAddress, EthAddress}, constants::{ - MAX_NOTE_HASHES_PER_CALL, MAX_L2_TO_L1_MSGS_PER_CALL, MAX_NULLIFIERS_PER_CALL, + MAX_ENCRYPTED_LOGS_PER_CALL, MAX_KEY_VALIDATION_REQUESTS_PER_CALL, + MAX_L2_TO_L1_MSGS_PER_CALL, MAX_NOTE_ENCRYPTED_LOGS_PER_CALL, + MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, MAX_NOTE_HASHES_PER_CALL, + MAX_NULLIFIER_READ_REQUESTS_PER_CALL, MAX_NULLIFIERS_PER_CALL, MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, - MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, MAX_NULLIFIER_READ_REQUESTS_PER_CALL, - MAX_KEY_VALIDATION_REQUESTS_PER_CALL, MAX_ENCRYPTED_LOGS_PER_CALL, - MAX_UNENCRYPTED_LOGS_PER_CALL, MAX_NOTE_ENCRYPTED_LOGS_PER_CALL, PUBLIC_DISPATCH_SELECTOR, - }, header::Header, messaging::l2_to_l1_message::L2ToL1Message, traits::Empty, + MAX_UNENCRYPTED_LOGS_PER_CALL, PUBLIC_DISPATCH_SELECTOR, + }, + header::Header, + messaging::l2_to_l1_message::L2ToL1Message, + traits::Empty, }; // When finished, one can call .finish() to convert back to the abi diff --git a/noir-projects/aztec-nr/aztec/src/context/public_context.nr b/noir-projects/aztec-nr/aztec/src/context/public_context.nr index 8c09a49c8c0..e63fde7e078 100644 --- a/noir-projects/aztec-nr/aztec/src/context/public_context.nr +++ b/noir-projects/aztec-nr/aztec/src/context/public_context.nr @@ -1,9 +1,9 @@ -use crate::hash::{compute_secret_hash, compute_message_hash, compute_message_nullifier}; +use crate::context::gas::GasOpts; +use crate::hash::{compute_message_hash, compute_message_nullifier, compute_secret_hash}; +use dep::protocol_types::abis::function_selector::FunctionSelector; use dep::protocol_types::address::{AztecAddress, EthAddress}; use dep::protocol_types::constants::{MAX_FIELD_VALUE, PUBLIC_DISPATCH_SELECTOR}; -use dep::protocol_types::traits::{Serialize, Deserialize, Empty}; -use dep::protocol_types::abis::function_selector::FunctionSelector; -use crate::context::gas::GasOpts; +use dep::protocol_types::traits::{Deserialize, Empty, Serialize}; pub struct PublicContext { args_hash: Option, diff --git a/noir-projects/aztec-nr/aztec/src/context/unconstrained_context.nr b/noir-projects/aztec-nr/aztec/src/context/unconstrained_context.nr index fad4adff72b..26b8531187d 100644 --- a/noir-projects/aztec-nr/aztec/src/context/unconstrained_context.nr +++ b/noir-projects/aztec-nr/aztec/src/context/unconstrained_context.nr @@ -1,8 +1,8 @@ -use dep::protocol_types::{address::AztecAddress, traits::Deserialize}; use crate::oracle::{ - execution::{get_chain_id, get_version, get_contract_address, get_block_number}, + execution::{get_block_number, get_chain_id, get_contract_address, get_version}, storage::storage_read, }; +use dep::protocol_types::{address::AztecAddress, traits::Deserialize}; pub struct UnconstrainedContext { block_number: u32, diff --git a/noir-projects/aztec-nr/aztec/src/deploy.nr b/noir-projects/aztec-nr/aztec/src/deploy.nr index 2920d1c9241..ec564f7bdf6 100644 --- a/noir-projects/aztec-nr/aztec/src/deploy.nr +++ b/noir-projects/aztec-nr/aztec/src/deploy.nr @@ -1,7 +1,7 @@ use crate::{context::PrivateContext, oracle::get_contract_instance::get_contract_instance}; use dep::protocol_types::{ - address::AztecAddress, abis::function_selector::FunctionSelector, + abis::function_selector::FunctionSelector, address::AztecAddress, constants::DEPLOYER_CONTRACT_ADDRESS, }; diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_event_emission.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_event_emission.nr index 960313d961f..5cccd74799b 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_event_emission.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_event_emission.nr @@ -1,10 +1,11 @@ use crate::{ - context::PrivateContext, event::event_interface::EventInterface, - encrypted_logs::payload::compute_encrypted_log, keys::getters::get_ovsk_app, - oracle::random::random, + context::PrivateContext, encrypted_logs::payload::compute_encrypted_log, + event::event_interface::EventInterface, keys::getters::get_ovsk_app, oracle::random::random, }; use dep::protocol_types::{ - address::AztecAddress, public_keys::{OvpkM, IvpkM}, hash::sha256_to_field, + address::AztecAddress, + hash::sha256_to_field, + public_keys::{IvpkM, OvpkM}, }; fn compute_raw_event_log( diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr index 698da4ee6e7..5239418d7b9 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/encrypted_note_emission.nr @@ -1,10 +1,14 @@ use crate::{ - context::PrivateContext, note::{note_emission::NoteEmission, note_interface::NoteInterface}, - keys::getters::get_ovsk_app, encrypted_logs::payload::compute_encrypted_log, + context::PrivateContext, + encrypted_logs::payload::compute_encrypted_log, + keys::getters::get_ovsk_app, + note::{note_emission::NoteEmission, note_interface::NoteInterface}, }; use dep::protocol_types::{ - address::AztecAddress, public_keys::{PublicKeys, OvpkM, IvpkM}, hash::sha256_to_field, abis::note_hash::NoteHash, + address::AztecAddress, + hash::sha256_to_field, + public_keys::{IvpkM, OvpkM, PublicKeys}, }; fn compute_raw_note_log( diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/header.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/header.nr index 1872fbb21d8..54850470e1c 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/header.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/header.nr @@ -1,5 +1,8 @@ use dep::protocol_types::{ - address::AztecAddress, public_keys::{PublicKeys, IvpkM, ToPoint}, scalar::Scalar, point::Point, + address::AztecAddress, + point::Point, + public_keys::{IvpkM, PublicKeys, ToPoint}, + scalar::Scalar, }; use crate::keys::point_to_symmetric_key::point_to_symmetric_key; diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr index 60dad2821f0..8e8a419f6f9 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/payload.nr @@ -1,16 +1,20 @@ use dep::protocol_types::{ - address::AztecAddress, scalar::Scalar, point::Point, public_keys::{OvpkM, IvpkM}, - constants::GENERATOR_INDEX__SYMMETRIC_KEY, hash::poseidon2_hash_with_separator, + address::AztecAddress, + constants::GENERATOR_INDEX__SYMMETRIC_KEY, + hash::poseidon2_hash_with_separator, + point::Point, + public_keys::{IvpkM, OvpkM}, + scalar::Scalar, }; use std::{ aes128::aes128_encrypt, embedded_curve_ops::fixed_base_scalar_mul as derive_public_key, - hash::from_field_unsafe as fr_to_fq_unsafe, field::bn254::decompose, + field::bn254::decompose, hash::from_field_unsafe as fr_to_fq_unsafe, }; use crate::{ - oracle::random::random, utils::point::point_to_bytes, encrypted_logs::header::EncryptedLogHeader, - keys::point_to_symmetric_key::point_to_symmetric_key, + keys::point_to_symmetric_key::point_to_symmetric_key, oracle::random::random, + utils::point::point_to_bytes, }; pub fn compute_encrypted_log( @@ -152,10 +156,13 @@ mod test { use crate::encrypted_logs::payload::{ compute_encrypted_log, compute_incoming_body_ciphertext, compute_outgoing_body_ciphertext, }; - use std::embedded_curve_ops::fixed_base_scalar_mul as derive_public_key; use dep::protocol_types::{ - address::AztecAddress, public_keys::{OvpkM, IvpkM}, point::Point, scalar::Scalar, + address::AztecAddress, + point::Point, + public_keys::{IvpkM, OvpkM}, + scalar::Scalar, }; + use std::embedded_curve_ops::fixed_base_scalar_mul as derive_public_key; use std::test::OracleMock; #[test] diff --git a/noir-projects/aztec-nr/aztec/src/generators.nr b/noir-projects/aztec-nr/aztec/src/generators.nr index 7671d8f28c8..5c787b60e14 100644 --- a/noir-projects/aztec-nr/aztec/src/generators.nr +++ b/noir-projects/aztec-nr/aztec/src/generators.nr @@ -34,7 +34,7 @@ global G_slot = Point { }; mod test { - use crate::generators::{Ga1, Ga2, Ga3, Ga4, Ga5, G_slot}; + use crate::generators::{G_slot, Ga1, Ga2, Ga3, Ga4, Ga5}; use dep::protocol_types::point::Point; use std::hash::derive_generators; diff --git a/noir-projects/aztec-nr/aztec/src/hash.nr b/noir-projects/aztec-nr/aztec/src/hash.nr index c58c78dbb82..4e5b9111463 100644 --- a/noir-projects/aztec-nr/aztec/src/hash.nr +++ b/noir-projects/aztec-nr/aztec/src/hash.nr @@ -1,12 +1,14 @@ +use crate::utils::to_bytes::{arr_to_be_bytes_arr, str_to_be_bytes_arr}; use dep::protocol_types::{ address::{AztecAddress, EthAddress}, constants::{ - GENERATOR_INDEX__SECRET_HASH, GENERATOR_INDEX__MESSAGE_NULLIFIER, - GENERATOR_INDEX__FUNCTION_ARGS, - }, point::Point, traits::Hash, - hash::{sha256_to_field, poseidon2_hash_with_separator, poseidon2_hash_with_separator_slice}, + GENERATOR_INDEX__FUNCTION_ARGS, GENERATOR_INDEX__MESSAGE_NULLIFIER, + GENERATOR_INDEX__SECRET_HASH, + }, + hash::{poseidon2_hash_with_separator, poseidon2_hash_with_separator_slice, sha256_to_field}, + point::Point, + traits::Hash, }; -use crate::utils::to_bytes::{arr_to_be_bytes_arr, str_to_be_bytes_arr}; pub use dep::protocol_types::hash::{compute_siloed_nullifier, pedersen_hash}; diff --git a/noir-projects/aztec-nr/aztec/src/history/contract_inclusion.nr b/noir-projects/aztec-nr/aztec/src/history/contract_inclusion.nr index 456c1dac837..342be3c0522 100644 --- a/noir-projects/aztec-nr/aztec/src/history/contract_inclusion.nr +++ b/noir-projects/aztec-nr/aztec/src/history/contract_inclusion.nr @@ -1,6 +1,6 @@ use dep::protocol_types::{ - header::Header, address::AztecAddress, hash::compute_siloed_nullifier, - constants::DEPLOYER_CONTRACT_ADDRESS, + address::AztecAddress, constants::DEPLOYER_CONTRACT_ADDRESS, hash::compute_siloed_nullifier, + header::Header, }; trait ProveContractDeployment { diff --git a/noir-projects/aztec-nr/aztec/src/history/note_inclusion.nr b/noir-projects/aztec-nr/aztec/src/history/note_inclusion.nr index a7f18eb4e99..0876b824a07 100644 --- a/noir-projects/aztec-nr/aztec/src/history/note_inclusion.nr +++ b/noir-projects/aztec-nr/aztec/src/history/note_inclusion.nr @@ -1,8 +1,8 @@ -use dep::protocol_types::merkle_tree::root::root_from_sibling_path; use dep::protocol_types::header::Header; +use dep::protocol_types::merkle_tree::root::root_from_sibling_path; use crate::{ - note::{utils::compute_note_hash_for_nullify, note_interface::{NoteInterface, NullifiableNote}}, + note::{note_interface::{NoteInterface, NullifiableNote}, utils::compute_note_hash_for_nullify}, oracle::get_membership_witness::get_note_hash_membership_witness, }; diff --git a/noir-projects/aztec-nr/aztec/src/history/nullifier_inclusion.nr b/noir-projects/aztec-nr/aztec/src/history/nullifier_inclusion.nr index 3651acabab9..bd0f508d485 100644 --- a/noir-projects/aztec-nr/aztec/src/history/nullifier_inclusion.nr +++ b/noir-projects/aztec-nr/aztec/src/history/nullifier_inclusion.nr @@ -1,10 +1,10 @@ -use dep::protocol_types::merkle_tree::root::root_from_sibling_path; use dep::protocol_types::header::Header; +use dep::protocol_types::merkle_tree::root::root_from_sibling_path; use crate::{ context::PrivateContext, + note::{note_interface::{NoteInterface, NullifiableNote}, utils::compute_siloed_nullifier}, oracle::get_nullifier_membership_witness::get_nullifier_membership_witness, - note::{utils::compute_siloed_nullifier, note_interface::{NoteInterface, NullifiableNote}}, }; trait ProveNullifierInclusion { diff --git a/noir-projects/aztec-nr/aztec/src/history/nullifier_non_inclusion.nr b/noir-projects/aztec-nr/aztec/src/history/nullifier_non_inclusion.nr index e8cf5d7bf4d..95a43086b2b 100644 --- a/noir-projects/aztec-nr/aztec/src/history/nullifier_non_inclusion.nr +++ b/noir-projects/aztec-nr/aztec/src/history/nullifier_non_inclusion.nr @@ -1,12 +1,13 @@ -use dep::protocol_types::merkle_tree::root::root_from_sibling_path; -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, NullifiableNote}}, + note::{note_interface::{NoteInterface, NullifiableNote}, utils::compute_siloed_nullifier}, oracle::get_nullifier_membership_witness::get_low_nullifier_membership_witness, }; +use dep::protocol_types::{ + header::Header, + utils::field::{full_field_greater_than, full_field_less_than}, +}; +use dep::protocol_types::merkle_tree::root::root_from_sibling_path; trait ProveNullifierNonInclusion { fn prove_nullifier_non_inclusion(header: Header, nullifier: Field); diff --git a/noir-projects/aztec-nr/aztec/src/history/public_storage.nr b/noir-projects/aztec-nr/aztec/src/history/public_storage.nr index 78aeeb63be7..d26397d1314 100644 --- a/noir-projects/aztec-nr/aztec/src/history/public_storage.nr +++ b/noir-projects/aztec-nr/aztec/src/history/public_storage.nr @@ -1,6 +1,6 @@ use dep::protocol_types::{ - constants::GENERATOR_INDEX__PUBLIC_LEAF_INDEX, hash::poseidon2_hash_with_separator, - address::AztecAddress, header::Header, utils::field::full_field_less_than, + address::AztecAddress, constants::GENERATOR_INDEX__PUBLIC_LEAF_INDEX, + hash::poseidon2_hash_with_separator, header::Header, utils::field::full_field_less_than, }; use dep::protocol_types::merkle_tree::root::root_from_sibling_path; diff --git a/noir-projects/aztec-nr/aztec/src/initializer.nr b/noir-projects/aztec-nr/aztec/src/initializer.nr index ec966af74af..71509340e71 100644 --- a/noir-projects/aztec-nr/aztec/src/initializer.nr +++ b/noir-projects/aztec-nr/aztec/src/initializer.nr @@ -1,11 +1,11 @@ use dep::protocol_types::{ - address::AztecAddress, hash::poseidon2_hash_with_separator, - constants::GENERATOR_INDEX__CONSTRUCTOR, abis::function_selector::FunctionSelector, + abis::function_selector::FunctionSelector, address::AztecAddress, + constants::GENERATOR_INDEX__CONSTRUCTOR, hash::poseidon2_hash_with_separator, }; use crate::{ - context::{PrivateContext, PublicContext}, oracle::get_contract_instance::get_contract_instance, - oracle::get_contract_instance::get_contract_instance_avm, + context::{PrivateContext, PublicContext}, + oracle::get_contract_instance::{get_contract_instance, get_contract_instance_avm}, }; pub fn mark_as_initialized_public(context: &mut PublicContext) { diff --git a/noir-projects/aztec-nr/aztec/src/keys/constants.nr b/noir-projects/aztec-nr/aztec/src/keys/constants.nr index 2d465369fed..ad2c7cc7cd0 100644 --- a/noir-projects/aztec-nr/aztec/src/keys/constants.nr +++ b/noir-projects/aztec-nr/aztec/src/keys/constants.nr @@ -1,5 +1,5 @@ use dep::protocol_types::constants::{ - GENERATOR_INDEX__NSK_M, GENERATOR_INDEX__IVSK_M, GENERATOR_INDEX__OVSK_M, + GENERATOR_INDEX__IVSK_M, GENERATOR_INDEX__NSK_M, GENERATOR_INDEX__OVSK_M, GENERATOR_INDEX__TSK_M, }; diff --git a/noir-projects/aztec-nr/aztec/src/keys/getters/mod.nr b/noir-projects/aztec-nr/aztec/src/keys/getters/mod.nr index 52502eed6bf..da3b7cd6ef7 100644 --- a/noir-projects/aztec-nr/aztec/src/keys/getters/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/keys/getters/mod.nr @@ -1,10 +1,11 @@ -use dep::protocol_types::{address::AztecAddress, public_keys::PublicKeys}; use crate::{ + keys::constants::{NULLIFIER_INDEX, OUTGOING_INDEX}, oracle::{ - keys::get_public_keys_and_partial_address, key_validation_request::get_key_validation_request, - }, keys::constants::{NULLIFIER_INDEX, OUTGOING_INDEX}, + keys::get_public_keys_and_partial_address, + }, }; +use dep::protocol_types::{address::AztecAddress, public_keys::PublicKeys}; mod test; diff --git a/noir-projects/aztec-nr/aztec/src/keys/point_to_symmetric_key.nr b/noir-projects/aztec-nr/aztec/src/keys/point_to_symmetric_key.nr index 7c55cbe548b..f1ad2b43938 100644 --- a/noir-projects/aztec-nr/aztec/src/keys/point_to_symmetric_key.nr +++ b/noir-projects/aztec-nr/aztec/src/keys/point_to_symmetric_key.nr @@ -1,8 +1,8 @@ +use crate::utils::point::point_to_bytes; use dep::protocol_types::{ - constants::GENERATOR_INDEX__SYMMETRIC_KEY, scalar::Scalar, point::Point, utils::arr_copy_slice, + constants::GENERATOR_INDEX__SYMMETRIC_KEY, point::Point, scalar::Scalar, utils::arr_copy_slice, }; -use crate::utils::point::point_to_bytes; -use std::{hash::sha256, embedded_curve_ops::multi_scalar_mul}; +use std::{embedded_curve_ops::multi_scalar_mul, hash::sha256}; // TODO(#5726): This function is called deriveAESSecret in TS. I don't like point_to_symmetric_key name much since // point is not the only input of the function. Unify naming with TS once we have a better name. diff --git a/noir-projects/aztec-nr/aztec/src/macros/events/mod.nr b/noir-projects/aztec-nr/aztec/src/macros/events/mod.nr index be9e588cb90..bf7f433eca2 100644 --- a/noir-projects/aztec-nr/aztec/src/macros/events/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/macros/events/mod.nr @@ -1,5 +1,5 @@ -use protocol_types::meta::flatten_to_fields; use super::utils::compute_event_selector; +use protocol_types::meta::flatten_to_fields; comptime fn generate_event_interface(s: StructDefinition) -> Quoted { let name = s.name(); diff --git a/noir-projects/aztec-nr/aztec/src/macros/functions/interfaces.nr b/noir-projects/aztec-nr/aztec/src/macros/functions/interfaces.nr index d2800f8fae4..720ca2179b8 100644 --- a/noir-projects/aztec-nr/aztec/src/macros/functions/interfaces.nr +++ b/noir-projects/aztec-nr/aztec/src/macros/functions/interfaces.nr @@ -1,10 +1,11 @@ +use crate::macros::utils::{ + add_to_field_slice, compute_fn_selector, get_fn_visibility, is_fn_private, is_fn_public, + is_fn_view, +}; use std::{ - meta::{unquote, type_of}, collections::umap::UHashMap, + collections::umap::UHashMap, hash::{BuildHasherDefault, poseidon2::Poseidon2Hasher}, -}; -use crate::macros::utils::{ - get_fn_visibility, is_fn_view, is_fn_private, add_to_field_slice, compute_fn_selector, - is_fn_public, + meta::{type_of, unquote}, }; comptime mut global STUBS: UHashMap> = diff --git a/noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr b/noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr index b60212dc10f..bc74d225c19 100644 --- a/noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr @@ -1,11 +1,11 @@ mod interfaces; -use std::meta::type_of; use super::utils::{ - modify_fn_body, is_fn_private, get_fn_visibility, is_fn_view, is_fn_initializer, is_fn_internal, - fn_has_noinitcheck, add_to_hasher, module_has_storage, module_has_initializer, + add_to_hasher, fn_has_noinitcheck, get_fn_visibility, is_fn_initializer, is_fn_internal, + is_fn_private, is_fn_view, modify_fn_body, module_has_initializer, module_has_storage, }; use protocol_types::meta::flatten_to_fields; +use std::meta::type_of; use interfaces::{create_fn_abi_export, register_stub, stub_fn}; diff --git a/noir-projects/aztec-nr/aztec/src/macros/mod.nr b/noir-projects/aztec-nr/aztec/src/macros/mod.nr index cc9b860f528..95a30da6912 100644 --- a/noir-projects/aztec-nr/aztec/src/macros/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/macros/mod.nr @@ -6,12 +6,12 @@ mod storage; mod events; use functions::interfaces::STUBS; +use notes::{generate_note_export, NOTES}; use storage::STORAGE_LAYOUT_NAME; -use notes::{NOTES, generate_note_export}; +use dispatch::generate_public_dispatch; use functions::transform_unconstrained; use utils::module_has_storage; -use dispatch::generate_public_dispatch; /// Marks a contract as an Aztec contract, generating the interfaces for its functions and notes, as well as injecting /// the `compute_note_hash_and_optionally_a_nullifier` function PXE requires in order to validate notes. diff --git a/noir-projects/aztec-nr/aztec/src/macros/notes/mod.nr b/noir-projects/aztec-nr/aztec/src/macros/notes/mod.nr index edbf60dc17b..511cf4ec288 100644 --- a/noir-projects/aztec-nr/aztec/src/macros/notes/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/macros/notes/mod.nr @@ -1,9 +1,10 @@ +use crate::note::{note_getter_options::PropertySelector, note_header::NoteHeader}; +use protocol_types::meta::{flatten_to_fields, pack_from_fields}; use std::{ - meta::{type_of, unquote, typ::fresh_type_variable}, collections::umap::UHashMap, + collections::umap::UHashMap, hash::{BuildHasherDefault, poseidon2::Poseidon2Hasher}, + meta::{typ::fresh_type_variable, type_of, unquote}, }; -use protocol_types::meta::{flatten_to_fields, pack_from_fields}; -use crate::note::{note_header::NoteHeader, note_getter_options::PropertySelector}; comptime global NOTE_HEADER_TYPE = type_of(NoteHeader::empty()); diff --git a/noir-projects/aztec-nr/aztec/src/macros/storage/mod.nr b/noir-projects/aztec-nr/aztec/src/macros/storage/mod.nr index c9535db0716..5d1e27c7a49 100644 --- a/noir-projects/aztec-nr/aztec/src/macros/storage/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/macros/storage/mod.nr @@ -1,5 +1,6 @@ use std::{ - collections::umap::UHashMap, hash::{BuildHasherDefault, poseidon2::Poseidon2Hasher}, + collections::umap::UHashMap, + hash::{BuildHasherDefault, poseidon2::Poseidon2Hasher}, meta::unquote, }; diff --git a/noir-projects/aztec-nr/aztec/src/messaging.nr b/noir-projects/aztec-nr/aztec/src/messaging.nr index ffeddf4d72f..6679fe0671e 100644 --- a/noir-projects/aztec-nr/aztec/src/messaging.nr +++ b/noir-projects/aztec-nr/aztec/src/messaging.nr @@ -1,10 +1,11 @@ use crate::{ - hash::{compute_secret_hash, compute_message_hash, compute_message_nullifier}, + hash::{compute_message_hash, compute_message_nullifier, compute_secret_hash}, oracle::get_l1_to_l2_membership_witness::get_l1_to_l2_membership_witness, }; use dep::protocol_types::{ - address::{AztecAddress, EthAddress}, merkle_tree::root::root_from_sibling_path, + address::{AztecAddress, EthAddress}, + merkle_tree::root::root_from_sibling_path, }; pub fn process_l1_to_l2_message( diff --git a/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr b/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr index a348ef3f876..d07e61e8b6b 100644 --- a/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr +++ b/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr @@ -1,8 +1,9 @@ use crate::context::{PrivateContext, PublicContext}; use crate::note::{ - note_header::NoteHeader, note_interface::{NoteInterface, NullifiableNote}, - utils::{compute_note_hash_for_read_request, compute_note_hash_for_nullify_internal}, note_emission::NoteEmission, + note_header::NoteHeader, + note_interface::{NoteInterface, NullifiableNote}, + utils::{compute_note_hash_for_nullify_internal, compute_note_hash_for_read_request}, }; use crate::oracle::notes::{notify_created_note, notify_nullified_note}; diff --git a/noir-projects/aztec-nr/aztec/src/note/note_getter/mod.nr b/noir-projects/aztec-nr/aztec/src/note/note_getter/mod.nr index fb463154c9d..52e8a14b64b 100644 --- a/noir-projects/aztec-nr/aztec/src/note/note_getter/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/note/note_getter/mod.nr @@ -1,15 +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, VIEW_NOTE_ORACLE_RETURN_LENGTH}, - note_getter_options::{NoteGetterOptions, Select, Sort, SortOrder, NoteStatus, PropertySelector}, - note_interface::{NoteInterface, NullifiableNote}, note_viewer_options::NoteViewerOptions, + note_getter_options::{NoteGetterOptions, NoteStatus, PropertySelector, Select, Sort, SortOrder}, + note_interface::{NoteInterface, NullifiableNote}, + note_viewer_options::NoteViewerOptions, utils::compute_note_hash_for_read_request, }; use crate::oracle; use crate::utils::comparison::compare; +use dep::protocol_types::constants::{ + GET_NOTES_ORACLE_RETURN_LENGTH, MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, +}; pub use crate::note::constants::MAX_NOTES_PER_PAGE; diff --git a/noir-projects/aztec-nr/aztec/src/note/note_getter/test.nr b/noir-projects/aztec-nr/aztec/src/note/note_getter/test.nr index b9267de3c5a..48728210d4b 100644 --- a/noir-projects/aztec-nr/aztec/src/note/note_getter/test.nr +++ b/noir-projects/aztec-nr/aztec/src/note/note_getter/test.nr @@ -1,10 +1,11 @@ -use dep::protocol_types::constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL; use crate::{ note::{ - note_getter_options::{NoteGetterOptions, SortOrder, PropertySelector}, note_getter::constrain_get_notes_internal, - }, oracle::execution::get_contract_address, + note_getter_options::{NoteGetterOptions, PropertySelector, SortOrder}, + }, + oracle::execution::get_contract_address, }; +use dep::protocol_types::constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL; use crate::test::{helpers::test_environment::TestEnvironment, mocks::mock_note::MockNote}; use crate::utils::comparison::Comparator; diff --git a/noir-projects/aztec-nr/aztec/src/note/note_getter_options.nr b/noir-projects/aztec-nr/aztec/src/note/note_getter_options.nr index 452818b9c3b..c4a5eb0f742 100644 --- a/noir-projects/aztec-nr/aztec/src/note/note_getter_options.nr +++ b/noir-projects/aztec-nr/aztec/src/note/note_getter_options.nr @@ -1,6 +1,6 @@ -use std::option::Option; -use dep::protocol_types::{constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, traits::ToField}; use crate::note::note_interface::NoteInterface; +use dep::protocol_types::{constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, traits::ToField}; +use std::option::Option; pub struct PropertySelector { index: u8, // index of the field in the serialized note array diff --git a/noir-projects/aztec-nr/aztec/src/note/note_viewer_options.nr b/noir-projects/aztec-nr/aztec/src/note/note_viewer_options.nr index 321e3d6c0ad..e4d64104b14 100644 --- a/noir-projects/aztec-nr/aztec/src/note/note_viewer_options.nr +++ b/noir-projects/aztec-nr/aztec/src/note/note_viewer_options.nr @@ -1,8 +1,8 @@ -use std::option::Option; -use crate::note::note_getter_options::{PropertySelector, Select, Sort, NoteStatus}; -use dep::protocol_types::traits::ToField; -use crate::note::note_interface::NoteInterface; use crate::note::constants::MAX_NOTES_PER_PAGE; +use crate::note::note_getter_options::{NoteStatus, PropertySelector, Select, Sort}; +use crate::note::note_interface::NoteInterface; +use dep::protocol_types::traits::ToField; +use std::option::Option; // docs:start:NoteViewerOptions pub struct NoteViewerOptions { diff --git a/noir-projects/aztec-nr/aztec/src/note/utils.nr b/noir-projects/aztec-nr/aztec/src/note/utils.nr index 0dab8de2243..6f3031f0384 100644 --- a/noir-projects/aztec-nr/aztec/src/note/utils.nr +++ b/noir-projects/aztec-nr/aztec/src/note/utils.nr @@ -1,13 +1,15 @@ use crate::{ context::PrivateContext, - note::{note_header::NoteHeader, note_interface::{NullifiableNote, NoteInterface}}, + note::{note_header::NoteHeader, note_interface::{NoteInterface, NullifiableNote}}, }; use dep::protocol_types::{ hash::{ - compute_unique_note_hash, compute_siloed_note_hash as compute_siloed_note_hash, + compute_siloed_note_hash as compute_siloed_note_hash, compute_siloed_nullifier as compute_siloed_nullifier_from_preimage, - }, utils::arr_copy_slice, + compute_unique_note_hash, + }, + utils::arr_copy_slice, }; pub fn compute_siloed_nullifier( diff --git a/noir-projects/aztec-nr/aztec/src/oracle/get_contract_instance.nr b/noir-projects/aztec-nr/aztec/src/oracle/get_contract_instance.nr index 7e8416c50c9..7958bfd819c 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/get_contract_instance.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/get_contract_instance.nr @@ -1,5 +1,5 @@ use dep::protocol_types::{ - address::AztecAddress, contract_instance::ContractInstance, constants::CONTRACT_INSTANCE_LENGTH, + address::AztecAddress, constants::CONTRACT_INSTANCE_LENGTH, contract_instance::ContractInstance, utils::reader::Reader, }; diff --git a/noir-projects/aztec-nr/aztec/src/oracle/get_membership_witness.nr b/noir-projects/aztec-nr/aztec/src/oracle/get_membership_witness.nr index 3987fab937a..fed4c3b66b7 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/get_membership_witness.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/get_membership_witness.nr @@ -1,5 +1,6 @@ use dep::protocol_types::{ - constants::{ARCHIVE_HEIGHT, NOTE_HASH_TREE_HEIGHT}, utils::arr_copy_slice, + constants::{ARCHIVE_HEIGHT, NOTE_HASH_TREE_HEIGHT}, + utils::arr_copy_slice, }; global NOTE_HASH_TREE_ID = 1; diff --git a/noir-projects/aztec-nr/aztec/src/oracle/get_nullifier_membership_witness.nr b/noir-projects/aztec-nr/aztec/src/oracle/get_nullifier_membership_witness.nr index 3bf863ebee9..bfdf6a6d759 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/get_nullifier_membership_witness.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/get_nullifier_membership_witness.nr @@ -1,6 +1,7 @@ use dep::protocol_types::{ - abis::nullifier_leaf_preimage::{NullifierLeafPreimage, NULLIFIER_LEAF_PREIMAGE_LENGTH}, - constants::NULLIFIER_TREE_HEIGHT, utils::arr_copy_slice, + abis::nullifier_leaf_preimage::{NULLIFIER_LEAF_PREIMAGE_LENGTH, NullifierLeafPreimage}, + constants::NULLIFIER_TREE_HEIGHT, + utils::arr_copy_slice, }; // INDEX_LENGTH + NULLIFIER_LEAF_PREIMAGE_LENGTH + NULLIFIER_TREE_HEIGHT diff --git a/noir-projects/aztec-nr/aztec/src/oracle/header.nr b/noir-projects/aztec-nr/aztec/src/oracle/header.nr index b093494e4a1..9ce477aac1a 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/header.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/header.nr @@ -1,5 +1,5 @@ -use dep::protocol_types::merkle_tree::root::root_from_sibling_path; use dep::protocol_types::{constants::HEADER_LENGTH, header::Header}; +use dep::protocol_types::merkle_tree::root::root_from_sibling_path; use crate::{ context::PrivateContext, oracle::get_membership_witness::get_archive_membership_witness, diff --git a/noir-projects/aztec-nr/aztec/src/oracle/key_validation_request.nr b/noir-projects/aztec-nr/aztec/src/oracle/key_validation_request.nr index 6a779675fc4..30fa8f6dfd0 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/key_validation_request.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/key_validation_request.nr @@ -1,5 +1,5 @@ use dep::protocol_types::abis::validation_requests::{ - KeyValidationRequest, key_validation_request::KEY_VALIDATION_REQUEST_LENGTH, + key_validation_request::KEY_VALIDATION_REQUEST_LENGTH, KeyValidationRequest, }; #[oracle(getKeyValidationRequest)] diff --git a/noir-projects/aztec-nr/aztec/src/oracle/keys.nr b/noir-projects/aztec-nr/aztec/src/oracle/keys.nr index 7c6bb4a317f..f29c0e8b2f7 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/keys.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/keys.nr @@ -1,6 +1,7 @@ use dep::protocol_types::{ - address::{AztecAddress, PartialAddress}, public_keys::{PublicKeys, NpkM, IvpkM, OvpkM, TpkM}, + address::{AztecAddress, PartialAddress}, point::Point, + public_keys::{IvpkM, NpkM, OvpkM, PublicKeys, TpkM}, }; #[oracle(getPublicKeysAndPartialAddress)] diff --git a/noir-projects/aztec-nr/aztec/src/oracle/storage.nr b/noir-projects/aztec-nr/aztec/src/oracle/storage.nr index 5a7e6018a53..c766c739a30 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/storage.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/storage.nr @@ -36,8 +36,8 @@ mod tests { use crate::oracle::storage::{raw_storage_read, storage_read}; use dep::protocol_types::address::AztecAddress; - use std::test::OracleMock; use crate::test::mocks::mock_struct::MockStruct; + use std::test::OracleMock; global address = AztecAddress::from_field(29); global slot = 7; diff --git a/noir-projects/aztec-nr/aztec/src/prelude.nr b/noir-projects/aztec-nr/aztec/src/prelude.nr index bfa103d66f8..04dee82bf14 100644 --- a/noir-projects/aztec-nr/aztec/src/prelude.nr +++ b/noir-projects/aztec-nr/aztec/src/prelude.nr @@ -1,18 +1,23 @@ // docs:start:prelude -pub use dep::protocol_types::{ - address::{AztecAddress, EthAddress}, abis::function_selector::FunctionSelector, point::Point, - traits::{Serialize, Deserialize}, -}; pub use crate::{ + context::{FunctionReturns, PackedReturns, PrivateContext, PublicContext}, + note::{ + note_getter_options::NoteGetterOptions, + note_header::NoteHeader, + note_interface::{NoteInterface, NullifiableNote}, + note_viewer_options::NoteViewerOptions, + utils::compute_note_hash_and_optionally_a_nullifier as utils_compute_note_hash_and_optionally_a_nullifier, + }, state_vars::{ map::Map, private_immutable::PrivateImmutable, private_mutable::PrivateMutable, - public_immutable::PublicImmutable, public_mutable::PublicMutable, private_set::PrivateSet, + private_set::PrivateSet, public_immutable::PublicImmutable, public_mutable::PublicMutable, shared_immutable::SharedImmutable, shared_mutable::SharedMutable, storage::Storable, - }, context::{PrivateContext, PackedReturns, FunctionReturns, PublicContext}, - note::{ - note_header::NoteHeader, note_interface::{NoteInterface, NullifiableNote}, - note_getter_options::NoteGetterOptions, note_viewer_options::NoteViewerOptions, - utils::compute_note_hash_and_optionally_a_nullifier as utils_compute_note_hash_and_optionally_a_nullifier, }, }; +pub use dep::protocol_types::{ + abis::function_selector::FunctionSelector, + address::{AztecAddress, EthAddress}, + point::Point, + traits::{Deserialize, Serialize}, +}; // docs:end:prelude diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/map.nr b/noir-projects/aztec-nr/aztec/src/state_vars/map.nr index ddb88ac8038..f695a78a49d 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/map.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/map.nr @@ -1,5 +1,5 @@ -use dep::protocol_types::{storage::map::derive_storage_slot_in_map, traits::ToField}; use crate::state_vars::storage::Storage; +use dep::protocol_types::{storage::map::derive_storage_slot_in_map, traits::ToField}; // docs:start:map pub struct Map { diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/mod.nr b/noir-projects/aztec-nr/aztec/src/state_vars/mod.nr index 127f35094f4..72d00c2ac17 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/mod.nr @@ -11,9 +11,9 @@ mod 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::private_set::PrivateSet; 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; diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/private_immutable.nr b/noir-projects/aztec-nr/aztec/src/state_vars/private_immutable.nr index 4f6ff618fae..81bb6e42e6f 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/private_immutable.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/private_immutable.nr @@ -4,9 +4,11 @@ use dep::protocol_types::{ use crate::context::{PrivateContext, UnconstrainedContext}; use crate::note::{ - lifecycle::create_note, note_getter::{get_note, view_notes}, - note_interface::{NoteInterface, NullifiableNote}, note_viewer_options::NoteViewerOptions, + lifecycle::create_note, note_emission::NoteEmission, + note_getter::{get_note, view_notes}, + note_interface::{NoteInterface, NullifiableNote}, + note_viewer_options::NoteViewerOptions, }; use crate::oracle::notes::check_nullifier_exists; use crate::state_vars::storage::Storage; diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/private_mutable.nr b/noir-projects/aztec-nr/aztec/src/state_vars/private_mutable.nr index 29cc9c6b88b..7b144d1302a 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/private_mutable.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/private_mutable.nr @@ -4,9 +4,11 @@ use dep::protocol_types::{ use crate::context::{PrivateContext, UnconstrainedContext}; use crate::note::{ - lifecycle::{create_note, destroy_note_unsafe}, note_getter::{get_note, view_notes}, - note_interface::{NoteInterface, NullifiableNote}, note_viewer_options::NoteViewerOptions, + lifecycle::{create_note, destroy_note_unsafe}, note_emission::NoteEmission, + note_getter::{get_note, view_notes}, + note_interface::{NoteInterface, NullifiableNote}, + note_viewer_options::NoteViewerOptions, }; use crate::oracle::notes::check_nullifier_exists; use crate::state_vars::storage::Storage; diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/private_mutable/test.nr b/noir-projects/aztec-nr/aztec/src/state_vars/private_mutable/test.nr index 4d72ba7ac33..6f9ca70cbab 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/private_mutable/test.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/private_mutable/test.nr @@ -1,8 +1,8 @@ use crate::{ - context::PrivateContext, state_vars::private_mutable::PrivateMutable, - oracle::execution::get_contract_address, + context::PrivateContext, oracle::execution::get_contract_address, + state_vars::private_mutable::PrivateMutable, }; -use crate::test::{mocks::mock_note::MockNote, helpers::test_environment::TestEnvironment}; +use crate::test::{helpers::test_environment::TestEnvironment, mocks::mock_note::MockNote}; use std::test::OracleMock; global storage_slot = 17; diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/private_set.nr b/noir-projects/aztec-nr/aztec/src/state_vars/private_set.nr index da2d4926411..b63638fc33f 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/private_set.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/private_set.nr @@ -1,15 +1,18 @@ -use dep::protocol_types::{ - constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, abis::read_request::ReadRequest, -}; use crate::context::{PrivateContext, PublicContext, UnconstrainedContext}; use crate::note::{ constants::MAX_NOTES_PER_PAGE, lifecycle::{create_note, create_note_hash_from_public, destroy_note_unsafe}, - note_getter::{get_notes, view_notes}, note_getter_options::NoteGetterOptions, - note_interface::{NoteInterface, NullifiableNote}, note_viewer_options::NoteViewerOptions, - utils::compute_note_hash_for_read_request, note_emission::NoteEmission, + note_emission::NoteEmission, + note_getter::{get_notes, view_notes}, + note_getter_options::NoteGetterOptions, + note_interface::{NoteInterface, NullifiableNote}, + note_viewer_options::NoteViewerOptions, + utils::compute_note_hash_for_read_request, }; use crate::state_vars::storage::Storage; +use dep::protocol_types::{ + abis::read_request::ReadRequest, constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, +}; // docs:start:struct pub struct PrivateSet { diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/public_immutable.nr b/noir-projects/aztec-nr/aztec/src/state_vars/public_immutable.nr index 4fac882d8a9..1e9afe1de55 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/public_immutable.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/public_immutable.nr @@ -1,6 +1,7 @@ use crate::{context::{PublicContext, UnconstrainedContext}, state_vars::storage::Storage}; use dep::protocol_types::{ - constants::INITIALIZATION_SLOT_SEPARATOR, traits::{Deserialize, Serialize}, + constants::INITIALIZATION_SLOT_SEPARATOR, + traits::{Deserialize, Serialize}, }; // Just like SharedImmutable but without the ability to read from private functions. diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/public_mutable.nr b/noir-projects/aztec-nr/aztec/src/state_vars/public_mutable.nr index a1472db195d..d2b965d3377 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/public_mutable.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/public_mutable.nr @@ -1,6 +1,6 @@ use crate::context::{PublicContext, UnconstrainedContext}; -use dep::protocol_types::traits::{Deserialize, Serialize}; use crate::state_vars::storage::Storage; +use dep::protocol_types::traits::{Deserialize, Serialize}; // docs:start:public_mutable_struct pub struct PublicMutable { diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/shared_immutable.nr b/noir-projects/aztec-nr/aztec/src/state_vars/shared_immutable.nr index 8c6f3ecb9ab..00add0afb26 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/shared_immutable.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/shared_immutable.nr @@ -1,8 +1,10 @@ use crate::{ - context::{PrivateContext, PublicContext, UnconstrainedContext}, state_vars::storage::Storage, + context::{PrivateContext, PublicContext, UnconstrainedContext}, + state_vars::storage::Storage, }; use dep::protocol_types::{ - constants::INITIALIZATION_SLOT_SEPARATOR, traits::{Deserialize, Serialize}, + constants::INITIALIZATION_SLOT_SEPARATOR, + traits::{Deserialize, Serialize}, }; // Just like PublicImmutable but with the ability to read from private functions. diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/scheduled_delay_change.nr b/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/scheduled_delay_change.nr index 05ce69f59df..9522af5a3a4 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/scheduled_delay_change.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/scheduled_delay_change.nr @@ -1,4 +1,4 @@ -use dep::protocol_types::traits::{Serialize, Deserialize}; +use dep::protocol_types::traits::{Deserialize, Serialize}; use std::cmp::min; mod test; diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/scheduled_value_change.nr b/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/scheduled_value_change.nr index fb2288b3056..0bf97e7791f 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/scheduled_value_change.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/scheduled_value_change.nr @@ -1,4 +1,4 @@ -use dep::protocol_types::traits::{Serialize, Deserialize, FromField, ToField}; +use dep::protocol_types::traits::{Deserialize, FromField, Serialize, ToField}; use std::cmp::min; mod test; diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/shared_mutable.nr b/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/shared_mutable.nr index b07f08e552d..0a499c40c70 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/shared_mutable.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/shared_mutable.nr @@ -1,16 +1,18 @@ use dep::protocol_types::{ - hash::{poseidon2_hash, poseidon2_hash_with_separator}, address::AztecAddress, - traits::{FromField, ToField}, utils::arrays::array_concat, + address::AztecAddress, + hash::{poseidon2_hash, poseidon2_hash_with_separator}, + traits::{FromField, ToField}, + utils::arrays::array_concat, }; use crate::context::{PrivateContext, PublicContext, UnconstrainedContext}; +use crate::oracle::storage::storage_read; use crate::state_vars::{ - storage::Storage, shared_mutable::{ - scheduled_value_change::ScheduledValueChange, scheduled_delay_change::ScheduledDelayChange, + scheduled_delay_change::ScheduledDelayChange, scheduled_value_change::ScheduledValueChange, }, + storage::Storage, }; -use crate::oracle::storage::storage_read; use dep::std::mem::zeroed; mod test; diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/test.nr b/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/test.nr index e3850f280c8..cdf5414ec83 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/test.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/test.nr @@ -1,12 +1,13 @@ use crate::{ - context::{PublicContext, PrivateContext, UnconstrainedContext}, + context::{PrivateContext, PublicContext, UnconstrainedContext}, state_vars::shared_mutable::{ - shared_mutable::SharedMutable, scheduled_value_change::ScheduledValueChange, - scheduled_delay_change::ScheduledDelayChange, - }, test::helpers::test_environment::TestEnvironment, + scheduled_delay_change::ScheduledDelayChange, scheduled_value_change::ScheduledValueChange, + shared_mutable::SharedMutable, + }, + test::helpers::test_environment::TestEnvironment, }; -use dep::std::{test::OracleMock, mem::zeroed}; +use dep::std::{mem::zeroed, test::OracleMock}; global new_value = 17; diff --git a/noir-projects/aztec-nr/aztec/src/test/helpers/cheatcodes.nr b/noir-projects/aztec-nr/aztec/src/test/helpers/cheatcodes.nr index 2e7a44ada8f..d3f63c78eed 100644 --- a/noir-projects/aztec-nr/aztec/src/test/helpers/cheatcodes.nr +++ b/noir-projects/aztec-nr/aztec/src/test/helpers/cheatcodes.nr @@ -1,9 +1,10 @@ +use crate::context::inputs::PrivateContextInputs; +use crate::test::helpers::utils::TestAccount; use dep::protocol_types::{ - abis::function_selector::FunctionSelector, address::AztecAddress, public_keys::PublicKeys, + abis::function_selector::FunctionSelector, address::AztecAddress, constants::CONTRACT_INSTANCE_LENGTH, contract_instance::ContractInstance, + public_keys::PublicKeys, }; -use crate::context::inputs::PrivateContextInputs; -use crate::test::helpers::utils::TestAccount; pub unconstrained fn reset() { oracle_reset(); diff --git a/noir-projects/aztec-nr/aztec/src/test/helpers/test_environment.nr b/noir-projects/aztec-nr/aztec/src/test/helpers/test_environment.nr index 8755aefb94a..4c87fb9eddf 100644 --- a/noir-projects/aztec-nr/aztec/src/test/helpers/test_environment.nr +++ b/noir-projects/aztec-nr/aztec/src/test/helpers/test_environment.nr @@ -1,15 +1,16 @@ use dep::protocol_types::{abis::function_selector::FunctionSelector, address::AztecAddress}; +use crate::context::{call_interfaces::CallInterface, packed_returns::PackedReturns}; use crate::context::inputs::PrivateContextInputs; -use crate::context::{packed_returns::PackedReturns, call_interfaces::CallInterface}; use crate::context::{PrivateContext, PublicContext, UnconstrainedContext}; -use crate::test::helpers::{cheatcodes, utils::Deployer}; use crate::hash::hash_args; +use crate::test::helpers::{cheatcodes, utils::Deployer}; use crate::note::{note_header::NoteHeader, note_interface::{NoteInterface, NullifiableNote}}; use crate::oracle::{ - execution::{get_block_number, get_contract_address}, notes::notify_created_note, + execution::{get_block_number, get_contract_address}, + notes::notify_created_note, }; use protocol_types::constants::PUBLIC_DISPATCH_SELECTOR; diff --git a/noir-projects/aztec-nr/aztec/src/test/helpers/utils.nr b/noir-projects/aztec-nr/aztec/src/test/helpers/utils.nr index 4b2e537386e..e8c9734a6e4 100644 --- a/noir-projects/aztec-nr/aztec/src/test/helpers/utils.nr +++ b/noir-projects/aztec-nr/aztec/src/test/helpers/utils.nr @@ -1,21 +1,23 @@ use dep::protocol_types::{ - traits::{Deserialize, Serialize}, address::AztecAddress, - public_keys::{PublicKeys, PUBLIC_KEYS_LENGTH}, abis::function_selector::FunctionSelector, + abis::function_selector::FunctionSelector, + address::AztecAddress, contract_instance::ContractInstance, + public_keys::{PUBLIC_KEYS_LENGTH, PublicKeys}, + traits::{Deserialize, Serialize}, }; +use crate::context::call_interfaces::{CallInterface, PublicCallInterface}; use crate::context::{ - PrivateContext, PublicContext, UnconstrainedContext, inputs::PrivateContextInputs, + inputs::PrivateContextInputs, PrivateContext, PublicContext, UnconstrainedContext, }; -use crate::context::call_interfaces::{PublicCallInterface, CallInterface}; use crate::test::helpers::cheatcodes; -use crate::oracle::execution::{get_block_number, get_contract_address}; -use protocol_types::constants::PUBLIC_DISPATCH_SELECTOR; -use crate::context::gas::GasOpts; use crate::context::call_interfaces::PublicVoidCallInterface; +use crate::context::gas::GasOpts; use crate::hash::hash_args; use crate::oracle::arguments::pack_arguments; +use crate::oracle::execution::{get_block_number, get_contract_address}; +use protocol_types::constants::PUBLIC_DISPATCH_SELECTOR; pub struct Deployer { path: str, diff --git a/noir-projects/aztec-nr/aztec/src/test/mocks/mock_note.nr b/noir-projects/aztec-nr/aztec/src/test/mocks/mock_note.nr index 4991710182f..299204688a0 100644 --- a/noir-projects/aztec-nr/aztec/src/test/mocks/mock_note.nr +++ b/noir-projects/aztec-nr/aztec/src/test/mocks/mock_note.nr @@ -1,17 +1,18 @@ use crate::{ - context::PrivateContext, generators::Ga1 as G_val, + context::PrivateContext, + generators::Ga1 as G_val, note::{ note_header::NoteHeader, note_interface::NoteInterface, utils::compute_note_hash_for_nullify, }, }; +use crate::note::note_interface::NullifiableNote; use dep::protocol_types::{ address::AztecAddress, constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash_with_separator, }; use dep::std::{embedded_curve_ops::multi_scalar_mul, hash::from_field_unsafe}; -use crate::note::note_interface::NullifiableNote; global MOCK_NOTE_LENGTH: u32 = 1; diff --git a/noir-projects/aztec-nr/aztec/src/test/mocks/mock_struct.nr b/noir-projects/aztec-nr/aztec/src/test/mocks/mock_struct.nr index 339312e1749..87015947beb 100644 --- a/noir-projects/aztec-nr/aztec/src/test/mocks/mock_struct.nr +++ b/noir-projects/aztec-nr/aztec/src/test/mocks/mock_struct.nr @@ -1,4 +1,4 @@ -use dep::protocol_types::traits::{Serialize, Deserialize}; +use dep::protocol_types::traits::{Deserialize, Serialize}; pub(crate) struct MockStruct { a: Field, diff --git a/noir-projects/aztec-nr/aztec/src/utils/comparison.nr b/noir-projects/aztec-nr/aztec/src/utils/comparison.nr index d3ec8c4f612..2da17acce73 100644 --- a/noir-projects/aztec-nr/aztec/src/utils/comparison.nr +++ b/noir-projects/aztec-nr/aztec/src/utils/comparison.nr @@ -32,8 +32,8 @@ pub fn compare(lhs: Field, operation: u8, rhs: Field) -> bool { } mod test { - use super::compare; use super::Comparator; + use super::compare; #[test] unconstrained fn test_compare() { diff --git a/noir-projects/aztec-nr/aztec/src/utils/mod.nr b/noir-projects/aztec-nr/aztec/src/utils/mod.nr index ae469c45465..91236021d40 100644 --- a/noir-projects/aztec-nr/aztec/src/utils/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/utils/mod.nr @@ -5,5 +5,5 @@ mod point; mod test; mod to_bytes; -pub use crate::utils::collapse_array::collapse_array; pub use crate::utils::bytes::{bytes_to_fields, fields_to_bytes}; +pub use crate::utils::collapse_array::collapse_array; diff --git a/noir-projects/aztec-nr/aztec/src/utils/point.nr b/noir-projects/aztec-nr/aztec/src/utils/point.nr index ecfb802dd48..d02c302f176 100644 --- a/noir-projects/aztec-nr/aztec/src/utils/point.nr +++ b/noir-projects/aztec-nr/aztec/src/utils/point.nr @@ -32,8 +32,8 @@ pub fn point_to_bytes(pk: Point) -> [u8; 32] { } mod test { - use dep::protocol_types::point::Point; use crate::utils::point::point_to_bytes; + use dep::protocol_types::point::Point; #[test] unconstrained fn test_point_to_bytes_positive_sign() { diff --git a/noir-projects/aztec-nr/compressed-string/src/compressed_string.nr b/noir-projects/aztec-nr/compressed-string/src/compressed_string.nr index 6c209bf9c17..deab09c4e37 100644 --- a/noir-projects/aztec-nr/compressed-string/src/compressed_string.nr +++ b/noir-projects/aztec-nr/compressed-string/src/compressed_string.nr @@ -1,4 +1,4 @@ -use dep::aztec::protocol_types::{utils::field::field_from_bytes, traits::{Serialize, Deserialize}}; +use dep::aztec::protocol_types::{traits::{Deserialize, Serialize}, utils::field::field_from_bytes}; // The general Compressed String. // Compresses M bytes into N fields. diff --git a/noir-projects/aztec-nr/compressed-string/src/field_compressed_string.nr b/noir-projects/aztec-nr/compressed-string/src/field_compressed_string.nr index 54675974958..41b391c260c 100644 --- a/noir-projects/aztec-nr/compressed-string/src/field_compressed_string.nr +++ b/noir-projects/aztec-nr/compressed-string/src/field_compressed_string.nr @@ -1,4 +1,4 @@ -use dep::aztec::protocol_types::{utils::field::field_from_bytes, traits::{Serialize, Deserialize}}; +use dep::aztec::protocol_types::{traits::{Deserialize, Serialize}, utils::field::field_from_bytes}; // A Fixedsize Compressed String. // Essentially a special version of Compressed String for practical use. diff --git a/noir-projects/aztec-nr/easy-private-state/src/easy_private_uint.nr b/noir-projects/aztec-nr/easy-private-state/src/easy_private_uint.nr index ec014ecd026..6b70c6ac3e9 100644 --- a/noir-projects/aztec-nr/easy-private-state/src/easy_private_uint.nr +++ b/noir-projects/aztec-nr/easy-private-state/src/easy_private_uint.nr @@ -1,8 +1,7 @@ use dep::aztec::{ - context::PrivateContext, protocol_types::address::AztecAddress, - note::note_getter_options::NoteGetterOptions, state_vars::PrivateSet, - encrypted_logs::encrypted_note_emission::encode_and_encrypt_note, - keys::getters::get_public_keys, + context::PrivateContext, encrypted_logs::encrypted_note_emission::encode_and_encrypt_note, + keys::getters::get_public_keys, note::note_getter_options::NoteGetterOptions, + protocol_types::address::AztecAddress, state_vars::PrivateSet, }; use dep::value_note::{filter::filter_notes_min_sum, value_note::ValueNote}; diff --git a/noir-projects/aztec-nr/uint-note/src/uint_note.nr b/noir-projects/aztec-nr/uint-note/src/uint_note.nr index 4552c980c64..44ab33c7201 100644 --- a/noir-projects/aztec-nr/uint-note/src/uint_note.nr +++ b/noir-projects/aztec-nr/uint-note/src/uint_note.nr @@ -1,8 +1,11 @@ use dep::aztec::{ + keys::getters::get_nsk_app, + macros::notes::note, + note::utils::compute_note_hash_for_nullify, prelude::{NullifiableNote, PrivateContext}, protocol_types::{ constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash_with_separator, - }, note::utils::compute_note_hash_for_nullify, keys::getters::get_nsk_app, macros::notes::note, + }, }; #[note] diff --git a/noir-projects/aztec-nr/value-note/src/balance_utils.nr b/noir-projects/aztec-nr/value-note/src/balance_utils.nr index 35254d99943..f03b9993e4a 100644 --- a/noir-projects/aztec-nr/value-note/src/balance_utils.nr +++ b/noir-projects/aztec-nr/value-note/src/balance_utils.nr @@ -1,8 +1,8 @@ +use crate::value_note::ValueNote; use dep::aztec::{ - context::UnconstrainedContext, state_vars::PrivateSet, - note::note_viewer_options::NoteViewerOptions, + context::UnconstrainedContext, note::note_viewer_options::NoteViewerOptions, + state_vars::PrivateSet, }; -use crate::value_note::ValueNote; pub unconstrained fn get_balance(set: PrivateSet) -> Field { get_balance_with_offset(set, 0) diff --git a/noir-projects/aztec-nr/value-note/src/filter.nr b/noir-projects/aztec-nr/value-note/src/filter.nr index fb24074a0d9..29e2ccd4af3 100644 --- a/noir-projects/aztec-nr/value-note/src/filter.nr +++ b/noir-projects/aztec-nr/value-note/src/filter.nr @@ -1,5 +1,5 @@ -use dep::aztec::protocol_types::constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL; use crate::value_note::ValueNote; +use dep::aztec::protocol_types::constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL; pub fn filter_notes_min_sum( notes: [Option; MAX_NOTE_HASH_READ_REQUESTS_PER_CALL], diff --git a/noir-projects/aztec-nr/value-note/src/utils.nr b/noir-projects/aztec-nr/value-note/src/utils.nr index e5cedaf9dcb..adc37d263f9 100644 --- a/noir-projects/aztec-nr/value-note/src/utils.nr +++ b/noir-projects/aztec-nr/value-note/src/utils.nr @@ -1,8 +1,8 @@ -use dep::aztec::prelude::{AztecAddress, PrivateContext, PrivateSet, NoteGetterOptions}; -use dep::aztec::note::note_getter_options::SortOrder; +use crate::{filter::filter_notes_min_sum, value_note::{VALUE_NOTE_LEN, ValueNote}}; use dep::aztec::encrypted_logs::encrypted_note_emission::encode_and_encrypt_note; use dep::aztec::keys::getters::get_public_keys; -use crate::{filter::filter_notes_min_sum, value_note::{ValueNote, VALUE_NOTE_LEN}}; +use dep::aztec::note::note_getter_options::SortOrder; +use dep::aztec::prelude::{AztecAddress, NoteGetterOptions, PrivateContext, PrivateSet}; // Sort the note values (0th field) in descending order. // Pick the fewest notes whose sum is equal to or greater than `amount`. diff --git a/noir-projects/aztec-nr/value-note/src/value_note.nr b/noir-projects/aztec-nr/value-note/src/value_note.nr index 69d6cd68dbf..c243dbea25c 100644 --- a/noir-projects/aztec-nr/value-note/src/value_note.nr +++ b/noir-projects/aztec-nr/value-note/src/value_note.nr @@ -1,12 +1,16 @@ use dep::aztec::{ - protocol_types::{ - traits::Serialize, constants::GENERATOR_INDEX__NOTE_NULLIFIER, - hash::poseidon2_hash_with_separator, - }, macros::notes::note, + context::PrivateContext, + keys::getters::get_nsk_app, + macros::notes::note, note::{ note_header::NoteHeader, note_interface::NullifiableNote, utils::compute_note_hash_for_nullify, - }, oracle::random::random, keys::getters::get_nsk_app, context::PrivateContext, + }, + oracle::random::random, + protocol_types::{ + constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash_with_separator, + traits::Serialize, + }, }; global VALUE_NOTE_LEN: u32 = 3; // 3 plus a header. diff --git a/noir-projects/mock-protocol-circuits/crates/mock-private-kernel-init/src/main.nr b/noir-projects/mock-protocol-circuits/crates/mock-private-kernel-init/src/main.nr index 4721892e815..9a7b6ca0d63 100644 --- a/noir-projects/mock-protocol-circuits/crates/mock-private-kernel-init/src/main.nr +++ b/noir-projects/mock-protocol-circuits/crates/mock-private-kernel-init/src/main.nr @@ -1,5 +1,5 @@ use dep::mock_types::{ - TxRequest, PrivateKernelPublicInputs, PrivateKernelPublicInputsBuilder, AppPublicInputs, + AppPublicInputs, PrivateKernelPublicInputs, PrivateKernelPublicInputsBuilder, TxRequest, }; fn main( diff --git a/noir-projects/mock-protocol-circuits/crates/mock-private-kernel-inner/src/main.nr b/noir-projects/mock-protocol-circuits/crates/mock-private-kernel-inner/src/main.nr index db3f1b6b965..4dee3d46e75 100644 --- a/noir-projects/mock-protocol-circuits/crates/mock-private-kernel-inner/src/main.nr +++ b/noir-projects/mock-protocol-circuits/crates/mock-private-kernel-inner/src/main.nr @@ -1,4 +1,4 @@ -use dep::mock_types::{PrivateKernelPublicInputs, PrivateKernelPublicInputsBuilder, AppPublicInputs}; +use dep::mock_types::{AppPublicInputs, PrivateKernelPublicInputs, PrivateKernelPublicInputsBuilder}; fn main( prev_kernel_public_inputs: call_data(0) PrivateKernelPublicInputs, diff --git a/noir-projects/mock-protocol-circuits/crates/mock-private-kernel-reset/src/main.nr b/noir-projects/mock-protocol-circuits/crates/mock-private-kernel-reset/src/main.nr index bfe1fed3b81..6c27e065204 100644 --- a/noir-projects/mock-protocol-circuits/crates/mock-private-kernel-reset/src/main.nr +++ b/noir-projects/mock-protocol-circuits/crates/mock-private-kernel-reset/src/main.nr @@ -1,5 +1,5 @@ use dep::mock_types::{ - PrivateKernelPublicInputs, MAX_COMMITMENT_READ_REQUESTS_PER_TX, MAX_COMMITMENTS_PER_TX, + MAX_COMMITMENT_READ_REQUESTS_PER_TX, MAX_COMMITMENTS_PER_TX, PrivateKernelPublicInputs, }; // Mock reset kernel that reset read requests. diff --git a/noir-projects/mock-protocol-circuits/crates/mock-private-kernel-tail/src/main.nr b/noir-projects/mock-protocol-circuits/crates/mock-private-kernel-tail/src/main.nr index fe978c813ab..acac4a95543 100644 --- a/noir-projects/mock-protocol-circuits/crates/mock-private-kernel-tail/src/main.nr +++ b/noir-projects/mock-protocol-circuits/crates/mock-private-kernel-tail/src/main.nr @@ -1,5 +1,5 @@ use dep::mock_types::{ - PrivateKernelPublicInputs, KernelPublicInputs, MAX_COMMITMENT_READ_REQUESTS_PER_TX, + KernelPublicInputs, MAX_COMMITMENT_READ_REQUESTS_PER_TX, PrivateKernelPublicInputs, }; // The tail kernel finishes the client IVC chain exposing the final public inputs with no remaining calls or unfulfilled read requests. diff --git a/noir-projects/mock-protocol-circuits/crates/mock-public-kernel/src/main.nr b/noir-projects/mock-protocol-circuits/crates/mock-public-kernel/src/main.nr index 21db8524f23..fa619dba3b6 100644 --- a/noir-projects/mock-protocol-circuits/crates/mock-public-kernel/src/main.nr +++ b/noir-projects/mock-protocol-circuits/crates/mock-public-kernel/src/main.nr @@ -1,6 +1,6 @@ use dep::types::constants::{ - AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS, AVM_PROOF_LENGTH_IN_FIELDS, - AVM_PUBLIC_INPUTS_FLATTENED_SIZE, PROOF_TYPE_AVM, + AVM_PROOF_LENGTH_IN_FIELDS, AVM_PUBLIC_INPUTS_FLATTENED_SIZE, + AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS, PROOF_TYPE_AVM, }; fn main( diff --git a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/dapp_payload.nr b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/dapp_payload.nr index 46946dac5eb..af2919e229e 100644 --- a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/dapp_payload.nr +++ b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/dapp_payload.nr @@ -1,6 +1,7 @@ -use dep::aztec::prelude::{PrivateContext, AztecAddress}; +use dep::aztec::prelude::{AztecAddress, PrivateContext}; use dep::aztec::protocol_types::{ - constants::GENERATOR_INDEX__SIGNATURE_PAYLOAD, hash::poseidon2_hash_with_separator, + constants::GENERATOR_INDEX__SIGNATURE_PAYLOAD, + hash::poseidon2_hash_with_separator, traits::{Hash, Serialize}, }; diff --git a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/main.nr b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/main.nr index 29890944b7f..e9077096fe8 100644 --- a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/main.nr @@ -7,16 +7,17 @@ use dep::aztec::macros::aztec; contract AppSubscription { use crate::{dapp_payload::DAppPayload, subscription_note::SubscriptionNote}; + use authwit::auth::assert_current_call_valid_authwit; use aztec::{ + encrypted_logs::encrypted_note_emission::encode_and_encrypt_note, + keys::getters::get_public_keys, + macros::{functions::{initializer, private, public}, storage::storage}, prelude::{AztecAddress, Map, PrivateMutable, SharedImmutable}, - keys::getters::get_public_keys, protocol_types::constants::MAX_FIELD_VALUE, + protocol_types::constants::MAX_FIELD_VALUE, utils::comparison::Comparator, - encrypted_logs::encrypted_note_emission::encode_and_encrypt_note, - macros::{storage::storage, functions::{public, initializer, private}}, }; - use authwit::auth::assert_current_call_valid_authwit; - use token::Token; use router::utils::privately_check_block_number; + use token::Token; #[storage] struct Storage { diff --git a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/subscription_note.nr b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/subscription_note.nr index 815c512544e..c8ce2bc8184 100644 --- a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/subscription_note.nr +++ b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/subscription_note.nr @@ -1,8 +1,11 @@ use dep::aztec::{ - hash::poseidon2_hash_with_separator, note::utils::compute_note_hash_for_nullify, - keys::getters::get_nsk_app, oracle::random::random, - prelude::{PrivateContext, NoteHeader, NullifiableNote}, - protocol_types::constants::GENERATOR_INDEX__NOTE_NULLIFIER, macros::notes::note, + hash::poseidon2_hash_with_separator, + keys::getters::get_nsk_app, + macros::notes::note, + note::utils::compute_note_hash_for_nullify, + oracle::random::random, + prelude::{NoteHeader, NullifiableNote, PrivateContext}, + protocol_types::constants::GENERATOR_INDEX__NOTE_NULLIFIER, }; #[note] diff --git a/noir-projects/noir-contracts/contracts/auth_contract/src/main.nr b/noir-projects/noir-contracts/contracts/auth_contract/src/main.nr index cf5c1d9c089..e14deb2bf2e 100644 --- a/noir-projects/noir-contracts/contracts/auth_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/auth_contract/src/main.nr @@ -7,8 +7,9 @@ use dep::aztec::macros::aztec; #[aztec] contract Auth { use dep::aztec::{ - protocol_types::address::AztecAddress, state_vars::{PublicImmutable, SharedMutable}, - macros::{storage::storage, functions::{private, public, initializer, view}}, + macros::{functions::{initializer, private, public, view}, storage::storage}, + protocol_types::address::AztecAddress, + state_vars::{PublicImmutable, SharedMutable}, }; // Authorizing a new address has a certain block delay before it goes into effect. diff --git a/noir-projects/noir-contracts/contracts/auth_contract/src/test/main.nr b/noir-projects/noir-contracts/contracts/auth_contract/src/test/main.nr index 93b094faa70..12eabed0037 100644 --- a/noir-projects/noir-contracts/contracts/auth_contract/src/test/main.nr +++ b/noir-projects/noir-contracts/contracts/auth_contract/src/test/main.nr @@ -1,5 +1,5 @@ -use crate::test::utils; use crate::Auth; +use crate::test::utils; use dep::aztec::prelude::AztecAddress; diff --git a/noir-projects/noir-contracts/contracts/auth_registry_contract/src/main.nr b/noir-projects/noir-contracts/contracts/auth_registry_contract/src/main.nr index e21398eefcc..74423e063e0 100644 --- a/noir-projects/noir-contracts/contracts/auth_registry_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/auth_registry_contract/src/main.nr @@ -2,12 +2,13 @@ use dep::aztec::macros::aztec; #[aztec] contract AuthRegistry { - use dep::aztec::{ - state_vars::{PublicMutable, Map}, protocol_types::address::AztecAddress, - macros::{storage::storage, functions::{private, public, internal, view}}, - }; use dep::authwit::auth::{ - IS_VALID_SELECTOR, compute_authwit_message_hash, assert_current_call_valid_authwit, + assert_current_call_valid_authwit, compute_authwit_message_hash, IS_VALID_SELECTOR, + }; + use dep::aztec::{ + macros::{functions::{internal, private, public, view}, storage::storage}, + protocol_types::address::AztecAddress, + state_vars::{Map, PublicMutable}, }; #[storage] diff --git a/noir-projects/noir-contracts/contracts/auth_wit_test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/auth_wit_test_contract/src/main.nr index eb317769c20..c936c3d5b3c 100644 --- a/noir-projects/noir-contracts/contracts/auth_wit_test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/auth_wit_test_contract/src/main.nr @@ -2,7 +2,7 @@ use dep::aztec::macros::aztec; #[aztec] contract AuthWitTest { - use dep::aztec::{protocol_types::address::AztecAddress, macros::functions::{private, public}}; + use dep::aztec::{macros::functions::{private, public}, protocol_types::address::AztecAddress}; use dep::authwit::auth::{ assert_inner_hash_valid_authwit, assert_inner_hash_valid_authwit_public, diff --git a/noir-projects/noir-contracts/contracts/avm_initializer_test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/avm_initializer_test_contract/src/main.nr index 463e17c5030..8051e89933a 100644 --- a/noir-projects/noir-contracts/contracts/avm_initializer_test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/avm_initializer_test_contract/src/main.nr @@ -4,7 +4,8 @@ use dep::aztec::macros::aztec; contract AvmInitializerTest { // Libs use dep::aztec::{ - state_vars::PublicImmutable, macros::{storage::storage, functions::{initializer, public}}, + macros::{functions::{initializer, public}, storage::storage}, + state_vars::PublicImmutable, }; #[storage] diff --git a/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr index ff31737f6ab..ee524904896 100644 --- a/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr @@ -1,4 +1,4 @@ -use dep::aztec::protocol_types::traits::{Serialize, Deserialize}; +use dep::aztec::protocol_types::traits::{Deserialize, Serialize}; pub struct Note { a: Field, @@ -29,22 +29,24 @@ contract AvmTest { 0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef; // Libs - use std::embedded_curve_ops::{multi_scalar_mul, EmbeddedCurvePoint}; - use dep::aztec::protocol_types::constants::CONTRACT_INSTANCE_LENGTH; - use dep::aztec::prelude::Map; - use dep::aztec::state_vars::PublicMutable; - use dep::aztec::protocol_types::{ - address::{AztecAddress, EthAddress}, point::Point, scalar::Scalar, - }; + use dep::aztec::context::gas::GasOpts; + use dep::aztec::macros::{functions::{private, public}, storage::storage}; use dep::aztec::oracle::get_contract_instance::{ get_contract_instance_avm, get_contract_instance_internal_avm, }; + use dep::aztec::prelude::Map; use dep::aztec::protocol_types::{ abis::function_selector::FunctionSelector, storage::map::derive_storage_slot_in_map, }; + use dep::aztec::protocol_types::{ + address::{AztecAddress, EthAddress}, + point::Point, + scalar::Scalar, + }; + use dep::aztec::protocol_types::constants::CONTRACT_INSTANCE_LENGTH; + use dep::aztec::state_vars::PublicMutable; use dep::compressed_string::CompressedString; - use dep::aztec::macros::{storage::storage, functions::{public, private}}; - use dep::aztec::context::gas::GasOpts; + use std::embedded_curve_ops::{EmbeddedCurvePoint, multi_scalar_mul}; #[storage] struct Storage { diff --git a/noir-projects/noir-contracts/contracts/benchmarking_contract/src/main.nr b/noir-projects/noir-contracts/contracts/benchmarking_contract/src/main.nr index 2116a55fa3a..436617354af 100644 --- a/noir-projects/noir-contracts/contracts/benchmarking_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/benchmarking_contract/src/main.nr @@ -7,10 +7,10 @@ use dep::aztec::macros::aztec; #[aztec] contract Benchmarking { - use dep::aztec::prelude::{AztecAddress, NoteGetterOptions, Map, PublicMutable, PrivateSet}; + use dep::aztec::prelude::{AztecAddress, Map, NoteGetterOptions, PrivateSet, PublicMutable}; use dep::value_note::{utils::increment, value_note::ValueNote}; - use dep::aztec::macros::{storage::storage, functions::{private, public}}; + use dep::aztec::macros::{functions::{private, public}, storage::storage}; #[storage] struct Storage { diff --git a/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr b/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr index ded14bb8b76..e68d155be82 100644 --- a/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr +++ b/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr @@ -1,11 +1,15 @@ -use dep::aztec::prelude::{AztecAddress, PrivateContext, NoteGetterOptions, NoteViewerOptions}; +use dep::aztec::prelude::{AztecAddress, NoteGetterOptions, NoteViewerOptions, PrivateContext}; use dep::aztec::{ context::UnconstrainedContext, + encrypted_logs::encrypted_note_emission::encode_and_encrypt_note, + keys::getters::get_public_keys, + note::constants::MAX_NOTES_PER_PAGE, protocol_types::{ - traits::{ToField, Serialize, FromField}, constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, - }, encrypted_logs::encrypted_note_emission::encode_and_encrypt_note, - keys::getters::get_public_keys, state_vars::PrivateSet, note::constants::MAX_NOTES_PER_PAGE, + constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, + traits::{FromField, Serialize, ToField}, + }, + state_vars::PrivateSet, }; use dep::value_note::value_note::ValueNote; diff --git a/noir-projects/noir-contracts/contracts/card_game_contract/src/game.nr b/noir-projects/noir-contracts/contracts/card_game_contract/src/game.nr index 01991ddf74d..436e102d6d5 100644 --- a/noir-projects/noir-contracts/contracts/card_game_contract/src/game.nr +++ b/noir-projects/noir-contracts/contracts/card_game_contract/src/game.nr @@ -1,5 +1,5 @@ -use dep::aztec::protocol_types::{address::AztecAddress, traits::{Serialize, Deserialize}}; use crate::cards::Card; +use dep::aztec::protocol_types::{address::AztecAddress, traits::{Deserialize, Serialize}}; global NUMBER_OF_PLAYERS: u32 = 2; global NUMBER_OF_CARDS_DECK: u32 = 2; diff --git a/noir-projects/noir-contracts/contracts/card_game_contract/src/main.nr b/noir-projects/noir-contracts/contracts/card_game_contract/src/main.nr index 2cdb926ac63..325b5b11937 100644 --- a/noir-projects/noir-contracts/contracts/card_game_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/card_game_contract/src/main.nr @@ -5,14 +5,14 @@ use dep::aztec::macros::aztec; #[aztec] contract CardGame { - use dep::aztec::protocol_types::address::AztecAddress; use dep::aztec::{hash::pedersen_hash, state_vars::{Map, PublicMutable}}; + use dep::aztec::protocol_types::address::AztecAddress; use dep::aztec::note::constants::MAX_NOTES_PER_PAGE; - use crate::cards::{Deck, Card, get_pack_cards, compute_deck_strength}; - use crate::game::{PLAYABLE_CARDS, PlayerEntry, Game}; - use dep::aztec::macros::{storage::storage, functions::{private, public, internal}}; + use crate::cards::{Card, compute_deck_strength, Deck, get_pack_cards}; + use crate::game::{Game, PLAYABLE_CARDS, PlayerEntry}; + use dep::aztec::macros::{functions::{internal, private, public}, storage::storage}; #[storage] struct Storage { diff --git a/noir-projects/noir-contracts/contracts/child_contract/src/main.nr b/noir-projects/noir-contracts/contracts/child_contract/src/main.nr index 7e97d112e5f..178516f0e9b 100644 --- a/noir-projects/noir-contracts/contracts/child_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/child_contract/src/main.nr @@ -3,13 +3,14 @@ use dep::aztec::macros::aztec; #[aztec] contract Child { - use dep::aztec::prelude::{AztecAddress, PublicMutable, PrivateSet, Map}; + use dep::aztec::prelude::{AztecAddress, Map, PrivateSet, PublicMutable}; use dep::aztec::{ - note::note_getter_options::NoteGetterOptions, encrypted_logs::encrypted_note_emission::encode_and_encrypt_note, - keys::getters::get_public_keys, utils::comparison::Comparator, - macros::{storage::storage, functions::{private, public, internal}}, + keys::getters::get_public_keys, + macros::{functions::{internal, private, public}, storage::storage}, + note::note_getter_options::NoteGetterOptions, + utils::comparison::Comparator, }; use dep::value_note::value_note::ValueNote; diff --git a/noir-projects/noir-contracts/contracts/claim_contract/src/main.nr b/noir-projects/noir-contracts/contracts/claim_contract/src/main.nr index 0d7259d168c..668c2c86e31 100644 --- a/noir-projects/noir-contracts/contracts/claim_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/claim_contract/src/main.nr @@ -3,9 +3,10 @@ use dep::aztec::macros::aztec; #[aztec] contract Claim { use dep::aztec::{ - note::utils::compute_note_hash_for_nullify, protocol_types::address::AztecAddress, + macros::{functions::{initializer, private, public}, storage::storage}, + note::utils::compute_note_hash_for_nullify, + protocol_types::address::AztecAddress, state_vars::SharedImmutable, - macros::{storage::storage, functions::{private, public, initializer}}, }; use dep::value_note::value_note::ValueNote; use token::Token; diff --git a/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/class_registered.nr b/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/class_registered.nr index f89db47b7bd..3a5e11515ed 100644 --- a/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/class_registered.nr +++ b/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/class_registered.nr @@ -1,8 +1,9 @@ use dep::aztec::protocol_types::{ - contract_class_id::ContractClassId, constants::{ MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS, REGISTERER_CONTRACT_CLASS_REGISTERED_MAGIC_VALUE, - }, traits::Serialize, + }, + contract_class_id::ContractClassId, + traits::Serialize, }; // #[event] diff --git a/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/private_function_broadcasted.nr b/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/private_function_broadcasted.nr index 7a542059f9b..8ffcef81f51 100644 --- a/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/private_function_broadcasted.nr +++ b/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/private_function_broadcasted.nr @@ -1,12 +1,13 @@ use dep::aztec::prelude::FunctionSelector; use dep::aztec::protocol_types::{ - contract_class_id::ContractClassId, constants::{ - FUNCTION_TREE_HEIGHT, ARTIFACT_FUNCTION_TREE_MAX_HEIGHT, + ARTIFACT_FUNCTION_TREE_MAX_HEIGHT, FUNCTION_TREE_HEIGHT, MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS, - REGISTERER_PRIVATE_FUNCTION_BROADCASTED_MAGIC_VALUE, REGISTERER_PRIVATE_FUNCTION_BROADCASTED_ADDITIONAL_FIELDS, - }, traits::Serialize, + REGISTERER_PRIVATE_FUNCTION_BROADCASTED_MAGIC_VALUE, + }, + contract_class_id::ContractClassId, + traits::Serialize, }; pub struct InnerPrivateFunction { diff --git a/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/unconstrained_function_broadcasted.nr b/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/unconstrained_function_broadcasted.nr index d2a9995d8ed..f81da27fb8c 100644 --- a/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/unconstrained_function_broadcasted.nr +++ b/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/events/unconstrained_function_broadcasted.nr @@ -1,12 +1,13 @@ use dep::aztec::prelude::FunctionSelector; use dep::aztec::protocol_types::{ - contract_class_id::ContractClassId, constants::{ ARTIFACT_FUNCTION_TREE_MAX_HEIGHT, MAX_PACKED_BYTECODE_SIZE_PER_UNCONSTRAINED_FUNCTION_IN_FIELDS, - REGISTERER_UNCONSTRAINED_FUNCTION_BROADCASTED_MAGIC_VALUE, REGISTERER_UNCONSTRAINED_FUNCTION_BROADCASTED_ADDITIONAL_FIELDS, - }, traits::Serialize, + REGISTERER_UNCONSTRAINED_FUNCTION_BROADCASTED_MAGIC_VALUE, + }, + contract_class_id::ContractClassId, + traits::Serialize, }; pub struct InnerUnconstrainedFunction { diff --git a/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr b/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr index 4a20582ea6e..f268b7d3318 100644 --- a/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr @@ -6,28 +6,29 @@ use dep::aztec::macros::aztec; #[aztec] contract ContractClassRegisterer { use dep::aztec::protocol_types::{ - contract_class_id::ContractClassId, + abis::log_hash::LogHash, constants::{ ARTIFACT_FUNCTION_TREE_MAX_HEIGHT, FUNCTION_TREE_HEIGHT, MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS, MAX_PACKED_BYTECODE_SIZE_PER_UNCONSTRAINED_FUNCTION_IN_FIELDS, MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS, - }, abis::log_hash::LogHash, + }, + contract_class_id::ContractClassId, }; use dep::aztec::{ - context::PrivateContext, oracle::logs::emit_contract_class_unencrypted_log_private, - macros::functions::private, + context::PrivateContext, macros::functions::private, + oracle::logs::emit_contract_class_unencrypted_log_private, }; use crate::events::{ class_registered::ContractClassRegistered, private_function_broadcasted::{ - ClassPrivateFunctionBroadcasted, PrivateFunction, InnerPrivateFunction, + ClassPrivateFunctionBroadcasted, InnerPrivateFunction, PrivateFunction, }, unconstrained_function_broadcasted::{ - ClassUnconstrainedFunctionBroadcasted, UnconstrainedFunction, - InnerUnconstrainedFunction, + ClassUnconstrainedFunctionBroadcasted, InnerUnconstrainedFunction, + UnconstrainedFunction, }, }; diff --git a/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/main.nr b/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/main.nr index 6ffb083f264..51a883bdc4c 100644 --- a/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/main.nr @@ -2,16 +2,20 @@ use dep::aztec::macros::aztec; #[aztec] contract ContractInstanceDeployer { + use dep::aztec::{ + hash::compute_unencrypted_log_hash, + macros::{events::event, functions::private}, + oracle::logs::emit_unencrypted_log_private, + utils::to_bytes::arr_to_be_bytes_arr, + }; use dep::aztec::protocol_types::{ - address::{AztecAddress, PublicKeysHash, PartialAddress}, public_keys::PublicKeys, + abis::log_hash::LogHash, + address::{AztecAddress, PartialAddress, PublicKeysHash}, + constants::DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE, contract_class_id::ContractClassId, - constants::DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE, abis::log_hash::LogHash, + public_keys::PublicKeys, traits::Serialize, }; - use dep::aztec::{ - hash::compute_unencrypted_log_hash, oracle::logs::emit_unencrypted_log_private, - macros::{events::event, functions::private}, utils::to_bytes::arr_to_be_bytes_arr, - }; use std::meta::derive; #[event] diff --git a/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr b/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr index ba0824ab138..965de3140a5 100644 --- a/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr @@ -5,10 +5,10 @@ use dep::aztec::macros::aztec; contract Counter { // docs:end:setup // docs:start:imports + use aztec::macros::{functions::{initializer, private}, storage::storage}; use aztec::prelude::{AztecAddress, Map}; - use value_note::{balance_utils, value_note::ValueNote}; use easy_private_state::EasyPrivateUint; - use aztec::macros::{storage::storage, functions::{initializer, private}}; + use value_note::{balance_utils, value_note::ValueNote}; // docs:end:imports // docs:start:storage_struct @@ -49,10 +49,10 @@ contract Counter { // docs:end:get_counter // docs:start:test_imports - use dep::aztec::test::helpers::{cheatcodes, test_environment::TestEnvironment}; - use dep::aztec::protocol_types::storage::map::derive_storage_slot_in_map; use dep::aztec::note::note_getter::{MAX_NOTES_PER_PAGE, view_notes}; use dep::aztec::note::note_viewer_options::NoteViewerOptions; + use dep::aztec::protocol_types::storage::map::derive_storage_slot_in_map; + use dep::aztec::test::helpers::{cheatcodes, test_environment::TestEnvironment}; // docs:end:test_imports // docs:start:txe_test_increment #[test] diff --git a/noir-projects/noir-contracts/contracts/crowdfunding_contract/src/main.nr b/noir-projects/noir-contracts/contracts/crowdfunding_contract/src/main.nr index a2304487c59..654ca2e39c1 100644 --- a/noir-projects/noir-contracts/contracts/crowdfunding_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/crowdfunding_contract/src/main.nr @@ -8,18 +8,23 @@ contract Crowdfunding { // docs:start:all-deps use dep::aztec::{ encrypted_logs::encrypted_note_emission::encode_and_encrypt_note, - keys::getters::get_public_keys, prelude::{AztecAddress, PrivateSet, SharedImmutable}, - utils::comparison::Comparator, unencrypted_logs::unencrypted_event_emission::encode_event, + keys::getters::get_public_keys, macros::{ - storage::storage, events::event, functions::{public, initializer, private, internal}, - }, protocol_types::traits::Serialize, + events::event, + functions::{initializer, internal, private, public}, + storage::storage, + }, + prelude::{AztecAddress, PrivateSet, SharedImmutable}, + protocol_types::traits::Serialize, + unencrypted_logs::unencrypted_event_emission::encode_event, + utils::comparison::Comparator, }; use std::meta::derive; // docs:start:import_valuenote use dep::value_note::value_note::ValueNote; // docs:end:import_valuenote - use token::Token; use router::utils::privately_check_timestamp; + use token::Token; // docs:end:all-deps #[event] diff --git a/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr b/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr index fd3e0194d57..fde9a5d7fca 100644 --- a/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr @@ -16,14 +16,14 @@ use dep::aztec::macros::aztec; #[aztec] contract DocsExample { // how to import dependencies defined in your workspace - use dep::aztec::prelude::{ - AztecAddress, NoteViewerOptions, PrivateContext, Map, PublicMutable, PublicImmutable, - PrivateMutable, PrivateImmutable, PrivateSet, SharedImmutable, - }; use dep::aztec::{ encrypted_logs::encrypted_note_emission::encode_and_encrypt_note, keys::getters::get_public_keys, - macros::{storage::{storage, storage_no_init}, functions::{public, private, internal, view}}, + macros::{functions::{internal, private, public, view}, storage::{storage, storage_no_init}}, + }; + use dep::aztec::prelude::{ + AztecAddress, Map, NoteViewerOptions, PrivateContext, PrivateImmutable, PrivateMutable, + PrivateSet, PublicImmutable, PublicMutable, SharedImmutable, }; // how to import methods from other files/folders within your workspace diff --git a/noir-projects/noir-contracts/contracts/docs_example_contract/src/options.nr b/noir-projects/noir-contracts/contracts/docs_example_contract/src/options.nr index 928e5fbf71a..cdeea999865 100644 --- a/noir-projects/noir-contracts/contracts/docs_example_contract/src/options.nr +++ b/noir-projects/noir-contracts/contracts/docs_example_contract/src/options.nr @@ -1,8 +1,8 @@ use crate::types::card_note::{CARD_NOTE_LEN, CardNote}; use dep::aztec::prelude::NoteGetterOptions; -use dep::aztec::protocol_types::constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL; use dep::aztec::{note::note_getter_options::SortOrder, utils::comparison::Comparator}; +use dep::aztec::protocol_types::constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL; // Shows how to use NoteGetterOptions and query for notes. diff --git a/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr b/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr index c1d2fbf4e95..219a098ac06 100644 --- a/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr +++ b/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr @@ -1,11 +1,13 @@ -use dep::aztec::prelude::{NullifiableNote, PrivateContext, NoteHeader}; use dep::aztec::{ - note::utils::compute_note_hash_for_nullify, keys::getters::get_nsk_app, + keys::getters::get_nsk_app, + macros::notes::note, + note::utils::compute_note_hash_for_nullify, protocol_types::{ - traits::Serialize, constants::GENERATOR_INDEX__NOTE_NULLIFIER, - hash::poseidon2_hash_with_separator, - }, macros::notes::note, + constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash_with_separator, + traits::Serialize, + }, }; +use dep::aztec::prelude::{NoteHeader, NullifiableNote, PrivateContext}; // docs:start:state_vars-CardNote global CARD_NOTE_LEN: u32 = 3; // 3 plus a header. diff --git a/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/leader.nr b/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/leader.nr index 1c6dbf021b4..485ccf634c2 100644 --- a/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/leader.nr +++ b/noir-projects/noir-contracts/contracts/docs_example_contract/src/types/leader.nr @@ -1,4 +1,4 @@ -use dep::aztec::protocol_types::{address::AztecAddress, traits::{Serialize, Deserialize}}; +use dep::aztec::protocol_types::{address::AztecAddress, traits::{Deserialize, Serialize}}; // Shows how to create a custom struct in Public pub struct Leader { diff --git a/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr b/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr index e2a94ae71ee..0544a592f73 100644 --- a/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr @@ -3,10 +3,10 @@ use dep::aztec::macros::aztec; #[aztec] contract EasyPrivateToken { + use dep::aztec::macros::{functions::{initializer, private}, storage::storage}; use dep::aztec::prelude::{AztecAddress, Map}; - use dep::value_note::balance_utils; use dep::easy_private_state::EasyPrivateUint; - use dep::aztec::macros::{storage::storage, functions::{initializer, private}}; + use dep::value_note::balance_utils; #[storage] struct Storage { diff --git a/noir-projects/noir-contracts/contracts/easy_private_voting_contract/src/main.nr b/noir-projects/noir-contracts/contracts/easy_private_voting_contract/src/main.nr index 5e0b77265fe..31e1a32ed95 100644 --- a/noir-projects/noir-contracts/contracts/easy_private_voting_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/easy_private_voting_contract/src/main.nr @@ -3,11 +3,11 @@ use dep::aztec::macros::aztec; #[aztec] contract EasyPrivateVoting { // docs:start:imports - use dep::aztec::prelude::{AztecAddress, Map, PublicMutable, SharedImmutable}; use dep::aztec::{ keys::getters::get_public_keys, - macros::{storage::storage, functions::{public, initializer, private, internal}}, + macros::{functions::{initializer, internal, private, public}, storage::storage}, }; + use dep::aztec::prelude::{AztecAddress, Map, PublicMutable, SharedImmutable}; // docs:end:imports // docs:start:storage_struct #[storage] diff --git a/noir-projects/noir-contracts/contracts/ecdsa_k_account_contract/src/main.nr b/noir-projects/noir-contracts/contracts/ecdsa_k_account_contract/src/main.nr index 1e6fe084acb..3c7ad72c92d 100644 --- a/noir-projects/noir-contracts/contracts/ecdsa_k_account_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/ecdsa_k_account_contract/src/main.nr @@ -4,16 +4,17 @@ use dep::aztec::macros::aztec; #[aztec] contract EcdsaKAccount { - use dep::aztec::prelude::{PrivateContext, PrivateImmutable}; use dep::aztec::{ encrypted_logs::encrypted_note_emission::encode_and_encrypt_note, keys::getters::get_public_keys, - macros::{storage::storage, functions::{private, initializer, view, noinitcheck}}, + macros::{functions::{initializer, noinitcheck, private, view}, storage::storage}, }; + use dep::aztec::prelude::{PrivateContext, PrivateImmutable}; use dep::authwit::{ - entrypoint::{app::AppPayload, fee::FeePayload}, account::AccountActions, + account::AccountActions, auth_witness::get_auth_witness, + entrypoint::{app::AppPayload, fee::FeePayload}, }; use dep::ecdsa_public_key_note::EcdsaPublicKeyNote; diff --git a/noir-projects/noir-contracts/contracts/ecdsa_r_account_contract/src/main.nr b/noir-projects/noir-contracts/contracts/ecdsa_r_account_contract/src/main.nr index bf47165081e..c166ef2aa9c 100644 --- a/noir-projects/noir-contracts/contracts/ecdsa_r_account_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/ecdsa_r_account_contract/src/main.nr @@ -3,16 +3,17 @@ use dep::aztec::macros::aztec; #[aztec] contract EcdsaRAccount { - use dep::aztec::prelude::{PrivateContext, PrivateImmutable}; use dep::aztec::{ encrypted_logs::encrypted_note_emission::encode_and_encrypt_note, keys::getters::get_public_keys, - macros::{storage::storage, functions::{private, initializer, view, noinitcheck}}, + macros::{functions::{initializer, noinitcheck, private, view}, storage::storage}, }; + use dep::aztec::prelude::{PrivateContext, PrivateImmutable}; use dep::authwit::{ - entrypoint::{app::AppPayload, fee::FeePayload}, account::AccountActions, + account::AccountActions, auth_witness::get_auth_witness, + entrypoint::{app::AppPayload, fee::FeePayload}, }; use dep::ecdsa_public_key_note::EcdsaPublicKeyNote; diff --git a/noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr b/noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr index 59fd82197f7..e2227112978 100644 --- a/noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr @@ -3,12 +3,12 @@ use dep::aztec::macros::aztec; #[aztec] contract Escrow { - use dep::aztec::prelude::{AztecAddress, PrivateImmutable}; use dep::aztec::{ encrypted_logs::encrypted_note_emission::encode_and_encrypt_note, keys::getters::get_public_keys, - macros::{storage::storage, functions::{private, initializer}}, + macros::{functions::{initializer, private}, storage::storage}, }; + use dep::aztec::prelude::{AztecAddress, PrivateImmutable}; // docs:start:addressnote_import use dep::address_note::address_note::AddressNote; diff --git a/noir-projects/noir-contracts/contracts/fee_juice_contract/src/lib.nr b/noir-projects/noir-contracts/contracts/fee_juice_contract/src/lib.nr index 9eaea655015..6f77d74b16e 100644 --- a/noir-projects/noir-contracts/contracts/fee_juice_contract/src/lib.nr +++ b/noir-projects/noir-contracts/contracts/fee_juice_contract/src/lib.nr @@ -1,5 +1,5 @@ -use dep::aztec::prelude::AztecAddress; use dep::aztec::context::PublicContext; +use dep::aztec::prelude::AztecAddress; use dep::aztec::protocol_types::hash::sha256_to_field; pub fn calculate_fee(context: PublicContext) -> Field { diff --git a/noir-projects/noir-contracts/contracts/fee_juice_contract/src/main.nr b/noir-projects/noir-contracts/contracts/fee_juice_contract/src/main.nr index 2f4129a84de..3f0cdbaa78e 100644 --- a/noir-projects/noir-contracts/contracts/fee_juice_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/fee_juice_contract/src/main.nr @@ -5,9 +5,9 @@ use dep::aztec::macros::aztec; #[aztec] contract FeeJuice { use dep::aztec::{ + macros::{functions::{internal, private, public, view}, storage::storage}, protocol_types::{address::{AztecAddress, EthAddress}, constants::FEE_JUICE_INITIAL_MINT}, - state_vars::{SharedImmutable, PublicMutable, Map}, - macros::{storage::storage, functions::{private, public, view, internal}}, + state_vars::{Map, PublicMutable, SharedImmutable}, }; use crate::lib::get_bridge_gas_msg_hash; diff --git a/noir-projects/noir-contracts/contracts/fpc_contract/src/main.nr b/noir-projects/noir-contracts/contracts/fpc_contract/src/main.nr index 7b3900f8c4e..708f24fe0b8 100644 --- a/noir-projects/noir-contracts/contracts/fpc_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/fpc_contract/src/main.nr @@ -4,13 +4,13 @@ use dep::aztec::macros::aztec; #[aztec] contract FPC { + use crate::lib::compute_rebate; use dep::aztec::{ + macros::{functions::{initializer, internal, private, public}, storage::storage}, protocol_types::{abis::function_selector::FunctionSelector, address::AztecAddress}, state_vars::SharedImmutable, - macros::{storage::storage, functions::{private, public, initializer, internal}}, }; use dep::token::Token; - use crate::lib::compute_rebate; #[storage] struct Storage { diff --git a/noir-projects/noir-contracts/contracts/import_test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/import_test_contract/src/main.nr index 3a3b7ec8b68..e608bf58c02 100644 --- a/noir-projects/noir-contracts/contracts/import_test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/import_test_contract/src/main.nr @@ -6,7 +6,7 @@ use dep::aztec::macros::aztec; contract ImportTest { use dep::aztec::prelude::AztecAddress; - use dep::test::{Test, Test::DeepStruct, Test::DummyNote}; + use dep::test::Test::{self, DeepStruct, DummyNote}; use dep::aztec::macros::functions::{private, public}; diff --git a/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr b/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr index 2c96b03771b..18b76fbca92 100644 --- a/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr @@ -3,15 +3,15 @@ use dep::aztec::macros::aztec; #[aztec] contract InclusionProofs { - use dep::aztec::prelude::{AztecAddress, NoteGetterOptions, Map, PrivateSet, PublicMutable}; use dep::aztec::{ encrypted_logs::encrypted_note_emission::encode_and_encrypt_note, keys::getters::get_public_keys, }; + use dep::aztec::prelude::{AztecAddress, Map, NoteGetterOptions, PrivateSet, PublicMutable}; use dep::aztec::{ + macros::{functions::{initializer, private, public}, storage::storage}, note::note_getter_options::NoteStatus, - macros::{storage::storage, functions::{private, public, initializer}}, }; // docs:start:value_note_imports use dep::value_note::value_note::ValueNote; diff --git a/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr b/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr index 3066eb5b04b..077be6fea40 100644 --- a/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr @@ -17,14 +17,15 @@ contract Lending { use dep::aztec::prelude::{AztecAddress, Map, PublicMutable}; use crate::asset::Asset; - use crate::position::Position; + use crate::helpers::{compute_identifier, covered_by_collateral, debt_updates, debt_value}; use crate::interest_math::compute_multiplier; - use crate::helpers::{covered_by_collateral, debt_updates, debt_value, compute_identifier}; - use dep::token::Token; + use crate::position::Position; use dep::price_feed::PriceFeed; + use dep::token::Token; use dep::aztec::macros::{ - storage::storage, functions::{private, public, initializer, internal, view}, + functions::{initializer, internal, private, public, view}, + storage::storage, }; // Storage structure, containing all storage, and specifying what slots they use. diff --git a/noir-projects/noir-contracts/contracts/nft_contract/src/main.nr b/noir-projects/noir-contracts/contracts/nft_contract/src/main.nr index bdab2dac015..f5d83db36a4 100644 --- a/noir-projects/noir-contracts/contracts/nft_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/nft_contract/src/main.nr @@ -7,29 +7,33 @@ use dep::aztec::macros::aztec; // and private. #[aztec] contract NFT { - use dep::compressed_string::FieldCompressedString; + use crate::types::nft_note::NFTNote; + use dep::authwit::auth::{ + assert_current_call_valid_authwit, assert_current_call_valid_authwit_public, + compute_authwit_nullifier, + }; use dep::aztec::{ - oracle::random::random, - prelude::{ - NoteGetterOptions, NoteViewerOptions, Map, PublicMutable, SharedImmutable, PrivateSet, - AztecAddress, PrivateContext, PublicContext, - }, encrypted_logs::encrypted_note_emission::{ encode_and_encrypt_note, encrypt_and_emit_partial_log, - }, hash::pedersen_hash, keys::getters::get_public_keys, note::constants::MAX_NOTES_PER_PAGE, - protocol_types::traits::is_empty, utils::comparison::Comparator, - protocol_types::{point::Point, traits::Serialize}, + }, + hash::pedersen_hash, + keys::getters::get_public_keys, macros::{ - storage::storage, events::event, - functions::{private, public, view, internal, initializer}, + events::event, + functions::{initializer, internal, private, public, view}, + storage::storage, }, + note::constants::MAX_NOTES_PER_PAGE, + oracle::random::random, + prelude::{ + AztecAddress, Map, NoteGetterOptions, NoteViewerOptions, PrivateContext, PrivateSet, + PublicContext, PublicMutable, SharedImmutable, + }, + protocol_types::{point::Point, traits::{is_empty, Serialize}}, + utils::comparison::Comparator, }; - use dep::authwit::auth::{ - assert_current_call_valid_authwit, assert_current_call_valid_authwit_public, - compute_authwit_nullifier, - }; + use dep::compressed_string::FieldCompressedString; use std::{embedded_curve_ops::EmbeddedCurvePoint, meta::derive}; - use crate::types::nft_note::NFTNote; // TODO(#8467): Rename this to Transfer - calling this NFTTransfer to avoid export conflict with the Transfer event // in the Token contract. diff --git a/noir-projects/noir-contracts/contracts/nft_contract/src/test/access_control.nr b/noir-projects/noir-contracts/contracts/nft_contract/src/test/access_control.nr index e787bf643cb..fef5a236372 100644 --- a/noir-projects/noir-contracts/contracts/nft_contract/src/test/access_control.nr +++ b/noir-projects/noir-contracts/contracts/nft_contract/src/test/access_control.nr @@ -1,5 +1,5 @@ -use crate::test::utils; use crate::NFT; +use crate::test::utils; #[test] unconstrained fn access_control() { diff --git a/noir-projects/noir-contracts/contracts/nft_contract/src/test/minting.nr b/noir-projects/noir-contracts/contracts/nft_contract/src/test/minting.nr index 79730309e9a..cc9d12e24dd 100644 --- a/noir-projects/noir-contracts/contracts/nft_contract/src/test/minting.nr +++ b/noir-projects/noir-contracts/contracts/nft_contract/src/test/minting.nr @@ -1,5 +1,5 @@ -use crate::test::utils; use crate::NFT; +use crate::test::utils; #[test] unconstrained fn mint_success() { diff --git a/noir-projects/noir-contracts/contracts/nft_contract/src/test/transfer_in_private.nr b/noir-projects/noir-contracts/contracts/nft_contract/src/test/transfer_in_private.nr index d80a77b38f1..63022cc57a0 100644 --- a/noir-projects/noir-contracts/contracts/nft_contract/src/test/transfer_in_private.nr +++ b/noir-projects/noir-contracts/contracts/nft_contract/src/test/transfer_in_private.nr @@ -1,8 +1,8 @@ +use crate::NFT; use crate::test::utils; +use dep::authwit::cheatcodes as authwit_cheatcodes; use dep::aztec::test::helpers::cheatcodes; use aztec::oracle::random::random; -use dep::authwit::cheatcodes as authwit_cheatcodes; -use crate::NFT; #[test] unconstrained fn transfer_in_private() { diff --git a/noir-projects/noir-contracts/contracts/nft_contract/src/test/transfer_in_public.nr b/noir-projects/noir-contracts/contracts/nft_contract/src/test/transfer_in_public.nr index b5fb7c59698..d64c5180461 100644 --- a/noir-projects/noir-contracts/contracts/nft_contract/src/test/transfer_in_public.nr +++ b/noir-projects/noir-contracts/contracts/nft_contract/src/test/transfer_in_public.nr @@ -1,7 +1,7 @@ +use crate::NFT; use crate::test::utils; -use dep::aztec::oracle::random::random; use dep::authwit::cheatcodes as authwit_cheatcodes; -use crate::NFT; +use dep::aztec::oracle::random::random; #[test] unconstrained fn transfer_in_public() { diff --git a/noir-projects/noir-contracts/contracts/nft_contract/src/test/transfer_to_private.nr b/noir-projects/noir-contracts/contracts/nft_contract/src/test/transfer_to_private.nr index 9d48bdb4977..e70b66e8ab6 100644 --- a/noir-projects/noir-contracts/contracts/nft_contract/src/test/transfer_to_private.nr +++ b/noir-projects/noir-contracts/contracts/nft_contract/src/test/transfer_to_private.nr @@ -1,6 +1,8 @@ -use crate::{test::utils, types::nft_note::NFTNote, NFT}; +use crate::{NFT, test::utils, types::nft_note::NFTNote}; use dep::aztec::{ - keys::getters::get_public_keys, prelude::{AztecAddress, NoteHeader}, oracle::random::random, + keys::getters::get_public_keys, + oracle::random::random, + prelude::{AztecAddress, NoteHeader}, protocol_types::storage::map::derive_storage_slot_in_map, }; use std::test::OracleMock; diff --git a/noir-projects/noir-contracts/contracts/nft_contract/src/test/transfer_to_public.nr b/noir-projects/noir-contracts/contracts/nft_contract/src/test/transfer_to_public.nr index b386a4c0454..0dbec15b255 100644 --- a/noir-projects/noir-contracts/contracts/nft_contract/src/test/transfer_to_public.nr +++ b/noir-projects/noir-contracts/contracts/nft_contract/src/test/transfer_to_public.nr @@ -1,7 +1,7 @@ +use crate::NFT; use crate::test::utils; -use dep::aztec::oracle::random::random; use dep::authwit::cheatcodes as authwit_cheatcodes; -use crate::NFT; +use dep::aztec::oracle::random::random; #[test] unconstrained fn transfer_to_public() { diff --git a/noir-projects/noir-contracts/contracts/nft_contract/src/test/utils.nr b/noir-projects/noir-contracts/contracts/nft_contract/src/test/utils.nr index bd4829003eb..429844e7f59 100644 --- a/noir-projects/noir-contracts/contracts/nft_contract/src/test/utils.nr +++ b/noir-projects/noir-contracts/contracts/nft_contract/src/test/utils.nr @@ -1,11 +1,15 @@ -use crate::{types::nft_note::NFTNote, NFT}; +use crate::{NFT, types::nft_note::NFTNote}; use dep::aztec::{ - hash::pedersen_hash, keys::getters::get_public_keys, prelude::{AztecAddress, NoteHeader}, - test::helpers::{cheatcodes, test_environment::TestEnvironment}, - protocol_types::storage::map::derive_storage_slot_in_map, + hash::pedersen_hash, + keys::getters::get_public_keys, oracle::{ - execution::{get_block_number, get_contract_address}, random::random, storage::storage_read, + execution::{get_block_number, get_contract_address}, + random::random, + storage::storage_read, }, + prelude::{AztecAddress, NoteHeader}, + protocol_types::storage::map::derive_storage_slot_in_map, + test::helpers::{cheatcodes, test_environment::TestEnvironment}, }; use std::test::OracleMock; diff --git a/noir-projects/noir-contracts/contracts/nft_contract/src/types/nft_note.nr b/noir-projects/noir-contracts/contracts/nft_contract/src/types/nft_note.nr index 9fd3bd2afff..e055e32c983 100644 --- a/noir-projects/noir-contracts/contracts/nft_contract/src/types/nft_note.nr +++ b/noir-projects/noir-contracts/contracts/nft_contract/src/types/nft_note.nr @@ -1,10 +1,14 @@ use dep::aztec::{ - note::utils::compute_note_hash_for_nullify, keys::getters::get_nsk_app, oracle::random::random, - prelude::{NullifiableNote, NoteHeader, PrivateContext}, + keys::getters::get_nsk_app, + macros::notes::partial_note, + note::utils::compute_note_hash_for_nullify, + oracle::random::random, + prelude::{NoteHeader, NullifiableNote, PrivateContext}, protocol_types::{ - constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash_with_separator, + constants::GENERATOR_INDEX__NOTE_NULLIFIER, + hash::poseidon2_hash_with_separator, traits::{Empty, Eq}, - }, macros::notes::partial_note, + }, }; #[partial_note(quote { token_id})] diff --git a/noir-projects/noir-contracts/contracts/parent_contract/src/main.nr b/noir-projects/noir-contracts/contracts/parent_contract/src/main.nr index 141e2ad10f8..b586f73b956 100644 --- a/noir-projects/noir-contracts/contracts/parent_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/parent_contract/src/main.nr @@ -3,8 +3,8 @@ use dep::aztec::macros::aztec; #[aztec] contract Parent { - use dep::aztec::prelude::{AztecAddress, FunctionSelector}; use dep::aztec::{context::gas::GasOpts, macros::functions::{private, public}}; + use dep::aztec::prelude::{AztecAddress, FunctionSelector}; // Private function to call another private function in the target_contract using the provided selector #[private] fn entry_point(target_contract: AztecAddress, target_selector: FunctionSelector) -> Field { @@ -247,10 +247,10 @@ contract Parent { // Call the target private function context.static_call_public_function(target_contract, target_selector, args); } - use dep::aztec::test::helpers::{cheatcodes, test_environment::TestEnvironment}; - use dep::aztec::protocol_types::storage::map::derive_storage_slot_in_map; use dep::aztec::note::note_getter::{MAX_NOTES_PER_PAGE, view_notes}; use dep::aztec::note::note_viewer_options::NoteViewerOptions; + use dep::aztec::protocol_types::storage::map::derive_storage_slot_in_map; + use dep::aztec::test::helpers::{cheatcodes, test_environment::TestEnvironment}; use dep::child_contract::Child; use dep::value_note::value_note::ValueNote; #[test] diff --git a/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr b/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr index c25ab29afdb..c2ef2c31370 100644 --- a/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr @@ -7,17 +7,17 @@ use dep::aztec::macros::aztec; #[aztec] contract PendingNoteHashes { // Libs + use dep::aztec::encrypted_logs::encrypted_note_emission::encode_and_encrypt_note; + use dep::aztec::keys::getters::get_public_keys; + use dep::aztec::macros::{functions::private, storage::storage}; + use dep::aztec::note::note_emission::NoteEmission; use dep::aztec::prelude::{ - AztecAddress, FunctionSelector, NoteGetterOptions, PrivateContext, Map, PrivateSet, + AztecAddress, FunctionSelector, Map, NoteGetterOptions, PrivateContext, PrivateSet, }; - use dep::value_note::{filter::filter_notes_min_sum, value_note::ValueNote}; use dep::aztec::protocol_types::constants::{ MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, MAX_NOTE_HASHES_PER_CALL, }; - use dep::aztec::encrypted_logs::encrypted_note_emission::encode_and_encrypt_note; - use dep::aztec::note::note_emission::NoteEmission; - use dep::aztec::keys::getters::get_public_keys; - use dep::aztec::macros::{storage::storage, functions::private}; + use dep::value_note::{filter::filter_notes_min_sum, value_note::ValueNote}; #[storage] struct Storage { diff --git a/noir-projects/noir-contracts/contracts/price_feed_contract/src/asset.nr b/noir-projects/noir-contracts/contracts/price_feed_contract/src/asset.nr index f28fc928259..86c7b11c198 100644 --- a/noir-projects/noir-contracts/contracts/price_feed_contract/src/asset.nr +++ b/noir-projects/noir-contracts/contracts/price_feed_contract/src/asset.nr @@ -1,4 +1,4 @@ -use dep::aztec::protocol_types::traits::{Serialize, Deserialize}; +use dep::aztec::protocol_types::traits::{Deserialize, Serialize}; pub struct Asset { price: U128, diff --git a/noir-projects/noir-contracts/contracts/price_feed_contract/src/main.nr b/noir-projects/noir-contracts/contracts/price_feed_contract/src/main.nr index f360c87ad74..92739ffb6ab 100644 --- a/noir-projects/noir-contracts/contracts/price_feed_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/price_feed_contract/src/main.nr @@ -4,10 +4,10 @@ use dep::aztec::macros::aztec; #[aztec] contract PriceFeed { - use dep::aztec::prelude::{Map, PublicMutable}; use crate::asset::Asset; + use dep::aztec::prelude::{Map, PublicMutable}; - use dep::aztec::macros::{storage::storage, functions::{public, view}}; + use dep::aztec::macros::{functions::{public, view}, storage::storage}; // Storage structure, containing all storage, and specifying what slots they use. #[storage] diff --git a/noir-projects/noir-contracts/contracts/private_fpc_contract/src/main.nr b/noir-projects/noir-contracts/contracts/private_fpc_contract/src/main.nr index c3ec2837927..eda77466809 100644 --- a/noir-projects/noir-contracts/contracts/private_fpc_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/private_fpc_contract/src/main.nr @@ -4,13 +4,13 @@ use dep::aztec::macros::aztec; #[aztec] contract PrivateFPC { + use crate::settings::Settings; use dep::aztec::{ + macros::{functions::{initializer, private, public}, storage::storage}, protocol_types::{address::AztecAddress, hash::compute_siloed_nullifier}, state_vars::SharedImmutable, - macros::{storage::storage, functions::{private, initializer, public}}, }; use token::Token; - use crate::settings::Settings; #[storage] struct Storage { diff --git a/noir-projects/noir-contracts/contracts/private_fpc_contract/src/settings.nr b/noir-projects/noir-contracts/contracts/private_fpc_contract/src/settings.nr index fe5a5474e01..c3717ca1a7e 100644 --- a/noir-projects/noir-contracts/contracts/private_fpc_contract/src/settings.nr +++ b/noir-projects/noir-contracts/contracts/private_fpc_contract/src/settings.nr @@ -1,4 +1,4 @@ -use dep::aztec::protocol_types::{address::AztecAddress, traits::{Serialize, Deserialize}}; +use dep::aztec::protocol_types::{address::AztecAddress, traits::{Deserialize, Serialize}}; global SETTINGS_LENGTH: u32 = 2; diff --git a/noir-projects/noir-contracts/contracts/router_contract/src/main.nr b/noir-projects/noir-contracts/contracts/router_contract/src/main.nr index 10908953fbc..0255a43ff01 100644 --- a/noir-projects/noir-contracts/contracts/router_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/router_contract/src/main.nr @@ -8,7 +8,7 @@ use dep::aztec::macros::aztec; /// the `msg_sender` in the public call is the address of this contract. #[aztec] contract Router { - use aztec::{macros::functions::{private, public, view, internal}, utils::comparison::compare}; + use aztec::{macros::functions::{internal, private, public, view}, utils::comparison::compare}; // docs:start:check_timestamp /// Asserts that the current timestamp in the enqueued public call satisfies the `operation` with respect diff --git a/noir-projects/noir-contracts/contracts/router_contract/src/test.nr b/noir-projects/noir-contracts/contracts/router_contract/src/test.nr index e8480bc0719..a708a71ad11 100644 --- a/noir-projects/noir-contracts/contracts/router_contract/src/test.nr +++ b/noir-projects/noir-contracts/contracts/router_contract/src/test.nr @@ -1,5 +1,5 @@ -use dep::aztec::test::helpers::test_environment::TestEnvironment; use crate::Router; +use dep::aztec::test::helpers::test_environment::TestEnvironment; use aztec::utils::comparison::Comparator; #[test] diff --git a/noir-projects/noir-contracts/contracts/router_contract/src/utils.nr b/noir-projects/noir-contracts/contracts/router_contract/src/utils.nr index 46471bf6585..a6925c4f8c3 100644 --- a/noir-projects/noir-contracts/contracts/router_contract/src/utils.nr +++ b/noir-projects/noir-contracts/contracts/router_contract/src/utils.nr @@ -1,6 +1,6 @@ -use aztec::protocol_types::constants::ROUTER_ADDRESS; -use aztec::context::private_context::PrivateContext; use crate::Router; +use aztec::context::private_context::PrivateContext; +use aztec::protocol_types::constants::ROUTER_ADDRESS; // docs:start:helper_router_functions /// Asserts that the current timestamp in the enqueued public call enqueued by `check_timestamp` satisfies diff --git a/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/main.nr b/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/main.nr index ddd2ae24292..1356b3aec67 100644 --- a/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/main.nr @@ -8,18 +8,20 @@ use dep::aztec::macros::aztec; contract SchnorrAccount { use dep::std; - use dep::aztec::prelude::{AztecAddress, PrivateContext, PrivateImmutable}; - use dep::aztec::encrypted_logs::encrypted_note_emission::encode_and_encrypt_note; use dep::authwit::{ - entrypoint::{app::AppPayload, fee::FeePayload}, account::AccountActions, + account::AccountActions, + auth::{compute_authwit_message_hash, compute_authwit_nullifier}, auth_witness::get_auth_witness, - auth::{compute_authwit_nullifier, compute_authwit_message_hash}, + entrypoint::{app::AppPayload, fee::FeePayload}, }; + use dep::aztec::encrypted_logs::encrypted_note_emission::encode_and_encrypt_note; use dep::aztec::{hash::compute_siloed_nullifier, keys::getters::get_public_keys}; - use dep::aztec::oracle::get_nullifier_membership_witness::get_low_nullifier_membership_witness; use dep::aztec::macros::{ - storage::storage, functions::{private, initializer, view, noinitcheck}, + functions::{initializer, noinitcheck, private, view}, + storage::storage, }; + use dep::aztec::oracle::get_nullifier_membership_witness::get_low_nullifier_membership_witness; + use dep::aztec::prelude::{AztecAddress, PrivateContext, PrivateImmutable}; use crate::public_key_note::PublicKeyNote; diff --git a/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr b/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr index 2234c8316f2..2e48a31ac8d 100644 --- a/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr +++ b/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr @@ -1,10 +1,12 @@ -use dep::aztec::prelude::{NoteHeader, NullifiableNote, PrivateContext}; use dep::aztec::{ - note::utils::compute_note_hash_for_nullify, keys::getters::get_nsk_app, + keys::getters::get_nsk_app, + macros::notes::note, + note::utils::compute_note_hash_for_nullify, protocol_types::{ constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash_with_separator, - }, macros::notes::note, + }, }; +use dep::aztec::prelude::{NoteHeader, NullifiableNote, PrivateContext}; // Stores a public key composed of two fields // TODO: Do we need to include a nonce, in case we want to read/nullify/recreate with the same pubkey value? diff --git a/noir-projects/noir-contracts/contracts/schnorr_hardcoded_account_contract/src/main.nr b/noir-projects/noir-contracts/contracts/schnorr_hardcoded_account_contract/src/main.nr index 30790f2a817..1eea24b7356 100644 --- a/noir-projects/noir-contracts/contracts/schnorr_hardcoded_account_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/schnorr_hardcoded_account_contract/src/main.nr @@ -4,11 +4,12 @@ use dep::aztec::macros::aztec; #[aztec] contract SchnorrHardcodedAccount { - use dep::aztec::prelude::PrivateContext; use dep::authwit::{ - entrypoint::{app::AppPayload, fee::FeePayload}, account::AccountActions, + account::AccountActions, auth_witness::get_auth_witness, + entrypoint::{app::AppPayload, fee::FeePayload}, }; + use dep::aztec::prelude::PrivateContext; use dep::aztec::macros::functions::{private, view}; diff --git a/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/auth_oracle.nr b/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/auth_oracle.nr index 97b1205054d..063720d28e1 100644 --- a/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/auth_oracle.nr +++ b/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/auth_oracle.nr @@ -1,6 +1,8 @@ use dep::authwit::auth_witness; use dep::aztec::protocol_types::{ - address::PartialAddress, utils::arr_copy_slice, public_keys::{PublicKeys, PUBLIC_KEYS_LENGTH}, + address::PartialAddress, + public_keys::{PUBLIC_KEYS_LENGTH, PublicKeys}, + utils::arr_copy_slice, }; pub struct AuthWitness { diff --git a/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/main.nr b/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/main.nr index 25a1c376799..3de21d464a1 100644 --- a/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/main.nr @@ -7,9 +7,9 @@ use dep::aztec::macros::aztec; contract SchnorrSingleKeyAccount { use dep::aztec::prelude::PrivateContext; - use dep::authwit::{entrypoint::{app::AppPayload, fee::FeePayload}, account::AccountActions}; + use dep::authwit::{account::AccountActions, entrypoint::{app::AppPayload, fee::FeePayload}}; - use crate::{util::recover_address, auth_oracle::get_auth_witness}; + use crate::{auth_oracle::get_auth_witness, util::recover_address}; use dep::aztec::macros::functions::{private, view}; diff --git a/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/util.nr b/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/util.nr index 82e839cda08..3ab737de82f 100644 --- a/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/util.nr +++ b/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/util.nr @@ -1,6 +1,6 @@ -use std::schnorr::verify_signature; -use dep::aztec::prelude::AztecAddress; use crate::auth_oracle::AuthWitness; +use dep::aztec::prelude::AztecAddress; +use std::schnorr::verify_signature; pub fn recover_address(message_hash: Field, witness: AuthWitness) -> AztecAddress { let message_bytes: [u8; 32] = message_hash.to_be_bytes(); diff --git a/noir-projects/noir-contracts/contracts/spam_contract/src/main.nr b/noir-projects/noir-contracts/contracts/spam_contract/src/main.nr index c44c8b050aa..53cdee95ef4 100644 --- a/noir-projects/noir-contracts/contracts/spam_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/spam_contract/src/main.nr @@ -7,19 +7,20 @@ use dep::aztec::macros::aztec; contract Spam { use dep::aztec::{ - prelude::{Map, AztecAddress, PublicMutable}, encrypted_logs::encrypted_note_emission::encode_and_encrypt_note_unconstrained, keys::getters::get_public_keys, + macros::{functions::{internal, private, public}, storage::storage}, + prelude::{AztecAddress, Map, PublicMutable}, protocol_types::{ - hash::poseidon2_hash_with_separator, constants::{ - MAX_NOTE_HASHES_PER_CALL, MAX_NULLIFIERS_PER_CALL, GENERATOR_INDEX__NOTE_NULLIFIER, - MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, + GENERATOR_INDEX__NOTE_NULLIFIER, MAX_NOTE_HASHES_PER_CALL, MAX_NULLIFIERS_PER_CALL, + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, }, - }, macros::{storage::storage, functions::{private, public, internal}}, + hash::poseidon2_hash_with_separator, + }, }; - use crate::types::{token_note::TokenNote, balance_set::BalanceSet}; + use crate::types::{balance_set::BalanceSet, token_note::TokenNote}; #[storage] struct Storage { diff --git a/noir-projects/noir-contracts/contracts/spam_contract/src/types/balance_set.nr b/noir-projects/noir-contracts/contracts/spam_contract/src/types/balance_set.nr index fe7840ff1ba..c9526d85c49 100644 --- a/noir-projects/noir-contracts/contracts/spam_contract/src/types/balance_set.nr +++ b/noir-projects/noir-contracts/contracts/spam_contract/src/types/balance_set.nr @@ -1,13 +1,13 @@ // This file is copied from the token contract. -use dep::aztec::prelude::{ - NoteGetterOptions, NoteViewerOptions, NoteInterface, NullifiableNote, PrivateSet, -}; +use crate::types::token_note::OwnedNote; use dep::aztec::{ context::{PrivateContext, UnconstrainedContext}, - protocol_types::{constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, public_keys::NpkM}, note::note_emission::OuterNoteEmission, + protocol_types::{constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, public_keys::NpkM}, +}; +use dep::aztec::prelude::{ + NoteGetterOptions, NoteInterface, NoteViewerOptions, NullifiableNote, PrivateSet, }; -use crate::types::token_note::OwnedNote; pub struct BalanceSet { set: PrivateSet, diff --git a/noir-projects/noir-contracts/contracts/spam_contract/src/types/token_note.nr b/noir-projects/noir-contracts/contracts/spam_contract/src/types/token_note.nr index 5108ad854b0..3b60ed16816 100644 --- a/noir-projects/noir-contracts/contracts/spam_contract/src/types/token_note.nr +++ b/noir-projects/noir-contracts/contracts/spam_contract/src/types/token_note.nr @@ -1,9 +1,12 @@ use dep::aztec::{ + keys::getters::get_nsk_app, + macros::notes::note, + note::utils::compute_note_hash_for_nullify, + oracle::random::random, prelude::{NoteHeader, NullifiableNote, PrivateContext}, protocol_types::{ constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash_with_separator, - }, note::utils::compute_note_hash_for_nullify, oracle::random::random, - keys::getters::get_nsk_app, macros::notes::note, + }, }; trait OwnedNote { diff --git a/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr index fc65d46ef8a..958386d0803 100644 --- a/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr @@ -3,12 +3,12 @@ use dep::aztec::macros::aztec; #[aztec] contract StatefulTest { - use dep::aztec::prelude::{Map, PublicMutable, PrivateSet, AztecAddress, FunctionSelector}; - use dep::value_note::{balance_utils, utils::{increment, decrement}, value_note::ValueNote}; use dep::aztec::{ initializer::assert_is_initialized_private, - macros::{storage::storage, functions::{private, public, initializer, noinitcheck, view}}, + macros::{functions::{initializer, noinitcheck, private, public, view}, storage::storage}, }; + use dep::aztec::prelude::{AztecAddress, FunctionSelector, Map, PrivateSet, PublicMutable}; + use dep::value_note::{balance_utils, utils::{decrement, increment}, value_note::ValueNote}; #[storage] struct Storage { diff --git a/noir-projects/noir-contracts/contracts/static_child_contract/src/main.nr b/noir-projects/noir-contracts/contracts/static_child_contract/src/main.nr index b79a844b4c8..1d44bb0350a 100644 --- a/noir-projects/noir-contracts/contracts/static_child_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/static_child_contract/src/main.nr @@ -3,13 +3,14 @@ use dep::aztec::macros::aztec; #[aztec] contract StaticChild { - use dep::aztec::prelude::{AztecAddress, PublicMutable, PrivateSet}; + use dep::aztec::prelude::{AztecAddress, PrivateSet, PublicMutable}; use dep::aztec::{ - note::note_getter_options::NoteGetterOptions, encrypted_logs::encrypted_note_emission::encode_and_encrypt_note, - keys::getters::get_public_keys, utils::comparison::Comparator, - macros::{storage::storage, functions::{private, public, view}}, + keys::getters::get_public_keys, + macros::{functions::{private, public, view}, storage::storage}, + note::note_getter_options::NoteGetterOptions, + utils::comparison::Comparator, }; use dep::value_note::value_note::ValueNote; diff --git a/noir-projects/noir-contracts/contracts/static_parent_contract/src/main.nr b/noir-projects/noir-contracts/contracts/static_parent_contract/src/main.nr index e0d371cbd23..f1e0487c446 100644 --- a/noir-projects/noir-contracts/contracts/static_parent_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/static_parent_contract/src/main.nr @@ -3,8 +3,8 @@ use dep::aztec::macros::aztec; #[aztec] contract StaticParent { - use dep::aztec::prelude::{AztecAddress, FunctionSelector}; use dep::aztec::{context::gas::GasOpts, macros::functions::{private, public, view}}; + use dep::aztec::prelude::{AztecAddress, FunctionSelector}; use dep::static_child_contract::StaticChild; // Public function to directly call another public function to the target_contract using the selector and value provided diff --git a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr index 88977b9c7f7..c19a1a63ecd 100644 --- a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr @@ -6,36 +6,39 @@ use dep::aztec::macros::aztec; #[aztec] contract Test { + use dep::aztec::encrypted_logs::encrypted_event_emission::encode_and_encrypt_event_with_randomness_unconstrained; + use dep::aztec::encrypted_logs::encrypted_note_emission::encode_and_encrypt_note; use dep::aztec::prelude::{ AztecAddress, EthAddress, FunctionSelector, NoteGetterOptions, NoteViewerOptions, PrivateImmutable, PrivateSet, }; - use dep::aztec::encrypted_logs::encrypted_note_emission::encode_and_encrypt_note; - use dep::aztec::encrypted_logs::encrypted_event_emission::encode_and_encrypt_event_with_randomness_unconstrained; use dep::aztec::protocol_types::{ - constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, traits::Serialize, point::Point, - public_keys::IvpkM, + constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, point::Point, public_keys::IvpkM, + traits::Serialize, }; - use dep::aztec::note::constants::MAX_NOTES_PER_PAGE; use dep::aztec::keys::getters::get_public_keys; + use dep::aztec::note::constants::MAX_NOTES_PER_PAGE; use dep::aztec::{ - hash::{pedersen_hash, compute_secret_hash, ArgsHasher}, + deploy::deploy_contract as aztec_deploy_contract, + hash::{ArgsHasher, compute_secret_hash, pedersen_hash}, + macros::{events::event, functions::{internal, private, public}, storage::storage}, note::{ - lifecycle::{create_note, destroy_note_unsafe}, note_getter::{get_notes, view_notes}, + lifecycle::{create_note, destroy_note_unsafe}, + note_getter::{get_notes, view_notes}, note_getter_options::NoteStatus, - }, deploy::deploy_contract as aztec_deploy_contract, oracle::random::random, + }, + oracle::random::random, utils::comparison::Comparator, - macros::{storage::storage, events::event, functions::{private, public, internal}}, }; use dep::token_portal_content_hash_lib::{ get_mint_private_content_hash, get_mint_public_content_hash, }; use dep::value_note::value_note::ValueNote; // TODO investigate why the macros require EmbeddedCurvePoint and EmbeddedCurveScalar - use std::embedded_curve_ops::{EmbeddedCurveScalar, EmbeddedCurvePoint}; + use std::embedded_curve_ops::{EmbeddedCurvePoint, EmbeddedCurveScalar}; use std::meta::derive; use crate::test_note::TestNote; diff --git a/noir-projects/noir-contracts/contracts/test_contract/src/test_note.nr b/noir-projects/noir-contracts/contracts/test_contract/src/test_note.nr index 66796939be9..7f938fa42cd 100644 --- a/noir-projects/noir-contracts/contracts/test_contract/src/test_note.nr +++ b/noir-projects/noir-contracts/contracts/test_contract/src/test_note.nr @@ -1,6 +1,7 @@ use dep::aztec::{ - note::{note_header::NoteHeader, note_interface::NullifiableNote}, context::PrivateContext, + context::PrivateContext, macros::notes::note, + note::{note_header::NoteHeader, note_interface::NullifiableNote}, }; // A note which stores a field and is expected to be passed around using the `addNote` function. diff --git a/noir-projects/noir-contracts/contracts/test_log_contract/src/main.nr b/noir-projects/noir-contracts/contracts/test_log_contract/src/main.nr index d94213d9349..64d6cb1f756 100644 --- a/noir-projects/noir-contracts/contracts/test_log_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/test_log_contract/src/main.nr @@ -2,14 +2,14 @@ use dep::aztec::macros::aztec; #[aztec] contract TestLog { - use std::meta::derive; + use dep::aztec::encrypted_logs::encrypted_event_emission::encode_and_encrypt_event_with_randomness; + use dep::aztec::keys::getters::get_public_keys; + use dep::aztec::macros::{events::event, functions::{private, public}, storage::storage}; use dep::aztec::prelude::PrivateSet; use dep::aztec::protocol_types::{address::AztecAddress, traits::Serialize}; - use dep::aztec::keys::getters::get_public_keys; - use dep::value_note::value_note::ValueNote; - use dep::aztec::encrypted_logs::encrypted_event_emission::encode_and_encrypt_event_with_randomness; use dep::aztec::unencrypted_logs::unencrypted_event_emission::encode_event; - use dep::aztec::macros::{storage::storage, events::event, functions::{private, public}}; + use dep::value_note::value_note::ValueNote; + use std::meta::derive; use std::embedded_curve_ops::EmbeddedCurveScalar; diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr index b7ff9f52f94..f49d64b7ba1 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr @@ -14,13 +14,14 @@ use dep::aztec::macros::aztec; contract TokenBlacklist { // Libs use dep::aztec::{ - hash::compute_secret_hash, - prelude::{AztecAddress, Map, NoteGetterOptions, PrivateSet, PublicMutable, SharedMutable}, encrypted_logs::encrypted_note_emission::{ - encode_and_encrypt_note_unconstrained, encode_and_encrypt_note, - }, utils::comparison::Comparator, - macros::{storage::storage, functions::{private, public, initializer, view, internal}}, + encode_and_encrypt_note, encode_and_encrypt_note_unconstrained, + }, + hash::compute_secret_hash, keys::getters::get_public_keys, + macros::{functions::{initializer, internal, private, public, view}, storage::storage}, + prelude::{AztecAddress, Map, NoteGetterOptions, PrivateSet, PublicMutable, SharedMutable}, + utils::comparison::Comparator, }; use dep::authwit::auth::{ @@ -28,8 +29,8 @@ contract TokenBlacklist { }; use crate::types::{ - transparent_note::TransparentNote, token_note::TokenNote, balances_map::BalancesMap, - roles::UserFlags, + balances_map::BalancesMap, roles::UserFlags, token_note::TokenNote, + transparent_note::TransparentNote, }; // Changing an address' roles has a certain block delay before it goes into effect. diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/balances_map.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/balances_map.nr index b7f1ae7206a..8c1d84c3cef 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/balances_map.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/balances_map.nr @@ -1,13 +1,14 @@ -use dep::aztec::prelude::{ - AztecAddress, NoteGetterOptions, NoteViewerOptions, NoteInterface, NullifiableNote, PrivateSet, - Map, -}; +use crate::types::token_note::OwnedNote; use dep::aztec::{ context::{PrivateContext, UnconstrainedContext}, + keys::getters::get_public_keys, + note::note_emission::OuterNoteEmission, protocol_types::constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, - note::note_emission::OuterNoteEmission, keys::getters::get_public_keys, }; -use crate::types::token_note::OwnedNote; +use dep::aztec::prelude::{ + AztecAddress, Map, NoteGetterOptions, NoteInterface, NoteViewerOptions, NullifiableNote, + PrivateSet, +}; pub struct BalancesMap { map: Map, Context>, diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/roles.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/roles.nr index e27898f0a57..46b784f6899 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/roles.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/roles.nr @@ -1,4 +1,4 @@ -use dep::aztec::protocol_types::traits::{FromField, ToField, Serialize, Deserialize}; +use dep::aztec::protocol_types::traits::{Deserialize, FromField, Serialize, ToField}; global ADMIN_FLAG: u64 = 1; global MINTER_FLAG: u64 = 2; diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr index 16b1fe92e64..b36d5316324 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr @@ -1,9 +1,12 @@ use dep::aztec::{ + keys::getters::get_nsk_app, + macros::notes::note, + note::utils::compute_note_hash_for_nullify, + oracle::random::random, prelude::{NoteHeader, NullifiableNote, PrivateContext}, protocol_types::{ constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash_with_separator, - }, note::utils::compute_note_hash_for_nullify, oracle::random::random, - keys::getters::get_nsk_app, macros::notes::note, + }, }; trait OwnedNote { diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr index 77ea426a53f..f830f8265c8 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr @@ -1,10 +1,11 @@ // docs:start:token_types_all use dep::aztec::{ + macros::notes::note, note::{note_getter_options::PropertySelector, utils::compute_note_hash_for_nullify}, prelude::{NoteHeader, NullifiableNote, PrivateContext}, protocol_types::{ constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash_with_separator, - }, macros::notes::note, + }, }; use dep::std::mem::zeroed; diff --git a/noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr index e83b07118ab..ef94712166a 100644 --- a/noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr @@ -12,13 +12,14 @@ contract TokenBridge { use dep::aztec::prelude::{AztecAddress, EthAddress, PublicMutable, SharedImmutable}; use dep::token_portal_content_hash_lib::{ - get_mint_public_content_hash, get_mint_private_content_hash, get_withdraw_content_hash, + get_mint_private_content_hash, get_mint_public_content_hash, get_withdraw_content_hash, }; use dep::token::Token; use dep::aztec::macros::{ - storage::storage, functions::{public, initializer, private, internal, view}, + functions::{initializer, internal, private, public, view}, + storage::storage, }; // docs:end:token_bridge_imports diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_contract/src/main.nr index e69d0fedec6..b38e513d7da 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/main.nr @@ -19,22 +19,28 @@ contract Token { use dep::compressed_string::FieldCompressedString; use dep::aztec::{ - context::{PrivateContext, PrivateCallInterface}, hash::compute_secret_hash, - oracle::random::random, - prelude::{ - NoteGetterOptions, Map, PublicMutable, SharedImmutable, PrivateSet, AztecAddress, - FunctionSelector, - }, + context::{PrivateCallInterface, PrivateContext}, encrypted_logs::{ + encrypted_event_emission::encode_and_encrypt_event_unconstrained, encrypted_note_emission::{ encode_and_encrypt_note, encode_and_encrypt_note_unconstrained, encrypt_and_emit_partial_log, - }, encrypted_event_emission::encode_and_encrypt_event_unconstrained, - }, keys::getters::get_public_keys, + }, + }, + hash::compute_secret_hash, + keys::getters::get_public_keys, macros::{ - storage::storage, events::event, - functions::{initializer, private, view, public, internal}, - }, utils::comparison::Comparator, protocol_types::{point::Point, traits::Serialize}, + events::event, + functions::{initializer, internal, private, public, view}, + storage::storage, + }, + oracle::random::random, + prelude::{ + AztecAddress, FunctionSelector, Map, NoteGetterOptions, PrivateSet, PublicMutable, + SharedImmutable, + }, + protocol_types::{point::Point, traits::Serialize}, + utils::comparison::Comparator, }; // docs:start:import_authwit @@ -45,7 +51,7 @@ contract Token { // docs:end:import_authwit use crate::types::{ - transparent_note::TransparentNote, token_note::TokenNote, balance_set::BalanceSet, + balance_set::BalanceSet, token_note::TokenNote, transparent_note::TransparentNote, }; // docs:end::imports diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/test/burn.nr b/noir-projects/noir-contracts/contracts/token_contract/src/test/burn.nr index 233b842c651..3fbf1d73c64 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/test/burn.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/test/burn.nr @@ -1,7 +1,7 @@ use crate::test::utils; -use dep::aztec::oracle::random::random; -use dep::authwit::cheatcodes as authwit_cheatcodes; use crate::Token; +use dep::authwit::cheatcodes as authwit_cheatcodes; +use dep::aztec::oracle::random::random; #[test] unconstrained fn burn_public_success() { diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/test/minting.nr b/noir-projects/noir-contracts/contracts/token_contract/src/test/minting.nr index d4ee834bdb4..fb894336bd5 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/test/minting.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/test/minting.nr @@ -1,6 +1,6 @@ use crate::test::utils; -use dep::aztec::{test::helpers::cheatcodes, oracle::random::random, hash::compute_secret_hash}; -use crate::{types::transparent_note::TransparentNote, Token}; +use crate::{Token, types::transparent_note::TransparentNote}; +use dep::aztec::{hash::compute_secret_hash, oracle::random::random, test::helpers::cheatcodes}; #[test] unconstrained fn mint_public_success() { diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/test/reading_constants.nr b/noir-projects/noir-contracts/contracts/token_contract/src/test/reading_constants.nr index c96bd9613be..6081e27ae4c 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/test/reading_constants.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/test/reading_constants.nr @@ -1,6 +1,6 @@ use crate::test::utils; -use dep::aztec::test::helpers::cheatcodes; use crate::Token; +use dep::aztec::test::helpers::cheatcodes; // It is not possible to deserialize strings in Noir ATM, so name and symbol cannot be checked yet. diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/test/refunds.nr b/noir-projects/noir-contracts/contracts/token_contract/src/test/refunds.nr index a8f48973acb..93c57bde666 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/test/refunds.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/test/refunds.nr @@ -1,10 +1,10 @@ use crate::{test::utils, Token, types::token_note::TokenNote}; +use dep::authwit::cheatcodes as authwit_cheatcodes; use dep::aztec::{ - prelude::NoteHeader, protocol_types::storage::map::derive_storage_slot_in_map, - keys::getters::get_public_keys, + keys::getters::get_public_keys, prelude::NoteHeader, + protocol_types::storage::map::derive_storage_slot_in_map, }; -use dep::authwit::cheatcodes as authwit_cheatcodes; use std::test::OracleMock; #[test] diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/test/shielding.nr b/noir-projects/noir-contracts/contracts/token_contract/src/test/shielding.nr index 5abf58a7328..ed49a1807d4 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/test/shielding.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/test/shielding.nr @@ -1,7 +1,7 @@ use crate::test::utils; -use dep::aztec::{oracle::random::random, hash::compute_secret_hash}; +use crate::{Token, types::transparent_note::TransparentNote}; use dep::authwit::cheatcodes as authwit_cheatcodes; -use crate::{types::transparent_note::TransparentNote, Token}; +use dep::aztec::{hash::compute_secret_hash, oracle::random::random}; #[test] unconstrained fn shielding_on_behalf_of_self() { diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_private.nr b/noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_private.nr index feaa922200a..8e606030d1c 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_private.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_private.nr @@ -1,7 +1,7 @@ use crate::test::utils; -use dep::aztec::test::helpers::cheatcodes; -use dep::authwit::cheatcodes as authwit_cheatcodes; use crate::Token; +use dep::authwit::cheatcodes as authwit_cheatcodes; +use dep::aztec::test::helpers::cheatcodes; #[test] unconstrained fn transfer_private() { diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_public.nr b/noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_public.nr index 600f1e92ed4..829fd1a31a6 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_public.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/test/transfer_public.nr @@ -1,7 +1,7 @@ use crate::test::utils; -use dep::aztec::oracle::random::random; -use dep::authwit::cheatcodes as authwit_cheatcodes; use crate::Token; +use dep::authwit::cheatcodes as authwit_cheatcodes; +use dep::aztec::oracle::random::random; #[test] unconstrained fn public_transfer() { diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/test/unshielding.nr b/noir-projects/noir-contracts/contracts/token_contract/src/test/unshielding.nr index 8e4063561a7..60350ca624b 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/test/unshielding.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/test/unshielding.nr @@ -1,7 +1,7 @@ use crate::test::utils; -use dep::aztec::oracle::random::random; -use dep::authwit::cheatcodes as authwit_cheatcodes; use crate::Token; +use dep::authwit::cheatcodes as authwit_cheatcodes; +use dep::aztec::oracle::random::random; #[test] unconstrained fn unshield_on_behalf_of_self() { diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/test/utils.nr b/noir-projects/noir-contracts/contracts/token_contract/src/test/utils.nr index 082cb882370..c3f93777556 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/test/utils.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/test/utils.nr @@ -1,13 +1,16 @@ use dep::aztec::{ - hash::compute_secret_hash, prelude::AztecAddress, - test::helpers::{cheatcodes, test_environment::TestEnvironment}, - protocol_types::storage::map::derive_storage_slot_in_map, + hash::compute_secret_hash, oracle::{ - execution::{get_block_number, get_contract_address}, random::random, storage::storage_read, + execution::{get_block_number, get_contract_address}, + random::random, + storage::storage_read, }, + prelude::AztecAddress, + protocol_types::storage::map::derive_storage_slot_in_map, + test::helpers::{cheatcodes, test_environment::TestEnvironment}, }; -use crate::{types::transparent_note::TransparentNote, Token}; +use crate::{Token, types::transparent_note::TransparentNote}; pub unconstrained fn setup( with_account_contracts: bool, diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/types/balance_set.nr b/noir-projects/noir-contracts/contracts/token_contract/src/types/balance_set.nr index 2bb1a34b5cb..9f650a94291 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/types/balance_set.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/types/balance_set.nr @@ -1,12 +1,13 @@ -use dep::aztec::prelude::{NoteGetterOptions, NoteViewerOptions, NoteInterface, PrivateSet}; +use crate::types::token_note::OwnedNote; use dep::aztec::{ context::{PrivateContext, UnconstrainedContext}, - protocol_types::{constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, public_keys::NpkM}, + keys::getters::get_public_keys, note::{ - note_interface::NullifiableNote, note_getter::view_notes, note_emission::OuterNoteEmission, - }, keys::getters::get_public_keys, + note_emission::OuterNoteEmission, note_getter::view_notes, note_interface::NullifiableNote, + }, + protocol_types::{constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, public_keys::NpkM}, }; -use crate::types::token_note::OwnedNote; +use dep::aztec::prelude::{NoteGetterOptions, NoteInterface, NoteViewerOptions, PrivateSet}; pub struct BalanceSet { set: PrivateSet, diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/types/token_note.nr b/noir-projects/noir-contracts/contracts/token_contract/src/types/token_note.nr index ace732b7c72..677dd918033 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/types/token_note.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/types/token_note.nr @@ -1,9 +1,12 @@ use dep::aztec::{ + keys::getters::get_nsk_app, + macros::notes::partial_note, + note::utils::compute_note_hash_for_nullify, + oracle::random::random, prelude::{NoteHeader, NullifiableNote, PrivateContext}, protocol_types::{ constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash_with_separator, - }, note::utils::compute_note_hash_for_nullify, oracle::random::random, - keys::getters::get_nsk_app, macros::notes::partial_note, + }, }; trait OwnedNote { diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/types/transparent_note.nr b/noir-projects/noir-contracts/contracts/token_contract/src/types/transparent_note.nr index b89920a82ec..ed1f08e0d74 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/types/transparent_note.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/types/transparent_note.nr @@ -1,10 +1,11 @@ // docs:start:token_types_all use dep::aztec::{ + macros::notes::note, note::utils::compute_note_hash_for_nullify, prelude::{NoteHeader, NullifiableNote, PrivateContext}, protocol_types::{ constants::GENERATOR_INDEX__NOTE_NULLIFIER, hash::poseidon2_hash_with_separator, - }, macros::notes::note, + }, }; use dep::std::mem::zeroed; diff --git a/noir-projects/noir-contracts/contracts/uniswap_contract/src/main.nr b/noir-projects/noir-contracts/contracts/uniswap_contract/src/main.nr index 4e488288226..f1625dc6119 100644 --- a/noir-projects/noir-contracts/contracts/uniswap_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/uniswap_contract/src/main.nr @@ -8,19 +8,20 @@ use dep::aztec::macros::aztec; #[aztec] contract Uniswap { - use dep::aztec::prelude::{FunctionSelector, AztecAddress, EthAddress, SharedImmutable}; + use dep::aztec::prelude::{AztecAddress, EthAddress, FunctionSelector, SharedImmutable}; use dep::authwit::auth::{ assert_current_call_valid_authwit_public, compute_authwit_message_hash_from_call, set_authorized, }; - use dep::token::Token; - use dep::token_bridge::TokenBridge; use crate::util::{compute_swap_private_content_hash, compute_swap_public_content_hash}; use dep::aztec::macros::{ - storage::storage, functions::{public, initializer, view, internal, private}, + functions::{initializer, internal, private, public, view}, + storage::storage, }; + use dep::token::Token; + use dep::token_bridge::TokenBridge; #[storage] struct Storage { diff --git a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/lib.nr b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/lib.nr index dcd55f829ce..9aaac2a23f6 100644 --- a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/lib.nr +++ b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/lib.nr @@ -4,7 +4,7 @@ mod parity_public_inputs; mod utils; pub use crate::base::base_parity_inputs::BaseParityInputs; +pub use crate::parity_public_inputs::ParityPublicInputs; pub use crate::root::root_parity_input::RootParityInput; pub use crate::root::root_parity_inputs::RootParityInputs; pub use crate::root::root_rollup_parity_input::RootRollupParityInput; -pub use crate::parity_public_inputs::ParityPublicInputs; diff --git a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/parity_public_inputs.nr b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/parity_public_inputs.nr index 3b7b286020c..ae7c1263c4a 100644 --- a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/parity_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/parity_public_inputs.nr @@ -1,4 +1,4 @@ -use dep::types::traits::{Empty, Serialize, Deserialize}; +use dep::types::traits::{Deserialize, Empty, Serialize}; pub struct ParityPublicInputs { sha_root: Field, diff --git a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_parity_input.nr b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_parity_input.nr index 1999eff165e..cb1b2edc1ea 100644 --- a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_parity_input.nr +++ b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_parity_input.nr @@ -1,12 +1,14 @@ +use crate::parity_public_inputs::ParityPublicInputs; use dep::types::{ - traits::Empty, + constants::{BASE_PARITY_INDEX, VK_TREE_HEIGHT}, + merkle_tree::membership::assert_check_membership, recursion::{ - verification_key::{VerificationKey, HonkVerificationKey}, proof::RecursiveProof, + proof::RecursiveProof, traits::Verifiable, - }, constants::{BASE_PARITY_INDEX, VK_TREE_HEIGHT}, - merkle_tree::membership::assert_check_membership, + verification_key::{HonkVerificationKey, VerificationKey}, + }, + traits::Empty, }; -use crate::parity_public_inputs::ParityPublicInputs; pub struct RootParityInput { proof: RecursiveProof, diff --git a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_parity_inputs.nr b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_parity_inputs.nr index 50bc3edc4ce..4053d13743e 100644 --- a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_parity_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_parity_inputs.nr @@ -1,8 +1,8 @@ -use dep::types::merkle_tree::MerkleTree; use crate::{ parity_public_inputs::ParityPublicInputs, root::root_parity_input::RootParityInput, utils::sha256_merkle_tree::Sha256MerkleTree, }; +use dep::types::merkle_tree::MerkleTree; global NUM_BASE_PARITY_PER_ROOT_PARITY: u32 = 4; @@ -59,9 +59,9 @@ mod tests { parity_public_inputs::ParityPublicInputs, root::{root_parity_input::RootParityInput, root_parity_inputs::RootParityInputs}, }; - use dep::types::recursion::{verification_key::VerificationKey, proof::RecursiveProof}; - use dep::types::tests::fixtures; use dep::types::constants::BASE_PARITY_INDEX; + use dep::types::recursion::{proof::RecursiveProof, verification_key::VerificationKey}; + use dep::types::tests::fixtures; use super::NUM_BASE_PARITY_PER_ROOT_PARITY; use types::hash::verification_key_hash; diff --git a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_rollup_parity_input.nr b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_rollup_parity_input.nr index 23f082d38f9..dc0c35e2454 100644 --- a/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_rollup_parity_input.nr +++ b/noir-projects/noir-protocol-circuits/crates/parity-lib/src/root/root_rollup_parity_input.nr @@ -1,12 +1,14 @@ +use crate::parity_public_inputs::ParityPublicInputs; use dep::types::{ - traits::Empty, + constants::{ROOT_PARITY_INDEX, VK_TREE_HEIGHT}, + merkle_tree::membership::assert_check_membership, recursion::{ - verification_key::{VerificationKey, HonkVerificationKey}, proof::NestedRecursiveProof, + proof::NestedRecursiveProof, traits::Verifiable, - }, constants::{ROOT_PARITY_INDEX, VK_TREE_HEIGHT}, - merkle_tree::membership::assert_check_membership, + verification_key::{HonkVerificationKey, VerificationKey}, + }, + traits::Empty, }; -use crate::parity_public_inputs::ParityPublicInputs; pub struct RootRollupParityInput { proof: NestedRecursiveProof, diff --git a/noir-projects/noir-protocol-circuits/crates/parity-root/src/main.nr b/noir-projects/noir-protocol-circuits/crates/parity-root/src/main.nr index 7356387215f..05850ad6169 100644 --- a/noir-projects/noir-protocol-circuits/crates/parity-root/src/main.nr +++ b/noir-projects/noir-protocol-circuits/crates/parity-root/src/main.nr @@ -1,4 +1,4 @@ -use dep::parity_lib::{RootParityInputs, ParityPublicInputs}; +use dep::parity_lib::{ParityPublicInputs, RootParityInputs}; #[recursive] fn main(inputs: RootParityInputs) -> pub ParityPublicInputs { diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-init-simulated/src/main.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-init-simulated/src/main.nr index 8d34da7efff..a3585b3a092 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-init-simulated/src/main.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-init-simulated/src/main.nr @@ -1,8 +1,8 @@ use dep::private_kernel_lib::PrivateKernelInitCircuitPrivateInputs; use dep::types::PrivateKernelCircuitPublicInputs; -use types::transaction::tx_request::TxRequest; -use types::abis::private_kernel::private_call_data::PrivateCallDataWithoutPublicInputs; use types::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs; +use types::abis::private_kernel::private_call_data::PrivateCallDataWithoutPublicInputs; +use types::transaction::tx_request::TxRequest; unconstrained fn main( tx_request: TxRequest, diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-init/src/main.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-init/src/main.nr index 8ed70c84e56..1553c4a86fa 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-init/src/main.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-init/src/main.nr @@ -1,8 +1,8 @@ use dep::private_kernel_lib::PrivateKernelInitCircuitPrivateInputs; use dep::types::PrivateKernelCircuitPublicInputs; -use types::transaction::tx_request::TxRequest; -use types::abis::private_kernel::private_call_data::PrivateCallDataWithoutPublicInputs; use types::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs; +use types::abis::private_kernel::private_call_data::PrivateCallDataWithoutPublicInputs; +use types::transaction::tx_request::TxRequest; fn main( tx_request: TxRequest, diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-inner-simulated/src/main.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-inner-simulated/src/main.nr index 930117c4bcc..15f931a5d75 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-inner-simulated/src/main.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-inner-simulated/src/main.nr @@ -1,8 +1,8 @@ use dep::private_kernel_lib::PrivateKernelInnerCircuitPrivateInputs; use dep::types::PrivateKernelCircuitPublicInputs; -use types::abis::private_kernel_data::PrivateKernelDataWithoutPublicInputs; -use types::abis::private_kernel::private_call_data::PrivateCallDataWithoutPublicInputs; use types::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs; +use types::abis::private_kernel::private_call_data::PrivateCallDataWithoutPublicInputs; +use types::abis::private_kernel_data::PrivateKernelDataWithoutPublicInputs; unconstrained fn main( previous_kernel: PrivateKernelDataWithoutPublicInputs, diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-inner/src/main.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-inner/src/main.nr index 54a3ae66fb5..11a51d9e694 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-inner/src/main.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-inner/src/main.nr @@ -1,8 +1,8 @@ use dep::private_kernel_lib::PrivateKernelInnerCircuitPrivateInputs; use dep::types::PrivateKernelCircuitPublicInputs; -use types::abis::private_kernel_data::PrivateKernelDataWithoutPublicInputs; -use types::abis::private_kernel::private_call_data::PrivateCallDataWithoutPublicInputs; use types::abis::private_circuit_public_inputs::PrivateCircuitPublicInputs; +use types::abis::private_kernel::private_call_data::PrivateCallDataWithoutPublicInputs; +use types::abis::private_kernel_data::PrivateKernelDataWithoutPublicInputs; fn main( previous_kernel: PrivateKernelDataWithoutPublicInputs, diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/previous_kernel_validator.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/previous_kernel_validator.nr index fdadacfe1ad..4476930b3a4 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/previous_kernel_validator.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/previous_kernel_validator.nr @@ -5,7 +5,9 @@ use crate::components::previous_kernel_validator::previous_kernel_validator_hint }; use dep::types::{ abis::{log_hash::ScopedEncryptedLogHash, private_kernel_data::PrivateKernelData}, - address::AztecAddress, traits::is_empty, utils::arrays::array_length, + address::AztecAddress, + traits::is_empty, + utils::arrays::array_length, }; pub struct PreviousKernelValidator { diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/previous_kernel_validator/previous_kernel_validator_hints.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/previous_kernel_validator/previous_kernel_validator_hints.nr index 28719890ab0..23927a82882 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/previous_kernel_validator/previous_kernel_validator_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/previous_kernel_validator/previous_kernel_validator_hints.nr @@ -1,7 +1,9 @@ use dep::types::{ abis::{ kernel_circuit_public_inputs::PrivateKernelCircuitPublicInputs, note_hash::ScopedNoteHash, - }, constants::{MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX}, utils::arrays::find_index_hint, + }, + constants::{MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX}, + utils::arrays::find_index_hint, }; pub struct PreviousKernelValidatorHints { diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_call_data_validator.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_call_data_validator.nr index 2fa422b6c00..24eaeec2842 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_call_data_validator.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_call_data_validator.nr @@ -9,11 +9,17 @@ use crate::components::private_call_data_validator::{ }; use dep::types::{ abis::{ - call_context::CallContext, kernel_circuit_public_inputs::PrivateKernelCircuitPublicInputs, - note_hash::ScopedNoteHash, private_call_request::PrivateCallRequest, + call_context::CallContext, + kernel_circuit_public_inputs::PrivateKernelCircuitPublicInputs, + note_hash::ScopedNoteHash, + private_call_request::PrivateCallRequest, private_circuit_public_inputs::PrivateCircuitPublicInputsArrayLengths, - private_kernel::private_call_data::PrivateCallData, side_effect::{Ordered, RangeOrdered}, - }, address::AztecAddress, constants::MAX_FIELD_VALUE, transaction::tx_request::TxRequest, + private_kernel::private_call_data::PrivateCallData, + side_effect::{Ordered, RangeOrdered}, + }, + address::AztecAddress, + constants::MAX_FIELD_VALUE, + transaction::tx_request::TxRequest, utils::arrays::find_index_hint, }; diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_output_validator.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_output_validator.nr index fcc7ed1819e..9784fefe4d0 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_output_validator.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_output_validator.nr @@ -3,11 +3,15 @@ use dep::types::{ abis::{ kernel_circuit_public_inputs::{ PrivateKernelCircuitPublicInputs, PrivateKernelCircuitPublicInputsArrayLengths, - }, max_block_number::MaxBlockNumber, + }, + max_block_number::MaxBlockNumber, private_circuit_public_inputs::{ PrivateCircuitPublicInputs, PrivateCircuitPublicInputsArrayLengths, }, - }, address::AztecAddress, traits::is_empty, transaction::tx_request::TxRequest, + }, + address::AztecAddress, + traits::is_empty, + transaction::tx_request::TxRequest, utils::arrays::{ assert_array_appended, assert_array_appended_reversed, assert_array_appended_scoped, assert_array_prepended, diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_public_inputs_composer.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_public_inputs_composer.nr index 67cfffefe28..f0702793359 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_public_inputs_composer.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_public_inputs_composer.nr @@ -3,9 +3,14 @@ use dep::types::{ combined_constant_data::CombinedConstantData, kernel_circuit_public_inputs::{ PrivateKernelCircuitPublicInputs, PrivateKernelCircuitPublicInputsBuilder, - }, max_block_number::MaxBlockNumber, nullifier::{Nullifier, ScopedNullifier}, + }, + max_block_number::MaxBlockNumber, + nullifier::{Nullifier, ScopedNullifier}, private_circuit_public_inputs::PrivateCircuitPublicInputs, - }, address::AztecAddress, traits::is_empty, transaction::tx_request::TxRequest, + }, + address::AztecAddress, + traits::is_empty, + transaction::tx_request::TxRequest, utils::arrays::{array_length, array_to_bounded_vec, sort_by_counter_asc, sort_by_counter_desc}, }; diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer.nr index 747f6594245..3d570925058 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer.nr @@ -3,17 +3,20 @@ mod reset_output_hints; pub use reset_output_hints::ResetOutputHints; use crate::components::reset_output_composer::reset_output_hints::generate_reset_output_hints; -use dep::reset_kernel_lib::{TransientDataIndexHint, PrivateValidationRequestProcessor}; +use dep::reset_kernel_lib::{PrivateValidationRequestProcessor, TransientDataIndexHint}; use dep::types::{ abis::{ kernel_circuit_public_inputs::PrivateKernelCircuitPublicInputs, - log_hash::{NoteLogHash, ScopedEncryptedLogHash}, note_hash::ScopedNoteHash, + log_hash::{NoteLogHash, ScopedEncryptedLogHash}, + note_hash::ScopedNoteHash, nullifier::ScopedNullifier, - }, address::AztecAddress, + }, + address::AztecAddress, constants::{ MAX_ENCRYPTED_LOGS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, - }, hash::{mask_encrypted_log_hash, silo_note_hash, silo_nullifier}, + }, + hash::{mask_encrypted_log_hash, silo_note_hash, silo_nullifier}, utils::arrays::sort_by_counter_asc, }; diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer/reset_output_hints.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer/reset_output_hints.nr index 9a669dd1701..a88cbd99565 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer/reset_output_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer/reset_output_hints.nr @@ -14,7 +14,8 @@ use dep::types::{ constants::{ MAX_ENCRYPTED_LOGS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, - }, utils::arrays::{OrderHint, get_order_hints_asc}, + }, + utils::arrays::{get_order_hints_asc, OrderHint}, }; pub struct ResetOutputHints { diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer/reset_output_hints/get_transient_or_propagated_note_hash_indexes_for_logs.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer/reset_output_hints/get_transient_or_propagated_note_hash_indexes_for_logs.nr index 208bfc36c15..d57b7c061d2 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer/reset_output_hints/get_transient_or_propagated_note_hash_indexes_for_logs.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer/reset_output_hints/get_transient_or_propagated_note_hash_indexes_for_logs.nr @@ -1,6 +1,7 @@ use dep::reset_kernel_lib::TransientDataIndexHint; use dep::types::{ - abis::{log_hash::NoteLogHash, note_hash::ScopedNoteHash}, utils::arrays::find_index_hint, + abis::{log_hash::NoteLogHash, note_hash::ScopedNoteHash}, + utils::arrays::find_index_hint, }; pub unconstrained fn get_transient_or_propagated_note_hash_indexes_for_logs( diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer/reset_output_hints/squash_transient_data.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer/reset_output_hints/squash_transient_data.nr index f6f17f626d2..b5879b1a2c3 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer/reset_output_hints/squash_transient_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer/reset_output_hints/squash_transient_data.nr @@ -1,6 +1,6 @@ use dep::reset_kernel_lib::TransientDataIndexHint; use dep::types::abis::{ - note_hash::ScopedNoteHash, nullifier::ScopedNullifier, log_hash::NoteLogHash, + log_hash::NoteLogHash, note_hash::ScopedNoteHash, nullifier::ScopedNullifier, }; pub unconstrained fn squash_transient_data( diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_validator.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_validator.nr index e0ab7346acc..c126b1ebf5b 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_validator.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_validator.nr @@ -5,9 +5,12 @@ use dep::reset_kernel_lib::{ use dep::types::{ abis::{ kernel_circuit_public_inputs::PrivateKernelCircuitPublicInputs, - log_hash::{NoteLogHash, ScopedEncryptedLogHash}, note_hash::ScopedNoteHash, + log_hash::{NoteLogHash, ScopedEncryptedLogHash}, + note_hash::ScopedNoteHash, nullifier::ScopedNullifier, - }, hash::{mask_encrypted_log_hash, silo_note_hash, silo_nullifier}, traits::is_empty, + }, + hash::{mask_encrypted_log_hash, silo_note_hash, silo_nullifier}, + traits::is_empty, utils::arrays::{ assert_sorted_transformed_value_array, assert_sorted_transformed_value_array_capped_size, }, diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_composer.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_composer.nr index 50ebb157830..44eca05c0f6 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_composer.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_composer.nr @@ -8,9 +8,11 @@ use dep::types::{ abis::{ accumulated_data::combined_accumulated_data::CombinedAccumulatedData, kernel_circuit_public_inputs::{KernelCircuitPublicInputs, PrivateKernelCircuitPublicInputs}, - log_hash::{ScopedEncryptedLogHash, NoteLogHash, ScopedLogHash}, note_hash::ScopedNoteHash, + log_hash::{NoteLogHash, ScopedEncryptedLogHash, ScopedLogHash}, + note_hash::ScopedNoteHash, nullifier::ScopedNullifier, - }, messaging::l2_to_l1_message::ScopedL2ToL1Message, + }, + messaging::l2_to_l1_message::ScopedL2ToL1Message, }; pub struct TailOutputComposer { diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_composer/meter_gas_used.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_composer/meter_gas_used.nr index cbe17a44eb0..7ecd1b59a77 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_composer/meter_gas_used.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_composer/meter_gas_used.nr @@ -4,9 +4,10 @@ use dep::types::{ gas_settings::GasSettings, }, constants::{ - DA_BYTES_PER_FIELD, DA_GAS_PER_BYTE, L2_GAS_PER_NOTE_HASH, L2_GAS_PER_NULLIFIER, - L2_GAS_PER_LOG_BYTE, - }, utils::arrays::array_length, + DA_BYTES_PER_FIELD, DA_GAS_PER_BYTE, L2_GAS_PER_LOG_BYTE, L2_GAS_PER_NOTE_HASH, + L2_GAS_PER_NULLIFIER, + }, + utils::arrays::array_length, }; pub fn meter_gas_used(data: CombinedAccumulatedData, gas_settings: GasSettings) -> Gas { diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_validator.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_validator.nr index 87b11475ae8..dbca9f64106 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_validator.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_validator.nr @@ -8,7 +8,9 @@ use dep::types::{ abis::{ kernel_circuit_public_inputs::{KernelCircuitPublicInputs, PrivateKernelCircuitPublicInputs}, log_hash::{NoteLogHash, ScopedEncryptedLogHash, ScopedLogHash}, - }, messaging::l2_to_l1_message::ScopedL2ToL1Message, traits::is_empty, + }, + messaging::l2_to_l1_message::ScopedL2ToL1Message, + traits::is_empty, utils::arrays::assert_exposed_sorted_transformed_value_array, }; diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_validator/tail_output_hints.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_validator/tail_output_hints.nr index 171a5547035..459c68948b5 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_validator/tail_output_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_validator/tail_output_hints.nr @@ -1,7 +1,7 @@ use dep::types::{ abis::{kernel_circuit_public_inputs::PrivateKernelCircuitPublicInputs, log_hash::ScopedLogHash}, constants::{MAX_L2_TO_L1_MSGS_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX}, - utils::arrays::{OrderHint, sort_by_counter_asc, get_order_hints_asc}, + utils::arrays::{get_order_hints_asc, OrderHint, sort_by_counter_asc}, }; pub struct TailOutputHints { diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_composer.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_composer.nr index 241256003e7..b32a7408dce 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_composer.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_composer.nr @@ -11,7 +11,8 @@ use crate::components::{ use dep::types::abis::{ kernel_circuit_public_inputs::{ PrivateKernelCircuitPublicInputs, PublicKernelCircuitPublicInputs, - }, validation_requests::PublicValidationRequests, + }, + validation_requests::PublicValidationRequests, }; pub struct TailToPublicOutputComposer { diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_composer/meter_gas_used.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_composer/meter_gas_used.nr index cc56b9bac00..a338db8f439 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_composer/meter_gas_used.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_composer/meter_gas_used.nr @@ -1,9 +1,10 @@ use dep::types::{ abis::{accumulated_data::PublicAccumulatedData, gas::Gas, log_hash::{LogHash, ScopedLogHash}}, constants::{ - DA_BYTES_PER_FIELD, DA_GAS_PER_BYTE, FIXED_AVM_STARTUP_L2_GAS, L2_GAS_PER_NOTE_HASH, - L2_GAS_PER_NULLIFIER, L2_GAS_PER_LOG_BYTE, - }, utils::arrays::array_length, + DA_BYTES_PER_FIELD, DA_GAS_PER_BYTE, FIXED_AVM_STARTUP_L2_GAS, L2_GAS_PER_LOG_BYTE, + L2_GAS_PER_NOTE_HASH, L2_GAS_PER_NULLIFIER, + }, + utils::arrays::array_length, }; fn meter_gas_used(data: PublicAccumulatedData) -> Gas { diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_validator.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_validator.nr index 2a80338180d..7201736c70e 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_validator.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_validator.nr @@ -12,10 +12,14 @@ use dep::types::{ abis::{ kernel_circuit_public_inputs::{ PrivateKernelCircuitPublicInputs, PublicKernelCircuitPublicInputs, - }, log_hash::{LogHash, ScopedEncryptedLogHash, NoteLogHash, ScopedLogHash}, - note_hash::ScopedNoteHash, nullifier::{Nullifier, ScopedNullifier}, + }, + log_hash::{LogHash, NoteLogHash, ScopedEncryptedLogHash, ScopedLogHash}, + note_hash::ScopedNoteHash, + nullifier::{Nullifier, ScopedNullifier}, public_call_request::PublicCallRequest, - }, messaging::l2_to_l1_message::ScopedL2ToL1Message, traits::is_empty_array, + }, + messaging::l2_to_l1_message::ScopedL2ToL1Message, + traits::is_empty_array, utils::arrays::{ assert_split_sorted_transformed_value_arrays_asc, assert_split_sorted_transformed_value_arrays_desc, assert_split_transformed_value_arrays, diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_validator/tail_to_public_output_hints.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_validator/tail_to_public_output_hints.nr index f46f0af3422..be4038a7515 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_validator/tail_to_public_output_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_validator/tail_to_public_output_hints.nr @@ -2,7 +2,8 @@ use dep::types::{ abis::kernel_circuit_public_inputs::PrivateKernelCircuitPublicInputs, constants::{ MAX_L2_TO_L1_MSGS_PER_TX, MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX, - }, utils::arrays::{get_split_order_hints_asc, get_split_order_hints_desc, SplitOrderHints}, + }, + utils::arrays::{get_split_order_hints_asc, get_split_order_hints_desc, SplitOrderHints}, }; pub struct TailToPublicOutputHints { diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/lib.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/lib.nr index a47d3cd2bc1..876871ae5c7 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/lib.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/lib.nr @@ -7,9 +7,9 @@ mod private_kernel_empty; mod private_kernel_reset; mod tests; +pub use private_kernel_empty::PrivateKernelEmptyPrivateInputs; pub use private_kernel_init::PrivateKernelInitCircuitPrivateInputs; pub use private_kernel_inner::PrivateKernelInnerCircuitPrivateInputs; pub use private_kernel_reset::PrivateKernelResetCircuitPrivateInputs; pub use private_kernel_tail::PrivateKernelTailCircuitPrivateInputs; pub use private_kernel_tail_to_public::PrivateKernelTailToPublicCircuitPrivateInputs; -pub use private_kernel_empty::PrivateKernelEmptyPrivateInputs; diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_empty.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_empty.nr index e13bee75379..f1042b6d945 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_empty.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_empty.nr @@ -1,9 +1,12 @@ use dep::types::{ - header::Header, KernelCircuitPublicInputs, traits::Empty, + header::Header, + KernelCircuitPublicInputs, recursion::{ - verification_key::{VerificationKey, HonkVerificationKey}, proof::RecursiveProof, + proof::RecursiveProof, traits::Verifiable, + verification_key::{HonkVerificationKey, VerificationKey}, }, + traits::Empty, }; pub struct EmptyNestedCircuitPublicInputs { @@ -62,7 +65,7 @@ impl Empty for PrivateKernelEmptyPrivateInputs { mod tests { use crate::private_kernel_empty::{ - PrivateKernelEmptyPrivateInputs, EmptyNestedCircuitPublicInputs, + EmptyNestedCircuitPublicInputs, PrivateKernelEmptyPrivateInputs, }; use dep::types::header::Header; diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_init.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_init.nr index d794b3f92af..5f6eceb0c47 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_init.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_init.nr @@ -6,9 +6,10 @@ use crate::components::{ use dep::types::{ abis::{ kernel_circuit_public_inputs::PrivateKernelCircuitPublicInputs, - private_kernel::private_call_data::{PrivateCallData, PrivateCallDataWithoutPublicInputs}, private_circuit_public_inputs::PrivateCircuitPublicInputs, - }, transaction::tx_request::TxRequest, + private_kernel::private_call_data::{PrivateCallData, PrivateCallDataWithoutPublicInputs}, + }, + transaction::tx_request::TxRequest, }; // Initialization struct for private inputs to the private kernel diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_inner.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_inner.nr index 40321bb4cb1..b63f31ede3d 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_inner.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_inner.nr @@ -8,9 +8,10 @@ use dep::types::{ abis::{ kernel_circuit_public_inputs::{ PrivateKernelCircuitPublicInputs, PrivateKernelCircuitPublicInputsArrayLengths, - }, private_kernel_data::{PrivateKernelData, PrivateKernelDataWithoutPublicInputs}, - private_kernel::private_call_data::{PrivateCallData, PrivateCallDataWithoutPublicInputs}, + }, private_circuit_public_inputs::PrivateCircuitPublicInputs, + private_kernel::private_call_data::{PrivateCallData, PrivateCallDataWithoutPublicInputs}, + private_kernel_data::{PrivateKernelData, PrivateKernelDataWithoutPublicInputs}, }, constants::{PRIVATE_KERNEL_INIT_INDEX, PRIVATE_KERNEL_INNER_INDEX, PRIVATE_KERNEL_RESET_INDEX}, }; @@ -83,11 +84,11 @@ impl PrivateKernelInnerCircuitPrivateInputs { mod tests { use crate::private_kernel_inner::{ - PrivateKernelInnerCircuitPrivateInputs, ALLOWED_PREVIOUS_CIRCUITS, + ALLOWED_PREVIOUS_CIRCUITS, PrivateKernelInnerCircuitPrivateInputs, }; use dep::types::{ abis::kernel_circuit_public_inputs::PrivateKernelCircuitPublicInputs, - constants::{PRIVATE_KERNEL_INIT_INDEX, BASE_ROLLUP_INDEX}, + constants::{BASE_ROLLUP_INDEX, PRIVATE_KERNEL_INIT_INDEX}, tests::{fixture_builder::FixtureBuilder, utils::assert_array_eq}, }; diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_reset.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_reset.nr index d862f5c3eb0..682c7a0a521 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_reset.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_reset.nr @@ -125,30 +125,37 @@ impl { diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail.nr index d1fecb668cc..8e8268ad5b4 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail.nr @@ -4,8 +4,8 @@ use crate::components::{ }; use dep::types::{ abis::{ - private_kernel_data::{PrivateKernelData, PrivateKernelDataWithoutPublicInputs}, kernel_circuit_public_inputs::KernelCircuitPublicInputs, + private_kernel_data::{PrivateKernelData, PrivateKernelDataWithoutPublicInputs}, }, constants::{PRIVATE_KERNEL_INIT_INDEX, PRIVATE_KERNEL_INNER_INDEX, PRIVATE_KERNEL_RESET_INDEX}, PrivateKernelCircuitPublicInputs, @@ -52,18 +52,21 @@ impl PrivateKernelTailCircuitPrivateInputs { mod tests { use crate::private_kernel_tail::{ - PrivateKernelTailCircuitPrivateInputs, ALLOWED_PREVIOUS_CIRCUITS, - }; - use dep::types::constants::{ - DA_BYTES_PER_FIELD, DA_GAS_PER_BYTE, GENERATOR_INDEX__IVSK_M, L2_GAS_PER_LOG_BYTE, - L2_GAS_PER_NULLIFIER, PRIVATE_KERNEL_INNER_INDEX, BASE_ROLLUP_INDEX, + ALLOWED_PREVIOUS_CIRCUITS, PrivateKernelTailCircuitPrivateInputs, }; use dep::types::{ abis::{ - kernel_circuit_public_inputs::KernelCircuitPublicInputs, - max_block_number::MaxBlockNumber, gas::Gas, log_hash::ScopedLogHash, - }, address::{AztecAddress, EthAddress}, tests::fixture_builder::FixtureBuilder, - traits::is_empty, point::Point, + gas::Gas, kernel_circuit_public_inputs::KernelCircuitPublicInputs, + log_hash::ScopedLogHash, max_block_number::MaxBlockNumber, + }, + address::{AztecAddress, EthAddress}, + point::Point, + tests::fixture_builder::FixtureBuilder, + traits::is_empty, + }; + use dep::types::constants::{ + BASE_ROLLUP_INDEX, DA_BYTES_PER_FIELD, DA_GAS_PER_BYTE, GENERATOR_INDEX__IVSK_M, + L2_GAS_PER_LOG_BYTE, L2_GAS_PER_NULLIFIER, PRIVATE_KERNEL_INNER_INDEX, }; // TODO: Reduce the duplicated code/tests for PrivateKernelTailInputs and PrivateKernelTailToPublicInputs. diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail_to_public.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail_to_public.nr index 93023d588c7..7910463a800 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail_to_public.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail_to_public.nr @@ -5,8 +5,8 @@ use crate::components::{ }; use dep::types::{ abis::{ - private_kernel_data::{PrivateKernelData, PrivateKernelDataWithoutPublicInputs}, kernel_circuit_public_inputs::PublicKernelCircuitPublicInputs, + private_kernel_data::{PrivateKernelData, PrivateKernelDataWithoutPublicInputs}, }, constants::{PRIVATE_KERNEL_INIT_INDEX, PRIVATE_KERNEL_INNER_INDEX, PRIVATE_KERNEL_RESET_INDEX}, PrivateKernelCircuitPublicInputs, @@ -53,20 +53,24 @@ impl PrivateKernelTailToPublicCircuitPrivateInputs { mod tests { use crate::private_kernel_tail_to_public::{ - PrivateKernelTailToPublicCircuitPrivateInputs, ALLOWED_PREVIOUS_CIRCUITS, - }; - use dep::types::constants::{ - DA_BYTES_PER_FIELD, DA_GAS_PER_BYTE, GENERATOR_INDEX__TSK_M, L2_GAS_PER_LOG_BYTE, - L2_GAS_PER_NOTE_HASH, L2_GAS_PER_NULLIFIER, FIXED_AVM_STARTUP_L2_GAS, + ALLOWED_PREVIOUS_CIRCUITS, PrivateKernelTailToPublicCircuitPrivateInputs, }; use dep::types::{ abis::{ - kernel_circuit_public_inputs::PublicKernelCircuitPublicInputs, gas::Gas, - note_hash::ScopedNoteHash, nullifier::{Nullifier, ScopedNullifier}, + gas::Gas, + kernel_circuit_public_inputs::PublicKernelCircuitPublicInputs, log_hash::{LogHash, NoteLogHash}, - }, address::{AztecAddress, EthAddress}, - tests::{fixture_builder::FixtureBuilder, utils::assert_array_eq}, point::Point, + note_hash::ScopedNoteHash, + nullifier::{Nullifier, ScopedNullifier}, + }, + address::{AztecAddress, EthAddress}, constants::PRIVATE_KERNEL_INNER_INDEX, + point::Point, + tests::{fixture_builder::FixtureBuilder, utils::assert_array_eq}, + }; + use dep::types::constants::{ + DA_BYTES_PER_FIELD, DA_GAS_PER_BYTE, FIXED_AVM_STARTUP_L2_GAS, GENERATOR_INDEX__TSK_M, + L2_GAS_PER_LOG_BYTE, L2_GAS_PER_NOTE_HASH, L2_GAS_PER_NULLIFIER, }; // TODO: Reduce the duplicated code/tests for PrivateKernelTailToPublicInputs and PrivateKernelTailInputs. diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_call_data_validator_builder/mod.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_call_data_validator_builder/mod.nr index 5f0d70f292b..58b753d3b01 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_call_data_validator_builder/mod.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_call_data_validator_builder/mod.nr @@ -15,7 +15,9 @@ use dep::types::{ abis::{ note_hash::ScopedNoteHash, private_call_request::PrivateCallRequest, private_kernel::private_call_data::PrivateCallData, - }, tests::fixture_builder::FixtureBuilder, transaction::tx_request::TxRequest, + }, + tests::fixture_builder::FixtureBuilder, + transaction::tx_request::TxRequest, }; pub struct PrivateCallDataValidatorBuilder { diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_output_validator_builder/mod.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_output_validator_builder/mod.nr index f614d5ed1e4..0604a83155e 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_output_validator_builder/mod.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_output_validator_builder/mod.nr @@ -9,11 +9,13 @@ use crate::components::{ }; use dep::types::{ abis::{ - private_call_request::PrivateCallRequest, kernel_circuit_public_inputs::PrivateKernelCircuitPublicInputsArrayLengths, + private_call_request::PrivateCallRequest, private_circuit_public_inputs::PrivateCircuitPublicInputsArrayLengths, - }, tests::fixture_builder::FixtureBuilder, transaction::tx_request::TxRequest, + }, constants::PRIVATE_KERNEL_INIT_INDEX, + tests::fixture_builder::FixtureBuilder, + transaction::tx_request::TxRequest, }; pub struct PrivateKernelCircuitOutputValidatorBuilder { diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_public_inputs_composer_builder/mod.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_public_inputs_composer_builder/mod.nr index adc4b05947d..3ccc2438ab7 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_public_inputs_composer_builder/mod.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_public_inputs_composer_builder/mod.nr @@ -7,7 +7,9 @@ use dep::types::{ abis::{ kernel_circuit_public_inputs::PrivateKernelCircuitPublicInputs, private_call_request::PrivateCallRequest, - }, tests::fixture_builder::FixtureBuilder, transaction::tx_request::TxRequest, + }, + tests::fixture_builder::FixtureBuilder, + transaction::tx_request::TxRequest, }; pub struct PrivateKernelCircuitPublicInputsComposerBuilder { diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_public_inputs_composer_builder/new_from_previous_kernel_with_private_call.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_public_inputs_composer_builder/new_from_previous_kernel_with_private_call.nr index 092cf5a2529..d11b387c074 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_public_inputs_composer_builder/new_from_previous_kernel_with_private_call.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_public_inputs_composer_builder/new_from_previous_kernel_with_private_call.nr @@ -1,7 +1,7 @@ use crate::tests::private_kernel_circuit_public_inputs_composer_builder::PrivateKernelCircuitPublicInputsComposerBuilder; use dep::types::{ abis::kernel_circuit_public_inputs::PrivateKernelCircuitPublicInputsArrayLengths, - traits::is_empty, tests::utils::assert_array_eq, + tests::utils::assert_array_eq, traits::is_empty, }; #[test] diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_public_inputs_composer_builder/propagate_from_private_call.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_public_inputs_composer_builder/propagate_from_private_call.nr index 75f70cad1ac..07094557fd3 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_public_inputs_composer_builder/propagate_from_private_call.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/private_kernel_circuit_public_inputs_composer_builder/propagate_from_private_call.nr @@ -4,7 +4,7 @@ use crate::{ }; use dep::types::{ abis::kernel_circuit_public_inputs::PrivateKernelCircuitPublicInputsArrayLengths, - traits::is_empty, tests::utils::assert_array_eq, + tests::utils::assert_array_eq, traits::is_empty, }; #[test] diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/reset_output_validator_builder/mod.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/reset_output_validator_builder/mod.nr index 46fbe569a48..71955e0ebd5 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/reset_output_validator_builder/mod.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/reset_output_validator_builder/mod.nr @@ -6,7 +6,8 @@ use crate::components::{ reset_output_validator::ResetOutputValidator, }; use dep::reset_kernel_lib::{ - KeyValidationHint, PrivateValidationRequestProcessor, + KeyValidationHint, + PrivateValidationRequestProcessor, tests::{NoteHashReadRequestHintsBuilder, NullifierReadRequestHintsBuilder}, TransientDataIndexHint, }; diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_output_composer_builder/meter_gas_used.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_output_composer_builder/meter_gas_used.nr index ff5644f9c26..3a04eb2c387 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_output_composer_builder/meter_gas_used.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_output_composer_builder/meter_gas_used.nr @@ -2,9 +2,10 @@ use crate::components::tail_output_composer::meter_gas_used::meter_gas_used; use dep::types::{ abis::gas::Gas, constants::{ - DA_BYTES_PER_FIELD, DA_GAS_PER_BYTE, L2_GAS_PER_NOTE_HASH, L2_GAS_PER_NULLIFIER, - L2_GAS_PER_LOG_BYTE, - }, tests::fixture_builder::FixtureBuilder, + DA_BYTES_PER_FIELD, DA_GAS_PER_BYTE, L2_GAS_PER_LOG_BYTE, L2_GAS_PER_NOTE_HASH, + L2_GAS_PER_NULLIFIER, + }, + tests::fixture_builder::FixtureBuilder, }; fn new_builder() -> FixtureBuilder { diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_output_validator_builder/mod.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_output_validator_builder/mod.nr index e3a784e5081..7bc01c93661 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_output_validator_builder/mod.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_output_validator_builder/mod.nr @@ -6,7 +6,8 @@ mod validate_propagated_values; use crate::components::{ tail_output_composer::meter_gas_used::meter_gas_used, tail_output_validator::{ - tail_output_hints::{generate_tail_output_hints, TailOutputHints}, TailOutputValidator, + tail_output_hints::{generate_tail_output_hints, TailOutputHints}, + TailOutputValidator, }, }; use dep::types::{ diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_to_public_output_composer_builder/meter_gas_used.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_to_public_output_composer_builder/meter_gas_used.nr index 2c6fb1d2e23..f85e960474e 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_to_public_output_composer_builder/meter_gas_used.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_to_public_output_composer_builder/meter_gas_used.nr @@ -4,9 +4,10 @@ use crate::components::tail_to_public_output_composer::meter_gas_used::{ use dep::types::{ abis::gas::Gas, constants::{ - DA_BYTES_PER_FIELD, DA_GAS_PER_BYTE, FIXED_AVM_STARTUP_L2_GAS, L2_GAS_PER_NOTE_HASH, - L2_GAS_PER_NULLIFIER, L2_GAS_PER_LOG_BYTE, - }, tests::fixture_builder::FixtureBuilder, + DA_BYTES_PER_FIELD, DA_GAS_PER_BYTE, FIXED_AVM_STARTUP_L2_GAS, L2_GAS_PER_LOG_BYTE, + L2_GAS_PER_NOTE_HASH, L2_GAS_PER_NULLIFIER, + }, + tests::fixture_builder::FixtureBuilder, }; #[test] diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_to_public_output_composer_builder/tail_to_public_output_composer.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_to_public_output_composer_builder/tail_to_public_output_composer.nr index ba858cbe75d..02cea830552 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_to_public_output_composer_builder/tail_to_public_output_composer.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/tests/tail_to_public_output_composer_builder/tail_to_public_output_composer.nr @@ -2,9 +2,10 @@ use crate::tests::tail_to_public_output_composer_builder::TailToPublicOutputComp use dep::types::{ abis::gas::Gas, constants::{ - DA_BYTES_PER_FIELD, DA_GAS_PER_BYTE, FIXED_AVM_STARTUP_L2_GAS, L2_GAS_PER_NOTE_HASH, - L2_GAS_PER_NULLIFIER, L2_GAS_PER_LOG_BYTE, - }, tests::utils::{assert_array_eq, swap_items}, + DA_BYTES_PER_FIELD, DA_GAS_PER_BYTE, FIXED_AVM_STARTUP_L2_GAS, L2_GAS_PER_LOG_BYTE, + L2_GAS_PER_NOTE_HASH, L2_GAS_PER_NULLIFIER, + }, + tests::utils::{assert_array_eq, swap_items}, }; #[test] @@ -140,7 +141,7 @@ fn tail_to_public_output_composer_succeeds() { // Gas: revertible let total_num_side_effects = 2 + 1 + 1; let total_log_length = 20 // note_encrypted_log_hash - + 6 + + 6 + 24 // encrypted_log_hash + 4; // unencrypted_log_hash let computed_da_gas = diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-reset-simulated/src/main.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-reset-simulated/src/main.nr index 7884b49de77..89199192db0 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-reset-simulated/src/main.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-reset-simulated/src/main.nr @@ -1,13 +1,13 @@ use dep::private_kernel_lib::private_kernel_reset::{ - PrivateKernelResetHints, PrivateKernelResetCircuitPrivateInputs, + PrivateKernelResetCircuitPrivateInputs, PrivateKernelResetHints, }; use dep::types::{ - PrivateKernelCircuitPublicInputs, constants::{ - MAX_ENCRYPTED_LOGS_PER_TX, MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NOTE_HASHES_PER_TX, + MAX_ENCRYPTED_LOGS_PER_TX, MAX_KEY_VALIDATION_REQUESTS_PER_TX, + MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_NULLIFIERS_PER_TX, - MAX_KEY_VALIDATION_REQUESTS_PER_TX, }, + PrivateKernelCircuitPublicInputs, }; use types::abis::private_kernel_data::PrivateKernelDataWithoutPublicInputs; diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-reset/src/main.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-reset/src/main.nr index dc6185015d9..a5371db73d7 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-reset/src/main.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-reset/src/main.nr @@ -1,13 +1,13 @@ use dep::private_kernel_lib::private_kernel_reset::{ - PrivateKernelResetHints, PrivateKernelResetCircuitPrivateInputs, + PrivateKernelResetCircuitPrivateInputs, PrivateKernelResetHints, }; use dep::types::{ - PrivateKernelCircuitPublicInputs, constants::{ - MAX_ENCRYPTED_LOGS_PER_TX, MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NOTE_HASHES_PER_TX, + MAX_ENCRYPTED_LOGS_PER_TX, MAX_KEY_VALIDATION_REQUESTS_PER_TX, + MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_NULLIFIERS_PER_TX, - MAX_KEY_VALIDATION_REQUESTS_PER_TX, }, + PrivateKernelCircuitPublicInputs, }; use types::abis::private_kernel_data::PrivateKernelDataWithoutPublicInputs; diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-tail-simulated/src/main.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-tail-simulated/src/main.nr index fa99dc2bea4..285d20b1395 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-tail-simulated/src/main.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-tail-simulated/src/main.nr @@ -1,7 +1,7 @@ use dep::private_kernel_lib::PrivateKernelTailCircuitPrivateInputs; use dep::types::KernelCircuitPublicInputs; -use types::abis::private_kernel_data::PrivateKernelDataWithoutPublicInputs; use types::abis::kernel_circuit_public_inputs::PrivateKernelCircuitPublicInputs; +use types::abis::private_kernel_data::PrivateKernelDataWithoutPublicInputs; unconstrained fn main( previous_kernel: PrivateKernelDataWithoutPublicInputs, diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-tail-to-public-simulated/src/main.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-tail-to-public-simulated/src/main.nr index dbbc22e0df6..85f93ac33e3 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-tail-to-public-simulated/src/main.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-tail-to-public-simulated/src/main.nr @@ -1,7 +1,7 @@ use dep::private_kernel_lib::PrivateKernelTailToPublicCircuitPrivateInputs; use dep::types::PublicKernelCircuitPublicInputs; -use types::abis::private_kernel_data::PrivateKernelDataWithoutPublicInputs; use types::abis::kernel_circuit_public_inputs::PrivateKernelCircuitPublicInputs; +use types::abis::private_kernel_data::PrivateKernelDataWithoutPublicInputs; unconstrained fn main( previous_kernel: PrivateKernelDataWithoutPublicInputs, diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-tail-to-public/src/main.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-tail-to-public/src/main.nr index ea2bd39412e..b3921692128 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-tail-to-public/src/main.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-tail-to-public/src/main.nr @@ -1,7 +1,7 @@ use dep::private_kernel_lib::PrivateKernelTailToPublicCircuitPrivateInputs; use dep::types::PublicKernelCircuitPublicInputs; -use types::abis::private_kernel_data::PrivateKernelDataWithoutPublicInputs; use types::abis::kernel_circuit_public_inputs::PrivateKernelCircuitPublicInputs; +use types::abis::private_kernel_data::PrivateKernelDataWithoutPublicInputs; fn main( previous_kernel: PrivateKernelDataWithoutPublicInputs, diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-tail/src/main.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-tail/src/main.nr index 675e7f082a6..f520694f68b 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-tail/src/main.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-tail/src/main.nr @@ -1,7 +1,7 @@ use dep::private_kernel_lib::PrivateKernelTailCircuitPrivateInputs; use dep::types::KernelCircuitPublicInputs; -use types::abis::private_kernel_data::PrivateKernelDataWithoutPublicInputs; use types::abis::kernel_circuit_public_inputs::PrivateKernelCircuitPublicInputs; +use types::abis::private_kernel_data::PrivateKernelDataWithoutPublicInputs; fn main( previous_kernel: PrivateKernelDataWithoutPublicInputs, diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/enqueued_call_data_validator.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/enqueued_call_data_validator.nr index 13f96c95651..874779c9b90 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/enqueued_call_data_validator.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/enqueued_call_data_validator.nr @@ -1,11 +1,13 @@ use crate::public_kernel_phase::PublicKernelPhase; use dep::types::{ abis::{ - accumulated_data::PublicAccumulatedDataArrayLengths, + accumulated_data::PublicAccumulatedDataArrayLengths, enqueued_call_data::EnqueuedCallData, kernel_circuit_public_inputs::PublicKernelCircuitPublicInputs, - enqueued_call_data::EnqueuedCallData, public_call_request::PublicCallRequest, + public_call_request::PublicCallRequest, validation_requests::PublicValidationRequestArrayLengths, - }, constants::MAX_L2_GAS_PER_ENQUEUED_CALL, utils::arrays::array_length, + }, + constants::MAX_L2_GAS_PER_ENQUEUED_CALL, + utils::arrays::array_length, }; pub struct EnqueuedCallDataValidator { diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_kernel_output_composer.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_kernel_output_composer.nr index e073a9d9bc5..0c982cd789d 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_kernel_output_composer.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_kernel_output_composer.nr @@ -10,8 +10,10 @@ use dep::types::{ kernel_circuit_public_inputs::{ PublicKernelCircuitPublicInputs, PublicKernelCircuitPublicInputsBuilder, VMCircuitPublicInputs, - }, public_call_request::PublicCallRequest, - }, traits::is_empty, + }, + public_call_request::PublicCallRequest, + }, + traits::is_empty, }; pub struct PublicKernelOutputComposer { diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_kernel_output_validator.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_kernel_output_validator.nr index 52e0af2d111..d54de5d49e6 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_kernel_output_validator.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_kernel_output_validator.nr @@ -3,9 +3,11 @@ use dep::types::{ abis::{ accumulated_data::public_accumulated_data::{ PublicAccumulatedData, PublicAccumulatedDataArrayLengths, - }, kernel_circuit_public_inputs::{PublicKernelCircuitPublicInputs, VMCircuitPublicInputs}, + }, + kernel_circuit_public_inputs::{PublicKernelCircuitPublicInputs, VMCircuitPublicInputs}, validation_requests::public_validation_requests::PublicValidationRequestArrayLengths, - }, traits::is_empty, + }, + traits::is_empty, utils::arrays::{array_length, assert_array_appended, assert_array_prepended}, }; diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer.nr index 61a302e5187..70f8219bf52 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer.nr @@ -12,7 +12,9 @@ use crate::components::public_tail_output_composer::{ use dep::types::{ abis::kernel_circuit_public_inputs::{ KernelCircuitPublicInputs, PublicKernelCircuitPublicInputs, - }, data::PublicDataLeafHint, partial_state_reference::PartialStateReference, + }, + data::PublicDataLeafHint, + partial_state_reference::PartialStateReference, }; pub struct PublicTailOutputComposer { diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/combine_data.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/combine_data.nr index 01c537cf41f..e6362a42aa8 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/combine_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/combine_data.nr @@ -2,8 +2,10 @@ use crate::components::public_tail_output_composer::generate_output_hints::Outpu use dep::types::{ abis::{ accumulated_data::{CombinedAccumulatedData, PublicAccumulatedData}, - log_hash::{LogHash, ScopedLogHash}, nullifier::Nullifier, - }, utils::arrays::{array_merge, dedupe_array, sort_by_counter_asc}, + log_hash::{LogHash, ScopedLogHash}, + nullifier::Nullifier, + }, + utils::arrays::{array_merge, dedupe_array, sort_by_counter_asc}, }; pub unconstrained fn combine_data( diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_output_hints.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_output_hints.nr index 17d38d69f39..e36f4ef41a8 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_output_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_output_hints.nr @@ -1,7 +1,8 @@ use crate::components::public_tail_output_composer::{ generate_overridable_public_data_writes::{ generate_overridable_public_data_writes, LinkedIndexHint, - }, generate_public_data_leaves::generate_public_data_leaves, + }, + generate_public_data_leaves::generate_public_data_leaves, }; use dep::types::{ abis::{ @@ -9,10 +10,12 @@ use dep::types::{ public_data_write::OverridablePublicDataWrite, }, constants::{ - MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, - MAX_UNENCRYPTED_LOGS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, MAX_ENCRYPTED_LOGS_PER_TX, - MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, - }, data::{OverridablePublicDataTreeLeaf, PublicDataLeafHint}, hash::silo_note_hash, + MAX_ENCRYPTED_LOGS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, + MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, + MAX_UNENCRYPTED_LOGS_PER_TX, + }, + data::{OverridablePublicDataTreeLeaf, PublicDataLeafHint}, + hash::silo_note_hash, traits::Empty, utils::arrays::{ array_merge, CombinedOrderHint, get_combined_order_hints_asc, sort_by_counter_asc, diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_overridable_public_data_writes.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_overridable_public_data_writes.nr index f67768f322c..e18193b31be 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_overridable_public_data_writes.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_overridable_public_data_writes.nr @@ -2,7 +2,9 @@ use dep::types::{ abis::{ public_data_update_request::PublicDataUpdateRequest, public_data_write::OverridablePublicDataWrite, - }, data::OverridablePublicDataTreeLeaf, traits::Empty, + }, + data::OverridablePublicDataTreeLeaf, + traits::Empty, utils::arrays::{array_length, find_index_hint}, }; diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_public_data_leaves.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_public_data_leaves.nr index 7f73cccfe48..0a2f95e8392 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_public_data_leaves.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_public_data_leaves.nr @@ -1,6 +1,7 @@ use dep::types::{ abis::{public_data_read::PublicDataRead, public_data_update_request::PublicDataUpdateRequest}, - data::{OverridablePublicDataTreeLeaf, PublicDataLeafHint, PublicDataTreeLeaf}, traits::Empty, + data::{OverridablePublicDataTreeLeaf, PublicDataLeafHint, PublicDataTreeLeaf}, + traits::Empty, utils::arrays::{get_sorted_result, SortedResult}, }; diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_validator.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_validator.nr index 61e98866d8c..4b5da5a4d8f 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_validator.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_validator.nr @@ -3,19 +3,24 @@ mod validate_public_data_leaf_memberships; mod validate_unique_leaf_slots; use crate::components::{ + public_tail_output_composer::{OutputHints, SiloedNoteHashHint}, public_tail_output_validator::{ validate_linked_public_data_writes::validate_linked_public_data_writes, validate_public_data_leaf_memberships::validate_public_data_leaf_memberships, validate_unique_leaf_slots::validate_unique_leaf_slots, - }, public_tail_output_composer::{OutputHints, SiloedNoteHashHint}, + }, }; use dep::types::{ abis::{ kernel_circuit_public_inputs::{KernelCircuitPublicInputs, PublicKernelCircuitPublicInputs}, - log_hash::{LogHash, ScopedLogHash}, note_hash::ScopedNoteHash, nullifier::Nullifier, + log_hash::{LogHash, ScopedLogHash}, + note_hash::ScopedNoteHash, + nullifier::Nullifier, public_data_update_request::PublicDataUpdateRequest, public_data_write::OverridablePublicDataWrite, - }, data::PublicDataLeafHint, hash::silo_note_hash, + }, + data::PublicDataLeafHint, + hash::silo_note_hash, messaging::l2_to_l1_message::ScopedL2ToL1Message, partial_state_reference::PartialStateReference, utils::arrays::{ diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_validator/validate_linked_public_data_writes.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_validator/validate_linked_public_data_writes.nr index 881478ac767..44bea48e398 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_validator/validate_linked_public_data_writes.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_validator/validate_linked_public_data_writes.nr @@ -57,9 +57,11 @@ mod tests { }; use dep::types::{ abis::{ - public_data_write::OverridablePublicDataWrite, public_data_update_request::PublicDataUpdateRequest, - }, data::{OverridablePublicDataTreeLeaf, PublicDataTreeLeaf}, tests::utils::pad_end, + public_data_write::OverridablePublicDataWrite, + }, + data::{OverridablePublicDataTreeLeaf, PublicDataTreeLeaf}, + tests::utils::pad_end, }; struct TestBuilder { diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_validator/validate_unique_leaf_slots.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_validator/validate_unique_leaf_slots.nr index 63fd9ffea1e..e0c3ec42171 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_validator/validate_unique_leaf_slots.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_validator/validate_unique_leaf_slots.nr @@ -30,7 +30,8 @@ pub fn validate_unique_leaf_slots( mod tests { use crate::components::public_tail_output_validator::validate_unique_leaf_slots::validate_unique_leaf_slots; use dep::types::{ - data::{OverridablePublicDataTreeLeaf, PublicDataTreeLeaf}, tests::utils::pad_end, + data::{OverridablePublicDataTreeLeaf, PublicDataTreeLeaf}, + tests::utils::pad_end, utils::arrays::SortedResult, }; diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/vm_circuit_output_composer.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/vm_circuit_output_composer.nr index 8318a02c6c3..2a492590f23 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/vm_circuit_output_composer.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/vm_circuit_output_composer.nr @@ -4,16 +4,20 @@ use crate::components::vm_circuit_output_composer::propagate_accumulated_data::p use dep::types::{ abis::{ accumulated_data::{PublicAccumulatedDataArrayLengths, PublicAccumulatedDataBuilder}, - combined_constant_data::CombinedConstantData, gas::Gas, + combined_constant_data::CombinedConstantData, + gas::Gas, kernel_circuit_public_inputs::vm_circuit_public_inputs::VMCircuitPublicInputs, public_call_request::PublicCallRequest, - public_circuit_public_inputs::PublicCircuitPublicInputs, public_data_read::PublicDataRead, + public_circuit_public_inputs::PublicCircuitPublicInputs, + public_data_read::PublicDataRead, public_inner_call_request::PublicInnerCallRequest, validation_requests::{ - PublicValidationRequestArrayLengths, public_validation_requests_builder::PublicValidationRequestsBuilder, + PublicValidationRequestArrayLengths, }, - }, constants::MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, traits::is_empty, + }, + constants::MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, + traits::is_empty, utils::arrays::array_to_bounded_vec, }; diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/vm_circuit_output_composer/propagate_accumulated_data.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/vm_circuit_output_composer/propagate_accumulated_data.nr index 3c1df8c3fbf..6010ea888b4 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/vm_circuit_output_composer/propagate_accumulated_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/vm_circuit_output_composer/propagate_accumulated_data.nr @@ -3,7 +3,8 @@ use dep::types::{ accumulated_data::PublicAccumulatedDataBuilder, nullifier::Nullifier, public_circuit_public_inputs::PublicCircuitPublicInputs, public_data_update_request::PublicDataUpdateRequest, - }, hash::compute_siloed_nullifier, + }, + hash::compute_siloed_nullifier, }; pub fn propagate_accumulated_data( diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_inner.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_inner.nr index 82790088d16..8d5ceb2bbab 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_inner.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_inner.nr @@ -1,7 +1,7 @@ use crate::components::vm_circuit_output_composer::VMCircuitOutputComposer; use dep::types::abis::{ - kernel_circuit_public_inputs::VMCircuitPublicInputs, - public_kernel_inner_data::PublicKernelInnerData, public_call_data::PublicCallData, + kernel_circuit_public_inputs::VMCircuitPublicInputs, public_call_data::PublicCallData, + public_kernel_inner_data::PublicKernelInnerData, }; // TODO(#7124): To be deprecated. diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_merge.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_merge.nr index 6fa7f50fd1c..26283872651 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_merge.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_merge.nr @@ -4,14 +4,16 @@ use crate::{ previous_kernel_validator::PreviousKernelValidator, public_kernel_output_composer::PublicKernelOutputComposer, public_kernel_output_validator::PublicKernelOutputValidator, - }, public_kernel_phase::PublicKernelPhase, + }, + public_kernel_phase::PublicKernelPhase, }; use dep::types::{ abis::{ enqueued_call_data::EnqueuedCallData, kernel_circuit_public_inputs::PublicKernelCircuitPublicInputs, public_kernel_data::PublicKernelData, - }, constants::{TUBE_INDEX, PUBLIC_KERNEL_MERGE_INDEX}, + }, + constants::{PUBLIC_KERNEL_MERGE_INDEX, TUBE_INDEX}, }; global ALLOWED_PREVIOUS_CIRCUITS = [TUBE_INDEX, PUBLIC_KERNEL_MERGE_INDEX]; @@ -80,8 +82,8 @@ impl PublicKernelMergeCircuitPrivateInputs { mod tests { use crate::{ - public_kernel_phase::PublicKernelPhase, public_kernel_merge::{ALLOWED_PREVIOUS_CIRCUITS, PublicKernelMergeCircuitPrivateInputs}, + public_kernel_phase::PublicKernelPhase, }; use dep::types::{ abis::{ @@ -89,7 +91,8 @@ mod tests { kernel_circuit_public_inputs::PublicKernelCircuitPublicInputs, max_block_number::MaxBlockNumber, validation_requests::PublicValidationRequestArrayLengths, - }, constants::{PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX, BASE_ROLLUP_INDEX}, + }, + constants::{BASE_ROLLUP_INDEX, PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX}, tests::{fixture_builder::FixtureBuilder, utils::assert_array_eq}, }; diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_tail.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_tail.nr index fc4ec877a16..6f28560c91e 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_tail.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_tail.nr @@ -3,14 +3,17 @@ use crate::{ previous_kernel_validator::PreviousKernelValidator, public_tail_output_composer::{OutputHints, PublicTailOutputComposer}, public_tail_output_validator::PublicTailOutputValidator, - }, public_kernel_phase::PublicKernelPhase, + }, + public_kernel_phase::PublicKernelPhase, }; use dep::reset_kernel_lib::{ - NullifierReadRequestHints, NullifierNonExistentReadRequestHints, - PublicValidationRequestProcessor, + NullifierNonExistentReadRequestHints, + NullifierReadRequestHints, public_data_read_request_hints::{ build_public_data_read_request_hints, PublicDataReadRequestHints, - }, TreeLeafReadRequestHint, + }, + PublicValidationRequestProcessor, + TreeLeafReadRequestHint, }; use dep::types::{ abis::{ @@ -22,7 +25,9 @@ use dep::types::{ MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_PUBLIC_DATA_HINTS, MAX_PUBLIC_DATA_READS_PER_TX, NOTE_HASH_TREE_HEIGHT, PUBLIC_KERNEL_MERGE_INDEX, - }, data::PublicDataLeafHint, partial_state_reference::PartialStateReference, + }, + data::PublicDataLeafHint, + partial_state_reference::PartialStateReference, }; global ALLOWED_PREVIOUS_CIRCUITS = [PUBLIC_KERNEL_MERGE_INDEX]; @@ -94,10 +99,11 @@ impl PublicKernelTailCircuitPrivateInputs { mod tests { use crate::public_kernel_tail::PublicKernelTailCircuitPrivateInputs; use dep::reset_kernel_lib::{ + reset::read_request::{PendingReadHint, ReadRequestState, ReadRequestStatus}, tests::{ nullifier_non_existent_read_request_hints_builder::NullifierNonExistentReadRequestHintsBuilder, nullifier_read_request_hints_builder::NullifierReadRequestHintsBuilder, - }, reset::read_request::{PendingReadHint, ReadRequestState, ReadRequestStatus}, + }, TreeLeafReadRequestHint, }; use dep::types::{ @@ -105,23 +111,29 @@ mod tests { kernel_circuit_public_inputs::KernelCircuitPublicInputs, nullifier::ScopedNullifier, nullifier_leaf_preimage::NullifierLeafPreimage, public_data_update_request::PublicDataUpdateRequest, - }, address::AztecAddress, + }, + address::AztecAddress, constants::{ - L1_TO_L2_MSG_TREE_HEIGHT, MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX, MAX_NOTE_HASHES_PER_TX, - MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NULLIFIERS_PER_TX, - MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_PUBLIC_DATA_HINTS, NOTE_HASH_SUBTREE_HEIGHT, - NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH, NULLIFIER_TREE_HEIGHT, - NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, NULLIFIER_SUBTREE_HEIGHT, + BASE_ROLLUP_INDEX, L1_TO_L2_MSG_TREE_HEIGHT, MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX, + MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NOTE_HASHES_PER_TX, + MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_PUBLIC_DATA_HINTS, + MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, NOTE_HASH_SUBTREE_HEIGHT, + NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH, NOTE_HASH_TREE_HEIGHT, NULLIFIER_SUBTREE_HEIGHT, + NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, NULLIFIER_TREE_HEIGHT, PUBLIC_DATA_SUBTREE_HEIGHT, PUBLIC_DATA_SUBTREE_SIBLING_PATH_LENGTH, - PUBLIC_DATA_TREE_HEIGHT, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, - NOTE_HASH_TREE_HEIGHT, PUBLIC_KERNEL_MERGE_INDEX, BASE_ROLLUP_INDEX, - }, data::{PublicDataLeafHint, PublicDataTreeLeafPreimage}, + PUBLIC_DATA_TREE_HEIGHT, PUBLIC_KERNEL_MERGE_INDEX, + }, + data::{PublicDataLeafHint, PublicDataTreeLeafPreimage}, hash::{compute_siloed_nullifier, silo_note_hash}, + merkle_tree::MembershipWitness, + partial_state_reference::PartialStateReference, tests::{ - fixture_builder::FixtureBuilder, merkle_tree_utils::NonEmptyMerkleTree, + fixture_builder::FixtureBuilder, + merkle_tree_utils::NonEmptyMerkleTree, utils::{assert_array_eq, pad_end, swap_items}, - }, traits::is_empty, partial_state_reference::PartialStateReference, - utils::arrays::{array_merge, find_index_hint}, merkle_tree::MembershipWitness, + }, + traits::is_empty, + utils::arrays::{array_merge, find_index_hint}, }; fn build_note_hash_tree( diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/note_hash_read_request_reset.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/note_hash_read_request_reset.nr index 41e52c15b7d..52aa039a2b6 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/note_hash_read_request_reset.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/note_hash_read_request_reset.nr @@ -51,11 +51,15 @@ mod tests { verify_reset_read_requests, }; use dep::types::{ - address::AztecAddress, merkle_tree::MembershipWitness, abis::{ - note_hash::{NoteHash, ScopedNoteHash}, note_hash_leaf_preimage::NoteHashLeafPreimage, + note_hash::{NoteHash, ScopedNoteHash}, + note_hash_leaf_preimage::NoteHashLeafPreimage, read_request::{ReadRequest, ScopedReadRequest}, - }, constants::NOTE_HASH_TREE_HEIGHT, hash::compute_siloed_note_hash, + }, + address::AztecAddress, + constants::NOTE_HASH_TREE_HEIGHT, + hash::compute_siloed_note_hash, + merkle_tree::MembershipWitness, tests::{merkle_tree_utils::NonEmptyMerkleTree, utils::assert_array_eq}, traits::is_empty_array, }; diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/nullifier_non_existent_read_request_reset.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/nullifier_non_existent_read_request_reset.nr index 3c6bf8c74f3..4068202c37b 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/nullifier_non_existent_read_request_reset.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/nullifier_non_existent_read_request_reset.nr @@ -1,11 +1,11 @@ use crate::reset::non_existent_read_request::NonMembershipHint; use dep::types::{ abis::{nullifier::Nullifier, nullifier_leaf_preimage::NullifierLeafPreimage}, - merkle_tree::MembershipWitness, constants::{ - MAX_NULLIFIERS_PER_TX, MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX, + MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX, MAX_NULLIFIERS_PER_TX, NULLIFIER_TREE_HEIGHT, }, + merkle_tree::MembershipWitness, }; pub struct NullifierNonMembershipHint { diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/nullifier_read_request_reset.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/nullifier_read_request_reset.nr index 04c6d5a5d36..96a5fac86d0 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/nullifier_read_request_reset.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/nullifier_read_request_reset.nr @@ -51,11 +51,14 @@ mod tests { verify_reset_read_requests, }; use dep::types::{ - address::AztecAddress, abis::{ - nullifier::{Nullifier, ScopedNullifier}, nullifier_leaf_preimage::NullifierLeafPreimage, + nullifier::{Nullifier, ScopedNullifier}, + nullifier_leaf_preimage::NullifierLeafPreimage, read_request::{ReadRequest, ScopedReadRequest}, - }, constants::NULLIFIER_TREE_HEIGHT, hash::compute_siloed_nullifier, + }, + address::AztecAddress, + constants::NULLIFIER_TREE_HEIGHT, + hash::compute_siloed_nullifier, merkle_tree::MembershipWitness, tests::{merkle_tree_utils::NonEmptyMerkleTree, utils::assert_array_eq}, traits::is_empty_array, diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/private_validation_request_processor.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/private_validation_request_processor.nr index c2a429d7382..8f641126807 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/private_validation_request_processor.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/private_validation_request_processor.nr @@ -1,17 +1,20 @@ use crate::{ note_hash_read_request_reset::NoteHashReadRequestHints, nullifier_read_request_reset::NullifierReadRequestHints, - reset::read_request::{get_unverified_read_requests, verify_reset_read_requests}, - reset::key_validation_hint::{ - get_unverified_key_validation_requests, KeyValidationHint, - verify_reset_key_validation_requests, + reset::{ + key_validation_hint::{ + get_unverified_key_validation_requests, KeyValidationHint, + verify_reset_key_validation_requests, + }, + read_request::{get_unverified_read_requests, verify_reset_read_requests}, }, }; use dep::types::{ abis::{ note_hash::ScopedNoteHash, nullifier::ScopedNullifier, validation_requests::PrivateValidationRequests, - }, constants::{MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX}, + }, + constants::{MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX}, }; pub struct PrivateValidationRequestProcessor { diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/public_data_read_request_hints.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/public_data_read_request_hints.nr index e54d5e0cc31..2b8effeed0a 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/public_data_read_request_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/public_data_read_request_hints.nr @@ -1,7 +1,8 @@ use crate::reset::{mutable_data_read_request::ReadIndexHint, read_request::ReadRequestStatus}; use dep::types::{ abis::{public_data_read::PublicDataRead, public_data_write::OverridablePublicDataWrite}, - data::OverridablePublicDataTreeLeaf, utils::arrays::find_index_hint, + data::OverridablePublicDataTreeLeaf, + utils::arrays::find_index_hint, }; pub struct PublicDataReadRequestHints { diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/public_validation_request_processor.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/public_validation_request_processor.nr index cb0a6534026..103a358d287 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/public_validation_request_processor.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/public_validation_request_processor.nr @@ -1,12 +1,13 @@ use crate::{ + nullifier_non_existent_read_request_reset::NullifierNonExistentReadRequestHints, + nullifier_read_request_reset::NullifierReadRequestHints, + public_data_read_request_hints::PublicDataReadRequestHints, reset::{ - non_existent_read_request::reset_non_existent_read_requests, mutable_data_read_request::reset_mutable_data_read_requests, + non_existent_read_request::reset_non_existent_read_requests, read_request::verify_reset_read_requests, tree_leaf_read_request::{TreeLeafReadRequestHint, validate_tree_leaf_read_requests}, - }, nullifier_read_request_reset::NullifierReadRequestHints, - nullifier_non_existent_read_request_reset::NullifierNonExistentReadRequestHints, - public_data_read_request_hints::PublicDataReadRequestHints, + }, }; use dep::types::{ abis::{ @@ -15,11 +16,14 @@ use dep::types::{ validation_requests::PublicValidationRequests, }, constants::{ - MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX, L1_TO_L2_MSG_TREE_HEIGHT, - MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NULLIFIERS_PER_TX, - MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_PUBLIC_DATA_READS_PER_TX, NOTE_HASH_TREE_HEIGHT, - }, data::OverridablePublicDataTreeLeaf, hash::compute_siloed_nullifier, - partial_state_reference::PartialStateReference, traits::is_empty, + L1_TO_L2_MSG_TREE_HEIGHT, MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX, + MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX, + MAX_NULLIFIERS_PER_TX, MAX_PUBLIC_DATA_READS_PER_TX, NOTE_HASH_TREE_HEIGHT, + }, + data::OverridablePublicDataTreeLeaf, + hash::compute_siloed_nullifier, + partial_state_reference::PartialStateReference, + traits::is_empty, utils::arrays::{ array_to_bounded_vec, assert_combined_array, assert_sorted_array, combine_arrays, }, diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/key_validation_hint.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/key_validation_hint.nr index 167c6b97803..dd4e3a7bedd 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/key_validation_hint.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/key_validation_hint.nr @@ -1,6 +1,6 @@ use dep::types::{ - traits::Empty, abis::validation_requests::ScopedKeyValidationRequestAndGenerator, - scalar::Scalar, hash::poseidon2_hash_with_separator, + abis::validation_requests::ScopedKeyValidationRequestAndGenerator, + hash::poseidon2_hash_with_separator, scalar::Scalar, traits::Empty, }; use std::embedded_curve_ops::fixed_base_scalar_mul as derive_public_key; diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/mutable_data_read_request.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/mutable_data_read_request.nr index 2b7b3bcdef6..87027b7e18f 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/mutable_data_read_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/mutable_data_read_request.nr @@ -122,14 +122,19 @@ mod tests { use crate::reset::{ mutable_data_read_request::{ ensure_all_read_requests_are_verified, ReadIndexHint, reset_mutable_data_read_requests, - validate_pending_read_requests, validate_leaf_data_read_requests, - }, read_request::{ReadRequestState, ReadRequestStatus}, + validate_leaf_data_read_requests, validate_pending_read_requests, + }, + read_request::{ReadRequestState, ReadRequestStatus}, }; use dep::types::{ abis::{ - public_data_read::PublicDataRead, public_data_update_request::PublicDataUpdateRequest, - public_data_write::OverridablePublicDataWrite, side_effect::{Overridable, Readable}, - }, tests::utils::pad_end, traits::Empty, + public_data_read::PublicDataRead, + public_data_update_request::PublicDataUpdateRequest, + public_data_write::OverridablePublicDataWrite, + side_effect::{Overridable, Readable}, + }, + tests::utils::pad_end, + traits::Empty, }; struct TestLeafData { diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/non_existent_read_request.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/non_existent_read_request.nr index 55aab06e6fb..3cd22aa7443 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/non_existent_read_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/non_existent_read_request.nr @@ -1,5 +1,5 @@ use dep::types::{ - abis::{side_effect::OrderedValue, read_request::ScopedReadRequest}, + abis::{read_request::ScopedReadRequest, side_effect::OrderedValue}, merkle_tree::{assert_check_non_membership, IndexedTreeLeafPreimage, MembershipWitness}, traits::is_empty, }; @@ -112,7 +112,8 @@ mod tests { }; use dep::types::{ - address::AztecAddress, abis::{read_request::ReadRequest, side_effect::OrderedValue}, + abis::{read_request::ReadRequest, side_effect::OrderedValue}, + address::AztecAddress, merkle_tree::{leaf_preimage::IndexedTreeLeafPreimage, membership::MembershipWitness}, tests::merkle_tree_utils::NonEmptyMerkleTree, }; diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/read_request.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/read_request.nr index 4b2d07b93f7..5e82fc20751 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/read_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/read_request.nr @@ -1,7 +1,8 @@ // This will be moved to a separate Read Request Reset Circuit. use dep::types::{ abis::{read_request::ScopedReadRequest, side_effect::Readable}, - merkle_tree::{assert_check_membership, LeafPreimage, MembershipWitness}, traits::Empty, + merkle_tree::{assert_check_membership, LeafPreimage, MembershipWitness}, + traits::Empty, }; pub struct ReadRequestStateEnum { @@ -193,13 +194,13 @@ pub unconstrained fn get_unverified_read_requests( mod tests { use crate::reset::read_request::{ - PendingReadHint, ReadRequestState, ReadRequestStatus, ReadValueHint, SettledReadHint, - get_unverified_read_requests, validate_pending_read_requests, + get_unverified_read_requests, PendingReadHint, ReadRequestState, ReadRequestStatus, + ReadValueHint, SettledReadHint, validate_pending_read_requests, validate_settled_read_requests, verify_reset_read_requests, }; use dep::types::{ - address::AztecAddress, abis::{read_request::{ReadRequest, ScopedReadRequest}, side_effect::Readable}, + address::AztecAddress, merkle_tree::{LeafPreimage, MembershipWitness}, tests::{merkle_tree_utils::NonEmptyMerkleTree, utils::assert_array_eq}, traits::{Empty, is_empty_array}, diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/transient_data.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/transient_data.nr index 7d970eaf2fb..19471c18b8a 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/transient_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/transient_data.nr @@ -1,5 +1,5 @@ use dep::types::{ - abis::{note_hash::ScopedNoteHash, nullifier::ScopedNullifier, log_hash::NoteLogHash}, + abis::{log_hash::NoteLogHash, note_hash::ScopedNoteHash, nullifier::ScopedNullifier}, traits::is_empty, }; @@ -198,9 +198,11 @@ mod tests { }; use dep::types::{ abis::{ - note_hash::{NoteHash, ScopedNoteHash}, nullifier::{Nullifier, ScopedNullifier}, log_hash::NoteLogHash, - }, address::AztecAddress, + note_hash::{NoteHash, ScopedNoteHash}, + nullifier::{Nullifier, ScopedNullifier}, + }, + address::AztecAddress, }; global contract_address = AztecAddress::from_field(987654); diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/tree_leaf_read_request.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/tree_leaf_read_request.nr index a5dd79f6c4f..9798dbdb948 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/tree_leaf_read_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/tree_leaf_read_request.nr @@ -1,6 +1,6 @@ use dep::types::{ - abis::tree_leaf_read_request::TreeLeafReadRequest, traits::is_empty, - merkle_tree::assert_check_membership, + abis::tree_leaf_read_request::TreeLeafReadRequest, merkle_tree::assert_check_membership, + traits::is_empty, }; pub struct TreeLeafReadRequestHint { diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/note_hash_read_request_hints_builder.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/note_hash_read_request_hints_builder.nr index 7976ef3a222..e066aedb756 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/note_hash_read_request_hints_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/note_hash_read_request_hints_builder.nr @@ -1,5 +1,5 @@ use crate::{ - note_hash_read_request_reset::{NoteHashSettledReadHint, NoteHashReadRequestHints}, + note_hash_read_request_reset::{NoteHashReadRequestHints, NoteHashSettledReadHint}, reset::read_request::{PendingReadHint, ReadRequestStatus}, }; use dep::types::constants::MAX_NOTE_HASH_READ_REQUESTS_PER_TX; diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/nullifier_non_existent_read_request_hints_builder.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/nullifier_non_existent_read_request_hints_builder.nr index 3fd0579ca1d..a7d48860ad1 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/nullifier_non_existent_read_request_hints_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/nullifier_non_existent_read_request_hints_builder.nr @@ -1,12 +1,14 @@ use crate::nullifier_non_existent_read_request_reset::{ - NullifierNonMembershipHint, NullifierNonExistentReadRequestHints, + NullifierNonExistentReadRequestHints, NullifierNonMembershipHint, }; use dep::types::{ abis::{nullifier::Nullifier, nullifier_leaf_preimage::NullifierLeafPreimage}, constants::{ - MAX_NULLIFIERS_PER_TX, MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX, - NULLIFIER_TREE_HEIGHT, NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, NULLIFIER_SUBTREE_HEIGHT, - }, merkle_tree::MembershipWitness, tests::merkle_tree_utils::NonEmptyMerkleTree, + MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX, MAX_NULLIFIERS_PER_TX, + NULLIFIER_SUBTREE_HEIGHT, NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, NULLIFIER_TREE_HEIGHT, + }, + merkle_tree::MembershipWitness, + tests::merkle_tree_utils::NonEmptyMerkleTree, utils::arrays::{find_index_hint, get_sorted_result}, }; diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/nullifier_read_request_hints_builder.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/nullifier_read_request_hints_builder.nr index b3a4717bcf3..9d60bce4e83 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/nullifier_read_request_hints_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/nullifier_read_request_hints_builder.nr @@ -1,5 +1,5 @@ use crate::{ - nullifier_read_request_reset::{NullifierSettledReadHint, NullifierReadRequestHints}, + nullifier_read_request_reset::{NullifierReadRequestHints, NullifierSettledReadHint}, reset::read_request::{PendingReadHint, ReadRequestStatus}, }; use dep::types::constants::MAX_NULLIFIER_READ_REQUESTS_PER_TX; diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-base-simulated/src/main.nr b/noir-projects/noir-protocol-circuits/crates/rollup-base-simulated/src/main.nr index 970496511a1..0ff893873e4 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-base-simulated/src/main.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-base-simulated/src/main.nr @@ -1,4 +1,4 @@ -use dep::rollup_lib::base::{BaseRollupInputs, BaseOrMergeRollupPublicInputs}; +use dep::rollup_lib::base::{BaseOrMergeRollupPublicInputs, BaseRollupInputs}; unconstrained fn main(inputs: BaseRollupInputs) -> pub BaseOrMergeRollupPublicInputs { inputs.base_rollup_circuit() diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-base/src/main.nr b/noir-projects/noir-protocol-circuits/crates/rollup-base/src/main.nr index 260fea00f1e..19ea63d649a 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-base/src/main.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-base/src/main.nr @@ -1,4 +1,4 @@ -use dep::rollup_lib::base::{BaseRollupInputs, BaseOrMergeRollupPublicInputs}; +use dep::rollup_lib::base::{BaseOrMergeRollupPublicInputs, BaseRollupInputs}; #[recursive] fn main(inputs: BaseRollupInputs) -> pub BaseOrMergeRollupPublicInputs { diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-block-root-empty/src/main.nr b/noir-projects/noir-protocol-circuits/crates/rollup-block-root-empty/src/main.nr index e2f80bb0ad2..459ebf947e1 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-block-root-empty/src/main.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-block-root-empty/src/main.nr @@ -1,4 +1,4 @@ -use rollup_lib::block_root::{EmptyBlockRootRollupInputs, BlockRootOrBlockMergePublicInputs}; +use rollup_lib::block_root::{BlockRootOrBlockMergePublicInputs, EmptyBlockRootRollupInputs}; #[recursive] fn main(inputs: EmptyBlockRootRollupInputs) -> pub BlockRootOrBlockMergePublicInputs { diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-block-root/src/main.nr b/noir-projects/noir-protocol-circuits/crates/rollup-block-root/src/main.nr index f4ce060103f..33bcb5c457e 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-block-root/src/main.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-block-root/src/main.nr @@ -1,4 +1,4 @@ -use dep::rollup_lib::block_root::{BlockRootRollupInputs, BlockRootOrBlockMergePublicInputs}; +use dep::rollup_lib::block_root::{BlockRootOrBlockMergePublicInputs, BlockRootRollupInputs}; #[recursive] fn main(inputs: BlockRootRollupInputs) -> pub BlockRootOrBlockMergePublicInputs { diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/base_or_merge_rollup_public_inputs.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/base_or_merge_rollup_public_inputs.nr index cf844edcfe4..bd9e7994bbb 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/base_or_merge_rollup_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/base_or_merge_rollup_public_inputs.nr @@ -1,8 +1,10 @@ +use crate::abis::constant_rollup_data::ConstantRollupData; use dep::types::{ - constants::BASE_OR_MERGE_PUBLIC_INPUTS_LENGTH, partial_state_reference::PartialStateReference, - traits::{Empty, Serialize, Deserialize}, utils::reader::Reader, + constants::BASE_OR_MERGE_PUBLIC_INPUTS_LENGTH, + partial_state_reference::PartialStateReference, + traits::{Deserialize, Empty, Serialize}, + utils::reader::Reader, }; -use crate::abis::constant_rollup_data::ConstantRollupData; global BASE_ROLLUP_TYPE = 0; global MERGE_ROLLUP_TYPE = 1; diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/block_root_or_block_merge_public_inputs.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/block_root_or_block_merge_public_inputs.nr index a8fea926e2c..5f4d14647f1 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/block_root_or_block_merge_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/block_root_or_block_merge_public_inputs.nr @@ -1,8 +1,11 @@ use dep::types::{ abis::{append_only_tree_snapshot::AppendOnlyTreeSnapshot, global_variables::GlobalVariables}, + address::EthAddress, constants::{ AZTEC_EPOCH_DURATION, BLOCK_ROOT_OR_BLOCK_MERGE_PUBLIC_INPUTS_LENGTH, FEE_RECIPIENT_LENGTH, - }, traits::{Empty, Serialize, Deserialize}, utils::reader::Reader, address::EthAddress, + }, + traits::{Deserialize, Empty, Serialize}, + utils::reader::Reader, }; pub struct FeeRecipient { diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/constant_rollup_data.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/constant_rollup_data.nr index 6c5380cc42e..1d798746866 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/constant_rollup_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/constant_rollup_data.nr @@ -1,6 +1,7 @@ use dep::types::{ - abis::{global_variables::GlobalVariables, append_only_tree_snapshot::AppendOnlyTreeSnapshot}, - traits::{Empty, Serialize, Deserialize}, constants::CONSTANT_ROLLUP_DATA_LENGTH, + abis::{append_only_tree_snapshot::AppendOnlyTreeSnapshot, global_variables::GlobalVariables}, + constants::CONSTANT_ROLLUP_DATA_LENGTH, + traits::{Deserialize, Empty, Serialize}, utils::reader::Reader, }; diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/previous_rollup_block_data.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/previous_rollup_block_data.nr index 100233dcb6b..3a9c2ab9f02 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/previous_rollup_block_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/previous_rollup_block_data.nr @@ -1,11 +1,14 @@ use crate::abis::block_root_or_block_merge_public_inputs::BlockRootOrBlockMergePublicInputs; use dep::types::{ constants::VK_TREE_HEIGHT, + merkle_tree::{membership::assert_check_membership, MembershipWitness}, recursion::{ - proof::NestedRecursiveProof, verification_key::{HonkVerificationKey, VerificationKey}, + proof::NestedRecursiveProof, traits::Verifiable, - }, traits::Empty, merkle_tree::MembershipWitness, - merkle_tree::membership::assert_check_membership, utils::arrays::find_index_hint, + verification_key::{HonkVerificationKey, VerificationKey}, + }, + traits::Empty, + utils::arrays::find_index_hint, }; pub struct PreviousRollupBlockData { diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/previous_rollup_data.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/previous_rollup_data.nr index 1b7e4867811..a9e771d19d1 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/previous_rollup_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/previous_rollup_data.nr @@ -1,11 +1,14 @@ use crate::abis::base_or_merge_rollup_public_inputs::BaseOrMergeRollupPublicInputs; use dep::types::{ constants::VK_TREE_HEIGHT, + merkle_tree::{membership::assert_check_membership, MembershipWitness}, recursion::{ - proof::NestedRecursiveProof, verification_key::{VerificationKey, HonkVerificationKey}, + proof::NestedRecursiveProof, traits::Verifiable, - }, traits::Empty, merkle_tree::MembershipWitness, - merkle_tree::membership::assert_check_membership, utils::arrays::find_index_hint, + verification_key::{HonkVerificationKey, VerificationKey}, + }, + traits::Empty, + utils::arrays::find_index_hint, }; pub struct PreviousRollupData { diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/base_rollup_inputs.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/base_rollup_inputs.nr index dd9d49aaec1..4b74c94aa43 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/base_rollup_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/base_rollup_inputs.nr @@ -1,34 +1,42 @@ use crate::{ abis::{ + base_or_merge_rollup_public_inputs::{BASE_ROLLUP_TYPE, BaseOrMergeRollupPublicInputs}, constant_rollup_data::ConstantRollupData, - base_or_merge_rollup_public_inputs::{BaseOrMergeRollupPublicInputs, BASE_ROLLUP_TYPE}, - }, base::state_diff_hints::StateDiffHints, - components::{compute_tx_effects_hash, compute_kernel_out_hash}, + }, + base::state_diff_hints::StateDiffHints, + components::{compute_kernel_out_hash, compute_tx_effects_hash}, }; use dep::types::{ - hash::silo_l2_to_l1_message, - data::{ - public_data_hint::PublicDataHint, - hash::{compute_public_data_tree_index, compute_public_data_tree_value}, - }, storage::map::derive_storage_slot_in_map, address::AztecAddress, abis::{ - append_only_tree_snapshot::AppendOnlyTreeSnapshot, + append_only_tree_snapshot::AppendOnlyTreeSnapshot, kernel_data::KernelData, nullifier_leaf_preimage::NullifierLeafPreimage, - public_data_update_request::PublicDataUpdateRequest, kernel_data::KernelData, - }, messaging::l2_to_l1_message::ScopedL2ToL1Message, + public_data_update_request::PublicDataUpdateRequest, + }, + address::AztecAddress, constants::{ - PUBLIC_DATA_TREE_HEIGHT, NOTE_HASH_SUBTREE_HEIGHT, MAX_NOTE_HASHES_PER_TX, - MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, NULLIFIER_SUBTREE_HEIGHT, - NULLIFIER_TREE_HEIGHT, PUBLIC_DATA_SUBTREE_SIBLING_PATH_LENGTH, PUBLIC_DATA_SUBTREE_HEIGHT, - ARCHIVE_HEIGHT, FEE_JUICE_ADDRESS, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, - PUBLIC_KERNEL_TAIL_INDEX, PRIVATE_KERNEL_EMPTY_INDEX, TUBE_INDEX, + ARCHIVE_HEIGHT, FEE_JUICE_ADDRESS, MAX_NOTE_HASHES_PER_TX, + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, + NOTE_HASH_SUBTREE_HEIGHT, NULLIFIER_SUBTREE_HEIGHT, NULLIFIER_TREE_HEIGHT, + PRIVATE_KERNEL_EMPTY_INDEX, PUBLIC_DATA_SUBTREE_HEIGHT, + PUBLIC_DATA_SUBTREE_SIBLING_PATH_LENGTH, PUBLIC_DATA_TREE_HEIGHT, PUBLIC_KERNEL_TAIL_INDEX, + TUBE_INDEX, + }, + data::{ + hash::{compute_public_data_tree_index, compute_public_data_tree_value}, + public_data_hint::PublicDataHint, + PublicDataTreeLeaf, + PublicDataTreeLeafPreimage, }, + hash::silo_l2_to_l1_message, merkle_tree::{ append_only_tree, assert_check_membership, calculate_empty_tree_root, calculate_subtree_root, indexed_tree, MembershipWitness, - }, partial_state_reference::PartialStateReference, - data::{PublicDataTreeLeaf, PublicDataTreeLeafPreimage}, traits::is_empty, - utils::field::{full_field_less_than, full_field_greater_than}, + }, + messaging::l2_to_l1_message::ScopedL2ToL1Message, + partial_state_reference::PartialStateReference, + storage::map::derive_storage_slot_in_map, + traits::is_empty, + utils::field::{full_field_greater_than, full_field_less_than}, }; global ALLOWED_PREVIOUS_CIRCUITS = @@ -500,38 +508,44 @@ fn test_u256_greater_than() { mod tests { use crate::{ abis::{ - constant_rollup_data::ConstantRollupData, base_or_merge_rollup_public_inputs::BaseOrMergeRollupPublicInputs, + constant_rollup_data::ConstantRollupData, }, base::{ - state_diff_hints::StateDiffHints, base_rollup_inputs::{BaseRollupInputs, compute_fee_payer_fee_juice_balance_leaf_slot}, - }, components::TX_EFFECTS_HASH_INPUT_FIELDS, + state_diff_hints::StateDiffHints, + }, + components::TX_EFFECTS_HASH_INPUT_FIELDS, }; use dep::types::{ abis::{ - append_only_tree_snapshot::AppendOnlyTreeSnapshot, + append_only_tree_snapshot::AppendOnlyTreeSnapshot, kernel_data::KernelData, nullifier_leaf_preimage::NullifierLeafPreimage, - public_data_update_request::PublicDataUpdateRequest, kernel_data::KernelData, - }, messaging::l2_to_l1_message::ScopedL2ToL1Message, merkle_tree::MembershipWitness, - hash::silo_l2_to_l1_message, data::public_data_hint::PublicDataHint, + public_data_update_request::PublicDataUpdateRequest, + }, address::{AztecAddress, EthAddress}, constants::{ - ARCHIVE_HEIGHT, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_NOTE_HASHES_PER_TX, - MAX_NULLIFIERS_PER_TX, NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH, NOTE_HASH_TREE_HEIGHT, - NOTE_HASH_SUBTREE_HEIGHT, NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, NULLIFIER_TREE_HEIGHT, - NULLIFIER_SUBTREE_HEIGHT, PUBLIC_DATA_TREE_HEIGHT, PUBLIC_DATA_SUBTREE_HEIGHT, - PUBLIC_DATA_SUBTREE_SIBLING_PATH_LENGTH, MAX_L2_TO_L1_MSGS_PER_TX, - PROTOCOL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, - PRIVATE_KERNEL_EMPTY_INDEX, PRIVATE_KERNEL_TAIL_INDEX, PUBLIC_KERNEL_TAIL_INDEX, - BASE_ROLLUP_INDEX, TUBE_INDEX, - }, partial_state_reference::PartialStateReference, - data::{PublicDataTreeLeaf, PublicDataTreeLeafPreimage}, - tests::{fixtures, fixture_builder::FixtureBuilder, merkle_tree_utils::NonEmptyMerkleTree}, + ARCHIVE_HEIGHT, BASE_ROLLUP_INDEX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_HASHES_PER_TX, + MAX_NULLIFIERS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, + MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, NOTE_HASH_SUBTREE_HEIGHT, + NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH, NOTE_HASH_TREE_HEIGHT, NULLIFIER_SUBTREE_HEIGHT, + NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, NULLIFIER_TREE_HEIGHT, + PRIVATE_KERNEL_EMPTY_INDEX, PRIVATE_KERNEL_TAIL_INDEX, + PROTOCOL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, PUBLIC_DATA_SUBTREE_HEIGHT, + PUBLIC_DATA_SUBTREE_SIBLING_PATH_LENGTH, PUBLIC_DATA_TREE_HEIGHT, + PUBLIC_KERNEL_TAIL_INDEX, TUBE_INDEX, + }, + data::{public_data_hint::PublicDataHint, PublicDataTreeLeaf, PublicDataTreeLeafPreimage}, + hash::silo_l2_to_l1_message, + merkle_tree::MembershipWitness, + messaging::l2_to_l1_message::ScopedL2ToL1Message, + partial_state_reference::PartialStateReference, + tests::{fixture_builder::FixtureBuilder, fixtures, merkle_tree_utils::NonEmptyMerkleTree}, + traits::Empty, utils::{ arrays::get_sorted_tuple::get_sorted_tuple, - field::{full_field_less_than, field_from_bytes_32_trunc}, - }, traits::Empty, + field::{field_from_bytes_32_trunc, full_field_less_than}, + }, }; struct NullifierInsertion { diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/mod.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/mod.nr index d7de5b52f98..89b645952b3 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/mod.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/mod.nr @@ -1,5 +1,5 @@ mod base_rollup_inputs; mod state_diff_hints; -pub use base_rollup_inputs::BaseRollupInputs; pub use crate::abis::base_or_merge_rollup_public_inputs::BaseOrMergeRollupPublicInputs; +pub use base_rollup_inputs::BaseRollupInputs; diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/state_diff_hints.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/state_diff_hints.nr index 00bcc9e0986..5015f7ed779 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/state_diff_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/state_diff_hints.nr @@ -2,9 +2,10 @@ use dep::types::{ abis::nullifier_leaf_preimage::NullifierLeafPreimage, constants::{ MAX_NULLIFIERS_PER_TX, NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH, - NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, PUBLIC_DATA_SUBTREE_SIBLING_PATH_LENGTH, - NULLIFIER_TREE_HEIGHT, - }, merkle_tree::MembershipWitness, + NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, NULLIFIER_TREE_HEIGHT, + PUBLIC_DATA_SUBTREE_SIBLING_PATH_LENGTH, + }, + merkle_tree::MembershipWitness, }; pub struct StateDiffHints { diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_merge/block_merge_rollup_inputs.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_merge/block_merge_rollup_inputs.nr index 66f52d9e0b1..50b956e01a8 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_merge/block_merge_rollup_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_merge/block_merge_rollup_inputs.nr @@ -1,7 +1,7 @@ -use dep::types::{traits::Empty, constants::{BLOCK_ROOT_ROLLUP_INDEX, BLOCK_MERGE_ROLLUP_INDEX}}; -use crate::abis::previous_rollup_block_data::PreviousRollupBlockData; use crate::abis::block_root_or_block_merge_public_inputs::BlockRootOrBlockMergePublicInputs; +use crate::abis::previous_rollup_block_data::PreviousRollupBlockData; use crate::components; +use dep::types::{constants::{BLOCK_MERGE_ROLLUP_INDEX, BLOCK_ROOT_ROLLUP_INDEX}, traits::Empty}; // TODO(#7346): Currently unused! Will be used when batch rollup circuits are integrated. global ALLOWED_PREVIOUS_CIRCUITS = [BLOCK_ROOT_ROLLUP_INDEX, BLOCK_MERGE_ROLLUP_INDEX]; @@ -62,12 +62,12 @@ impl BlockMergeRollupInputs { mod tests { use crate::tests::block_merge_rollup_inputs::default_block_merge_rollup_inputs; - use dep::types::hash::accumulate_sha256; use dep::types::constants::{ - BLOCK_ROOT_ROLLUP_INDEX, BLOCK_MERGE_ROLLUP_INDEX, ROOT_PARITY_INDEX, + BLOCK_MERGE_ROLLUP_INDEX, BLOCK_ROOT_ROLLUP_INDEX, ROOT_PARITY_INDEX, }; - use types::merkle_tree::merkle_tree::MerkleTree; + use dep::types::hash::accumulate_sha256; use dep::types::tests::fixtures; + use types::merkle_tree::merkle_tree::MerkleTree; #[test(should_fail_with = "input blocks have different chain id")] fn constants_different_chain_id_fails() { diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_merge/mod.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_merge/mod.nr index e6e595f1091..a8006f912e3 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_merge/mod.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_merge/mod.nr @@ -1,4 +1,4 @@ mod block_merge_rollup_inputs; -pub use block_merge_rollup_inputs::BlockMergeRollupInputs; pub use crate::abis::block_root_or_block_merge_public_inputs::BlockRootOrBlockMergePublicInputs; +pub use block_merge_rollup_inputs::BlockMergeRollupInputs; diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_root/block_root_rollup_inputs.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_root/block_root_rollup_inputs.nr index 0b0ee32a8ee..845d5b056ea 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_root/block_root_rollup_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_root/block_root_rollup_inputs.nr @@ -1,18 +1,22 @@ use crate::{ abis::{ - previous_rollup_data::PreviousRollupData, block_root_or_block_merge_public_inputs::{BlockRootOrBlockMergePublicInputs, FeeRecipient}, - }, components, + previous_rollup_data::PreviousRollupData, + }, + components, }; use parity_lib::root::root_rollup_parity_input::RootRollupParityInput; use types::{ abis::append_only_tree_snapshot::AppendOnlyTreeSnapshot, constants::{ - AZTEC_EPOCH_DURATION, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, L1_TO_L2_MSG_SUBTREE_HEIGHT, - L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, ARCHIVE_HEIGHT, BASE_ROLLUP_INDEX, - MERGE_ROLLUP_INDEX, - }, header::Header, content_commitment::ContentCommitment, - merkle_tree::{append_only_tree, calculate_empty_tree_root}, state_reference::StateReference, + ARCHIVE_HEIGHT, AZTEC_EPOCH_DURATION, BASE_ROLLUP_INDEX, L1_TO_L2_MSG_SUBTREE_HEIGHT, + L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, MERGE_ROLLUP_INDEX, + NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, + }, + content_commitment::ContentCommitment, + header::Header, + merkle_tree::{append_only_tree, calculate_empty_tree_root}, + state_reference::StateReference, traits::Empty, }; use types::debug_log::debug_log_format; diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_root/empty_block_root_rollup_inputs.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_root/empty_block_root_rollup_inputs.nr index 7d431741163..18ba14c564d 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_root/empty_block_root_rollup_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_root/empty_block_root_rollup_inputs.nr @@ -1,9 +1,9 @@ use crate::abis::block_root_or_block_merge_public_inputs::BlockRootOrBlockMergePublicInputs; +use crate::abis::block_root_or_block_merge_public_inputs::FeeRecipient; use types::abis::{ append_only_tree_snapshot::AppendOnlyTreeSnapshot, global_variables::GlobalVariables, }; use types::constants::AZTEC_EPOCH_DURATION; -use crate::abis::block_root_or_block_merge_public_inputs::FeeRecipient; pub struct EmptyBlockRootRollupInputs { archive: AppendOnlyTreeSnapshot, diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_root/mod.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_root/mod.nr index 51065ad968c..dd7f71030b0 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_root/mod.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_root/mod.nr @@ -2,9 +2,9 @@ mod block_root_rollup_inputs; mod empty_block_root_rollup_inputs; // Re-exports +pub use crate::abis::block_root_or_block_merge_public_inputs::BlockRootOrBlockMergePublicInputs; pub use block_root_rollup_inputs::BlockRootRollupInputs; pub use empty_block_root_rollup_inputs::EmptyBlockRootRollupInputs; -pub use crate::abis::block_root_or_block_merge_public_inputs::BlockRootOrBlockMergePublicInputs; mod tests { use crate::tests::block_root_rollup_inputs::default_block_root_rollup_inputs; diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/components.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/components.nr index b25f9fef8bc..68bdd43b3d8 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/components.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/components.nr @@ -3,22 +3,25 @@ use crate::abis::{ block_root_or_block_merge_public_inputs::{BlockRootOrBlockMergePublicInputs, FeeRecipient}, }; use crate::abis::{ - previous_rollup_data::PreviousRollupData, previous_rollup_block_data::PreviousRollupBlockData, + previous_rollup_block_data::PreviousRollupBlockData, previous_rollup_data::PreviousRollupData, }; use dep::types::{ - hash::{ - accumulate_sha256, silo_unencrypted_log_hash, compute_tx_logs_hash, silo_encrypted_log_hash, - compute_tx_note_logs_hash, - }, merkle_tree::VariableMerkleTree, - constants::{ - AZTEC_EPOCH_DURATION, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, - MAX_L2_TO_L1_MSGS_PER_TX, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, - MAX_UNENCRYPTED_LOGS_PER_TX, - }, utils::arrays::{array_length, array_merge}, abis::{ accumulated_data::CombinedAccumulatedData, - public_data_update_request::PublicDataUpdateRequest, log_hash::{LogHash, ScopedLogHash}, + log_hash::{LogHash, ScopedLogHash}, + public_data_update_request::PublicDataUpdateRequest, + }, + constants::{ + AZTEC_EPOCH_DURATION, MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_HASHES_PER_TX, + MAX_NULLIFIERS_PER_TX, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, + MAX_UNENCRYPTED_LOGS_PER_TX, + }, + hash::{ + accumulate_sha256, compute_tx_logs_hash, compute_tx_note_logs_hash, silo_encrypted_log_hash, + silo_unencrypted_log_hash, }, + merkle_tree::VariableMerkleTree, + utils::arrays::{array_length, array_merge}, }; /** @@ -358,7 +361,7 @@ fn get_all_update_requests_for_tx_effects( #[test] fn consistent_TX_EFFECTS_HASH_INPUT_FIELDS() { let expected_size = 1 // revert code - + 1 // transaction fee + + 1 // transaction fee + MAX_NOTE_HASHES_PER_TX + MAX_NULLIFIERS_PER_TX + MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX * 2 diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/merge/merge_rollup_inputs.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/merge/merge_rollup_inputs.nr index fdcc1ce5d1a..8994feaba8f 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/merge/merge_rollup_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/merge/merge_rollup_inputs.nr @@ -1,9 +1,9 @@ -use dep::types::{traits::Empty, constants::{BASE_ROLLUP_INDEX, MERGE_ROLLUP_INDEX}}; -use crate::abis::previous_rollup_data::PreviousRollupData; use crate::abis::base_or_merge_rollup_public_inputs::{ BaseOrMergeRollupPublicInputs, MERGE_ROLLUP_TYPE, }; +use crate::abis::previous_rollup_data::PreviousRollupData; use crate::components; +use dep::types::{constants::{BASE_ROLLUP_INDEX, MERGE_ROLLUP_INDEX}, traits::Empty}; global ALLOWED_PREVIOUS_CIRCUITS = [BASE_ROLLUP_INDEX, MERGE_ROLLUP_INDEX]; @@ -61,8 +61,8 @@ impl MergeRollupInputs { mod tests { use crate::tests::merge_rollup_inputs::default_merge_rollup_inputs; + use dep::types::constants::{BASE_ROLLUP_INDEX, MERGE_ROLLUP_INDEX, ROOT_PARITY_INDEX}; use dep::types::hash::accumulate_sha256; - use dep::types::constants::{MERGE_ROLLUP_INDEX, BASE_ROLLUP_INDEX, ROOT_PARITY_INDEX}; use types::merkle_tree::merkle_tree::MerkleTree; use types::tests::fixtures; diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/merge/mod.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/merge/mod.nr index 2ec68ba0487..56608d0eb3c 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/merge/mod.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/merge/mod.nr @@ -1,4 +1,4 @@ mod merge_rollup_inputs; -pub use merge_rollup_inputs::MergeRollupInputs; pub use crate::abis::base_or_merge_rollup_public_inputs::BaseOrMergeRollupPublicInputs; +pub use merge_rollup_inputs::MergeRollupInputs; diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root/root_rollup_inputs.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root/root_rollup_inputs.nr index 5711b1bb5ed..619aed711df 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root/root_rollup_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root/root_rollup_inputs.nr @@ -3,8 +3,8 @@ use crate::{ root::root_rollup_public_inputs::RootRollupPublicInputs, }; use types::{ + constants::{BLOCK_MERGE_ROLLUP_INDEX, BLOCK_ROOT_ROLLUP_EMPTY_INDEX, BLOCK_ROOT_ROLLUP_INDEX}, traits::Empty, - constants::{BLOCK_ROOT_ROLLUP_INDEX, BLOCK_MERGE_ROLLUP_INDEX, BLOCK_ROOT_ROLLUP_EMPTY_INDEX}, }; // TODO(#7346): Currently unused! Will be used when batch rollup circuits are integrated. global ALLOWED_PREVIOUS_CIRCUITS = diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root/root_rollup_public_inputs.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root/root_rollup_public_inputs.nr index 5909a58ef9f..69469e41881 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root/root_rollup_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root/root_rollup_public_inputs.nr @@ -1,6 +1,6 @@ +use crate::abis::block_root_or_block_merge_public_inputs::FeeRecipient; use dep::types::abis::append_only_tree_snapshot::AppendOnlyTreeSnapshot; use dep::types::constants::AZTEC_EPOCH_DURATION; -use crate::abis::block_root_or_block_merge_public_inputs::FeeRecipient; pub struct RootRollupPublicInputs { // Snapshot of archive tree before/after this rollup has been processed diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/block_root_rollup_inputs.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/block_root_rollup_inputs.nr index 85007c7a404..7a213dc35da 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/block_root_rollup_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/block_root_rollup_inputs.nr @@ -1,13 +1,14 @@ use crate::block_root::block_root_rollup_inputs::BlockRootRollupInputs; +use crate::tests::l1_to_l2_roots::default_root_rollup_parity_input; +use crate::tests::previous_rollup_data::default_previous_rollup_data; use dep::types::{ abis::append_only_tree_snapshot::AppendOnlyTreeSnapshot, constants::{ - L1_TO_L2_MSG_TREE_HEIGHT, L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, - L1_TO_L2_MSG_SUBTREE_HEIGHT, ARCHIVE_HEIGHT, - }, tests::merkle_tree_utils::compute_zero_hashes, + ARCHIVE_HEIGHT, L1_TO_L2_MSG_SUBTREE_HEIGHT, L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, + L1_TO_L2_MSG_TREE_HEIGHT, + }, + tests::merkle_tree_utils::compute_zero_hashes, }; -use crate::tests::previous_rollup_data::default_previous_rollup_data; -use crate::tests::l1_to_l2_roots::default_root_rollup_parity_input; pub fn compute_l1_l2_empty_snapshot() -> (AppendOnlyTreeSnapshot, [Field; L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH]) { let zero_hashes = compute_zero_hashes([0; L1_TO_L2_MSG_TREE_HEIGHT]); diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/l1_to_l2_roots.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/l1_to_l2_roots.nr index f67fc7637c5..84a4685e8e2 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/l1_to_l2_roots.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/l1_to_l2_roots.nr @@ -1,6 +1,6 @@ +use dep::parity_lib::root::root_rollup_parity_input::RootRollupParityInput; use dep::types::constants::ROOT_PARITY_INDEX; use dep::types::tests::fixtures; -use dep::parity_lib::root::root_rollup_parity_input::RootRollupParityInput; use types::merkle_tree::merkle_tree::MerkleTree; pub fn default_root_rollup_parity_input() -> RootRollupParityInput { diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/previous_rollup_block_data.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/previous_rollup_block_data.nr index d34e5b3c08f..7b70fb93e17 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/previous_rollup_block_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/previous_rollup_block_data.nr @@ -1,8 +1,8 @@ use crate::abis::previous_rollup_block_data::PreviousRollupBlockData; -use dep::types::constants::BLOCK_ROOT_ROLLUP_INDEX; -use dep::types::tests::fixtures; 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 types::merkle_tree::merkle_tree::MerkleTree; pub fn default_previous_rollup_block_data() -> [PreviousRollupBlockData; 2] { diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/previous_rollup_data.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/previous_rollup_data.nr index 1bccb203cc4..aac3ffd73d4 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/previous_rollup_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/tests/previous_rollup_data.nr @@ -1,9 +1,9 @@ use crate::abis::base_or_merge_rollup_public_inputs::BASE_ROLLUP_TYPE; use crate::abis::previous_rollup_data::PreviousRollupData; -use dep::types::constants::BASE_ROLLUP_INDEX; -use dep::types::tests::fixtures; use dep::types::abis::append_only_tree_snapshot::AppendOnlyTreeSnapshot; +use dep::types::constants::BASE_ROLLUP_INDEX; use dep::types::merkle_tree::MembershipWitness; +use dep::types::tests::fixtures; use types::merkle_tree::merkle_tree::MerkleTree; pub fn default_previous_rollup_data() -> [PreviousRollupData; 2] { diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-merge/src/main.nr b/noir-projects/noir-protocol-circuits/crates/rollup-merge/src/main.nr index 2dd95814a6b..108aadfa738 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-merge/src/main.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-merge/src/main.nr @@ -1,4 +1,4 @@ -use dep::rollup_lib::merge::{MergeRollupInputs, BaseOrMergeRollupPublicInputs}; +use dep::rollup_lib::merge::{BaseOrMergeRollupPublicInputs, MergeRollupInputs}; #[recursive] fn main(inputs: MergeRollupInputs) -> pub BaseOrMergeRollupPublicInputs { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/combined_accumulated_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/combined_accumulated_data.nr index aabd69b5316..56116a56531 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/combined_accumulated_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/combined_accumulated_data.nr @@ -1,13 +1,17 @@ use crate::{ abis::{ - public_data_update_request::PublicDataUpdateRequest, log_hash::{LogHash, ScopedLogHash}, gas::Gas, - }, messaging::l2_to_l1_message::ScopedL2ToL1Message, + log_hash::{LogHash, ScopedLogHash}, + public_data_update_request::PublicDataUpdateRequest, + }, constants::{ - MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, - MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, COMBINED_ACCUMULATED_DATA_LENGTH, - MAX_UNENCRYPTED_LOGS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, MAX_ENCRYPTED_LOGS_PER_TX, - }, utils::reader::Reader, traits::{Empty, Serialize, Deserialize}, + COMBINED_ACCUMULATED_DATA_LENGTH, MAX_ENCRYPTED_LOGS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, + MAX_NOTE_ENCRYPTED_LOGS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX, + }, + messaging::l2_to_l1_message::ScopedL2ToL1Message, + traits::{Deserialize, Empty, Serialize}, + utils::reader::Reader, }; pub struct CombinedAccumulatedData { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_accumulated_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_accumulated_data.nr index 421e7c815eb..b7aee6d64c6 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_accumulated_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_accumulated_data.nr @@ -1,15 +1,20 @@ use crate::{ abis::{ - note_hash::ScopedNoteHash, nullifier::ScopedNullifier, - private_call_request::PrivateCallRequest, public_call_request::PublicCallRequest, - log_hash::{ScopedEncryptedLogHash, NoteLogHash, ScopedLogHash}, - }, traits::{Serialize, Deserialize, Empty}, messaging::l2_to_l1_message::ScopedL2ToL1Message, + log_hash::{NoteLogHash, ScopedEncryptedLogHash, ScopedLogHash}, + note_hash::ScopedNoteHash, + nullifier::ScopedNullifier, + private_call_request::PrivateCallRequest, + public_call_request::PublicCallRequest, + }, + messaging::l2_to_l1_message::ScopedL2ToL1Message, + traits::{Deserialize, Empty, Serialize}, utils::reader::Reader, }; use crate::constants::{ + MAX_ENCRYPTED_LOGS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, - MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_ENCRYPTED_LOGS_PER_TX, - MAX_UNENCRYPTED_LOGS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, PRIVATE_ACCUMULATED_DATA_LENGTH, + MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX, + PRIVATE_ACCUMULATED_DATA_LENGTH, }; pub struct PrivateAccumulatedData { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_accumulated_data_builder.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_accumulated_data_builder.nr index 34933ce092f..3bd58cddbcf 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_accumulated_data_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_accumulated_data_builder.nr @@ -1,15 +1,19 @@ use crate::{ abis::{ accumulated_data::private_accumulated_data::PrivateAccumulatedData, - note_hash::ScopedNoteHash, nullifier::ScopedNullifier, - private_call_request::PrivateCallRequest, public_call_request::PublicCallRequest, - log_hash::{ScopedEncryptedLogHash, NoteLogHash, ScopedLogHash}, + log_hash::{NoteLogHash, ScopedEncryptedLogHash, ScopedLogHash}, + note_hash::ScopedNoteHash, + nullifier::ScopedNullifier, + private_call_request::PrivateCallRequest, + public_call_request::PublicCallRequest, }, constants::{ + MAX_ENCRYPTED_LOGS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, - MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_ENCRYPTED_LOGS_PER_TX, - MAX_UNENCRYPTED_LOGS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, - }, messaging::l2_to_l1_message::ScopedL2ToL1Message, traits::Empty, + MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX, + }, + messaging::l2_to_l1_message::ScopedL2ToL1Message, + traits::Empty, }; pub struct PrivateAccumulatedDataBuilder { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/public_accumulated_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/public_accumulated_data.nr index 56fdeb8565a..4c1ddda3649 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/public_accumulated_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/public_accumulated_data.nr @@ -1,15 +1,21 @@ use crate::{ abis::{ - public_data_update_request::PublicDataUpdateRequest, gas::Gas, note_hash::ScopedNoteHash, - nullifier::Nullifier, log_hash::{LogHash, ScopedLogHash}, + gas::Gas, + log_hash::{LogHash, ScopedLogHash}, + note_hash::ScopedNoteHash, + nullifier::Nullifier, public_call_request::PublicCallRequest, - }, messaging::l2_to_l1_message::ScopedL2ToL1Message, + public_data_update_request::PublicDataUpdateRequest, + }, constants::{ + MAX_ENCRYPTED_LOGS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, - MAX_L2_TO_L1_MSGS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_ENCRYPTED_LOGS_PER_TX, - MAX_UNENCRYPTED_LOGS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX, NUM_PUBLIC_ACCUMULATED_DATA_ARRAYS, PUBLIC_ACCUMULATED_DATA_LENGTH, - }, traits::{Empty, Serialize, Deserialize}, utils::{arrays::array_length, reader::Reader}, + }, + messaging::l2_to_l1_message::ScopedL2ToL1Message, + traits::{Deserialize, Empty, Serialize}, + utils::{arrays::array_length, reader::Reader}, }; pub struct PublicAccumulatedData { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/public_accumulated_data_builder.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/public_accumulated_data_builder.nr index ea5958c89e9..98b52060000 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/public_accumulated_data_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/public_accumulated_data_builder.nr @@ -1,14 +1,21 @@ use crate::{ abis::{ - gas::Gas, accumulated_data::public_accumulated_data::PublicAccumulatedData, - note_hash::ScopedNoteHash, nullifier::Nullifier, public_call_request::PublicCallRequest, - public_data_update_request::PublicDataUpdateRequest, log_hash::{LogHash, ScopedLogHash}, - }, messaging::l2_to_l1_message::ScopedL2ToL1Message, + accumulated_data::public_accumulated_data::PublicAccumulatedData, + gas::Gas, + log_hash::{LogHash, ScopedLogHash}, + note_hash::ScopedNoteHash, + nullifier::Nullifier, + public_call_request::PublicCallRequest, + public_data_update_request::PublicDataUpdateRequest, + }, constants::{ + MAX_ENCRYPTED_LOGS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, - MAX_L2_TO_L1_MSGS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_ENCRYPTED_LOGS_PER_TX, - MAX_UNENCRYPTED_LOGS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, - }, traits::Empty, utils::arrays::array_to_bounded_vec, + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX, + }, + messaging::l2_to_l1_message::ScopedL2ToL1Message, + traits::Empty, + utils::arrays::array_to_bounded_vec, }; pub struct PublicAccumulatedDataBuilder { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/call_context.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/call_context.nr index 88cd270c42e..6eafed0eedd 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/call_context.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/call_context.nr @@ -1,6 +1,9 @@ use crate::{ - abis::function_selector::FunctionSelector, address::AztecAddress, - constants::CALL_CONTEXT_LENGTH, traits::{Deserialize, Serialize, Empty}, utils::reader::Reader, + abis::function_selector::FunctionSelector, + address::AztecAddress, + constants::CALL_CONTEXT_LENGTH, + traits::{Deserialize, Empty, Serialize}, + utils::reader::Reader, }; // docs:start:call-context diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/combined_constant_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/combined_constant_data.nr index 40d0e8b05ae..6998476def8 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/combined_constant_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/combined_constant_data.nr @@ -1,8 +1,8 @@ -use crate::transaction::tx_context::TxContext; -use crate::header::Header; -use crate::traits::{Empty, Serialize, Deserialize}; use crate::abis::global_variables::GlobalVariables; use crate::constants::COMBINED_CONSTANT_DATA_LENGTH; +use crate::header::Header; +use crate::traits::{Deserialize, Empty, Serialize}; +use crate::transaction::tx_context::TxContext; use crate::utils::reader::Reader; pub struct CombinedConstantData { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/contract_class_function_leaf_preimage.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/contract_class_function_leaf_preimage.nr index 2e82f407044..df6c115b6f6 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/contract_class_function_leaf_preimage.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/contract_class_function_leaf_preimage.nr @@ -1,7 +1,7 @@ use crate::abis::function_selector::FunctionSelector; use crate::constants::GENERATOR_INDEX__FUNCTION_LEAF; -use crate::traits::Hash; use crate::hash::poseidon2_hash_with_separator; +use crate::traits::Hash; pub struct ContractClassFunctionLeafPreimage { selector: FunctionSelector, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/event_selector.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/event_selector.nr index 0b8fdb604f4..464a27c64b1 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/event_selector.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/event_selector.nr @@ -1,4 +1,4 @@ -use crate::traits::{Serialize, Deserialize, FromField, ToField, Empty}; +use crate::traits::{Deserialize, Empty, FromField, Serialize, ToField}; pub struct EventSelector { // 1st 4-bytes (big-endian leftmost) of abi-encoding of an event. diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/function_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/function_data.nr index 66a337f675f..2366cb99ab7 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/function_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/function_data.nr @@ -1,6 +1,7 @@ use crate::{ - abis::function_selector::FunctionSelector, constants::FUNCTION_DATA_LENGTH, - traits::{Serialize, Deserialize, Empty}, + abis::function_selector::FunctionSelector, + constants::FUNCTION_DATA_LENGTH, + traits::{Deserialize, Empty, Serialize}, }; pub struct FunctionData { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/function_selector.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/function_selector.nr index 7e742dba38d..e5aa823cec1 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/function_selector.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/function_selector.nr @@ -1,4 +1,4 @@ -use crate::traits::{Serialize, Deserialize, FromField, ToField, Empty}; +use crate::traits::{Deserialize, Empty, FromField, Serialize, ToField}; pub struct FunctionSelector { // 1st 4-bytes of abi-encoding of function. diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/gas.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/gas.nr index a485eb7cd14..ccd0c236802 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/gas.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/gas.nr @@ -1,6 +1,7 @@ use crate::{ - constants::{GAS_LENGTH, FIXED_DA_GAS, FIXED_L2_GAS}, traits::{Deserialize, Serialize, Empty}, abis::gas_fees::GasFees, + constants::{FIXED_DA_GAS, FIXED_L2_GAS, GAS_LENGTH}, + traits::{Deserialize, Empty, Serialize}, }; use std::ops::{Add, Sub}; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/gas_fees.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/gas_fees.nr index 86a1280e433..60e2b29fa77 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/gas_fees.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/gas_fees.nr @@ -1,4 +1,4 @@ -use crate::{constants::GAS_FEES_LENGTH, traits::{Deserialize, Serialize, Empty}}; +use crate::{constants::GAS_FEES_LENGTH, traits::{Deserialize, Empty, Serialize}}; pub struct GasFees { fee_per_da_gas: Field, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/gas_settings.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/gas_settings.nr index 212875f1580..bf31b75ac47 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/gas_settings.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/gas_settings.nr @@ -1,9 +1,11 @@ use crate::{ abis::{gas::Gas, gas_fees::GasFees}, constants::{ - GAS_SETTINGS_LENGTH, DEFAULT_GAS_LIMIT, DEFAULT_TEARDOWN_GAS_LIMIT, DEFAULT_MAX_FEE_PER_GAS, - DEFAULT_INCLUSION_FEE, - }, traits::{Deserialize, Serialize, Empty}, utils::reader::Reader, + DEFAULT_GAS_LIMIT, DEFAULT_INCLUSION_FEE, DEFAULT_MAX_FEE_PER_GAS, + DEFAULT_TEARDOWN_GAS_LIMIT, GAS_SETTINGS_LENGTH, + }, + traits::{Deserialize, Empty, Serialize}, + utils::reader::Reader, }; pub struct GasSettings { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/global_variables.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/global_variables.nr index 8980b18b01f..abcfab91273 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/global_variables.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/global_variables.nr @@ -1,6 +1,8 @@ use crate::{ - address::{AztecAddress, EthAddress}, abis::gas_fees::GasFees, - constants::GLOBAL_VARIABLES_LENGTH, traits::{Deserialize, Empty, Serialize}, + abis::gas_fees::GasFees, + address::{AztecAddress, EthAddress}, + constants::GLOBAL_VARIABLES_LENGTH, + traits::{Deserialize, Empty, Serialize}, utils::reader::Reader, }; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/kernel_circuit_public_inputs.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/kernel_circuit_public_inputs.nr index 20aa177237d..5743fdb34a3 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/kernel_circuit_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/kernel_circuit_public_inputs.nr @@ -1,9 +1,12 @@ use crate::{ abis::{ accumulated_data::CombinedAccumulatedData, combined_constant_data::CombinedConstantData, - validation_requests::RollupValidationRequests, gas_fees::GasFees, - }, address::AztecAddress, partial_state_reference::PartialStateReference, - traits::{Empty, Serialize, Deserialize}, constants::KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH, + gas_fees::GasFees, validation_requests::RollupValidationRequests, + }, + address::AztecAddress, + constants::KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH, + partial_state_reference::PartialStateReference, + traits::{Deserialize, Empty, Serialize}, utils::reader::Reader, }; @@ -85,9 +88,10 @@ impl Deserialize for KernelCircuitPublicInp mod tests { use crate::abis::{ - kernel_circuit_public_inputs::kernel_circuit_public_inputs::KernelCircuitPublicInputs, accumulated_data::CombinedAccumulatedData, combined_constant_data::CombinedConstantData, - validation_requests::RollupValidationRequests, gas::Gas, gas_fees::GasFees, + gas::Gas, gas_fees::GasFees, + kernel_circuit_public_inputs::kernel_circuit_public_inputs::KernelCircuitPublicInputs, + validation_requests::RollupValidationRequests, }; use crate::address::AztecAddress; use crate::partial_state_reference::PartialStateReference; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/private_kernel_circuit_public_inputs.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/private_kernel_circuit_public_inputs.nr index 992fb75c8f2..647d8d6fc88 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/private_kernel_circuit_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/private_kernel_circuit_public_inputs.nr @@ -2,8 +2,11 @@ use crate::{ abis::{ accumulated_data::PrivateAccumulatedData, combined_constant_data::CombinedConstantData, public_call_request::PublicCallRequest, validation_requests::PrivateValidationRequests, - }, address::AztecAddress, constants::PRIVATE_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH, - traits::{Serialize, Deserialize, Empty}, utils::{arrays::array_length, reader::Reader}, + }, + address::AztecAddress, + constants::PRIVATE_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH, + traits::{Deserialize, Empty, Serialize}, + utils::{arrays::array_length, reader::Reader}, }; pub struct PrivateKernelCircuitPublicInputsArrayLengths { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/private_kernel_circuit_public_inputs_builder.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/private_kernel_circuit_public_inputs_builder.nr index 94a770fbf9d..c602171f27d 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/private_kernel_circuit_public_inputs_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/private_kernel_circuit_public_inputs_builder.nr @@ -5,7 +5,9 @@ use crate::{ kernel_circuit_public_inputs::private_kernel_circuit_public_inputs::PrivateKernelCircuitPublicInputs, public_call_request::PublicCallRequest, validation_requests::PrivateValidationRequestsBuilder, - }, address::AztecAddress, traits::Empty, + }, + address::AztecAddress, + traits::Empty, }; pub struct PrivateKernelCircuitPublicInputsBuilder { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/public_kernel_circuit_public_inputs.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/public_kernel_circuit_public_inputs.nr index 341a839e2bc..7e7921f340e 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/public_kernel_circuit_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/public_kernel_circuit_public_inputs.nr @@ -2,8 +2,11 @@ use crate::{ abis::{ accumulated_data::PublicAccumulatedData, combined_constant_data::CombinedConstantData, public_call_request::PublicCallRequest, validation_requests::PublicValidationRequests, - }, address::AztecAddress, constants::PUBLIC_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH, - traits::{Empty, Serialize, Deserialize}, utils::reader::Reader, + }, + address::AztecAddress, + constants::PUBLIC_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH, + traits::{Deserialize, Empty, Serialize}, + utils::reader::Reader, }; pub struct PublicKernelCircuitPublicInputs { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/public_kernel_circuit_public_inputs_builder.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/public_kernel_circuit_public_inputs_builder.nr index 87d4a1f7e37..f81c736f9bd 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/public_kernel_circuit_public_inputs_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/public_kernel_circuit_public_inputs_builder.nr @@ -5,7 +5,9 @@ use crate::{ kernel_circuit_public_inputs::public_kernel_circuit_public_inputs::PublicKernelCircuitPublicInputs, public_call_request::PublicCallRequest, validation_requests::PublicValidationRequestsBuilder, - }, address::AztecAddress, traits::Empty, + }, + address::AztecAddress, + traits::Empty, }; pub struct PublicKernelCircuitPublicInputsBuilder { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/vm_circuit_public_inputs.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/vm_circuit_public_inputs.nr index 0c56f0f34bb..2bfd1cfe59d 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/vm_circuit_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_circuit_public_inputs/vm_circuit_public_inputs.nr @@ -1,11 +1,15 @@ use crate::{ abis::{ accumulated_data::{PublicAccumulatedData, PublicAccumulatedDataArrayLengths}, - combined_constant_data::CombinedConstantData, gas::Gas, - public_call_request::PublicCallRequest, public_inner_call_request::PublicInnerCallRequest, - validation_requests::{PublicValidationRequests, PublicValidationRequestArrayLengths}, - }, constants::{MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, VM_CIRCUIT_PUBLIC_INPUTS_LENGTH}, - traits::{Deserialize, Empty, Serialize}, utils::reader::Reader, + combined_constant_data::CombinedConstantData, + gas::Gas, + public_call_request::PublicCallRequest, + public_inner_call_request::PublicInnerCallRequest, + validation_requests::{PublicValidationRequestArrayLengths, PublicValidationRequests}, + }, + constants::{MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, VM_CIRCUIT_PUBLIC_INPUTS_LENGTH}, + traits::{Deserialize, Empty, Serialize}, + utils::reader::Reader, }; pub struct VMCircuitPublicInputs { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_data.nr index 92dc2b13ef2..ba83686a0a8 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/kernel_data.nr @@ -1,9 +1,11 @@ use crate::{ abis::kernel_circuit_public_inputs::KernelCircuitPublicInputs, - constants::{VK_TREE_HEIGHT, TUBE_INDEX}, merkle_tree::membership::check_membership, + constants::{TUBE_INDEX, VK_TREE_HEIGHT}, + merkle_tree::membership::check_membership, recursion::{ - proof::NestedRecursiveProof, verification_key::HonkVerificationKey, traits::Verifiable, - }, utils::arrays::find_index_hint, + proof::NestedRecursiveProof, traits::Verifiable, verification_key::HonkVerificationKey, + }, + utils::arrays::find_index_hint, }; pub struct KernelData { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/log_hash.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/log_hash.nr index bacd96d4503..6969df71a5e 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/log_hash.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/log_hash.nr @@ -1,9 +1,12 @@ use crate::{ - abis::side_effect::{Ordered, OrderedValue, Scoped}, address::AztecAddress, + abis::side_effect::{Ordered, OrderedValue, Scoped}, + address::AztecAddress, constants::{ - LOG_HASH_LENGTH, NOTE_LOG_HASH_LENGTH, ENCRYPTED_LOG_HASH_LENGTH, SCOPED_LOG_HASH_LENGTH, - SCOPED_ENCRYPTED_LOG_HASH_LENGTH, - }, traits::{Empty, Serialize, Deserialize}, utils::{arrays::array_concat, reader::Reader}, + ENCRYPTED_LOG_HASH_LENGTH, LOG_HASH_LENGTH, NOTE_LOG_HASH_LENGTH, + SCOPED_ENCRYPTED_LOG_HASH_LENGTH, SCOPED_LOG_HASH_LENGTH, + }, + traits::{Deserialize, Empty, Serialize}, + utils::{arrays::array_concat, reader::Reader}, }; pub struct LogHash { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/max_block_number.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/max_block_number.nr index c2df0f417c9..501ff0a3c55 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/max_block_number.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/max_block_number.nr @@ -1,4 +1,4 @@ -use crate::{constants::MAX_BLOCK_NUMBER_LENGTH, traits::{Deserialize, Serialize, Empty}}; +use crate::{constants::MAX_BLOCK_NUMBER_LENGTH, traits::{Deserialize, Empty, Serialize}}; pub struct MaxBlockNumber { _opt: Option, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/note_hash.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/note_hash.nr index e7096bf0175..83063fe84cc 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/note_hash.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/note_hash.nr @@ -1,7 +1,8 @@ use crate::{ - abis::read_request::ScopedReadRequest, address::AztecAddress, - abis::side_effect::{Ordered, OrderedValue, Readable, Scoped}, - constants::{NOTE_HASH_LENGTH, SCOPED_NOTE_HASH_LENGTH}, traits::{Empty, Serialize, Deserialize}, + abis::{read_request::ScopedReadRequest, side_effect::{Ordered, OrderedValue, Readable, Scoped}}, + address::AztecAddress, + constants::{NOTE_HASH_LENGTH, SCOPED_NOTE_HASH_LENGTH}, + traits::{Deserialize, Empty, Serialize}, utils::{arrays::array_concat, reader::Reader}, }; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/note_hash_leaf_preimage.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/note_hash_leaf_preimage.nr index 1c0cedca919..0c8d740f55e 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/note_hash_leaf_preimage.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/note_hash_leaf_preimage.nr @@ -1,8 +1,10 @@ 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, + abis::{read_request::ScopedReadRequest, side_effect::Readable}, + hash::compute_siloed_note_hash, + merkle_tree::leaf_preimage::LeafPreimage, + traits::Empty, }; pub struct NoteHashLeafPreimage { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/nullifier.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/nullifier.nr index 834247cec8e..fdfe8e26425 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/nullifier.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/nullifier.nr @@ -1,7 +1,9 @@ use crate::{ - abis::{side_effect::{Ordered, OrderedValue, Readable, Scoped}, read_request::ScopedReadRequest}, - address::AztecAddress, constants::{NULLIFIER_LENGTH, SCOPED_NULLIFIER_LENGTH}, - hash::compute_siloed_nullifier, traits::{Empty, Serialize, Deserialize}, + abis::{read_request::ScopedReadRequest, side_effect::{Ordered, OrderedValue, Readable, Scoped}}, + address::AztecAddress, + constants::{NULLIFIER_LENGTH, SCOPED_NULLIFIER_LENGTH}, + hash::compute_siloed_nullifier, + traits::{Deserialize, Empty, Serialize}, utils::{arrays::array_concat, reader::Reader}, }; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/nullifier_leaf_preimage.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/nullifier_leaf_preimage.nr index 9a957395e6a..d9361aa1dec 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/nullifier_leaf_preimage.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/nullifier_leaf_preimage.nr @@ -1,8 +1,10 @@ global NULLIFIER_LEAF_PREIMAGE_LENGTH: u32 = 3; use crate::{ - abis::{read_request::ScopedReadRequest, side_effect::Readable}, hash::compute_siloed_nullifier, - merkle_tree::leaf_preimage::{LeafPreimage, IndexedTreeLeafPreimage}, traits::{Empty, Hash}, + abis::{read_request::ScopedReadRequest, side_effect::Readable}, + hash::compute_siloed_nullifier, + merkle_tree::leaf_preimage::{IndexedTreeLeafPreimage, LeafPreimage}, + traits::{Empty, Hash}, }; pub struct NullifierLeafPreimage { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_call_request.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_call_request.nr index 5165d1ad434..b1585b82e92 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_call_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_call_request.nr @@ -1,6 +1,7 @@ use crate::{ abis::{call_context::CallContext, side_effect::{Ordered, RangeOrdered}}, - constants::PRIVATE_CALL_REQUEST_LENGTH, traits::{Empty, Serialize, Deserialize}, + constants::PRIVATE_CALL_REQUEST_LENGTH, + traits::{Deserialize, Empty, Serialize}, utils::reader::Reader, }; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_circuit_public_inputs.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_circuit_public_inputs.nr index 52361319969..cf1b9b4f8c8 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_circuit_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_circuit_public_inputs.nr @@ -1,21 +1,28 @@ use crate::{ abis::{ - call_context::CallContext, max_block_number::MaxBlockNumber, - validation_requests::KeyValidationRequestAndGenerator, note_hash::NoteHash, - nullifier::Nullifier, private_call_request::PrivateCallRequest, - public_call_request::PublicCallRequest, read_request::ReadRequest, - log_hash::{LogHash, NoteLogHash, EncryptedLogHash}, + call_context::CallContext, + log_hash::{EncryptedLogHash, LogHash, NoteLogHash}, + max_block_number::MaxBlockNumber, + note_hash::NoteHash, + nullifier::Nullifier, + private_call_request::PrivateCallRequest, + public_call_request::PublicCallRequest, + read_request::ReadRequest, + validation_requests::KeyValidationRequestAndGenerator, }, constants::{ - MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, MAX_NULLIFIER_READ_REQUESTS_PER_CALL, - MAX_KEY_VALIDATION_REQUESTS_PER_CALL, MAX_NOTE_HASHES_PER_CALL, MAX_NULLIFIERS_PER_CALL, + MAX_ENCRYPTED_LOGS_PER_CALL, MAX_KEY_VALIDATION_REQUESTS_PER_CALL, + MAX_L2_TO_L1_MSGS_PER_CALL, MAX_NOTE_ENCRYPTED_LOGS_PER_CALL, + MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, MAX_NOTE_HASHES_PER_CALL, + MAX_NULLIFIER_READ_REQUESTS_PER_CALL, MAX_NULLIFIERS_PER_CALL, MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, - MAX_L2_TO_L1_MSGS_PER_CALL, PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH, - MAX_ENCRYPTED_LOGS_PER_CALL, MAX_UNENCRYPTED_LOGS_PER_CALL, - MAX_NOTE_ENCRYPTED_LOGS_PER_CALL, - }, header::Header, messaging::l2_to_l1_message::L2ToL1Message, - traits::{Deserialize, Serialize, Empty}, utils::reader::Reader, - transaction::tx_context::TxContext, utils::arrays::validate_array, + MAX_UNENCRYPTED_LOGS_PER_CALL, PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH, + }, + header::Header, + messaging::l2_to_l1_message::L2ToL1Message, + traits::{Deserialize, Empty, Serialize}, + transaction::tx_context::TxContext, + utils::{arrays::validate_array, reader::Reader}, }; pub struct PrivateCircuitPublicInputsArrayLengths { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_kernel/private_call_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_kernel/private_call_data.nr index 8ac455d134f..459aeab8bd2 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_kernel/private_call_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_kernel/private_call_data.nr @@ -1,8 +1,9 @@ use crate::{ abis::private_circuit_public_inputs::PrivateCircuitPublicInputs, - address::SaltedInitializationHash, public_keys::PublicKeys, + address::SaltedInitializationHash, constants::{FUNCTION_TREE_HEIGHT, PROTOCOL_CONTRACT_TREE_HEIGHT}, merkle_tree::membership::MembershipWitness, + public_keys::PublicKeys, recursion::verification_key::ClientIVCVerificationKey, }; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_kernel_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_kernel_data.nr index 813f04794b3..4a8f350de4a 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_kernel_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_kernel_data.nr @@ -2,7 +2,8 @@ use crate::{ abis::kernel_circuit_public_inputs::PrivateKernelCircuitPublicInputs, constants::{PRIVATE_KERNEL_RESET_INDEX, VK_TREE_HEIGHT}, merkle_tree::membership::assert_check_membership, - recursion::verification_key::ClientIVCVerificationKey, utils::arrays::find_index_hint, + recursion::verification_key::ClientIVCVerificationKey, + utils::arrays::find_index_hint, }; pub struct PrivateKernelData { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_call_request.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_call_request.nr index dd0472b4f29..d8aaf06f80c 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_call_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_call_request.nr @@ -1,6 +1,8 @@ use crate::{ - abis::{call_context::CallContext, side_effect::Ordered}, address::AztecAddress, - constants::PUBLIC_CALL_REQUEST_LENGTH, traits::{Empty, Serialize, Deserialize}, + abis::{call_context::CallContext, side_effect::Ordered}, + address::AztecAddress, + constants::PUBLIC_CALL_REQUEST_LENGTH, + traits::{Deserialize, Empty, Serialize}, utils::reader::Reader, }; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_call_stack_item_compressed.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_call_stack_item_compressed.nr index c3348f0e107..4718fdba549 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_call_stack_item_compressed.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_call_stack_item_compressed.nr @@ -1,7 +1,7 @@ use crate::abis::{call_context::CallContext, gas::Gas}; use crate::address::AztecAddress; use crate::constants::PUBLIC_CALL_STACK_ITEM_COMPRESSED_LENGTH; -use crate::traits::{Empty, Serialize, Deserialize}; +use crate::traits::{Deserialize, Empty, Serialize}; use crate::utils::reader::Reader; /** diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_circuit_public_inputs.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_circuit_public_inputs.nr index dd2da003f28..f1171176d09 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_circuit_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_circuit_public_inputs.nr @@ -1,20 +1,24 @@ use crate::{ abis::{ - call_context::CallContext, note_hash::NoteHash, nullifier::Nullifier, - read_request::ReadRequest, tree_leaf_read_request::TreeLeafReadRequest, gas::Gas, - global_variables::GlobalVariables, log_hash::LogHash, - public_inner_call_request::PublicInnerCallRequest, - }, address::AztecAddress, + call_context::CallContext, gas::Gas, global_variables::GlobalVariables, log_hash::LogHash, + note_hash::NoteHash, nullifier::Nullifier, + public_inner_call_request::PublicInnerCallRequest, read_request::ReadRequest, + tree_leaf_read_request::TreeLeafReadRequest, + }, + address::AztecAddress, constants::{ MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL, MAX_L2_TO_L1_MSGS_PER_CALL, - MAX_NULLIFIERS_PER_CALL, MAX_NOTE_HASHES_PER_CALL, MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, - MAX_NULLIFIER_READ_REQUESTS_PER_CALL, MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL, - MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, MAX_PUBLIC_DATA_READS_PER_CALL, - MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH, - MAX_UNENCRYPTED_LOGS_PER_CALL, - }, contrakt::{storage_read::StorageRead, storage_update_request::StorageUpdateRequest}, - header::Header, messaging::l2_to_l1_message::L2ToL1Message, - traits::{Serialize, Deserialize, Empty}, utils::reader::Reader, + MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, MAX_NOTE_HASHES_PER_CALL, + MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL, MAX_NULLIFIER_READ_REQUESTS_PER_CALL, + MAX_NULLIFIERS_PER_CALL, MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, + MAX_PUBLIC_DATA_READS_PER_CALL, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, + MAX_UNENCRYPTED_LOGS_PER_CALL, PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH, + }, + contrakt::{storage_read::StorageRead, storage_update_request::StorageUpdateRequest}, + header::Header, + messaging::l2_to_l1_message::L2ToL1Message, + traits::{Deserialize, Empty, Serialize}, + utils::reader::Reader, }; // Public inputs to public app circuit. diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_read.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_read.nr index 1b45465e30a..89427f042c2 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_read.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_read.nr @@ -1,8 +1,10 @@ use crate::{ - abis::side_effect::Ordered, address::AztecAddress, constants::PUBLIC_DATA_READ_LENGTH, + abis::side_effect::Ordered, + address::AztecAddress, + constants::PUBLIC_DATA_READ_LENGTH, contrakt::storage_read::StorageRead, - data::hash::{compute_public_data_tree_value, compute_public_data_tree_index}, - traits::{Empty, Serialize, Deserialize}, + data::hash::{compute_public_data_tree_index, compute_public_data_tree_value}, + traits::{Deserialize, Empty, Serialize}, }; pub struct PublicDataRead { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_update_request.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_update_request.nr index 7dd85276626..6b55882403a 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_update_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_update_request.nr @@ -1,10 +1,13 @@ use crate::{ - abis::side_effect::Ordered, address::AztecAddress, constants::PUBLIC_DATA_UPDATE_REQUEST_LENGTH, + abis::side_effect::Ordered, + address::AztecAddress, + constants::PUBLIC_DATA_UPDATE_REQUEST_LENGTH, contrakt::storage_update_request::StorageUpdateRequest, data::{ - hash::{compute_public_data_tree_value, compute_public_data_tree_index}, + hash::{compute_public_data_tree_index, compute_public_data_tree_value}, public_data_tree_leaf::PublicDataTreeLeaf, - }, traits::{Empty, Serialize, Deserialize}, + }, + traits::{Deserialize, Empty, Serialize}, }; // TODO: Rename to PublicDataWrite diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_write.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_write.nr index b829d06d7b4..290c6ca6e31 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_write.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_data_write.nr @@ -1,8 +1,10 @@ use crate::{ abis::{ - public_data_read::PublicDataRead, public_data_update_request::PublicDataUpdateRequest, + public_data_read::PublicDataRead, + public_data_update_request::PublicDataUpdateRequest, side_effect::{Inner, Ordered, Overridable, Readable}, - }, traits::Empty, + }, + traits::Empty, }; pub struct OverridablePublicDataWrite { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_inner_call_request.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_inner_call_request.nr index cdabed4663e..1535e297904 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_inner_call_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_inner_call_request.nr @@ -1,6 +1,7 @@ use crate::{ abis::{public_call_stack_item_compressed::PublicCallStackItemCompressed, side_effect::Ordered}, - constants::PUBLIC_INNER_CALL_REQUEST_LENGTH, traits::{Empty, Serialize, Deserialize}, + constants::PUBLIC_INNER_CALL_REQUEST_LENGTH, + traits::{Deserialize, Empty, Serialize}, utils::reader::Reader, }; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_kernel_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_kernel_data.nr index 13c68e9d82b..c8e8a15d35e 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_kernel_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_kernel_data.nr @@ -1,9 +1,11 @@ use crate::{ abis::kernel_circuit_public_inputs::PublicKernelCircuitPublicInputs, - constants::{VK_TREE_HEIGHT, TUBE_INDEX}, merkle_tree::membership::check_membership, + constants::{TUBE_INDEX, VK_TREE_HEIGHT}, + merkle_tree::membership::check_membership, recursion::{ - proof::NestedRecursiveProof, verification_key::HonkVerificationKey, traits::Verifiable, - }, utils::arrays::find_index_hint, + proof::NestedRecursiveProof, traits::Verifiable, verification_key::HonkVerificationKey, + }, + utils::arrays::find_index_hint, }; pub struct PublicKernelData { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_kernel_inner_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_kernel_inner_data.nr index 491abeb3169..1b4977af032 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_kernel_inner_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_kernel_inner_data.nr @@ -1,7 +1,7 @@ use crate::{ abis::kernel_circuit_public_inputs::VMCircuitPublicInputs, recursion::{ - proof::NestedRecursiveProof, verification_key::HonkVerificationKey, traits::Verifiable, + proof::NestedRecursiveProof, traits::Verifiable, verification_key::HonkVerificationKey, }, }; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/read_request.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/read_request.nr index fc7742e4eb4..8191f4ee4dc 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/read_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/read_request.nr @@ -1,6 +1,8 @@ use crate::{ - abis::side_effect::{Ordered, Scoped}, traits::{Empty, Serialize, Deserialize}, - address::AztecAddress, constants::{READ_REQUEST_LENGTH, SCOPED_READ_REQUEST_LEN}, + abis::side_effect::{Ordered, Scoped}, + address::AztecAddress, + constants::{READ_REQUEST_LENGTH, SCOPED_READ_REQUEST_LEN}, + traits::{Deserialize, Empty, Serialize}, utils::{arrays::array_concat, reader::Reader}, }; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/tree_leaf_read_request.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/tree_leaf_read_request.nr index fe03444b4ca..22998960b2c 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/tree_leaf_read_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/tree_leaf_read_request.nr @@ -1,4 +1,4 @@ -use crate::{traits::{Empty, Serialize, Deserialize}, constants::TREE_LEAF_READ_REQUEST_LENGTH}; +use crate::{constants::TREE_LEAF_READ_REQUEST_LENGTH, traits::{Deserialize, Empty, Serialize}}; pub struct TreeLeafReadRequest { value: Field, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/key_validation_request.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/key_validation_request.nr index 2929f3a15ca..cb2c3eea7d3 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/key_validation_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/key_validation_request.nr @@ -1,4 +1,4 @@ -use crate::{traits::{Empty, Serialize, Deserialize}, point::Point}; +use crate::{point::Point, traits::{Deserialize, Empty, Serialize}}; pub use crate::constants::KEY_VALIDATION_REQUEST_LENGTH; pub struct KeyValidationRequest { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/key_validation_request_and_generator.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/key_validation_request_and_generator.nr index 604a0d3aa5f..5ae055a5724 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/key_validation_request_and_generator.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/key_validation_request_and_generator.nr @@ -1,10 +1,12 @@ use crate::{ - address::AztecAddress, abis::validation_requests::{ key_validation_request::KeyValidationRequest, scoped_key_validation_request_and_generator::ScopedKeyValidationRequestAndGenerator, - }, constants::KEY_VALIDATION_REQUEST_AND_GENERATOR_LENGTH, - traits::{Empty, Serialize, Deserialize}, utils::{arrays::array_concat, reader::Reader}, + }, + address::AztecAddress, + constants::KEY_VALIDATION_REQUEST_AND_GENERATOR_LENGTH, + traits::{Deserialize, Empty, Serialize}, + utils::{arrays::array_concat, reader::Reader}, }; pub struct KeyValidationRequestAndGenerator { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/mod.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/mod.nr index fc63425956b..31703c5c251 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/mod.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/mod.nr @@ -11,7 +11,7 @@ pub use key_validation_request::KeyValidationRequest; pub use key_validation_request_and_generator::KeyValidationRequestAndGenerator; pub use private_validation_requests::PrivateValidationRequests; pub use private_validation_requests_builder::PrivateValidationRequestsBuilder; -pub use public_validation_requests::{PublicValidationRequests, PublicValidationRequestArrayLengths}; +pub use public_validation_requests::{PublicValidationRequestArrayLengths, PublicValidationRequests}; pub use public_validation_requests_builder::PublicValidationRequestsBuilder; pub use rollup_validation_requests::RollupValidationRequests; pub use scoped_key_validation_request_and_generator::ScopedKeyValidationRequestAndGenerator; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/private_validation_requests.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/private_validation_requests.nr index 6025c64900d..f1e6adea10e 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/private_validation_requests.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/private_validation_requests.nr @@ -7,9 +7,11 @@ use crate::{ }, }, constants::{ - MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX, - MAX_KEY_VALIDATION_REQUESTS_PER_TX, PRIVATE_VALIDATION_REQUESTS_LENGTH, - }, traits::{Serialize, Deserialize, Empty}, utils::reader::Reader, + MAX_KEY_VALIDATION_REQUESTS_PER_TX, MAX_NOTE_HASH_READ_REQUESTS_PER_TX, + MAX_NULLIFIER_READ_REQUESTS_PER_TX, PRIVATE_VALIDATION_REQUESTS_LENGTH, + }, + traits::{Deserialize, Empty, Serialize}, + utils::reader::Reader, }; pub struct PrivateValidationRequests { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/private_validation_requests_builder.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/private_validation_requests_builder.nr index e395c1ff6a7..1fe0e108e8b 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/private_validation_requests_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/private_validation_requests_builder.nr @@ -1,6 +1,7 @@ use crate::{ abis::{ - max_block_number::MaxBlockNumber, read_request::ScopedReadRequest, + max_block_number::MaxBlockNumber, + read_request::ScopedReadRequest, validation_requests::{ private_validation_requests::PrivateValidationRequests, rollup_validation_requests::RollupValidationRequests, @@ -8,9 +9,10 @@ use crate::{ }, }, constants::{ - MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX, - MAX_KEY_VALIDATION_REQUESTS_PER_TX, - }, traits::Empty, + MAX_KEY_VALIDATION_REQUESTS_PER_TX, MAX_NOTE_HASH_READ_REQUESTS_PER_TX, + MAX_NULLIFIER_READ_REQUESTS_PER_TX, + }, + traits::Empty, }; pub struct PrivateValidationRequestsBuilder { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/public_validation_requests.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/public_validation_requests.nr index b0c8ce4a3c4..c6d77daadd1 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/public_validation_requests.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/public_validation_requests.nr @@ -6,10 +6,12 @@ use crate::{ }, constants::{ MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX, MAX_NOTE_HASH_READ_REQUESTS_PER_TX, - MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX, + MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_PUBLIC_DATA_READS_PER_TX, NUM_PUBLIC_VALIDATION_REQUEST_ARRAYS, PUBLIC_VALIDATION_REQUESTS_LENGTH, - }, traits::{Serialize, Deserialize, Empty}, utils::{arrays::array_length, reader::Reader}, + }, + traits::{Deserialize, Empty, Serialize}, + utils::{arrays::array_length, reader::Reader}, }; pub struct PublicValidationRequests { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/public_validation_requests_builder.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/public_validation_requests_builder.nr index 4fcbe4a6cb9..b5a45d5faea 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/public_validation_requests_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/public_validation_requests_builder.nr @@ -1,7 +1,9 @@ use crate::{ abis::{ - max_block_number::MaxBlockNumber, public_data_read::PublicDataRead, - read_request::ScopedReadRequest, tree_leaf_read_request::TreeLeafReadRequest, + max_block_number::MaxBlockNumber, + public_data_read::PublicDataRead, + read_request::ScopedReadRequest, + tree_leaf_read_request::TreeLeafReadRequest, validation_requests::{ public_validation_requests::PublicValidationRequests, rollup_validation_requests::RollupValidationRequests, @@ -9,9 +11,11 @@ use crate::{ }, constants::{ MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX, MAX_NOTE_HASH_READ_REQUESTS_PER_TX, - MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX, + MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_PUBLIC_DATA_READS_PER_TX, - }, traits::Empty, utils::arrays::array_to_bounded_vec, + }, + traits::Empty, + utils::arrays::array_to_bounded_vec, }; pub struct PublicValidationRequestsBuilder { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/rollup_validation_requests.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/rollup_validation_requests.nr index c29122fbc1f..79ddba32742 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/rollup_validation_requests.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/rollup_validation_requests.nr @@ -1,6 +1,8 @@ use crate::{ - abis::max_block_number::MaxBlockNumber, traits::{Empty, Serialize, Deserialize}, - constants::ROLLUP_VALIDATION_REQUESTS_LENGTH, utils::reader::Reader, + abis::max_block_number::MaxBlockNumber, + constants::ROLLUP_VALIDATION_REQUESTS_LENGTH, + traits::{Deserialize, Empty, Serialize}, + utils::reader::Reader, }; // These are validation requests that cannot be fulfilled in the current context (private or public), and must be diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/scoped_key_validation_request_and_generator.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/scoped_key_validation_request_and_generator.nr index 259ba94bc9b..17eda595bc8 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/scoped_key_validation_request_and_generator.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/scoped_key_validation_request_and_generator.nr @@ -1,10 +1,12 @@ use crate::{ - address::AztecAddress, constants::SCOPED_KEY_VALIDATION_REQUEST_AND_GENERATOR_LENGTH, - traits::{Empty, Serialize, Deserialize}, utils::{arrays::array_concat, reader::Reader}, abis::{ side_effect::Scoped, validation_requests::key_validation_request_and_generator::KeyValidationRequestAndGenerator, }, + address::AztecAddress, + constants::SCOPED_KEY_VALIDATION_REQUEST_AND_GENERATOR_LENGTH, + traits::{Deserialize, Empty, Serialize}, + utils::{arrays::array_concat, reader::Reader}, }; pub struct ScopedKeyValidationRequestAndGenerator { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/address/aztec_address.nr b/noir-projects/noir-protocol-circuits/crates/types/src/address/aztec_address.nr index c1515da11b0..718cbeea4ef 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/address/aztec_address.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/address/aztec_address.nr @@ -8,7 +8,8 @@ use crate::{ contract_class_id::ContractClassId, hash::{poseidon2_hash_with_separator, private_functions_root_from_siblings}, merkle_tree::membership::MembershipWitness, - traits::{Empty, FromField, ToField, Serialize, Deserialize}, utils, + traits::{Deserialize, Empty, FromField, Serialize, ToField}, + utils, }; // Aztec address diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/address/eth_address.nr b/noir-projects/noir-protocol-circuits/crates/types/src/address/eth_address.nr index 22c40cc3876..465ae83c61e 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/address/eth_address.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/address/eth_address.nr @@ -1,4 +1,4 @@ -use crate::{constants::ETH_ADDRESS_LENGTH, traits::{Empty, ToField, Serialize, Deserialize}, utils}; +use crate::{constants::ETH_ADDRESS_LENGTH, traits::{Deserialize, Empty, Serialize, ToField}, utils}; pub struct EthAddress { inner: Field, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/address/partial_address.nr b/noir-projects/noir-protocol-circuits/crates/types/src/address/partial_address.nr index d0be0319866..e44ff45d7d5 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/address/partial_address.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/address/partial_address.nr @@ -1,7 +1,9 @@ use crate::{ - address::{salted_initialization_hash::SaltedInitializationHash, aztec_address::AztecAddress}, - constants::GENERATOR_INDEX__PARTIAL_ADDRESS, contract_class_id::ContractClassId, - hash::poseidon2_hash_with_separator, traits::{ToField, Serialize, Deserialize}, + address::{aztec_address::AztecAddress, salted_initialization_hash::SaltedInitializationHash}, + constants::GENERATOR_INDEX__PARTIAL_ADDRESS, + contract_class_id::ContractClassId, + hash::poseidon2_hash_with_separator, + traits::{Deserialize, Serialize, ToField}, }; global PARTIAL_ADDRESS_LENGTH: u32 = 1; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/address/public_keys_hash.nr b/noir-projects/noir-protocol-circuits/crates/types/src/address/public_keys_hash.nr index 6e18b46788d..3c24408410c 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/address/public_keys_hash.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/address/public_keys_hash.nr @@ -1,4 +1,4 @@ -use crate::traits::{ToField, Serialize, Deserialize}; +use crate::traits::{Deserialize, Serialize, ToField}; // Public keys hash. Used in the computation of an address. pub struct PublicKeysHash { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/contract_class_id.nr b/noir-projects/noir-protocol-circuits/crates/types/src/contract_class_id.nr index 515c840de60..76938ab5391 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/contract_class_id.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/contract_class_id.nr @@ -1,5 +1,5 @@ use crate::constants::GENERATOR_INDEX__CONTRACT_LEAF; -use crate::traits::{ToField, FromField, Serialize, Deserialize}; +use crate::traits::{Deserialize, FromField, Serialize, ToField}; pub struct ContractClassId { inner: Field, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/contract_instance.nr b/noir-projects/noir-protocol-circuits/crates/types/src/contract_instance.nr index dfe75822aba..2a95be38ea6 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/contract_instance.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/contract_instance.nr @@ -2,8 +2,11 @@ use crate::{ address::{ aztec_address::AztecAddress, partial_address::PartialAddress, public_keys_hash::PublicKeysHash, - }, public_keys::PublicKeys, contract_class_id::ContractClassId, - constants::CONTRACT_INSTANCE_LENGTH, traits::{Deserialize, Hash, Serialize}, + }, + constants::CONTRACT_INSTANCE_LENGTH, + contract_class_id::ContractClassId, + public_keys::PublicKeys, + traits::{Deserialize, Hash, Serialize}, }; pub struct ContractInstance { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/contrakt/storage_update_request.nr b/noir-projects/noir-protocol-circuits/crates/types/src/contrakt/storage_update_request.nr index 37cb287f5d2..d9a8071a605 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/contrakt/storage_update_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/contrakt/storage_update_request.nr @@ -1,5 +1,6 @@ use crate::{ - constants::CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH, traits::{Deserialize, Empty, Serialize}, + constants::CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH, + traits::{Deserialize, Empty, Serialize}, }; pub struct StorageUpdateRequest { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_hint.nr b/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_hint.nr index 75d40b0e754..6adec664620 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_hint.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_hint.nr @@ -1,7 +1,8 @@ use crate::{ - data::public_data_tree_leaf_preimage::PublicDataTreeLeafPreimage, traits::Empty, - merkle_tree::{MembershipWitness, conditionally_assert_check_membership}, constants::PUBLIC_DATA_TREE_HEIGHT, + data::public_data_tree_leaf_preimage::PublicDataTreeLeafPreimage, + merkle_tree::{conditionally_assert_check_membership, MembershipWitness}, + traits::Empty, }; pub struct PublicDataHint { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_leaf_hint.nr b/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_leaf_hint.nr index a6fb45794a0..7bbc6e2c659 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_leaf_hint.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_leaf_hint.nr @@ -1,6 +1,7 @@ use crate::{ - data::public_data_tree_leaf_preimage::PublicDataTreeLeafPreimage, traits::Empty, - merkle_tree::MembershipWitness, constants::PUBLIC_DATA_TREE_HEIGHT, + constants::PUBLIC_DATA_TREE_HEIGHT, + data::public_data_tree_leaf_preimage::PublicDataTreeLeafPreimage, + merkle_tree::MembershipWitness, traits::Empty, }; pub struct PublicDataLeafHint { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_tree_leaf.nr b/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_tree_leaf.nr index 07c2fd40a6d..64f02300c9e 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_tree_leaf.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/data/public_data_tree_leaf.nr @@ -1,5 +1,6 @@ use crate::{ - abis::{public_data_read::PublicDataRead, side_effect::{Overridable, Readable}}, traits::Empty, + abis::{public_data_read::PublicDataRead, side_effect::{Overridable, Readable}}, + traits::Empty, }; pub struct PublicDataTreeLeaf { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/hash.nr b/noir-projects/noir-protocol-circuits/crates/types/src/hash.nr index 63c14f6966e..7ceb2ba0b6e 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/hash.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/hash.nr @@ -2,16 +2,20 @@ use crate::{ abis::{ contract_class_function_leaf_preimage::ContractClassFunctionLeafPreimage, function_selector::FunctionSelector, - log_hash::{LogHash, ScopedLogHash, ScopedEncryptedLogHash}, note_hash::ScopedNoteHash, + log_hash::{LogHash, ScopedEncryptedLogHash, ScopedLogHash}, + note_hash::ScopedNoteHash, nullifier::ScopedNullifier, - }, address::{AztecAddress, EthAddress}, + }, + address::{AztecAddress, EthAddress}, constants::{ - FUNCTION_TREE_HEIGHT, GENERATOR_INDEX__SILOED_NOTE_HASH, GENERATOR_INDEX__OUTER_NULLIFIER, - GENERATOR_INDEX__VK, GENERATOR_INDEX__NOTE_HASH_NONCE, GENERATOR_INDEX__UNIQUE_NOTE_HASH, + FUNCTION_TREE_HEIGHT, GENERATOR_INDEX__NOTE_HASH_NONCE, GENERATOR_INDEX__OUTER_NULLIFIER, + GENERATOR_INDEX__SILOED_NOTE_HASH, GENERATOR_INDEX__UNIQUE_NOTE_HASH, GENERATOR_INDEX__VK, MAX_ENCRYPTED_LOGS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, - }, merkle_tree::root::root_from_sibling_path, + }, + merkle_tree::root::root_from_sibling_path, messaging::l2_to_l1_message::{L2ToL1Message, ScopedL2ToL1Message}, - recursion::verification_key::VerificationKey, traits::{is_empty, ToField}, + recursion::verification_key::VerificationKey, + traits::{is_empty, ToField}, utils::field::field_from_bytes_32_trunc, }; use super::utils::field::field_from_bytes; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/header.nr b/noir-projects/noir-protocol-circuits/crates/types/src/header.nr index d56fa590b9f..fa4a57da32b 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/header.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/header.nr @@ -1,14 +1,17 @@ use crate::{ abis::{ - append_only_tree_snapshot::{AppendOnlyTreeSnapshot, APPEND_ONLY_TREE_SNAPSHOT_LENGTH}, + append_only_tree_snapshot::{APPEND_ONLY_TREE_SNAPSHOT_LENGTH, AppendOnlyTreeSnapshot}, global_variables::GlobalVariables, }, constants::{ - GENERATOR_INDEX__BLOCK_HASH, GLOBAL_VARIABLES_LENGTH, HEADER_LENGTH, STATE_REFERENCE_LENGTH, - CONTENT_COMMITMENT_LENGTH, - }, hash::poseidon2_hash_with_separator, state_reference::StateReference, - traits::{Deserialize, Empty, Hash, Serialize}, utils::arr_copy_slice, + CONTENT_COMMITMENT_LENGTH, GENERATOR_INDEX__BLOCK_HASH, GLOBAL_VARIABLES_LENGTH, + HEADER_LENGTH, STATE_REFERENCE_LENGTH, + }, content_commitment::ContentCommitment, + hash::poseidon2_hash_with_separator, + state_reference::StateReference, + traits::{Deserialize, Empty, Hash, Serialize}, + utils::arr_copy_slice, }; // docs:start:header diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/indexed_tree.nr b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/indexed_tree.nr index aa44d2c84f5..1a12382093b 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/indexed_tree.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/indexed_tree.nr @@ -4,8 +4,10 @@ use crate::{ abis::append_only_tree_snapshot::AppendOnlyTreeSnapshot, merkle_tree::{ membership::{assert_check_membership, MembershipWitness}, - root::{calculate_subtree_root, calculate_empty_tree_root, root_from_sibling_path}, - }, traits::{Empty, Hash, is_empty}, utils::arrays::check_permutation, + root::{calculate_empty_tree_root, calculate_subtree_root, root_from_sibling_path}, + }, + traits::{Empty, Hash, is_empty}, + utils::arrays::check_permutation, }; pub fn batch_insert( diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/indexed_tree/check_valid_low_leaf.nr b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/indexed_tree/check_valid_low_leaf.nr index f7f625ce836..6c454c5f583 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/indexed_tree/check_valid_low_leaf.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/indexed_tree/check_valid_low_leaf.nr @@ -13,8 +13,8 @@ where mod tests { use crate::merkle_tree::{ - leaf_preimage::IndexedTreeLeafPreimage, indexed_tree::check_valid_low_leaf::assert_check_valid_low_leaf, + leaf_preimage::IndexedTreeLeafPreimage, }; struct TestLeafPreimage { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/membership.nr b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/membership.nr index 62a4ac53bc5..1d3815dde9a 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/membership.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/membership.nr @@ -1,9 +1,9 @@ use crate::{ merkle_tree::{ - leaf_preimage::IndexedTreeLeafPreimage, indexed_tree::check_valid_low_leaf::assert_check_valid_low_leaf, - root::root_from_sibling_path, - }, traits::Empty, + leaf_preimage::IndexedTreeLeafPreimage, root::root_from_sibling_path, + }, + traits::Empty, }; pub struct MembershipWitness { @@ -90,7 +90,8 @@ mod tests { assert_check_membership, assert_check_non_membership, check_membership, conditionally_assert_check_membership, MembershipWitness, }, - }, tests::merkle_tree_utils::NonEmptyMerkleTree, + }, + tests::merkle_tree_utils::NonEmptyMerkleTree, }; use std::hash::pedersen_hash; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/merkle_tree.nr b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/merkle_tree.nr index 697d841d82b..f1d52918883 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/merkle_tree.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/merkle_tree.nr @@ -1,4 +1,4 @@ -use crate::{traits::Empty, hash::merkle_hash}; +use crate::{hash::merkle_hash, traits::Empty}; pub struct MerkleTree { leaves: [Field; N], diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/mod.nr b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/mod.nr index 5c306bbc575..e3afdddb7f1 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/mod.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/mod.nr @@ -12,5 +12,5 @@ pub use membership::{ conditionally_assert_check_membership, MembershipWitness, }; pub use merkle_tree::MerkleTree; -pub use variable_merkle_tree::VariableMerkleTree; pub use root::{calculate_empty_tree_root, calculate_subtree_root, root_from_sibling_path}; +pub use variable_merkle_tree::VariableMerkleTree; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/variable_merkle_tree.nr b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/variable_merkle_tree.nr index 483670f475b..aec8dbe1cdb 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/variable_merkle_tree.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/variable_merkle_tree.nr @@ -91,8 +91,8 @@ impl VariableMerkleTree { mod tests { use crate::{ - merkle_tree::{variable_merkle_tree::VariableMerkleTree, merkle_tree::MerkleTree}, hash::accumulate_sha256, + merkle_tree::{merkle_tree::MerkleTree, variable_merkle_tree::VariableMerkleTree}, }; fn generate_test_array(non_empty_items: u32) -> [Field; 100] { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/messaging/l2_to_l1_message.nr b/noir-projects/noir-protocol-circuits/crates/types/src/messaging/l2_to_l1_message.nr index 0ff95b3e140..b3de63f26b0 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/messaging/l2_to_l1_message.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/messaging/l2_to_l1_message.nr @@ -1,7 +1,8 @@ use crate::{ + abis::side_effect::{Ordered, Scoped}, address::{AztecAddress, EthAddress}, constants::{L2_TO_L1_MESSAGE_LENGTH, SCOPED_L2_TO_L1_MESSAGE_LENGTH}, - abis::side_effect::{Ordered, Scoped}, traits::{Deserialize, Empty, Serialize}, + traits::{Deserialize, Empty, Serialize}, utils::{arrays::array_concat, reader::Reader}, }; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/meta/mod.nr b/noir-projects/noir-protocol-circuits/crates/types/src/meta/mod.nr index d56ef6d87ee..23de9e52177 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/meta/mod.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/meta/mod.nr @@ -1,4 +1,4 @@ -use super::traits::{Serialize, Deserialize}; +use super::traits::{Deserialize, Serialize}; pub comptime fn pack_from_fields( name: Quoted, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/partial_state_reference.nr b/noir-projects/noir-protocol-circuits/crates/types/src/partial_state_reference.nr index 0384aa58b94..b85b9b3e328 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/partial_state_reference.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/partial_state_reference.nr @@ -1,6 +1,7 @@ use crate::{ abis::append_only_tree_snapshot::AppendOnlyTreeSnapshot, - constants::PARTIAL_STATE_REFERENCE_LENGTH, traits::{Deserialize, Empty, Serialize}, + constants::PARTIAL_STATE_REFERENCE_LENGTH, + traits::{Deserialize, Empty, Serialize}, }; pub struct PartialStateReference { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/point.nr b/noir-projects/noir-protocol-circuits/crates/types/src/point.nr index 5de69793449..62a9212a7c9 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/point.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/point.nr @@ -1,5 +1,5 @@ pub use dep::std::embedded_curve_ops::EmbeddedCurvePoint as Point; -use crate::{traits::{Deserialize, Empty, Hash, Serialize}, hash::poseidon2_hash}; +use crate::{hash::poseidon2_hash, traits::{Deserialize, Empty, Hash, Serialize}}; global POINT_LENGTH: u32 = 3; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/public_keys.nr b/noir-projects/noir-protocol-circuits/crates/types/src/public_keys.nr index 65bb1defab9..94fae081b85 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/public_keys.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/public_keys.nr @@ -1,16 +1,18 @@ use crate::{ address::public_keys_hash::PublicKeysHash, constants::{ - GENERATOR_INDEX__PUBLIC_KEYS_HASH, DEFAULT_NPK_M_X, DEFAULT_NPK_M_Y, DEFAULT_IVPK_M_X, - DEFAULT_IVPK_M_Y, DEFAULT_OVPK_M_X, DEFAULT_OVPK_M_Y, DEFAULT_TPK_M_X, DEFAULT_TPK_M_Y, - }, hash::poseidon2_hash_with_separator, point::POINT_LENGTH, - traits::{Deserialize, Serialize, Hash}, + DEFAULT_IVPK_M_X, DEFAULT_IVPK_M_Y, DEFAULT_NPK_M_X, DEFAULT_NPK_M_Y, DEFAULT_OVPK_M_X, + DEFAULT_OVPK_M_Y, DEFAULT_TPK_M_X, DEFAULT_TPK_M_Y, GENERATOR_INDEX__PUBLIC_KEYS_HASH, + }, + hash::poseidon2_hash_with_separator, + point::POINT_LENGTH, + traits::{Deserialize, Hash, Serialize}, }; use dep::std::embedded_curve_ops::EmbeddedCurvePoint as Point; use dep::std::embedded_curve_ops::fixed_base_scalar_mul as derive_public_key; -use std::embedded_curve_ops::EmbeddedCurveScalar; use std::default::Default; +use std::embedded_curve_ops::EmbeddedCurveScalar; pub global PUBLIC_KEYS_LENGTH: u32 = 12; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/recursion/proof.nr b/noir-projects/noir-protocol-circuits/crates/types/src/recursion/proof.nr index 4ebd589b4f0..2dafd8391d2 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/recursion/proof.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/recursion/proof.nr @@ -1,6 +1,6 @@ use crate::{ - traits::{Serialize, Deserialize, Empty}, - constants::{RECURSIVE_PROOF_LENGTH, NESTED_RECURSIVE_PROOF_LENGTH}, + constants::{NESTED_RECURSIVE_PROOF_LENGTH, RECURSIVE_PROOF_LENGTH}, + traits::{Deserialize, Empty, Serialize}, }; pub struct RecursiveProof { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/recursion/verification_key.nr b/noir-projects/noir-protocol-circuits/crates/types/src/recursion/verification_key.nr index 20d958d5dc3..a11b7852902 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/recursion/verification_key.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/recursion/verification_key.nr @@ -1,8 +1,8 @@ use crate::{ - traits::{Serialize, Deserialize, Empty}, constants::{ - HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS, CLIENT_IVC_VERIFICATION_KEY_LENGTH_IN_FIELDS, + CLIENT_IVC_VERIFICATION_KEY_LENGTH_IN_FIELDS, HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS, }, + traits::{Deserialize, Empty, Serialize}, }; pub struct VerificationKey { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/state_reference.nr b/noir-projects/noir-protocol-circuits/crates/types/src/state_reference.nr index 1bc4110d32f..c2ac4b58123 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/state_reference.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/state_reference.nr @@ -1,7 +1,8 @@ use crate::{ - abis::append_only_tree_snapshot::{AppendOnlyTreeSnapshot, APPEND_ONLY_TREE_SNAPSHOT_LENGTH}, + abis::append_only_tree_snapshot::{APPEND_ONLY_TREE_SNAPSHOT_LENGTH, AppendOnlyTreeSnapshot}, constants::{PARTIAL_STATE_REFERENCE_LENGTH, STATE_REFERENCE_LENGTH}, - partial_state_reference::PartialStateReference, traits::{Deserialize, Empty, Serialize}, + partial_state_reference::PartialStateReference, + traits::{Deserialize, Empty, Serialize}, utils::arr_copy_slice, }; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixture_builder.nr b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixture_builder.nr index ad244b94ba5..3b121da821c 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixture_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixture_builder.nr @@ -1,67 +1,85 @@ use crate::{ abis::{ - gas::Gas, gas_settings::GasSettings, call_context::CallContext, accumulated_data::{ CombinedAccumulatedData, PrivateAccumulatedData, PrivateAccumulatedDataBuilder, PublicAccumulatedData, PublicAccumulatedDataArrayLengths, PublicAccumulatedDataBuilder, - }, function_data::FunctionData, function_selector::FunctionSelector, - global_variables::GlobalVariables, combined_constant_data::CombinedConstantData, + }, + call_context::CallContext, + combined_constant_data::CombinedConstantData, enqueued_call_data::{EnqueuedCallData, Proof}, + function_data::FunctionData, + function_selector::FunctionSelector, + gas::Gas, + gas_settings::GasSettings, + global_variables::GlobalVariables, kernel_circuit_public_inputs::{ KernelCircuitPublicInputs, PrivateKernelCircuitPublicInputs, PublicKernelCircuitPublicInputs, VMCircuitPublicInputs, - }, kernel_data::KernelData, public_kernel_data::PublicKernelData, - max_block_number::MaxBlockNumber, private_kernel_data::PrivateKernelData, - note_hash::{NoteHash, ScopedNoteHash}, nullifier::{Nullifier, ScopedNullifier}, + }, + kernel_data::KernelData, + log_hash::{EncryptedLogHash, LogHash, NoteLogHash, ScopedEncryptedLogHash, ScopedLogHash}, + max_block_number::MaxBlockNumber, + note_hash::{NoteHash, ScopedNoteHash}, + nullifier::{Nullifier, ScopedNullifier}, private_call_request::PrivateCallRequest, private_circuit_public_inputs::PrivateCircuitPublicInputs, private_kernel::private_call_data::PrivateCallData, + private_kernel_data::PrivateKernelData, public_call_data::{Proof as PublicCallDataProof, PublicCallData}, public_call_request::PublicCallRequest, - public_circuit_public_inputs::PublicCircuitPublicInputs, public_data_read::PublicDataRead, + public_circuit_public_inputs::PublicCircuitPublicInputs, + public_data_read::PublicDataRead, public_data_update_request::PublicDataUpdateRequest, public_inner_call_request::PublicInnerCallRequest, - read_request::{ReadRequest, ScopedReadRequest}, tree_leaf_read_request::TreeLeafReadRequest, - log_hash::{LogHash, NoteLogHash, ScopedLogHash, EncryptedLogHash, ScopedEncryptedLogHash}, + public_kernel_data::PublicKernelData, + read_request::{ReadRequest, ScopedReadRequest}, + tree_leaf_read_request::TreeLeafReadRequest, validation_requests::{ KeyValidationRequest, KeyValidationRequestAndGenerator, PrivateValidationRequests, - PublicValidationRequests, PublicValidationRequestArrayLengths, RollupValidationRequests, + PublicValidationRequestArrayLengths, PublicValidationRequests, RollupValidationRequests, ScopedKeyValidationRequestAndGenerator, }, - }, address::{AztecAddress, EthAddress, SaltedInitializationHash, PublicKeysHash}, - public_keys::PublicKeys, + }, + address::{AztecAddress, EthAddress, PublicKeysHash, SaltedInitializationHash}, constants::{ - FUNCTION_TREE_HEIGHT, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, - MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, - MAX_PUBLIC_DATA_READS_PER_CALL, MAX_PUBLIC_DATA_READS_PER_TX, - MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, - MAX_FIELD_VALUE, MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, - MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX, - MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX, MAX_KEY_VALIDATION_REQUESTS_PER_TX, - VK_TREE_HEIGHT, MAX_ENCRYPTED_LOGS_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX, - MAX_NOTE_ENCRYPTED_LOGS_PER_TX, PRIVATE_CALL_REQUEST_LENGTH, PROTOCOL_CONTRACT_TREE_HEIGHT, - PUBLIC_CALL_REQUEST_LENGTH, - }, contrakt::{storage_read::StorageRead, storage_update_request::StorageUpdateRequest}, + FUNCTION_TREE_HEIGHT, MAX_ENCRYPTED_LOGS_PER_TX, MAX_FIELD_VALUE, + MAX_KEY_VALIDATION_REQUESTS_PER_TX, MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX, + MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, + MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NOTE_HASHES_PER_TX, + MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX, + MAX_NULLIFIERS_PER_TX, MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, + MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, MAX_PUBLIC_DATA_READS_PER_CALL, + MAX_PUBLIC_DATA_READS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX, + PRIVATE_CALL_REQUEST_LENGTH, PROTOCOL_CONTRACT_TREE_HEIGHT, PUBLIC_CALL_REQUEST_LENGTH, + VK_TREE_HEIGHT, + }, + contrakt::{storage_read::StorageRead, storage_update_request::StorageUpdateRequest}, hash::{ - compute_l2_to_l1_hash, compute_tx_logs_hash, compute_siloed_nullifier, silo_note_hash, - silo_unencrypted_log_hash, mask_encrypted_log_hash, - }, header::Header, merkle_tree::{membership::MembershipWitness, MerkleTree}, + compute_l2_to_l1_hash, compute_siloed_nullifier, compute_tx_logs_hash, + mask_encrypted_log_hash, silo_note_hash, silo_unencrypted_log_hash, + }, + header::Header, + merkle_tree::{membership::MembershipWitness, MerkleTree}, messaging::l2_to_l1_message::{L2ToL1Message, ScopedL2ToL1Message}, partial_state_reference::PartialStateReference, - tests::{ - fixtures, - fixtures::{ - contracts::ContractData, contract_functions::ContractFunction, - vk_tree::{ - generate_fake_honk_vk_for_index, generate_fake_client_ivc_vk_for_index, - get_vk_merkle_tree, VK_TREE_WIDTH, - }, - }, - }, transaction::{tx_context::TxContext, tx_request::TxRequest}, traits::Empty, + point::Point, + public_keys::PublicKeys, recursion::{ - verification_key::{HonkVerificationKey, ClientIVCVerificationKey, VerificationKey}, proof::NestedRecursiveProof, - }, point::Point, + verification_key::{ClientIVCVerificationKey, HonkVerificationKey, VerificationKey}, + }, + tests::fixtures::{ + self, + contract_functions::ContractFunction, + contracts::ContractData, + vk_tree::{ + generate_fake_client_ivc_vk_for_index, generate_fake_honk_vk_for_index, + get_vk_merkle_tree, VK_TREE_WIDTH, + }, + }, + traits::Empty, + transaction::{tx_context::TxContext, tx_request::TxRequest}, }; fn subarray(arr: [T; N]) -> [T; M] { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/contract_functions.nr b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/contract_functions.nr index 3ec6eed50a9..ffecfd4ef69 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/contract_functions.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/contract_functions.nr @@ -1,6 +1,6 @@ use crate::abis::{function_data::FunctionData, function_selector::FunctionSelector}; -use crate::merkle_tree::membership::MembershipWitness; use crate::constants::FUNCTION_TREE_HEIGHT; +use crate::merkle_tree::membership::MembershipWitness; pub struct ContractFunction { data: FunctionData, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/contracts.nr b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/contracts.nr index c854adeec7f..837e2403652 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/contracts.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/contracts.nr @@ -1,7 +1,9 @@ use crate::{ - address::{AztecAddress, PublicKeysHash, SaltedInitializationHash, PartialAddress}, - contract_class_id::ContractClassId, hash::private_functions_root_from_siblings, - tests::fixtures::contract_functions::get_protocol_contract_function, public_keys::PublicKeys, + address::{AztecAddress, PartialAddress, PublicKeysHash, SaltedInitializationHash}, + contract_class_id::ContractClassId, + hash::private_functions_root_from_siblings, + public_keys::PublicKeys, + tests::fixtures::contract_functions::get_protocol_contract_function, }; pub struct ContractData { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/vk_tree.nr b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/vk_tree.nr index e3a9a8b6d62..5513d6d9f24 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/vk_tree.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixtures/vk_tree.nr @@ -1,15 +1,15 @@ use crate::constants::{ - VK_TREE_HEIGHT, PRIVATE_KERNEL_INIT_INDEX, PRIVATE_KERNEL_INNER_INDEX, - PRIVATE_KERNEL_RESET_INDEX, PRIVATE_KERNEL_TAIL_INDEX, PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX, - EMPTY_NESTED_INDEX, PRIVATE_KERNEL_EMPTY_INDEX, PUBLIC_KERNEL_INNER_INDEX, - PUBLIC_KERNEL_MERGE_INDEX, PUBLIC_KERNEL_TAIL_INDEX, BASE_PARITY_INDEX, ROOT_PARITY_INDEX, - BASE_ROLLUP_INDEX, MERGE_ROLLUP_INDEX, BLOCK_ROOT_ROLLUP_INDEX, BLOCK_MERGE_ROLLUP_INDEX, - ROOT_ROLLUP_INDEX, BLOCK_ROOT_ROLLUP_EMPTY_INDEX, HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS, - CLIENT_IVC_VERIFICATION_KEY_LENGTH_IN_FIELDS, + BASE_PARITY_INDEX, BASE_ROLLUP_INDEX, BLOCK_MERGE_ROLLUP_INDEX, BLOCK_ROOT_ROLLUP_EMPTY_INDEX, + BLOCK_ROOT_ROLLUP_INDEX, CLIENT_IVC_VERIFICATION_KEY_LENGTH_IN_FIELDS, EMPTY_NESTED_INDEX, + HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS, MERGE_ROLLUP_INDEX, PRIVATE_KERNEL_EMPTY_INDEX, + PRIVATE_KERNEL_INIT_INDEX, PRIVATE_KERNEL_INNER_INDEX, PRIVATE_KERNEL_RESET_INDEX, + PRIVATE_KERNEL_TAIL_INDEX, PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX, PUBLIC_KERNEL_INNER_INDEX, + PUBLIC_KERNEL_MERGE_INDEX, PUBLIC_KERNEL_TAIL_INDEX, ROOT_PARITY_INDEX, ROOT_ROLLUP_INDEX, + VK_TREE_HEIGHT, }; +use crate::hash::verification_key_hash; use crate::merkle_tree::merkle_tree::MerkleTree; use crate::recursion::verification_key::VerificationKey; -use crate::hash::verification_key_hash; pub global VK_TREE_WIDTH: u32 = (1 as u8 << VK_TREE_HEIGHT as u8) as u32; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/tests/merkle_tree_utils.nr b/noir-projects/noir-protocol-circuits/crates/types/src/tests/merkle_tree_utils.nr index e7cfbd7566d..b4ff548be02 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/tests/merkle_tree_utils.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/tests/merkle_tree_utils.nr @@ -1,6 +1,7 @@ use crate::{ - merkle_tree::{merkle_tree, MerkleTree, calculate_empty_tree_root}, traits::Empty, hash::merkle_hash, + merkle_tree::{calculate_empty_tree_root, merkle_tree, MerkleTree}, + traits::Empty, }; pub fn compute_zero_hashes(mut hashes: [Field; N]) -> [Field; N] { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/traits.nr b/noir-projects/noir-protocol-circuits/crates/types/src/traits.nr index 614388f5259..4034448eda5 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/traits.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/traits.nr @@ -1,5 +1,5 @@ -use crate::utils::field::field_from_bytes; use crate::meta::{derive_deserialize, derive_serialize}; +use crate::utils::field::field_from_bytes; // Trait: is_empty // diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/transaction/tx_context.nr b/noir-projects/noir-protocol-circuits/crates/types/src/transaction/tx_context.nr index f7cf4faef7a..25de53247cf 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/transaction/tx_context.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/transaction/tx_context.nr @@ -1,6 +1,8 @@ use crate::{ - constants::TX_CONTEXT_LENGTH, traits::{Deserialize, Serialize, Empty}, utils::reader::Reader, abis::gas_settings::GasSettings, + constants::TX_CONTEXT_LENGTH, + traits::{Deserialize, Empty, Serialize}, + utils::reader::Reader, }; // docs:start:tx-context diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/transaction/tx_request.nr b/noir-projects/noir-protocol-circuits/crates/types/src/transaction/tx_request.nr index fb367b28111..e8f743548db 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/transaction/tx_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/transaction/tx_request.nr @@ -1,8 +1,11 @@ use crate::{ - address::AztecAddress, abis::function_data::FunctionData, + abis::function_data::FunctionData, + address::AztecAddress, constants::{GENERATOR_INDEX__TX_REQUEST, TX_REQUEST_LENGTH}, - hash::poseidon2_hash_with_separator, traits::{Hash, Serialize, Deserialize, Empty}, - transaction::tx_context::TxContext, utils::reader::Reader, + hash::poseidon2_hash_with_separator, + traits::{Deserialize, Empty, Hash, Serialize}, + transaction::tx_context::TxContext, + utils::reader::Reader, }; pub struct TxRequest { @@ -73,9 +76,11 @@ impl Deserialize for TxRequest { mod tests { use crate::{ abis::{ - function_selector::FunctionSelector, function_data::FunctionData, - gas_settings::GasSettings, gas::Gas, gas_fees::GasFees, - }, address::AztecAddress, transaction::{tx_request::TxRequest, tx_context::TxContext}, + function_data::FunctionData, function_selector::FunctionSelector, gas::Gas, + gas_fees::GasFees, gas_settings::GasSettings, + }, + address::AztecAddress, + transaction::{tx_context::TxContext, tx_request::TxRequest}, }; #[test] diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/type_serialization.nr b/noir-projects/noir-protocol-circuits/crates/types/src/type_serialization.nr index 953ab67b50d..a509d6b9eef 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/type_serialization.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/type_serialization.nr @@ -1,4 +1,4 @@ -use crate::traits::{Serialize, Deserialize}; +use crate::traits::{Deserialize, Serialize}; global BOOL_SERIALIZED_LEN: u32 = 1; global U8_SERIALIZED_LEN: u32 = 1; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays.nr index 52456a02286..6e6f28f3307 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays.nr @@ -27,20 +27,20 @@ pub use assert_combined_sorted_transformed_value_array::{ pub use assert_combined_transformed_array::{ assert_combined_transformed_array, combine_and_transform_arrays, }; +pub use assert_deduped_array::{assert_deduped_array, dedupe_array}; pub use assert_exposed_sorted_transformed_value_array::{ assert_exposed_sorted_transformed_value_array, get_order_hints::{get_order_hints_asc, get_order_hints_desc, OrderHint}, }; -pub use assert_deduped_array::{assert_deduped_array, dedupe_array}; pub use assert_sorted_array::assert_sorted_array; +pub use assert_sorted_transformed_value_array::{ + assert_sorted_transformed_value_array, assert_sorted_transformed_value_array_capped_size, +}; pub use assert_split_sorted_transformed_value_arrays::{ assert_split_sorted_transformed_value_arrays_asc, assert_split_sorted_transformed_value_arrays_desc, get_split_order_hints::{get_split_order_hints_asc, get_split_order_hints_desc, SplitOrderHints}, }; -pub use assert_sorted_transformed_value_array::{ - assert_sorted_transformed_value_array, assert_sorted_transformed_value_array_capped_size, -}; pub use assert_split_transformed_value_arrays::assert_split_transformed_value_arrays; pub use get_sorted_result::{get_sorted_result, SortedResult}; pub use sort_by_counter::{sort_by_counter_asc, sort_by_counter_desc}; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_array_appended.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_array_appended.nr index 1377ada4486..8142b69c430 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_array_appended.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_array_appended.nr @@ -1,5 +1,7 @@ use crate::{ - abis::side_effect::Scoped, address::aztec_address::AztecAddress, traits::{Empty, is_empty}, + abis::side_effect::Scoped, + address::aztec_address::AztecAddress, + traits::{Empty, is_empty}, }; pub fn assert_array_appended( diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_combined_sorted_transformed_value_array.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_combined_sorted_transformed_value_array.nr index a79a826af90..cac15101a86 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_combined_sorted_transformed_value_array.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_combined_sorted_transformed_value_array.nr @@ -1,7 +1,8 @@ mod get_combined_order_hints; use crate::{ - abis::side_effect::Ordered, traits::{Empty, is_empty}, + abis::side_effect::Ordered, + traits::{Empty, is_empty}, utils::arrays::{ array_length, assert_combined_sorted_transformed_value_array::get_combined_order_hints::{ @@ -97,16 +98,19 @@ where mod tests { use crate::{ - tests::utils::pad_end, - tests::types::{ - combine_two_values, is_combined_from_two_values, TestCombinedValue, TestTwoValues, + tests::{ + types::{ + combine_two_values, is_combined_from_two_values, TestCombinedValue, TestTwoValues, + }, + utils::pad_end, }, utils::arrays::{ array_merge, assert_combined_sorted_transformed_value_array::{ assert_combined_sorted_transformed_value_array_asc, get_combined_order_hints::{CombinedOrderHint, get_combined_order_hints_asc}, - }, sort_by_counter::sort_by_counter_asc, + }, + sort_by_counter::sort_by_counter_asc, }, }; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_combined_sorted_transformed_value_array/get_combined_order_hints.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_combined_sorted_transformed_value_array/get_combined_order_hints.nr index 548362fb9df..ac62b93bd14 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_combined_sorted_transformed_value_array/get_combined_order_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_combined_sorted_transformed_value_array/get_combined_order_hints.nr @@ -1,8 +1,9 @@ use crate::{ - abis::side_effect::Ordered, traits::{Empty, is_empty}, + abis::side_effect::Ordered, + traits::{Empty, is_empty}, utils::arrays::{ - array_length, sort_by_counter::compare_by_counter_empty_padded_asc, - get_sorted_tuple::get_sorted_tuple, + array_length, get_sorted_tuple::get_sorted_tuple, + sort_by_counter::compare_by_counter_empty_padded_asc, }, }; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_deduped_array.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_deduped_array.nr index 17460434e88..af7e9c4bdac 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_deduped_array.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_deduped_array.nr @@ -39,8 +39,10 @@ where mod tests { use crate::{ - abis::side_effect::{Inner, Overridable}, tests::{types::TestValue, utils::pad_end}, - traits::Empty, utils::arrays::assert_deduped_array::{assert_deduped_array, dedupe_array}, + abis::side_effect::{Inner, Overridable}, + tests::{types::TestValue, utils::pad_end}, + traits::Empty, + utils::arrays::assert_deduped_array::{assert_deduped_array, dedupe_array}, }; struct TestItem { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_exposed_sorted_transformed_value_array.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_exposed_sorted_transformed_value_array.nr index 40f0072676e..eba9fe575a2 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_exposed_sorted_transformed_value_array.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_exposed_sorted_transformed_value_array.nr @@ -1,7 +1,8 @@ mod get_order_hints; use crate::{ - abis::side_effect::Ordered, traits::{Empty, is_empty}, + abis::side_effect::Ordered, + traits::{Empty, is_empty}, utils::arrays::{ array_length, assert_exposed_sorted_transformed_value_array::get_order_hints::OrderHint, }, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_exposed_sorted_transformed_value_array/get_order_hints.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_exposed_sorted_transformed_value_array/get_order_hints.nr index eb2f3c4827c..145df154174 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_exposed_sorted_transformed_value_array/get_order_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_exposed_sorted_transformed_value_array/get_order_hints.nr @@ -1,9 +1,11 @@ use crate::{ - abis::side_effect::Ordered, traits::Empty, + abis::side_effect::Ordered, + traits::Empty, utils::arrays::{ + get_sorted_tuple::get_sorted_tuple, sort_by_counter::{ compare_by_counter_empty_padded_asc, compare_by_counter_empty_padded_desc, - }, get_sorted_tuple::get_sorted_tuple, + }, }, }; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_split_sorted_transformed_value_arrays.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_split_sorted_transformed_value_arrays.nr index d5d058e54ea..36cc3b3d07c 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_split_sorted_transformed_value_arrays.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_split_sorted_transformed_value_arrays.nr @@ -1,7 +1,8 @@ mod get_split_order_hints; use crate::{ - abis::side_effect::Ordered, traits::Empty, + abis::side_effect::Ordered, + traits::Empty, utils::arrays::{ array_length, assert_split_sorted_transformed_value_arrays::get_split_order_hints::SplitOrderHints, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_split_sorted_transformed_value_arrays/get_split_order_hints.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_split_sorted_transformed_value_arrays/get_split_order_hints.nr index ebb47835188..2a330cc2fe2 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_split_sorted_transformed_value_arrays/get_split_order_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_split_sorted_transformed_value_arrays/get_split_order_hints.nr @@ -1,9 +1,11 @@ use crate::{ - abis::side_effect::Ordered, traits::{Empty, is_empty}, + abis::side_effect::Ordered, + traits::{Empty, is_empty}, utils::arrays::{ + get_sorted_tuple::get_sorted_tuple, sort_by_counter::{ compare_by_counter_empty_padded_asc, compare_by_counter_empty_padded_desc, - }, get_sorted_tuple::get_sorted_tuple, + }, }, }; diff --git a/noir/noir-repo/compiler/noirc_frontend/src/ast/statement.rs b/noir/noir-repo/compiler/noirc_frontend/src/ast/statement.rs index 441eff99d9e..038a7b76bac 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/ast/statement.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/ast/statement.rs @@ -373,7 +373,9 @@ impl UseTree { match self.kind { UseTreeKind::Path(name, alias) => { - vec![ImportStatement { visibility, path: prefix.join(name), alias }] + // Desugar `use foo::{self}` to `use foo` + let path = if name.0.contents == "self" { prefix } else { prefix.join(name) }; + vec![ImportStatement { visibility, path, alias }] } UseTreeKind::List(trees) => { let trees = trees.into_iter(); diff --git a/noir/noir-repo/compiler/noirc_frontend/src/elaborator/lints.rs b/noir/noir-repo/compiler/noirc_frontend/src/elaborator/lints.rs index c0a18d219b7..57db2359772 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/elaborator/lints.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/elaborator/lints.rs @@ -6,11 +6,13 @@ use crate::{ type_check::TypeCheckError, }, hir_def::{ - expr::{HirExpression, HirIdent, HirLiteral}, + expr::{HirBlockExpression, HirExpression, HirIdent, HirLiteral}, function::FuncMeta, + stmt::HirStatement, + }, + node_interner::{ + DefinitionId, DefinitionKind, ExprId, FuncId, FunctionModifiers, NodeInterner, }, - node_interner::NodeInterner, - node_interner::{DefinitionKind, ExprId, FuncId, FunctionModifiers}, Type, }; @@ -264,3 +266,77 @@ pub(crate) fn overflowing_int( fn func_meta_name_ident(func: &FuncMeta, modifiers: &FunctionModifiers) -> Ident { Ident(Spanned::from(func.name.location.span, modifiers.name.clone())) } + +/// Check that a recursive function *can* return without endlessly calling itself. +pub(crate) fn unbounded_recursion<'a>( + interner: &'a NodeInterner, + func_id: FuncId, + func_name: impl FnOnce() -> &'a str, + func_span: Span, + body_id: ExprId, +) -> Option { + if !can_return_without_recursing(interner, func_id, body_id) { + Some(ResolverError::UnconditionalRecursion { + name: func_name().to_string(), + span: func_span, + }) + } else { + None + } +} + +/// Check if an expression will end up calling a specific function. +fn can_return_without_recursing(interner: &NodeInterner, func_id: FuncId, expr_id: ExprId) -> bool { + let check = |e| can_return_without_recursing(interner, func_id, e); + + let check_block = |block: HirBlockExpression| { + block.statements.iter().all(|stmt_id| match interner.statement(stmt_id) { + HirStatement::Let(s) => check(s.expression), + HirStatement::Assign(s) => check(s.expression), + HirStatement::Expression(e) => check(e), + HirStatement::Semi(e) => check(e), + // Rust doesn't seem to check the for loop body (it's bounds might mean it's never called). + HirStatement::For(e) => check(e.start_range) && check(e.end_range), + HirStatement::Constrain(_) + | HirStatement::Comptime(_) + | HirStatement::Break + | HirStatement::Continue + | HirStatement::Error => true, + }) + }; + + match interner.expression(&expr_id) { + HirExpression::Ident(ident, _) => { + if ident.id == DefinitionId::dummy_id() { + return true; + } + let definition = interner.definition(ident.id); + if let DefinitionKind::Function(id) = definition.kind { + func_id != id + } else { + true + } + } + HirExpression::Block(b) => check_block(b), + HirExpression::Prefix(e) => check(e.rhs), + HirExpression::Infix(e) => check(e.lhs) && check(e.rhs), + HirExpression::Index(e) => check(e.collection) && check(e.index), + HirExpression::MemberAccess(e) => check(e.lhs), + HirExpression::Call(e) => check(e.func) && e.arguments.iter().cloned().all(check), + HirExpression::MethodCall(e) => check(e.object) && e.arguments.iter().cloned().all(check), + HirExpression::Cast(e) => check(e.lhs), + HirExpression::If(e) => { + check(e.condition) && (check(e.consequence) || e.alternative.map(check).unwrap_or(true)) + } + HirExpression::Tuple(e) => e.iter().cloned().all(check), + HirExpression::Unsafe(b) => check_block(b), + // Rust doesn't check the lambda body (it might not be called). + HirExpression::Lambda(_) + | HirExpression::Literal(_) + | HirExpression::Constructor(_) + | HirExpression::Quote(_) + | HirExpression::Unquote(_) + | HirExpression::Comptime(_) + | HirExpression::Error => true, + } +} diff --git a/noir/noir-repo/compiler/noirc_frontend/src/elaborator/mod.rs b/noir/noir-repo/compiler/noirc_frontend/src/elaborator/mod.rs index aef0771c486..641e2d1d57e 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/elaborator/mod.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/elaborator/mod.rs @@ -470,6 +470,20 @@ impl<'context> Elaborator<'context> { self.check_for_unused_variables_in_scope_tree(func_scope_tree); } + // Check that the body can return without calling the function. + if let FunctionKind::Normal | FunctionKind::Recursive = kind { + self.run_lint(|elaborator| { + lints::unbounded_recursion( + elaborator.interner, + id, + || elaborator.interner.definition_name(func_meta.name.id), + func_meta.name.location.span, + hir_func.as_expr(), + ) + .map(Into::into) + }); + } + let meta = self .interner .func_meta diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/errors.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/errors.rs index 4f9907d6a16..3c4022b58bb 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/errors.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/resolution/errors.rs @@ -29,6 +29,8 @@ pub enum ResolverError { UnusedVariable { ident: Ident }, #[error("Unused {}", item.item_type())] UnusedItem { ident: Ident, item: UnusedItem }, + #[error("Unconditional recursion")] + UnconditionalRecursion { name: String, span: Span }, #[error("Could not find variable in this scope")] VariableNotDeclared { name: String, span: Span }, #[error("path is not an identifier")] @@ -213,6 +215,15 @@ impl<'a> From<&'a ResolverError> for Diagnostic { diagnostic.unnecessary = true; diagnostic } + ResolverError::UnconditionalRecursion { name, span} => { + let mut diagnostic = Diagnostic::simple_warning( + format!("function `{name}` cannot return without recursing"), + "function cannot return without recursing".to_string(), + *span, + ); + diagnostic.unnecessary = true; + diagnostic + } ResolverError::VariableNotDeclared { name, span } => Diagnostic::simple_error( format!("cannot find `{name}` in this scope "), "not found in this scope".to_string(), diff --git a/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/global.rs b/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/global.rs index d24064673b1..5ece510022a 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/global.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/global.rs @@ -59,7 +59,8 @@ impl<'a> Parser<'a> { fn ident_to_pattern(ident: Ident, mutable: bool) -> Pattern { if mutable { - Pattern::Mutable(Box::new(Pattern::Identifier(ident)), Span::default(), false) + let span = ident.span(); + Pattern::Mutable(Box::new(Pattern::Identifier(ident)), span, false) } else { Pattern::Identifier(ident) } @@ -140,6 +141,8 @@ mod tests { panic!("Expected identifier pattern"); }; assert_eq!("foo", name.to_string()); + assert_eq!(pattern.span().start(), 11); + assert_eq!(pattern.span().end(), 14); } #[test] diff --git a/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/use_tree.rs b/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/use_tree.rs index 1c43732c94f..bc95c04d46b 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/use_tree.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/use_tree.rs @@ -66,6 +66,14 @@ impl<'a> Parser<'a> { fn parse_use_tree_in_list(&mut self) -> Option { let start_span = self.current_token_span; + // Special case: "self" cannot be followed by anything else + if self.eat_self() { + return Some(UseTree { + prefix: Path { segments: Vec::new(), kind: PathKind::Plain, span: start_span }, + kind: UseTreeKind::Path(Ident::new("self".to_string(), start_span), None), + }); + } + let use_tree = self.parse_use_tree_without_kind( start_span, PathKind::Plain, @@ -250,4 +258,11 @@ mod tests { let (_, errors) = parse_program(src); assert!(!errors.is_empty()); } + + #[test] + fn errors_on_double_colon_after_self() { + let src = "use foo::{self::bar};"; + let (_, errors) = parse_program(src); + assert!(!errors.is_empty()); + } } diff --git a/noir/noir-repo/compiler/noirc_frontend/src/tests.rs b/noir/noir-repo/compiler/noirc_frontend/src/tests.rs index 17acd17dcc9..ce4ad4d1bb9 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/tests.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/tests.rs @@ -122,7 +122,7 @@ pub(crate) fn get_program_errors(src: &str) -> Vec<(CompilationError, FileId)> { fn assert_no_errors(src: &str) { let errors = get_program_errors(src); if !errors.is_empty() { - panic!("Expected no errors, got: {:?}", errors); + panic!("Expected no errors, got: {:?}; src = {src}", errors); } } @@ -3389,3 +3389,155 @@ fn arithmetic_generics_rounding_fail() { let errors = get_program_errors(src); assert_eq!(errors.len(), 1); } + +#[test] +fn unconditional_recursion_fail() { + let srcs = vec![ + r#" + fn main() { + main() + } + "#, + r#" + fn main() -> pub bool { + if main() { true } else { false } + } + "#, + r#" + fn main() -> pub bool { + if true { main() } else { main() } + } + "#, + r#" + fn main() -> pub u64 { + main() + main() + } + "#, + r#" + fn main() -> pub u64 { + 1 + main() + } + "#, + r#" + fn main() -> pub bool { + let _ = main(); + true + } + "#, + r#" + fn main(a: u64, b: u64) -> pub u64 { + main(a + b, main(a, b)) + } + "#, + r#" + fn main() -> pub u64 { + foo(1, main()) + } + fn foo(a: u64, b: u64) -> u64 { + a + b + } + "#, + r#" + fn main() -> pub u64 { + let (a, b) = (main(), main()); + a + b + } + "#, + r#" + fn main() -> pub u64 { + let mut sum = 0; + for i in 0 .. main() { + sum += i; + } + sum + } + "#, + ]; + + for src in srcs { + let errors = get_program_errors(src); + assert!( + !errors.is_empty(), + "expected 'unconditional recursion' error, got nothing; src = {src}" + ); + + for (error, _) in errors { + let CompilationError::ResolverError(ResolverError::UnconditionalRecursion { .. }) = + error + else { + panic!("Expected an 'unconditional recursion' error, got {:?}; src = {src}", error); + }; + } + } +} + +#[test] +fn unconditional_recursion_pass() { + let srcs = vec![ + r#" + fn main() { + if false { main(); } + } + "#, + r#" + fn main(i: u64) -> pub u64 { + if i == 0 { 0 } else { i + main(i-1) } + } + "#, + // Only immediate self-recursion is detected. + r#" + fn main() { + foo(); + } + fn foo() { + bar(); + } + fn bar() { + foo(); + } + "#, + // For loop bodies are not checked. + r#" + fn main() -> pub u64 { + let mut sum = 0; + for _ in 0 .. 10 { + sum += main(); + } + sum + } + "#, + // Lambda bodies are not checked. + r#" + fn main() { + let foo = || main(); + foo(); + } + "#, + ]; + + for src in srcs { + assert_no_errors(src); + } +} + +#[test] +fn uses_self_in_import() { + let src = r#" + mod moo { + pub mod bar { + pub fn foo() -> i32 { + 1 + } + } + } + + use moo::bar::{self}; + + pub fn baz() -> i32 { + bar::foo() + } + + fn main() {} + "#; + assert_no_errors(src); +} diff --git a/noir/noir-repo/docs/docs/explainers/explainer-writing-noir.md b/noir/noir-repo/docs/docs/explainers/explainer-writing-noir.md index 3ef6e014a2f..3ce4245dc45 100644 --- a/noir/noir-repo/docs/docs/explainers/explainer-writing-noir.md +++ b/noir/noir-repo/docs/docs/explainers/explainer-writing-noir.md @@ -1,6 +1,6 @@ --- -title: Writing Performant Noir -description: Understand new considerations when writing Noir +title: Thinking in Circuits +description: Considerations when writing Noir programs keywords: [Noir, programming, rust] tags: [Optimization] sidebar_position: 0 diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.36.0/how_to/_category_.json b/noir/noir-repo/docs/versioned_docs/version-v0.36.0/how_to/_category_.json new file mode 100644 index 00000000000..360a8ad77f0 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.36.0/how_to/_category_.json @@ -0,0 +1,6 @@ +{ + "label": "Modules, Packages and Crates", + "position": 2, + "collapsible": true, + "collapsed": true +} diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.36.0/noir/concepts/data_types/_category_.json b/noir/noir-repo/docs/versioned_docs/version-v0.36.0/noir/concepts/data_types/_category_.json new file mode 100644 index 00000000000..5b6a20a609a --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.36.0/noir/concepts/data_types/_category_.json @@ -0,0 +1,5 @@ +{ + "position": 4, + "collapsible": true, + "collapsed": true +} diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.36.0/noir/standard_library/_category_.json b/noir/noir-repo/docs/versioned_docs/version-v0.36.0/noir/standard_library/_category_.json new file mode 100644 index 00000000000..e275f03bc6a --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.36.0/noir/standard_library/_category_.json @@ -0,0 +1,6 @@ +{ + "label": "Standard Library", + "position": 1, + "collapsible": true, + "collapsed": true +} diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.36.0/noir/standard_library/cryptographic_primitives/_category_.json b/noir/noir-repo/docs/versioned_docs/version-v0.36.0/noir/standard_library/cryptographic_primitives/_category_.json new file mode 100644 index 00000000000..7da08f8a8c5 --- /dev/null +++ b/noir/noir-repo/docs/versioned_docs/version-v0.36.0/noir/standard_library/cryptographic_primitives/_category_.json @@ -0,0 +1,6 @@ +{ + "label": "Concepts", + "position": 0, + "collapsible": true, + "collapsed": true +} \ No newline at end of file diff --git a/noir/noir-repo/docs/versioned_docs/version-v0.36.0/reference/debugger/_category_.json b/noir/noir-repo/docs/versioned_docs/version-v0.36.0/reference/debugger/_category_.json index 27869205ad3..186aeb3654e 100644 --- a/noir/noir-repo/docs/versioned_docs/version-v0.36.0/reference/debugger/_category_.json +++ b/noir/noir-repo/docs/versioned_docs/version-v0.36.0/reference/debugger/_category_.json @@ -1,6 +1,6 @@ { - "label": "Debugger", - "position": 1, - "collapsible": true, - "collapsed": true + "label": "Debugger", + "position": 1, + "collapsible": true, + "collapsed": true } diff --git a/noir/noir-repo/noir_stdlib/src/array/check_shuffle.nr b/noir/noir-repo/noir_stdlib/src/array/check_shuffle.nr index 82028d487c7..2e8c227feee 100644 --- a/noir/noir-repo/noir_stdlib/src/array/check_shuffle.nr +++ b/noir/noir-repo/noir_stdlib/src/array/check_shuffle.nr @@ -59,8 +59,8 @@ where } mod test { - use super::check_shuffle; use crate::cmp::Eq; + use super::check_shuffle; struct CompoundStruct { a: bool, diff --git a/noir/noir-repo/noir_stdlib/src/bigint.nr b/noir/noir-repo/noir_stdlib/src/bigint.nr index 203ff90d444..be072257be3 100644 --- a/noir/noir-repo/noir_stdlib/src/bigint.nr +++ b/noir/noir-repo/noir_stdlib/src/bigint.nr @@ -1,5 +1,5 @@ -use crate::ops::{Add, Sub, Mul, Div}; use crate::cmp::Eq; +use crate::ops::{Add, Div, Mul, Sub}; global bn254_fq = &[ 0x47, 0xFD, 0x7C, 0xD8, 0x16, 0x8C, 0x20, 0x3C, 0x8d, 0xca, 0x71, 0x68, 0x91, 0x6a, 0x81, 0x97, diff --git a/noir/noir-repo/noir_stdlib/src/cmp.nr b/noir/noir-repo/noir_stdlib/src/cmp.nr index 10be6e7b867..ae515150a4d 100644 --- a/noir/noir-repo/noir_stdlib/src/cmp.nr +++ b/noir/noir-repo/noir_stdlib/src/cmp.nr @@ -537,7 +537,7 @@ where } mod cmp_tests { - use crate::cmp::{min, max}; + use crate::cmp::{max, min}; #[test] fn sanity_check_min() { diff --git a/noir/noir-repo/noir_stdlib/src/collections/map.nr b/noir/noir-repo/noir_stdlib/src/collections/map.nr index cd203c43ad3..b46bfa837fb 100644 --- a/noir/noir-repo/noir_stdlib/src/collections/map.nr +++ b/noir/noir-repo/noir_stdlib/src/collections/map.nr @@ -1,8 +1,8 @@ use crate::cmp::Eq; -use crate::option::Option; -use crate::default::Default; -use crate::hash::{Hash, Hasher, BuildHasher}; use crate::collections::bounded_vec::BoundedVec; +use crate::default::Default; +use crate::hash::{BuildHasher, Hash, Hasher}; +use crate::option::Option; // We use load factor alpha_max = 0.75. // Upon exceeding it, assert will fail in order to inform the user diff --git a/noir/noir-repo/noir_stdlib/src/collections/umap.nr b/noir/noir-repo/noir_stdlib/src/collections/umap.nr index 9b72b6173ca..3e074551e9d 100644 --- a/noir/noir-repo/noir_stdlib/src/collections/umap.nr +++ b/noir/noir-repo/noir_stdlib/src/collections/umap.nr @@ -1,7 +1,7 @@ use crate::cmp::Eq; -use crate::option::Option; use crate::default::Default; -use crate::hash::{Hash, Hasher, BuildHasher}; +use crate::hash::{BuildHasher, Hash, Hasher}; +use crate::option::Option; // An unconstrained hash table with open addressing and quadratic probing. // Note that "unconstrained" here means that almost all operations on this diff --git a/noir/noir-repo/noir_stdlib/src/ec/consts/te.nr b/noir/noir-repo/noir_stdlib/src/ec/consts/te.nr index 561c16e846a..150eb849947 100644 --- a/noir/noir-repo/noir_stdlib/src/ec/consts/te.nr +++ b/noir/noir-repo/noir_stdlib/src/ec/consts/te.nr @@ -1,5 +1,5 @@ -use crate::ec::tecurve::affine::Point as TEPoint; use crate::ec::tecurve::affine::Curve as TECurve; +use crate::ec::tecurve::affine::Point as TEPoint; pub struct BabyJubjub { pub curve: TECurve, diff --git a/noir/noir-repo/noir_stdlib/src/ec/montcurve.nr b/noir/noir-repo/noir_stdlib/src/ec/montcurve.nr index 6c83feb1607..239585ba13f 100644 --- a/noir/noir-repo/noir_stdlib/src/ec/montcurve.nr +++ b/noir/noir-repo/noir_stdlib/src/ec/montcurve.nr @@ -3,16 +3,16 @@ pub mod affine { // Points are represented by two-dimensional Cartesian coordinates. // All group operations are induced by those of the corresponding Twisted Edwards curve. // See e.g. for details on the correspondences. + use crate::cmp::Eq; + use crate::ec::is_square; use crate::ec::montcurve::curvegroup; + use crate::ec::safe_inverse; + use crate::ec::sqrt; use crate::ec::swcurve::affine::Curve as SWCurve; use crate::ec::swcurve::affine::Point as SWPoint; use crate::ec::tecurve::affine::Curve as TECurve; use crate::ec::tecurve::affine::Point as TEPoint; - use crate::ec::is_square; - use crate::ec::safe_inverse; - use crate::ec::sqrt; use crate::ec::ZETA; - use crate::cmp::Eq; // Curve specification pub struct Curve { // Montgomery Curve configuration (ky^2 = x^3 + j*x^2 + x) @@ -222,12 +222,12 @@ pub mod curvegroup { // Points are represented by three-dimensional projective (homogeneous) coordinates. // All group operations are induced by those of the corresponding Twisted Edwards curve. // See e.g. for details on the correspondences. + use crate::cmp::Eq; use crate::ec::montcurve::affine; use crate::ec::swcurve::curvegroup::Curve as SWCurve; use crate::ec::swcurve::curvegroup::Point as SWPoint; use crate::ec::tecurve::curvegroup::Curve as TECurve; use crate::ec::tecurve::curvegroup::Point as TEPoint; - use crate::cmp::Eq; pub struct Curve { // Montgomery Curve configuration (ky^2 z = x*(x^2 + j*x*z + z*z)) pub j: Field, diff --git a/noir/noir-repo/noir_stdlib/src/ec/swcurve.nr b/noir/noir-repo/noir_stdlib/src/ec/swcurve.nr index 145b2506f73..d9c1cf8c8c7 100644 --- a/noir/noir-repo/noir_stdlib/src/ec/swcurve.nr +++ b/noir/noir-repo/noir_stdlib/src/ec/swcurve.nr @@ -3,11 +3,11 @@ pub mod affine { // Points are represented by two-dimensional Cartesian coordinates. // Group operations are implemented in terms of those in CurveGroup (in this case, extended Twisted Edwards) coordinates // for reasons of efficiency, cf. . - use crate::ec::swcurve::curvegroup; - use crate::ec::safe_inverse; + use crate::cmp::Eq; use crate::ec::is_square; + use crate::ec::safe_inverse; use crate::ec::sqrt; - use crate::cmp::Eq; + use crate::ec::swcurve::curvegroup; // Curve specification pub struct Curve { // Short Weierstrass curve @@ -190,8 +190,8 @@ pub mod curvegroup { // CurveGroup representation of Weierstrass curves // Points are represented by three-dimensional Jacobian coordinates. // See for details. - use crate::ec::swcurve::affine; use crate::cmp::Eq; + use crate::ec::swcurve::affine; // Curve specification pub struct Curve { // Short Weierstrass curve diff --git a/noir/noir-repo/noir_stdlib/src/ec/tecurve.nr b/noir/noir-repo/noir_stdlib/src/ec/tecurve.nr index 0088896015d..8512413c831 100644 --- a/noir/noir-repo/noir_stdlib/src/ec/tecurve.nr +++ b/noir/noir-repo/noir_stdlib/src/ec/tecurve.nr @@ -4,12 +4,12 @@ pub mod affine { // Group operations are implemented in terms of those in CurveGroup (in this case, extended Twisted Edwards) coordinates // for reasons of efficiency. // See for details. - use crate::ec::tecurve::curvegroup; + use crate::cmp::Eq; use crate::ec::montcurve::affine::Curve as MCurve; use crate::ec::montcurve::affine::Point as MPoint; use crate::ec::swcurve::affine::Curve as SWCurve; use crate::ec::swcurve::affine::Point as SWPoint; - use crate::cmp::Eq; + use crate::ec::tecurve::curvegroup; // Curve specification pub struct Curve { // Twisted Edwards curve @@ -197,12 +197,12 @@ pub mod curvegroup { // CurveGroup coordinate representation of Twisted Edwards curves // Points are represented by four-dimensional projective coordinates, viz. extended Twisted Edwards coordinates. // See section 3 of for details. - use crate::ec::tecurve::affine; + use crate::cmp::Eq; use crate::ec::montcurve::curvegroup::Curve as MCurve; use crate::ec::montcurve::curvegroup::Point as MPoint; use crate::ec::swcurve::curvegroup::Curve as SWCurve; use crate::ec::swcurve::curvegroup::Point as SWPoint; - use crate::cmp::Eq; + use crate::ec::tecurve::affine; // Curve specification pub struct Curve { // Twisted Edwards curve diff --git a/noir/noir-repo/noir_stdlib/src/eddsa.nr b/noir/noir-repo/noir_stdlib/src/eddsa.nr index 89a0b05b072..c049b7abbb5 100644 --- a/noir/noir-repo/noir_stdlib/src/eddsa.nr +++ b/noir/noir-repo/noir_stdlib/src/eddsa.nr @@ -1,8 +1,8 @@ +use crate::default::Default; use crate::ec::consts::te::baby_jubjub; use crate::ec::tecurve::affine::Point as TEPoint; use crate::hash::Hasher; use crate::hash::poseidon::PoseidonHasher; -use crate::default::Default; // Returns true if signature is valid pub fn eddsa_poseidon_verify( diff --git a/noir/noir-repo/noir_stdlib/src/embedded_curve_ops.nr b/noir/noir-repo/noir_stdlib/src/embedded_curve_ops.nr index dd5e4285c00..6b225ee18b2 100644 --- a/noir/noir-repo/noir_stdlib/src/embedded_curve_ops.nr +++ b/noir/noir-repo/noir_stdlib/src/embedded_curve_ops.nr @@ -1,5 +1,5 @@ -use crate::ops::arith::{Add, Sub, Neg}; use crate::cmp::Eq; +use crate::ops::arith::{Add, Neg, Sub}; /// A point on the embedded elliptic curve /// By definition, the base field of the embedded curve is the scalar field of the proof system curve, i.e the Noir Field. diff --git a/noir/noir-repo/noir_stdlib/src/field/bn254.nr b/noir/noir-repo/noir_stdlib/src/field/bn254.nr index 356b47e63cf..9642c2aa1b8 100644 --- a/noir/noir-repo/noir_stdlib/src/field/bn254.nr +++ b/noir/noir-repo/noir_stdlib/src/field/bn254.nr @@ -141,7 +141,7 @@ pub fn lt(a: Field, b: Field) -> bool { mod tests { // TODO: Allow imports from "super" use crate::field::bn254::{ - decompose, compute_lt, assert_gt, gt, TWO_POW_128, compute_lte, PLO, PHI, + assert_gt, compute_lt, compute_lte, decompose, gt, PHI, PLO, TWO_POW_128, }; #[test] diff --git a/noir/noir-repo/noir_stdlib/src/field/mod.nr b/noir/noir-repo/noir_stdlib/src/field/mod.nr index 915ea8f939e..b632cf1f7a2 100644 --- a/noir/noir-repo/noir_stdlib/src/field/mod.nr +++ b/noir/noir-repo/noir_stdlib/src/field/mod.nr @@ -1,6 +1,6 @@ pub mod bn254; -use bn254::lt as bn254_lt; use crate::runtime::is_unconstrained; +use bn254::lt as bn254_lt; impl Field { /// Asserts that `self` can be represented in `bit_size` bits. diff --git a/noir/noir-repo/noir_stdlib/src/hash/mimc.nr b/noir/noir-repo/noir_stdlib/src/hash/mimc.nr index 6045ae3dbdb..55c06964122 100644 --- a/noir/noir-repo/noir_stdlib/src/hash/mimc.nr +++ b/noir/noir-repo/noir_stdlib/src/hash/mimc.nr @@ -1,5 +1,5 @@ -use crate::hash::Hasher; use crate::default::Default; +use crate::hash::Hasher; // mimc-p/p implementation // constants are (publicly generated) random numbers, for instance using keccak as a ROM. diff --git a/noir/noir-repo/noir_stdlib/src/hash/mod.nr b/noir/noir-repo/noir_stdlib/src/hash/mod.nr index 609017d70aa..15112757312 100644 --- a/noir/noir-repo/noir_stdlib/src/hash/mod.nr +++ b/noir/noir-repo/noir_stdlib/src/hash/mod.nr @@ -6,11 +6,11 @@ pub mod sha256; pub mod sha512; use crate::default::Default; -use crate::uint128::U128; use crate::embedded_curve_ops::{ EmbeddedCurvePoint, EmbeddedCurveScalar, multi_scalar_mul, multi_scalar_mul_array_return, }; use crate::meta::derive_via; +use crate::uint128::U128; // Kept for backwards compatibility pub use sha256::{digest, sha256, sha256_compression, sha256_var}; diff --git a/noir/noir-repo/noir_stdlib/src/hash/poseidon/bn254/consts.nr b/noir/noir-repo/noir_stdlib/src/hash/poseidon/bn254/consts.nr index 835ed3ea476..42df0ef662f 100644 --- a/noir/noir-repo/noir_stdlib/src/hash/poseidon/bn254/consts.nr +++ b/noir/noir-repo/noir_stdlib/src/hash/poseidon/bn254/consts.nr @@ -2,8 +2,8 @@ // Used like so: sage generate_parameters_grain.sage 1 0 254 2 8 56 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001 // Constants for various Poseidon instances in the case of the prime field of the same order as BN254. // Consistent with https://github.com/iden3/circomlib/blob/master/circuits/poseidon.circom and https://github.com/iden3/circomlib/blob/master/circuits/poseidon_constants.circom -use crate::hash::poseidon::PoseidonConfig; use crate::hash::poseidon::config; +use crate::hash::poseidon::PoseidonConfig; // S-box power fn alpha() -> Field { 5 diff --git a/noir/noir-repo/noir_stdlib/src/hash/poseidon/mod.nr b/noir/noir-repo/noir_stdlib/src/hash/poseidon/mod.nr index 0af7951b8dc..6f0e461a610 100644 --- a/noir/noir-repo/noir_stdlib/src/hash/poseidon/mod.nr +++ b/noir/noir-repo/noir_stdlib/src/hash/poseidon/mod.nr @@ -1,6 +1,6 @@ pub mod bn254; // Instantiations of Poseidon for prime field of the same order as BN254 -use crate::hash::Hasher; use crate::default::Default; +use crate::hash::Hasher; // A config struct defining the parameters of the Poseidon instance to use. // diff --git a/noir/noir-repo/noir_stdlib/src/hash/poseidon2.nr b/noir/noir-repo/noir_stdlib/src/hash/poseidon2.nr index 517c2cd8f5f..f2167c43c2c 100644 --- a/noir/noir-repo/noir_stdlib/src/hash/poseidon2.nr +++ b/noir/noir-repo/noir_stdlib/src/hash/poseidon2.nr @@ -1,5 +1,5 @@ -use crate::hash::Hasher; use crate::default::Default; +use crate::hash::Hasher; comptime global RATE: u32 = 3; diff --git a/noir/noir-repo/noir_stdlib/src/meta/expr.nr b/noir/noir-repo/noir_stdlib/src/meta/expr.nr index 1b04a97ab15..bb795a520d3 100644 --- a/noir/noir-repo/noir_stdlib/src/meta/expr.nr +++ b/noir/noir-repo/noir_stdlib/src/meta/expr.nr @@ -1,8 +1,8 @@ //! Contains methods on the built-in `Expr` type for quoted, syntactically valid expressions. -use crate::option::Option; -use crate::meta::op::UnaryOp; use crate::meta::op::BinaryOp; +use crate::meta::op::UnaryOp; +use crate::option::Option; impl Expr { /// If this expression is an array literal `[elem1, ..., elemN]`, this returns a slice of each element in the array. diff --git a/noir/noir-repo/noir_stdlib/src/meta/mod.nr b/noir/noir-repo/noir_stdlib/src/meta/mod.nr index ff662b878ec..5102f0cf1fd 100644 --- a/noir/noir-repo/noir_stdlib/src/meta/mod.nr +++ b/noir/noir-repo/noir_stdlib/src/meta/mod.nr @@ -259,6 +259,8 @@ mod tests { let _: MyOtherStruct = MyOtherStruct { my_other_field: 2 }; let _ = derive_do_nothing(crate::panic::panic(f"")); let _ = derive_do_nothing_alt(crate::panic::panic(f"")); - remove_unused_warnings(); + if false { + remove_unused_warnings(); + } } } diff --git a/noir/noir-repo/noir_stdlib/src/meta/trait_constraint.nr b/noir/noir-repo/noir_stdlib/src/meta/trait_constraint.nr index bf22f454448..2d9c6639dbd 100644 --- a/noir/noir-repo/noir_stdlib/src/meta/trait_constraint.nr +++ b/noir/noir-repo/noir_stdlib/src/meta/trait_constraint.nr @@ -1,5 +1,5 @@ -use crate::hash::{Hash, Hasher}; use crate::cmp::Eq; +use crate::hash::{Hash, Hasher}; impl Eq for TraitConstraint { comptime fn eq(self, other: Self) -> bool { diff --git a/noir/noir-repo/noir_stdlib/src/meta/trait_def.nr b/noir/noir-repo/noir_stdlib/src/meta/trait_def.nr index cc448b2eae5..75f746337d4 100644 --- a/noir/noir-repo/noir_stdlib/src/meta/trait_def.nr +++ b/noir/noir-repo/noir_stdlib/src/meta/trait_def.nr @@ -1,5 +1,5 @@ -use crate::hash::{Hash, Hasher}; use crate::cmp::Eq; +use crate::hash::{Hash, Hasher}; impl TraitDefinition { #[builtin(trait_def_as_trait_constraint)] diff --git a/noir/noir-repo/noir_stdlib/src/ops/mod.nr b/noir/noir-repo/noir_stdlib/src/ops/mod.nr index bf908ea4b27..0e3a2467c60 100644 --- a/noir/noir-repo/noir_stdlib/src/ops/mod.nr +++ b/noir/noir-repo/noir_stdlib/src/ops/mod.nr @@ -1,5 +1,5 @@ pub(crate) mod arith; pub(crate) mod bit; -pub use arith::{Add, Sub, Mul, Div, Rem, Neg}; -pub use bit::{Not, BitOr, BitAnd, BitXor, Shl, Shr}; +pub use arith::{Add, Div, Mul, Neg, Rem, Sub}; +pub use bit::{BitAnd, BitOr, BitXor, Not, Shl, Shr}; diff --git a/noir/noir-repo/noir_stdlib/src/option.nr b/noir/noir-repo/noir_stdlib/src/option.nr index 5db2ce84efd..0a62e412849 100644 --- a/noir/noir-repo/noir_stdlib/src/option.nr +++ b/noir/noir-repo/noir_stdlib/src/option.nr @@ -1,6 +1,6 @@ -use crate::hash::{Hash, Hasher}; -use crate::cmp::{Ordering, Ord, Eq}; +use crate::cmp::{Eq, Ord, Ordering}; use crate::default::Default; +use crate::hash::{Hash, Hasher}; pub struct Option { _is_some: bool, diff --git a/noir/noir-repo/noir_stdlib/src/prelude.nr b/noir/noir-repo/noir_stdlib/src/prelude.nr index b6e54eaae60..a4a6c35b615 100644 --- a/noir/noir-repo/noir_stdlib/src/prelude.nr +++ b/noir/noir-repo/noir_stdlib/src/prelude.nr @@ -1,10 +1,10 @@ -pub use crate::collections::vec::Vec; -pub use crate::collections::bounded_vec::BoundedVec; -pub use crate::option::Option; -pub use crate::{print, println, assert_constant}; -pub use crate::uint128::U128; +pub use crate::{assert_constant, print, println}; pub use crate::cmp::{Eq, Ord}; -pub use crate::default::Default; +pub use crate::collections::bounded_vec::BoundedVec; +pub use crate::collections::vec::Vec; pub use crate::convert::{From, Into}; +pub use crate::default::Default; pub use crate::meta::{derive, derive_via}; +pub use crate::option::Option; pub use crate::panic::panic; +pub use crate::uint128::U128; diff --git a/noir/noir-repo/noir_stdlib/src/uint128.nr b/noir/noir-repo/noir_stdlib/src/uint128.nr index a4e20859604..06febb3ee00 100644 --- a/noir/noir-repo/noir_stdlib/src/uint128.nr +++ b/noir/noir-repo/noir_stdlib/src/uint128.nr @@ -1,5 +1,5 @@ -use crate::ops::{Add, Sub, Mul, Div, Rem, Not, BitOr, BitAnd, BitXor, Shl, Shr}; use crate::cmp::{Eq, Ord, Ordering}; +use crate::ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Not, Rem, Shl, Shr, Sub}; global pow64: Field = 18446744073709551616; //2^64; global pow63: Field = 9223372036854775808; // 2^63; @@ -313,7 +313,7 @@ impl Shr for U128 { } mod tests { - use crate::uint128::{U128, pow64, pow63}; + use crate::uint128::{pow63, pow64, U128}; #[test] fn test_not(lo: u64, hi: u64) { diff --git a/noir/noir-repo/test_programs/benchmarks/bench_sha256_long/Nargo.toml b/noir/noir-repo/test_programs/benchmarks/bench_sha256_long/Nargo.toml new file mode 100644 index 00000000000..ae66d7ed5a6 --- /dev/null +++ b/noir/noir-repo/test_programs/benchmarks/bench_sha256_long/Nargo.toml @@ -0,0 +1,7 @@ +[package] +name = "bench_sha256_long" +version = "0.1.0" +type = "bin" +authors = [""] + +[dependencies] diff --git a/noir/noir-repo/test_programs/compile_success_empty/ec_baby_jubjub/src/main.nr b/noir/noir-repo/test_programs/compile_success_empty/ec_baby_jubjub/src/main.nr index 935b1c613ad..caaa51d84f0 100644 --- a/noir/noir-repo/test_programs/compile_success_empty/ec_baby_jubjub/src/main.nr +++ b/noir/noir-repo/test_programs/compile_success_empty/ec_baby_jubjub/src/main.nr @@ -6,9 +6,9 @@ use std::ec::tecurve::curvegroup::Point as G; use std::ec::swcurve::affine::Point as SWGaffine; use std::ec::swcurve::curvegroup::Point as SWG; +use std::compat; use std::ec::montcurve::affine::Point as MGaffine; use std::ec::montcurve::curvegroup::Point as MG; -use std::compat; fn main() { // This test only makes sense if Field is the right prime field. diff --git a/noir/noir-repo/test_programs/compile_success_empty/mod_nr_entrypoint/src/main.nr b/noir/noir-repo/test_programs/compile_success_empty/mod_nr_entrypoint/src/main.nr index 620fd99f6ec..972a64bfeb9 100644 --- a/noir/noir-repo/test_programs/compile_success_empty/mod_nr_entrypoint/src/main.nr +++ b/noir/noir-repo/test_programs/compile_success_empty/mod_nr_entrypoint/src/main.nr @@ -1,6 +1,6 @@ -use crate::foo::in_foo_mod; -use crate::foo::bar::in_bar_mod; use crate::baz::in_baz_mod; +use crate::foo::bar::in_bar_mod; +use crate::foo::in_foo_mod; mod foo; mod baz; diff --git a/noir/noir-repo/test_programs/compile_success_empty/reexports/src/main.nr b/noir/noir-repo/test_programs/compile_success_empty/reexports/src/main.nr index 0fd65a33564..6b568bea682 100644 --- a/noir/noir-repo/test_programs/compile_success_empty/reexports/src/main.nr +++ b/noir/noir-repo/test_programs/compile_success_empty/reexports/src/main.nr @@ -1,4 +1,4 @@ -use reexporting_lib::{FooStruct, MyStruct, lib}; +use reexporting_lib::{FooStruct, lib, MyStruct}; fn main() { let x: FooStruct = MyStruct { inner: 0 }; diff --git a/noir/noir-repo/test_programs/compile_success_empty/turbofish_call_func_diff_types/src/main.nr b/noir/noir-repo/test_programs/compile_success_empty/turbofish_call_func_diff_types/src/main.nr index 535d7b18137..e44df34a193 100644 --- a/noir/noir-repo/test_programs/compile_success_empty/turbofish_call_func_diff_types/src/main.nr +++ b/noir/noir-repo/test_programs/compile_success_empty/turbofish_call_func_diff_types/src/main.nr @@ -1,6 +1,6 @@ use std::hash::Hasher; -use std::hash::poseidon2::Poseidon2Hasher; use std::hash::poseidon::PoseidonHasher; +use std::hash::poseidon2::Poseidon2Hasher; fn main(x: Field, y: pub Field) { let mut hasher = PoseidonHasher::default(); diff --git a/noir/noir-repo/test_programs/execution_success/binary_operator_overloading/src/main.nr b/noir/noir-repo/test_programs/execution_success/binary_operator_overloading/src/main.nr index a5e12fd5da9..03a4e1ed22f 100644 --- a/noir/noir-repo/test_programs/execution_success/binary_operator_overloading/src/main.nr +++ b/noir/noir-repo/test_programs/execution_success/binary_operator_overloading/src/main.nr @@ -1,5 +1,5 @@ -use std::ops::{Add, Sub, Mul, Div, Rem, BitAnd, BitOr, BitXor, Shl, Shr}; use std::cmp::Ordering; +use std::ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Rem, Shl, Shr, Sub}; // x = 3, y = 9 fn main(x: u32, y: u32) { diff --git a/noir/noir-repo/test_programs/execution_success/eddsa/src/main.nr b/noir/noir-repo/test_programs/execution_success/eddsa/src/main.nr index d0ce8e70053..48e1e4af9fb 100644 --- a/noir/noir-repo/test_programs/execution_success/eddsa/src/main.nr +++ b/noir/noir-repo/test_programs/execution_success/eddsa/src/main.nr @@ -1,8 +1,8 @@ use std::compat; use std::ec::consts::te::baby_jubjub; use std::ec::tecurve::affine::Point as TEPoint; +use std::eddsa::{eddsa_poseidon_verify, eddsa_to_pub, eddsa_verify}; use std::hash; -use std::eddsa::{eddsa_to_pub, eddsa_poseidon_verify, eddsa_verify}; use std::hash::poseidon2::Poseidon2Hasher; fn main(msg: pub Field, _priv_key_a: Field, _priv_key_b: Field) { diff --git a/noir/noir-repo/test_programs/execution_success/regression_3889/src/main.nr b/noir/noir-repo/test_programs/execution_success/regression_3889/src/main.nr index 2b54ae54418..dfd9e8c2c85 100644 --- a/noir/noir-repo/test_programs/execution_success/regression_3889/src/main.nr +++ b/noir/noir-repo/test_programs/execution_success/regression_3889/src/main.nr @@ -5,8 +5,8 @@ mod Foo { } mod Bar { - use crate::Foo::NewType as BarStruct; use crate::Foo::NewType; + use crate::Foo::NewType as BarStruct; } mod Baz { diff --git a/noir/noir-repo/tooling/nargo_fmt/src/config.rs b/noir/noir-repo/tooling/nargo_fmt/src/config.rs index 6a1a019f18d..488647c0b39 100644 --- a/noir/noir-repo/tooling/nargo_fmt/src/config.rs +++ b/noir/noir-repo/tooling/nargo_fmt/src/config.rs @@ -1,5 +1,7 @@ use std::path::Path; +use serde::{Deserialize, Serialize}; + use crate::errors::ConfigError; macro_rules! config { @@ -49,6 +51,8 @@ config! { array_width: usize, 100, "Maximum width of an array literal before falling back to vertical formatting"; fn_call_width: usize, 60, "Maximum width of the args of a function call before falling back to vertical formatting"; single_line_if_else_max_width: usize, 50, "Maximum line length for single line if-else expressions"; + imports_granularity: ImportsGranularity, ImportsGranularity::Preserve, "How imports should be grouped into use statements."; + reorder_imports: bool, true, "Reorder imports alphabetically"; } impl Config { @@ -71,3 +75,13 @@ impl Config { Ok(config) } } + +/// How imports should be grouped into use statements. +/// Imports will be merged or split to the configured level of granularity. +#[derive(Serialize, Deserialize, Copy, Clone, PartialEq, Eq)] +pub enum ImportsGranularity { + /// Do not change the granularity of any imports and preserve the original structure written by the developer. + Preserve, + /// Merge imports from the same crate into a single use statement. + Crate, +} diff --git a/noir/noir-repo/tooling/nargo_fmt/src/formatter.rs b/noir/noir-repo/tooling/nargo_fmt/src/formatter.rs index 558dab2829e..4ae5443a2cc 100644 --- a/noir/noir-repo/tooling/nargo_fmt/src/formatter.rs +++ b/noir/noir-repo/tooling/nargo_fmt/src/formatter.rs @@ -31,6 +31,7 @@ mod traits; mod type_expression; mod types; mod use_tree; +mod use_tree_merge; mod visibility; mod where_clause; @@ -107,21 +108,12 @@ impl<'a> Formatter<'a> { self.format_parsed_module(parsed_module, self.ignore_next); } - pub(crate) fn format_parsed_module( - &mut self, - parsed_module: ParsedModule, - mut ignore_next: bool, - ) { + pub(crate) fn format_parsed_module(&mut self, parsed_module: ParsedModule, ignore_next: bool) { if !parsed_module.inner_doc_comments.is_empty() { self.format_inner_doc_comments(); } - for item in parsed_module.items { - self.format_item(item, ignore_next); - self.write_line(); - ignore_next = self.ignore_next; - } - + self.format_items(parsed_module.items, ignore_next); self.write_line(); } @@ -249,7 +241,14 @@ impl<'a> Formatter<'a> { pub(super) fn write_and_skip_span_without_formatting(&mut self, span: Span) { self.write_source_span(span); - while self.token_span.start() < span.end() { + while self.token_span.start() < span.end() && self.token != Token::EOF { + self.bump(); + } + } + + /// Advances the lexer until past the given span end without writing anything to the buffer. + pub(super) fn skip_past_span_end_without_formatting(&mut self, span_end: u32) { + while self.token_span.start() < span_end && self.token != Token::EOF { self.bump(); } } diff --git a/noir/noir-repo/tooling/nargo_fmt/src/formatter/expression.rs b/noir/noir-repo/tooling/nargo_fmt/src/formatter/expression.rs index 448481047df..6f7ebf56348 100644 --- a/noir/noir-repo/tooling/nargo_fmt/src/formatter/expression.rs +++ b/noir/noir-repo/tooling/nargo_fmt/src/formatter/expression.rs @@ -705,6 +705,12 @@ impl<'a, 'b> ChunkFormatter<'a, 'b> { } }; + // Indent right after the lhs so that if there's a trailing comment, + // the next line is indented correctly. + if increase_indentation { + group.increase_indentation(); + } + let mut comment_chunk_after_lhs = self.skip_comments_and_whitespace_chunk(); // If the comment is not empty but doesn't have newlines, it's surely `/* comment */`. @@ -719,10 +725,6 @@ impl<'a, 'b> ChunkFormatter<'a, 'b> { group.trailing_comment(comment_chunk_after_lhs); } - if increase_indentation { - group.increase_indentation(); - } - group.space_or_line(); group.text(self.chunk(|formatter| { let tokens_count = @@ -1421,6 +1423,23 @@ global y = 1; assert_format_with_max_width(src, expected, "one + two + three + four".len() - 1); } + #[test] + fn format_infix_with_trailing_comments() { + let src = "fn foo() { + let x = 1 // one ++ 2 // two ++ 3; // three +} +"; + let expected = "fn foo() { + let x = 1 // one + + 2 // two + + 3; // three +} +"; + assert_format(src, expected); + } + #[test] fn format_empty_block() { let src = "global x = { } ;"; diff --git a/noir/noir-repo/tooling/nargo_fmt/src/formatter/item.rs b/noir/noir-repo/tooling/nargo_fmt/src/formatter/item.rs index 072f45278ee..77f1cd10cbc 100644 --- a/noir/noir-repo/tooling/nargo_fmt/src/formatter/item.rs +++ b/noir/noir-repo/tooling/nargo_fmt/src/formatter/item.rs @@ -1,8 +1,42 @@ -use noirc_frontend::parser::{Item, ItemKind}; +use noirc_frontend::{ + ast::{ItemVisibility, UseTree}, + hir::resolution::errors::Span, + parser::{Item, ItemKind}, +}; + +use crate::config::ImportsGranularity; use super::Formatter; impl<'a> Formatter<'a> { + pub(super) fn format_items(&mut self, mut items: Vec, mut ignore_next: bool) { + // Reverse the items because we'll be processing them one by one, and it's a bit + // more efficient to pop than to shift. + items.reverse(); + + while !items.is_empty() { + // Format the next import group, if there is one. + let import_group = self.next_import_group(&mut items); + if let Some(import_group) = import_group { + self.merge_and_format_imports(import_group.imports, import_group.visibility); + self.skip_past_span_end_without_formatting(import_group.span_end); + self.write_line(); + ignore_next = self.ignore_next; + + // Continue from the top because the next thing that comes might be another import group + continue; + } + + if let Some(item) = items.pop() { + self.format_item(item, ignore_next); + self.write_line(); + ignore_next = self.ignore_next; + } else { + break; + } + } + } + pub(super) fn format_item(&mut self, item: Item, mut ignore_next: bool) { self.skip_comments_and_whitespace(); @@ -42,4 +76,100 @@ impl<'a> Formatter<'a> { ItemKind::InnerAttribute(..) => self.format_inner_attribute(), } } + + /// Returns the next import group, if there's is one. + /// + /// An import group is one or more `use` statements that all have the same visibility, + /// as long as exactly one newline separates them, and as long as there are no comments + /// in the `use` statements or trailing comments in them. + /// + /// Each import group will be sorted and merged, if the configuration is set to do so. + fn next_import_group(&self, items: &mut Vec) -> Option { + if self.config.imports_granularity == ImportsGranularity::Preserve + && !self.config.reorder_imports + { + return None; + } + + let mut imports = Vec::new(); + + let item = items.last()?; + if self.span_has_comments(item.span) { + return None; + } + + let ItemKind::Import(..) = item.kind else { + return None; + }; + + let item = items.pop().unwrap(); + let ItemKind::Import(use_tree, visibility) = item.kind else { + panic!("Expected import, got {:?}", item.kind); + }; + + imports.push(use_tree); + let mut span_end = item.span.end(); + + while let Some(item) = items.last() { + if self.span_is_import_group_separator(Span::from(span_end..item.span.start())) { + break; + } + + let next_item_start = if items.len() > 1 { + if let Some(next_item) = items.get(items.len() - 2) { + next_item.span.start() + } else { + self.source.len() as u32 + } + } else { + self.source.len() as u32 + }; + + if self.span_starts_with_trailing_comment(Span::from(item.span.end()..next_item_start)) + { + break; + } + + let ItemKind::Import(_, next_visibility) = &item.kind else { + break; + }; + + if visibility != *next_visibility { + break; + } + + let item = items.pop().unwrap(); + let ItemKind::Import(use_tree, _) = item.kind else { + panic!("Expected import, got {:?}", item.kind); + }; + imports.push(use_tree); + span_end = item.span.end(); + } + + Some(ImportGroup { imports, visibility, span_end }) + } + + fn span_has_comments(&self, span: Span) -> bool { + let slice = &self.source[span.start() as usize..span.end() as usize]; + slice.contains("/*") || slice.contains("//") + } + + fn span_starts_with_trailing_comment(&self, span: Span) -> bool { + let slice = &self.source[span.start() as usize..span.end() as usize]; + slice.trim_start_matches(' ').starts_with("//") + } + + /// Returns true if there at most one newline in the given span and it contains no comments. + fn span_is_import_group_separator(&self, span: Span) -> bool { + let slice = &self.source[span.start() as usize..span.end() as usize]; + let number_of_newlines = slice.chars().filter(|char| *char == '\n').count(); + number_of_newlines > 1 || slice.contains("//") || slice.contains("/*") + } +} + +#[derive(Debug)] +struct ImportGroup { + imports: Vec, + visibility: ItemVisibility, + span_end: u32, } diff --git a/noir/noir-repo/tooling/nargo_fmt/src/formatter/statement.rs b/noir/noir-repo/tooling/nargo_fmt/src/formatter/statement.rs index 036066e346f..b0692d2d631 100644 --- a/noir/noir-repo/tooling/nargo_fmt/src/formatter/statement.rs +++ b/noir/noir-repo/tooling/nargo_fmt/src/formatter/statement.rs @@ -182,12 +182,15 @@ impl<'a, 'b> ChunkFormatter<'a, 'b> { if formatter.is_at(Token::Assign) { formatter.write_token(Token::Assign); } else { - while formatter.token != Token::Assign { - formatter.write_current_token(); - formatter.bump(); - formatter.skip_comments_and_whitespace(); - } - formatter.write_token(Token::Assign); + // This is something like `x += 1`, which is parsed as an + // Assign with an InfixExpression as its right-hand side: `x = x + 1`. + // There will always be two tokens here, like `+ =` or `> >=`. + formatter.write_current_token(); + formatter.bump(); + formatter.skip_comments_and_whitespace(); + formatter.write_current_token(); + formatter.bump(); + is_op_assign = true; } formatter.write_space(); @@ -435,6 +438,16 @@ mod tests { assert_format(src, expected); } + #[test] + fn format_shift_right_assign() { + let src = " fn foo() { x >>= 2 ; } "; + let expected = "fn foo() { + x >>= 2; +} +"; + assert_format(src, expected); + } + #[test] fn format_comptime_let_statement() { let src = " fn foo() { comptime let x = 1 ; } "; @@ -555,10 +568,10 @@ mod tests { #[test] fn format_two_for_separated_by_multiple_lines() { - let src = " fn foo() { for x in array { 1 } - + let src = " fn foo() { for x in array { 1 } + for x in array { 1 } - + } "; let expected = "fn foo() { for x in array { diff --git a/noir/noir-repo/tooling/nargo_fmt/src/formatter/use_tree.rs b/noir/noir-repo/tooling/nargo_fmt/src/formatter/use_tree.rs index 0c99bc7ee79..bc8dc3fcabb 100644 --- a/noir/noir-repo/tooling/nargo_fmt/src/formatter/use_tree.rs +++ b/noir/noir-repo/tooling/nargo_fmt/src/formatter/use_tree.rs @@ -68,6 +68,11 @@ impl<'a, 'b> ChunkFormatter<'a, 'b> { })); } UseTreeKind::List(use_trees) => { + // We check if there are nested lists. If yes, then each item will be on a separate line + // (it reads better, and this is what rustfmt seems to do too) + let has_nested_list = + use_trees.iter().any(|use_tree| matches!(use_tree.kind, UseTreeKind::List(..))); + let use_trees_len = use_trees.len(); let left_brace_chunk = self.chunk(|formatter| { @@ -99,6 +104,10 @@ impl<'a, 'b> ChunkFormatter<'a, 'b> { items_chunk.chunks.into_iter().filter_map(Chunk::group).next().unwrap(); group.chunks.extend(single_group.chunks); } else { + if has_nested_list { + group.one_chunk_per_line = true; + } + group.text(left_brace_chunk); group.chunks.extend(items_chunk.chunks); group.text(right_brace_chunk); @@ -112,10 +121,29 @@ impl<'a, 'b> ChunkFormatter<'a, 'b> { #[cfg(test)] mod tests { - use crate::{assert_format, assert_format_with_max_width}; + use crate::{assert_format_with_config, config::ImportsGranularity, Config}; + + fn assert_format(src: &str, expected: &str) { + let config = Config { + imports_granularity: ImportsGranularity::Preserve, + reorder_imports: false, + ..Config::default() + }; + assert_format_with_config(src, expected, config); + } + + fn assert_format_with_max_width(src: &str, expected: &str, max_width: usize) { + let config = Config { + imports_granularity: ImportsGranularity::Preserve, + reorder_imports: false, + max_width, + ..Config::default() + }; + assert_format_with_config(src, expected, config); + } #[test] - fn format_simple_use() { + fn format_simple_use_without_alias() { let src = " mod moo { pub use foo ; }"; let expected = "mod moo { pub use foo; @@ -152,7 +180,9 @@ mod tests { fn format_use_trees_with_max_width() { let src = " use foo::{ bar, baz , qux , one::{two, three} };"; let expected = "use foo::{ - bar, baz, qux, + bar, + baz, + qux, one::{ two, three, }, @@ -175,7 +205,7 @@ mod tests { four, five, }; "; - assert_format_with_max_width(src, expected, 20); + assert_format_with_max_width(src, expected, 25); } #[test] @@ -201,4 +231,33 @@ mod tests { "; assert_format_with_max_width(src, expected, "use crate::hash::{Hash, Hasher}".len()); } + + #[test] + fn do_not_merge_and_sort_imports() { + let src = " +use aztec::{ + context::Context, log::emit_unencrypted_log, note::{ + note_getter_options::NoteGetterOptions, note_header::NoteHeader, + }, state_vars::{ + Map, PrivateSet, PublicMutable, + }, types::{ + address::AztecAddress, type_serialization::field_serialization::{ + FIELD_SERIALIZED_LEN, FieldSerializationMethods, + }, + }, +}; + "; + let expected = "use aztec::{ + context::Context, + log::emit_unencrypted_log, + note::{note_getter_options::NoteGetterOptions, note_header::NoteHeader}, + state_vars::{Map, PrivateSet, PublicMutable}, + types::{ + address::AztecAddress, + type_serialization::field_serialization::{FIELD_SERIALIZED_LEN, FieldSerializationMethods}, + }, +}; +"; + assert_format(src, expected); + } } diff --git a/noir/noir-repo/tooling/nargo_fmt/src/formatter/use_tree_merge.rs b/noir/noir-repo/tooling/nargo_fmt/src/formatter/use_tree_merge.rs new file mode 100644 index 00000000000..e24b7b8cbf6 --- /dev/null +++ b/noir/noir-repo/tooling/nargo_fmt/src/formatter/use_tree_merge.rs @@ -0,0 +1,627 @@ +use std::{ + cmp::Ordering, + collections::BTreeMap, + fmt::{self, Display}, +}; + +use noirc_frontend::ast::{ItemVisibility, PathKind, UseTree, UseTreeKind}; + +use crate::{ + chunks::{ChunkGroup, TextChunk}, + config::ImportsGranularity, +}; + +use super::Formatter; + +impl<'a> Formatter<'a> { + pub(super) fn merge_and_format_imports( + &mut self, + imports: Vec, + visibility: ItemVisibility, + ) { + match self.config.imports_granularity { + ImportsGranularity::Preserve => { + let mut import_trees: Vec = + imports.into_iter().map(|import| merge_imports(vec![import])).collect(); + import_trees.sort(); + + for (index, import_tree) in import_trees.into_iter().enumerate() { + if index > 0 { + self.write_line_without_skipping_whitespace_and_comments(); + } + + self.format_import_tree(import_tree, visibility); + } + } + ImportsGranularity::Crate => { + let import_tree = merge_imports(imports); + self.format_import_tree(import_tree, visibility); + } + } + } + + fn format_import_tree(&mut self, import_tree: ImportTree, visibility: ItemVisibility) { + for (index, (segment, segment_tree)) in import_tree.tree.into_iter().enumerate() { + if index > 0 { + self.write_line_without_skipping_whitespace_and_comments(); + } + + let tree = ImportTree::single(segment, *segment_tree); + let tree = tree.simplify(); + + let group = format_merged_import_with_visibility(tree, visibility); + self.write_indentation(); + self.format_chunk_group(group); + } + } +} + +// The logic here is similar to that of `use_tree.rs`, except that it works with ImportTree +// instead of UseTree and we never check or advance the lexer. + +fn format_merged_import_with_visibility( + mut import_tree: ImportTree, + visibility: ItemVisibility, +) -> ChunkGroup { + let mut group = ChunkGroup::new(); + match visibility { + ItemVisibility::Private => (), + ItemVisibility::PublicCrate => { + group.text(TextChunk::new("pub(crate) ".to_string())); + } + ItemVisibility::Public => { + group.text(TextChunk::new("pub ".to_string())); + } + } + group.text(TextChunk::new("use ".to_string())); + + let (segment, tree) = import_tree.tree.pop_first().unwrap(); + assert!(import_tree.tree.is_empty()); + + group.group(format_merged_import(segment, *tree)); + group.text_attached_to_last_group(TextChunk::new(";".to_string())); + group +} + +fn format_merged_import(segment: Segment, import_tree: ImportTree) -> ChunkGroup { + let mut group = ChunkGroup::new(); + + group.text(TextChunk::new(segment.to_string())); + + if import_tree.tree.is_empty() { + return group; + } + + // We check if there are nested lists. If yes, then each item will be on a separate line + // (it reads better, and this is what rustfmt seems to do too) + if import_tree.tree.values().all(|tree| tree.tree.is_empty()) { + group.one_chunk_per_line = false; + } + + group.text(TextChunk::new("::{".to_string())); + group.increase_indentation(); + group.line(); + + for (index, (segment, import_tree)) in import_tree.tree.into_iter().enumerate() { + if index > 0 { + group.text_attached_to_last_group(TextChunk::new(",".to_string())); + group.space_or_line(); + } + + group.group(format_merged_import(segment, *import_tree)); + } + + group.trailing_comma(); + group.decrease_indentation(); + group.line(); + group.text(TextChunk::new("}".to_string())); + + group +} + +/// We keep Crate, Super and Dep as special segments so that they are ordered in that way +/// (they'll come in that order before any plain segment). +#[derive(Debug, PartialEq, Eq)] +enum Segment { + /// Represents the end of a path. + /// This is needed because we have want to merge "foo" and "foo::bar", + /// we need to know that "foo" is the end of a path, and "foo::bar" is another one. + /// If we don't, merging "foo" and "foo::bar" will result in just "foo::bar", loosing "foo", + /// when we actually want "foo::{self, bar}". + SelfReference, + Crate, + Super, + Dep, + Plain(String), +} + +impl Segment { + /// Combines two segments into a single one, by joining them with "::". + fn combine(self, other: Segment) -> Segment { + if other == Segment::SelfReference { + self + } else { + Segment::Plain(format!("{}::{}", self, other)) + } + } + + fn order_number(&self) -> usize { + match self { + Segment::SelfReference => 0, + Segment::Crate => 1, + Segment::Super => 2, + Segment::Dep => 3, + Segment::Plain(_) => 4, + } + } +} + +impl Display for Segment { + fn fmt(&self, f: &mut std::fmt::Formatter) -> fmt::Result { + match self { + Segment::Crate => write!(f, "crate"), + Segment::Super => write!(f, "super"), + Segment::Dep => write!(f, "dep"), + Segment::Plain(s) => write!(f, "{}", s), + Segment::SelfReference => write!(f, "self"), + } + } +} + +impl PartialOrd for Segment { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl Ord for Segment { + fn cmp(&self, other: &Self) -> Ordering { + let order_number_ordering = self.order_number().cmp(&other.order_number()); + if order_number_ordering != Ordering::Equal { + return order_number_ordering; + } + + if let (Segment::Plain(self_string), Segment::Plain(other_string)) = (self, other) { + // Case-insensitive comparison for plain segments + self_string.to_lowercase().cmp(&other_string.to_lowercase()) + } else { + order_number_ordering + } + } +} + +/// An import tree to represent merged imports. +/// For example for the given imports: +/// +/// use foo::bar::{baz, qux}; +/// use foo::another; +/// +/// an ImportTree that represents the merged imports would be: +/// +/// { +/// "foo" => { +/// "another" => {} +/// "bar" => {"baz", "qux"}, +/// } +/// } +#[derive(Debug, Default, PartialEq, Eq, PartialOrd, Ord)] +struct ImportTree { + tree: BTreeMap>, +} + +impl ImportTree { + fn new() -> Self { + Self { tree: BTreeMap::new() } + } + + /// Creates an import tree that has `segment` as the only element with `tree` as its value. + fn single(segment: Segment, tree: ImportTree) -> Self { + let mut tree_map = BTreeMap::new(); + tree_map.insert(segment, Box::new(tree)); + Self { tree: tree_map } + } + + /// Inserts a segment to the tree, creating the necessary empty children if they don't exist yet. + fn insert(&mut self, segment: Segment) -> &mut ImportTree { + self.tree.entry(segment).or_default() + } + + /// Simplifies a tree by combining segments that only have one child. + /// + /// For example, this tree: + /// + /// { + /// "foo" => { + /// "bar" => {"baz", "qux"} + /// } + /// } + /// + /// will be simplified to: + /// + /// { + /// "foo::bar" => {"baz", "qux"} + /// } + fn simplify(self) -> ImportTree { + let mut new_tree = ImportTree::new(); + for (segment, tree) in self.tree.into_iter() { + let mut tree = tree.simplify(); + if tree.tree.len() == 1 { + let (first_segment, first_tree) = tree.tree.pop_first().unwrap(); + let new_segment = segment.combine(first_segment); + new_tree.tree.insert(new_segment, first_tree); + } else { + new_tree.tree.insert(segment, Box::new(tree)); + } + } + new_tree + } +} + +/// Combines all use trees to form a single ImportTree. +fn merge_imports(imports: Vec) -> ImportTree { + let mut tree = ImportTree::new(); + merge_imports_in_tree(imports, &mut tree); + tree +} + +fn merge_imports_in_tree(imports: Vec, mut tree: &mut ImportTree) { + for import in imports { + let mut tree = match import.prefix.kind { + PathKind::Crate => tree.insert(Segment::Crate), + PathKind::Super => tree.insert(Segment::Super), + PathKind::Dep => tree.insert(Segment::Dep), + PathKind::Plain => &mut tree, + }; + + for segment in import.prefix.segments { + tree = tree.insert(Segment::Plain(segment.ident.to_string())); + } + + match import.kind { + UseTreeKind::Path(ident, alias) => { + if let Some(alias) = alias { + tree = tree.insert(Segment::Plain(format!("{} as {}", ident, alias))); + tree.insert(Segment::SelfReference); + } else if ident.0.contents == "self" { + tree.insert(Segment::SelfReference); + } else { + tree = tree.insert(Segment::Plain(ident.to_string())); + tree.insert(Segment::SelfReference); + } + } + UseTreeKind::List(trees) => { + merge_imports_in_tree(trees, tree); + } + } + } +} + +#[cfg(test)] +mod tests { + use crate::{assert_format_with_config, config::ImportsGranularity, Config}; + + fn assert_format(src: &str, expected: &str) { + let config = Config { + imports_granularity: ImportsGranularity::Crate, + reorder_imports: true, + ..Config::default() + }; + assert_format_with_config(src, expected, config); + } + + fn assert_format_with_max_width(src: &str, expected: &str, max_width: usize) { + let config = Config { + imports_granularity: ImportsGranularity::Crate, + reorder_imports: true, + max_width, + ..Config::default() + }; + assert_format_with_config(src, expected, config); + } + + fn assert_format_preserving_granularity(src: &str, expected: &str) { + let config = Config { + imports_granularity: ImportsGranularity::Preserve, + reorder_imports: true, + ..Config::default() + }; + assert_format_with_config(src, expected, config); + } + + #[test] + fn format_simple_use_without_alias() { + let src = " mod moo { pub use foo ; }"; + let expected = "mod moo { + pub use foo; +} +"; + assert_format(src, expected); + } + + #[test] + fn format_simple_use_with_alias() { + let src = " mod moo { use foo :: bar as baz ; }"; + let expected = "mod moo { + use foo::bar as baz; +} +"; + assert_format(src, expected); + } + + #[test] + fn format_simple_use_with_path_kind() { + let src = "use super :: foo ;"; + let expected = "use super::foo;\n"; + assert_format(src, expected); + } + + #[test] + fn format_use_list_two_items() { + let src = " use foo::{ bar, baz };"; + let expected = "use foo::{bar, baz};\n"; + assert_format(src, expected); + } + + #[test] + fn format_use_trees_with_max_width() { + let src = " use foo::{ bar, baz , qux , one::{two, three} };"; + let expected = "use foo::{ + bar, + baz, + one::{ + three, two, + }, + qux, +}; +"; + assert_format_with_max_width(src, expected, 20); + } + + #[test] + fn format_use_list_one_item() { + let src = " use foo::{ bar, };"; + let expected = "use foo::bar;\n"; + assert_format(src, expected); + } + + #[test] + fn format_long_use_list_one_item() { + let src = "use one::two::{three::{four, five}};"; + let expected = "use one::two::three::{ + five, four, +}; +"; + assert_format_with_max_width(src, expected, 25); + } + + #[test] + fn format_use_list_one_item_with_comments() { + let src = " use foo::{ /* do not remove me */ bar, };"; + let expected = "use foo::{ /* do not remove me */ bar};\n"; + assert_format(src, expected); + } + + #[test] + fn format_use_crate_with_list() { + let src = " use crate :: hash :: { Hash, Hasher }; "; + let expected = "use crate::hash::{Hash, Hasher};\n"; + assert_format(src, expected); + } + + #[test] + fn attaches_semicolon_to_last_group() { + let src = " use crate::hash::{Hash, Hasher}; "; + let expected = "use crate::hash::{ + Hash, Hasher, +}; +"; + assert_format_with_max_width(src, expected, "use crate::hash::{Hash, Hasher}".len()); + } + + #[test] + fn does_not_merge_imports_if_they_are_separated_by_two_lines() { + let src = " + use foo::baz; + + use foo::{def, abc}; +"; + let expected = "use foo::baz; + +use foo::{abc, def}; +"; + assert_format(src, expected); + } + + #[test] + fn does_not_merge_imports_if_they_have_different_visibilities() { + let src = " + pub use foo::baz; + use foo::{def, abc}; +"; + let expected = "pub use foo::baz; +use foo::{abc, def}; +"; + assert_format(src, expected); + } + + #[test] + fn does_not_merge_imports_if_they_have_trailing_comments_on_the_first_use() { + let src = " + use foo; // trailing + use bar; + + fn foo() {} +"; + let expected = "use foo; // trailing +use bar; + +fn foo() {} +"; + assert_format(src, expected); + } + + #[test] + fn does_not_merge_imports_if_they_have_trailing_comments_followed_by_item() { + let src = " + use foo; + use bar; // trailing + + fn foo() {} +"; + let expected = "use foo; +use bar; // trailing + +fn foo() {} +"; + assert_format(src, expected); + } + + #[test] + fn does_not_merge_imports_if_they_have_trailing_comments_followed_by_nothing() { + let src = " + use foo; + use bar; // trailing +"; + let expected = "use foo; +use bar; // trailing +"; + assert_format(src, expected); + } + + #[test] + fn merges_and_sorts_imports_just_two() { + let src = " + use foo::baz; + use foo::bar; + "; + let expected = "use foo::{bar, baz};\n"; + assert_format(src, expected); + } + + #[test] + fn sorts_but_not_merges_if_not_told_so() { + let src = " + use foo::baz; + use foo::{qux, bar}; + use bar; + "; + let expected = "use bar; +use foo::{bar, qux}; +use foo::baz; +"; + assert_format_preserving_granularity(src, expected); + } + + #[test] + fn does_not_sort_imports_in_separate_groups() { + let src = " + use foo::baz; + use foo::{qux, bar}; + + use bar; + "; + let expected = "use foo::{bar, qux}; +use foo::baz; + +use bar; +"; + assert_format_preserving_granularity(src, expected); + } + + #[test] + fn merges_and_sorts_imports_2() { + let src = " +use aztec::{ + context::Context, log::emit_unencrypted_log, note::{ + note_getter_options::NoteGetterOptions, note_header::NoteHeader, + }, state_vars::{ + Map, PrivateSet, PublicMutable, + }, types::{ + address::AztecAddress, type_serialization::field_serialization::{ + FIELD_SERIALIZED_LEN, FieldSerializationMethods, + }, + }, +}; + "; + let expected = "use aztec::{ + context::Context, + log::emit_unencrypted_log, + note::{note_getter_options::NoteGetterOptions, note_header::NoteHeader}, + state_vars::{Map, PrivateSet, PublicMutable}, + types::{ + address::AztecAddress, + type_serialization::field_serialization::{FIELD_SERIALIZED_LEN, FieldSerializationMethods}, + }, +}; +"; + assert_format(src, expected); + } + + #[test] + fn merges_and_sorts_imports_with_different_path_kinds() { + let src = " + use bar::baz; + use foo::bar; + use crate::foo; + "; + let expected = "use crate::foo; +use bar::baz; +use foo::bar; +"; + assert_format(src, expected); + } + + #[test] + fn sorts_import() { + let src = " + use value_note::{ + utils::{increment, decrement}, value_note::{VALUE_NOTE_LEN, ValueNote, ValueNoteMethods}, + }; + "; + let expected = "use value_note::{ + utils::{decrement, increment}, + value_note::{VALUE_NOTE_LEN, ValueNote, ValueNoteMethods}, +}; +"; + assert_format(src, expected); + } + + #[test] + fn sorts_import_ignoring_case() { + let src = " + use foo::{def, ZETA, ABC, efg}; + use BAR; + "; + let expected = "use BAR; +use foo::{ABC, def, efg, ZETA}; +"; + assert_format(src, expected); + } + + #[test] + fn merges_nested_import() { + let src = " + use foo::bar; + use foo; + "; + let expected = "use foo::{self, bar};\n"; + assert_format(src, expected); + } + + #[test] + fn idempotent_test_check_next_test() { + let src = " + use std::as_witness; +use std::merkle::compute_merkle_root; + "; + let expected = "use std::{as_witness, merkle::compute_merkle_root};\n"; + assert_format(src, expected); + } + + #[test] + fn idempotent_test_check_previous_test() { + let src = "use std::{as_witness, merkle::compute_merkle_root};"; + let expected = "use std::{as_witness, merkle::compute_merkle_root};\n"; + assert_format(src, expected); + } +} diff --git a/noir/noir-repo/tooling/nargo_fmt/tests/expected/contract.nr b/noir/noir-repo/tooling/nargo_fmt/tests/expected/contract.nr index 28e4ccd8ffe..ad53e61c911 100644 --- a/noir/noir-repo/tooling/nargo_fmt/tests/expected/contract.nr +++ b/noir/noir-repo/tooling/nargo_fmt/tests/expected/contract.nr @@ -6,15 +6,21 @@ contract Benchmarking { use aztec::protocol_types::abis::function_selector::FunctionSelector; use value_note::{ - utils::{increment, decrement}, value_note::{VALUE_NOTE_LEN, ValueNote, ValueNoteMethods}, + utils::{decrement, increment}, + value_note::{VALUE_NOTE_LEN, ValueNote, ValueNoteMethods}, }; use aztec::{ - context::Context, note::{note_getter_options::NoteGetterOptions, note_header::NoteHeader}, - log::emit_unencrypted_log, state_vars::{Map, PublicMutable, PrivateSet}, - types::type_serialization::field_serialization::{ - FieldSerializationMethods, FIELD_SERIALIZED_LEN, - }, types::address::AztecAddress, + context::Context, + log::emit_unencrypted_log, + note::{note_getter_options::NoteGetterOptions, note_header::NoteHeader}, + state_vars::{Map, PrivateSet, PublicMutable}, + types::{ + address::AztecAddress, + type_serialization::field_serialization::{ + FIELD_SERIALIZED_LEN, FieldSerializationMethods, + }, + }, }; struct Storage {