Commit Graph

150 Commits

Author SHA1 Message Date
Leo
ce673bb121 Fix arith machine for bus linker mode (#2297) 2025-01-02 13:58:29 +00:00
Leo
c8d2703d86 free input data (#2239)
This PR allows for free runtime data besides free compile time data,
based on `initial_memory`.

- Replaces `cbor` by `bincode` in prover queries (bincode is more
efficient and cbor crashed with `u128`)
- Allows the prover to pass a runtime initial memory, only possible with
continuations (from https://github.com/powdr-labs/powdr/pull/2251, was
already merged into here, see commits list)
- Changes the `powdr` lib, which already always uses continuations, to
always use this mechanism for prover data
- Provides a new stdin-stream-like function to read inputs in sequence,
like other zkVMs.
- The function above is called `read_stdin` which I'm not super happy
with, ideally it'd just be called `read` but the QueryCalldata function
is already called `read`. I think we could just keep this as is and
change later.

---------

Co-authored-by: Lucas Clemente Vella <lvella@powdrlabs.com>
2024-12-30 19:56:46 +00:00
Georg Wiese
409ecbba42 Reduce POWDR_JIT_OPT_LEVEL in CI (#2286)
This should speed up the test. If I remember correctly, with this
compilation is only 2-3s for Poseidon (instead of ~10min). At runtime,
it is about as "fast" as runtime witgen.
2024-12-29 11:47:37 +00:00
ShuangWu121
2e978667b2 Update stwo dependency to the latest version (#2264)
### 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.
2024-12-23 11:48:52 +00:00
Georg Wiese
a737ed851f Call JIT (#2242)
This PR puts together the pieces to run compile-time witgen for block
machines. There are still many cases where it doesn't work yet, in which
case it falls back to run-time solving. These cases should be fixed in
future PRs.

It also fixes two bugs:
- When multiplying two affine expression, the case where one of them is
zero is now handled properly.
- `WitgenInference` now handles intermediate columns.

Note that this PR could slow down witgen by attempting to compile code
once per incoming connection and input / output combination, in block
machines. I think this should be negligible though and it gives us that
much of the new pipeline is already running in the tests and elsewhere.

# Benchmark results

I tested the code with different opt levels on a benchmark that computes
ca. $2^{16}$ Poseidon hashes.

## Baseline

```
 == Witgen profile (393220 events)
   93.0% (   30.8s): Secondary machine 0: main_poseidon (BlockMachine)
    4.1% (    1.4s): witgen (outer code)
    2.3% ( 750.8ms): Main machine (Dynamic)
    0.6% ( 204.4ms): FixedLookup
    0.0% (   3.2µs): range constraint multiplicity witgen
  ---------------------------
    ==> Total: 33.109672458s
```

## JIT (opt level 1)

```
 == Witgen profile (393222 events)
   52.3% (    7.7s): JIT-compilation
   32.0% (    4.7s): Secondary machine 0: main_poseidon (BlockMachine)
    9.2% (    1.3s): witgen (outer code)
    5.1% ( 748.3ms): Main machine (Dynamic)
    1.4% ( 213.5ms): FixedLookup
    0.0% ( 417.0ns): range constraint multiplicity witgen
  ---------------------------
    ==> Total: 14.729149333s
```

## JIT (opt level 3)

```
== Witgen profile (393222 events)
   94.6% (  107.9s): JIT-compilation
    3.4% (    3.9s): Secondary machine 0: main_poseidon (BlockMachine)
    1.1% (    1.3s): witgen (outer code)
    0.7% ( 746.5ms): Main machine (Dynamic)
    0.2% ( 204.1ms): FixedLookup
    0.0% ( 542.0ns): range constraint multiplicity witgen
  ---------------------------
    ==> Total: 114.036571291s
```
2024-12-18 20:27:49 +00:00
Leo
a5df8bc035 Lift some tests from nightly to pr-tests (#2216) 2024-12-17 09:50:58 +00:00
Thibaut Schaeffer
670802aaee Fix book deploy again (#2218)
Turns out `git worktree` does not track the remote branch, so the
benchmarks are not there.
Revert to what we did before, and explicitly restore the benchmarks from
the remote `gh-pages` branch.
2024-12-10 14:09:38 +00:00
chriseth
0a12ffe188 Remove dependencies on build (#2217)
These runs make no use of the artefacts created in build and do a full
re-build, so we might as well run them from the start.
2024-12-10 13:28:44 +00:00
Leo
c40099e8b9 fix udeps and add to pr-tests (#2214)
This PR fixes udeps again and finally adds it to the pr-tests so it
fails in a PR already.
2024-12-10 11:52:53 +00:00
Thibaut Schaeffer
8450f6a1ce Fix book deploy (#2215)
Avoid deleting `.git` etc
2024-12-10 11:17:05 +00:00
Thibaut Schaeffer
ad858a1d7d Run cargo bench in PR CI tests and report result to PR and Github Pages (#2198)
Run benchmarks in PRs, fail and warn on the PR if we got more than 20%
slower, add benchmark results to https://docs.powdr.org/dev/bench/
2024-12-09 14:51:20 +00:00
Leo
60860b7317 Expose stdout/stderr in Session (#2189)
This PR:
- Makes explicit the notion that 0=stdin, 1=stdout, 2=stdout in the
QueryCallback's "FS"
- Exposes the outputs in Session
- Removes printing to stdout and stderr in the callback itself. This is
now the responsibility of the host if needed.
- Adds the Fibonacci test with stdout to CI using the write mechanism

The idea is that after this we should also expose the proof's publics
and make a stream mechanism for inputs and outputs
2024-12-04 20:57:53 +00:00
Leo
4e785d6de2 fix nightly again (#2195)
This PR moves nightly back to GH with Ubuntu 24.04 and the old settings.
The nightly test passed for this branch in here:
https://github.com/powdr-labs/powdr/actions/runs/12154934614
2024-12-04 14:20:03 +00:00
Leo
c9d9e3f4ea Fix ci again (#2193)
The new Ubuntu used in CI now requires new packages for estark. This is
already in nightly but broke the normal cache last night
2024-12-04 09:33:54 +00:00
Leo
a124dc6265 update CI ubuntu (#2187) 2024-12-03 17:32:45 +00:00
Leo
d0e49ceb3d install riscv assembler for nightly tests (#2179) 2024-11-29 19:44:15 +00:00
Lucas Clemente Vella
2049a358a9 Inlining system calls when possible. (#2087)
Solves #2040.
2024-11-15 22:03:58 +00:00
Lucas Clemente Vella
047f2721f5 Fixing cache build. (#2016) 2024-11-01 16:47:47 +00:00
Lucas Clemente Vella
5b0d9a0536 Fixing CI to an specific ubuntu image (#1993) 2024-10-30 16:10:47 +00:00
Lucas Clemente Vella
cf099fc109 Builds on better runner. (#1988)
Also, shallow git clones and more verbose build output, to make it
easier to diagnose why something was rebuilt.
2024-10-30 11:59:58 +00:00
chriseth
835213bb22 Move some more tests to nightly. (#1986) 2024-10-30 10:09:08 +00:00
Lucas Clemente Vella
fe3a4f0ef4 Attempt to make cache more useful for PR builds. (#1959)
The same build steps is now performed in both cache build and PR build.
2024-10-25 21:23:38 +00:00
ShuangWu121
d4ea38837b change toolchain to nightly (#1908)
related to [this PR](https://github.com/powdr-labs/powdr/pull/1898)
we need to change to nightly toolchain to integrate stwo

I kept the toolchain related to riscv to be "nightly-2024-08-01" as it
is handled separately in workflow, so I made the least change to make
stwo integrate-able for now.

fix some clippy issues about the comment format on some files.

---------

Co-authored-by: chriseth <chris@ethereum.org>
2024-10-16 20:01:45 +00:00
Leo
44beb1745b RISCV BabyBear machine (#1889)
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>
2024-10-16 16:49:38 +00:00
Lucas Clemente Vella
d91e4cafa2 Replacing the old cache without deleting it first. (#1909)
Working on the assumption that there is a race condition between the
delete command and the push new cache command, that is why some days we
have no cache.
2024-10-15 15:53:51 +00:00
Leo
b16709d180 fix publics bug halo2 (#1814)
Fixes a bug where circuits with publics can't be verified properly. This
was caused by a difference in the circuit when the verification key is
generated (without witnesses) vs when the user requests a proof (with).

---------

Co-authored-by: Leo Alt <leo@ethereum.org>
2024-10-10 05:45:32 +00:00
Lucas Clemente Vella
7b7e727a81 Using Warpbuild instead of BuildJet (#1860)
BuildJet cache is broken and they won't answer support ticket.
2024-10-02 13:07:53 +00:00
Lucas Clemente Vella
a68d0b7100 Remove RISC-V assembler (#1852)
Removal of a quite important feature.

Better get many approvals.
2024-10-02 10:50:23 +00:00
Thibaut Schaeffer
0358dec845 Upgrade Rust to 1.81 (#1846)
This is a prerequisite for #1845 

TODO:
- [x] narrow down or remove the dead_code exception
2024-09-27 14:08:26 +00:00
Lucas Clemente Vella
83e2c841e6 Trying buildjet CI runner (#1777) 2024-09-11 08:53:12 +00:00
chriseth
72cacd2c78 Use cache v4 (#1774) 2024-09-10 11:06:30 +00:00
chriseth
e061ad0685 Use checkout v4 (#1773) 2024-09-10 11:05:51 +00:00
chriseth
2b5d2e1ca1 Use artifact v4 actions (#1772) 2024-09-10 09:55:04 +00:00
Leandro Pacheco
7fe5fb4d02 run pr-tests on self hosted runner (#1734) 2024-09-04 14:46:30 +00:00
Leandro Pacheco
19503e1cbb cancel old workflows for the same branch (#1740)
when a new commit to branch triggers a build and tests, cancel any
currently running (now obsolete) workflows for the same branch
2024-08-31 11:51:10 +00:00
Georg Wiese
34fdbd1ccd RISC-V machine: Use dynamic VADCOP (#1683)
Builds on #1687
Fixed #1572 

With this PR, we are using dynamic VADCOP in the RISC-V zk-VM.

There were a few smaller fixes needed to make this work. In summary, the
changes are as follows:
- We set the degree the main machine to `None`, and all fixed lookup
machines to the appropriate size. As a consequence, the CPU, all block
machines & memory have a dynamic size.
- As a consequence, I had to adjust some tests (set the size of all
machines, so they can still be run with monolithic provers) *and* was
able to remove the `Memory_<size>` machines 🎉
- With the main machine being of flexible size, the prover can chose for
how long to run it. We run it for `1 << (MAX_DEGREE_LOG - 2)` steps and
compute the bootloader inputs accordingly. With this choice, we can
guarantee that the register memory (which can be up to 4x larger than
the main machine) does not run out of rows.

Note that while we do access `MAX_DEGREE_LOG` in a bunch of places now,
this will go away once #1667 is merged, which will allow us to configure
the degree range in ASM and for each machine individually.

### Example:
```bash
export MAX_LOG_DEGREE=18
cargo run -r --bin powdr-rs compile riscv/tests/riscv_data/many_chunks -o output --continuations
cargo run -r --bin powdr-rs execute output/many_chunks.asm -o output --continuations -w
cargo run -r --features plonky3,halo2 prove output/many_chunks.asm -d output/chunk_0 --field gl --backend plonky3-composite
```

This leads to the following output:
```
== Proving machine: main (size 65536), stage 0
==> Proof stage computed in 1.918317417s
== Proving machine: main__rom (size 8192), stage 0
==> Proof stage computed in 45.847375ms
== Proving machine: main_binary (size 1024), stage 0
==> Proof stage computed in 27.718416ms
== Proving machine: main_bit2 (size 4), stage 0
==> Proof stage computed in 15.280667ms
== Proving machine: main_bit6 (size 64), stage 0
==> Proof stage computed in 17.449875ms
== Proving machine: main_bit7 (size 128), stage 0
==> Proof stage computed in 20.717834ms
== Proving machine: main_bootloader_inputs (size 262144), stage 0
==> Proof stage computed in 524.013375ms
== Proving machine: main_byte (size 256), stage 0
==> Proof stage computed in 17.280167ms
== Proving machine: main_byte2 (size 65536), stage 0
==> Proof stage computed in 164.709625ms
== Proving machine: main_byte_binary (size 262144), stage 0
==> Proof stage computed in 504.743917ms
== Proving machine: main_byte_compare (size 65536), stage 0
==> Proof stage computed in 169.881542ms
== Proving machine: main_byte_shift (size 65536), stage 0
==> Proof stage computed in 146.235916ms
== Proving machine: main_memory (size 32768), stage 0
==> Proof stage computed in 326.522167ms
== Proving machine: main_poseidon_gl (size 16384), stage 0
==> Proof stage computed in 1.324662625s
== Proving machine: main_regs (size 262144), stage 0
==> Proof stage computed in 2.009408667s
== Proving machine: main_shift (size 32), stage 0
==> Proof stage computed in 13.71825ms
== Proving machine: main_split_gl (size 16384), stage 0
==> Proof stage computed in 108.019334ms
Proof generation took 7.364567s
Proof size: 8432928 bytes
Writing output/chunk_0/many_chunks_proof.bin.
```

Note that `main_bootloader_inputs` is still equal to the maximum size,
we should fix that in a following PR!
2024-08-15 11:27:52 +00:00
Georg Wiese
2b9984c9d6 Run Halo2 MockProver even when POWDR_GENERATE_PROOFS=false (#1629)
This is similar to how we always run PILCOM in the Goldilocks setting,
and shouldn't be expensive!
2024-08-13 15:05:17 +00:00
Georg Wiese
d87a33cd2c Make MAX_DEGREE_LOG configurable (#1677)
Pulled out of #1676, where it helps making the tests run faster.

I think this could possibly be removed by #1667 again.
2024-08-12 11:36:06 +00:00
Lucas Clemente Vella
231be6bfdc fake std support (#1641)
We don't plan to actually support all the features of `std`, but this
will allow Powdr to build and execute `std` crates that limits
themselves to the features we do support (which, as of this PR, is
reading and writing to specific file descriptors). Only works via ELF
path.
2024-08-05 12:06:24 +00:00
Lucas Clemente Vella
138b0fa697 Updating RISC-V toolchain (#1642) 2024-08-01 11:07:35 +00:00
chriseth
d63525fb16 Avoid needless witgen and only generate proofs in CI. (#1621) 2024-07-29 16:22:58 +00:00
chriseth
bc77897910 Mark slow tests (#1622)
This marks more tests as ignored because they are slow.

It also adds a list of "nightly tests", which are ignored tests that are
explicitly excluded in the regular PR runs (but executed in the nightly
run that runs all tests).
2024-07-29 13:15:45 +00:00
chriseth
49cf6d5725 Create separate runner for examples. (#1617)
The test runner only has the nextest archived test runner, running the
examples triggers a full rebuild.
2024-07-26 07:50:40 +00:00
chriseth
add4b42a5c Matrix test run. (#1618) 2024-07-26 07:24:55 +00:00
Lucas Clemente Vella
b06fa28c7e Translating RISC-V programs directly from ELF files. (#1453)
There are many advantages in using standard assemblers and linkers,
like:
- maturity;
- more complete support of assembly language, which in turn allows for
support to more high level languages and compilers;
- link-time optimizations;
- no need to deal with language edge cases (our assembler and linker
deals with a number of rust stuff, but it would need even more to
support `std`).

But it comes with a cost, as we need to lift references to text data
back into labels, (because powdr operates on a higher abstraction
level), and to do that, we need the ELF file to either be a PIE
(Position Independent Executable), or to still have the linkage
relocation tables (option `--emit-relocs` of GNU and LLVM linkers).

---------

Co-authored-by: Leo Alt <leo@ethereum.org>
Co-authored-by: Leo <leo@powdrlabs.com>
2024-07-08 22:08:41 +00:00
Lucas Clemente Vella
21ddd28cc7 Fixing broken example. (#1284)
And minor test name change.
2024-04-18 15:28:35 +00:00
Lucas Clemente Vella
ac9dcfda87 zkEVM prover backend (#1211)
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>
2024-04-18 09:16:09 +00:00
Lucas Clemente Vella
9d104c2088 Removing pub and "test_" from test functions. (#1274)
One is unecessary, the other is redundant.

Co-authored-by: Lucas Clemente Vella <lucas.vella@powdrlabs.com>
2024-04-15 20:01:47 +00:00
Georg Wiese
de76e46bc2 Rebalance slow tests in CI (#1273)
Moves tests from "subset1" to "subset2" (which is still slightly faster)
2024-04-15 15:52:25 +00:00
Thibaut Schaeffer
ef2409b008 Upgrade rust to 1.77 (#1253)
Required for #1158
2024-04-04 20:17:48 +00:00