diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..01971844 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,54 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + runs-on: kuberunner + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + - name: Install golang + uses: actions/setup-go@v5 + with: + go-version: '1.20.1' + - name: Install foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: nightly + - name: Build + run: cargo build --all-targets + lints: + runs-on: kuberunner + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + - name: Install golang + uses: actions/setup-go@v5 + with: + go-version: '1.20.1' + - name: Install foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: nightly + - name: Run clippy + run: cargo clippy --all-targets -- -D warnings $(cat .lints | cut -f1 -d"#" | tr '\n' ' ') + - name: Run rustfmt + run: cargo fmt -- --check diff --git a/circuits/plonky2_blake2b256/src/circuit.rs b/circuits/plonky2_blake2b256/src/circuit.rs index 75d649b5..c0bba072 100644 --- a/circuits/plonky2_blake2b256/src/circuit.rs +++ b/circuits/plonky2_blake2b256/src/circuit.rs @@ -277,12 +277,11 @@ mod tests { let mut pw = PartialWitness::new(); let data_bits = data .iter() - .map(|byte| (0..8).rev().map(move |bit_idx| (byte >> bit_idx) % 2 == 1)) - .flatten() + .flat_map(|byte| (0..8).rev().map(move |bit_idx| (byte >> bit_idx) % 2 == 1)) .collect::>(); - for i in 0..data_bits.len() { - pw.set_bool_target(targets.message[i], data_bits[i]); + for (i, bit) in data_bits.into_iter().enumerate() { + pw.set_bool_target(targets.message[i], bit); } let circuit = builder.build::(); diff --git a/circuits/plonky2_blake2b256/src/utils.rs b/circuits/plonky2_blake2b256/src/utils.rs index 2981880c..f50ebef9 100644 --- a/circuits/plonky2_blake2b256/src/utils.rs +++ b/circuits/plonky2_blake2b256/src/utils.rs @@ -209,8 +209,8 @@ mod tests { } let a_rotate_targets = rright_word(a_targets, shift); - for i in 0..WORD_BITS { - builder.register_public_input(a_rotate_targets[i].target); + for target in a_rotate_targets { + builder.register_public_input(target.target); } let data = builder.build::(); @@ -256,8 +256,8 @@ mod tests { } let c_targets = builder.add_words_wrapping(a_targets, b_targets); - for i in 0..WORD_BITS { - builder.register_public_input(c_targets[i].target); + for target in c_targets { + builder.register_public_input(target.target); } let data = builder.build::(); diff --git a/circuits/plonky2_ed25519/src/gadgets/eddsa.rs b/circuits/plonky2_ed25519/src/gadgets/eddsa.rs index b8384347..262408fe 100644 --- a/circuits/plonky2_ed25519/src/gadgets/eddsa.rs +++ b/circuits/plonky2_ed25519/src/gadgets/eddsa.rs @@ -162,7 +162,7 @@ mod tests { let mut rng = rand::thread_rng(); let rnd_idx = rng.gen_range(0..64); - let mut sig = SAMPLE_SIG1.clone(); + let mut sig = SAMPLE_SIG1; let rnd_value = rng.gen_range(1..=255); sig[rnd_idx] += rnd_value; fill_circuits::( diff --git a/ethereum/client/src/tests.rs b/ethereum/client/src/tests.rs index 80c96487..da99f3ba 100644 --- a/ethereum/client/src/tests.rs +++ b/ethereum/client/src/tests.rs @@ -64,6 +64,7 @@ pub struct BlockMerkleRootProof { pub merkle_root: B256, } +#[allow(dead_code)] #[derive(Debug, Clone)] struct DeploymentEnv { pub wvara_erc20: Address, @@ -177,9 +178,7 @@ async fn verify_block() { #[test] fn verify_message_hash() { let msg = ContentMessage { - sender: U256::from_be_bytes(H256::repeat_byte(3).to_fixed_bytes()) - .try_into() - .unwrap(), + sender: U256::from_be_bytes(H256::repeat_byte(3).to_fixed_bytes()).into(), receiver: Address::repeat_byte(3), nonce: B256::from(U256::from(3)), data: Bytes::from(vec![3, 3]), diff --git a/gear-programs/checkpoint-light-client/src/tests/mod.rs b/gear-programs/checkpoint-light-client/src/tests/mod.rs index 1b72132e..cca94a9e 100644 --- a/gear-programs/checkpoint-light-client/src/tests/mod.rs +++ b/gear-programs/checkpoint-light-client/src/tests/mod.rs @@ -289,7 +289,7 @@ async fn init_and_updating() -> Result<()> { let program_id = upload_program(&client, &mut listener, init).await?; - println!("program_id = {:?}", hex::encode(&program_id)); + println!("program_id = {:?}", hex::encode(program_id)); println!(); println!(); @@ -432,7 +432,7 @@ async fn replaying_back() -> Result<()> { let program_id = upload_program(&client, &mut listener, init).await?; - println!("program_id = {:?}", hex::encode(&program_id)); + println!("program_id = {:?}", hex::encode(program_id)); println!(); println!(); diff --git a/prover/src/storage_inclusion/storage_trie_proof/node_parser/branch_parser/bitmap_parser.rs b/prover/src/storage_inclusion/storage_trie_proof/node_parser/branch_parser/bitmap_parser.rs index 6d860074..dc097e94 100644 --- a/prover/src/storage_inclusion/storage_trie_proof/node_parser/branch_parser/bitmap_parser.rs +++ b/prover/src/storage_inclusion/storage_trie_proof/node_parser/branch_parser/bitmap_parser.rs @@ -154,7 +154,7 @@ mod tests { let data_block_target = NodeDataBlockTarget::constant(&pad_byte_vec(bitmap.to_vec()), &mut builder); - let read_offset = builder.zero().into(); + let read_offset = builder.zero(); let claimed_child_node_nibble = HalfByteTarget::constant(claimed_nibble, &mut builder); let input = BitmapParserInputTarget { diff --git a/prover/src/storage_inclusion/storage_trie_proof/node_parser/branch_parser/child_node_array_parser/child_node_parser.rs b/prover/src/storage_inclusion/storage_trie_proof/node_parser/branch_parser/child_node_array_parser/child_node_parser.rs index 7ac25f0c..b9ffafaa 100644 --- a/prover/src/storage_inclusion/storage_trie_proof/node_parser/branch_parser/child_node_array_parser/child_node_parser.rs +++ b/prover/src/storage_inclusion/storage_trie_proof/node_parser/branch_parser/child_node_array_parser/child_node_parser.rs @@ -157,7 +157,7 @@ mod tests { let child_hash = vec![120, 200, 3, 10] .into_iter() - .chain([0; 27].into_iter()) + .chain([0; 27]) .chain(std::iter::once(99)) .collect::>() .try_into() @@ -261,12 +261,11 @@ pub mod tests_common { types: &[MockChildType], ) -> [[u8; NODE_DATA_BLOCK_BYTES]; MAX_BRANCH_NODE_DATA_LENGTH_IN_BLOCKS] { let data = types - .into_iter() - .map(|ty| match ty { + .iter() + .flat_map(|ty| match ty { MockChildType::Claimed(hash) => encode_claimed_node(hash).collect(), MockChildType::NotClaimed(len) => encode_not_claimed_node(*len).collect::>(), }) - .flatten() .collect(); compose_padded_node_data(data) diff --git a/prover/src/storage_inclusion/storage_trie_proof/node_parser/mod.rs b/prover/src/storage_inclusion/storage_trie_proof/node_parser/mod.rs index 7b1e343a..169790a2 100644 --- a/prover/src/storage_inclusion/storage_trie_proof/node_parser/mod.rs +++ b/prover/src/storage_inclusion/storage_trie_proof/node_parser/mod.rs @@ -292,7 +292,7 @@ mod tests { let at_target = builder.add_virtual_target(); pw.set_target(at_target, F::from_canonical_usize(at)); - let data = node_data.random_read(at_target.into(), &mut builder); + let data = node_data.random_read(at_target, &mut builder); let expected = ByteTarget::constant(expected_data, &mut builder); data.connect(&expected, &mut builder); diff --git a/prover/src/storage_inclusion/storage_trie_proof/node_parser/nibble_parser.rs b/prover/src/storage_inclusion/storage_trie_proof/node_parser/nibble_parser.rs index db446ce1..4725c5fe 100644 --- a/prover/src/storage_inclusion/storage_trie_proof/node_parser/nibble_parser.rs +++ b/prover/src/storage_inclusion/storage_trie_proof/node_parser/nibble_parser.rs @@ -221,8 +221,8 @@ mod tests { let input = NibbleParserInputTarget { first_node_data_block: data_block_target, - read_offset: builder.zero().into(), - nibble_count: nibble_count_target.into(), + read_offset: builder.zero(), + nibble_count: nibble_count_target, partial_address: PartialStorageAddressTarget::empty(&mut builder), }; diff --git a/prover/src/storage_inclusion/storage_trie_proof/storage_address.rs b/prover/src/storage_inclusion/storage_trie_proof/storage_address.rs index 24f754a2..1279fd1a 100644 --- a/prover/src/storage_inclusion/storage_trie_proof/storage_address.rs +++ b/prover/src/storage_inclusion/storage_trie_proof/storage_address.rs @@ -207,9 +207,9 @@ mod tests { address_append_test_case(&[0x1, 0x2, 0x3, 0x4], &[], Some(&[0x1, 0x2, 0x3, 0x4])); address_append_test_case( - &vec![0xA; MAX_STORAGE_ADDRESS_LENGTH_IN_NIBBLES / 2], &[0xA; MAX_STORAGE_ADDRESS_LENGTH_IN_NIBBLES / 2], - Some(&vec![0xA; MAX_STORAGE_ADDRESS_LENGTH_IN_NIBBLES]), + &[0xA; MAX_STORAGE_ADDRESS_LENGTH_IN_NIBBLES / 2], + Some(&[0xA; MAX_STORAGE_ADDRESS_LENGTH_IN_NIBBLES]), ); } @@ -218,20 +218,16 @@ mod tests { expected = "assertion `left == right` failed: Partition containing Wire(Wire { row: 130, column: 33 }) was set twice with different values: 0 != 1" )] fn test_address_append_overflow_fails() { - address_append_test_case( - &vec![0xA; MAX_STORAGE_ADDRESS_LENGTH_IN_NIBBLES], - &[0x1], - None, - ); + address_append_test_case(&[0xA; MAX_STORAGE_ADDRESS_LENGTH_IN_NIBBLES], &[0x1], None); } #[test] fn test_address_append_have_constant_verifier_data() { let (first_cd, _) = build_test_case_circuit(&[0xA], &[0x3], Some(&[0xA, 0x3])); let (second_cd, _) = build_test_case_circuit( - &vec![0xA; MAX_STORAGE_ADDRESS_LENGTH_IN_NIBBLES / 2], &[0xA; MAX_STORAGE_ADDRESS_LENGTH_IN_NIBBLES / 2], - Some(&vec![0xA; MAX_STORAGE_ADDRESS_LENGTH_IN_NIBBLES]), + &[0xA; MAX_STORAGE_ADDRESS_LENGTH_IN_NIBBLES / 2], + Some(&[0xA; MAX_STORAGE_ADDRESS_LENGTH_IN_NIBBLES]), ); assert_eq!(first_cd.verifier_only, second_cd.verifier_only); @@ -274,18 +270,18 @@ mod tests { #[test] fn test_address_from_half_byte_targets_safe() { - address_from_half_byte_targets_safe_test_case(&pad_byte_vec(vec![]), 0, &vec![]); + address_from_half_byte_targets_safe_test_case(&pad_byte_vec(vec![]), 0, &[]); address_from_half_byte_targets_safe_test_case( &pad_byte_vec(vec![1, 2, 3, 4]), 4, - &vec![1, 2, 3, 4], + &[1, 2, 3, 4], ); address_from_half_byte_targets_safe_test_case( &pad_byte_vec(vec![1, 2, 3, 4, 5]), 3, - &vec![1, 2, 3], + &[1, 2, 3], ); } @@ -299,7 +295,7 @@ mod tests { let mut pw = PartialWitness::new(); let targets = data - .into_iter() + .iter() .map(|byte| HalfByteTarget::constant(*byte, &mut builder)) .collect::>() .try_into() @@ -307,11 +303,8 @@ mod tests { let length = builder.constant(F::from_canonical_usize(length)); - let address = PartialStorageAddressTarget::from_half_byte_targets_safe( - targets, - length.into(), - &mut builder, - ); + let address = + PartialStorageAddressTarget::from_half_byte_targets_safe(targets, length, &mut builder); let expected_address = create_address_target(expected_data, &mut builder, &mut pw); @@ -350,7 +343,7 @@ pub mod tests_common { }); PartialStorageAddressTarget { - length: length.into(), + length, padded_address: ArrayTarget::parse_exact(&mut nibble_targets), } }