129 Commits

Author SHA1 Message Date
Hamy Ratoanina
4b40bc0313
Remerge context flags (#1292)
* Remerge context flags

* Apply comments and revert some unwanted changes
2023-10-30 12:56:11 -04:00
Linda Guiga
666a155d4a
Remove new_stack_top_channel from StackBehavior (#1296) 2023-10-26 17:52:54 -04:00
Robin Salen
29005dc586
Use SUBMOD in Kernel 2023-10-21 11:44:23 -04:00
Linda Guiga
817e3e78e0
Combine DUP and SWAP (#1254)
* Combine dup and swap flags.

* Add comments
2023-10-18 17:32:43 -04:00
Hamy Ratoanina
1d60431992
Store top of the stack in memory channel 0 (#1215)
* Store top of the stack in memory channel 0

* Fix interpreter

* Apply comments

* Remove debugging code

* Merge commit

* Remove debugging comments

* Apply comments

* Fix witness generation for exceptions

* Fix witness generation for exceptions (again)

* Fix modfp254 constraint
2023-10-11 16:28:49 -04:00
Robin Salen
8a5eed9d1c
Fix shift constraint (#1280) 2023-10-09 07:41:30 -04:00
Linda Guiga
e58d7795f8
Remove reg_preimage columns in KeccakStark (#1279)
* Remove reg_preimage columns in KeccakStark

* Apply comments

* Minor cleanup
2023-10-06 15:49:57 -04:00
Linda Guiga
0de6f94962
Remove extra SHL/SHR CTL. (#1270)
* Remove extra shift CTL.

* Change order of inputs for the arithmetic shift operations. Add SHR test. Fix max number of bit shifts. Cleanup.

* Fix SHR in the case shift >= 256

* Limit visibility of helper functions
2023-10-05 09:56:56 -04:00
Robin Salen
0f19cd0dbc
Make gas fit in 2 limbs (#1261)
* Make gas fit in 2 limbs

* Fix recursive challenger

* Fix indices

* Add clarifying comments on ranges supported

* Add mention to revert before production
2023-09-29 14:47:23 -04:00
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