Skip to content

Commit

Permalink
chore: skip formatting informattable comments (#6288)
Browse files Browse the repository at this point in the history
I've flipped the config to just skip formatting any comments which would
be lost if formatted (really not sure why that was turned on as the
default behaviour).
  • Loading branch information
TomAFrench committed May 9, 2024
1 parent f0a1c89 commit 95b499b
Show file tree
Hide file tree
Showing 19 changed files with 47 additions and 42 deletions.
5 changes: 2 additions & 3 deletions noir-projects/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ test:
format:
FROM +build

# TODO: https://github.com/noir-lang/noir/issues/4980
# WORKDIR /usr/src/noir-projects/noir-protocol-circuits
# RUN nargo fmt --check
WORKDIR /usr/src/noir-projects/noir-protocol-circuits
RUN nargo fmt --check

WORKDIR /usr/src/noir-projects/noir-contracts
RUN nargo fmt --check
Expand Down
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::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,14 +1,15 @@
use crate::kernel_circuit_public_inputs_composer::KernelCircuitPublicInputsComposer;
use dep::reset_kernel_lib::{NoteHashReadRequestHints, NullifierReadRequestHints, PrivateValidationRequestProcessor};
use dep::types::{
abis::{
private_kernel_data::{PrivateKernelData, verify_previous_kernel_proof}, kernel_circuit_public_inputs::KernelCircuitPublicInputs,
note_hash::ScopedNoteHash, nullifier::ScopedNullifier, side_effect::SideEffect
},
constants::{
MAX_NEW_NOTE_HASHES_PER_TX, MAX_NEW_NULLIFIERS_PER_TX, MAX_NOTE_HASH_READ_REQUESTS_PER_TX,
MAX_NULLIFIER_KEY_VALIDATION_REQUESTS_PER_TX, MAX_ENCRYPTED_LOGS_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX
},
abis::{
private_kernel_data::{PrivateKernelData, verify_previous_kernel_proof},
kernel_circuit_public_inputs::KernelCircuitPublicInputs, note_hash::ScopedNoteHash,
nullifier::ScopedNullifier, side_effect::SideEffect
},
constants::{
MAX_NEW_NOTE_HASHES_PER_TX, MAX_NEW_NULLIFIERS_PER_TX, MAX_NOTE_HASH_READ_REQUESTS_PER_TX,
MAX_NULLIFIER_KEY_VALIDATION_REQUESTS_PER_TX, MAX_ENCRYPTED_LOGS_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX
},
grumpkin_private_key::GrumpkinPrivateKey, utils::arrays::array_length
};

Expand Down Expand Up @@ -94,16 +95,19 @@ 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::{
kernel_circuit_public_inputs::KernelCircuitPublicInputs, max_block_number::MaxBlockNumber,
note_hash::{NoteHash, ScopedNoteHash}, nullifier::{Nullifier, ScopedNullifier}, side_effect::SideEffect, gas::Gas
note_hash::{NoteHash, ScopedNoteHash}, nullifier::{Nullifier, ScopedNullifier},
side_effect::SideEffect, gas::Gas
},
grumpkin_private_key::GrumpkinPrivateKey,
hash::{compute_note_hash_nonce, compute_unique_siloed_note_hash, sha256_to_field, silo_note_hash, silo_nullifier},
hash::{
compute_note_hash_nonce, compute_unique_siloed_note_hash, sha256_to_field, silo_note_hash,
silo_nullifier
},
tests::{fixture_builder::FixtureBuilder, sort::sort_get_sorted_hints},
utils::{arrays::{array_eq, array_length}}, traits::{Empty, is_empty, is_empty_array}
};
Expand Down Expand Up @@ -135,10 +139,7 @@ mod tests {

// A helper function that uses the first nullifer in the previous kernel to compute the unique siloed
// note_hashes for the given note_hashes.
pub fn compute_output_note_hashes<N>(
self,
note_hashes: [ScopedNoteHash; N]
) -> [Field; N] {
pub fn compute_output_note_hashes<N>(self, note_hashes: [ScopedNoteHash; N]) -> [Field; N] {
let first_nullifier = self.previous_kernel.new_nullifiers.get_unchecked(0);
let mut unique_siloed_note_hashes = [0; N];
for i in 0..N {
Expand Down Expand Up @@ -308,13 +309,15 @@ mod tests {
public_inputs.end.unencrypted_log_preimages_length, unencrypted_log_preimages_length + prev_unencrypted_log_preimages_length
);

// noir-fmt:ignore
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);

// noir-fmt:ignore
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))
Expand Down Expand Up @@ -584,7 +587,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
Expand Up @@ -2,8 +2,9 @@ use crate::kernel_circuit_public_inputs_composer::KernelCircuitPublicInputsCompo
use dep::reset_kernel_lib::{NoteHashReadRequestHints, NullifierReadRequestHints, PrivateValidationRequestProcessor};
use dep::types::{
abis::{
private_kernel_data::{PrivateKernelData, verify_previous_kernel_proof}, kernel_circuit_public_inputs::PublicKernelCircuitPublicInputs,
note_hash::ScopedNoteHash, nullifier::ScopedNullifier, side_effect::SideEffect
private_kernel_data::{PrivateKernelData, verify_previous_kernel_proof},
kernel_circuit_public_inputs::PublicKernelCircuitPublicInputs, note_hash::ScopedNoteHash,
nullifier::ScopedNullifier, side_effect::SideEffect
},
constants::{
MAX_NEW_NOTE_HASHES_PER_TX, MAX_NEW_NULLIFIERS_PER_TX, MAX_NOTE_HASH_READ_REQUESTS_PER_TX,
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::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
@@ -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(),
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ use crate::{
combined_constant_data::CombinedConstantData,
kernel_circuit_public_inputs::{public_kernel_circuit_public_inputs::PublicKernelCircuitPublicInputs},
validation_requests::ValidationRequestsBuilder, call_request::CallRequest
}, traits::Empty
},
traits::Empty
};

struct PublicKernelCircuitPublicInputsBuilder {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use crate::{abis::max_block_number::MaxBlockNumber, traits::{Empty, Serialize}, constants::ROLLUP_VALIDATION_REQUESTS_LENGTH};
use crate::{
abis::max_block_number::MaxBlockNumber, traits::{Empty, Serialize},
constants::ROLLUP_VALIDATION_REQUESTS_LENGTH
};

// These are validation requests that cannot be fulfilled in the current context (private or public), and must be
// instead forwarded to the rollup for it to take care of them.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ use crate::{
MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX,
MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX, MAX_NULLIFIER_KEY_VALIDATION_REQUESTS_PER_TX,
MAX_PUBLIC_DATA_READS_PER_TX, VALIDATION_REQUESTS_LENGTH
}, traits::Serialize
},
traits::Serialize
};

// TODO - Use specific structs for private and public: PrivateValidationRequests vs PublicValidationRequests
Expand Down Expand Up @@ -52,4 +53,4 @@ impl Serialize<VALIDATION_REQUESTS_LENGTH> for ValidationRequests {

fields.storage
}
}
}
2 changes: 1 addition & 1 deletion noir/noir-repo/tooling/nargo_fmt/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ config! {
max_width: usize, 100, "Maximum width of each line";
tab_spaces: usize, 4, "Number of spaces per tab";
remove_nested_parens: bool, true, "Remove nested parens";
error_on_lost_comment: bool, true, "Error if unable to get comments";
error_on_lost_comment: bool, false, "Error if unable to get comments";
short_array_element_width_threshold: usize, 10, "Width threshold for an array element to be considered short";
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";
Expand Down

0 comments on commit 95b499b

Please sign in to comment.