Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Rust toolchain 1.77 (with clippy and rustfmt)
run: rustup toolchain install 1.77-x86_64-unknown-linux-gnu && rustup component add clippy --toolchain 1.77-x86_64-unknown-linux-gnu && rustup component add rustfmt --toolchain 1.77-x86_64-unknown-linux-gnu
- name: Install Rust toolchain 1.81 (with clippy and rustfmt)
run: rustup toolchain install 1.81-x86_64-unknown-linux-gnu && rustup component add clippy --toolchain 1.81-x86_64-unknown-linux-gnu && rustup component add rustfmt --toolchain 1.81-x86_64-unknown-linux-gnu
- name: Install EStarkPolygon prover dependencies
run: sudo apt-get install -y nlohmann-json3-dev libpqxx-dev nasm
- name: Lint
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/nightly-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ jobs:
path: |
~/pilcom/node_modules
key: ${{ runner.os }}-pilcom-node-modules
- name: Install Rust toolchain 1.77
run: rustup toolchain install 1.77-x86_64-unknown-linux-gnu
- name: Install Rust toolchain 1.81
run: rustup toolchain install 1.81-x86_64-unknown-linux-gnu
- name: Install nightly
run: rustup toolchain install nightly-2024-08-01-x86_64-unknown-linux-gnu
- name: Install stdlib
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/pr-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ jobs:
key: ${{ runner.os }}-cargo-pr-tests-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-pr-tests-
- name: Install Rust toolchain 1.77 (with clippy and rustfmt)
run: rustup toolchain install 1.77-x86_64-unknown-linux-gnu && rustup component add clippy --toolchain 1.77-x86_64-unknown-linux-gnu && rustup component add rustfmt --toolchain 1.77-x86_64-unknown-linux-gnu
- name: Install Rust toolchain 1.81 (with clippy and rustfmt)
run: rustup toolchain install 1.81-x86_64-unknown-linux-gnu && rustup component add clippy --toolchain 1.81-x86_64-unknown-linux-gnu && rustup component add rustfmt --toolchain 1.81-x86_64-unknown-linux-gnu
- name: Install EStarkPolygon prover dependencies
run: sudo apt-get install -y nlohmann-json3-dev libpqxx-dev nasm
- name: Lint no default features
Expand Down Expand Up @@ -87,8 +87,8 @@ jobs:
path: |
~/pilcom/node_modules
key: ${{ runner.os }}-pilcom-node-modules
- name: Install Rust toolchain 1.77 (with clippy and rustfmt)
run: rustup toolchain install 1.77-x86_64-unknown-linux-gnu && rustup component add clippy --toolchain 1.77-x86_64-unknown-linux-gnu && rustup component add rustfmt --toolchain 1.77-x86_64-unknown-linux-gnu
- name: Install Rust toolchain 1.81 (with clippy and rustfmt)
run: rustup toolchain install 1.81-x86_64-unknown-linux-gnu && rustup component add clippy --toolchain 1.81-x86_64-unknown-linux-gnu && rustup component add rustfmt --toolchain 1.81-x86_64-unknown-linux-gnu
- name: Install nightly
run: rustup toolchain install nightly-2024-08-01-x86_64-unknown-linux-gnu
- name: Install stdlib
Expand Down Expand Up @@ -122,8 +122,8 @@ jobs:
key: ${{ runner.os }}-cargo-pr-tests-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-pr-tests-
- name: Install Rust toolchain 1.77 (with clippy and rustfmt)
run: rustup toolchain install 1.77-x86_64-unknown-linux-gnu && rustup component add clippy --toolchain 1.77-x86_64-unknown-linux-gnu && rustup component add rustfmt --toolchain 1.77-x86_64-unknown-linux-gnu
- name: Install Rust toolchain 1.81 (with clippy and rustfmt)
run: rustup toolchain install 1.81-x86_64-unknown-linux-gnu && rustup component add clippy --toolchain 1.81-x86_64-unknown-linux-gnu && rustup component add rustfmt --toolchain 1.81-x86_64-unknown-linux-gnu
- name: Run examples
run: cargo run --example hello_world

