298 Commits

Author SHA1 Message Date
Daniel Lubarov
1e6cf4c4ab newline 2022-08-04 09:34:46 -07:00
Daniel Lubarov
7423124e36 Split up memory asm and add more helper functions 2022-08-03 22:18:29 -07:00
Daniel Lubarov
fae653da2a Missing retdest 2022-08-03 21:56:31 -07:00
Daniel Lubarov
233584e945
Merge pull request #656 from mir-protocol/min_max
min, max macros
2022-08-03 21:41:23 -07:00
Daniel Lubarov
f58990160e min, max macros
Will be used later for things like updating `MemorySize`.
2022-08-03 13:44:44 -07:00
Daniel Lubarov
90be4749ef Merge branch 'main' into optimizer 2022-08-03 09:58:54 -07:00
Daniel Lubarov
6416826643 Feedback 2022-08-02 15:44:50 -07:00
Daniel Lubarov
d6b5193c9b RLP decoding tests 2022-07-31 20:29:57 -07:00
Daniel Lubarov
a34a4c8184 fix 2022-07-31 13:03:07 -07:00
Daniel Lubarov
497b26dee6 Some simple optimization rules
Depends on #647.
2022-07-31 13:00:27 -07:00
Daniel Lubarov
7a6d996fe7 Move couple asm files 2022-07-31 09:28:16 -07:00
Daniel Lubarov
718b3c0961 Move ecrecover 2022-07-31 09:24:04 -07:00
Daniel Lubarov
86a797b1db Add a asm/curve/ directory 2022-07-30 22:24:11 -07:00
Dmitry Vagner
cf63711597 add u32 macros 2022-07-30 14:52:39 -04:00
Dmitry Vagner
7e0334fcce fix shift direction 2022-07-30 14:21:06 -04:00
Dmitry Vagner
d25693d77c update dups, write out stack states 2022-07-29 13:24:11 -04:00
Daniel Lubarov
760a111a63
Merge pull request #642 from mir-protocol/type_0_fix
Small fix for type 0 txns
2022-07-29 09:28:20 -07:00
wborgeaud
2bae8f92f0
Merge pull request #635 from mir-protocol/nondeterministic_ec_ops
Use non-determinism in EC ops
2022-07-29 13:05:12 +02:00
wborgeaud
eb96216278 Typo 2022-07-29 11:32:55 +02:00
Daniel Lubarov
563de9e1c5 Small fix for type 0 txns
Always parse "to" as a scalar. No need for a branch; it's left over from when I was trying to enforce canonical RLP (in which case "to" must be 0 or 20 bytes).

