2173 Commits

Author SHA1 Message Date
Daniel Lubarov
83643aa584
Merge pull request #612 from mir-protocol/bootstrapping_continued
Continue work on bootstrapping
2022-07-15 13:03:16 -07:00
Daniel Lubarov
134c66b37d Missing TODO 2022-07-15 13:02:56 -07:00
Daniel Lubarov
2e3ad0142e
Merge pull request #613 from mir-protocol/asm_rep
Add `%rep` syntax for repeating a block
2022-07-14 22:47:34 -07:00
Daniel Lubarov
6d69e14a89 Add %rep syntax for repeating a block
Same syntax as NASM.
2022-07-14 14:58:18 -07:00
Daniel Lubarov
0802d6c021 Continue work on bootstrapping
The kernel is hashed using a Keccak based sponge for now. We could switch to Poseidon later if our kernel grows too large.

Note that we use simple zero-padding (pad0*) instead of the standard pad10* rule. It's simpler, and we don't care that the prover can add extra 0s at the end of the code. The program counter can never reach those bytes, and even if it could, they'd be 0 anyway given the EVM's zero-initialization rule.

In one CPU row, we can do a whole Keccak hash (via the CTL), absorbing 136 bytes. But we can't actually bootstrap that many bytes of kernel code in one row, because we're also limited by memory bandwidth. Currently we can write 4 bytes of the kernel to memory in one row.

So we treat the `keccak_input_limbs` columns as a buffer. We gradually fill up this buffer, 4 bytes (one `u32` word) at a time. Every `136 / 4 = 34` rows, the buffer will be full, so at that point we activate the Keccak CTL to absorb the buffer.
2022-07-14 11:59:01 -07:00
wborgeaud
0d62895098
Merge pull request #606 from mir-protocol/jumpdest_push_data
Fix interpreter JUMPDEST check + change stopping behavior
2022-07-14 13:18:15 +02:00
Daniel Lubarov
8751aaec7a
Merge pull request #609 from mir-protocol/row_wise_memory_gen
Generate most of the memory table while it's in row-wise form
2022-07-13 17:09:56 -07:00
Daniel Lubarov
33622c1ec1
Merge pull request #608 from mir-protocol/kernel_size_logs
Have `make_kernel` log the size of each (assembled) file
2022-07-13 13:13:39 -07:00
Daniel Lubarov
bfd924870f Generate most of the memory table while it's in row-wise form
This should improve cache locality - since we generally access several values at a time in a given row, we want themt to be close together in memory.

There are a few steps that make more sense column-wise, though, such as generating the `COUNTER` column. I put those after the transpose.
2022-07-13 13:08:41 -07:00
wborgeaud
4be5a25a7d
Merge pull request #607 from mir-protocol/duplicate_macros
Avoid duplicate macros
2022-07-13 19:56:09 +02:00
Daniel Lubarov
d36eda20e2
Merge pull request #605 from mir-protocol/memory_misc
More realistic padding rows in memory table
2022-07-13 10:55:04 -07:00
Daniel Lubarov
a8852946b3 Have make_kernel log the size of each (assembled) file
For now it doesn't log filenames, but we can compare against the list of filenames in `combined_kernel`.

Current output:
```
[DEBUG plonky2_evm::cpu::kernel::assembler] Assembled file size: 0 bytes
[DEBUG plonky2_evm::cpu::kernel::assembler] Assembled file size: 49 bytes
[DEBUG plonky2_evm::cpu::kernel::assembler] Assembled file size: 387 bytes
[DEBUG plonky2_evm::cpu::kernel::assembler] Assembled file size: 27365 bytes
[DEBUG plonky2_evm::cpu::kernel::assembler] Assembled file size: 0 bytes
[DEBUG plonky2_evm::cpu::kernel::assembler] Assembled file size: 11 bytes
[DEBUG plonky2_evm::cpu::kernel::assembler] Assembled file size: 7 bytes
[DEBUG plonky2_evm::cpu::kernel::aggregator::tests] Total kernel size: 27819 bytes
```

This shows that most of our kernel code is from `curve_add.asm`, which makes sense since it invovles a couple uses of the large `inverse` macro.  Thankfully that will be replaced at some point.
2022-07-13 10:53:26 -07:00
wborgeaud
a68d8ff586 Avoid duplicate macros 2022-07-13 18:54:43 +02:00
Daniel Lubarov
c214c53c93
Merge pull request #604 from mir-protocol/get_subgroup_evals
Use FFTs to get subgroup evaluations in `check_constraints`
2022-07-13 09:52:14 -07:00
wborgeaud
b1bc48197c Fix jumpdest check 2022-07-13 10:51:49 +02:00
Daniel Lubarov
678d04e69a fix 2022-07-12 17:52:53 -07:00
Daniel Lubarov
d1afe8129c More realistic padding rows in memory
This adds padding rows which satisfy the ordering checks. To ensure that they also satisfy the value consistency checks, I just copied the address and value from the last operation.

