From 967f7b12815c447b3410f8ac310fa14c60e2388f Mon Sep 17 00:00:00 2001 From: Nicholas Ward Date: Fri, 8 Sep 2023 10:08:01 -0700 Subject: [PATCH 1/9] latest nightly in CI and rust-toolchain --- .github/workflows/continuous-integration-workflow.yml | 4 ++-- rust-toolchain | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 rust-toolchain diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml index 2e17f9a502..ba2ad1bd9b 100644 --- a/.github/workflows/continuous-integration-workflow.yml +++ b/.github/workflows/continuous-integration-workflow.yml @@ -24,7 +24,7 @@ jobs: uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: nightly-2023-06-30 + toolchain: nightly override: true - name: rust-cache @@ -95,7 +95,7 @@ jobs: uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: nightly-2023-06-30 + toolchain: nightly override: true components: rustfmt, clippy diff --git a/rust-toolchain b/rust-toolchain new file mode 100644 index 0000000000..07ade694b1 --- /dev/null +++ b/rust-toolchain @@ -0,0 +1 @@ +nightly \ No newline at end of file From e947a62483400b21fe3f085bddb6058ad5cfde3e Mon Sep 17 00:00:00 2001 From: Nicholas Ward Date: Fri, 8 Sep 2023 10:17:41 -0700 Subject: [PATCH 2/9] suppress incorrect Clippy error --- plonky2/src/gates/selectors.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plonky2/src/gates/selectors.rs b/plonky2/src/gates/selectors.rs index ef2dec8171..6e9718dbe4 100644 --- a/plonky2/src/gates/selectors.rs +++ b/plonky2/src/gates/selectors.rs @@ -121,6 +121,10 @@ pub(crate) fn selector_polynomials, const D: usize> // Special case if we can use only one selector polynomial. if max_gate_degree + num_gates - 1 <= max_degree { + // We *want* `groups` to be a vector containing one Range (all gates are in one selector group), + // but Clippy doesn't trust us. + #[allow(clippy::single_range_in_vec_init)] + return ( vec![PolynomialValues::new( instances From 1dd77d6d27c609aa52427ee7aad0ec92a76ead69 Mon Sep 17 00:00:00 2001 From: Nicholas Ward Date: Fri, 8 Sep 2023 10:18:39 -0700 Subject: [PATCH 3/9] fmt --- plonky2/src/gates/selectors.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/plonky2/src/gates/selectors.rs b/plonky2/src/gates/selectors.rs index 6e9718dbe4..1018ba755b 100644 --- a/plonky2/src/gates/selectors.rs +++ b/plonky2/src/gates/selectors.rs @@ -124,7 +124,6 @@ pub(crate) fn selector_polynomials, const D: usize> // We *want* `groups` to be a vector containing one Range (all gates are in one selector group), // but Clippy doesn't trust us. #[allow(clippy::single_range_in_vec_init)] - return ( vec![PolynomialValues::new( instances From ed8bcf9d7470cb475022ffa88e4902d2283cd320 Mon Sep 17 00:00:00 2001 From: Nicholas Ward Date: Fri, 8 Sep 2023 10:34:37 -0700 Subject: [PATCH 4/9] clippy suggestions --- evm/src/cpu/kernel/tests/bignum/mod.rs | 2 +- evm/src/cpu/kernel/tests/log.rs | 4 ++-- evm/src/cpu/kernel/tests/receipt.rs | 4 ++-- evm/src/verifier.rs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/evm/src/cpu/kernel/tests/bignum/mod.rs b/evm/src/cpu/kernel/tests/bignum/mod.rs index f7ba220693..9e15d96f02 100644 --- a/evm/src/cpu/kernel/tests/bignum/mod.rs +++ b/evm/src/cpu/kernel/tests/bignum/mod.rs @@ -188,7 +188,7 @@ fn test_add_bignum(a: BigUint, b: BigUint, expected_output: BigUint) -> Result<( fn test_addmul_bignum(a: BigUint, b: BigUint, c: u128, expected_output: BigUint) -> Result<()> { let len = bignum_len(&a).max(bignum_len(&b)); let mut memory = pad_bignums(&[a, b], len); - memory.splice(len..len, vec![0.into(); 2].iter().cloned()); + memory.splice(len..len, [0.into(); 2].iter().cloned()); let a_start_loc = 0; let b_start_loc = len + 2; diff --git a/evm/src/cpu/kernel/tests/log.rs b/evm/src/cpu/kernel/tests/log.rs index 08ba7d520e..14502ff289 100644 --- a/evm/src/cpu/kernel/tests/log.rs +++ b/evm/src/cpu/kernel/tests/log.rs @@ -109,7 +109,7 @@ fn test_log_4() -> Result<()> { let logs_entry = KERNEL.global_labels["log_n_entry"]; let address: Address = thread_rng().gen(); let num_topics = U256::from(4); - let topics = vec![45.into(), 46.into(), 47.into(), 48.into()]; + let topics = [45.into(), 46.into(), 47.into(), 48.into()]; let data_len = U256::from(1); let data_offset = U256::from(2); @@ -170,7 +170,7 @@ fn test_log_5() -> Result<()> { let logs_entry = KERNEL.global_labels["log_n_entry"]; let address: Address = thread_rng().gen(); let num_topics = U256::from(5); - let topics = vec![1.into(), 2.into(), 3.into(), 4.into(), 5.into()]; + let topics = [1.into(), 2.into(), 3.into(), 4.into(), 5.into()]; let data_len = U256::from(0); let data_offset = U256::from(0); diff --git a/evm/src/cpu/kernel/tests/receipt.rs b/evm/src/cpu/kernel/tests/receipt.rs index 3096c29d58..783f592b01 100644 --- a/evm/src/cpu/kernel/tests/receipt.rs +++ b/evm/src/cpu/kernel/tests/receipt.rs @@ -423,7 +423,7 @@ fn test_mpt_insert_receipt() -> Result<()> { } // stack: transaction_nb, value_ptr, retdest - let initial_stack = vec![retdest, cur_trie_data.len().into(), 0.into()]; + let initial_stack = [retdest, cur_trie_data.len().into(), 0.into()]; for i in 0..initial_stack.len() { interpreter.push(initial_stack[i]); } @@ -487,7 +487,7 @@ fn test_mpt_insert_receipt() -> Result<()> { // Get updated TrieData segment. cur_trie_data = interpreter.get_memory_segment(Segment::TrieData); - let initial_stack2 = vec![retdest, cur_trie_data.len().into(), 1.into()]; + let initial_stack2 = [retdest, cur_trie_data.len().into(), 1.into()]; for i in 0..initial_stack2.len() { interpreter.push(initial_stack2[i]); } diff --git a/evm/src/verifier.rs b/evm/src/verifier.rs index ff3a246a05..49225f1426 100644 --- a/evm/src/verifier.rs +++ b/evm/src/verifier.rs @@ -266,7 +266,7 @@ fn add_data_write( where F: RichField + Extendable, { - let mut row = vec![F::ZERO; 13]; + let mut row = [F::ZERO; 13]; row[0] = F::ZERO; // is_read row[1] = F::ZERO; // context row[2] = segment; From 8af3b0feb49f3f1dbf907ae6877ec776edd30c5c Mon Sep 17 00:00:00 2001 From: Nicholas Ward Date: Fri, 8 Sep 2023 10:40:17 -0700 Subject: [PATCH 5/9] clippy suggestions --- evm/src/cpu/bootstrap_kernel.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/evm/src/cpu/bootstrap_kernel.rs b/evm/src/cpu/bootstrap_kernel.rs index c7565709a0..66f88d3ae1 100644 --- a/evm/src/cpu/bootstrap_kernel.rs +++ b/evm/src/cpu/bootstrap_kernel.rs @@ -111,9 +111,9 @@ pub(crate) fn eval_bootstrap_kernel_circuit, const let one = builder.one_extension(); // IS_BOOTSTRAP_KERNEL must have an init value of 1, a final value of 0, and a delta in {0, -1}. - let local_is_bootstrap = builder.add_many_extension(local_values.op.into_iter()); + let local_is_bootstrap = builder.add_many_extension(local_values.op.iter()); let local_is_bootstrap = builder.sub_extension(one, local_is_bootstrap); - let next_is_bootstrap = builder.add_many_extension(next_values.op.into_iter()); + let next_is_bootstrap = builder.add_many_extension(next_values.op.iter()); let next_is_bootstrap = builder.sub_extension(one, next_is_bootstrap); let constraint = builder.sub_extension(local_is_bootstrap, one); yield_constr.constraint_first_row(builder, constraint); From 7415810f1968629b08f3fbe86e5a0a57e7d98c29 Mon Sep 17 00:00:00 2001 From: Nicholas Ward Date: Fri, 8 Sep 2023 10:40:31 -0700 Subject: [PATCH 6/9] clippy suggestions --- evm/src/arithmetic/modular.rs | 2 +- evm/src/witness/util.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/evm/src/arithmetic/modular.rs b/evm/src/arithmetic/modular.rs index 2335d02987..4e540cb6b4 100644 --- a/evm/src/arithmetic/modular.rs +++ b/evm/src/arithmetic/modular.rs @@ -210,7 +210,7 @@ fn bigint_to_columns(num: &BigInt) -> [i64; N] { /// NB: `operation` can set the higher order elements in its result to /// zero if they are not used. pub(crate) fn generate_modular_op( - lv: &mut [F], + lv: &[F], nv: &mut [F], filter: usize, pol_input: [i64; 2 * N_LIMBS - 1], diff --git a/evm/src/witness/util.rs b/evm/src/witness/util.rs index 755981e5ae..7d32d5d375 100644 --- a/evm/src/witness/util.rs +++ b/evm/src/witness/util.rs @@ -68,7 +68,7 @@ pub(crate) fn mem_read_with_log( pub(crate) fn mem_write_log( channel: MemoryChannel, address: MemoryAddress, - state: &mut GenerationState, + state: &GenerationState, val: U256, ) -> MemoryOp { MemoryOp::new( @@ -96,7 +96,7 @@ pub(crate) fn mem_read_code_with_log_and_fill( pub(crate) fn mem_read_gp_with_log_and_fill( n: usize, address: MemoryAddress, - state: &mut GenerationState, + state: &GenerationState, row: &mut CpuColumnsView, ) -> (U256, MemoryOp) { let (val, op) = mem_read_with_log(MemoryChannel::GeneralPurpose(n), address, state); From a4e6c6ae901d0b49e4ce849387b8fae3e57df7e1 Mon Sep 17 00:00:00 2001 From: Nicholas Ward Date: Fri, 8 Sep 2023 10:41:01 -0700 Subject: [PATCH 7/9] clippy suggestions --- evm/src/cpu/membus.rs | 2 +- evm/src/witness/transition.rs | 2 +- evm/src/witness/util.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/evm/src/cpu/membus.rs b/evm/src/cpu/membus.rs index 3ee75a652c..bf7a03aeb5 100644 --- a/evm/src/cpu/membus.rs +++ b/evm/src/cpu/membus.rs @@ -34,7 +34,7 @@ pub mod channel_indices { pub const NUM_CHANNELS: usize = channel_indices::GP.end; /// Calculates `lv.stack_len_bounds_aux`. Note that this must be run after decode. -pub fn generate(lv: &mut CpuColumnsView) { +pub fn generate(lv: &CpuColumnsView) { let cycle_filter: F = COL_MAP.op.iter().map(|&col_i| lv[col_i]).sum(); if cycle_filter != F::ZERO { assert!(lv.is_kernel_mode.to_canonical_u64() <= 1); diff --git a/evm/src/witness/transition.rs b/evm/src/witness/transition.rs index e9b8c09b69..3ee8d4f562 100644 --- a/evm/src/witness/transition.rs +++ b/evm/src/witness/transition.rs @@ -281,7 +281,7 @@ fn try_perform_instruction(state: &mut GenerationState) -> Result<( perform_op(state, op, row) } -fn log_kernel_instruction(state: &mut GenerationState, op: Operation) { +fn log_kernel_instruction(state: &GenerationState, op: Operation) { // The logic below is a bit costly, so skip it if debug logs aren't enabled. if !log_enabled!(log::Level::Debug) { return; diff --git a/evm/src/witness/util.rs b/evm/src/witness/util.rs index 7d32d5d375..0e2b36608b 100644 --- a/evm/src/witness/util.rs +++ b/evm/src/witness/util.rs @@ -120,7 +120,7 @@ pub(crate) fn mem_read_gp_with_log_and_fill( pub(crate) fn mem_write_gp_log_and_fill( n: usize, address: MemoryAddress, - state: &mut GenerationState, + state: &GenerationState, row: &mut CpuColumnsView, val: U256, ) -> MemoryOp { From 55d051475530b03b23adccd85000d2e1964dab41 Mon Sep 17 00:00:00 2001 From: Nicholas Ward Date: Fri, 8 Sep 2023 10:41:22 -0700 Subject: [PATCH 8/9] clippy suggestions --- evm/src/recursive_verifier.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evm/src/recursive_verifier.rs b/evm/src/recursive_verifier.rs index 67a95c9597..e669f4ab35 100644 --- a/evm/src/recursive_verifier.rs +++ b/evm/src/recursive_verifier.rs @@ -207,7 +207,7 @@ where let circuit = buffer.read_circuit_data(gate_serializer, generator_serializer)?; let target_vec = buffer.read_target_vec()?; let init_challenger_state_target = - >::AlgebraicPermutation::new(target_vec.into_iter()); + >::AlgebraicPermutation::new(target_vec); let zero_target = buffer.read_target()?; let stark_proof_target = StarkProofTarget::from_buffer(buffer)?; let ctl_challenges_target = GrandProductChallengeSet::from_buffer(buffer)?; From 9a8a769dc46b2b255dfcd0ffb17d6f30786ed529 Mon Sep 17 00:00:00 2001 From: Nicholas Ward Date: Fri, 8 Sep 2023 10:44:45 -0700 Subject: [PATCH 9/9] more clippy suggestions --- evm/src/cpu/kernel/tests/log.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evm/src/cpu/kernel/tests/log.rs b/evm/src/cpu/kernel/tests/log.rs index 14502ff289..406fba0c5b 100644 --- a/evm/src/cpu/kernel/tests/log.rs +++ b/evm/src/cpu/kernel/tests/log.rs @@ -50,7 +50,7 @@ fn test_log_2() -> Result<()> { let logs_entry = KERNEL.global_labels["log_n_entry"]; let address: Address = thread_rng().gen(); let num_topics = U256::from(2); - let topics = vec![4.into(), 5.into()]; + let topics = [4.into(), 5.into()]; let data_len = U256::from(3); let data_offset = U256::from(0);