34 Commits

Author SHA1 Message Date
Robin Salen
03a9558198
Handle additional panics (#1250)
* Remove some panic risks

* Remove more panics

* Handle jump with empty stack

* Handle last expect

* More panics

* Handle from_big_endian

* Handle from_little_endian

* Remove remaining risky as_usize()

* Remove explicit panic

* Clippy

* Handle unwrap

* Make error messages more explicit

* Simplify u256 to usize conversion
2023-09-26 11:13:57 -04:00
Robin Salen
5a1b05acfb
Remove risks of panic 2023-09-12 19:23:16 -04:00
wborgeaud
b7e93511e4
New contract hook (#1002)
* New contract hook

* Minor

* PR feedback
2023-04-24 09:07:00 +02:00
Nicholas Ward
1fbe305034 Merge branch 'main' into bignum-modexp 2023-03-22 09:46:17 -07:00
Nicholas Ward
d59501e6a7 fixes, testing, and in-progress debugging 2023-03-21 16:03:54 -07:00
Daniel Lubarov
afded1682b Contract creation fixes 2023-03-20 23:43:13 -07:00
Nicholas Ward
42d65839e7 addressed comments 2023-03-20 15:07:02 -07:00
Nicholas Ward
be9cbd5a81 fmt 2023-03-20 13:09:42 -07:00
Nicholas Ward
4cef5aaa84 modmul and modexp 2023-03-20 13:09:42 -07:00
Daniel Lubarov
7ed53142a0 Fix reads from not-found ext nodes 2023-03-19 14:13:42 -07:00
Daniel Lubarov
994c54abe6
Merge pull request #912 from mir-protocol/stack_on_panic
Log stack on panic
2023-03-17 11:46:46 -07:00
Daniel Lubarov
c8d591f6da Add a prove_with_outputs method
Which returns information about the post-state after execution. This is useful for debugging purposes.
2023-03-16 13:42:59 -07:00
Daniel Lubarov
d4a485ece5 Log stack on panic 2023-03-15 11:23:29 -07:00
Daniel Lubarov
c558eedd65 Misc EVM fixes 2023-03-05 09:39:49 -08:00
Daniel Lubarov
1f92d73177 Misc fixes 2022-12-02 14:31:18 -08:00
Daniel Lubarov
027dfc14b6 Refactor to support PROVER_INPUT 2022-12-01 11:15:51 -08:00
Daniel Lubarov
b6326c56b2 stubs 2022-11-30 22:03:00 -08:00
Daniel Lubarov
afb3e4b1e1 Misc work on witness generation 2022-11-30 14:58:40 -08:00
Daniel Lubarov
c721155e23 Main function, txn processing loop 2022-09-29 23:15:33 -07:00
Daniel Lubarov
c7b03cfe9a More MPT logic 2022-09-24 20:49:19 -07: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
Jacqueline Nabaglo
013bf6471d
Transpose memory columns (make it an array of channel structs) (#700) 2022-08-26 22:05:16 -07:00
Daniel Lubarov
aa87f2c3ba Public memory 2022-08-25 20:19:18 -07:00
Daniel Lubarov
9671c1e535
Merge pull request #669 from mir-protocol/keccak_memory
Keccak memory stark
2022-08-25 15:55:48 -07:00
Daniel Lubarov
ff228c9386 Have witness generation take a partial trie instead of Merkle proofs 2022-08-24 20:43:49 -07:00
Daniel Lubarov
522cac5e15 Keccak memory stark 2022-08-24 09:29:17 -07:00
Daniel Lubarov
c38a98f9e4 Simpler CPU <-> memory CTL 2022-08-23 23:38:28 -07:00
Daniel Lubarov
b9b3c24cf9 PROVER_INPUT instruction 2022-07-19 06:55:23 -07:00
Daniel Lubarov
997453237f Store memory values as U256s
Ultimately they're encoded as `[F; 8]`s in the table, but I don't anticipate that we'll have any use cases where we want to store more than 256 bits. Might as well store `U256` until we actually build the table since they're more compact.
2022-07-17 07:58:28 -07:00
Daniel Lubarov
ab5abc391d Organize segments in an enum
It's a bit more type-safe (can't mix up segment with context or virtual addr), and this way uniqueness of ordinals is enforced, partially addressing a concern raised in #591.

To avoid making `Segment` public (which I don't think would be appropriate), I had to make some other visibility changes, and had to move `generate_random_memory_ops` into the test module.
2022-07-16 10:16:12 -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
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
10c31b7036 feedback 2022-07-12 14:33:10 -07:00
Daniel Lubarov
e7b480deaf Begin work on witness generation and kernel bootstrapping 2022-07-01 10:09:57 -07:00