51 Commits

Author SHA1 Message Date
BGluth
db93badaf2 Bumped eth_trie_utils to 0.6.0 2023-04-20 11:05:34 -06:00
Robin Salen
df5a90cca4
Provide methods for serializing Kernel 2023-04-15 11:01:40 -04:00
Robin Salen
6124e4d6a3
Fix BlockCircuitData proofs 2023-04-08 14:31:10 -04:00
BGluth
60ad9e03ba Bumped eth_trie_utils to 0.5.0 2023-03-27 17:30:11 -06:00
Nicholas Ward
b16b82613e
Merge pull request #881 from mir-protocol/bignum-basic
Basic bignum operations
2023-03-20 13:09:17 -07:00
Hamish Ivey-Law
692575a24b
Bump eth_trie_utils version. (#923) 2023-03-21 02:20:11 +11:00
Nicholas Ward
fa605d7b22 basic bignum 2023-03-07 17:47:09 -08:00
Daniel Lubarov
2133c7f3ba Use new plonky2 2023-02-25 09:36:25 -08:00
Daniel Lubarov
137bc78565 Prep for publishing to crates.io 2023-01-30 13:18:06 -08:00
Nicholas Ward
f3937e9977 deps fix 2022-12-13 10:29:03 -08:00
Nicholas Ward
d3a7201348 fixes 2022-12-13 10:08:36 -08:00
Nicholas Ward
dd29ec1f46 fixes and test infrastructure 2022-12-13 10:08:30 -08:00
BGluth
b34b3875f7 Removed unused deps unovered by cargo-udeps
Some deps were moved to `[dev-dependencies]`.
2022-12-12 18:23:22 -07:00
Daniel Lubarov
fbb26546dd Jemalloc for EVM
Also update the version used elsewhere.
2022-12-04 10:15:28 -08:00
Brandon H. Gomes
812a5d468a
chore: merge branch main
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
2022-11-15 01:54:30 -05:00
Brandon H. Gomes
14c2a6dd1f
Fork Update (#3)
* Use static `KERNEL` in tests

* Print opcode count

* Update criterion

* Combine all syscalls into one flag (#802)

* Combine all syscalls into one flag

* Minor: typo

* Daniel PR comments

* Check that `le_sum` won't overflow

* security notes

* Test reverse_index_bits

Thanks to Least Authority for this

* clippy

* 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.

* Remove signed operation placeholders from arithmetic table. (#812)

Co-authored-by: wborgeaud <williamborgeaud@gmail.com>
Co-authored-by: Daniel Lubarov <daniel@lubarov.com>
Co-authored-by: Jacqueline Nabaglo <jakub@mirprotocol.org>
Co-authored-by: Hamish Ivey-Law <426294+unzvfu@users.noreply.github.com>
2022-11-15 01:51:29 -05:00
Brandon H. Gomes
38e467f1c0
chore: fix serde-cbor and run cargo-sort
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
2022-11-03 11:41:12 -07:00
Brandon H. Gomes
e2cdd5a954
feat: upgrade Sampling APIs
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
2022-11-03 08:26:03 -07:00
BGluth
8736435ea9 Updated eth_trie_utils to 0.4.0 2022-10-31 15:15:20 -06:00
BGluth
2e7da17554 Bumped eth_trie_utils to 0.3.1 2022-10-31 15:03:34 -06:00
Daniel Lubarov
7f366cdace Treat storage tries as sub-tries of the state trie
I.e. have leaves in the state trie point to the root of a storage trie
2022-10-16 20:26:37 -07:00
BGluth
06475c2b61 Bumped patch version 2022-10-11 22:07:32 -06:00
BGluth
cb2e69a2c9 Updated eth_trie_utils to 0.2.0 2022-10-11 20:57:46 -06:00
Hamish Ivey-Law
d7bb47318c
Modular operations for the EVM arithmetic unit (#755)
* First draft of 256-bit addition.

* Update comment.

* cargo fmt

* Rename addition evaluation file.

* Port ALU logic from SZ.

* Give a name to some magic numbers.

* `addition.rs` -> `add.rs`; fix carry propagation in add; impl sub.

* Clippy.

* Combine hi and lo parts of the output.

* Implement MUL.

* Suppress Clippy's attempt to make my code even harder to read.

* Next draft of MUL.

* Make all limbs (i.e. input and output) 16-bits.

* Tidying.

* Use iterators instead of building arrays.

* Documentation.

* Clippy is wrong; also cargo fmt.

* Un-refactor equality checking, since it was wrong for sub.

* Daniel comments.

* Daniel comments.

* Rename folder 'alu' -> 'arithmetic'.

* Rename file.

* Finish changing name ALU -> Arithmetic Unit.

* Finish removing dependency on array_zip feature.

* Remove operations that will be handled elsewhere.

* Rename var; tidy up.

* Clean up columns; mark places where range-checks need to be done.

* Import all names in 'columns' to reduce verbiage.

* cargo fmt

* Fix aux_in calculation in mul.

* Remove redundant 'allow's; more precise range-check size.

* Document functions.

* Document MUL instruction verification technique.

* Initial tests for ADD.

* Minor test fixes; add test for SUB.

* Fix bugs in generate functions.

* Fix SUB verification; refactor equality verification.

* cargo fmt

* Add test for MUL and fix some bugs.

* Update doc.

* Quiet incorrect clippy error.

* Initial implementation of ADDMOD and MOD.

* Fixes to addmod.

* Update doc.

* Do 1000 random tests instead of just 1.

* Documentation fix.

* Working version of ADDMOD.

* Working version of MOD.

* Name magic number; do multiple MUL tests.

* Add code and test for special case; add some docs.

* Fix spelling mistake.

* Simplify asserts.

* Tidy comment.

* Remove unused module.

* cargo fmt

* Check that output is reduced.

* Add conversion of canonical `i64` to a `Field64`.

* Handle zero modulus within degree constraint.

* cargo fmt

* Fix some comments.

* Check that the top half of the product is zero!

* Start of refactor.

* Refactoring.

* Remove zero and reduction handling from addmod.

* Refactoring; renaming; bug fixes.

* Reuse intermediate calculations across all modular operations; don't negate quot poly unnecessarily.

* Fix bug where last elt of q*m wasn't checked.

* Refactoring.

* Move circuit poly functions to utils.rs.

* Rename ADDMOD stuff to MODULAR.

* Rename module addmod -> modular.

* Handle zero modulus.

* Verify that output is reduced.

* Implement recursive version of modular circuits.

* clippy

* Tidy up i64 -> Field conversion following Jacqui's comments.

* cargo fmt

* Improved documentation.

* Address Jacqui's comments.

* Save some gates by using builder.arithmetic_extension().
2022-10-07 17:15:50 +11:00
BGluth
bf57fe9835 Now uses eth_trie_utils on crates.io 2022-10-04 22:07:43 -06:00
Daniel Lubarov
d8bf30150f
Merge pull request #756 from mir-protocol/rlp_fixes
RLP related fixes
2022-10-04 15:34:38 -07:00
Daniel Lubarov
0ccb340e40 RLP related fixes 2022-10-04 15:18:31 -07:00
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