Commit Graph

1958 Commits

Author SHA1 Message Date
chriseth
7ecf0de94b Change intermediate column syntax. (#1630)
Fixes #1190 
Fixes https://github.com/powdr-labs/powdr/issues/1488

```
// creates intermediate column.
let x: inter = ...
// same here, expects an array on the rhs
let x: inter[k] = ...

// Creates an intermediate column, this is printed from Analyzed
col x = ...;
// Creates an array of intermediate columns, this is printed from analyzed and it's actually new syntax.
col x[k] = ...;

// old syntax for intermediate columns, this just defines a "generic variable" after the change,
// essentially an intermediate column that is always inlined.
let x: expr = ...;
```

---------

Co-authored-by: Leo <leo@powdrlabs.com>
2024-08-03 13:12:57 +00:00
chriseth
10be8ab355 Improve evaluator (#1648)
Extracted from @Schaeff `s https://github.com/powdr-labs/powdr/pull/1623

---------

Co-authored-by: schaeff <thibaut@schaeff.fr>
2024-08-02 21:18:45 +00:00
topanisto
9a292720c1 Plonky public values constrained by fixed columns (#1610)
Addressing #1607 -- changing the implementation for constraining public
values to reflect changes from #1543, as well as a slight refactoring of
PowdrCircuit struct to include publics.
2024-08-01 14:20:27 +00:00
Georg Wiese
307e514a4f Plonky3 and Halo2: Use bincode for serialization (#1644)
This brings down proof and verification key sizes.

I didn't touch the eStark backends, because I think they need the JSON
file and I also got some strange errors doing the same there (couldn't
deserialize a serialized `StarkInfo`).
2024-08-01 13:40:29 +00:00
Thibaut Schaeffer
bda1b8f29a Enable the linker to output dynamic namespaces (#1640)
What we can have after this PR:
- only dynamic namespaces
- dynamic main, others dynamic or static

What we still cannot have:
- static main and another machines dynamic

The change to `_linker_first_step` can be reverted after #1565
2024-08-01 13:22:53 +00:00
chriseth
f2ac21f32f Add set_hint to asm. (#1643) 2024-08-01 12:59:38 +00:00
Lucas Clemente Vella
138b0fa697 Updating RISC-V toolchain (#1642) 2024-08-01 11:07:35 +00:00
Georg Wiese
39a148508e CompositeBackend: Fix machine stats (#1637)
Previously, arrays of columns were counted as 1.
2024-07-31 17:25:03 +00:00
Georg Wiese
b59b2836c0 Activate parallel feature for Plonky3 (#1638)
On my system, this brings proof time for Keccak with `plonky3-composite`
on main from 180s -> 22s.
2024-07-31 16:47:08 +00:00
chriseth
98ebf3fbc6 Set hint (#1609) 2024-07-31 16:19:34 +00:00
Lucas Clemente Vella
ce6cb0bc6c Added halt system call. (#1636)
Will be needed to support std.
2024-07-31 15:06:21 +00:00
Lucas Clemente Vella
3889906383 Saving one deep clone. (#1635) 2024-07-31 13:21:52 +00:00
Lucas Clemente Vella
84fe12cc58 More sane multimap when parsing debug symbols from Elf. (#1616) 2024-07-30 14:58:04 +00:00
chriseth
4e6187a200 Fix type display on error. (#1631) 2024-07-30 13:57:17 +00:00
Gastón Zanitti
2e7c473413 Impl parsing (#1490)
This PR splits from the main Trait implementation PR
https://github.com/powdr-labs/powdr/pull/1450 to simplify the review
process.

It includes only the parsing of the impls (trait parsing PR here: #1489
) and some functionality necessary for the code to compile.

---------

Co-authored-by: chriseth <chris@ethereum.org>
2024-07-30 13:49:58 +00:00
Lucas Clemente Vella
e58ddac313 Aggregating challenges of all proofs (#1603)
Co-authored-by: Georg Wiese <georgwiese@gmail.com>
2024-07-29 21:06:04 +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
onurinanc
bc5f71e109 fix sub implementation in link_merging.asm test (#1600)
The previous version of link_merging.asm is not working correctly since
the `operation sub<1>` implementation is wrong. With this PR, `operation
sub<1>` implementation is fixed.
2024-07-29 11:05:27 +00:00
chriseth
5ecd36c662 Adjust log positions. (#1626) 2024-07-29 06:16:16 +00:00
Leo
86be6d2509 Make main instantiate all submachines and pass them as arguments (#1606) 2024-07-26 13:23:31 +00:00
chriseth
b71ab8ad8d Assign local types (#1620) 2024-07-26 10:53:00 +00:00
chriseth
d1924ecd29 Fixed cols in functions (#1545) 2024-07-26 09:31:52 +00:00
chriseth
ac3b96eecf Even more quick tests (#1613) 2024-07-26 08:16: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
chriseth
2ff93f4894 Fix clippy with disabled halo2 (#1614) 2024-07-25 19:31:48 +00:00
chriseth
995f61e02c Speed up some more quick tests (#1612) 2024-07-25 19:10:06 +00:00
chriseth
67742879ed Speed up quick tests (#1611) 2024-07-25 17:42:20 +00:00
Georg Wiese
58d405a2ce Add test using a bus in each machine (#1605)
I started this in order to test #1603. However, due to #1604, currently
only one machine has a bus so far. This should be fixed as part of
#1604.

Then, what we would expect is that both machines have the same final
accumulator values, assuming challenges are shared across machines.
2024-07-25 13:16:26 +00:00
Lucas Clemente Vella
204b9e4ff3 DWARF debug symbols parsing in ELF files (#1564)
Conversion from ELF now has feature parity with conversion from
assembly, so I am setting it as the default.

---------

Co-authored-by: Leandro Pacheco <contact@leandropacheco.com>
2024-07-25 09:09:03 +00:00
Leo
3932a6838f Some simplficiations for the regs in mem ricsv machine (#1598) 2024-07-24 15:37:51 +00:00
Georg Wiese
5c31155a7e Add dynamic VADCOP witness generation (for block machines) (#1595)
Another step towards #1572
Builds on #1574

I modified witness generation as follows:
- Each machine keeps track of its current size; whenever a fixed column
value is read, it has to pass the requested size as well.
- If fixed columns are available in several sizes, witness generation
starts out by using the largest size, as before
- When finalizing a block machine, it "downsizes" the machine to the
smallest possible value

Doing this for other machine types (e.g. VM, memory, etc) should be done
in another PR.

In the `vm_to_block_dynamic_length.pil` example, witness generation now
pics the minimum size instead of the maximum size for `main_arith`

```
$ cargo run pil test_data/pil/vm_to_block_dynamic_length.pil -o output -f --field bn254 --prove-with halo2-mock-composite
...
== Proving machine: main (size 256)
==> Machine proof of 256 rows (0 bytes) computed in 60.174583ms
size: 256
Machine: main__rom
== Proving machine: main__rom (size 256)
==> Machine proof of 256 rows (0 bytes) computed in 33.310292ms
size: 32
Machine: main_arith
== Proving machine: main_arith (size 32)
==> Machine proof of 32 rows (0 bytes) computed in 2.766541ms
```
2024-07-23 12:21:33 +00:00
Leo
8f72dd436a reduce the degree of compiled asm to pil so it works with P3 (#1596)
Depends on https://github.com/powdr-labs/powdr/pull/1594

---------

Co-authored-by: schaeff <thibaut@schaeff.fr>
2024-07-23 12:11:04 +00:00
Georg Wiese
7a1ccfcead Add dynamic VADCOP proving (no witgen yet) (#1574)
Fixes #1496
Also, a step towards #1572

This PR implements the steps needed in `CompositeBackend` to implement
dynamic VADCOP.

In summary:
- If a machines size (a.k.a. "degree") is set to `None`, fixed columns
are computed in all powers of too in some hard-coded range. This fixes
#1572. As a result, machines with a size set to `None` are available in
multiple sizes. If the size is explicitly set by the user, the machine
is only available in that one size.
- Note that the ASM linker still sets the size of machines without a
size. So, currently, this can only happen when coming from PIL directly.
- `CompositeBackend` instantiates a new backend for each machine *and
size*:
  - The verification key contains a key for each machine and size.
- When proving, it it uses the backend of whatever size the witness has.
The size chosen is also stored in the proof.
  - When verifying, the verification key of the reported size is used.
- Witness generation currently chooses the largest available size. This
will change in a future PR.

This is an example:
```
$ cargo run pil test_data/pil/vm_to_block_dynamic_length.pil -o output -f --field bn254 --prove-with halo2-mock-composite
...
== Proving machine: main (size 256)
==> Machine proof of 256 rows (0 bytes) computed in 209.101166ms
== Proving machine: main__rom (size 256)
==> Machine proof of 256 rows (0 bytes) computed in 226.87175ms
== Proving machine: main_arith (size 1024)
==> Machine proof of 1024 rows (0 bytes) computed in 432.807583ms
```
2024-07-23 09:41:44 +00:00
Thibaut Schaeffer
5bfeea8b58 Extract range checks from riscv into std machines (#1594)
Also, allow vms to have links outside instructions.

---------

Co-authored-by: Leo Alt <leo@ethereum.org>
2024-07-23 09:22:42 +00:00
Georg Wiese
de2905de69 Add data structures for variably-sized fixed columns (#1542)
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.
2024-07-22 16:10:23 +00:00
Leo
d8218a2cae Registers in memory (#1443)
Fixes #1492

---------

Co-authored-by: schaeff <thibaut@schaeff.fr>
2024-07-22 13:17:02 +00:00
onurinanc
60acaec5fc Remove some unused code in some tests & std (#1592) 2024-07-22 11:50:09 +00:00
Thibaut Schaeffer
8b32dcaa50 Extract ROM machine (#1555)
This PR continues the task to replace lookups by links. The advantages
of this approach are:
- with a link, the two machines can have different degrees and be proven
separately
- with a lookup, only a monolithic proof works
- some backends such as Plonky3 do not support lookups
- this is backwards compatible, since in the monolithic setting, links
are turned into lookups

In the compiler, we currently reduce each machine to another machine
which has only pil code and links. To this end, in the case of virtual
machines, we encode the program in fixed columns. This change introduces
a separate machine to store the ROM. Therefore, each VM gets turned into
not one, but two machines:

```
machine MyVM {
}
```

becomes

```
machine MyVM {
   MyVMROM _rom;
}

machine MyVMROM {
}
```

We introduce a new name alongside the original name, which pollutes the
module. When raised, it was decided that we should not currently allow
defining the ROM machine *inside* the VM.

A better long term solution would be to have a generic `ROM` machine in
the stdlib which can be instantiated with the fixed columns which encode
the program, using them in the `get_line` operation. There are a few
missing pieces in the asm language to enable that.
2024-07-22 10:42:32 +00:00
Georg Wiese
7936a5a09d Test re-parsing of all test files after optimization (with blacklist) (#1590)
A new iteration of #1476.

These added tests demonstrate that #1488 is *mostly* solved (see [this
comment](https://github.com/powdr-labs/powdr/issues/1488#issuecomment-2220759508)
though): We parse, optimize, serialize, and re-parse all test files. A
small number of test files need to be blacklisted for reasons explained
in the comments.
2024-07-19 13:06:16 +00:00
Georg Wiese
ebc4d56e7b CompositeBackend: Print maximum degree per machine (#1589)
Computes & prints the maximum degree of any identity for every machine.

Example output for Keccak:
```
Instantiating a composite backend with 7 machines:
* main:
  * Number of witness columns: 247
  * Number of fixed columns: 195
  * Maximum identity degree: 4
  * Number of identities:
    * Polynomial: 68
    * Plookup: 16
* main_binary:
  * Number of witness columns: 9
  * Number of fixed columns: 2
  * Maximum identity degree: 2
  * Number of identities:
    * Polynomial: 8
* main_binary_byte_binary:
  * Number of witness columns: 1
  * Number of fixed columns: 4
  * Maximum identity degree: 1
  * Number of identities:
    * Polynomial: 1
* main_memory:
  * Number of witness columns: 9
  * Number of fixed columns: 2
  * Maximum identity degree: 3
  * Number of identities:
    * Polynomial: 12
    * Plookup: 2
* main_shift:
  * Number of witness columns: 8
  * Number of fixed columns: 3
  * Maximum identity degree: 2
  * Number of identities:
    * Polynomial: 7
* main_shift_byte_shift:
  * Number of witness columns: 1
  * Number of fixed columns: 5
  * Maximum identity degree: 1
  * Number of identities:
    * Polynomial: 1
* main_split_gl:
  * Number of witness columns: 9
  * Number of fixed columns: 9
  * Maximum identity degree: 3
  * Number of identities:
    * Polynomial: 7
    * Plookup: 1
```
2024-07-17 17:48:57 +00:00
Thibaut Schaeffer
6ae4c0ba24 Turn range check lookups into links (#1557) 2024-07-17 13:54:51 +00:00
Georg Wiese
e63c59be09 Always test PILCOM + Composite (#1587)
This PR contains the following changes:
- I renamed a bunch of functions `verify_*` to `run_pilcom_*`, because I
think it better describes what they do
- They all call `run_pilcom_with_backend_variant`, which works analogous
to `gen_estark_proof_with_backend_variant` and
`test_halo2_with_backend_variant`
- In functions like `run_pilcom_test_file` (previously
`verify_test_file`), which are used for many tests, we now test both the
monolithic and composite backend variant (but share the generated
witness & constants). This is anlogous to `gen_estark_proof` and
`test_halo2`
- In the RISC-V tests, we only test the composite variant, because with
registers in memory (#1443) we don't expect the monolithic backend
variant to work anymore.
2024-07-17 13:40:08 +00:00
onurinanc
4f873e6205 Implement Basic Bus (#1566)
Related to the issue of implementing basic bus (#1497), I have
implemented basic bus together with an example
(`permutation_via_bus.asm`) as specified inside the issue.

Currently, `test_data/std/bus_permutation_via_challenges.asm` works as
intended (To make it sound, stage(1) witness columns need to be exposed
publicly and verifier needs to check such as `out_z1 + out_z2 = 0`) We
can now check using RUST_LOG=trace and adding the final z1 and z2 is
equal to 0.

However, `test_data/std/bus_permutation_via_challenges_ext.asm` is not
working correctly as intended. This will be fixed with the following
commits.
2024-07-17 10:50:57 +00:00
Georg Wiese
9483a26f41 Block machine: report side effect (fixes TODO) (#1563)
Since #1385 is resolved, we can fix this TODO.
2024-07-17 09:51:10 +00:00
Georg Wiese
718459ba69 CompositeBackend: Improve logging (#1581)
This should help us to collect more data and get a better understanding
of the factors that drive proof times and sizes.

Example:
```
$ cargo run pil test_data/asm/block_to_block.asm -o output -f --field bn254 --prove-with halo2-composite
...
Instantiating a composite backend with 2 machines:
* main:
  * Number of witness columns: 3
  * Number of fixed columns: 4
  * Number of identities:
    * Polynomial: 3
* main_arith:
  * Number of witness columns: 4
  * Number of fixed columns: 0
  * Number of identities:
    * Polynomial: 2
== Proving machine: main (size 8)
Starting proof generation...
Generating PK for snark...
Generating proof...
Time taken: 151.890834ms
Proof generation done.
==> Machine proof of 1753 bytes computed in 292.9045ms
== Proving machine: main_arith (size 8)
Starting proof generation...
Generating PK for snark...
Generating proof...
Time taken: 154.678333ms
Proof generation done.
==> Machine proof of 1625 bytes computed in 276.353375ms
Proof generation took 0.5694918s
Proof size: 3402 bytes
Writing output/block_to_block_proof.bin.
```
2024-07-17 09:38:18 +00:00
Leo
e6bc15d491 change riscv tests to use composite backends (#1583)
Also in preparation for registers in memory.
Removing the `public`s for continuations as discussed with @georgwiese ,
since those are not sound anyway and we might change it completely soon.
2024-07-17 09:35:41 +00:00
Lucas Clemente Vella
eb3bdfbe60 Fixing atomic instructions in ELF translate. (#1582)
Fixes EVM test.
2024-07-16 12:02:32 +00:00
Georg Wiese
bd4ac9c059 Fix vm_to_block_different_length test (#1580)
Fixes one of the tests that failed in the [last nightly
run](https://github.com/powdr-labs/powdr/actions/runs/9949789019/job/27486609397).

To reproduce:
```
IS_NIGHTLY_TEST=true PILCOM=$(pwd)/pilcom/ cargo nextest run --all --features halo2 -E 'test(=vm_to_block_different_length)'
```
2024-07-16 09:52:19 +00:00