The old code would be wrong if we had multiple txns per proof, as if to=0 we wouldn't write that field to memory, so it could have an old value from a previous txn.
2022-07-28 15:51:33 -07:00
wborgeaud
87640d7e98 PR feedback 2022-07-28 10:35:53 +02:00
Jacqueline Nabaglo
c160c4032d
Inter-row program counter constraints (#639)
* Beginning of control flow support

* Fixes to halt spin loop
2022-07-27 11:36:33 -07:00
Dmitry Vagner
21e6477755 subroutines draft 2022-07-27 14:34:00 -04:00
wborgeaud
bb2ee9d543 Implement sqrt 2022-07-27 17:06:16 +02:00
wborgeaud
8053215841 Inverse for other fields 2022-07-27 16:49:26 +02:00
wborgeaud
bb773e42b3 Merge branch 'main' into nondeterministic_ec_ops
# Conflicts:
#	evm/src/cpu/kernel/interpreter.rs
2022-07-27 11:24:22 +02:00
Daniel Lubarov
3d8ac2a391 style 2022-07-26 16:25:01 -07:00
Daniel Lubarov
d1cb854cf2 terminology 2022-07-26 16:12:21 -07:00
Daniel Lubarov
0ba6078984 Merge branch 'main' into rlp_3 2022-07-25 19:47:43 -07:00
Daniel Lubarov
05c7dfa115 Feedback 2022-07-25 16:32:59 -07:00
Daniel Lubarov
1db5b7374d Move storage asm 2022-07-24 08:42:06 -07:00
Daniel Lubarov
544c84b420 Transaction (RLP) parsing
Will add tests once we have the interpreter support for other segmnets.
2022-07-23 21:39:01 -07:00
wborgeaud
cafae8b818 Add run_with_kernel fn 2022-07-23 12:36:03 +02:00
wborgeaud
0afe98525b Minor 2022-07-22 19:25:06 +02:00
wborgeaud
e93235d07e Modify inverse asm 2022-07-22 18:26:15 +02:00
Daniel Lubarov
47ea00d6c7 A few ASM fixes 2022-07-20 15:05:09 -07:00
Daniel Lubarov
c7ba4eb6ee Feedback 2022-07-20 09:45:05 -07:00
Daniel Lubarov
78fb34a9b6 Minor 2022-07-20 00:10:52 -07:00
Daniel Lubarov
05a1fbfbae Stack manipulation macro
Uses a variant of Dijkstra's, with a few pruning mechanics, to find a path of instructions between the two stack states. We don't explicitly store the graph though.

The Dijkstra implementation is somewhat inspired by the `pathfinding` crate. That crate doesn't quite fit our needs though.

If we need to make it faster later, there are a lot of allocations and clones that we could probably eliminate.
2022-07-19 22:59:56 -07:00
Daniel Lubarov
3dc79274a8 Add a mload_kernel_code_u32 macro
Intended for loading constants in SHA2, and maybe RIPEMD.

Sample usage
```
// Loads the i'th K256 constant.
%macro k256
  // stack: i
  %mul_const(4)
  // stack: 4*i
  PUSH k256_data
  // stack: k256_data, 4*i
  ADD
  // stack: k256_data + 4*i
  %mload_kernel_code_u32
  // stack: K256[4*i]
%endmacro

k256_data:
    BYTES 0x42, 0x8a, 0x2f, 0x98
    BYTES 0x71, 0x37, 0x44, 0x91
    ...
```

Untested for now since our interpreter doesn't have the needed memory support quite yet.
2022-07-19 10:36:18 -07:00
Daniel Lubarov
71db231c59
Merge pull request #622 from mir-protocol/memcpy
Implement memcpy
2022-07-19 07:21:15 -07:00
Daniel Lubarov
5b1f564039 Feedback 2022-07-19 07:20:57 -07:00
wborgeaud
54629a0ef9 Merge branch 'main' into sha3_interpreter_ecrecover
# Conflicts:
#	evm/src/cpu/kernel/interpreter.rs
#	evm/src/cpu/kernel/tests/ecrecover.rs
2022-07-19 15:24:28 +02:00
wborgeaud
e7dbba8d7b s/sha3/keccak256 2022-07-19 15:21:44 +02:00
Daniel Lubarov
80d32f89b6 fixes 2022-07-18 15:58:12 -07:00
Daniel Lubarov
6610ec4487 Implement memcpy
This can be used, for example, to copy `CALL` data (which is a slice of the caller's main memory) to the callee's `CALLDATA` segment.
2022-07-18 14:55:15 -07:00
Daniel Lubarov
cbdf2a66a1
Merge pull request #619 from mir-protocol/add_priviledged_opcodes
Add custom opcodes
2022-07-18 10:55:56 -07:00
Daniel Lubarov
71b9705a0d
Merge pull request #618 from mir-protocol/asm_assertions
More basic ASM macros
2022-07-18 09:31:34 -07:00
Daniel Lubarov
b29de2c46a tweak 2022-07-18 09:29:21 -07:00
Daniel Lubarov
d53804c66f Merge branch 'main' into add_priviledged_opcodes 2022-07-18 08:47:15 -07:00