Skip to content

Commit 35dec90

Browse files
authored
chore: address some visibility warnings (#13728)
Pulls out some changes from #13685
1 parent f19c182 commit 35dec90

File tree

13 files changed

+49
-38
lines changed

13 files changed

+49
-38
lines changed

noir-projects/mock-protocol-circuits/crates/mock-types/src/lib.nr

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
global MAX_COMMITMENTS_PER_CALL: u32 = 2;
2-
global MAX_COMMITMENTS_PER_TX: u32 = 4;
3-
global MAX_COMMITMENT_READ_REQUESTS_PER_CALL: u32 = 2;
4-
global MAX_COMMITMENT_READ_REQUESTS_PER_TX: u32 = 4;
1+
pub global MAX_COMMITMENTS_PER_CALL: u32 = 2;
2+
pub global MAX_COMMITMENTS_PER_TX: u32 = 4;
3+
pub global MAX_COMMITMENT_READ_REQUESTS_PER_CALL: u32 = 2;
4+
pub global MAX_COMMITMENT_READ_REQUESTS_PER_TX: u32 = 4;
55

66
pub use protocol_types::{
77
constants::{
@@ -13,13 +13,13 @@ pub use protocol_types::{
1313
traits::Serialize,
1414
};
1515

16-
struct TxRequest {
17-
number_of_calls: u32,
16+
pub struct TxRequest {
17+
pub number_of_calls: u32,
1818
}
1919

20-
struct AppPublicInputs {
21-
commitments: [Field; MAX_COMMITMENTS_PER_CALL],
22-
read_requests: [Field; MAX_COMMITMENT_READ_REQUESTS_PER_CALL],
20+
pub struct AppPublicInputs {
21+
pub commitments: [Field; MAX_COMMITMENTS_PER_CALL],
22+
pub read_requests: [Field; MAX_COMMITMENT_READ_REQUESTS_PER_CALL],
2323
}
2424

2525
impl Default for AppPublicInputs {
@@ -31,10 +31,10 @@ impl Default for AppPublicInputs {
3131
}
3232
}
3333

34-
struct PrivateKernelPublicInputs {
35-
remaining_calls: u32,
36-
commitments: [Field; MAX_COMMITMENTS_PER_TX],
37-
read_requests: [Field; MAX_COMMITMENT_READ_REQUESTS_PER_TX],
34+
pub struct PrivateKernelPublicInputs {
35+
pub remaining_calls: u32,
36+
pub commitments: [Field; MAX_COMMITMENTS_PER_TX],
37+
pub read_requests: [Field; MAX_COMMITMENT_READ_REQUESTS_PER_TX],
3838
}
3939

4040
impl Default for PrivateKernelPublicInputs {
@@ -47,22 +47,22 @@ impl Default for PrivateKernelPublicInputs {
4747
}
4848
}
4949

50-
struct PrivateKernelPublicInputsBuilder {
51-
remaining_calls: u32,
52-
commitments: BoundedVec<Field, MAX_COMMITMENTS_PER_TX>,
53-
read_requests: BoundedVec<Field, MAX_COMMITMENT_READ_REQUESTS_PER_TX>,
50+
pub struct PrivateKernelPublicInputsBuilder {
51+
pub remaining_calls: u32,
52+
pub commitments: BoundedVec<Field, MAX_COMMITMENTS_PER_TX>,
53+
pub read_requests: BoundedVec<Field, MAX_COMMITMENT_READ_REQUESTS_PER_TX>,
5454
}
5555

5656
impl PrivateKernelPublicInputsBuilder {
57-
fn from_tx(tx: TxRequest) -> Self {
57+
pub fn from_tx(tx: TxRequest) -> Self {
5858
Self {
5959
remaining_calls: tx.number_of_calls,
6060
commitments: BoundedVec::new(),
6161
read_requests: BoundedVec::new(),
6262
}
6363
}
6464

65-
fn from_previous_kernel(prev_kernel_public_inputs: PrivateKernelPublicInputs) -> Self {
65+
pub fn from_previous_kernel(prev_kernel_public_inputs: PrivateKernelPublicInputs) -> Self {
6666
let mut builder = PrivateKernelPublicInputsBuilder {
6767
remaining_calls: prev_kernel_public_inputs.remaining_calls,
6868
commitments: BoundedVec::new(),
@@ -81,7 +81,7 @@ impl PrivateKernelPublicInputsBuilder {
8181
builder
8282
}
8383

84-
fn ingest_app_inputs(&mut self, app_inputs: AppPublicInputs) {
84+
pub fn ingest_app_inputs(&mut self, app_inputs: AppPublicInputs) {
8585
for i in 0..MAX_COMMITMENTS_PER_CALL {
8686
if app_inputs.commitments[i] != 0 {
8787
self.commitments.push(app_inputs.commitments[i]);
@@ -97,7 +97,7 @@ impl PrivateKernelPublicInputsBuilder {
9797
self.remaining_calls -= 1;
9898
}
9999

100-
fn finish(self) -> PrivateKernelPublicInputs {
100+
pub fn finish(self) -> PrivateKernelPublicInputs {
101101
PrivateKernelPublicInputs {
102102
remaining_calls: self.remaining_calls,
103103
commitments: self.commitments.storage(),
@@ -107,7 +107,7 @@ impl PrivateKernelPublicInputsBuilder {
107107
}
108108

109109
pub struct KernelPublicInputs {
110-
commitments: [Field; MAX_COMMITMENTS_PER_TX],
110+
pub commitments: [Field; MAX_COMMITMENTS_PER_TX],
111111
}
112112

113113
impl Default for KernelPublicInputs {

noir-projects/noir-protocol-circuits/bootstrap.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,19 @@ function compile {
142142
export -f compile
143143

144144
function build {
145+
set -eu
146+
147+
echo_stderr "Checking libraries for warnings..."
148+
parallel -v --line-buffer --tag $NARGO --program-dir {} check --deny-warnings ::: \
149+
./crates/blob \
150+
./crates/parity-lib \
151+
./crates/private-kernel-lib \
152+
./crates/reset-kernel-lib \
153+
./crates/rollup-lib \
154+
./crates/types \
155+
145156
# We allow errors so we can output the joblog.
146157
set +e
147-
set -u
148158
rm -rf target
149159
mkdir -p $key_dir
150160

noir-projects/noir-protocol-circuits/crates/blob/Nargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ compiler_version = ">=0.30.0"
77
[dependencies]
88
bigint = { tag = "v0.6.0", git = "https://github.com/noir-lang/noir-bignum" }
99
types = { path = "../types" }
10+
poseidon = { tag = "v0.1.0", git = "https://github.com/noir-lang/poseidon" }

noir-projects/noir-protocol-circuits/crates/blob/src/blob.nr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub fn check_block_blob_sponge(
4444

4545
fn compute_challenge(hashed_blobs_fields: Field, kzg_commitment: BlobCommitment) -> Field {
4646
let preimage = [hashed_blobs_fields, kzg_commitment.inner[0], kzg_commitment.inner[1]];
47-
let challenge = std::hash::poseidon2::Poseidon2::hash(preimage, 3);
47+
let challenge = poseidon::poseidon2::Poseidon2::hash(preimage, 3);
4848
challenge
4949
}
5050

@@ -474,7 +474,7 @@ mod tests {
474474
let padded_blob_fields = pad_end(blob, 0);
475475
let hashed_blob = check_block_blob_sponge(padded_blob_fields, sponge_blob);
476476
let output = evaluate_blob(blob, kzg_commitment_in, hashed_blob);
477-
let expected_z = std::hash::poseidon2::Poseidon2::hash(
477+
let expected_z = poseidon::poseidon2::Poseidon2::hash(
478478
[sponge_blob.squeeze(), kzg_commitment_in.inner[0], kzg_commitment_in.inner[1]],
479479
3,
480480
);

noir-projects/noir-protocol-circuits/crates/rollup-lib/Nargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ compiler_version = ">=0.18.0"
88
types = { path = "../types" }
99
parity_lib = { path = "../parity-lib" }
1010
blob = { path = "../blob" }
11+
poseidon = { tag = "v0.1.0", git = "https://github.com/noir-lang/poseidon" }

noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/private_base_rollup.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ mod tests {
409409
start_public_data_tree: NonEmptyMerkleTree<AVAILABLE_PUBLIC_DATA_LEAVES_FOR_TEST, PUBLIC_DATA_TREE_HEIGHT, PUBLIC_DATA_TREE_HEIGHT - AVAILABLE_PUBLIC_DATA_SUBTREE_HEIGHT_FOR_TEST, AVAILABLE_PUBLIC_DATA_SUBTREE_HEIGHT_FOR_TEST>,
410410
) -> PublicDataHint {
411411
let leaf_index = self.fee_payer_balance_leaf_index as Field;
412-
let leaf_preimage = self.pre_existing_public_data[leaf_index];
412+
let leaf_preimage = self.pre_existing_public_data[leaf_index as u32];
413413
let membership_witness = MembershipWitness {
414414
leaf_index,
415415
sibling_path: start_public_data_tree.get_sibling_path(

noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_root/block_root_rollup_inputs.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub(crate) mod tests {
4949
block_root::block_root_rollup_inputs::BlockRootRollupInputs,
5050
tests::rollup_fixture_builder::RollupFixtureBuilder,
5151
};
52-
use std::hash::poseidon2::Poseidon2;
52+
use poseidon::poseidon2::Poseidon2;
5353
use types::{
5454
hash::accumulate_sha256, tests::utils::assert_array_eq, utils::arrays::array_concat,
5555
};

noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_root/empty_block_root_rollup_inputs.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ mod tests {
6060
},
6161
tests::rollup_fixture_builder::RollupFixtureBuilder,
6262
};
63-
use std::hash::poseidon2::Poseidon2;
63+
use poseidon::poseidon2::Poseidon2;
6464
use types::{abis::sponge_blob::SpongeBlob, address::EthAddress, tests::utils::assert_array_eq};
6565

6666
pub struct TestBuilder {

noir-projects/noir-protocol-circuits/crates/types/Nargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ authors = [""]
55
compiler_version = ">=0.18.0"
66

77
[dependencies]
8-
sha256 = { tag = "v0.1.2", git = "https://github.com/noir-lang/sha256" }
8+
sha256 = { tag = "v0.1.3", git = "https://github.com/noir-lang/sha256" }
9+
poseidon = { tag = "v0.1.0", git = "https://github.com/noir-lang/poseidon" }

noir-projects/noir-protocol-circuits/crates/types/src/abis/avm_circuit_public_inputs.nr

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ use crate::{
2222
utils::reader::Reader,
2323
};
2424

25-
use std::hash::{poseidon2, poseidon2_permutation};
26-
2725
pub struct AvmCircuitPublicInputs {
2826
///////////////////////////////////
2927
// Inputs.

noir-projects/noir-protocol-circuits/crates/types/src/hash.nr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ pub fn pedersen_hash<let N: u32>(inputs: [Field; N], hash_index: u32) -> Field {
234234
}
235235

236236
pub fn poseidon2_hash<let N: u32>(inputs: [Field; N]) -> Field {
237-
std::hash::poseidon2::Poseidon2::hash(inputs, N)
237+
poseidon::poseidon2::Poseidon2::hash(inputs, N)
238238
}
239239

240240
#[no_predicates]
@@ -256,7 +256,7 @@ pub fn poseidon2_hash_subarray<let N: u32>(input: [Field; N], in_len: u32) -> Fi
256256
sponge.squeeze()
257257
}
258258

259-
// NB the below is the same as std::hash::poseidon2::Poseidon2::hash(), but replacing a range check with a bit check,
259+
// NB the below is the same as poseidon::poseidon2::Poseidon2::hash(), but replacing a range check with a bit check,
260260
// and absorbing in chunks of 3 below.
261261
#[no_predicates]
262262
pub fn poseidon2_cheaper_variable_hash<let N: u32>(input: [Field; N], in_len: u32) -> Field {
@@ -462,7 +462,7 @@ fn poseidon_chunks_matches_fixed() {
462462
input[i] = 3;
463463
}
464464
let sub_chunk_hash = poseidon2_hash_subarray(input, in_len);
465-
let fixed_len_hash = std::hash::poseidon2::Poseidon2::hash(fixed_input, fixed_input.len());
465+
let fixed_len_hash = poseidon::poseidon2::Poseidon2::hash(fixed_input, fixed_input.len());
466466
assert(sub_chunk_hash == fixed_len_hash);
467467
}
468468

@@ -474,7 +474,7 @@ fn poseidon_chunks_matches_variable() {
474474
input[i] = 3;
475475
}
476476
let variable_chunk_hash = poseidon2_cheaper_variable_hash(input, in_len);
477-
let variable_len_hash = std::hash::poseidon2::Poseidon2::hash(input, in_len);
477+
let variable_len_hash = poseidon::poseidon2::Poseidon2::hash(input, in_len);
478478
assert(variable_chunk_hash == variable_len_hash);
479479
}
480480

noir-projects/noir-protocol-circuits/crates/types/src/public_keys.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::{
66
},
77
hash::poseidon2_hash_with_separator,
88
point::POINT_LENGTH,
9-
traits::{Deserialize, Hash, Serialize, ToField},
9+
traits::{Deserialize, Hash, Serialize},
1010
};
1111

1212
use dep::std::embedded_curve_ops::EmbeddedCurvePoint as Point;

noir-projects/noir-protocol-circuits/crates/types/src/tests/merkle_tree_utils.nr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl<let SUBTREE_ITEMS: u32, let TREE_HEIGHT: u32, let SUPERTREE_HEIGHT: u32, le
118118
// TODO(md): far right of this yuck
119119
left_supertree_branch[i] = merkle_hash(
120120
left_supertree_branch[i - 1],
121-
zero_hashes[(SUBTREE_HEIGHT as u8) - 1 + (i as u8)],
121+
zero_hashes[SUBTREE_HEIGHT - 1 + i],
122122
);
123123
}
124124

@@ -180,7 +180,7 @@ impl<let SUBTREE_ITEMS: u32, let TREE_HEIGHT: u32, let SUPERTREE_HEIGHT: u32, le
180180
for i in 1..self.left_supertree_branch.len() {
181181
self.left_supertree_branch[i] = merkle_hash(
182182
self.left_supertree_branch[i - 1],
183-
self.zero_hashes[(SUBTREE_HEIGHT as u8) - 1 + (i as u8)],
183+
self.zero_hashes[SUBTREE_HEIGHT - 1 + i],
184184
);
185185
}
186186
}

0 commit comments

Comments
 (0)