120 Commits

Author SHA1 Message Date
Alonso González
f49fbc8e9b
Transactions trie support (#1232)
* Implement transactions.

* Fix receipts and transactions

* Add some fixes

* Update tests

* Remove changes added for debugging purposes only

* Clippy

* Remove additional debug changes

* Remove unused

* Apply comments

---------

Co-authored-by: Linda Guiga <lindaguiga3@gmail.com>
Co-authored-by: Robin Salen <salenrobin@gmail.com>
2023-09-27 10:00:16 -04:00
Robin Salen
03a9558198
Handle additional panics (#1250)
* Remove some panic risks

* Remove more panics

* Handle jump with empty stack

* Handle last expect

* More panics

* Handle from_big_endian

* Handle from_little_endian

* Remove remaining risky as_usize()

* Remove explicit panic

* Clippy

* Handle unwrap

* Make error messages more explicit

* Simplify u256 to usize conversion
2023-09-26 11:13:57 -04:00
Robin Salen
f3ea95cacc
Merge branch 'main' into error_vs_panic 2023-09-18 09:59:52 -04:00
Robin Salen
8903aec129
Change padding rule for CPU (#1234)
* Change padding rule for CPU

* Disable memory channels for padding rows

* Apply some of Jacqueline's comments

* Update halt routine

* Add clarifying comment

* Redundant constraints and padding bug

* Revert "Remove is_bootstrap_kernel column"

This reverts commit 49d92cb8f1b0ae9de76872f76af4429699ff692f.

* Make halt_state implicit

* Move halting logic constraints to dedicated module

* Include new module

* Update some comments
2023-09-15 17:46:58 -04:00
Linda Guiga
d4a8026bf9
Combine mstore_general and mload_general into one flag (#1188)
* Combine mstore_general and mload_general into one flag

* Add comments and make stack constraints cleaner.

* Fix number of native instructions

* Ordering

* Cleanup

* Update calls to stack eval from latest main

---------

Co-authored-by: Robin Salen <salenrobin@gmail.com>
2023-09-14 19:51:02 -04:00
Robin Salen
06bc73f7ea
Combine arithmetic flags on the CPU side (#1187)
* Combine FP254 flags

* Combine basic binary ops together and do CTL with opcode value

* Combine ternary ops together

* Combine MUL DIV and MOD

* Combine shift operations

* Combine byte with other binary ops

* Fix tests

* Clean leftover comment

* Update from latest main

* Put the 'is_simulated' flag inside the Operation enum

* Cleaner way to handle "simulated" operations SHL and SHR.

* Fix comments.

* Minor: suggestion for re-expressing `combined_ops`.

* Update comment

---------

Co-authored-by: Hamish Ivey-Law <hamish@ivey-law.name>
2023-09-14 10:36:48 -04:00
Robin Salen
5a1b05acfb
Remove risks of panic 2023-09-12 19:23:16 -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
Nicholas Ward
a4e6c6ae90 clippy suggestions 2023-09-08 10:41:01 -07:00
Nicholas Ward
7415810f19 clippy suggestions 2023-09-08 10:40:31 -07:00
Robin Salen
d0379e9428
Apply Nick's comment 2023-09-07 15:35:34 -04:00
Robin Salen
8dcb29e5ad
Display actual trace lengths instead of number of ops 2023-09-06 12:31:17 -04:00
Robin Salen
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
Linda Guiga
4e5f6e7e63
Apply comment 2023-08-21 23:12:25 +01:00
Linda Guiga
10bbda039b
Remove unnecessary changes in the Operation enum 2023-08-21 23:12:25 +01:00
Linda Guiga
c3cb227896
Combine get_context and set_context into one flag 2023-08-21 23:12:25 +01:00
Hamy Ratoanina
815a02ab75
Remove is_cpu_cycle 2023-08-15 15:22:41 -04:00
Hamy Ratoanina
12f379f99b
Combine jump flags 2023-08-14 19:08:24 -04:00
Robin Salen
7829dccf83
Combine EQ and ISZERO flags 2023-08-12 11:08:01 -04:00
Robin Salen
e10eaad09b
Combine all logic flags together 2023-08-11 10:17:45 -04:00
Robin Salen
ee9ce4c59d
Combine AND and OR flags in CpuStark 2023-08-09 16:05:24 -04:00
Robin Salen
5f4b15af7a
Connect SHL/SHR operations to the Arithmetic table (#1166)
* Add corresponding arithmetic operations to shift ones

* Include SHL/SHR in the arithmetic CTL

* Prevent overflow

* Expand documentation for ctl_data_ternops()
2023-08-09 23:17:06 +10:00
Linda Guiga
017e621778
Set exception flag to 1. 2023-08-07 18:39:55 +01: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
Linda Guiga
7437fe2b51
Fill modulus in cpu row for Fp254 operations. (#1122) 2023-07-14 06:53:06 +10:00
Jacqueline Nabaglo
dca50adfac
Merge pull request #1119 from mir-protocol/jacqui/topos-protocol/stack_len_bounds_aux_error
Fix `generate_exception` (#1115 replacement)
2023-07-10 15:37:21 -04:00
Jacqueline Nabaglo
6b493d6faa Remove redundant case (error in kernel mode) 2023-07-08 16:52:26 -04:00
Jacqueline Nabaglo
1664ab4408
Merge pull request #1112 from topos-protocol/fix-generate-jump
Fix jump operation generation
2023-07-08 16:38:35 -04:00
Linda Guiga
5bff02a198
Fix generate_set_context 2023-07-07 15:37:47 +01:00
Hamy Ratoanina
325cd2f7c1
Compute stack_len_bounds_aux correctly in generate_error 2023-07-06 16:24:45 -04:00
Linda Guiga
224064bf05
Fix jump operation generation 2023-07-06 13:57:41 -04:00
Jacqueline Nabaglo
cedeff5219 PUSH0 2023-06-13 13:29:30 -07:00
Jacqueline Nabaglo
9cc353607e
Merge pull request #1082 from mir-protocol/jacqui/simplify-stack-bounds
Simplify stack bounds constraints
2023-06-13 10:59:33 -07:00
wborgeaud
ba705703a5
Use current context for pairing memory (#1091) 2023-06-12 22:55:38 +02:00
Jacqueline Nabaglo
6920992e01 Simplify stack bounds constraints 2023-06-07 18:27:23 -07:00
Jacqueline Nabaglo
0117541909
Merge pull request #1071 from mir-protocol/jacqui/bad-opcode-witness-generation
Error handling
2023-06-07 15:49:07 -07:00
Jacqueline Nabaglo
ae290dbf11 William PR comments 2023-06-07 14:58:59 -07:00
Robin Salen
2cf31f5f2d
Prevent shift ops from panicking (#1073) 2023-06-06 17:39:36 +10:00
Jacqueline Nabaglo
c773476cb9 Minor docs 2023-06-04 12:40:34 -07:00
Jacqueline Nabaglo
3ecf530956 Minor bugfixes 2023-06-04 10:05:28 -07:00
Jacqueline Nabaglo
448bc719d8 Lints 2023-06-03 18:46:24 -07:00
Jacqueline Nabaglo
7ab0bba559
Merge branch 'main' into jacqui/bad-opcode-witness-generation 2023-06-02 21:34:52 -07:00
Jacqueline Nabaglo
b7220428b3 Error handling 2023-06-02 15:51:26 -07:00
Hamish Ivey-Law
0d819cf888
Implement EVM BYTE operation (#1059)
* Initial implementation of BYTE.

* Large index constraints; byte range check (hat-tip to Jacqui)

* Implement recursive circuit version.

* Rebind variable to avoid exceeding degree limit.

* Integrate BYTE with arithmetic stark and witness generation.

* Clippy.

* Document verification proof; miscellaneous tidying.

* Update CTL mapping.

* Reverse argument order.

* Avoid undesired doctest.

* Address Jacqui's comments.

* Address remaining comments from Jacqui.
2023-06-03 02:16:45 +10: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
Nicholas Ward
8d738729e8
Merge pull request #1015 from mir-protocol/clippy-fix
Fix for updated clippy
2023-05-01 11:07:06 -07:00
Nicholas Ward
8358b85d9f remove unneeded mut 2023-05-01 08:36:16 -07:00
wborgeaud
4ad8520e34
SNARKV precompile (#1010)
* Serialize impls, and use in Fibonacci example

* seralizing

* cleanup

* don't serialize challenges

* deterministic build function

* cleanup

* cleanup

* cleanup

* fix

* cleanup

* fmt

* rename

* Unpacking and storing inputs

* Finish snarkv interface

* Failing test

* move serialization to separate example

* Imaginary part in front of real

* serialize ProofChallenges

* remove build_without_randomizing (no longer needed)

* fix

* Fix kernel peak

* Fix stack comments

* Minor

* SSTORE gas (#1007)

* Update storage access list and sload

* Add noop for sys_sstore

* Comments

* Fix access list test

* PR feedback

---------

Co-authored-by: Nicholas Ward <npward@berkeley.edu>
2023-04-27 19:21:26 +02:00
Hamy Ratoanina
938e3bd5da
Set stack_len_bounds_aux properly 2023-04-11 16:38:59 -04:00
Robin Salen
0529fa06a5
Change endianness within generate_keccak_general 2023-04-09 17:36:39 -04:00