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 idea of this PR is to add the most commonly used workflow to the
outer facing `powdr` crate so that users have quick access to the prover
functionalities for Rust programs.
The changes to `powdr/src/lib.rs` wrap those common functionalities
(compiling Rust to powdr-asm, compiling powdr-asm to PIL, witgen, proof
generation with continuations) into simple function calls and hide the
Pipeline type a bit by using the new `Session` trait.
The end result is that a user can do the following:
```rust
use powdr::Session;
use std::path::Path;
fn main() {
env_logger::init();
let some_data = vec![1, 2, 3, 4, 5];
let out_path = Path::new("powdr-target");
let mut session = Session::new("./guest", out_path).write(1, &some_data);
// Dry run to test execution
session.run();
// Compute the proof
session.prove();
}
```
TODO:
- [x] Decide on the abstraction
- [x] Try to remove some clones from the continuations setup
- [x] Make sure the `prove` function re-uses artifacts if available
(like setup), and re-runs if needed
- [x] Should we have a separate `setup` call? I feel like it should be
automatic with the item above.
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
```
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.
As suggested by @lvella .
I'm not too sure about this actually. I agree that compiling Rust ->
powdr-asm should have a separate pipeline somewhere, but before we could
do Rust -> proof in a single command, and with this we can't anymore.
- Do we expose the `prove` command and everything else here as well?
That'd be a lot of duplicated code.
- Do we force the user to first run `powdr-rs compile <rust_proj>` then
`powdr pil/prove ...`? That's potentially worse UX than right now.
- Do we keep all the Rust stuff in the `cli` crate?
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>
- Refactor `CoProcessors` into a `Runtime` with submachines and syscalls
- Calls into prover functionality and submachines done via `ecall`
instead of "call symbol replacement"
- Call `poseidon_gl` machine with riscv registers by using the stack
(~50% speedup in many_chunks benchmark)
- New `riscv-syscalls` crate keeps the list of syscalls and related
constants
# Context
Now powdr can allow handle log in cli option.
Example
```bash
powdr --log DEBUG pil test_data/asm/book/hello_world.asm --field bn254 --force --inputs 0
```
--log value is LevelFilter
```rust
pub enum LevelFilter {
/// A level lower than all log levels.
Off,
/// Corresponds to the `Error` log level.
Error,
/// Corresponds to the `Warn` log level.
Warn,
/// Corresponds to the `Info` log level.
Info,
/// Corresponds to the `Debug` log level.
Debug,
/// Corresponds to the `Trace` log level.
Trace,
}
```
Fixes#164
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