47 Commits

Author SHA1 Message Date
wborgeaud
6e3036017e
Support for type-2 transactions (#1052)
* Type-2 txns

* Minor

* Minor

* Fix add11_yml block metadata

* Fix simple_transfer test

* Minor
2023-05-23 15:06:26 +02:00
BGluth
10e6c76842 TrieInputs now uses H256 for storage account addresses
- Slightly easier for us if we use `H256` instead of `H160`.
2023-05-16 13:51:03 -06: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
Daniel Lubarov
8562abe0f7 Disable a couple tests
They're slow on CI, and `add11_yml` seems like a better integration test.
2023-04-17 17:32:31 -07: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
Daniel Lubarov
31cd0f6445 Remove dbg 2023-03-30 17:24:12 -07:00
Daniel Lubarov
9ae69a7c21 Add an integration test for the selfBalanceGasCost case 2023-03-30 16:10:02 -07: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
a05ed9fc3a Fix clobbering of RLP data memory 2023-03-19 11:49:15 -07: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
d5003b7cf2 Gas fees go to coinbase 2023-03-12 23:13:19 -07:00
Daniel Lubarov
84fbbbf410 Couple minor fixes 2023-03-10 17:02:15 -08:00
Daniel Lubarov
137bc78565 Prep for publishing to crates.io 2023-01-30 13:18:06 -08:00
Daniel Lubarov
f2e40541d9 Increment sender nonce + buy gas 2023-01-17 23:57:53 -08:00
Daniel Lubarov
df2ba7a384 Basic smart contract test 2023-01-14 21:18:58 -08: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
b8e97aaaf8 Fix logic and Keccak CTLs
Lots of little bugs!

- The Keccak sponge table's padding logic was wrong, it was mixing up the number of rows with the number of hashes.
- The Keccak sponge table's Keccak-looking data was wrong - input to Keccak-f should be after xor'ing in the block.
- The Keccak sponge table's logic-looking filter was wrong. We do 5 logic CTLs for any final-block row, even if some of the xors are with 0s from Keccak padding.
- The CPU was using the wrong/outdated output memory channel for its Keccak sponge and logic CTLs.
- The Keccak table just didn't have a way to filter out padding rows. I added a filter column for this.
- The Keccak table wasn't remembering the original preimage of a permutation; lookers were seeing the preimage of the final step. I added columns for the original preimage.
- `ctl_data_logic` was using the wrong memory channel
- Kernel bootloading generation was using the wrong length for its Keccak sponge CTL, and its `keccak_sponge_log` was seeing the wrong clock since it was called after adding the final bootloading row.
2022-12-19 15:42:59 -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
1c78204df0 fix eth_to_wei 2022-12-09 19:57:02 -08:00
Daniel Lubarov
7557f320d4 Fix to add_eth
It was creating a new account with the hash of an empty storage trie, when really it should be a pointer to an empty storage trie. We can use 0 as this pointer since `@SEGMENT_TRIE_DATA[0] = 0 = @MPT_NODE_EMPTY`.

Also a couple tweaks that helped me debug, like moving the memory value range checks from the interpreter into `MemoryState`, so they're done in actual witness generation as well as interpreter tests.
2022-12-09 18:58:48 -08:00
Daniel Lubarov
f4ab65f973 Fixes to get test_simple_transfer working 2022-12-08 23:27:20 -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
Daniel Lubarov
c7b03cfe9a More MPT logic 2022-09-24 20:49:19 -07:00
BGluth
8fb1e4e760 Added a mapping between code hashes and contract byte code
Added a mapping between an account's `codehash` field and the actual contract byte code in `GenerationInputs`.
2022-09-21 16:46:18 -06:00
BGluth
d7d8803d0a Replaced PartialTrie definitions with eth-trie-utils crate
- There were enough dependencies that it made sense to move
  `PartialTrie` logic to its own crate.
2022-09-19 11:05:48 -06:00
Daniel Lubarov
a4300758b4 Fix test 2022-08-25 23:38:39 -07:00
Daniel Lubarov
b829b44dcf Fix test 2022-08-25 22:11:25 -07:00
Daniel Lubarov
aa87f2c3ba Public memory 2022-08-25 20:19:18 -07:00
Daniel Lubarov
ff228c9386 Have witness generation take a partial trie instead of Merkle proofs 2022-08-24 20:43:49 -07:00
Daniel Lubarov
5d74a19ad6 Add test (won't work for a while, but to illustrate) 2022-07-04 18:10:03 -07:00