43 Commits

Author SHA1 Message Date
Linda Guiga
e41435e927
Add memory checks for prover_input, as well as range_checks for prover_input, syscalls/exceptions (#1168)
* Add memory checks for prover_input and range_checks for prover_input, syscalls and exceptions

* Replace u32 by U256, and remove extra CTLs

* Add column in ArithmeticStark to use ctl_arithmetic_base_rows for is_range_check

* Fix CTLs and circuit constraint.

* Fix CTLs
2023-11-07 15:52:00 -05:00
shuoer86
d941539bb8
Fix typos in comments 2023-11-04 23:29:42 +08:00
shuoer86
a0ea26f4b2
Fix typos in comments 2023-11-04 23:07:36 +08:00
Linda Guiga
413620751e
Combine JUMPDEST and KECCAK_GENERAL flags. (#1259)
* Combine JUMPDEST and KECCAK_GENERAL flags.

* Apply comments
2023-11-01 10:43:09 -04:00
Linda Guiga
6332900d86
Combine PUSH0 and PC flags. (#1256) 2023-10-30 15:43:06 -04:00
Robin Salen
0d97b93af5
Add some documentation in EVM crate (#1295)
Co-authored-by: Linda Guiga <linda.guiga@toposware.com>
2023-10-30 14:28:24 -04:00
Linda Guiga
af4935cde8
Merge NOT and POP flags. (#1257)
* Merge NOT and POP flags

* Add comments

* Disable remaining memory channels for POP

* Apply comments

* Fix stack
2023-10-30 14:05:54 -04:00
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
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
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
Hamy Ratoanina
0b5ac312c0
Merge pull request #1203 from topos-protocol/constrain_nv_stack_len
Constrain next row's stack length
2023-09-14 22:42:32 +02: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
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
Hamy Ratoanina
8beba56903
Constrain next row's stack length 2023-08-28 16:32:04 -04: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
f01098a783
Constrain keccak general 2023-08-01 11:16:45 -04:00
Nicholas Ward
14c4011593
Revert "clippy fixes" 2023-07-07 12:16:43 -07:00
Nicholas Ward
96fbecd9c7 ignoring where appropriate (for izip), fixing elsewhere 2023-07-05 17:40:48 -07:00
Jacqueline Nabaglo
cedeff5219 PUSH0 2023-06-13 13:29:30 -07:00
Jacqueline Nabaglo
6920992e01 Simplify stack bounds constraints 2023-06-07 18:27:23 -07:00
Jacqueline Nabaglo
b7220428b3 Error handling 2023-06-02 15:51:26 -07:00
4l0n50
ba844a2403 Change shl/shr behavior as well as BASIC_TERNARY_OP 2023-04-12 17:35:32 +02:00
Jacqueline Nabaglo
f3946f75bf
Gas constraints (#880)
* Gas constraints

* Bugfix

* make test pass post rebase
2023-02-14 22:30:19 -08:00
Hamish Ivey-Law
40866e775a
Refactor arithmetic operation traits (#876)
* Use U256s in `generate(...)` interfaces; fix reduction bug modular.

* Refactor `Operation` trait.

* Rename file.

* Rename `add_cc` things to `addcy`.

* Clippy.

* Simplify generation of less-than and greater-than.

* Add some comparison tests.

* Use `PrimeField64` instead of `RichField` where possible.

* Connect `SUBMOD` operation to witness generator.

* Add clippy exception.

* Add missing verification of range counter column.

* Fix generation of RANGE_COUNTER column.

* Address William's PR comments.
2023-02-10 23:07:57 +11:00
Daniel Lubarov
df2ba7a384 Basic smart contract test 2023-01-14 21:18:58 -08:00
Jacqueline Nabaglo
b6bc018cba
Simplify JUMP/JUMPI constraints and finish witness generation (#846)
* Simplify `JUMP`/`JUMPI` constraints and finish witness generation

* Constrain stack
2022-12-11 11:08:33 -08:00
Jacqueline Nabaglo
1732239a00
Constrain memory channels in JUMPDEST (#844) 2022-12-11 11:02:19 -08:00
Jacqueline Nabaglo
249e50ebcb
Get/set context (#843) 2022-12-11 10:59:14 -08:00
Jacqueline Nabaglo
29644e5111
Implement PC instruction (#847)
* Implement `PC` instruction

* lints
2022-12-11 10:41:32 -08:00
Jacqueline Nabaglo
95eeed46f0
Memory load/store constraints (#839) 2022-12-09 10:35:00 -08:00
Daniel Lubarov
526dc9bb77 Flush out operation list 2022-11-30 21:00:48 -08:00
Jacqueline Nabaglo
626c2583de
Combine all syscalls into one flag (#802)
* Combine all syscalls into one flag

* Minor: typo

* Daniel PR comments
2022-11-07 12:29:28 -08:00
Jacqueline Nabaglo
ec3391f9c4
Add Fp254 ops to the CPU table (#779)
* Add Fp254 ops to the CPU table

* Add forgotten file
2022-10-13 14:02:19 -07:00
Jacqueline Nabaglo
d5cf53c227
Constraints for dup/swap (#743)
* Constraints for dup/swap

* Minor comments

* Daniel comments

* More comments
2022-10-03 12:31:43 -07:00
Daniel Lubarov
9e483528d3 MPT hashing logic, part 3 2022-10-02 09:11:39 -07:00
Jacqueline Nabaglo
e978425b26
Connect stack to memory (#735)
* Connect stack to memory

* Daniel PR comment
2022-09-28 15:18:56 -07:00