Skip to content

Commit

Permalink
Merge pull request #661 from powdr-labs/fix-clippy
Browse files Browse the repository at this point in the history
CI: Add back clippy & fmt checks
  • Loading branch information
chriseth authored Oct 4, 2023
2 parents 7081a5a + 122767b commit a7fe0a4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 18 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/pr-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
1 change: 0 additions & 1 deletion ast/src/asm_analysis/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
mod display;
pub mod utils;

use std::{
collections::{
Expand Down
1 change: 0 additions & 1 deletion ast/src/asm_analysis/utils.rs

This file was deleted.

38 changes: 24 additions & 14 deletions executor/src/witgen/machines/block_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ use ast::analyzed::{
};
use number::{DegreeType, FieldElement};

enum ProcessResult<'a, T: FieldElement> {
Success(Vec<Row<'a, T>>, 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<T: FieldElement>(
Expand Down Expand Up @@ -317,22 +331,22 @@ 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
.processing_sequence_cache
.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()
Expand Down Expand Up @@ -361,14 +375,7 @@ impl<'a, T: FieldElement> BlockMachine<'a, T> {
left: &[AffineExpression<&'a PolynomialReference, T>],
right: &'a SelectedExpressions<T>,
sequence_iterator: &mut ProcessingSequenceIterator,
) -> Result<
(
bool,
Vec<Row<'a, T>>,
Constraints<&'a PolynomialReference, T>,
),
EvalError<T>,
> {
) -> Result<ProcessResult<'a, T>, EvalError<T>> {
// 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];
Expand All @@ -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
Expand Down

0 comments on commit a7fe0a4

Please sign in to comment.