I think this method of padding feels more natural, though it is a bit more code since we need to calculate the max range check in a different way. But on the plus side, the constraints are a bit smaller and simpler.

Also added a few constraints that I think we need for soundness:
- Each `is_channel` flag is bool.
- Sum of `is_channel` flags is bool.
- Dummy operations must be reads (otherwise the prover could put writes in the memory table which aren't in the CPU table).
2022-07-12 17:46:19 -07:00
Daniel Lubarov
7221c96440 Use FFTs to get subgroup evaluations in check_constraints
Instead of quadratic evaluation. Should speed up `test_all_stark`.
2022-07-12 15:29:27 -07:00
Daniel Lubarov
f053932791
Merge pull request #603 from mir-protocol/memory_simplifications
Simplify memory table
2022-07-12 14:59:21 -07:00
Daniel Lubarov
1331f992a6 fix 2022-07-12 14:55:34 -07:00
Daniel Lubarov
25d429af7a fix 2022-07-12 14:54:36 -07:00
Daniel Lubarov
934f1aeb7e Simplify memory table
By no longer storing unsorted operations; they are effectively stored in the CPU table already.

I ran into some issues with sorting, since the existing sort method didn't include `is_channel` columns. Rather than update the existing method, I removed it and added a sort on the `MemoryOp`s, which I think seems cleaner.
2022-07-12 14:53:34 -07:00
Daniel Lubarov
2507985da7
Merge pull request #591 from mir-protocol/evm_generation
Begin work on witness generation and kernel bootstrapping
2022-07-12 14:34:18 -07:00
Daniel Lubarov
10c31b7036 feedback 2022-07-12 14:33:10 -07:00
Daniel Lubarov
a3deefd891 fix 2022-07-11 17:37:17 -07:00
Daniel Lubarov
ef3addea2c Merge branch 'main' into evm_generation 2022-07-11 17:24:37 -07:00
wborgeaud
61f98f3695
Merge pull request #602 from mir-protocol/better_ctl_error
Better CTL errors
2022-07-11 20:07:28 +02:00
wborgeaud
d35d3e2095 PR feedback + underflow check 2022-07-11 19:53:00 +02:00
Nicholas Ward
29ef56eb69
Merge pull request #599 from mir-protocol/memory_ctl
Separate timestamps per memory operation
2022-07-11 10:45:28 -07:00
Nicholas Ward
abc729f1d6 TODO 2022-07-11 10:44:48 -07:00
Nicholas Ward
bdae9bc33b update 2022-07-11 10:44:48 -07:00
Nicholas Ward
b935605f69 fmt 2022-07-11 10:44:48 -07:00
Nicholas Ward
467f532024 addressed comments 2022-07-11 10:44:48 -07:00
Nicholas Ward
49c208ec9b addressed comments 2022-07-11 10:44:48 -07:00
Nicholas Ward
888cfe4ca4 fix 2022-07-11 10:44:48 -07:00
Nicholas Ward
9ad2958f73 fix 2022-07-11 10:44:48 -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
6b2b745291 removed debug prints 2022-07-11 10:44:48 -07:00
Nicholas Ward
3a6f2ef25e clippy 2022-07-11 10:44:48 -07:00
Nicholas Ward
51498eb748 fmt 2022-07-11 10:44:48 -07:00
Nicholas Ward
58c2e7214a another padding-row constraint fix 2022-07-11 10:44:48 -07:00
Nicholas Ward
77a7ace39c updates to recursive constraints 2022-07-11 10:44:48 -07:00
Nicholas Ward
f3ef6c9bf3 fix: ignore padding rows in constraints 2022-07-11 10:44:48 -07:00
Nicholas Ward
83963c3a8f permutation pairs 2022-07-11 10:44:48 -07:00
Nicholas Ward
b467a13d91 fix 2022-07-11 10:44:48 -07:00
Nicholas Ward
c3e7652763 updates 2022-07-11 10:44:48 -07:00
Nicholas Ward
181a132335 fixes 2022-07-11 10:44:48 -07:00
Nicholas Ward
a98f267ff0 initial change 2022-07-11 10:44:48 -07:00
Daniel Lubarov
8a2a035411 Merge branch 'main' into evm_generation 2022-07-11 09:58:38 -07:00