diff --git a/.github/workflows/pr-tests.yml b/.github/workflows/pr-tests.yml index 775913b827..048b6ffc28 100644 --- a/.github/workflows/pr-tests.yml +++ b/.github/workflows/pr-tests.yml @@ -29,8 +29,8 @@ jobs: path: | ~/pilcom/node_modules key: ${{ runner.os }}-pilcom-node-modules - - name: Install Rust toolchain 1.72 - run: rustup toolchain install 1.72-x86_64-unknown-linux-gnu + - name: Install Rust toolchain 1.72 (with clippy and rustfmt) + run: rustup toolchain install 1.72-x86_64-unknown-linux-gnu && rustup component add clippy --toolchain 1.72-x86_64-unknown-linux-gnu && rustup component add rustfmt --toolchain 1.72-x86_64-unknown-linux-gnu - name: Install nightly run: rustup toolchain install nightly-2023-01-03-x86_64-unknown-linux-gnu - name: Install riscv target @@ -48,5 +48,9 @@ jobs: - name: Run slow tests # Number threads is set to 1 because the runner does not have enough memory for more. run: PILCOM=$(pwd)/pilcom/ cargo test --all --all-features --profile pr-tests --verbose -- --ignored --nocapture --test-threads=1 --exact test_keccak test_vec_median instruction_tests::addi + - name: Lint + run: cargo clippy --all --all-features -- -D warnings + - name: Format + run: cargo fmt --all --check --verbose - name: Check benches compile without running them run: cargo bench --all --all-features --profile pr-tests --no-run diff --git a/ast/src/asm_analysis/mod.rs b/ast/src/asm_analysis/mod.rs index 8cb330bac2..19f638ed07 100644 --- a/ast/src/asm_analysis/mod.rs +++ b/ast/src/asm_analysis/mod.rs @@ -1,5 +1,4 @@ mod display; -pub mod utils; use std::{ collections::{ diff --git a/ast/src/asm_analysis/utils.rs b/ast/src/asm_analysis/utils.rs deleted file mode 100644 index 8b13789179..0000000000 --- a/ast/src/asm_analysis/utils.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/executor/src/witgen/machines/block_machine.rs b/executor/src/witgen/machines/block_machine.rs index bdf7a992c6..2c8e618d0b 100644 --- a/executor/src/witgen/machines/block_machine.rs +++ b/executor/src/witgen/machines/block_machine.rs @@ -17,6 +17,20 @@ use ast::analyzed::{ }; use number::{DegreeType, FieldElement}; +enum ProcessResult<'a, T: FieldElement> { + Success(Vec>, Constraints<&'a PolynomialReference, T>), + Incomplete, +} + +impl<'a, T: FieldElement> ProcessResult<'a, T> { + fn is_success(&self) -> bool { + match self { + ProcessResult::Success(_, _) => true, + ProcessResult::Incomplete => false, + } + } +} + /// Transposes a list of rows into a map from column to a list of values. /// This is done to match the interface of [Machine::take_witness_col_values]. pub fn transpose_rows( @@ -317,11 +331,11 @@ impl<'a, T: FieldElement> BlockMachine<'a, T> { )); } - let (success, new_block, outer_assignments) = + let process_result = self.process(&mut identity_processor, left, right, &mut sequence_iterator)?; - let (success, new_block, outer_assignments) = if sequence_iterator.is_cached() && !success { - log::trace!("The cached sequence did not complete the block machine. \ + let process_result = if sequence_iterator.is_cached() && !process_result.is_success() { + log::debug!("The cached sequence did not complete the block machine. \ This can happen if the machine's execution steps depend on the input or constant values. \ We'll try again with the default sequence."); let mut sequence_iterator = self @@ -329,10 +343,10 @@ impl<'a, T: FieldElement> BlockMachine<'a, T> { .get_default_sequence_iterator(); self.process(&mut identity_processor, left, right, &mut sequence_iterator)? } else { - (success, new_block, outer_assignments) + process_result }; - if success { + if let ProcessResult::Success(new_block, outer_assignments) = process_result { log::trace!( "End processing block machine '{}' (successfully)", self.name() @@ -361,14 +375,7 @@ impl<'a, T: FieldElement> BlockMachine<'a, T> { left: &[AffineExpression<&'a PolynomialReference, T>], right: &'a SelectedExpressions, sequence_iterator: &mut ProcessingSequenceIterator, - ) -> Result< - ( - bool, - Vec>, - Constraints<&'a PolynomialReference, T>, - ), - EvalError, - > { + ) -> Result, EvalError> { // Make the block two rows larger than the block size, it includes the last row of the previous block // and the first row of the next block. let block = vec![self.row_factory.fresh_row(); self.block_size + 2]; @@ -392,7 +399,10 @@ impl<'a, T: FieldElement> BlockMachine<'a, T> { // Otherwise it is messy because we have to find the correct block again. let success = left_new.iter().all(|v| v.is_constant()); - Ok((success, new_block, outer_assignments)) + match success { + true => Ok(ProcessResult::Success(new_block, outer_assignments)), + false => Ok(ProcessResult::Incomplete), + } } /// Takes a block of rows, which contains the last row of its previous block