Expand All @@ -144,8 +144,8 @@ jobs:
path: |
~/pilcom/node_modules
key: ${{ runner.os }}-pilcom-node-modules
- name: Install Rust toolchain 1.77 (with clippy and rustfmt)
run: rustup toolchain install 1.77-x86_64-unknown-linux-gnu && rustup component add clippy --toolchain 1.77-x86_64-unknown-linux-gnu && rustup component add rustfmt --toolchain 1.77-x86_64-unknown-linux-gnu
- name: Install Rust toolchain 1.81 (with clippy and rustfmt)
run: rustup toolchain install 1.81-x86_64-unknown-linux-gnu && rustup component add clippy --toolchain 1.81-x86_64-unknown-linux-gnu && rustup component add rustfmt --toolchain 1.81-x86_64-unknown-linux-gnu
- name: Install nightly
run: rustup toolchain install nightly-2024-08-01-x86_64-unknown-linux-gnu
- name: Install stdlib
Expand Down Expand Up @@ -192,8 +192,8 @@ jobs:
path: |
~/pilcom/node_modules
key: ${{ runner.os }}-pilcom-node-modules
- name: Install Rust toolchain 1.77 (with clippy and rustfmt)
run: rustup toolchain install 1.77-x86_64-unknown-linux-gnu && rustup component add clippy --toolchain 1.77-x86_64-unknown-linux-gnu && rustup component add rustfmt --toolchain 1.77-x86_64-unknown-linux-gnu
- name: Install Rust toolchain 1.81 (with clippy and rustfmt)
run: rustup toolchain install 1.81-x86_64-unknown-linux-gnu && rustup component add clippy --toolchain 1.81-x86_64-unknown-linux-gnu && rustup component add rustfmt --toolchain 1.81-x86_64-unknown-linux-gnu
- name: Install test dependencies
run: sudo apt-get install -y binutils-riscv64-unknown-elf lld
- name: Install nightly
Expand Down
1 change: 1 addition & 0 deletions airgen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ impl<'a> ASMPILConverter<'a> {
/// - they target the same instance.operation
/// - they are of the same kind (permutation/lookup)
/// - their flags are mutually exclusive
///
/// Right now we only consider links from different instructions,
/// as a single instruction can be active at a time.
fn process_and_merge_links(&self, defs: &[LinkDefinition]) -> Vec<Link> {
Expand Down
4 changes: 2 additions & 2 deletions backend/src/field_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ macro_rules! generalize_factory {
unsafe {
let result = <$restricted_factory as BackendFactory<$supported_type>>::create(
&$restricted_factory,
std::mem::transmute(pil), std::mem::transmute(fixed), output_dir, setup,
std::mem::transmute::<std::sync::Arc<powdr_ast::analyzed::Analyzed<F>>, std::sync::Arc<powdr_ast::analyzed::Analyzed<$supported_type>>>(pil), std::mem::transmute::<std::sync::Arc<std::vec::Vec<(std::string::String, powdr_executor::constant_evaluator::VariablySizedColumn<F>)>>, std::sync::Arc<std::vec::Vec<(std::string::String, powdr_executor::constant_evaluator::VariablySizedColumn<$supported_type>)>>>(fixed), output_dir, setup,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. what

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait this evil macro was merged after all?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. what

A new clippy rule on transmute to make things more explicit. I just used the suggestion for now, it can probably be made less verbose.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait this evil macro was merged after all?

The first unsafe solution got nuked by rust. The evil macro was the only PR in town.
rust-lang/rust#120248 (comment)

verification_key, verification_app_key, backend_options)?;
let result: Box<dyn Backend<$supported_type>> = result;
std::mem::transmute(result)
std::mem::transmute::<std::boxed::Box<dyn Backend<$supported_type>>, std::boxed::Box<dyn Backend<F>>>(result)
}
}
)*
Expand Down
1 change: 1 addition & 0 deletions executor/src/witgen/identity_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ impl<'a, 'b, 'c, T: FieldElement, Q: QueryCallback<T>> IdentityProcessor<'a, 'b,
/// - `left`: The evaluation of the left side of the lookup (symbolic for unknown values).
/// - `right`: The expressions on the right side of the lookup.
/// - `current_rows`: The [RowPair] needed to evaluate the right side of the lookup.
///
/// Returns:
/// - `Ok(updates)`: The updates for the lookup.
/// - `Err(e)`: If the constraint system is not satisfiable.
Expand Down
2 changes: 1 addition & 1 deletion executor/src/witgen/machines/fixed_lookup_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl<T: FieldElement> IndexedColumns<T> {
/// `input_fixed_columns` is assumed to be sorted
fn ensure_index(&mut self, fixed_data: &FixedData<T>, sorted_fixed_columns: &Application) {
// we do not use the Entry API here because we want to clone `sorted_input_fixed_columns` only on index creation
if self.indices.get(sorted_fixed_columns).is_some() {
if self.indices.contains_key(sorted_fixed_columns) {
return;
}

Expand Down
1 change: 1 addition & 0 deletions executor/src/witgen/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use powdr_ast::analyzed::{AlgebraicExpression as Expression, AlgebraicReference}
/// - a polynomial
/// - not part of a polynomial array
/// - not shifted with `'`
///
/// and return the polynomial if so
pub fn try_to_simple_poly<T>(expr: &Expression<T>) -> Option<&AlgebraicReference> {
if let Expression::Reference(p @ AlgebraicReference { next: false, .. }) = expr {
Expand Down
1 change: 1 addition & 0 deletions executor/src/witgen/vm_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ impl<'a, 'b, 'c, T: FieldElement, Q: QueryCallback<T>> VmProcessor<'a, 'b, 'c, T
/// Arguments:
/// * `identities`: Identities to process. Completed identities are removed from the list.
/// * `unknown_strategy`: How to process unknown variables. Either use zero or keep it symbolic.
///
/// Returns:
/// * `Ok(true)`: If progress was made.
/// * `Ok(false)`: If no progress was made.
Expand Down
1 change: 1 addition & 0 deletions riscv-executor/src/poseidon_gl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const MDS_MATRIX: [[u64; 12]; 12] = [
/// Ported from:
/// - https://github.com/0xPolygonHermez/zkevm-proverjs/blob/main/pil/poseidong.pil
/// - https://github.com/0xPolygonHermez/zkevm-proverjs/blob/main/src/sm/sm_poseidong.js
///
/// It's also equivalent to std::machines::hash::poseidon_gl::PoseidonGL from the Powdr standard library.
pub fn poseidon_gl<F: FieldElement>(inputs: &[F]) -> [F; 4] {
assert_eq!(inputs.len(), 12);
Expand Down
2 changes: 1 addition & 1 deletion riscv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ num-traits = "0.2.15"
raki = "0.1.4"
# This is only here to work around https://github.com/lalrpop/lalrpop/issues/750
# It should be removed once that workaround is no longer needed.
regex-syntax = { version = "0.6", default_features = false, features = [
regex-syntax = { version = "0.6", default-features = false, features = [
"unicode",
] }
serde_json = "1.0"
Expand Down
22 changes: 17 additions & 5 deletions riscv/src/asm/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// this is required to please clippy which finds dome dead code in the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the generated parser already has allow(all) (in parser.rs) - where exactly is the dead code?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parser has allow(clippy::all) but dead_code is a rustc lint not a clippy lint. I moved it there!

// generated parser
// this might be fixed by upgrading lalrpop
#![allow(dead_code)]

use std::collections::{BTreeMap, BTreeSet, HashSet};

use itertools::Itertools;
Expand Down Expand Up @@ -50,19 +55,19 @@ impl RiscVProgram for AsmProgram {

fn take_executable_statements(
&mut self,
) -> impl Iterator<Item = code_gen::Statement<&str, &[Argument]>> {
) -> impl Iterator<Item = code_gen::Statement<'_, impl AsRef<str>, impl InstructionArgs>> {
self.statements.iter().filter_map(process_statement)
}

fn start_function(&self) -> &str {
fn start_function(&self) -> impl AsRef<str> {
START_FUNCTION
}
}

impl InstructionArgs for &[Argument] {
type Error = &'static str;

fn l(&self) -> Result<&str, &'static str> {
fn l(&self) -> Result<impl AsRef<str>, <Self as InstructionArgs>::Error> {
const ERR: &str = "Expected: label";
match self {
[l] => Ok(argument_to_symbol(l).ok_or(ERR)?),
Expand Down Expand Up @@ -116,7 +121,12 @@ impl InstructionArgs for &[Argument] {
}
}

fn rrl(&self) -> Result<(Register, Register, &str), &'static str> {
fn rrl(
&self,
) -> Result<
(code_gen::Register, code_gen::Register, impl AsRef<str>),
<Self as InstructionArgs>::Error,
> {
const ERR: &str = "Expected: register, register, label";
match self {
[Argument::Register(r1), Argument::Register(r2), l] => {
Expand All @@ -126,7 +136,9 @@ impl InstructionArgs for &[Argument] {
}
}

fn rl(&self) -> Result<(Register, &str), &'static str> {
fn rl(
&self,
) -> Result<(code_gen::Register, impl AsRef<str>), <Self as InstructionArgs>::Error> {
const ERR: &str = "Expected: register, label";
match self {
[Argument::Register(r1), l] => Ok((*r1, argument_to_symbol(l).ok_or(ERR)?)),
Expand Down
19 changes: 10 additions & 9 deletions riscv/src/elf/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::{
borrow::Cow,
cell::Cell,
cmp::Ordering,
collections::{btree_map::Entry, BTreeMap, BTreeSet},
Expand Down Expand Up @@ -306,7 +305,7 @@ impl RiscVProgram for ElfProgram {

fn take_executable_statements(
&mut self,
) -> impl Iterator<Item = crate::code_gen::Statement<impl AsRef<str>, WrappedArgs>> {
) -> impl Iterator<Item = code_gen::Statement<'_, impl AsRef<str>, impl InstructionArgs>> {
// In the output, the precedence is labels, locations, and then instructions.
// We merge the 3 iterators with this operations: merge(labels, merge(locs, instructions)), where each is sorted by address.

Expand Down Expand Up @@ -370,7 +369,7 @@ impl RiscVProgram for ElfProgram {
})
}

fn start_function(&self) -> Cow<str> {
fn start_function(&self) -> impl AsRef<str> {
self.dbg.symbols.get_one(self.entry_point)
}
}
Expand All @@ -385,14 +384,14 @@ struct WrappedArgs<'a> {
impl<'a> InstructionArgs for WrappedArgs<'a> {
type Error = String;

fn l(&self) -> Result<String, Self::Error> {
fn l(&self) -> Result<impl AsRef<str>, Self::Error> {
match self.args {
HighLevelArgs {
imm: HighLevelImmediate::CodeLabel(addr),
rd: None,
rs1: None,
rs2: None,
} => Ok(self.symbol_table.get_one(*addr).into()),
} => Ok(self.symbol_table.get_one(*addr).to_string()),
_ => Err(format!("Expected: label, got {:?}", self.args)),
}
}
Expand Down Expand Up @@ -481,7 +480,9 @@ impl<'a> InstructionArgs for WrappedArgs<'a> {
}
}

fn rrl(&self) -> Result<(Register, Register, String), Self::Error> {
fn rrl(
&self,
) -> Result<(Register, Register, impl AsRef<str>), <Self as InstructionArgs>::Error> {
match self.args {
HighLevelArgs {
imm: HighLevelImmediate::CodeLabel(addr),
Expand All @@ -491,13 +492,13 @@ impl<'a> InstructionArgs for WrappedArgs<'a> {
} => Ok((
Register::new(*rs1 as u8),
Register::new(*rs2 as u8),
self.symbol_table.get_one(*addr).into(),
self.symbol_table.get_one(*addr).to_string(),
)),
_ => Err(format!("Expected: rs1, rs2, label, got {:?}", self.args)),
}
}

fn rl(&self) -> Result<(Register, String), Self::Error> {
fn rl(&self) -> Result<(Register, impl AsRef<str>), Self::Error> {
match self.args {
HighLevelArgs {
imm: HighLevelImmediate::CodeLabel(addr),
Expand All @@ -506,7 +507,7 @@ impl<'a> InstructionArgs for WrappedArgs<'a> {
rs2: None,
} => Ok((
Register::new(*rs1 as u8),
self.symbol_table.get_one(*addr).into(),
self.symbol_table.get_one(*addr).to_string(),
)),
HighLevelArgs {
imm: HighLevelImmediate::CodeLabel(addr),
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "1.77"
channel = "1.81"