46 Commits

Author SHA1 Message Date
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
wborgeaud
a268677936 Merge branch 'main' into ecrecover_kernel
# Conflicts:
#	evm/src/cpu/kernel/aggregator.rs
2022-07-18 14:01:10 +02:00
wborgeaud
ba9aa14f51 PR feedback 2022-07-18 14:00:20 +02:00
Daniel Lubarov
925483ed1e Add custom opcodes
- `GET_STATE_ROOT` and `SET_STATE_ROOT` deal with the root of the state trie, and will be called from storage routines. Similarly `GET_RECEIPT_ROOT` and `SET_RECEIPT_ROOT` deal with the root of the receipt trie.
- `PANIC` enables an unsatisfiable constraint, so no proof can be generated.
- `GET_CONTEXT` and `SET_CONTEXT`, used when calling and returning
- `CONSUME_GAS` charges the sender gas; useful for cases where gas calculations are nontrivial and best implemented in assembly.
- `EXIT_KERNEL` simply clears the CPU flag indicating that we're in kernel mode; it would be used just before a jump to return to the (userspace) caller.
- `MLOAD_GENERAL` and `MSTORE_GENERAL` are for reading and writing memory, but they're not limited to the main memory segment of the current context; they can access any context and any segment. I added a couple macros to show how the they would typically be used.

There may be more later, but these are the ones I think we need for now.  I tried to fill in smaller invalid sections of the decoder's tree, as Jacqui suggested, while keeping related opcodes together. We can fine tune it when the opcode list is more stable.

These are all intended to be priviledged, i.e. they will be treated as invalid if used from userspace, for compatibility as well as (in some cases) security reasons.
2022-07-17 15:43:49 -07:00
wborgeaud
48f9b7fdf3 PR feedback 2022-07-15 09:56:52 +02:00
Daniel Lubarov
6d69e14a89 Add %rep syntax for repeating a block
Same syntax as NASM.
2022-07-14 14:58:18 -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
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
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
c8c3cc9a8f Files shuffling 2022-07-13 18:48:25 +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
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
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
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
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
wborgeaud
4cdbb8c1a9 Minor 2022-07-05 10:47:29 +02:00
wborgeaud
6db8539bc8 Minor 2022-07-05 10:46:07 +02:00
wborgeaud
683efc0d74 Impl double 2022-07-05 10:45:26 +02:00
wborgeaud
797bece7bd First attempt 2022-07-01 18:28:22 +02:00
Daniel Lubarov
7b75eaa98d
ASM macro support (#580)
* ASM macro support

Also recognize global labels as a PUSH target; previously it only considered local labels.

* macro test
2022-06-25 23:10:08 -07:00
Jacqueline Nabaglo
191ddf7bc1
Exponentiation kernel function (#574)
* Exponentiation kernel function

* Exponentiation: Hamish comments
2022-06-23 15:33:55 -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