Skip to content

Commit

Permalink
chore: nargo fmt (#6184)
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan authored May 6, 2024
1 parent a9aeba3 commit 2014752
Show file tree
Hide file tree
Showing 38 changed files with 78 additions and 123 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use dep::aztec::prelude::{AztecAddress, PrivateContext, NoteHeader, NoteInterface};
use dep::aztec::{
keys::getters::get_ivpk_m,
protocol_types::constants::GENERATOR_INDEX__NOTE_NULLIFIER, note::utils::compute_note_hash_for_consumption,
hash::poseidon2_hash,
keys::getters::get_ivpk_m, protocol_types::constants::GENERATOR_INDEX__NOTE_NULLIFIER,
note::utils::compute_note_hash_for_consumption, hash::poseidon2_hash,
oracle::{nullifier_key::get_app_nullifier_secret_key}
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
use dep::aztec::prelude::{AztecAddress, FunctionSelector, PrivateContext, NoteHeader, NoteGetterOptions, NoteViewerOptions};

use dep::aztec::{
protocol_types::{
traits::{ToField, Serialize, FromField},
constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL,
},
protocol_types::{traits::{ToField, Serialize, FromField}, constants::MAX_NOTE_HASH_READ_REQUESTS_PER_CALL},
context::{PublicContext, Context}, note::note_getter::view_notes, state_vars::PrivateSet,
note::constants::MAX_NOTES_PER_PAGE,
note::constants::MAX_NOTES_PER_PAGE
};
use dep::std;
use dep::std::{option::Option};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use dep::aztec::prelude::{AztecAddress, NoteInterface, NoteHeader, PrivateContext};
use dep::aztec::{
keys::getters::get_ivpk_m,
note::{utils::compute_note_hash_for_consumption},
oracle::nullifier_key::get_app_nullifier_secret_key,
hash::poseidon2_hash, protocol_types::{traits::Empty, constants::GENERATOR_INDEX__NOTE_NULLIFIER},
keys::getters::get_ivpk_m, note::{utils::compute_note_hash_for_consumption},
oracle::nullifier_key::get_app_nullifier_secret_key, hash::poseidon2_hash,
protocol_types::{traits::Empty, constants::GENERATOR_INDEX__NOTE_NULLIFIER}
};

// Shows how to create a custom note
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
use dep::aztec::prelude::{
AztecAddress, FunctionSelector, NoteHeader, NoteInterface, NoteGetterOptions, PrivateContext
};
use dep::aztec::prelude::{AztecAddress, FunctionSelector, NoteHeader, NoteInterface, NoteGetterOptions, PrivateContext};

use dep::aztec::{
keys::getters::get_ivpk_m,
note::utils::compute_note_hash_for_consumption,
oracle::nullifier_key::get_app_nullifier_secret_key,
hash::poseidon2_hash, protocol_types::constants::GENERATOR_INDEX__NOTE_NULLIFIER,
keys::getters::get_ivpk_m, note::utils::compute_note_hash_for_consumption,
oracle::nullifier_key::get_app_nullifier_secret_key, hash::poseidon2_hash,
protocol_types::constants::GENERATOR_INDEX__NOTE_NULLIFIER
};

global ECDSA_PUBLIC_KEY_NOTE_LEN: Field = 5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ contract KeyRegistry {

use dep::aztec::{
state_vars::{SharedMutable, Map},
protocol_types::{
grumpkin_point::GrumpkinPoint, address::{AztecAddress, PartialAddress},
}
protocol_types::{grumpkin_point::GrumpkinPoint, address::{AztecAddress, PartialAddress}}
};

global KEY_ROTATION_DELAY = 5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
// be read/nullified before their creation etc.
contract PendingNoteHashes {
// Libs
use dep::aztec::prelude::{
AztecAddress, FunctionSelector, NoteHeader, NoteGetterOptions, PrivateContext, Map, PrivateSet
};
use dep::aztec::prelude::{AztecAddress, FunctionSelector, NoteHeader, NoteGetterOptions, PrivateContext, Map, PrivateSet};
use dep::value_note::{balance_utils, filter::filter_notes_min_sum, value_note::{VALUE_NOTE_LEN, ValueNote}};
use dep::aztec::context::{PublicContext, Context};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use dep::aztec::prelude::{AztecAddress, NoteHeader, NoteInterface, PrivateContext};
use dep::aztec::{
keys::getters::get_ivpk_m,
note::utils::compute_note_hash_for_consumption, hash::poseidon2_hash,
keys::getters::get_ivpk_m, note::utils::compute_note_hash_for_consumption, hash::poseidon2_hash,
oracle::{nullifier_key::get_app_nullifier_secret_key},
protocol_types::constants::GENERATOR_INDEX__NOTE_NULLIFIER,
protocol_types::constants::GENERATOR_INDEX__NOTE_NULLIFIER
};

global PUBLIC_KEY_NOTE_LEN: Field = 3;
Expand Down
20 changes: 9 additions & 11 deletions noir-projects/noir-contracts/contracts/test_contract/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ contract Test {

use dep::aztec::protocol_types::{
abis::private_circuit_public_inputs::PrivateCircuitPublicInputs,
constants::{MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, CANONICAL_KEY_REGISTRY_ADDRESS}, traits::{Serialize, ToField, FromField},
grumpkin_point::GrumpkinPoint
constants::{MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, CANONICAL_KEY_REGISTRY_ADDRESS},
traits::{Serialize, ToField, FromField}, grumpkin_point::GrumpkinPoint
};

use dep::aztec::note::constants::MAX_NOTES_PER_PAGE;
Expand All @@ -27,10 +27,7 @@ contract Test {
note_getter_options::NoteStatus
},
deploy::deploy_contract as aztec_deploy_contract,
oracle::{
encryption::aes128_encrypt,
unsafe_rand::unsafe_rand
}
oracle::{encryption::aes128_encrypt, unsafe_rand::unsafe_rand}
};
use dep::token_portal_content_hash_lib::{get_mint_private_content_hash, get_mint_public_content_hash};
use dep::value_note::value_note::ValueNote;
Expand Down Expand Up @@ -424,15 +421,16 @@ contract Test {
let derived_slot = derive_storage_slot_in_map(storage_slot_of_shared_mutable, address_to_get_in_registry);

// It's a bit wonky because we need to know the delay for get_current_value_in_private to work correctly
let registry_private_getter: SharedMutablePrivateGetter<Field, 5> = SharedMutablePrivateGetter::new(context, AztecAddress::from_field(CANONICAL_KEY_REGISTRY_ADDRESS), derived_slot);
let registry_private_getter: SharedMutablePrivateGetter<Field, 5> = SharedMutablePrivateGetter::new(
context,
AztecAddress::from_field(CANONICAL_KEY_REGISTRY_ADDRESS),
derived_slot
);
registry_private_getter.get_current_value_in_private()
}

#[aztec(private)]
fn test_nullifier_key_freshness(
address: AztecAddress,
public_nullifying_key: GrumpkinPoint,
) {
fn test_nullifier_key_freshness(address: AztecAddress, public_nullifying_key: GrumpkinPoint) {
assert_eq(get_npk_m(&mut context, address), public_nullifying_key);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use dep::aztec::{
keys::getters::get_ivpk_m,
prelude::{AztecAddress, NoteHeader, NoteInterface, PrivateContext},
keys::getters::get_ivpk_m, prelude::{AztecAddress, NoteHeader, NoteInterface, PrivateContext},
protocol_types::constants::GENERATOR_INDEX__NOTE_NULLIFIER,
note::utils::compute_note_hash_for_consumption, hash::poseidon2_hash,
oracle::{unsafe_rand::unsafe_rand, nullifier_key::get_app_nullifier_secret_key}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use dep::aztec::{
keys::getters::get_ivpk_m,
prelude::{AztecAddress, NoteHeader, NoteInterface, PrivateContext},
keys::getters::get_ivpk_m, prelude::{AztecAddress, NoteHeader, NoteInterface, PrivateContext},
protocol_types::constants::GENERATOR_INDEX__NOTE_NULLIFIER,
note::utils::compute_note_hash_for_consumption, hash::poseidon2_hash,
oracle::{unsafe_rand::unsafe_rand, nullifier_key::get_app_nullifier_secret_key}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use dep::aztec::{
note::{note_getter_options::PropertySelector, utils::compute_note_hash_for_consumption},
hash::poseidon2_hash, prelude::{NoteHeader, NoteInterface, PrivateContext},
protocol_types::constants::GENERATOR_INDEX__NOTE_NULLIFIER,
protocol_types::constants::GENERATOR_INDEX__NOTE_NULLIFIER
};

global TRANSPARENT_NOTE_LEN: Field = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,12 @@ contract Uniswap {
token.eq(TokenBridge::at(token_bridge).get_token().static_call(&mut context)), "input_asset address is not the same as seen in the bridge contract"
);
}

// /// Unconstrained ///

// this method exists solely for e2e tests to test that nonce gets incremented each time.
unconstrained fn nonce_for_burn_approval() -> pub Field {
storage.nonce_for_burn_approval.read()
}
// docs:end:assert_token_is_same

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use dep::parity_lib::{RootParityInputs, ParityPublicInputs};

#[recursive]
fn main(inputs: RootParityInputs) -> pub ParityPublicInputs {
fn main(inputs: RootParityInputs) -> pub ParityPublicInputs {
inputs.root_parity_circuit()
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use dep::private_kernel_lib::PrivateKernelInitCircuitPrivateInputs;
use dep::types::PrivateKernelCircuitPublicInputs;

unconstrained fn main(input: PrivateKernelInitCircuitPrivateInputs) -> pub PrivateKernelCircuitPublicInputs {
unconstrained fn main(input: PrivateKernelInitCircuitPrivateInputs) -> pub PrivateKernelCircuitPublicInputs {
input.native_private_kernel_circuit_initial()
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use dep::private_kernel_lib::PrivateKernelInitCircuitPrivateInputs;
use dep::types::PrivateKernelCircuitPublicInputs;

fn main(input: PrivateKernelInitCircuitPrivateInputs) -> pub PrivateKernelCircuitPublicInputs {
fn main(input: PrivateKernelInitCircuitPrivateInputs) -> pub PrivateKernelCircuitPublicInputs {
input.native_private_kernel_circuit_initial()
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use dep::private_kernel_lib::PrivateKernelInnerCircuitPrivateInputs;
use dep::types::PrivateKernelCircuitPublicInputs;

unconstrained fn main(input: PrivateKernelInnerCircuitPrivateInputs) -> pub PrivateKernelCircuitPublicInputs {
unconstrained fn main(input: PrivateKernelInnerCircuitPrivateInputs) -> pub PrivateKernelCircuitPublicInputs {
input.native_private_kernel_circuit_inner()
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use dep::private_kernel_lib::PrivateKernelInnerCircuitPrivateInputs;
use dep::types::PrivateKernelCircuitPublicInputs;

fn main(input: PrivateKernelInnerCircuitPrivateInputs) -> pub PrivateKernelCircuitPublicInputs {
fn main(input: PrivateKernelInnerCircuitPrivateInputs) -> pub PrivateKernelCircuitPublicInputs {
input.native_private_kernel_circuit_inner()
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ mod tests {
use dep::types::constants::{
MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NEW_NOTE_HASHES_PER_TX, MAX_NEW_NULLIFIERS_PER_TX,
MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_NULLIFIER_KEY_VALIDATION_REQUESTS_PER_TX,
MAX_ENCRYPTED_LOGS_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX,
DA_BYTES_PER_FIELD, DA_GAS_PER_BYTE
MAX_ENCRYPTED_LOGS_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX, DA_BYTES_PER_FIELD, DA_GAS_PER_BYTE
};
use dep::types::{
abis::{
Expand Down Expand Up @@ -296,18 +295,11 @@ mod tests {
public_inputs.end.unencrypted_log_preimages_length, unencrypted_log_preimages_length + prev_unencrypted_log_preimages_length
);

let hash_bytes: [u8; MAX_ENCRYPTED_LOGS_PER_TX * 32] = prev_encrypted_logs_hash
.to_be_bytes(32)
.append(&[0; MAX_ENCRYPTED_LOGS_PER_TX * 32 - 32])
.as_array();
let hash_bytes: [u8; MAX_ENCRYPTED_LOGS_PER_TX * 32] = prev_encrypted_logs_hash.to_be_bytes(32).append(&[0; MAX_ENCRYPTED_LOGS_PER_TX * 32 - 32]).as_array();
let expected_encrypted_logs_hash = sha256_to_field(hash_bytes);
assert_eq(public_inputs.end.encrypted_logs_hash, expected_encrypted_logs_hash);

let hash_bytes: [u8; MAX_UNENCRYPTED_LOGS_PER_TX * 32] = prev_unencrypted_logs_hash
.to_be_bytes(32)
.append(unencrypted_logs_hash.to_be_bytes(32))
.append(&[0; MAX_UNENCRYPTED_LOGS_PER_TX * 32 - 64])
.as_array();
let hash_bytes: [u8; MAX_UNENCRYPTED_LOGS_PER_TX * 32] = prev_unencrypted_logs_hash.to_be_bytes(32).append(unencrypted_logs_hash.to_be_bytes(32)).append(&[0; MAX_UNENCRYPTED_LOGS_PER_TX * 32 - 64]).as_array();
let expected_unencrypted_logs_hash = sha256_to_field(hash_bytes);
assert_eq(public_inputs.end.unencrypted_logs_hash, expected_unencrypted_logs_hash);
}
Expand Down Expand Up @@ -578,7 +570,6 @@ mod tests {
builder.previous_kernel.tx_context.gas_settings.teardown_gas_limits = Gas::new(300, 300);
let public_inputs = builder.execute();


let expected_gas_consumed = Gas::new(300, 300) // teardown gas
+ Gas::tx_overhead() // tx overhead
+ Gas::new(DA_GAS_PER_BYTE * DA_BYTES_PER_FIELD * 1, 0); // tx nullifier
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use dep::private_kernel_lib::PrivateKernelTailToPublicCircuitPrivateInputs;
use dep::types::PublicKernelCircuitPublicInputs;

unconstrained fn main(input: PrivateKernelTailToPublicCircuitPrivateInputs) -> pub PublicKernelCircuitPublicInputs {
unconstrained fn main(input: PrivateKernelTailToPublicCircuitPrivateInputs) -> pub PublicKernelCircuitPublicInputs {
input.execute()
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use dep::private_kernel_lib::PrivateKernelTailToPublicCircuitPrivateInputs;
use dep::types::PublicKernelCircuitPublicInputs;

fn main(input: PrivateKernelTailToPublicCircuitPrivateInputs) -> pub PublicKernelCircuitPublicInputs {
fn main(input: PrivateKernelTailToPublicCircuitPrivateInputs) -> pub PublicKernelCircuitPublicInputs {
input.execute()
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use dep::private_kernel_lib::PrivateKernelTailCircuitPrivateInputs;
use dep::types::KernelCircuitPublicInputs;

fn main(input: PrivateKernelTailCircuitPrivateInputs) -> pub KernelCircuitPublicInputs {
fn main(input: PrivateKernelTailCircuitPrivateInputs) -> pub KernelCircuitPublicInputs {
input.native_private_kernel_circuit_tail()
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use dep::public_kernel_lib::PublicKernelAppLogicCircuitPrivateInputs;
use dep::types::PublicKernelCircuitPublicInputs;

unconstrained fn main(input: PublicKernelAppLogicCircuitPrivateInputs) -> pub PublicKernelCircuitPublicInputs {
unconstrained fn main(input: PublicKernelAppLogicCircuitPrivateInputs) -> pub PublicKernelCircuitPublicInputs {
input.public_kernel_app_logic()
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use dep::public_kernel_lib::PublicKernelAppLogicCircuitPrivateInputs;
use dep::types::PublicKernelCircuitPublicInputs;

fn main(input: PublicKernelAppLogicCircuitPrivateInputs) -> pub PublicKernelCircuitPublicInputs {
fn main(input: PublicKernelAppLogicCircuitPrivateInputs) -> pub PublicKernelCircuitPublicInputs {
input.public_kernel_app_logic()
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ mod tests {
MAX_PUBLIC_DATA_READS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, NULLIFIER_TREE_HEIGHT,
NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, NULLIFIER_SUBTREE_HEIGHT, PUBLIC_DATA_SUBTREE_HEIGHT,
PUBLIC_DATA_SUBTREE_SIBLING_PATH_LENGTH, PUBLIC_DATA_TREE_HEIGHT, MAX_ENCRYPTED_LOGS_PER_TX,
MAX_UNENCRYPTED_LOGS_PER_TX,
MAX_UNENCRYPTED_LOGS_PER_TX
},
hash::{silo_nullifier, sha256_to_field},
public_data_tree_leaf_preimage::PublicDataTreeLeafPreimage,
Expand Down Expand Up @@ -360,18 +360,11 @@ mod tests {
public_inputs.end.unencrypted_log_preimages_length, unencrypted_log_preimages_length + prev_unencrypted_log_preimages_length
);

let hash_bytes: [u8; MAX_ENCRYPTED_LOGS_PER_TX * 32] = prev_encrypted_logs_hash
.to_be_bytes(32)
.append(&[0; MAX_ENCRYPTED_LOGS_PER_TX * 32 - 32])
.as_array();
let hash_bytes: [u8; MAX_ENCRYPTED_LOGS_PER_TX * 32] = prev_encrypted_logs_hash.to_be_bytes(32).append(&[0; MAX_ENCRYPTED_LOGS_PER_TX * 32 - 32]).as_array();
let expected_encrypted_logs_hash = sha256_to_field(hash_bytes);
assert_eq(public_inputs.end.encrypted_logs_hash, expected_encrypted_logs_hash);

let hash_bytes: [u8; MAX_UNENCRYPTED_LOGS_PER_TX * 32] = prev_unencrypted_logs_hash
.to_be_bytes(32)
.append(unencrypted_logs_hash.to_be_bytes(32))
.append(&[0; MAX_UNENCRYPTED_LOGS_PER_TX * 32 - 64])
.as_array();
let hash_bytes: [u8; MAX_UNENCRYPTED_LOGS_PER_TX * 32] = prev_unencrypted_logs_hash.to_be_bytes(32).append(unencrypted_logs_hash.to_be_bytes(32)).append(&[0; MAX_UNENCRYPTED_LOGS_PER_TX * 32 - 64]).as_array();
let expected_unencrypted_logs_hash = sha256_to_field(hash_bytes);
assert_eq(public_inputs.end.unencrypted_logs_hash, expected_unencrypted_logs_hash);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use dep::public_kernel_lib::PublicKernelSetupCircuitPrivateInputs;
use dep::types::PublicKernelCircuitPublicInputs;

unconstrained fn main(input: PublicKernelSetupCircuitPrivateInputs) -> pub PublicKernelCircuitPublicInputs {
unconstrained fn main(input: PublicKernelSetupCircuitPrivateInputs) -> pub PublicKernelCircuitPublicInputs {
input.public_kernel_setup()
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use dep::public_kernel_lib::PublicKernelSetupCircuitPrivateInputs;
use dep::types::PublicKernelCircuitPublicInputs;

fn main(input: PublicKernelSetupCircuitPrivateInputs) -> pub PublicKernelCircuitPublicInputs {
fn main(input: PublicKernelSetupCircuitPrivateInputs) -> pub PublicKernelCircuitPublicInputs {
input.public_kernel_setup()
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use dep::public_kernel_lib::PublicKernelTailCircuitPrivateInputs;
use dep::types::KernelCircuitPublicInputs;

unconstrained fn main(input: PublicKernelTailCircuitPrivateInputs) -> pub KernelCircuitPublicInputs {
unconstrained fn main(input: PublicKernelTailCircuitPrivateInputs) -> pub KernelCircuitPublicInputs {
input.public_kernel_tail()
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use dep::public_kernel_lib::PublicKernelTailCircuitPrivateInputs;
use dep::types::KernelCircuitPublicInputs;

fn main(input: PublicKernelTailCircuitPrivateInputs) -> pub KernelCircuitPublicInputs {
fn main(input: PublicKernelTailCircuitPrivateInputs) -> pub KernelCircuitPublicInputs {
input.public_kernel_tail()
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use dep::public_kernel_lib::PublicKernelTeardownCircuitPrivateInputs;
use dep::types::PublicKernelCircuitPublicInputs;

unconstrained fn main(input: PublicKernelTeardownCircuitPrivateInputs) -> pub PublicKernelCircuitPublicInputs {
unconstrained fn main(input: PublicKernelTeardownCircuitPrivateInputs) -> pub PublicKernelCircuitPublicInputs {
input.public_kernel_teardown()
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use dep::types::{
abis::append_only_tree_snapshot::AppendOnlyTreeSnapshot,
partial_state_reference::PartialStateReference,
mocked::AggregationObject,
traits::Empty
partial_state_reference::PartialStateReference, mocked::AggregationObject, traits::Empty
};
use crate::abis::constant_rollup_data::ConstantRollupData;

Expand Down Expand Up @@ -44,4 +42,4 @@ impl Empty for BaseOrMergeRollupPublicInputs {
out_hash : 0,
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ impl Empty for ConstantRollupData {
global_variables: GlobalVariables::empty(),
}
}
}
}
Loading

0 comments on commit 2014752

Please sign in to comment.