mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-06 07:43:10 +00:00
- `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.
28 lines
1.0 KiB
NASM
28 lines
1.0 KiB
NASM
// Load a byte from the given segment of the current context's memory space.
|
|
// Note that main memory values are one byte each, but in general memory values
|
|
// can be 256 bits. This macro deals with a single address (unlike MSTORE), so
|
|
// if it is used with main memory, it will load a single byte.
|
|
%macro mload_current(segment)
|
|
// stack: offset
|
|
PUSH $segment
|
|
// stack: segment, offset
|
|
CURRENT_CONTEXT
|
|
// stack: context, segment, offset
|
|
MLOAD_GENERAL
|
|
// stack: value
|
|
%endmacro
|
|
|
|
// Store a byte to the given segment of the current context's memory space.
|
|
// Note that main memory values are one byte each, but in general memory values
|
|
// can be 256 bits. This macro deals with a single address (unlike MSTORE), so
|
|
// if it is used with main memory, it will store a single byte.
|
|
%macro mstore_current(segment)
|
|
// stack: offset, value
|
|
PUSH $segment
|
|
// stack: segment, offset, value
|
|
CURRENT_CONTEXT
|
|
// stack: context, segment, offset, value
|
|
MSTORE_GENERAL
|
|
// stack: (empty)
|
|
%endmacro
|