37 Commits

Author SHA1 Message Date
Linda Guiga
9d0101d652
Merge branch 'main' into 'constrain-genesis-state' 2023-09-25 10:19:13 -04:00
Robin Salen
9508b49090
Move byte packing / unpacking to a distinct table (#1212)
* Duplicate Memory trace into BytePacking one

* Add mload_32bytes instruction

* Use dedicated ops for byte packing trace

* Change witness generation to reduce memory reads for MLOAD_32BYTES

* Remove segments

* Fix stack

* Fix extra product when fixing CTL for byte_packing

* Write output value in trace

* Add constraints for BYTE_PACKING table

* Add recursive constraints for BYTE_PACKING table

* Fix constraints

* Add address in trace and constraints

* Add timestamp and batch inputs into BytePackingOp struct

* Add extra column

* Fix BytePackingStark CTL

* Tiny fix in witness generation

* Fix the Memory CTL

* Add constraints for the new columns

* Remove 1 column

* Remove limb columns

* Fix

* Fix recursive circuit of BytePackingTable

* Fix constraints

* Fix endianness

* Add MSTORE_32BYTES instruction and move decomposition to packing table

* Add missing constraint

* Add range-check for all bytes

* Add extra constraint

* Cleanup

* Remove REMAINING_LEN column

* Add corresponding implementations in interpreter

* Fix recursive version

* Remove debug assertion because of CI

* Remove FILTER column

* Update new test from rebasing

* Reorder STARK modules to match TraceCheckPoint ordering

* Address comments

* Pacify clippy

* Add documentation to the packing module

* Fix doctest
2023-09-13 04:45:37 +10:00
Linda Guiga
4d7d9ffa3c
Constrain genesis block's state trie. 2023-09-11 19:09:12 +01:00
Linda Guiga
42f7038031
Add blockhash sys opcode 2023-09-07 09:43:59 +01:00
Linda Guiga
b07644368f
Add missing links between public values 2023-08-31 13:40:13 +01:00
Robin Salen
7196714734
Update range from ReceiptTrie PR 2023-08-25 09:58:20 -07:00
wborgeaud
df07ae093a
Write trie roots to memory before kernel bootstrapping (#1172)
* Write trie roots

* Remove CPU trace length

* Update hash_initial/final_tries

* Fix tests

* Minor

* PR feedback
2023-08-09 10:15:13 +02:00
Robin Salen
9f8c152222
Remove unused attributes 2023-08-02 08:54:20 -04:00
Hamy Ratoanina
7a882d0a64
Clippy 2023-07-27 18:27:09 -04:00
Linda Guiga
6253a68ea5
Change public values into public inputs 2023-07-27 18:27:08 -04:00
Hamy Ratoanina
1590c1d0be
Fix indices in CTL functions 2023-07-27 18:27:05 -04:00
Linda Guiga
06037f814f
Fix the memory CTL and implement the verifier memory bus
Co-authored-by: Hamy Ratoanina <hamy.ratoanina@toposware.com>
2023-07-27 18:20:03 -04:00
Robin Salen
0a59aa6e6f
Remove need for matching start ranges 2023-07-06 16:26:00 -04:00
Hamish Ivey-Law
c134b59763
Cross-table lookup for arithmetic stark (#905)
* First draft of linking arithmetic Stark into the CTL mechanism.

* Handle {ADD,SUB,MUL}FP254 operations explicitly in `modular.rs`.

* Adjust argument order; add tests.

* Add CTLs for ADD, MUL, SUB, LT and GT.

* Add CTLs for {ADD,MUL,SUB}MOD, DIV and MOD.

* Add CTLs for {ADD,MUL,SUB}FP254 operations.

* Refactor the CPU/arithmetic CTL mapping; add some documentation.

* Minor comment fixes.

* Combine addcy CTLs at the expense of repeated constraint evaluation.

* Combine addcy CTLs at the expense of repeated constraint evaluation.

* Merge `*FP254` CTL into main CTL; rename some registers.

* Connect extra argument from CPU in binary ops to facilitate combining with ternary ops.

* Merge modular ops CTL into main CTL.

* Refactor DIV and MOD code into its own module.

* Merge DIV and MOD into arithmetic CTL.

* Clippy.

* Fixes related to merge.

* Simplify register naming.

* Generate u16 BN254 modulus limbs at compile time.

* Clippy.

* Add degree bits ranges for Arithmetic table.
2023-05-11 03:29:06 +10:00
Robin Salen
5de5bfb5e4
Move serialization files into dedicated module 2023-04-20 07:59:37 +02:00
Robin Salen
0e465c1ccf
Customize range specification for AllRecursiveCircuits 2023-04-20 07:59:36 +02:00
Robin Salen
f71139d934
Add serialisation support for gates, generators, and various structs
Co-authored-by: Sebastien La Duca <sladuca777@gmail.com>
2023-04-20 07:59:36 +02:00
Robin Salen
9ee47ab745
Move HashConfig into GenericConfig associated types 2023-04-01 09:54:14 -04:00
Robin Salen
e857c020bf
Make hash functions generic 2023-03-31 18:55:06 -04:00
BGluth
3c7bc8835c Removed a type alias
- Was conflicting with the trait `PartialTrie` and also making the types
  harder to follow.
2023-03-28 14:38:58 -06:00
BGluth
60ad9e03ba Bumped eth_trie_utils to 0.5.0 2023-03-27 17:30:11 -06:00
Daniel Lubarov
373421a1d1 Fix tests - need to supply empty code 2023-03-16 14:11:40 -07:00
Daniel Lubarov
44c77f5583 Input addresses 2023-03-16 14:08:31 -07:00
Daniel Lubarov
87be6097a1 Feedback 2023-01-04 14:50:15 -08:00
Daniel Lubarov
5df784416a Add aggregation circuit
Which can be used to compress two proofs into one. Each inner proof can be either
- an "EVM root" proof (which typically proves one transaction, though it could be 0 or more)
- another aggregation proof
2023-01-03 15:46:59 -08:00
Daniel Lubarov
18ce7ea547 Disable slow test on CI 2023-01-01 23:42:05 -08:00
Daniel Lubarov
595e751ac1 Shrink STARK proofs to a constant degree
The goal here is to end up with a single "root" circuit representing any EVM proof. I.e. it must verify each STARK, but be general enough to work with any combination of STARK sizes (within some range of sizes that we chose to support). This root circuit can then be plugged into our aggregation circuit.

In particular, for each STARK, and for each initial `degree_bits` (within a range that we choose to support), this adds a "shrinking chain" of circuits. Such a chain shrinks a STARK proof from that initial `degree_bits` down to a constant, `THRESHOLD_DEGREE_BITS`.

The root circuit then combines these shrunk-to-constant proofs for each table. It's similar to `RecursiveAllProof::verify_circuit`; I adapted the code from there and I think we can remove it after. The main difference is that now instead of having one verification key per STARK, we have several possible VKs, one per initial `degree_bits`. We bake the list of possible VKs into the root circuit, and have the prover indicate the index of the VK they're actually using.

This also partially removes the default feature of CTLs. So far we've used filters instead of defaults. Until now it was easy to keep supporting defaults just in case, but here maintaining support would require some more work. E.g. we couldn't use `exp_u64` any more, since the size delta is now dynamic, it can't be hardcoded. If there are no concerns, I'll fully remove the feature after.
2023-01-01 23:11:39 -08:00
Daniel Lubarov
569cd058a0 log level 2022-12-09 21:48:36 -08:00
Daniel Lubarov
6f841678a5 More timing for zkEVM proofs 2022-12-09 21:48:36 -08:00
Daniel Lubarov
1303a83f7f Misc witness generation fixes 2022-12-03 21:09:57 -08:00
Daniel Lubarov
7293054062 Warnings 2022-12-02 14:49:32 -08:00
Daniel Lubarov
a63b73a851 Misc fixes 2022-12-02 13:56:52 -08:00
Daniel Lubarov
afb3e4b1e1 Misc work on witness generation 2022-11-30 14:58:40 -08:00
Daniel Lubarov
2d92b4b6b4 Fix warning 2022-11-30 10:11:48 -08:00
Daniel Lubarov
55e5d56795 Trie fix 2022-11-29 08:52:37 -08:00
Daniel Lubarov
9f9143d6f6 Finish some misc storage logic 2022-10-02 11:14:19 -07:00
Daniel Lubarov
1dbd96ba20 Empty txn list test (disabled for now) 2022-09-30 12:48:42 -07:00