63 Commits

Author SHA1 Message Date
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
16227f90b9
Merge syscall and exceptions constraints. 2023-07-24 15:40:48 +01: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
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
Hamy Ratoanina
c8637635b9
Remove dummy_yield_constr 2023-04-13 15:55:46 -04:00
Hamy Ratoanina
4946c3d5fd
Merge branch 'main' into stack_bound 2023-04-13 15:47:27 -04:00
4l0n50
ba844a2403 Change shl/shr behavior as well as BASIC_TERNARY_OP 2023-04-12 17:35:32 +02:00
Hamy Ratoanina
938e3bd5da
Set stack_len_bounds_aux properly 2023-04-11 16:38:59 -04:00
Hamy Ratoanina
310107f218
Fix decode constraint 2023-04-07 17:06:57 -04:00
Jacqueline Nabaglo
f3946f75bf
Gas constraints (#880)
* Gas constraints

* Bugfix

* make test pass post rebase
2023-02-14 22:30:19 -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
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
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
f4ab65f973 Fixes to get test_simple_transfer working 2022-12-08 23:27:20 -08:00
Daniel Lubarov
f4fdb6a12f Fix 2022-12-03 12:02:51 -08:00
Daniel Lubarov
b8b2fefe52 Use Keccak sponge table for bootloading
And get rid of the deprecated Keccak memory table.
2022-12-03 11:21:31 -08:00
Daniel Lubarov
20183c260b Fixes & re-enabling most constraints 2022-12-02 22:47:07 -08:00
Daniel Lubarov
bfa680fcea Fix recursive constraints 2022-12-02 19:43:01 -08:00
Daniel Lubarov
7293054062 Warnings 2022-12-02 14:49:32 -08:00
Daniel Lubarov
1f92d73177 Misc fixes 2022-12-02 14:31:18 -08:00
Daniel Lubarov
206f527338 Merge branch 'main' into jacqui/witness-generation 2022-11-30 10:09:57 -08:00
Jacqueline Nabaglo
87a9c002c9 Compiler errors + refactor 2022-11-28 13:19:40 -08:00
Hamish Ivey-Law
1c87fbb712
EVM shift left/right operations (#801)
* First parts of shift implementation.

* Disable range check errors.

* Tidy up ASM.

* Update comments; fix some .sum() expressions.

* First full draft of shift left/right.

* Missed a +1.

* Clippy.

* Address Jacqui's comments.

* Add comment.

* Fix missing filter.

* Address second round of comments from Jacqui.
2022-11-09 10:47:15 +11: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
Jacqueline Nabaglo
e978425b26
Connect stack to memory (#735)
* Connect stack to memory

* Daniel PR comment
2022-09-28 15:18:56 -07:00
Jacqueline Nabaglo
084700a7f4
Memory channel for program counter (#717) 2022-09-22 18:09:23 -07:00
Jacqueline Nabaglo
cae5f4870c
Stack pointer + underflow/overflow checks (#710)
* Stack pointer + underflow/overflow checks

* Daniel comments

* Extra docs
2022-09-10 13:20:30 -07:00
Jacqueline Nabaglo
013bf6471d
Transpose memory columns (make it an array of channel structs) (#700) 2022-08-26 22:05:16 -07:00
Jacqueline Nabaglo
f48de368a9
Make jumps, logic, and syscalls read from/write to memory columns (#699)
* Make jumps, logic, and syscalls read from/write to memory columns

* Change CTL convention (outputs precede inputs)

* Change convention so outputs follow inputs in memory channel order
2022-08-26 14:39:39 -07:00
Daniel Lubarov
aa87f2c3ba Public memory 2022-08-25 20:19:18 -07:00
Daniel Lubarov
522cac5e15 Keccak memory stark 2022-08-24 09:29:17 -07:00
Daniel Lubarov
782d7d0e18
Revert "Support accessing local row in CTLs" 2022-08-23 12:22:54 -07:00
Daniel Lubarov
a37dec9881 Support accessing previous row in CTLs 2022-08-22 15:20:10 -07:00
Jacqueline Nabaglo
b98dd47820
Permission levels, jumps, traps (#653)
* Permission levels, jumps, traps

* Tests passing

* PR comments + documentation

* Docs + minor bugfixes

* Tests

* Use already-defined `stop` and `exception` (but renamed to `sys_stop`, `fault_exception`)

* Daniel comments
2022-08-16 09:46:10 -07:00
Daniel Lubarov
b2f09881c0 Merge branch 'main' into cpu_shared_cols 2022-07-28 13:41:46 -07:00
Jacqueline Nabaglo
c160c4032d
Inter-row program counter constraints (#639)
* Beginning of control flow support

* Fixes to halt spin loop
2022-07-27 11:36:33 -07:00
Daniel Lubarov
3d83d63f0b Shared CPU columns
I was thinking we could have two sets of shared columns:
- First, a set of "core" columns which would contain instruction decoding registers during an execution cycle, or some counter data during a kernel bootloading cycle.
- Second, a set of "general" columns which would be more general-purpose. For now it could contain "looking" columns for most CTLs (Keccak, arithmetic and logic; NOT memory since memory can be used simultaneously with the others). It could potentially be reused for other things too, such as the registers used for `EQ` and `IS_ZERO` (but I know it's nontrivial to share those since we would need to use lower-degree constraints, so I wouldn't bother for now).

This PR implements just the latter. If it looks good I'll proceed with the former afterward.
2022-07-18 12:15:41 -07:00
Daniel Lubarov
ef3addea2c Merge branch 'main' into evm_generation 2022-07-11 17:24:37 -07:00
Nicholas Ward
afc5a4dc4f fixes 2022-07-11 10:44:48 -07:00
Nicholas Ward
6655ee68e4 restored timestamp column to CTL 2022-07-11 10:44:48 -07:00
Nicholas Ward
a98f267ff0 initial change 2022-07-11 10:44:48 -07:00
Daniel Lubarov
5d74a19ad6 Add test (won't work for a while, but to illustrate) 2022-07-04 18:10:03 -07:00