24 Commits

Author SHA1 Message Date
Dmitry Vagner
53014b732f almost done 2022-10-03 15:30:17 -07:00
Nicholas Ward
42320d815e fix 2022-10-03 13:34:16 -07:00
Nicholas Ward
e482bc7f0c addressed comments 2022-10-03 13:34:16 -07:00
Nicholas Ward
f4207e75a4 sha2 testing infrastructure 2022-10-03 13:34:16 -07:00
BGluth
7e6844963a Few small changes related to switching to H256 2022-09-29 17:24:23 -06:00
Daniel Lubarov
37d92b55ac Basic MPT logic
For now this contains most of the basic framework/structure. Logic for things like insertions will come later.
2022-09-22 11:25:37 -07:00
BGluth
d7d8803d0a Replaced PartialTrie definitions with eth-trie-utils crate
- There were enough dependencies that it made sense to move
  `PartialTrie` logic to its own crate.
2022-09-19 11:05:48 -06:00
Daniel Lubarov
19162db596 Tweak features 2022-09-07 15:10:40 -07:00
Sladuca
e72152eed8 fix default features in starky & evm 2022-09-06 14:56:48 -04:00
Daniel Lubarov
4112065692 Fix 2022-08-24 16:06:50 -07:00
Daniel Lubarov
fb34b09888 Remove keccak_rust in favor of tiny-keccak
`keccak_rust` doesn't seem to have much usage, and it treats `x` as the major axis of its 5x5 input.  This is not exactly wrong, since Keccak itself doesn't have a notion of axis order. However, there is a convention for mapping bits of the cube to a flat list of bits, which is

> The mapping between the bits of `s` and those of `a` is `s[w(5y + x) + z] = a[x][y][z]`.

Obeying this convention would be awkward with `keccak_rust` - the words in memory would need to be transposed.
2022-08-24 15:48:02 -07:00
Daniel Lubarov
763d63de08 For permutations, find the optimal sequence of swaps
Using a method Angus described. This is mainly his idea and code, I just ported it to Rust.
2022-08-09 16:33:02 -04:00
Sebastien La Duca
c9d610ec10 use maybe_rayon in starky and evm 2022-07-24 17:47:14 -04:00
Daniel Lubarov
78fb34a9b6 Minor 2022-07-20 00:10:52 -07:00
wborgeaud
a268677936 Merge branch 'main' into ecrecover_kernel
# Conflicts:
#	evm/src/cpu/kernel/aggregator.rs
2022-07-18 14:01:10 +02: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
33a5934255 Passing tests 2022-07-14 14:26:01 +02:00
Daniel Lubarov
5d74a19ad6 Add test (won't work for a while, but to illustrate) 2022-07-04 18:10:03 -07:00
Jacqueline Nabaglo
e3834a5335
Util for assembling EVM code to hex (#586)
This is just for debugging the kernel. It's fully disposable.
2022-06-27 18:08:03 -07:00
Jacqueline Nabaglo
46df1bb6b2
Fix EVM dependency list (#576) 2022-06-23 18:33:34 -07:00
Daniel Lubarov
2e818172f0
Parse and assemble kernel functions (#567)
* Parse and assemble kernel functions

Written in "EVM++" assembly. Later on we will add some priviledged opcodes (in unused opcode ordinals), making it an extension of EVM bytecode.

I don't think there's much of a standard for EVM assembly, but I loosely based the syntax on this [proposal](https://gist.github.com/axic/17ddbbce4738ccf4040d30cbb5de484e).

* PR feedback

* tweaks for consistency

* terminology tweaks

* Update evm/src/cpu/kernel/opcodes.rs

Co-authored-by: Jacqueline Nabaglo <jakub@mirprotocol.org>

* Update evm/src/cpu/kernel/opcodes.rs

Co-authored-by: Jacqueline Nabaglo <jakub@mirprotocol.org>

* Update evm/src/cpu/kernel/opcodes.rs

Co-authored-by: Jacqueline Nabaglo <jakub@mirprotocol.org>

Co-authored-by: Jacqueline Nabaglo <jakub@mirprotocol.org>
2022-06-20 20:32:29 -07:00
Nicholas Ward
80d5e5375e fixes, cleanup, and correctness test 2022-06-07 10:57:06 -07:00
Nicholas Ward
e6880e591b included everything 2022-06-07 10:57:06 -07:00
Daniel Lubarov
c54896dcb8
Rename starky2 -> evm (#547) 2022-05-18 10:32:14 -07:00