This PR refactors `QuadraticSymbolicExpression`: I removed the reference
to
[`SymbolicExpression`](f60e9d9f69/constraint-solver/src/quadratic_symbolic_expression.rs (L70)).
It can represent values that are known at runtime, represented as an
expression. We don't need this in the context of APC: Variables are
either unknown or known at compile time, and therefore can be
represented as a `FieldElement` instead.
The idea is to introduce [this
trait](4989be08f3/constraint-solver/src/runtime_constant.rs (L11)),
which is implemented by `SymbolicExpression` and any `T: FieldElement`.
This way, we can continue to use the solver with
`QuadraticSymbolicExpression<SymbolicExpression<T, V>, V>` (equivalent
to the current `QuadraticSymbolicExpression<T, V>`) in the old JIT
pipeline and use the simpler `QuadraticSymbolicExpression<T, V>` in the
APC pipeline.
---------
Co-authored-by: chriseth <chriseth.github@gmail.com>
`try_into_i32` is wrong for small fields, it always returns a positive
number.
I checked where it's used, and I think it makes more sense to have
`to_signed_integer`, so I changed that.
The only place it's used now is in the mock prover: negative values are
interpreted as receives, positive as sends. This would break if we
sent/received more than p/2 times, which seems fine for now.
Update: now also used in the riscv executor
### PR: Update Powdr's `stwo` Dependency and Align Toolchain
This PR updates Powdr's `stwo` dependency to the latest version, which
now uses the `nightly-2024-12-17` Rust toolchain. To ensure
compatibility, Powdr's toolchain has also been aligned with this new
nightly version.
As part of this update:
- Several modifications were made to address stricter rules and lints
introduced by the newer version of Clippy.
- System dependencies, including `uuid-dev` and `libgrpc++-dev`, were
added to resolve build and runtime issues brought about by updated
dependencies and toolchain requirements.
This is mostly a reduced copy of the goldilocks implementation we
already have with the main difference that the division tries to perform
integer division first if it can be done without remainder.
This PR does two things:
- make `--export-csv` not export fixed columns, so it can be directly
used as external witness
- skip witness generation when all witness columns are provided
externally
The KoalaBear prime ($2^{31} - 2^{24} + 1$) is very similar to the
BabyBear prime ($2^{31} - 2^{27} + 1$), but allows for a more efficient
S-Box in Poseidon2 ($x^3$ instead of $x^7$). It should be slightly
faster to evaluate and significantly faster to prove recursively. For
some reason, I [saw a much more significant
advantage](https://gist.github.com/georgwiese/211d14c860c16cc4e1fbde7dc374af35)
when running the Plonky3 examples.
One downside of BabyBear is that it supports smaller traces, e.g. up to
$2^{23}$ rows with a degree bound of 3. For example,
`test_data/pil/fibonacci.pil` fails for larger instances.
This PR supports KoalaBear end-to-end:
```bash
cargo run -r --bin powdr-rs compile riscv/tests/riscv_data/keccak -o output --field kb
cargo run -r --features plonky3,halo2 pil output/keccak.asm -o output -f --field kb --prove-with plonky3
```
Replaces https://github.com/powdr-labs/powdr/pull/1790
This PR:
- [X] implements the basic RISCV BB machine without precompiles
- [X] runs the instruction tests with BB as well
- [x] runs the Rust tests except for continuations and tests that
require keccak, poseidon, ec ops
- [x] Missing: inputs and outputs with 2 limbs. There is already a
failing test that covers that.
---------
Co-authored-by: Leo Alt <leo@ethereum.org>
Extracted from https://github.com/powdr-labs/powdr/pull/1790.
This PR:
- creates the new `CompilerOptions` that encapsulate precompiles and
common options, needed by both cli-rs and tests
- splits codegen, runtime and bootloader into an outer facing dispatcher
based on the compiler options, and internal versions that currently are
just copies of the previous implementation that is specific to
Goldilocks and larger modulus.
After this PR, the riscv-bb PR will simply add analogous 17-bit codegen,
runtime and bootloader files.
This PR is only a copy paste from https://github.com/powdr-labs/plonky3
with the following exceptions:
- only the files that differ from uni-stark are copied over. Any
references to other modules are targeting upstream uni-stark
- the `preprocessed_width` function is moved to the `MultiStageAir`
trait from `BaseAir` to avoid changes to `p3-air`
- upstream uni-stark is nostd. Our wrapper uses things like hashmaps and
mutexes, so for now I commented out `nostd`
- `lib.rs` is a merge of the existing lib.rs and that of our uni-stark
fork
- the `prove` function is removed, as it is only there for compatibility
with uni-stark tests
- `FieldMerkleTreeMmcs` was
[renamed](84a13454ea)
to `MerkleTreeMmcs` in plonky3 since we forked it. Our configs use this
type and the name is updated accordingly
TODO:
- [x] extract rust update to separate PR due to the new ways clippy
complains
Plonky3 challenges implementation:
- implements the relevant traits from our uni-stark fork to support
challenges
- public inputs are only supported in the first stage
- the p3 dependency is pinned to a specific commit rather than `main`
because of a possible issue with buildjet which @lvella is investigating
---------
Co-authored-by: schaeff <thibaut@schaeff.fr>
Adds Plonky3's implementation of the Mersenne-31 field.
To test:
```
cargo run pil test_data/pil/fibonacci.pil -o output -f --field m31
```
The implementation is basically the same wrapper as for BabyBear, so I
moved the code to a macro and used it for both fields.
This PR adds `number::VariablySizedColumns`, which can store several
sizes of the same column. Currently, we always just have one size, but
as part of #1496, we can relax that.
Fixes#1494
- use cbor for witness and constant files (moving polygon serialisation
to the relevant backend)
- add `degree` field on `Symbol`, inherited from the namespace degree
- have each machine in witgen operate over its own degree
- fail in the backend if we have many degrees
Similar to #1193, but in here I am just interested in having it working
end-to-end, at least for a few cases, so that everybody can try it and
build upon.
<!--
Please follow this protocol when creating or reviewing PRs in this
repository:
- Leave the PR as draft until review is required.
- When reviewing a PR, every reviewer should assign themselves as soon
as they
start, so that other reviewers know the PR is covered. You should not be
discouraged from reviewing a PR with assignees, but you will know it is
not
strictly needed.
- Unless the PR is very small, help the reviewers by not making forced
pushes, so
that GitHub properly tracks what has been changed since the last review;
use
"merge" instead of "rebase". It can be squashed after approval.
- Once the comments have been addressed, explicitly let the reviewer
know the PR
is ready again.
-->
---------
Co-authored-by: Leo <leo@powdrlabs.com>
Remove dangling function in macro
Fix variable name in schema_update.rs
Read the version number at runtime instread of compile time
Fix version_number parsing and write new schema after it
Add schemars feature `preserve_order`
Change unwrap for expect in schema_update.rs
Moved schema binary in its own crate
Graceful error management in powdr-schema instead of panic
Better graceful error handling in the pipeline and the cli
Fix clippy
Put the magic number at the start of the serialized data
Revert magic at the start of the file
Moved the SerializedAnalyzed to the schemas crate
Changed serialized.rs to analyzed.rs
Changed the magic number to be the ASCII `powdr`
Fix pipeline name from file name with suffix
Variable naming
Replace `splitted` with `split`
Co-authored-by: Leo <leo@ethereum.org>
Fix clippy
Add test for serde of PIL
Changed the optimized PIL file extension to .pilo
Changed function names to reflect the operation on pil object