-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Comment storage-memory opcodes group
Comment stack-operations opcodes group Pr review Comment log opcodes group Comment flow control opcodes group Comment flow crypto opcodes group PR review
- Loading branch information
Showing
7 changed files
with
510 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
name: Test executor inputs | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: [main, develop] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,141 @@ | ||
|
||
/** | ||
* @link [https://www.evm.codes/#56?fork=berlin] | ||
* @zk-counters | ||
* - 32 binary | ||
* - 120 steps | ||
* @process-opcode | ||
* - stack input: [counter] | ||
* - stack output: none | ||
*/ | ||
opJUMP: | ||
|
||
; checks zk-counters | ||
%MAX_CNT_BINARY - CNT_BINARY - 2 :JMPN(outOfCountersBinary) | ||
%MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCountersStep) | ||
|
||
; check stack underflow | ||
SP - 1 => SP :JMPN(stackUnderflow) | ||
$ => PC :MLOAD(SP) | ||
|
||
; check out-of-gas | ||
GAS - 8 => GAS :JMPN(outOfGas) | ||
|
||
$ => PC :MLOAD(SP); [counter => PC] | ||
; Check PC is a JUMPDEST | ||
:JMP(checkJumpDest) | ||
|
||
/** | ||
* @link [https://www.evm.codes/#57?fork=berlin] | ||
* @zk-counters | ||
* - 32 binary | ||
* - 120 steps | ||
* @process-opcode | ||
* - stack input: [counter, value] | ||
* - stack output: none | ||
*/ | ||
opJUMPI: | ||
|
||
%MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCountersStep) | ||
%MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary) | ||
|
||
SP - 2 => SP :JMPN(stackUnderflow) | ||
$ => B :MLOAD(SP) | ||
$ => B :MLOAD(SP); [value => B] | ||
GAS - 10 => GAS :JMPN(outOfGas) | ||
0 => A | ||
$ :EQ, JMPC(readCode) | ||
SP + 1 => SP | ||
$ => PC :MLOAD(SP--) ; | ||
$ => PC :MLOAD(SP--); [counter => PC] | ||
PC => B | ||
; Check PC is a JUMPDEST | ||
:JMP(checkJumpDest) | ||
|
||
; TODO check do not overflow | ||
checkJumpDest: | ||
; If it is a deploy we have to check the data from the calldata (not the bytecode) | ||
; if it is a deploy we have to check the data from the calldata (not the bytecode) | ||
$ => A :MLOAD(isCreateContract) | ||
-A :JMPN(checkJumpDestDeployment) | ||
PC => HASHPOS | ||
HASHPOS => D | ||
; set number of bytes to hashP at D | ||
1 => D | ||
$ => E :MLOAD(contractHashId) ; hash index | ||
; get hashP address pointer where contract bytecode is stored | ||
$ => E :MLOAD(contractHashId) | ||
$ => A :HASHP(E) | ||
; check if is a jumpDest (0x5B) | ||
0x5B => B | ||
$ :EQ, JMPC(readCode) | ||
:JMP(invalidJump) | ||
checkJumpDestDeployment: | ||
1 => A | ||
$ => B :MLOAD(isCreate) | ||
$ :EQ,JMPC(checkJumpDestDeploymentCreate) | ||
; check jumpDest from calldata | ||
$ => A :MLOAD(isCreate) | ||
-A :JMPN(checkJumpDestDeploymentCreate) | ||
; get position where data starts in the tx | ||
$ => HASHPOS :MLOAD(dataStarts) | ||
; add PC to data starts to point the bytes to read for the push | ||
HASHPOS + PC => HASHPOS | ||
; get memory pointer for hashing | ||
$ => E :MLOAD(batchHashDataId) | ||
; set number of bytes to hashK at D | ||
1 => D | ||
$ => A :HASHK(E) | ||
; check if is a jumpDest (0x5B) | ||
0x5B => B | ||
$ :EQ, JMPC(readCode) | ||
:JMP(invalidJump) | ||
|
||
checkJumpDestDeploymentCreate: | ||
|
||
; checks zk-counters | ||
%MAX_CNT_ARITH - CNT_ARITH - 224 :JMPN(outOfCountersArith) | ||
%MAX_CNT_BINARY - CNT_BINARY - 225 :JMPN(outOfCountersBinary) | ||
%MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 2 :JMPN(outOfCountersMemalign) | ||
|
||
; get bytes from previous context memory | ||
$ => CTX :MLOAD(originCTX) | ||
; get offset call position | ||
$ => E :MLOAD(argsOffsetCall) | ||
; increase current program counter (PC) to offset for getting pushed bytes to read | ||
E + PC => E | ||
; set bytes to read from memory at C | ||
1 => C | ||
:CALL(MLOADX) | ||
:CALL(MLOADX); in: [E: offset, C: length] out: [A: value, E: new offset] | ||
$ => CTX :MLOAD(currentCTX) | ||
31 => D | ||
:CALL(SHRarith) | ||
:CALL(SHRarith); in: [A: value, D: #bytes to right shift] out: [A: shifted result] | ||
; check if is a jumpDest (0x5B) | ||
0x5B => B | ||
$ :EQ, JMPC(readCode) | ||
:JMP(invalidJump) | ||
|
||
/** | ||
* @link [https://www.evm.codes/#58?fork=berlin] | ||
* @zk-counters | ||
* - dynamic steps: 120 * pushed bytes | ||
* @process-opcode | ||
* - stack input: none | ||
* - stack output: [PC] | ||
*/ | ||
opPC: | ||
|
||
; checks zk-counters | ||
%MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) | ||
|
||
; check out-of-gas | ||
GAS - 2 => GAS :JMPN(outOfGas) | ||
PC - 1 :MSTORE(SP++) ; TODO: check PC | ||
; store current PC | ||
PC - 1 :MSTORE(SP++); [PC => SP] | ||
; check stack overflow | ||
1024 - SP :JMPN(stackOverflow) | ||
:JMP(readCode) | ||
|
||
|
||
/** | ||
* @link [https://www.evm.codes/#5B?fork=berlin] | ||
* @zk-counters | ||
* - dynamic steps: 120 * pushed bytes | ||
* @process-opcode | ||
* - stack input: none | ||
* - stack output: none | ||
*/ | ||
opJUMPDEST: | ||
|
||
; checks zk-counters | ||
%MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) | ||
|
||
; check out-of-gas | ||
GAS - 1 => GAS :JMPN(outOfGas) | ||
:JMP(readCode) |
Oops, something went wrong.