diff --git a/main/constants.zkasm b/main/constants.zkasm index d177f2df..1601026a 100644 --- a/main/constants.zkasm +++ b/main/constants.zkasm @@ -7,7 +7,6 @@ CONST %TX_GAS_LIMIT = 30000000 CONSTL %BLOCK_GAS_LIMIT = 2**50 CONST %MAX_MEM_EXPANSION_BYTES = 0x3fffe0 CONST %FORK_ID = 8 -CONST %L1INFO_TREE_LEVELS = 32 CONST %CALLDATA_RESERVED_CTX = 1 CONSTL %FOUR_GOLDILOCKS = 0xffffffff00000001ffffffff00000001ffffffff00000001ffffffff00000001n diff --git a/main/l2-tx-hash.zkasm b/main/l2-tx-hash.zkasm index deb5ae77..397c6d29 100644 --- a/main/l2-tx-hash.zkasm +++ b/main/l2-tx-hash.zkasm @@ -65,7 +65,6 @@ addL2HashTx: ;; Write 1 byte to l2TxHash: flag deployment = 1 ('0': no deployment transaction, '1': deployment transaction) addL2HashTx_isDeploy: ; store temporary register values - A :MSTORE(tmpVar_A_L2HashTx) E :MSTORE(tmpVar_E_L2HashTx) HASHPOS :MSTORE(tmpVar_HASHPOS_L2HashTx) @@ -76,7 +75,6 @@ addL2HashTx_isDeploy: HASHPOS :MSTORE(l2HASHP) ; load temporary register values - $ => A :MLOAD(tmpVar_A_L2HashTx) $ => E :MLOAD(tmpVar_E_L2HashTx) $ => HASHPOS :MLOAD(tmpVar_HASHPOS_L2HashTx), RETURN diff --git a/main/load-change-l2-block.zkasm b/main/load-change-l2-block.zkasm index e26e7415..5c7ab02c 100644 --- a/main/load-change-l2-block.zkasm +++ b/main/load-change-l2-block.zkasm @@ -13,16 +13,16 @@ decodeChangeL2BlockTx: %DELTA_TIMESTAMP_NUM_BYTES => D :CALL(getChangeL2TxBytes) C + D => C :CALL(addBatchHashData) A :MSTORE(deltaTimestamp) + ; Decode indexL1InfoTree / 4 bytes %INDEX_L1INFOTREE_NUM_BYTES => D :CALL(getChangeL2TxBytes) C + D => C :CALL(addBatchHashData) A :MSTORE(indexL1InfoTree) - 1 :MSTORE(isChangeL2BlockTx), JMP(finishLoadChangeL2BlockTx) + 1 :MSTORE(isChangeL2BlockTx) -finishLoadChangeL2BlockTx: -;; update bytes parsed - $ => A :MLOAD(batchL2DataParsed) - A + C :MSTORE(batchL2DataParsed) -;; increase number of transaction to process - $ => A :MLOAD(pendingTxs) - A + 1 :MSTORE(pendingTxs), JMP(txLoopRLP) \ No newline at end of file + ; update bytes parsed + $ => A :MLOAD(batchL2DataParsed) + A + C :MSTORE(batchL2DataParsed) + ; increase number of transaction to process + $ => A :MLOAD(pendingTxs) + A + 1 :MSTORE(pendingTxs), JMP(txLoopRLP) \ No newline at end of file diff --git a/main/load-tx-rlp.zkasm b/main/load-tx-rlp.zkasm index b7f846bf..18e4e2e8 100644 --- a/main/load-tx-rlp.zkasm +++ b/main/load-tx-rlp.zkasm @@ -58,7 +58,7 @@ loadTx_rlp_continue: ; A new hash with position 0 is started 0 => HASHPOS A :HASHK(E) - A - 0xc0 :JMPN(invalidTxRLP) + A - 0xc1 :JMPN(invalidTxRLP) A - 0xf8 :JMPN(shortList) ; do not allow lists over 2**24 bytes length ; Transaction could not have more than 120.000 due to smart contract limitation (keccaks counters) diff --git a/main/modexp/modexp_utils.zkasm b/main/modexp/modexp_utils.zkasm index 39d5b019..153a3f07 100644 --- a/main/modexp/modexp_utils.zkasm +++ b/main/modexp/modexp_utils.zkasm @@ -217,7 +217,7 @@ modexp_saveModLen: ; if last value == 0 --> modexp_saveModLen $ :EQ,JMPC(modexp_saveModLen) ; else Mlen == modExpArrayIndex + 1 - E + 1 :MSTORE(modexp_Mlen),JMP(modexp_getReturn) + E + 1 :MSTORE(modexp_Mlen) modexp_getReturn: $ => RR :MLOAD(tmpZkPCmodexp) diff --git a/main/opcodes/arithmetic.zkasm b/main/opcodes/arithmetic.zkasm index 97652330..e1a6c9b4 100644 --- a/main/opcodes/arithmetic.zkasm +++ b/main/opcodes/arithmetic.zkasm @@ -315,7 +315,7 @@ opEXP: * - stack input: [b,x] * - stack output: [y] */ -opSIGNEXTEND: ; following this impl https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/vm/src/evm/opcodes/functions.ts#L193 +opSIGNEXTEND: ; following this impl https://github.com/0xPolygonHermez/ethereumjs-monorepo/blob/2349ebfab9d9a7d89cc91ff194b9ab4a30e7ebdc/packages/vm/src/evm/opcodes/functions.ts#L225 ; checks zk-counters %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) %MAX_CNT_BINARY - CNT_BINARY - 6 :JMPN(outOfCountersBinary) diff --git a/main/opcodes/comparison.zkasm b/main/opcodes/comparison.zkasm index 6a7ef2d9..b678fe08 100644 --- a/main/opcodes/comparison.zkasm +++ b/main/opcodes/comparison.zkasm @@ -281,7 +281,7 @@ opNOT: ; read one item from the stack $ => A :MLOAD(SP-1) - 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn => B ; 2**256 - 1 => + %MAX_UINT_256 => B $ => A :XOR,MSTORE(SP-1), JMP(readCode) ; [ NOT a => SP] /** @@ -425,7 +425,7 @@ negativeValue: %MAX_UINT_256 => B $ => A :XOR ; [~A => A] C => D :CALL(SHRarithBit) ; [shift (bits) => D]; [ A >> D => A] - $ => A :XOR, JMP(endSAR) ; [~A => A] + $ => A :XOR ; [~A => A] endSAR: ; check shifted result is greater than 0 diff --git a/main/opcodes/logs.zkasm b/main/opcodes/logs.zkasm index ca8f75fa..b5f9081b 100644 --- a/main/opcodes/logs.zkasm +++ b/main/opcodes/logs.zkasm @@ -122,7 +122,7 @@ opLOG4: GAS => A ; check out-of-gas $ :LT,JMPC(outOfGas) - GAS - B => GAS :JMP(initLogLoop) + GAS - B => GAS initLogLoop: ; check poseidon counters @@ -158,7 +158,6 @@ opLogFinal: C => D $ => E :MLOAD(nextHashPId) A :HASHP(E) - :JMP(opSaveTopicsInit) ; instruction added to allow executing $$ function opSaveTopicsInit: ; save topics diff --git a/main/utils.zkasm b/main/utils.zkasm index 3552759b..6fcf5c88 100644 --- a/main/utils.zkasm +++ b/main/utils.zkasm @@ -485,8 +485,7 @@ saveMem: saveMemGAS: ; store new memory length - B :MSTORE(memLength) - B => E + B => E :MSTORE(memLength) ; memory_size_word = (memory_byte_size + 31) / 32 in E ; ${(B+31)/32} => E E + 31 => A @@ -814,7 +813,6 @@ SHLarithinit: SHLarith0: 0 => E - :JMP(SHLarithfinal) SHLarithfinal: E => A @@ -1353,10 +1351,13 @@ checkBytecodeStartsEF: ; get 1 byte from memory 1 => C :CALL(MLOADX) ; in: [E: offset, C: length] out: [A: value , E: new offset] - 31 => D :CALL(SHRarith) ; in: [A: value, D: #bytes to right shift] out: [A: shifted result] + ; mask first byte + 0xFF00000000000000000000000000000000000000000000000000000000000000n => B + $ => A :AND ; check if byte read is equal to 0xEF - %BYTECODE_STARTS_EF - A :JMPNZ(checkBytecodeStartsEFend) + 0xEF00000000000000000000000000000000000000000000000000000000000000n => B + $ :EQ, JMPNC(checkBytecodeStartsEFend) 1 :MSTORE(startsWithEF) checkBytecodeStartsEFend: @@ -2279,7 +2280,6 @@ VAR GLOBAL readXFromCalldataResult VAR GLOBAL tmpVarAReadXFromOffset VAR GLOBAL tmpVarBReadXFromOffset VAR GLOBAL tmpVarCReadXFromOffset -VAR GLOBAL tmpVarDReadXFromOffset VAR GLOBAL tmpVarEReadXFromOffset ; @info Reads {readXFromCalldataOffset} bytes (max 32) from a given offset in calldata memory. If offset or offset + length exceeds txCalldataLen, zeros are added ; @internalParam {readXFromCalldataOffset} offset to read from calldata