From 7accd8a8faf198a30ab1752948f826dd858ea91d Mon Sep 17 00:00:00 2001 From: Ignasirv Date: Mon, 3 Oct 2022 13:06:06 +0200 Subject: [PATCH] Separate out of counters errors --- main/ecrecover/ecrecover.zkasm | 2 +- main/main.zkasm | 4 +- main/opcodes.zkasm | 514 ++++++++++++++++---------------- main/precompiled/identity.zkasm | 10 +- main/process-tx.zkasm | 18 +- main/utils.zkasm | 50 +++- 6 files changed, 308 insertions(+), 290 deletions(-) diff --git a/main/ecrecover/ecrecover.zkasm b/main/ecrecover/ecrecover.zkasm index 286d1fdd..98a8df9a 100644 --- a/main/ecrecover/ecrecover.zkasm +++ b/main/ecrecover/ecrecover.zkasm @@ -183,7 +183,7 @@ ecrecover_v_y2_same_parity: 64 :HASHKLEN(E) $ => A :MLOAD(cntKeccakPreProcess) - %MAX_CNT_KECCAK_F - CNT_KECCAK_F - A - 1 :JMPN(outOfCounters) + %MAX_CNT_KECCAK_F - CNT_KECCAK_F - A - 1 :JMPN(outOfCountersKeccak) $ => A :HASHKDIGEST(E) ; for address take only last 20 bytes diff --git a/main/main.zkasm b/main/main.zkasm index a22dd29a..0545add5 100644 --- a/main/main.zkasm +++ b/main/main.zkasm @@ -49,7 +49,7 @@ start: ; main zkROM entry point A - 1 :HASHK(E) %STATE_ROOT_STORAGE_POS :HASHK(E) ; Storage position of the batch hash HASHPOS :HASHKLEN(E) - %MAX_CNT_KECCAK_F - CNT_KECCAK_F - %MIN_CNT_KECCAK_BATCH - 2:JMPN(outOfCounters) + %MAX_CNT_KECCAK_F - CNT_KECCAK_F - %MIN_CNT_KECCAK_BATCH - 2:JMPN(outOfCountersKeccak) $ => C :HASHKDIGEST(E) ${eventLog(onStartBatch, C)} @@ -88,7 +88,7 @@ start: ; main zkROM entry point ; Compute minimum necessary keccaks to finish the batch B + %MIN_CNT_KECCAK_BATCH :MSTORE(cntKeccakPreProcess) %MAX_CNT_KECCAK_F - CNT_KECCAK_F => A - $ :LT, JMPC(outOfCounters) + $ :LT, JMPC(outOfCountersKeccak) ;;;;;;;;;;;;;;;;;; ;; C - Loop parsing RLP transactions ;; - Load transaction RLP data and ensure it has correct RLP encoding diff --git a/main/opcodes.zkasm b/main/opcodes.zkasm index e7b28ae6..04374d02 100644 --- a/main/opcodes.zkasm +++ b/main/opcodes.zkasm @@ -27,8 +27,8 @@ opSTOPend: opADD: - %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -45,8 +45,8 @@ opADD: opMUL: - %MAX_CNT_ARITH - CNT_ARITH - 1 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_ARITH - CNT_ARITH - 1 :JMPN(outOfCountersArith) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -64,8 +64,8 @@ opMUL: opSUB: - %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -78,9 +78,9 @@ opSUB: opDIV: - %MAX_CNT_ARITH - CNT_ARITH - 1 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 2 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_ARITH - CNT_ARITH - 1 :JMPN(outOfCountersArith) + %MAX_CNT_BINARY - CNT_BINARY - 2 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -98,9 +98,9 @@ opDIV: opSDIV: - %MAX_CNT_ARITH - CNT_ARITH - 1 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 8 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_ARITH - CNT_ARITH - 1 :JMPN(outOfCountersArith) + %MAX_CNT_BINARY - CNT_BINARY - 8 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -144,9 +144,9 @@ opSDIVNeg: opMOD: - %MAX_CNT_ARITH - CNT_ARITH - 1 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 2 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_ARITH - CNT_ARITH - 1 :JMPN(outOfCountersArith) + %MAX_CNT_BINARY - CNT_BINARY - 2 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -164,9 +164,9 @@ opMOD: opSMOD: - %MAX_CNT_ARITH - CNT_ARITH - 1 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 8 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_ARITH - CNT_ARITH - 1 :JMPN(outOfCountersArith) + %MAX_CNT_BINARY - CNT_BINARY - 8 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -208,9 +208,9 @@ opSMODNeg: opADDMOD: - %MAX_CNT_ARITH - CNT_ARITH - 1 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 4 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 80 :JMPN(outOfCounters) + %MAX_CNT_ARITH - CNT_ARITH - 1 :JMPN(outOfCountersArith) + %MAX_CNT_BINARY - CNT_BINARY - 4 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 80 :JMPN(outOfCountersStep) GAS-8 => GAS :JMPN(outOfGas) @@ -249,9 +249,9 @@ AddModJumpCarry: :JMP(readCode) opMULMOD: - %MAX_CNT_ARITH - CNT_ARITH - 3 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 3 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 150 :JMPN(outOfCounters) + %MAX_CNT_ARITH - CNT_ARITH - 3 :JMPN(outOfCountersArith) + %MAX_CNT_BINARY - CNT_BINARY - 3 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 150 :JMPN(outOfCountersStep) GAS-8 => GAS :JMPN(outOfGas) SP - 3 :JMPN(stackUnderflow) @@ -355,9 +355,9 @@ zeroOneMod: opEXP: ; //TODO: test exp == 0 - %MAX_CNT_ARITH - CNT_ARITH - 512 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 1025 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_ARITH - CNT_ARITH - 512 :JMPN(outOfCountersArith) + %MAX_CNT_BINARY - CNT_BINARY - 1025 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -372,8 +372,8 @@ opEXP: ; //TODO: test exp == 0 opSIGNEXTEND: ; following this impl https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/vm/src/evm/opcodes/functions.ts#L193 - %MAX_CNT_ARITH - CNT_ARITH - 6 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCounters) + %MAX_CNT_ARITH - CNT_ARITH - 6 :JMPN(outOfCountersArith) + %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -413,8 +413,8 @@ opSIGNEXTENDEnd: opSLT: - %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -426,8 +426,8 @@ opSLT: :JMP(readCode) opLT: - %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -440,8 +440,8 @@ opLT: opSGT: - %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -453,8 +453,8 @@ opSGT: :JMP(readCode) opGT: - %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -466,8 +466,8 @@ opGT: :JMP(readCode) opEQ: - %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -480,8 +480,8 @@ opEQ: opISZERO: - %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 1 => SP :JMPN(stackUnderflow) $ => A :MLOAD(SP) @@ -493,8 +493,8 @@ opISZERO: opAND: - %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -507,8 +507,8 @@ opAND: opOR: - %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -521,8 +521,8 @@ opOR: opXOR: - %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -535,8 +535,8 @@ opXOR: opNOT: - %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 1 => SP :JMPN(stackUnderflow) $ => A :MLOAD(SP) @@ -548,9 +548,9 @@ opNOT: opBYTE: - %MAX_CNT_ARITH - CNT_ARITH - 2 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 4 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_ARITH - CNT_ARITH - 2 :JMPN(outOfCountersArith) + %MAX_CNT_BINARY - CNT_BINARY - 4 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -569,9 +569,9 @@ opBYTE0: :JMP(readCode) opSHR: - %MAX_CNT_ARITH - CNT_ARITH - 1 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 3 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_ARITH - CNT_ARITH - 1 :JMPN(outOfCountersArith) + %MAX_CNT_BINARY - CNT_BINARY - 3 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -585,9 +585,9 @@ opSHR: opSHL: - %MAX_CNT_ARITH - CNT_ARITH - 1 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 3 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_ARITH - CNT_ARITH - 1 :JMPN(outOfCountersArith) + %MAX_CNT_BINARY - CNT_BINARY - 3 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -603,9 +603,9 @@ opSHL: ; https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/evm/src/opcodes/functions.ts#L336 opSAR: - %MAX_CNT_ARITH - CNT_ARITH - 2 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 10 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCounters) + %MAX_CNT_ARITH - CNT_ARITH - 2 :JMPN(outOfCountersArith) + %MAX_CNT_BINARY - CNT_BINARY - 10 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -644,13 +644,13 @@ opSARNeg: opSHA3: - %MAX_CNT_ARITH - CNT_ARITH - 192 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 193 :JMPN(outOfCounters) - %MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 2 :JMPN(outOfCounters) + %MAX_CNT_ARITH - CNT_ARITH - 192 :JMPN(outOfCountersArith) + %MAX_CNT_BINARY - CNT_BINARY - 193 :JMPN(outOfCountersBinary) + %MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 2 :JMPN(outOfCountersMemalign) $ => A :MLOAD(cntKeccakPreProcess) - %MAX_CNT_KECCAK_F - CNT_KECCAK_F - A - 2 :JMPN(outOfCounters) - %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 10 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCounters) + %MAX_CNT_KECCAK_F - CNT_KECCAK_F - A - 2 :JMPN(outOfCountersKeccak) + %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 10 :JMPN(outOfCountersPoseidon) + %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -685,8 +685,8 @@ opSHA3: opSHA3Loop: - %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCounters) + %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) C - 1 :JMPN(opSHA3End) C - 32 :JMPN(opSHA3Final) @@ -716,7 +716,7 @@ opSHA3End: $ => B :MLOAD(arithRes1) $ => A :MLOAD(cntKeccakPreProcess) %MAX_CNT_KECCAK_F - CNT_KECCAK_F - A => A - $ :LT, JMPC(outOfCounters) + $ :LT, JMPC(outOfCountersKeccak) $ => A :HASHKDIGEST(E) A :MSTORE(SP++) @@ -724,7 +724,7 @@ opSHA3End: :JMP(readCode) opADDRESS: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) $ => A :MLOAD(isCreateContract) 0 - A :JMPN(opADDRESSdeploy) @@ -742,8 +742,8 @@ opADDRESSend: opBALANCE: - %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 252 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 252 :JMPN(outOfCountersPoseidon) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 1 => SP :JMPN(stackUnderflow) $ => A :MLOAD(SP) @@ -758,7 +758,7 @@ opBALANCE: opORIGIN: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) $ => A :MLOAD(txSrcOriginAddr) A :MSTORE(SP++) @@ -768,7 +768,7 @@ opORIGIN: opCALLER: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) $ => A :MLOAD(txSrcAddr) A :MSTORE(SP++) @@ -778,7 +778,7 @@ opCALLER: opCALLVALUE: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) $ => A :MLOAD(txValue) A :MSTORE(SP++) @@ -789,9 +789,9 @@ opCALLVALUE: ; // TODO: Check when a contract is deployed with CREATE opCALLDATALOAD: - %MAX_CNT_ARITH - CNT_ARITH - 64 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 66 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCounters) + %MAX_CNT_ARITH - CNT_ARITH - 64 :JMPN(outOfCountersArith) + %MAX_CNT_BINARY - CNT_BINARY - 66 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCountersStep) SP - 1 => SP :JMPN(stackUnderflow) $ => E :MLOAD(SP) @@ -830,7 +830,7 @@ opCALLDATALOAD2: opCALLDATASIZE: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) $ => A :MLOAD(isCreateContract) 0 - A :JMPN(opCALLDATASIZEdep) @@ -850,10 +850,10 @@ opCALLDATASIZEdep: ; // TODO: if ins deployment only write 0 opCALLDATACOPY: - %MAX_CNT_ARITH - CNT_ARITH - 192 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 192 :JMPN(outOfCounters) - %MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 1 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCounters) + %MAX_CNT_ARITH - CNT_ARITH - 192 :JMPN(outOfCountersArith) + %MAX_CNT_BINARY - CNT_BINARY - 192 :JMPN(outOfCountersBinary) + %MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 1 :JMPN(outOfCountersMemalign) + %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCountersStep) SP - 3 :JMPN(stackUnderflow) SP - 1 => SP @@ -877,10 +877,10 @@ opCALLDATACOPYX0: opCALLDATACOPYinit: - %MAX_CNT_ARITH - CNT_ARITH - 192 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 192 :JMPN(outOfCounters) - %MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 1 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 400 :JMPN(outOfCounters) + %MAX_CNT_ARITH - CNT_ARITH - 192 :JMPN(outOfCountersArith) + %MAX_CNT_BINARY - CNT_BINARY - 192 :JMPN(outOfCountersBinary) + %MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 1 :JMPN(outOfCountersMemalign) + %MAX_CNT_STEPS - STEP - 400 :JMPN(outOfCountersStep) C - 1 :JMPN(opCALLDATACOPYcheckLen) C - 32 :JMPN(opCALLDATACOPYfinal) @@ -973,8 +973,8 @@ opCALLDATACOPYend: opCODESIZE: - %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 252 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCounters) + %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 252 :JMPN(outOfCountersPoseidon) + %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCountersStep) $ => A :MLOAD(isCreateContract) 0 - A :JMPN(opCODESIZEdep) @@ -1013,8 +1013,8 @@ opCODECOPY: E :MSTORE(lastMemLength) ;Check counters - %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCounters) + %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCountersStep) GAS - 3 => GAS :JMPN(outOfGas) GAS - ${3*((E+31)/32)} => GAS :JMPN(outOfGas) @@ -1038,10 +1038,10 @@ opCODECOPY2: E :MSTORE(remainingBytes) opCODECOPYinit: - %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCounters) - %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 510 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCounters) - %MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 2 :JMPN(outOfCounters) + %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCountersBinary) + %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 510 :JMPN(outOfCountersPoseidon) + %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCountersStep) + %MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 2 :JMPN(outOfCountersMemalign) $ => B :MLOAD(remainingBytes) B - 1 :JMPN(readCode) @@ -1085,7 +1085,7 @@ readValueBytecode: opGASPRICE: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) $ => A :MLOAD(txGasPrice) A :MSTORE(SP++) @@ -1095,8 +1095,8 @@ opGASPRICE: opEXTCODESIZE: - %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 255 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 255 :JMPN(outOfCountersPoseidon) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 1 => SP :JMPN(stackUnderflow) $ => A :MLOAD(SP) @@ -1120,9 +1120,9 @@ VAR GLOBAL tmpContractHashId VAR GLOBAL tmpContractLength opEXTCODECOPY: - %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 510 :JMPN(outOfCounters) - %MAX_CNT_PADDING_PG - CNT_PADDING_PG - 11 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCounters) + %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 510 :JMPN(outOfCountersPoseidon) + %MAX_CNT_PADDING_PG - CNT_PADDING_PG - 11 :JMPN(outOfCountersPadding) + %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCountersStep) SP - 4 :JMPN(stackUnderflow) SP - 1 => SP @@ -1138,9 +1138,9 @@ opEXTCODECOPY: E :MSTORE(lastMemLength) ;Check counters should be before than do all the operations! TODO - %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCounters) - %MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 2 :JMPN(outOfCounters) + %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCountersStep) + %MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 2 :JMPN(outOfCountersMemalign) GAS - ${3*((E+31)/32)} => GAS :JMPN(outOfGas) @@ -1196,7 +1196,7 @@ opEXTCODECOPYCheckHash: ; TODO: it could be improved by computing how many 32 bytes slots are needed opEXTCODECOPYCheckHashLoop: - %MAX_CNT_STEPS - STEP - 20 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 20 :JMPN(outOfCountersStep) B - 1 :JMPN(opEXTCODECOPYCheckHashLoopEnd) ; finish reading bytecode 1 => D @@ -1214,7 +1214,7 @@ opEXTCODECOPYCheckHashEnd: opEXTCODECOPYinit: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) C - 1 :JMPN(readCode) C - 32 :JMPN(opEXTCODECOPYfinal) @@ -1235,8 +1235,8 @@ opEXTCODECOPYfinal: opRETURNDATASIZE: - %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCounters) + %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCountersStep) ; Load ret data length from last ctx ; If no retDataCTX(0), retDataLength = 0 @@ -1265,11 +1265,11 @@ opRETURNDATACOPY: C :MSTORE(lastMemLength) ;Check counters - %MAX_CNT_ARITH - CNT_ARITH - 32 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCounters) - %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 510 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCounters) - %MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 2 :JMPN(outOfCounters) + %MAX_CNT_ARITH - CNT_ARITH - 32 :JMPN(outOfCountersArith) + %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCountersBinary) + %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 510 :JMPN(outOfCountersPoseidon) + %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCountersStep) + %MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 2 :JMPN(outOfCountersMemalign) :CALL(saveMem) ; if retDataCTX is 0, end opcode execution @@ -1309,7 +1309,7 @@ opRETURNDATACOPY: GAS - A => GAS :JMPN(outOfGas) opRETURNDATACOPYinit: - %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCountersStep) C - 1 :JMPN(readCode) C - 32 :JMPN(opRETURNDATACOPYfinal) @@ -1347,8 +1347,8 @@ opRETURNDATACOPYEmpty: opEXTCODEHASH: - %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 255 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCounters) + %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 255 :JMPN(outOfCountersPoseidon) + %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCountersStep) SP - 1 => SP :JMPN(stackUnderflow) $ => A :MLOAD(SP) @@ -1403,10 +1403,10 @@ opEXTCODEHASH: opBLOCKHASH: - %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 255 :JMPN(outOfCounters) + %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 255 :JMPN(outOfCountersPoseidon) $ => A :MLOAD(cntKeccakPreProcess) - %MAX_CNT_KECCAK_F - CNT_KECCAK_F - A - 2 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCounters) + %MAX_CNT_KECCAK_F - CNT_KECCAK_F - A - 2 :JMPN(outOfCountersKeccak) + %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCountersStep) SP - 1 => SP :JMPN(stackUnderflow) GAS-20 => GAS :JMPN(outOfGas) @@ -1445,7 +1445,7 @@ opBLOCKHASHzero: opCOINBASE: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) $ => A :MLOAD(sequencerAddr) A :MSTORE(SP++) @@ -1456,7 +1456,7 @@ opCOINBASE: opTIMESTAMP: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) $ => A :MLOAD(timestamp) A :MSTORE(SP++) @@ -1466,7 +1466,7 @@ opTIMESTAMP: opNUMBER: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) $ => A :MLOAD(numBatch) A :MSTORE(SP++) @@ -1476,7 +1476,7 @@ opNUMBER: opDIFFICULTY: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) %BATCH_DIFFICULTY => A A :MSTORE(SP++) @@ -1486,7 +1486,7 @@ opDIFFICULTY: opGASLIMIT: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) %BATCH_GAS_LIMIT => A A :MSTORE(SP++) @@ -1496,7 +1496,7 @@ opGASLIMIT: opCHAINID: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) $ => A :MLOAD(chainId) A :MSTORE(SP++) @@ -1506,8 +1506,8 @@ opCHAINID: opSELFBALANCE: - %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 255 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 255 :JMPN(outOfCountersPoseidon) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) $ => A :MLOAD(storageAddr) 0 => B,C ; balance key smt @@ -1519,7 +1519,7 @@ opSELFBALANCE: opPOP: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 1 => SP :JMPN(stackUnderflow) GAS-2 => GAS :JMPN(outOfGas) @@ -1527,11 +1527,11 @@ opPOP: opMLOAD: - %MAX_CNT_ARITH - CNT_ARITH - 32 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCounters) - %MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 1 :JMPN(outOfCounters) - %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 255 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_ARITH - CNT_ARITH - 32 :JMPN(outOfCountersArith) + %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCountersBinary) + %MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 1 :JMPN(outOfCountersMemalign) + %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 255 :JMPN(outOfCountersPoseidon) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 1 => SP :JMPN(stackUnderflow) $ => E :MLOAD(SP) ;offset @@ -1547,11 +1547,11 @@ opMLOAD: ;MSTORE 32 bytes opMSTORE: - %MAX_CNT_ARITH - CNT_ARITH - 32 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCounters) - %MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 1 :JMPN(outOfCounters) - %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 255 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_ARITH - CNT_ARITH - 32 :JMPN(outOfCountersArith) + %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCountersBinary) + %MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 1 :JMPN(outOfCountersMemalign) + %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 255 :JMPN(outOfCountersPoseidon) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -1569,10 +1569,10 @@ opMSTORE: opMSTORE8: - %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCounters) - %MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 1 :JMPN(outOfCounters) - %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 255 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCountersBinary) + %MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 1 :JMPN(outOfCountersMemalign) + %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 255 :JMPN(outOfCountersPoseidon) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -1594,8 +1594,8 @@ opMSTORE8: opSLOAD: - %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 255 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 255 :JMPN(outOfCountersPoseidon) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 1 => SP :JMPN(stackUnderflow) $ => C :MLOAD(SP) ;key @@ -1609,10 +1609,10 @@ opSLOAD: :JMP(readCode) opSSTORE: - %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 765 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 10 :JMPN(outOfCounters) - %MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 1 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCounters) + %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 765 :JMPN(outOfCountersPoseidon) + %MAX_CNT_BINARY - CNT_BINARY - 10 :JMPN(outOfCountersBinary) + %MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 1 :JMPN(outOfCountersMemalign) + %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) ; If GAS <= 2300 --> OOG @@ -1744,8 +1744,8 @@ opSSTOREsr: opJUMP: - %MAX_CNT_BINARY - CNT_BINARY - 2 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCounters) + %MAX_CNT_BINARY - CNT_BINARY - 2 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCountersStep) SP - 1 => SP :JMPN(stackUnderflow) $ => PC :MLOAD(SP) @@ -1755,7 +1755,7 @@ opJUMP: opJUMPI: - %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCountersStep) SP - 2 => SP :JMPN(stackUnderflow) $ => B :MLOAD(SP) @@ -1796,9 +1796,9 @@ checkJumpDestDeployment: checkJumpDestDeploymentCreate: - %MAX_CNT_ARITH - CNT_ARITH - 224 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 225 :JMPN(outOfCounters) - %MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 2 :JMPN(outOfCounters) + %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) $ => CTX :MLOAD(originCTX) $ => E :MLOAD(argsOffsetCall) @@ -1814,7 +1814,7 @@ checkJumpDestDeploymentCreate: opPC: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) GAS - 2 => GAS :JMPN(outOfGas) PC - 1 :MSTORE(SP++) ; TODO: check PC @@ -1823,9 +1823,9 @@ opPC: opMSIZE: - %MAX_CNT_ARITH - CNT_ARITH - 1 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 3 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCounters) + %MAX_CNT_ARITH - CNT_ARITH - 1 :JMPN(outOfCountersArith) + %MAX_CNT_BINARY - CNT_BINARY - 3 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCountersStep) GAS - 2 => GAS :JMPN(outOfGas) $ => E :MLOAD(memLength) @@ -1850,7 +1850,7 @@ MSIZEend: opGAS: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) GAS - 2 => GAS :JMPN(outOfGas) GAS :MSTORE(SP++) @@ -1858,14 +1858,14 @@ opGAS: :JMP(readCode) opJUMPDEST: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) GAS - 1 => GAS :JMPN(outOfGas) :JMP(readCode) opAuxPUSHA: - %MAX_CNT_BINARY - CNT_BINARY - 6 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_BINARY - CNT_BINARY - 6 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) GAS-3 => GAS :JMPN(outOfGas) :CALL(readPush) @@ -1876,8 +1876,8 @@ opAuxPUSHA: opAuxPUSHB: - %MAX_CNT_BINARY - CNT_BINARY - 6 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCounters) + %MAX_CNT_BINARY - CNT_BINARY - 6 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCountersStep) 1 => A $ => B :MLOAD(isCreate) @@ -1886,9 +1886,9 @@ opAuxPUSHB: 0 => A opAuxPUSHBloop: - %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 4 :JMPN(outOfCounters) - %MAX_CNT_ARITH - CNT_ARITH - 4 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_BINARY - CNT_BINARY - 4 :JMPN(outOfCountersBinary) + %MAX_CNT_ARITH - CNT_ARITH - 4 :JMPN(outOfCountersArith) 1 => D $ => HASHPOS :MLOAD(dataStarts) @@ -1909,9 +1909,9 @@ opAuxPUSHBend: opAuxPUSHBcreate: - %MAX_CNT_ARITH - CNT_ARITH - 224 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 225 :JMPN(outOfCounters) - %MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 2 :JMPN(outOfCounters) + %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) 0 => B $ => CTX :MLOAD(originCTX) @@ -2120,7 +2120,7 @@ opPUSH32: opDUP1: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 1 => SP :JMPN(stackUnderflow) $ => A :MLOAD(SP++) @@ -2132,7 +2132,7 @@ opDUP1: opDUP2: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 2 => SP :JMPN(stackUnderflow) $ => A :MLOAD(SP) @@ -2144,7 +2144,7 @@ opDUP2: opDUP3: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 3 => SP :JMPN(stackUnderflow) $ => A :MLOAD(SP) @@ -2156,7 +2156,7 @@ opDUP3: opDUP4: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 4 => SP :JMPN(stackUnderflow) $ => A :MLOAD(SP) @@ -2168,7 +2168,7 @@ opDUP4: opDUP5: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 5 => SP :JMPN(stackUnderflow) $ => A :MLOAD(SP) @@ -2180,7 +2180,7 @@ opDUP5: opDUP6: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 6 => SP :JMPN(stackUnderflow) $ => A :MLOAD(SP) @@ -2192,7 +2192,7 @@ opDUP6: opDUP7: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 7 => SP :JMPN(stackUnderflow) $ => A :MLOAD(SP) @@ -2204,7 +2204,7 @@ opDUP7: opDUP8: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 8 => SP :JMPN(stackUnderflow) $ => A :MLOAD(SP) @@ -2216,7 +2216,7 @@ opDUP8: opDUP9: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 9 => SP :JMPN(stackUnderflow) $ => A :MLOAD(SP) @@ -2228,7 +2228,7 @@ opDUP9: opDUP10: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 10 => SP :JMPN(stackUnderflow) $ => A :MLOAD(SP) @@ -2240,7 +2240,7 @@ opDUP10: opDUP11: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 11 => SP :JMPN(stackUnderflow) $ => A :MLOAD(SP) @@ -2252,7 +2252,7 @@ opDUP11: opDUP12: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 12 => SP :JMPN(stackUnderflow) $ => A :MLOAD(SP) @@ -2264,7 +2264,7 @@ opDUP12: opDUP13: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 13 => SP :JMPN(stackUnderflow) $ => A :MLOAD(SP) @@ -2276,7 +2276,7 @@ opDUP13: opDUP14: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 14 => SP :JMPN(stackUnderflow) $ => A :MLOAD(SP) @@ -2288,7 +2288,7 @@ opDUP14: opDUP15: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 15 => SP :JMPN(stackUnderflow) $ => A :MLOAD(SP) @@ -2300,7 +2300,7 @@ opDUP15: opDUP16: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 16 => SP :JMPN(stackUnderflow) $ => A :MLOAD(SP) @@ -2312,7 +2312,7 @@ opDUP16: opSWAP1: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -2327,7 +2327,7 @@ opSWAP1: opSWAP2: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 3 :JMPN(stackUnderflow) SP - 1 => SP @@ -2343,7 +2343,7 @@ opSWAP2: opSWAP3: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 4 :JMPN(stackUnderflow) SP - 1 => SP @@ -2359,7 +2359,7 @@ opSWAP3: opSWAP4: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 5 :JMPN(stackUnderflow) SP - 1 => SP @@ -2375,7 +2375,7 @@ opSWAP4: opSWAP5: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 6 :JMPN(stackUnderflow) SP - 1 => SP @@ -2391,7 +2391,7 @@ opSWAP5: opSWAP6: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 7 :JMPN(stackUnderflow) SP - 1 => SP @@ -2407,7 +2407,7 @@ opSWAP6: opSWAP7: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 8 :JMPN(stackUnderflow) SP - 1 => SP @@ -2423,7 +2423,7 @@ opSWAP7: opSWAP8: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 9 :JMPN(stackUnderflow) SP - 1 => SP @@ -2439,7 +2439,7 @@ opSWAP8: opSWAP9: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 10 :JMPN(stackUnderflow) SP - 1 => SP @@ -2455,7 +2455,7 @@ opSWAP9: opSWAP10: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 11 :JMPN(stackUnderflow) SP - 1 => SP @@ -2471,7 +2471,7 @@ opSWAP10: opSWAP11: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 12 :JMPN(stackUnderflow) SP - 1 => SP @@ -2487,7 +2487,7 @@ opSWAP11: opSWAP12: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 13 :JMPN(stackUnderflow) SP - 1 => SP @@ -2503,7 +2503,7 @@ opSWAP12: opSWAP13: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 14 :JMPN(stackUnderflow) SP - 1 => SP @@ -2519,7 +2519,7 @@ opSWAP13: opSWAP14: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 15 :JMPN(stackUnderflow) SP - 1 => SP @@ -2535,7 +2535,7 @@ opSWAP14: opSWAP15: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 16 :JMPN(stackUnderflow) SP - 1 => SP @@ -2551,7 +2551,7 @@ opSWAP15: opSWAP16: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) SP - 17 :JMPN(stackUnderflow) SP - 1 => SP @@ -2568,7 +2568,7 @@ opSWAP16: ; gas_cost = 375 + 375 * num_topics + 8 * data_size + mem_expansion_cost opLOG0: - %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) $ => A :MLOAD(isStaticCall) @@ -2594,7 +2594,7 @@ opLOG0: opLOG1: - %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCountersStep) SP - 3 :JMPN(stackUnderflow) $ => A :MLOAD(isStaticCall) @@ -2620,7 +2620,7 @@ opLOG1: opLOG2: - %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCountersStep) SP - 4 :JMPN(stackUnderflow) $ => A :MLOAD(isStaticCall) @@ -2646,7 +2646,7 @@ opLOG2: opLOG3: - %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCountersStep) SP - 5 :JMPN(stackUnderflow) $ => A :MLOAD(isStaticCall) @@ -2672,7 +2672,7 @@ opLOG3: opLOG4: - %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCountersStep) SP - 6 :JMPN(stackUnderflow) $ => A :MLOAD(isStaticCall) @@ -2698,8 +2698,8 @@ opLOG4: opLOGLoop: - %MAX_CNT_BINARY - CNT_BINARY - 2 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCounters) + %MAX_CNT_BINARY - CNT_BINARY - 2 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) C - 1 :JMPN(opSaveTopicsInit) C - 32 :JMPN(opLOGFinal) @@ -2717,7 +2717,7 @@ opSaveTopicsInit: opSaveTopicsLoop: - %MAX_CNT_STEPS - STEP - 20 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 20 :JMPN(outOfCountersStep) A - 1 :JMPN(readCode) SP - 1 => SP :JMPN(stackUnderflow) @@ -2745,11 +2745,11 @@ opCREATE: C :MSTORE(argsLengthCall) ;Check counters - %MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 2 :JMPN(outOfCounters) - %MAX_CNT_ARITH - CNT_ARITH - 32 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCounters) - %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 510 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCounters) + %MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 2 :JMPN(outOfCountersMemalign) + %MAX_CNT_ARITH - CNT_ARITH - 32 :JMPN(outOfCountersArith) + %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCountersBinary) + %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 510 :JMPN(outOfCountersPoseidon) + %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCountersStep) ; Substract gas cost ; Mem expansion gas cost @@ -2828,7 +2828,7 @@ opCreateFail: ; // https://eips.ethereum.org/EIPS/eip-211 opCALL: - %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCountersStep) $ => A :MLOAD(depth) A + 1 :MSTORE(depth) SP - 7 :JMPN(stackUnderflow) @@ -2876,10 +2876,10 @@ opCALL2: :CALL(saveMem) ;Check counters - %MAX_CNT_ARITH - CNT_ARITH - 32 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCounters) - %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 510 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCounters) + %MAX_CNT_ARITH - CNT_ARITH - 32 :JMPN(outOfCountersArith) + %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCountersBinary) + %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 510 :JMPN(outOfCountersPoseidon) + %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCountersStep) $ => B :MLOAD(lastMemOffset) @@ -2945,7 +2945,7 @@ opCALLend: ; should be the caller of the callCode? ( but we do not store this info yet) opCALLCODE: ; TODO check staticCall - %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCountersStep) $ => A :MLOAD(depth) A + 1 :MSTORE(depth) SP - 7 :JMPN(stackUnderflow) @@ -2982,10 +2982,10 @@ opCALLCODE: ; TODO check staticCall :CALL(saveMem) ;Check counters - %MAX_CNT_ARITH - CNT_ARITH - 32 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCounters) - %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 510 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCounters) + %MAX_CNT_ARITH - CNT_ARITH - 32 :JMPN(outOfCountersArith) + %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCountersBinary) + %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 510 :JMPN(outOfCountersPoseidon) + %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCountersStep) ; Substract gas cost @@ -3051,10 +3051,10 @@ opRETURN: $ => C :MLOAD(SP) ;length ;Check counters - %MAX_CNT_ARITH - CNT_ARITH - 32 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCounters) - %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 510 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCounters) + %MAX_CNT_ARITH - CNT_ARITH - 32 :JMPN(outOfCountersArith) + %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCountersBinary) + %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 510 :JMPN(outOfCountersPoseidon) + %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCountersStep) E :MSTORE(retDataOffset) C :MSTORE(retDataLength) @@ -3087,9 +3087,9 @@ preRETURN32: ; Copy from memory current CTX to memory origin CTX opRETURN32: - %MAX_CNT_BINARY - CNT_BINARY - 10 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCounters) - %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 510 :JMPN(outOfCounters) + %MAX_CNT_BINARY - CNT_BINARY - 10 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCountersStep) + %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 510 :JMPN(outOfCountersPoseidon) C - 1 :JMPN(opRETURNend) C - 32 :JMPN(opRETURNfinal) @@ -3139,11 +3139,11 @@ opRETURNdeploy: opRETURNcreate: ;Check counters - %MAX_CNT_ARITH - CNT_ARITH - 192 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 192 :JMPN(outOfCounters) - %MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 2 :JMPN(outOfCounters) - %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 1020 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCounters) + %MAX_CNT_ARITH - CNT_ARITH - 192 :JMPN(outOfCountersArith) + %MAX_CNT_BINARY - CNT_BINARY - 192 :JMPN(outOfCountersBinary) + %MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 2 :JMPN(outOfCountersMemalign) + %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 1020 :JMPN(outOfCountersPoseidon) + %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCountersStep) ; save offset memory and length to compute contract hash E :MSTORE(memOffsetLinearPoseidon) @@ -3189,7 +3189,7 @@ opRETURNcreateEnd: ; TODO if theres a delegate call, there should be not moveBalances opDELEGATECALL: - %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCountersStep) $ => A :MLOAD(depth) A + 1 :MSTORE(depth) SP - 6 :JMPN(stackUnderflow) @@ -3224,10 +3224,10 @@ opDELEGATECALL: :CALL(saveMem) ;Check counters - %MAX_CNT_ARITH - CNT_ARITH - 32 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCounters) - %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 510 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCounters) + %MAX_CNT_ARITH - CNT_ARITH - 32 :JMPN(outOfCountersArith) + %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCountersBinary) + %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 510 :JMPN(outOfCountersPoseidon) + %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCountersStep) $ => B :MLOAD(lastMemOffset) @@ -3292,10 +3292,10 @@ opCREATE2: $ => D :MLOAD(SP) ;salt ;Check counters - %MAX_CNT_ARITH - CNT_ARITH - 32 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCounters) - %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 510 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCounters) + %MAX_CNT_ARITH - CNT_ARITH - 32 :JMPN(outOfCountersArith) + %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCountersBinary) + %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 510 :JMPN(outOfCountersPoseidon) + %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCountersStep) ; Substract gas cost @@ -3407,10 +3407,10 @@ opSTATICCALL: :CALL(saveMem) ;Check counters - %MAX_CNT_ARITH - CNT_ARITH - 32 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCounters) - %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 510 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCounters) + %MAX_CNT_ARITH - CNT_ARITH - 32 :JMPN(outOfCountersArith) + %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCountersBinary) + %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 510 :JMPN(outOfCountersPoseidon) + %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCountersStep) ; Substract gas cost $ => A :MLOAD(addrCall) @@ -3451,7 +3451,7 @@ opSTATICCALL: opREVERT: - %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) $ => SR :MLOAD(initSR) @@ -3485,7 +3485,7 @@ opREVERT: ; Copy from memory current CTX to memory origin CTX opREVERT32: - %MAX_CNT_STEPS - STEP - 400 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 400 :JMPN(outOfCountersStep) $ => B :MLOAD(retCallOffset) C - 1 :JMPN(opREVERTend) @@ -3529,9 +3529,9 @@ opREVERTend: opSELFDESTRUCT: ;Check counters - %MAX_CNT_BINARY - CNT_BINARY - 10 :JMPN(outOfCounters) - %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 2040 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCounters) + %MAX_CNT_BINARY - CNT_BINARY - 10 :JMPN(outOfCountersBinary) + %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 2040 :JMPN(outOfCountersPoseidon) + %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCountersStep) $ => A :MLOAD(isStaticCall) 0 - A :JMPN(invalidStaticTx) @@ -3620,5 +3620,5 @@ opSELFDESTRUCTCend: :JMP(readCode) opINVALID: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) :JMP(invalidProcess) diff --git a/main/precompiled/identity.zkasm b/main/precompiled/identity.zkasm index db0ad856..9ce6d6b8 100644 --- a/main/precompiled/identity.zkasm +++ b/main/precompiled/identity.zkasm @@ -22,8 +22,8 @@ IDENTITY: C :MSTORE(retDataLength) IDENTITYinit: - %MAX_CNT_BINARY - CNT_BINARY - 10 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCounters) + %MAX_CNT_BINARY - CNT_BINARY - 10 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCountersStep) ; Copy from calldata to memory C - 1 :JMPN(IDENTITYreturn) C - 32 :JMPN(IDENTITYfinal) @@ -59,9 +59,9 @@ IDENTITYreturn2: $ => B :MLOAD(retCallOffset) IDENTITYreturnLoop: - %MAX_CNT_BINARY - CNT_BINARY - 10 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCounters) - %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 510 :JMPN(outOfCounters) + %MAX_CNT_BINARY - CNT_BINARY - 10 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 600 :JMPN(outOfCountersStep) + %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 510 :JMPN(outOfCountersPoseidon) C - 1 :JMPN(IDENTITYend) C - 32 :JMPN(IDENTITYreturnFinal) :CALL(MLOAD32) diff --git a/main/process-tx.zkasm b/main/process-tx.zkasm index 4f6b48ac..82491392 100644 --- a/main/process-tx.zkasm +++ b/main/process-tx.zkasm @@ -18,7 +18,7 @@ processTx: ${eventLog(onProcessTx)} ; Minimum of 100000 steps left to process a tx - %MAX_CNT_STEPS - STEP - 100000 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 100000 :JMPN(outOfCountersStep) ; Get sigDataSize $ => HASHPOS :MLOAD(sigDataSize) @@ -29,7 +29,7 @@ processTx: $ => B :MLOAD(arithRes1) $ => A :MLOAD(cntKeccakPreProcess) %MAX_CNT_KECCAK_F - CNT_KECCAK_F - A => A - $ :LT, JMPC(outOfCounters) + $ :LT, JMPC(outOfCountersKeccak) ; Get hash address previously stored in RLP parsing $ => E :MLOAD(lastTxHashId) @@ -125,7 +125,7 @@ addGas: 0 => C :JMP(loopBytes) loopBytes: - %MAX_CNT_STEPS - STEP - 20 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 20 :JMPN(outOfCountersStep) A - C - 1 :JMPN(endCalldataIntrinsicGas) E => B HASHPOS => D @@ -266,7 +266,7 @@ endContractAddress: ; end contract address hash and get the 20 first bytes HASHPOS :HASHKLEN(E) $ => A :MLOAD(cntKeccakPreProcess) - %MAX_CNT_KECCAK_F - CNT_KECCAK_F - A - 1 :JMPN(outOfCounters) + %MAX_CNT_KECCAK_F - CNT_KECCAK_F - A - 1 :JMPN(outOfCountersKeccak) $ => A :HASHKDIGEST(E) :CALL(maskAddress) ; Mask address to 20 bytes A :MSTORE(createContractAddress) @@ -282,8 +282,8 @@ create2: $ => B :MLOAD(argsOffsetCall) loopCreate2: - %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 4 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_BINARY - CNT_BINARY - 4 :JMPN(outOfCountersBinary) C - 1 :JMPN(create2end) C - 32 :JMPN(endloopCreate2) @@ -315,7 +315,7 @@ create2end: $ => B :MLOAD(arithRes1) $ => A :MLOAD(cntKeccakPreProcess) %MAX_CNT_KECCAK_F - CNT_KECCAK_F - A => A - $ :LT, JMPC(outOfCounters) + $ :LT, JMPC(outOfCountersKeccak) $ => C :HASHKDIGEST(E) ; new hash with position 0 is started 0 => HASHPOS @@ -340,7 +340,7 @@ create2end: $ => B :MLOAD(arithRes1) $ => A :MLOAD(cntKeccakPreProcess) %MAX_CNT_KECCAK_F - CNT_KECCAK_F - A => A - $ :LT, JMPC(outOfCounters) + $ :LT, JMPC(outOfCountersKeccak) $ => A :HASHKDIGEST(E) :CALL(maskAddress) ; Mask address to 20 bytes @@ -464,7 +464,7 @@ callContract: E+1 :MSTORE(nextHashPId) checkHashBytecodeLoop: - %MAX_CNT_STEPS - STEP - 10 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 10 :JMPN(outOfCountersStep) B - 1 - HASHPOS :JMPN(checkHashBytecodeEnd) ; finish reading bytecode ${getBytecode(A, HASHPOS, 1)} :HASHP(E) ; hash contract bytecode :JMP(checkHashBytecodeLoop) diff --git a/main/utils.zkasm b/main/utils.zkasm index 71b35d2e..bb01b4de 100644 --- a/main/utils.zkasm +++ b/main/utils.zkasm @@ -47,8 +47,8 @@ copySP: $ => C :MLOAD(argsLengthCall) ;length copyInit: - %MAX_CNT_BINARY - CNT_BINARY - 10 :JMPN(outOfCounters) - %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCounters) + %MAX_CNT_BINARY - CNT_BINARY - 10 :JMPN(outOfCountersBinary) + %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCountersStep) C - 1 :JMPN(copyEnd) C - 32 :JMPN(copyFinal) zkPC+1 => RR :JMP(MLOAD32) @@ -81,9 +81,9 @@ getLenBytes: B => A getLenBytesLoop: - %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 8 :JMPN(outOfCounters) - %MAX_CNT_ARITH - CNT_ARITH - 4 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_BINARY - CNT_BINARY - 8 :JMPN(outOfCountersBinary) + %MAX_CNT_ARITH - CNT_ARITH - 4 :JMPN(outOfCountersArith) 0 => B $ :EQ,JMPC(getLenEnd) 1 => D @@ -615,9 +615,27 @@ SHLarithfinal: $ => E :MLOAD(tmpVarE2) :JMP(RR) -outOfCounters: - ${eventLog(onError, OOC)} +outOfCountersStep: + ${eventLog(onError, OOCS)} :JMP(handleBatchError) +outOfCountersKeccak: + ${eventLog(onError, OOCK)} + :JMP(handleBatchError) +outOfCountersBinary: + ${eventLog(onError, OOCB)} + :JMP(handleBatchError) +outOfCountersMemalign: + ${eventLog(onError, OOCM)} + :JMP(handleBatchError) +outOfCountersArith: + ${eventLog(onError, OOCA)} + :JMP(handleBatchError) +outOfCountersPadding: + ${eventLog(onError, OOCPA)} + :JMP(handleBatchError) +outOfCountersPoseidon: + ${eventLog(onError, OOCPO)} + :JMP(handleBatchError) outOfGas: ${eventLog(onError, OOG)} :JMP(handleError) @@ -634,13 +652,13 @@ stackOverflow: ${eventLog(onError, overflow)} :JMP(handleError) deployAddressCollision: -${eventLog(onError, invalid)} + ${eventLog(onError, invalid)} :JMP(handleError) invalidStaticTx: -${eventLog(onError, invalid)} + ${eventLog(onError, invalid)} :JMP(handleError) invalidCodeSize: -${eventLog(onError, invalid)} + ${eventLog(onError, invalid)} :JMP(handleError) handleError: ;revert all state changes @@ -789,7 +807,7 @@ doRotate: :JMP(doRotateLoop) doRotateLoop: - %MAX_CNT_STEPS - STEP - 20 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 20 :JMPN(outOfCountersStep) A :JMPN(endRotate) ROTL_C => C A - 1 => A @@ -811,8 +829,8 @@ endPushInit: endPushLoop: - %MAX_CNT_STEPS - STEP - 40 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 4 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 40 :JMPN(outOfCountersStep) + %MAX_CNT_BINARY - CNT_BINARY - 4 :JMPN(outOfCountersBinary) $ => A :MLOAD(leftBytes) $ :EQ, JMPC(endPushFinal) @@ -843,7 +861,7 @@ doRotate2: :JMP(doRotateLoop2) doRotateLoop2: - %MAX_CNT_STEPS - STEP - 20 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 20 :JMPN(outOfCountersStep) A :JMPN(endRotate2) ROTL_C => C A - 1 => A @@ -911,8 +929,8 @@ hashPoseidonLinearFromMemory: 0 => HASHPOS hashPoseidonLoop: - %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCounters) - %MAX_CNT_BINARY - CNT_BINARY - 2 :JMPN(outOfCounters) + %MAX_CNT_STEPS - STEP - 120 :JMPN(outOfCountersStep) + %MAX_CNT_BINARY - CNT_BINARY - 2 :JMPN(outOfCountersBinary) C - 1 :JMPN(hashPoseidonEnd) C - 32 :JMPN(hashPoseidonFinal)