diff --git a/.github/workflows/build-cache.yml b/.github/workflows/build-cache.yml index 6e7b8c1e33..bc8a44a25d 100644 --- a/.github/workflows/build-cache.yml +++ b/.github/workflows/build-cache.yml @@ -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 diff --git a/.github/workflows/nightly-tests.yml b/.github/workflows/nightly-tests.yml index ad68ca7112..fdaf20f48a 100644 --- a/.github/workflows/nightly-tests.yml +++ b/.github/workflows/nightly-tests.yml @@ -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 diff --git a/.github/workflows/pr-tests.yml b/.github/workflows/pr-tests.yml index 73abea57b8..f9f9589e07 100644 --- a/.github/workflows/pr-tests.yml +++ b/.github/workflows/pr-tests.yml @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/airgen/src/lib.rs b/airgen/src/lib.rs index 3cab99d4ce..aa3b112180 100644 --- a/airgen/src/lib.rs +++ b/airgen/src/lib.rs @@ -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 { diff --git a/backend/src/field_filter.rs b/backend/src/field_filter.rs index d5a9b675d0..d7fb1abd34 100644 --- a/backend/src/field_filter.rs +++ b/backend/src/field_filter.rs @@ -26,7 +26,9 @@ macro_rules! generalize_factory { backend_options: crate::BackendOptions, ) -> std::result::Result>, crate::Error> { use crate::Backend; - use std::{any::TypeId, boxed::Box, result::Result::Ok}; + use powdr_ast::analyzed::Analyzed; + use powdr_executor::constant_evaluator::VariablySizedColumn; + use std::{any::TypeId, boxed::Box, result::Result::Ok, sync::Arc, string::String}; let result = match TypeId::of::() { $( @@ -34,10 +36,15 @@ 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, - verification_key, verification_app_key, backend_options)?; - let result: Box> = result; - std::mem::transmute(result) + std::mem::transmute::>, Arc>>(pil), + std::mem::transmute::)>>, Arc)>>>(fixed), + output_dir, + setup, + verification_key, + verification_app_key, + backend_options + )?; + std::mem::transmute::>, Box>>(result) } } )* diff --git a/executor/src/witgen/identity_processor.rs b/executor/src/witgen/identity_processor.rs index a990915e32..650640ec27 100644 --- a/executor/src/witgen/identity_processor.rs +++ b/executor/src/witgen/identity_processor.rs @@ -196,6 +196,7 @@ impl<'a, 'b, 'c, T: FieldElement, Q: QueryCallback> 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. diff --git a/executor/src/witgen/machines/fixed_lookup_machine.rs b/executor/src/witgen/machines/fixed_lookup_machine.rs index 4f35bd0fae..5bf9d01216 100644 --- a/executor/src/witgen/machines/fixed_lookup_machine.rs +++ b/executor/src/witgen/machines/fixed_lookup_machine.rs @@ -77,7 +77,7 @@ impl IndexedColumns { /// `input_fixed_columns` is assumed to be sorted fn ensure_index(&mut self, fixed_data: &FixedData, 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; } diff --git a/executor/src/witgen/util.rs b/executor/src/witgen/util.rs index 381f242636..5ff7c2beba 100644 --- a/executor/src/witgen/util.rs +++ b/executor/src/witgen/util.rs @@ -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(expr: &Expression) -> Option<&AlgebraicReference> { if let Expression::Reference(p @ AlgebraicReference { next: false, .. }) = expr { diff --git a/executor/src/witgen/vm_processor.rs b/executor/src/witgen/vm_processor.rs index 22b9dc5236..d391ff5472 100644 --- a/executor/src/witgen/vm_processor.rs +++ b/executor/src/witgen/vm_processor.rs @@ -395,6 +395,7 @@ impl<'a, 'b, 'c, T: FieldElement, Q: QueryCallback> 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. diff --git a/riscv-executor/src/poseidon_gl.rs b/riscv-executor/src/poseidon_gl.rs index d6a4c49096..8731fdf7c5 100644 --- a/riscv-executor/src/poseidon_gl.rs +++ b/riscv-executor/src/poseidon_gl.rs @@ -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(inputs: &[F]) -> [F; 4] { assert_eq!(inputs.len(), 12); diff --git a/riscv/Cargo.toml b/riscv/Cargo.toml index 82402c9cdc..f04f3ef04c 100644 --- a/riscv/Cargo.toml +++ b/riscv/Cargo.toml @@ -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" diff --git a/riscv/src/asm/mod.rs b/riscv/src/asm/mod.rs index 3ab7ac4c86..dc7a749de8 100644 --- a/riscv/src/asm/mod.rs +++ b/riscv/src/asm/mod.rs @@ -50,11 +50,11 @@ impl RiscVProgram for AsmProgram { fn take_executable_statements( &mut self, - ) -> impl Iterator> { + ) -> impl Iterator, impl InstructionArgs>> { self.statements.iter().filter_map(process_statement) } - fn start_function(&self) -> &str { + fn start_function(&self) -> impl AsRef { START_FUNCTION } } @@ -62,7 +62,7 @@ impl RiscVProgram for AsmProgram { impl InstructionArgs for &[Argument] { type Error = &'static str; - fn l(&self) -> Result<&str, &'static str> { + fn l(&self) -> Result, ::Error> { const ERR: &str = "Expected: label"; match self { [l] => Ok(argument_to_symbol(l).ok_or(ERR)?), @@ -116,7 +116,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), + ::Error, + > { const ERR: &str = "Expected: register, register, label"; match self { [Argument::Register(r1), Argument::Register(r2), l] => { @@ -126,7 +131,9 @@ impl InstructionArgs for &[Argument] { } } - fn rl(&self) -> Result<(Register, &str), &'static str> { + fn rl( + &self, + ) -> Result<(code_gen::Register, impl AsRef), ::Error> { const ERR: &str = "Expected: register, label"; match self { [Argument::Register(r1), l] => Ok((*r1, argument_to_symbol(l).ok_or(ERR)?)), diff --git a/riscv/src/asm/parser.rs b/riscv/src/asm/parser.rs index 0ca41b6f4f..6b4b10a53e 100644 --- a/riscv/src/asm/parser.rs +++ b/riscv/src/asm/parser.rs @@ -6,6 +6,7 @@ use powdr_parser_util::handle_parse_error; use super::Statement; lalrpop_mod!( + #[allow(dead_code)] #[allow(clippy::all)] #[allow(clippy::uninlined_format_args)] riscv_asm, diff --git a/riscv/src/elf/mod.rs b/riscv/src/elf/mod.rs index ea12c5c246..b4e688f483 100644 --- a/riscv/src/elf/mod.rs +++ b/riscv/src/elf/mod.rs @@ -1,5 +1,4 @@ use std::{ - borrow::Cow, cell::Cell, cmp::Ordering, collections::{btree_map::Entry, BTreeMap, BTreeSet}, @@ -306,7 +305,7 @@ impl RiscVProgram for ElfProgram { fn take_executable_statements( &mut self, - ) -> impl Iterator, WrappedArgs>> { + ) -> impl Iterator, 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. @@ -370,7 +369,7 @@ impl RiscVProgram for ElfProgram { }) } - fn start_function(&self) -> Cow { + fn start_function(&self) -> impl AsRef { self.dbg.symbols.get_one(self.entry_point) } } @@ -385,14 +384,14 @@ struct WrappedArgs<'a> { impl<'a> InstructionArgs for WrappedArgs<'a> { type Error = String; - fn l(&self) -> Result { + fn l(&self) -> Result, 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)), } } @@ -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), ::Error> { match self.args { HighLevelArgs { imm: HighLevelImmediate::CodeLabel(addr), @@ -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), Self::Error> { match self.args { HighLevelArgs { imm: HighLevelImmediate::CodeLabel(addr), @@ -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), diff --git a/rust-toolchain.toml b/rust-toolchain.toml index fcc85b9ecb..4cef0b738f 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.77" +channel = "1.81"