261 Commits

Author SHA1 Message Date
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
62c094615d Add _base suffix 2022-07-14 19:46:02 +02:00
wborgeaud
f4390410a3 Comments 2022-07-14 19:39:07 +02:00
wborgeaud
0ccd5adc7b Redundant x-coord in lifting 2022-07-14 19:23:08 +02:00
wborgeaud
7ee884b84d More tests 2022-07-14 15:26:07 +02:00
wborgeaud
33a5934255 Passing tests 2022-07-14 14:26:01 +02:00
wborgeaud
add2b42e16 Merge branch 'main' into ecrecover_kernel 2022-07-14 13:18:54 +02: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
wborgeaud
cb7215436b Merge branch 'main' into ecrecover_kernel
# Conflicts:
#	evm/src/cpu/kernel/aggregator.rs
2022-07-14 13:17:16 +02:00
wborgeaud
ad9e131026 Add test 2022-07-14 13:16:25 +02:00
wborgeaud
905b0243e7 Minor fixes 2022-07-14 13:07:58 +02:00
wborgeaud
522213c933 Ecrecover until hashing 2022-07-14 11:30:47 +02: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
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
b4ebbe5a31 Start ecrecover 2022-07-13 19:48:17 +02:00
wborgeaud
7a6c53e921 Working secp mul 2022-07-13 19:25:28 +02:00
wborgeaud
a831fab8f8 Working secp add 2022-07-13 19:22:32 +02:00
wborgeaud
a68d8ff586 Avoid duplicate macros 2022-07-13 18:54:43 +02:00
wborgeaud
c8c3cc9a8f Files shuffling 2022-07-13 18:48:25 +02:00
wborgeaud
b1bc48197c Fix jumpdest check 2022-07-13 10:51:49 +02:00
Daniel Lubarov
8a2a035411 Merge branch 'main' into evm_generation 2022-07-11 09:58:38 -07:00
Daniel Lubarov
58889e7649
Allow constants to be passed from Rust into our assembly (#598)
Roughly like environment variables. So we don't have to declare things like segment IDs twice.
2022-07-08 08:56:46 -07:00
wborgeaud
12ca084620 PR feedback 2022-07-08 09:58:52 +02:00
wborgeaud
a280e1c60a Merge branch 'ec_use_macro_params' into evm_interpreter 2022-07-07 19:28:22 +02:00
wborgeaud
a3c2e9a295 More macros 2022-07-07 19:28:11 +02:00
wborgeaud
122188c817 Merge branch 'ec_use_macro_params' into evm_interpreter 2022-07-07 19:17:31 +02:00
wborgeaud
4316be96cd Test exp kernel function 2022-07-07 19:15:39 +02:00
wborgeaud
7bf5118f69 Test exp kernel function 2022-07-07 18:46:20 +02:00
wborgeaud
f8987b7e80 Minor 2022-07-07 18:27:15 +02:00
wborgeaud
9c4947e0f0 EC ops test 2022-07-07 18:06:24 +02:00
Daniel Lubarov
beb8a90773
Macros with arguments (#595)
* Macros with arguments

See `basic_macros.rs` for an example.

* rename
2022-07-07 08:59:53 -07:00
wborgeaud
3ec2d307e5 EVM interpreter 2022-07-07 16:53:06 +02:00
wborgeaud
434615a03c PR feedback + comments 2022-07-07 08:26:57 +02:00
wborgeaud
e2b1e51280 Minor 2022-07-06 09:40:11 +02:00
wborgeaud
9747343ac2 PR feedback 2022-07-06 09:25:41 +02:00
wborgeaud
5bae732ea0 Minor 2022-07-05 21:24:51 +02:00
wborgeaud
8ffd25c127 Add zero case for mul 2022-07-05 21:22:05 +02:00
wborgeaud
fb8a67b0d9 Working ecmul 2022-07-05 21:12:11 +02:00
wborgeaud
006b74f4dc Merge branch 'main' into elliptic_curve_asm 2022-07-05 20:29:21 +02:00
wborgeaud
9e90d7d115 Add check for zero point 2022-07-05 20:27:55 +02:00
wborgeaud
fd1d9fe85e Add range check 2022-07-05 17:37:34 +02:00
wborgeaud
8e711d413a Minor 2022-07-05 16:41:28 +02:00
wborgeaud
ee80fa4a39 Minor 2022-07-05 16:19:23 +02:00
wborgeaud
8873eaba11 Find labels before assembly 2022-07-05 16:11:55 +02:00
wborgeaud
7364248e60 Fixes 2022-07-05 15:43:41 +02:00
wborgeaud
eed7cde388 Add moddiv for testing 2022-07-05 15:01:40 +02:00
wborgeaud
8a44c557c5 Curve mul assembly 2022-07-05 12:11:35 +02:00
wborgeaud
4d37685744 Comment 2022-07-05 11:12:56 +02:00
wborgeaud
a5988d6c26 Simplify 2022-07-05 11:09:25 +02:00