Commit Graph
63 Commits
Author SHA1 Message Date
Robin Salen fa9aae1fdc Remove duplicate code 2023-09-06 15:15:33 -04:00
Linda Guiga 6bd17e29c1 Apply comments 2023-09-06 01:19:31 +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
Linda Guiga 5b962f3c06 Change receipts_trie in basic_smart_contract and self_balance_gas_cost 2023-08-22 20:00:49 +01:00
Linda Guiga ad9796cb10 Fix tests and address comments 2023-08-22 20:00:49 +01:00
c0b4f155f4 Implement receipts and logs
Co-authored-by: Hamy Ratoanina <hamy.ratoanina@toposware.com>
Co-authored-by: Linda Guiga <lindaguiga3@gmail.com>
2023-08-22 20:00:49 +01:00
Robin Salen 68bb49671d Update tests to have a blockgaslimit fitting u32s 2023-08-18 19:02:06 -04:00
Robin Salen 89e62e554a Use Keccak config in simple tests 2023-08-15 10:48:40 -04: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 GuigaandHamy Ratoanina 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
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 SalenandSebastien La Duca 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