diff --git a/main/constants.zkasm b/main/constants.zkasm index a4a5355e..52f04e49 100644 --- a/main/constants.zkasm +++ b/main/constants.zkasm @@ -29,7 +29,7 @@ CONST %SSTORE_RESET_GAS = 2900 CONST %SSTORE_CLEARS_SCHEDULE = 15000 ; COUNTERS -CONST %MAX_CNT_STEPS = 2**23 +CONST %MAX_CNT_STEPS = 2**23 - 200 ; 200 = min steps to finish tx CONST %MAX_CNT_ARITH = %MAX_CNT_STEPS / 32 CONST %MAX_CNT_BINARY = %MAX_CNT_STEPS / 32 diff --git a/main/opcodes/arithmetic.zkasm b/main/opcodes/arithmetic.zkasm index 54657697..63618915 100644 --- a/main/opcodes/arithmetic.zkasm +++ b/main/opcodes/arithmetic.zkasm @@ -11,7 +11,7 @@ opADD: ; checks zk-counters %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) ; check stack underflow SP - 2 :JMPN(stackUnderflow) @@ -33,7 +33,7 @@ opADD: opMUL: %MAX_CNT_ARITH - CNT_ARITH - 1 :JMPN(outOfCountersArith) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -52,7 +52,7 @@ opMUL: opSUB: %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -67,7 +67,7 @@ opDIV: %MAX_CNT_ARITH - CNT_ARITH - 1 :JMPN(outOfCountersArith) %MAX_CNT_BINARY - CNT_BINARY - 2 :JMPN(outOfCountersBinary) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -87,7 +87,7 @@ opSDIV: %MAX_CNT_ARITH - CNT_ARITH - 1 :JMPN(outOfCountersArith) %MAX_CNT_BINARY - CNT_BINARY - 8 :JMPN(outOfCountersBinary) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -133,7 +133,7 @@ opMOD: %MAX_CNT_ARITH - CNT_ARITH - 1 :JMPN(outOfCountersArith) %MAX_CNT_BINARY - CNT_BINARY - 2 :JMPN(outOfCountersBinary) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -153,7 +153,7 @@ opSMOD: %MAX_CNT_ARITH - CNT_ARITH - 1 :JMPN(outOfCountersArith) %MAX_CNT_BINARY - CNT_BINARY - 8 :JMPN(outOfCountersBinary) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -197,7 +197,7 @@ opADDMOD: %MAX_CNT_ARITH - CNT_ARITH - 1 :JMPN(outOfCountersArith) %MAX_CNT_BINARY - CNT_BINARY - 4 :JMPN(outOfCountersBinary) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 80 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 80 :JMPN(outOfCountersStep) GAS-8 => GAS :JMPN(outOfGas) @@ -255,7 +255,7 @@ opMULMOD: opEXP: %MAX_CNT_BINARY - CNT_BINARY - 5 :JMPN(outOfCountersBinary) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP @@ -272,7 +272,7 @@ opEXP: 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(outOfCountersArith) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 2 :JMPN(stackUnderflow) SP - 1 => SP diff --git a/main/opcodes/block.zkasm b/main/opcodes/block.zkasm index 6fa10e9e..e3a5d7e5 100644 --- a/main/opcodes/block.zkasm +++ b/main/opcodes/block.zkasm @@ -4,7 +4,7 @@ opBLOCKHASH: %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 255 :JMPN(outOfCountersPoseidon) $ => A :MLOAD(cntKeccakPreProcess) %MAX_CNT_KECCAK_F - CNT_KECCAK_F - A - 1 :JMPN(outOfCountersKeccak) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 1 => SP :JMPN(stackUnderflow) GAS - 20 => GAS :JMPN(outOfGas) @@ -42,7 +42,7 @@ opBLOCKHASHzero: opCOINBASE: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) $ => A :MLOAD(sequencerAddr) A :MSTORE(SP++) @@ -52,7 +52,7 @@ opCOINBASE: opTIMESTAMP: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) $ => A :MLOAD(timestamp) A :MSTORE(SP++) @@ -62,7 +62,7 @@ opTIMESTAMP: opNUMBER: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) ; Get current tx count $ => D :MLOAD(txCount) @@ -73,7 +73,7 @@ opNUMBER: opDIFFICULTY: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) %BATCH_DIFFICULTY => A A :MSTORE(SP++) @@ -83,7 +83,7 @@ opDIFFICULTY: opGASLIMIT: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) %TX_GAS_LIMIT => A A :MSTORE(SP++) @@ -93,7 +93,7 @@ opGASLIMIT: opCHAINID: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) $ => A :MLOAD(chainID) A :MSTORE(SP++) @@ -102,7 +102,7 @@ opCHAINID: :JMP(readCode) opBASEFEE: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) 0 :MSTORE(SP++) 1024 - SP :JMPN(stackOverflow) diff --git a/main/opcodes/calldata-returndata-code.zkasm b/main/opcodes/calldata-returndata-code.zkasm index 5b106803..7451b38d 100644 --- a/main/opcodes/calldata-returndata-code.zkasm +++ b/main/opcodes/calldata-returndata-code.zkasm @@ -4,7 +4,7 @@ opCALLDATALOAD: %MAX_CNT_ARITH - CNT_ARITH - 64 :JMPN(outOfCountersArith) %MAX_CNT_BINARY - CNT_BINARY - 66 :JMPN(outOfCountersBinary) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 1 => SP :JMPN(stackUnderflow) $ => B :MLOAD(SP) @@ -52,7 +52,7 @@ CALLDATALOADreturn0: opCALLDATASIZE: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) $ => A :MLOAD(isCreateContract) 0 - A :JMPN(opCALLDATASIZEdep) @@ -75,7 +75,7 @@ opCALLDATACOPY: %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 - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 3 :JMPN(stackUnderflow) SP - 1 => SP @@ -102,7 +102,7 @@ opCALLDATACOPYinit: %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 - MIN_STEPS_FINISH_TX - STEP - 200 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCountersStep) C - 1 :JMPN(opCALLDATACOPYcheckLen) C - 32 :JMPN(opCALLDATACOPYfinal) @@ -196,7 +196,7 @@ opCALLDATACOPYend: opCODESIZE: %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 252 :JMPN(outOfCountersPoseidon) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) $ => A :MLOAD(isCreateContract) 0 - A :JMPN(opCODESIZEdep) @@ -236,7 +236,7 @@ opCODECOPY: ;Check counters %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCountersBinary) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) GAS - 3 => GAS :JMPN(outOfGas) GAS - ${3*((E+31)/32)} => GAS :JMPN(outOfGas) @@ -262,7 +262,7 @@ opCODECOPY2: opCODECOPYinit: %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCountersBinary) %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 510 :JMPN(outOfCountersPoseidon) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) %MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 2 :JMPN(outOfCountersMemalign) $ => B :MLOAD(remainingBytes) @@ -308,7 +308,7 @@ readValueBytecode: opEXTCODESIZE: %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 255 :JMPN(outOfCountersPoseidon) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 1 => SP :JMPN(stackUnderflow) $ => A :MLOAD(SP) @@ -334,7 +334,7 @@ opEXTCODECOPY: %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 510 :JMPN(outOfCountersPoseidon) %MAX_CNT_PADDING_PG - CNT_PADDING_PG - 11 :JMPN(outOfCountersPadding) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 4 :JMPN(stackUnderflow) SP - 1 => SP @@ -351,7 +351,7 @@ opEXTCODECOPY: ;Check counters should be before than do all the operations! TODO %MAX_CNT_BINARY - CNT_BINARY - 32 :JMPN(outOfCountersBinary) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) %MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 2 :JMPN(outOfCountersMemalign) @@ -408,7 +408,7 @@ opEXTCODECOPYCheckHash: ; TODO: it could be improved by computing how many 32 bytes slots are needed opEXTCODECOPYCheckHashLoop: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) B - 1 :JMPN(opEXTCODECOPYCheckHashLoopEnd) ; finish reading bytecode 1 => D @@ -426,7 +426,7 @@ opEXTCODECOPYCheckHashEnd: opEXTCODECOPYinit: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) C - 1 :JMPN(readCode) C - 32 :JMPN(opEXTCODECOPYfinal) @@ -448,7 +448,7 @@ opEXTCODECOPYfinal: opRETURNDATASIZE: %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) ; Load ret data length from last ctx ; If no retDataCTX(0), retDataLength = 0 @@ -480,7 +480,7 @@ opRETURNDATACOPY: %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 - MIN_STEPS_FINISH_TX - STEP - 400 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 400 :JMPN(outOfCountersStep) %MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 2 :JMPN(outOfCountersMemalign) :CALL(saveMem) @@ -521,7 +521,7 @@ opRETURNDATACOPY: GAS - A => GAS :JMPN(outOfGas) opRETURNDATACOPYinit: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) C - 1 :JMPN(readCode) C - 32 :JMPN(opRETURNDATACOPYfinal) @@ -560,7 +560,7 @@ opRETURNDATACOPYEmpty: opEXTCODEHASH: %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 255 :JMPN(outOfCountersPoseidon) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 1 => SP :JMPN(stackUnderflow) $ => A :MLOAD(SP) diff --git a/main/opcodes/context-information.zkasm b/main/opcodes/context-information.zkasm index 4c984add..0bd9ec0d 100644 --- a/main/opcodes/context-information.zkasm +++ b/main/opcodes/context-information.zkasm @@ -1,5 +1,5 @@ opADDRESS: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) $ => A :MLOAD(isCreateContract) 0 - A :JMPN(opADDRESSdeploy) @@ -18,7 +18,7 @@ opADDRESSend: opSELFBALANCE: %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 255 :JMPN(outOfCountersPoseidon) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) $ => A :MLOAD(storageAddr) 0 => B,C ; balance key smt @@ -30,7 +30,7 @@ opSELFBALANCE: opBALANCE: %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 252 :JMPN(outOfCountersPoseidon) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 1 => SP :JMPN(stackUnderflow) $ => A :MLOAD(SP) @@ -45,7 +45,7 @@ opBALANCE: opORIGIN: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) $ => A :MLOAD(txSrcOriginAddr) A :MSTORE(SP++) @@ -55,7 +55,7 @@ opORIGIN: opCALLER: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) $ => A :MLOAD(txSrcAddr) A :MSTORE(SP++) @@ -65,7 +65,7 @@ opCALLER: opCALLVALUE: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) $ => A :MLOAD(txValue) A :MSTORE(SP++) @@ -75,7 +75,7 @@ opCALLVALUE: opGASPRICE: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) $ => A :MLOAD(txGasPrice) A :MSTORE(SP++) @@ -84,7 +84,7 @@ opGASPRICE: :JMP(readCode) opGAS: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) GAS - 2 => GAS :JMPN(outOfGas) GAS :MSTORE(SP++) diff --git a/main/opcodes/create-terminate-context.zkasm b/main/opcodes/create-terminate-context.zkasm index ca21ce2f..dbfadc01 100644 --- a/main/opcodes/create-terminate-context.zkasm +++ b/main/opcodes/create-terminate-context.zkasm @@ -79,7 +79,7 @@ opCREATE: %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 - MIN_STEPS_FINISH_TX - STEP - 400 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 400 :JMPN(outOfCountersStep) ; store lastMemOffset for memory expansion gas cost E :MSTORE(lastMemOffset) @@ -182,7 +182,7 @@ opCreateFail: opCALL: ; checks zk-counters - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 400 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 400 :JMPN(outOfCountersStep) ; increase depth $ => A :MLOAD(depth) A + 1 :MSTORE(depth) @@ -240,7 +240,7 @@ opCALL2: %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 - MIN_STEPS_FINISH_TX - STEP - 400:JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 400:JMPN(outOfCountersStep) $ => B :MLOAD(lastMemOffset) ; check if an address is cold. If it is, add it to the touched tree @@ -321,7 +321,7 @@ opCALLend: opCALLCODE: ; checks zk-counters - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 400 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 400 :JMPN(outOfCountersStep) ; increase depth $ => A :MLOAD(depth) A + 1 :MSTORE(depth) @@ -368,7 +368,7 @@ opCALLCODE: %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 - MIN_STEPS_FINISH_TX - STEP - 400:JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 400:JMPN(outOfCountersStep) ; check if an address is cold. If it is, add it to the touched tree $ => A :MLOAD(addrCall) @@ -451,7 +451,7 @@ opRETURN: %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 - MIN_STEPS_FINISH_TX - STEP - 400 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 400 :JMPN(outOfCountersStep) ; store return data values E :MSTORE(retDataOffset) C :MSTORE(retDataLength) @@ -493,7 +493,7 @@ preRETURN32: opRETURN32: ; checks dynamic zk-counters %MAX_CNT_BINARY - CNT_BINARY - 10 :JMPN(outOfCountersBinary) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 200 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCountersStep) %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 510 :JMPN(outOfCountersPoseidon) C - 1 :JMPN(opRETURNend) @@ -559,7 +559,7 @@ opRETURNcreate: %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 - MIN_STEPS_FINISH_TX - STEP - 400 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 400 :JMPN(outOfCountersStep) ; save offset memory and length to compute contract hash E :MSTORE(memOffsetLinearPoseidon) @@ -621,7 +621,7 @@ opRETURNcreateEnd: */ opDELEGATECALL: ; checks zk-counters - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 400 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 400 :JMPN(outOfCountersStep) ; increase depth $ => A :MLOAD(depth) A + 1 :MSTORE(depth) @@ -665,7 +665,7 @@ opDELEGATECALL: %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 - MIN_STEPS_FINISH_TX - STEP - 400:JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 400:JMPN(outOfCountersStep) $ => B :MLOAD(lastMemOffset) @@ -754,7 +754,7 @@ opCREATE2: %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 - MIN_STEPS_FINISH_TX - STEP - 400 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 400 :JMPN(outOfCountersStep) ; store lastMemOffset for memory expansion gas cost E :MSTORE(lastMemOffset) @@ -901,7 +901,7 @@ opSTATICCALL: %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 - MIN_STEPS_FINISH_TX - STEP - 400 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 400 :JMPN(outOfCountersStep) ; check if an address is cold. If it is, add it to the touched tree $ => A :MLOAD(addrCall) @@ -954,7 +954,7 @@ opSTATICCALL: */ opREVERT: ; checks zk-counters - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 400 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 400 :JMPN(outOfCountersStep) ; check stack underflow SP - 2 :JMPN(stackUnderflow) ; load initSR to revert al state changes @@ -1000,7 +1000,7 @@ preREVERT32: opREVERT32: ; checks zk-counters - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 200 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCountersStep) C - 1 :JMPN(opREVERTend) C - 32 :JMPN(opREVERTfinal) @@ -1060,7 +1060,7 @@ opSENDALL: ; checks zk-counters %MAX_CNT_BINARY - CNT_BINARY - 10 :JMPN(outOfCountersBinary) %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 2040 :JMPN(outOfCountersPoseidon) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 400 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 400 :JMPN(outOfCountersStep) ; check stack underflow SP - 1 => SP :JMPN(stackUnderflow) @@ -1156,5 +1156,5 @@ opSENDALLend: */ opINVALID: ; checks zk-counters - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) :JMP(invalidProcess) diff --git a/main/opcodes/crypto.zkasm b/main/opcodes/crypto.zkasm index 38fa8a7d..573cf34b 100644 --- a/main/opcodes/crypto.zkasm +++ b/main/opcodes/crypto.zkasm @@ -19,7 +19,7 @@ opSHA3: $ => A :MLOAD(cntKeccakPreProcess) %MAX_CNT_KECCAK_F - CNT_KECCAK_F - A - 1 :JMPN(outOfCountersKeccak) %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 10 :JMPN(outOfCountersPoseidon) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) ; check stack underflow SP - 2 :JMPN(stackUnderflow) @@ -61,7 +61,7 @@ opSHA3: opSHA3Loop: ; checks zk-counters %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) C - 1 :JMPN(opSHA3End) C - 32 :JMPN(opSHA3Final) diff --git a/main/opcodes/flow-control.zkasm b/main/opcodes/flow-control.zkasm index 5cd796d6..d53ab03c 100644 --- a/main/opcodes/flow-control.zkasm +++ b/main/opcodes/flow-control.zkasm @@ -11,7 +11,7 @@ opJUMP: ; checks zk-counters %MAX_CNT_BINARY - CNT_BINARY - 2 :JMPN(outOfCountersBinary) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) ; check stack underflow SP - 1 => SP :JMPN(stackUnderflow) @@ -33,7 +33,7 @@ opJUMP: */ opJUMPI: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary) SP - 2 => SP :JMPN(stackUnderflow) @@ -116,7 +116,7 @@ checkJumpDestDeploymentCreate: */ opPC: ; checks zk-counters - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) ; check out-of-gas GAS - 2 => GAS :JMPN(outOfGas) @@ -138,7 +138,7 @@ opPC: opJUMPDEST: ; checks zk-counters - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) ; check out-of-gas GAS - 1 => GAS :JMPN(outOfGas) diff --git a/main/opcodes/logs.zkasm b/main/opcodes/logs.zkasm index feef3911..df381a73 100644 --- a/main/opcodes/logs.zkasm +++ b/main/opcodes/logs.zkasm @@ -9,7 +9,7 @@ */ opLOG0: ; checks zk-counters - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) ; check stack underflow SP - 2 :JMPN(stackUnderflow) @@ -47,7 +47,7 @@ opLOG0: opLOG1: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 3 :JMPN(stackUnderflow) GAS - 375 => GAS :JMPN(outOfGas) @@ -74,7 +74,7 @@ opLOG1: opLOG2: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 4 :JMPN(stackUnderflow) GAS - 375 => GAS :JMPN(outOfGas) @@ -101,7 +101,7 @@ opLOG2: opLOG3: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 5 :JMPN(stackUnderflow) GAS - 375 => GAS :JMPN(outOfGas) @@ -128,7 +128,7 @@ opLOG3: opLOG4: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 6 :JMPN(stackUnderflow) GAS - 375 => GAS :JMPN(outOfGas) @@ -156,7 +156,7 @@ opLOG4: opLOGLoop: ; checks zk-counters %MAX_CNT_BINARY - CNT_BINARY - 2 :JMPN(outOfCountersBinary) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) C - 1 :JMPN(opSaveTopicsInit) C - 32 :JMPN(opLOGFinal) @@ -177,7 +177,7 @@ opSaveTopicsInit: opSaveTopicsLoop: ; checks zk-counters - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) A - 1 :JMPN(readCode) ; check stack underflow diff --git a/main/opcodes/stack-operations.zkasm b/main/opcodes/stack-operations.zkasm index 263dcbce..8432de31 100644 --- a/main/opcodes/stack-operations.zkasm +++ b/main/opcodes/stack-operations.zkasm @@ -207,7 +207,7 @@ opPUSH32: opAuxPUSHA: ; checks zk-counters %MAX_CNT_BINARY - CNT_BINARY - 6 :JMPN(outOfCountersBinary) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) $ => B :MLOAD(bytecodeLength) PC + D => A @@ -231,7 +231,7 @@ opAuxPUSHA2: opAuxPUSHB: ; checks zk-counters %MAX_CNT_BINARY - CNT_BINARY - 6 :JMPN(outOfCountersBinary) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 400 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 400 :JMPN(outOfCountersStep) ; check is a create/create2 $ => A :MLOAD(isCreate) 0 - A :JMPN(opAuxPUSHBcreate) @@ -241,7 +241,7 @@ opAuxPUSHB: opAuxPUSHBloop: ; checks zk-counters - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) %MAX_CNT_BINARY - CNT_BINARY - 4 :JMPN(outOfCountersBinary) %MAX_CNT_ARITH - CNT_ARITH - 4 :JMPN(outOfCountersArith) @@ -306,7 +306,7 @@ opAuxPUSHBcreate: */ opDUP1: ; checks zk-counters - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) ; check stack underflow SP - 1 => SP :JMPN(stackUnderflow) @@ -325,7 +325,7 @@ opDUP1: opDUP2: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 2 => SP :JMPN(stackUnderflow) GAS - 3 => GAS :JMPN(outOfGas) @@ -337,7 +337,7 @@ opDUP2: opDUP3: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 3 => SP :JMPN(stackUnderflow) GAS - 3 => GAS :JMPN(outOfGas) @@ -349,7 +349,7 @@ opDUP3: opDUP4: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 4 => SP :JMPN(stackUnderflow) GAS - 3 => GAS :JMPN(outOfGas) @@ -361,7 +361,7 @@ opDUP4: opDUP5: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 5 => SP :JMPN(stackUnderflow) GAS - 3 => GAS :JMPN(outOfGas) @@ -373,7 +373,7 @@ opDUP5: opDUP6: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 6 => SP :JMPN(stackUnderflow) GAS - 3 => GAS :JMPN(outOfGas) @@ -385,7 +385,7 @@ opDUP6: opDUP7: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 7 => SP :JMPN(stackUnderflow) GAS - 3 => GAS :JMPN(outOfGas) @@ -397,7 +397,7 @@ opDUP7: opDUP8: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 8 => SP :JMPN(stackUnderflow) GAS - 3 => GAS :JMPN(outOfGas) @@ -409,7 +409,7 @@ opDUP8: opDUP9: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 9 => SP :JMPN(stackUnderflow) GAS - 3 => GAS :JMPN(outOfGas) @@ -421,7 +421,7 @@ opDUP9: opDUP10: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 10 => SP :JMPN(stackUnderflow) GAS - 3 => GAS :JMPN(outOfGas) @@ -433,7 +433,7 @@ opDUP10: opDUP11: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 11 => SP :JMPN(stackUnderflow) GAS - 3 => GAS :JMPN(outOfGas) @@ -445,7 +445,7 @@ opDUP11: opDUP12: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 12 => SP :JMPN(stackUnderflow) GAS - 3 => GAS :JMPN(outOfGas) @@ -457,7 +457,7 @@ opDUP12: opDUP13: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 13 => SP :JMPN(stackUnderflow) GAS - 3 => GAS :JMPN(outOfGas) @@ -469,7 +469,7 @@ opDUP13: opDUP14: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 14 => SP :JMPN(stackUnderflow) GAS - 3 => GAS :JMPN(outOfGas) @@ -481,7 +481,7 @@ opDUP14: opDUP15: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 15 => SP :JMPN(stackUnderflow) GAS - 3 => GAS :JMPN(outOfGas) @@ -493,7 +493,7 @@ opDUP15: opDUP16: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 16 => SP :JMPN(stackUnderflow) GAS - 3 => GAS :JMPN(outOfGas) @@ -512,7 +512,7 @@ opDUP16: */ opSWAP1: ; checks zk-counters - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) ; check stack underflow SP - 2 :JMPN(stackUnderflow) @@ -535,7 +535,7 @@ opSWAP1: opSWAP2: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 3 :JMPN(stackUnderflow) GAS - 3 => GAS :JMPN(outOfGas) @@ -551,7 +551,7 @@ opSWAP2: opSWAP3: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 4 :JMPN(stackUnderflow) GAS - 3 => GAS :JMPN(outOfGas) @@ -567,7 +567,7 @@ opSWAP3: opSWAP4: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 5 :JMPN(stackUnderflow) GAS - 3 => GAS :JMPN(outOfGas) @@ -583,7 +583,7 @@ opSWAP4: opSWAP5: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 6 :JMPN(stackUnderflow) GAS - 3 => GAS :JMPN(outOfGas) @@ -599,7 +599,7 @@ opSWAP5: opSWAP6: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 7 :JMPN(stackUnderflow) GAS - 3 => GAS :JMPN(outOfGas) @@ -615,7 +615,7 @@ opSWAP6: opSWAP7: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 8 :JMPN(stackUnderflow) GAS - 3 => GAS :JMPN(outOfGas) @@ -631,7 +631,7 @@ opSWAP7: opSWAP8: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 9 :JMPN(stackUnderflow) GAS - 3 => GAS :JMPN(outOfGas) @@ -647,7 +647,7 @@ opSWAP8: opSWAP9: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 10 :JMPN(stackUnderflow) GAS - 3 => GAS :JMPN(outOfGas) @@ -663,7 +663,7 @@ opSWAP9: opSWAP10: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 11 :JMPN(stackUnderflow) GAS - 3 => GAS :JMPN(outOfGas) @@ -679,7 +679,7 @@ opSWAP10: opSWAP11: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 12 :JMPN(stackUnderflow) GAS - 3 => GAS :JMPN(outOfGas) @@ -695,7 +695,7 @@ opSWAP11: opSWAP12: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 13 :JMPN(stackUnderflow) GAS - 3 => GAS :JMPN(outOfGas) @@ -711,7 +711,7 @@ opSWAP12: opSWAP13: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 14 :JMPN(stackUnderflow) GAS - 3 => GAS :JMPN(outOfGas) @@ -727,7 +727,7 @@ opSWAP13: opSWAP14: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 15 :JMPN(stackUnderflow) GAS - 3 => GAS :JMPN(outOfGas) @@ -743,7 +743,7 @@ opSWAP14: opSWAP15: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 16 :JMPN(stackUnderflow) GAS - 3 => GAS :JMPN(outOfGas) @@ -759,7 +759,7 @@ opSWAP15: opSWAP16: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) SP - 17 :JMPN(stackUnderflow) GAS - 3 => GAS :JMPN(outOfGas) @@ -783,7 +783,7 @@ opSWAP16: */ opPOP: ; checks zk-counters - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) ; check stack underflow SP - 1 => SP :JMPN(stackUnderflow) diff --git a/main/opcodes/storage-memory.zkasm b/main/opcodes/storage-memory.zkasm index cf72ec0c..80dd933e 100644 --- a/main/opcodes/storage-memory.zkasm +++ b/main/opcodes/storage-memory.zkasm @@ -16,7 +16,7 @@ opMLOAD: %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 - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) ; check stack underflow SP - 1 => SP :JMPN(stackUnderflow) @@ -56,7 +56,7 @@ opMLOAD: %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 - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) ; check stack underflow SP - 2 :JMPN(stackUnderflow) @@ -96,7 +96,7 @@ opMSTORE8: %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 - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) ; check stack underflow SP - 2 :JMPN(stackUnderflow) @@ -139,7 +139,7 @@ opMSIZE: ; checks zk-counters %MAX_CNT_ARITH - CNT_ARITH - 1 :JMPN(outOfCountersArith) %MAX_CNT_BINARY - CNT_BINARY - 3 :JMPN(outOfCountersBinary) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) ; check out-of-gas GAS - 2 => GAS :JMPN(outOfGas) @@ -177,7 +177,7 @@ MSIZEend: opSLOAD: ; checks zk-counters %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 255 :JMPN(outOfCountersPoseidon) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) ; check stack underflow SP - 1 => SP :JMPN(stackUnderflow) @@ -213,7 +213,7 @@ opSSTORE: %MAX_CNT_BINARY - CNT_BINARY - 10 :JMPN(outOfCountersBinary) %MAX_CNT_MEM_ALIGN - CNT_MEM_ALIGN - 1 :JMPN(outOfCountersMemalign) %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 765 :JMPN(outOfCountersPoseidon) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 400 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 400 :JMPN(outOfCountersStep) ; check stack underflow SP - 2 :JMPN(stackUnderflow) diff --git a/main/precompiled/identity.zkasm b/main/precompiled/identity.zkasm index 567b2b58..ce2cbb66 100644 --- a/main/precompiled/identity.zkasm +++ b/main/precompiled/identity.zkasm @@ -23,7 +23,7 @@ IDENTITY: IDENTITYinit: %MAX_CNT_BINARY - CNT_BINARY - 10 :JMPN(outOfCountersBinary) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) ; Copy from calldata to memory C - 1 :JMPN(IDENTITYreturn) C - 32 :JMPN(IDENTITYfinal) @@ -60,7 +60,7 @@ IDENTITYreturn2: IDENTITYreturnLoop: %MAX_CNT_BINARY - CNT_BINARY - 10 :JMPN(outOfCountersBinary) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 200 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 200 :JMPN(outOfCountersStep) %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - 510 :JMPN(outOfCountersPoseidon) C - 1 :JMPN(IDENTITYend) C - 32 :JMPN(IDENTITYreturnFinal) diff --git a/main/process-tx.zkasm b/main/process-tx.zkasm index 63168bf0..2ca93d1d 100644 --- a/main/process-tx.zkasm +++ b/main/process-tx.zkasm @@ -31,7 +31,7 @@ processTx: SR :MSTORE(initSR) ; Minimum of 100000 steps left to process a tx - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100000 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100000 :JMPN(outOfCountersStep) ; Get sigDataSize $ => HASHPOS :MLOAD(sigDataSize) @@ -139,7 +139,7 @@ addGas: 0 => C :JMP(loopBytes) loopBytes: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 10 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 10 :JMPN(outOfCountersStep) A - C - 1 :JMPN(endCalldataIntrinsicGas) E => B 1 => D @@ -281,7 +281,7 @@ create2: $ => B :MLOAD(argsOffsetCall) loopCreate2: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) %MAX_CNT_BINARY - CNT_BINARY - 4 :JMPN(outOfCountersBinary) C - 1 :JMPN(create2end) @@ -468,7 +468,6 @@ callContract: %MAX_CNT_STEPS - STEP - 2 * B :JMPN(outOfCountersStep) checkHashBytecodeLoop: - %MAX_CNT_STEPS - STEP - 20 :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 72b9dd82..923f5007 100644 --- a/main/utils.zkasm +++ b/main/utils.zkasm @@ -48,7 +48,7 @@ copySP: copyInit: %MAX_CNT_BINARY - CNT_BINARY - 10 :JMPN(outOfCountersBinary) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) C - 1 :JMPN(copyEnd) C - 32 :JMPN(copyFinal) zkPC+1 => RR :JMP(MLOAD32) @@ -81,7 +81,7 @@ getLenBytes: B => A getLenBytesLoop: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %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 @@ -111,7 +111,7 @@ getLenBits: B => A getLenBitsLoop: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary) %MAX_CNT_ARITH - CNT_ARITH - 1 :JMPN(outOfCountersArith) @@ -874,7 +874,7 @@ doRotate: :JMP(doRotateLoop) doRotateLoop: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) A :JMPN(endRotate) ROTL_C => C A - 1 => A @@ -896,7 +896,7 @@ endPushInit: endPushLoop: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) %MAX_CNT_BINARY - CNT_BINARY - 4 :JMPN(outOfCountersBinary) $ => A :MLOAD(leftBytes) @@ -928,7 +928,7 @@ doRotate2: :JMP(doRotateLoop2) doRotateLoop2: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) A :JMPN(endRotate2) ROTL_C => C A - 1 => A @@ -996,7 +996,7 @@ hashPoseidonLinearFromMemory: 0 => HASHPOS hashPoseidonLoop: - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) %MAX_CNT_BINARY - CNT_BINARY - 2 :JMPN(outOfCountersBinary) C - 1 :JMPN(hashPoseidonEnd) @@ -1079,7 +1079,7 @@ utilMULMOD: %MAX_CNT_ARITH - CNT_ARITH - 3 :JMPN(outOfCountersArith) %MAX_CNT_BINARY - CNT_BINARY - 3 :JMPN(outOfCountersBinary) - %MAX_CNT_STEPS - MIN_STEPS_FINISH_TX - STEP - 100 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) RR :MSTORE(tmpZkPC4) A :MSTORE(tmpVarA)