From 279241fcde78a4a89054865a360677efe62f045a Mon Sep 17 00:00:00 2001 From: zkronos73 Date: Sun, 31 Dec 2023 01:53:27 +0100 Subject: [PATCH 1/6] readPush optimization --- main/opcodes/stack-operations.zkasm | 2 +- main/utils.zkasm | 371 +++++++++++++++++++++------- test/read-push-ed.zkasm | 304 +++++++++++++++++++++++ 3 files changed, 587 insertions(+), 90 deletions(-) create mode 100644 test/read-push-ed.zkasm diff --git a/main/opcodes/stack-operations.zkasm b/main/opcodes/stack-operations.zkasm index 5bd3af0b..17d67274 100644 --- a/main/opcodes/stack-operations.zkasm +++ b/main/opcodes/stack-operations.zkasm @@ -169,7 +169,7 @@ opAuxPUSHA2: ; check out-of-gas GAS - %GAS_FASTEST_STEP => GAS :JMPN(outOfGas) ; read bytes from calldata - :CALL(readPush); in: [D: bytes to read] out: [E: value read] + D => E :CALL(readPushTable); in: [D,E: bytes to read] out: [E: value read] ; store stack output E :MSTORE(SP++); [pushed_value(E) => SP] ; check stack overflow diff --git a/main/utils.zkasm b/main/utils.zkasm index 45d5637a..9036d6dc 100644 --- a/main/utils.zkasm +++ b/main/utils.zkasm @@ -991,122 +991,315 @@ invalidCall: 0 :MSTORE(SP++), JMP(readCode) VAR GLOBAL pushBytes -VAR GLOBAL numBlocks -VAR GLOBAL leftBytes -VAR GLOBAL accumulator +VAR GLOBAL pushBytes_RR ; @info Read bytes opcode PUSHX ; @internalParam {numBlocks} 4 bytes blocks to read ; @internalParam {leftBytes} remaining bytes -; @in D => bytes to read +; @in D => bytes to read (1..32) ; @out E => value read + readPush: - %MAX_CNT_STEPS - STEP - 20 :JMPN(outOfCountersStep) - %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary) - D :MSTORE(pushBytes) - D => A - 0 :MSTORE(accumulator) - PC + D - 1 => HASHPOS - - ; B = [b7, b6, ..., b0] - ; JMPN instruction assures b0 is within the range [0, 2**32 - 1] - ${A >> 2} => B :JMPN(failAssert) - B :MSTORE(numBlocks) - ${A & 0x03} => D - D :MSTORE(leftBytes) - - ; since D is assured to be less than 0x04 - ; it is enforced that [b7, b6, ..., b1] are 0 since there is no value multiplied by 4 - ; that equals the field - ; Since b0 is assured to be less than 32 bits, b0 * 4 + d0 could not overflow the field - B * 4 + D :ASSERT - D => A - 0x04 => B - $ :LT,JMPNC(failAssert) - 0 => B + :JMP(@readPush+E) ;0 +; readPush: +; D => E +; readPushTable: +; :JMP(@readPushTable+E) ;0 + +readPush1: + PC => HASHPOS :JMP(_readPush1) ;1 +readPush2: + PC => HASHPOS :JMP(_readPush2) ;2 +readPush3: + PC => HASHPOS :JMP(_readPush3) ;3 +readPush4: + PC => HASHPOS :JMP(_readPush4) ;4 +readPush5: + PC => HASHPOS :JMP(_readPushX) ;5 +readPush6: + PC => HASHPOS :JMP(_readPushX) ;6 +readPush7: + PC => HASHPOS :JMP(_readPushX) ;7 +readPush8: + PC => HASHPOS :JMP(_readPushX) ;8 +readPush9: + PC => HASHPOS :JMP(_readPushX) ;9 +readPush10: + PC => HASHPOS :JMP(_readPushX) ;10 +readPush11: + PC => HASHPOS :JMP(_readPushX) ;11 +readPush12: + PC => HASHPOS :JMP(_readPushX) ;12 +readPush13: + PC => HASHPOS :JMP(_readPushX) ;13 +readPush14: + PC => HASHPOS :JMP(_readPushX) ;14 +readPush15: + PC => HASHPOS :JMP(_readPushX) ;15 +readPush16: + PC => HASHPOS :JMP(_readPushX) ;16 +readPush17: + PC => HASHPOS :JMP(_readPushX) ;17 +readPush18: + PC => HASHPOS :JMP(_readPushX) ;18 +readPush19: + PC => HASHPOS :JMP(_readPushX) ;19 +readPush20: + PC => HASHPOS :JMP(_readPushX) ;20 +readPush21: + PC => HASHPOS :JMP(_readPushX) ;21 +readPush22: + PC => HASHPOS :JMP(_readPushX) ;22 +readPush23: + PC => HASHPOS :JMP(_readPushX) ;23 +readPush24: + PC => HASHPOS :JMP(_readPushX) ;24 +readPush25: + PC => HASHPOS :JMP(_readPushX) ;25 +readPush26: + PC => HASHPOS :JMP(_readPushX) ;26 +readPush27: + PC => HASHPOS :JMP(_readPushX) ;27 +readPush28: + PC => HASHPOS :JMP(_readPushX) ;28 +readPush29: + PC => HASHPOS :JMP(_readPushX) ;29 +readPush30: + PC => HASHPOS :JMP(_readPushX) ;30 +readPush31: + PC => HASHPOS :JMP(_readPushX) ;31 +readPush32: + PC => HASHPOS :JMP(_readPush32) ;32 + +_readPush1: + %MAX_CNT_STEPS - STEP - 4 :JMPN(outOfCountersStep) -readPushBlock: - %MAX_CNT_STEPS - STEP - 20 :JMPN(outOfCountersStep) - %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary) - ; load hash contract identifier $ => E :MLOAD(contractHashId) - $ => A :MLOAD(numBlocks) - $ :EQ, JMPC(endPushInit) - ; read bytes - $ => C :HASHP1(E) - HASHPOS - 2 => HASHPOS + $ => E :HASHP1(E),RETURN + +_readPush2: + %MAX_CNT_STEPS - STEP - 7 :JMPN(outOfCountersStep) + $ => E :MLOAD(contractHashId) + $ => D :HASHP1(E) + $ => E :HASHP1(E) + D * 256 + E => E + 2 => D :RETURN + +_readPush3: + %MAX_CNT_STEPS - STEP - 8 :JMPN(outOfCountersStep) + + $ => E :MLOAD(contractHashId) $ => A :HASHP1(E) - HASHPOS - 2 => HASHPOS - A*256 + C => C + $ => D :HASHP1(E) + $ => E :HASHP1(E) + A * 2**16 + D * 2**8 + E => E + 3 => D :RETURN + +_readPush4: + %MAX_CNT_STEPS - STEP - 8 :JMPN(outOfCountersStep) + $ => E :MLOAD(contractHashId) $ => A :HASHP1(E) - HASHPOS - 2 => HASHPOS - A*65536 + C => C + $ => D :HASHP1(E) + A * 2**8 + D => A + $ => D :HASHP1(E) + $ => E :HASHP1(E) + A * 2**16 + D * 2**8 + E => E + 4 => D :RETURN + + +_readPush32: + %MAX_CNT_STEPS - STEP - 50 :JMPN(outOfCountersStep) + + $ => E :MLOAD(contractHashId) + $ => B :HASHP1(E) + $ => RCX :HASHP1(E) + $ => D :HASHP1(E) $ => A :HASHP1(E) - HASHPOS - 2 => HASHPOS - A*16777216 + C => C + 2**24 * B + 2**16 * RCX + 2**8 * D + A => C -doRotate: - B - 1 => A + ; 28 bytes -doRotateLoop: - %MAX_CNT_STEPS - STEP - 20 :JMPN(outOfCountersStep) - A :JMPN(endRotate) - ROTL_C => C - A - 1 => A :JMP(doRotateLoop) + $ => B :HASHP1(E) + $ => RCX :HASHP1(E) + $ => D :HASHP1(E) + $ => A :HASHP1(E) + ROTL_C + 2**24 * B + 2**16 * RCX + 2**8 * D + A => C -endRotate: - $ => D :MLOAD(accumulator) - C + D => D - D :MSTORE(accumulator) - B + 1 => B :JMP(readPushBlock) + ; 24 bytes -endPushInit: - $ => A :MLOAD(leftBytes), JMPZ(finalPush) - 0 => C - 0 => B :JMP(endPushLoop) + $ => B :HASHP1(E) + $ => RCX :HASHP1(E) + $ => D :HASHP1(E) + $ => A :HASHP1(E) + ROTL_C + 2**24 * B + 2**16 * RCX + 2**8 * D + A => C -endPushLoop: - %MAX_CNT_STEPS - STEP - 20 :JMPN(outOfCountersStep) - %MAX_CNT_BINARY - CNT_BINARY - 4 :JMPN(outOfCountersBinary) + ; 20 bytes - $ => A :MLOAD(leftBytes) - $ :EQ, JMPC(endPushFinal) + $ => B :HASHP1(E) + $ => RCX :HASHP1(E) + $ => D :HASHP1(E) + $ => A :HASHP1(E) + ROTL_C + 2**24 * B + 2**16 * RCX + 2**8 * D + A => C - $ => D :HASHP1(E) - HASHPOS - 2 => HASHPOS - B - 1 => A :JMP(computeFactorLoop) + ; 16 bytes -computeFactorLoop: - %MAX_CNT_STEPS - STEP - 10 :JMPN(outOfCountersStep) - A :JMPN(computeFactorEnd) - 256*D => D - A - 1 => A :JMP(computeFactorLoop) + $ => B :HASHP1(E) + $ => RCX :HASHP1(E) + $ => D :HASHP1(E) + $ => A :HASHP1(E) + ROTL_C + 2**24 * B + 2**16 * RCX + 2**8 * D + A => C -computeFactorEnd: - B + 1 => B - D + C => C :JMP(endPushLoop) + ; 12 bytes -endPushFinal: - $ => B :MLOAD(numBlocks), JMP(doRotate2) + $ => B :HASHP1(E) + $ => RCX :HASHP1(E) + $ => D :HASHP1(E) + $ => A :HASHP1(E) + ROTL_C + 2**24 * B + 2**16 * RCX + 2**8 * D + A => C -doRotate2: - B - 1 => A :JMP(doRotateLoop2) + ; 8 bytes -doRotateLoop2: - %MAX_CNT_STEPS - STEP - 10 :JMPN(outOfCountersStep) - A :JMPN(endRotate2) - ROTL_C => C - A - 1 => A :JMP(doRotateLoop2) + $ => B :HASHP1(E) + $ => RCX :HASHP1(E) + $ => D :HASHP1(E) + $ => A :HASHP1(E) + ROTL_C + 2**24 * B + 2**16 * RCX + 2**8 * D + A => C -endRotate2: - $ => D :MLOAD(accumulator) - C + D => D - D :MSTORE(accumulator), JMP(finalPush) + ; 4 bytes + + $ => B :HASHP1(E) + $ => RCX :HASHP1(E) + $ => D :HASHP1(E) + $ => A :HASHP1(E) + ROTL_C + 2**24 * B + 2**16 * RCX + 2**8 * D + A => E + + $ => RCX :MLOAD(pushBytes_RR) + 32 => D :RETURN + +_readPushX: + %MAX_CNT_STEPS - STEP - 20 - D :JMPN(outOfCountersStep) + D => A,E :MSTORE(pushBytes) + + $ => B :MLOAD(contractHashId) + +readPushBytes: + B => E :JMP(@readPushBytes + E) + + 0 => RCX, B, D, A, C :JMP(readPushBytes_1) + 0 => RCX, B, D, A, C :JMP(readPushBytes_2) + 0 => RCX, B, D, A, C :JMP(readPushBytes_3) + 0 => RCX, B, D, A, C :JMP(readPushBytes_4) + 0 => RCX, B, D, A, C :JMP(readPushBytes_5) + 0 => RCX, B, D, A, C :JMP(readPushBytes_6) + 0 => RCX, B, D, A, C :JMP(readPushBytes_7) + 0 => RCX, B, D, A, C :JMP(readPushBytes_8) + 0 => RCX, B, D, A, C :JMP(readPushBytes_9) + 0 => RCX, B, D, A, C :JMP(readPushBytes_10) + 0 => RCX, B, D, A, C :JMP(readPushBytes_11) + 0 => RCX, B, D, A, C :JMP(readPushBytes_12) + 0 => RCX, B, D, A, C :JMP(readPushBytes_13) + 0 => RCX, B, D, A, C :JMP(readPushBytes_14) + 0 => RCX, B, D, A, C :JMP(readPushBytes_15) + 0 => RCX, B, D, A, C :JMP(readPushBytes_16) + 0 => RCX, B, D, A, C :JMP(readPushBytes_17) + 0 => RCX, B, D, A, C :JMP(readPushBytes_18) + 0 => RCX, B, D, A, C :JMP(readPushBytes_19) + 0 => RCX, B, D, A, C :JMP(readPushBytes_20) + 0 => RCX, B, D, A, C :JMP(readPushBytes_21) + 0 => RCX, B, D, A, C :JMP(readPushBytes_22) + 0 => RCX, B, D, A, C :JMP(readPushBytes_23) + 0 => RCX, B, D, A, C :JMP(readPushBytes_24) + 0 => RCX, B, D, A, C :JMP(readPushBytes_25) + 0 => RCX, B, D, A, C :JMP(readPushBytes_26) + 0 => RCX, B, D, A, C :JMP(readPushBytes_27) + 0 => RCX, B, D, A, C :JMP(readPushBytes_28) + 0 => RCX, B, D, A, C :JMP(readPushBytes_29) + 0 => RCX, B, D, A, C :JMP(readPushBytes_30) + 0 => RCX, B, D, A, C :JMP(readPushBytes_31) + 0 => RCX, B, D, A, C :JMP(readPushBytes_32) + +readPushBytes_32: + $ => B :HASHP1(E) +readPushBytes_31: + $ => RCX :HASHP1(E) +readPushBytes_30: + $ => D :HASHP1(E) +readPushBytes_29: + $ => A :HASHP1(E) + 2**24 * B + 2**16 * RCX + 2**8 * D + A => C + +readPushBytes_28: + $ => B :HASHP1(E) +readPushBytes_27: + $ => RCX :HASHP1(E) +readPushBytes_26: + $ => D :HASHP1(E) +readPushBytes_25: + $ => A :HASHP1(E) + ROTL_C + 2**24 * B + 2**16 * RCX + 2**8 * D + A => C + +readPushBytes_24: + $ => B :HASHP1(E) +readPushBytes_23: + $ => RCX :HASHP1(E) +readPushBytes_22: + $ => D :HASHP1(E) +readPushBytes_21: + $ => A :HASHP1(E) + ROTL_C + 2**24 * B + 2**16 * RCX + 2**8 * D + A => C + +readPushBytes_20: + $ => B :HASHP1(E) +readPushBytes_19: + $ => RCX :HASHP1(E) +readPushBytes_18: + $ => D :HASHP1(E) +readPushBytes_17: + $ => A :HASHP1(E) + ROTL_C + 2**24 * B + 2**16 * RCX + 2**8 * D + A => C + +readPushBytes_16: + $ => B :HASHP1(E) +readPushBytes_15: + $ => RCX :HASHP1(E) +readPushBytes_14: + $ => D :HASHP1(E) +readPushBytes_13: + $ => A :HASHP1(E) + ROTL_C + 2**24 * B + 2**16 * RCX + 2**8 * D + A => C + +readPushBytes_12: + $ => B :HASHP1(E) +readPushBytes_11: + $ => RCX :HASHP1(E) +readPushBytes_10: + $ => D :HASHP1(E) +readPushBytes_9: + $ => A :HASHP1(E) + ROTL_C + 2**24 * B + 2**16 * RCX + 2**8 * D + A => C + +readPushBytes_8: + $ => B :HASHP1(E) +readPushBytes_7: + $ => RCX :HASHP1(E) +readPushBytes_6: + $ => D :HASHP1(E) +readPushBytes_5: + $ => A :HASHP1(E) + ROTL_C + 2**24 * B + 2**16 * RCX + 2**8 * D + A => C + +readPushBytes_4: + $ => B :HASHP1(E) +readPushBytes_3: + $ => RCX :HASHP1(E) +readPushBytes_2: + $ => D :HASHP1(E) +readPushBytes_1: + $ => A :HASHP1(E) + ROTL_C + 2**24 * B + 2**16 * RCX + 2**8 * D + A => E -finalPush: - $ => E :MLOAD(accumulator) $ => D :MLOAD(pushBytes), RETURN VAR GLOBAL tmpVarDaddB diff --git a/test/read-push-ed.zkasm b/test/read-push-ed.zkasm new file mode 100644 index 00000000..32358b8f --- /dev/null +++ b/test/read-push-ed.zkasm @@ -0,0 +1,304 @@ +VAR GLOBAL test + +;; Comments 'readPush' function +; @info Read bytes opcode PUSHX +; @internalParam {numBlocks} 4 bytes blocks to read +; @internalParam {leftBytes} remaining bytes +; @in D => bytes to read +; @out E => value read + +start: + ; init vars + 0 => HASHPOS + 1 => D + $${var rounds} + + ; add bytes one by one + 0x0102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20n => A :CALL(initLoop) + 0x2122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F40n => A :CALL(initLoop) + 0x4142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F60n => A :CALL(initLoop) + + ; close hash + HASHPOS :HASHPLEN(0) + $ :HASHPDIGEST(0) + 0 :MSTORE(contractHashId) + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;;;;; INIT TESTS ;;;;; + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ; log init counters + CNT_BINARY => A + ; ${log(A, binaryCouners)} ; result: 1 + STEP => A + ; ${log(A, stepCounter)} ; result: 202 + + ;; Start test PUSH1 + ; PUSH1 reading 1 byte at position 0 in the bytecode + 0 => PC + 1 => D,E :CALL(readPush) + 0x01 => A + E :ASSERT + + ; PUSH1 reading 1 byte at position 20 in the bytecode + 20 => PC + 1 => D,E :CALL(readPush) + 0x15 => A + E :ASSERT + + ; PUSH1 reading 1 byte at position 31 in the bytecode + 31 => PC + 1 => D,E :CALL(readPush) + 0x20 => A + E :ASSERT + + ; PUSH1 reading 1 byte at position 32 in the bytecode + 32 => PC + 1 => D,E :CALL(readPush) + 0x21 => A + E :ASSERT + + ; PUSH1 reading 1 byte at position 33 in the bytecode + 33 => PC + 1 => D,E :CALL(readPush) + 0x22 => A + E :ASSERT + + ;; Start test PUSH2 + ; PUSH2 reading 2 byte at position 4 in the bytecode + 4 => PC + 2 => D,E :CALL(readPush) + 0x0506 => A + E :ASSERT + + ; PUSH2 reading 2 byte at position 34 in the bytecode + 34 => PC + 2 => D,E :CALL(readPush) + 0x2324 => A + E :ASSERT + + ;; Start test PUSH3 + ; PUSH3 reading 3 byte at position 60 in the bytecode + 60 => PC + 3 => D,E :CALL(readPush) + 0x3d3e3f => A + E :ASSERT + + ;; Start test PUSH4 + ; PUSH4 reading 4 byte at position 72 in the bytecode + 72 => PC + 4 => D,E :CALL(readPush) + 0x494a4b4c => A + E :ASSERT + + ;; Start test PUSH5 + ; PUSH5 reading 5 byte at position 42 in the bytecode + 42 => PC + 5 => D,E :CALL(readPush) + 0x2B2C2D2E2Fn => A + E :ASSERT + + ;; Start test PUSH6 + ; PUSH6 reading 6 byte at position 42 in the bytecode + 42 => PC + 6 => D,E :CALL(readPush) + 0x2B2C2D2E2F30n => A + E :ASSERT + + ;; Start test PUSH7 + ; PUSH7 reading 7 byte at position 42 in the bytecode + 42 => PC + 7 => D,E :CALL(readPush) + 0x2B2C2D2E2F3031n => A + E :ASSERT + + ;; Start test PUSH8 + ; PUSH8 reading 8 byte at position 42 in the bytecode + 42 => PC + 8 => D,E :CALL(readPush) + 0x2B2C2D2E2F303132n => A + E :ASSERT + + ;; Start test PUSH9 + ; PUSH9 reading 9 byte at position 42 in the bytecode + 42 => PC + 9 => D,E :CALL(readPush) + 0x2B2C2D2E2F30313233n => A + E :ASSERT + + ;; Start test PUSH10 + ; PUSH10 reading 10 byte at position 42 in the bytecode + 42 => PC + 10 => D,E :CALL(readPush) + 0x2B2C2D2E2F3031323334n => A + E :ASSERT + + ;; Start test PUSH11 + ; PUSH11 reading 11 byte at position 42 in the bytecode + 42 => PC + 11 => D,E :CALL(readPush) + 0x2B2C2D2E2F303132333435n => A + E :ASSERT + + ;; Start test PUSH12 + ; PUSH12 reading 12 byte at position 42 in the bytecode + 42 => PC + 12 => D,E :CALL(readPush) + 0x2B2C2D2E2F30313233343536n => A + E :ASSERT + + ;; Start test PUSH13 + ; PUSH13 reading 13 byte at position 42 in the bytecode + 42 => PC + 13 => D,E :CALL(readPush) + 0x2B2C2D2E2F3031323334353637n => A + E :ASSERT + + ;; Start test PUSH14 + ; PUSH14 reading 14 byte at position 42 in the bytecode + 42 => PC + 14 => D,E :CALL(readPush) + 0x2B2C2D2E2F303132333435363738n => A + E :ASSERT + + ;; Start test PUSH15 + ; PUSH15 reading 15 byte at position 42 in the bytecode + 42 => PC + 15 => D,E :CALL(readPush) + 0x2B2C2D2E2F30313233343536373839n => A + E :ASSERT + + ;; Start test PUSH16 + ; PUSH16 reading 16 byte at position 42 in the bytecode + 42 => PC + 16 => D,E :CALL(readPush) + 0x2B2C2D2E2F303132333435363738393An => A + E :ASSERT + + ;; Start test PUSH17 + ; PUSH17 reading 17 byte at position 42 in the bytecode + 42 => PC + 17 => D,E :CALL(readPush) + 0x2B2C2D2E2F303132333435363738393A3Bn => A + E :ASSERT + + ;; Start test PUSH18 + ; PUSH18 reading 18 byte at position 42 in the bytecode + 42 => PC + 18 => D,E :CALL(readPush) + 0x2B2C2D2E2F303132333435363738393A3B3Cn => A + E :ASSERT + + ;; Start test PUSH19 + ; PUSH19 reading 19 byte at position 42 in the bytecode + 42 => PC + 19 => D,E :CALL(readPush) + 0x2B2C2D2E2F303132333435363738393A3B3C3Dn => A + E :ASSERT + + ;; Start test PUSH20 + ; PUSH20 reading 20 byte at position 42 in the bytecode + 42 => PC + 20 => D,E :CALL(readPush) + 0x2B2C2D2E2F303132333435363738393A3B3C3D3En => A + E :ASSERT + + ;; Start test PUSH21 + ; PUSH21 reading 21 byte at position 42 in the bytecode + 42 => PC + 21 => D,E :CALL(readPush) + 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3Fn => A + E :ASSERT + + ;; Start test PUSH22 + ; PUSH22 reading 22 byte at position 42 in the bytecode + 42 => PC + 22 => D,E :CALL(readPush) + 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F40n => A + E :ASSERT + + ;; Start test PUSH23 + ; PUSH23 reading 23 byte at position 42 in the bytecode + 42 => PC + 23 => D,E :CALL(readPush) + 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F4041n => A + E :ASSERT + + ;; Start test PUSH24 + ; PUSH24 reading 24 byte at position 42 in the bytecode + 42 => PC + 24 => D,E :CALL(readPush) + 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142n => A + E :ASSERT + + ;; Start test PUSH25 + ; PUSH25 reading 25 byte at position 42 in the bytecode + 42 => PC + 25 => D,E :CALL(readPush) + 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F40414243n => A + E :ASSERT + + ;; Start test PUSH26 + ; PUSH26 reading 26 byte at position 42 in the bytecode + 42 => PC + 26 => D,E :CALL(readPush) + 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F4041424344n => A + E :ASSERT + + ;; Start test PUSH27 + ; PUSH27 reading 27 byte at position 42 in the bytecode + 42 => PC + 27 => D,E :CALL(readPush) + 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445n => A + E :ASSERT + + ;; Start test PUSH28 + ; PUSH28 reading 28 byte at position 42 in the bytecode + 42 => PC + 28 => D,E :CALL(readPush) + 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F40414243444546n => A + E :ASSERT + + ;; Start test PUSH29 + ; PUSH29 reading 29 byte at position 42 in the bytecode + 42 => PC + 29 => D,E :CALL(readPush) + 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F4041424344454647n => A + E :ASSERT + + ;; Start test PUSH30 + ; PUSH30 reading 30 byte at position 42 in the bytecode + 42 => PC + 30 => D,E :CALL(readPush) + 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748n => A + E :ASSERT + + ;; Start test PUSH31 + ; PUSH31 reading 31 byte at position 42 in the bytecode + 42 => PC + 31 => D,E :CALL(readPush) + 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F40414243444546474849n => A + E :ASSERT + + ;; Start test PUSH32 + ; PUSH32 reading 32 byte at position 42 in the bytecode + 42 => PC + 32 => D,E :CALL(readPush) + 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494An => A + E :ASSERT + + 0 => A,B,C,D,E,CTX, SP, PC, GAS, SR, HASHPOS, RR ; Set all registers to 0 + :JMP(finalizeExecution) + +initLoop: + $${rounds = 32} + 0 => B ; to allow $$ + +loopAdd32Byte: + $${rounds = rounds - 1} + ${(A >> (rounds * 8)) & 0xFF} => E :HASHP1(0) + ${rounds} :JMPZ(endLoop, loopAdd32Byte) + +endLoop: + :RETURN + +INCLUDE "../main/main.zkasm" From eee5f107f123632554965cc685af8b247584d755 Mon Sep 17 00:00:00 2001 From: zkronos73 Date: Mon, 8 Jan 2024 14:07:54 +0100 Subject: [PATCH 2/6] update counters read push --- main/utils.zkasm | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/main/utils.zkasm b/main/utils.zkasm index 9036d6dc..09fb1a61 100644 --- a/main/utils.zkasm +++ b/main/utils.zkasm @@ -1071,7 +1071,7 @@ readPush32: PC => HASHPOS :JMP(_readPush32) ;32 _readPush1: - %MAX_CNT_STEPS - STEP - 4 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 2 :JMPN(outOfCountersStep) $ => E :MLOAD(contractHashId) $ => E :HASHP1(E),RETURN @@ -1080,32 +1080,28 @@ _readPush2: %MAX_CNT_STEPS - STEP - 7 :JMPN(outOfCountersStep) $ => E :MLOAD(contractHashId) - $ => D :HASHP1(E) + $ => C :HASHP1(E) $ => E :HASHP1(E) - D * 256 + E => E - 2 => D :RETURN + C * 256 + E => E :RETURN _readPush3: - %MAX_CNT_STEPS - STEP - 8 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 5 :JMPN(outOfCountersStep) $ => E :MLOAD(contractHashId) $ => A :HASHP1(E) - $ => D :HASHP1(E) + $ => C :HASHP1(E) $ => E :HASHP1(E) - A * 2**16 + D * 2**8 + E => E - 3 => D :RETURN + A * 2**16 + C * 2**8 + E => E :RETURN _readPush4: - %MAX_CNT_STEPS - STEP - 8 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 6 :JMPN(outOfCountersStep) $ => E :MLOAD(contractHashId) $ => A :HASHP1(E) - $ => D :HASHP1(E) - A * 2**8 + D => A - $ => D :HASHP1(E) + $ => B :HASHP1(E) + $ => C :HASHP1(E) $ => E :HASHP1(E) - A * 2**16 + D * 2**8 + E => E - 4 => D :RETURN + A * 2**24 + B * 2**16 + C * 2**8 + E => E :RETURN _readPush32: @@ -1185,7 +1181,7 @@ _readPushX: $ => B :MLOAD(contractHashId) readPushBytes: - B => E :JMP(@readPushBytes + E) + B => E :JMP(@readPushBytes + E) 0 => RCX, B, D, A, C :JMP(readPushBytes_1) 0 => RCX, B, D, A, C :JMP(readPushBytes_2) From 2f8e806f634897416cb96b420cf6de674d0ec2ca Mon Sep 17 00:00:00 2001 From: zkronos73 Date: Mon, 8 Jan 2024 15:41:27 +0100 Subject: [PATCH 3/6] fix readPush call --- main/opcodes/stack-operations.zkasm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/opcodes/stack-operations.zkasm b/main/opcodes/stack-operations.zkasm index 17d67274..3eb83b14 100644 --- a/main/opcodes/stack-operations.zkasm +++ b/main/opcodes/stack-operations.zkasm @@ -169,7 +169,7 @@ opAuxPUSHA2: ; check out-of-gas GAS - %GAS_FASTEST_STEP => GAS :JMPN(outOfGas) ; read bytes from calldata - D => E :CALL(readPushTable); in: [D,E: bytes to read] out: [E: value read] + D => E :CALL(readPush); in: [D,E: bytes to read] out: [E: value read] ; store stack output E :MSTORE(SP++); [pushed_value(E) => SP] ; check stack overflow From 19d7d93c1f9beb3ee0e327d4c30413846b9c9b5a Mon Sep 17 00:00:00 2001 From: zkronos73 Date: Tue, 9 Jan 2024 06:59:49 +0100 Subject: [PATCH 4/6] update readPush test to use D,E for bytes --- main/utils.zkasm | 9 +- test/read-push-ed.zkasm | 304 ---------------------------------------- test/read-push.zkasm | 74 +++++----- 3 files changed, 39 insertions(+), 348 deletions(-) delete mode 100644 test/read-push-ed.zkasm diff --git a/main/utils.zkasm b/main/utils.zkasm index 09fb1a61..ce283ed3 100644 --- a/main/utils.zkasm +++ b/main/utils.zkasm @@ -995,16 +995,11 @@ VAR GLOBAL pushBytes_RR ; @info Read bytes opcode PUSHX ; @internalParam {numBlocks} 4 bytes blocks to read ; @internalParam {leftBytes} remaining bytes -; @in D => bytes to read (1..32) +; @in D,E => bytes to read (1..32) ; @out E => value read readPush: :JMP(@readPush+E) ;0 -; readPush: -; D => E -; readPushTable: -; :JMP(@readPushTable+E) ;0 - readPush1: PC => HASHPOS :JMP(_readPush1) ;1 readPush2: @@ -1171,7 +1166,6 @@ _readPush32: $ => A :HASHP1(E) ROTL_C + 2**24 * B + 2**16 * RCX + 2**8 * D + A => E - $ => RCX :MLOAD(pushBytes_RR) 32 => D :RETURN _readPushX: @@ -1216,6 +1210,7 @@ readPushBytes: 0 => RCX, B, D, A, C :JMP(readPushBytes_31) 0 => RCX, B, D, A, C :JMP(readPushBytes_32) + readPushBytes_32: $ => B :HASHP1(E) readPushBytes_31: diff --git a/test/read-push-ed.zkasm b/test/read-push-ed.zkasm deleted file mode 100644 index 32358b8f..00000000 --- a/test/read-push-ed.zkasm +++ /dev/null @@ -1,304 +0,0 @@ -VAR GLOBAL test - -;; Comments 'readPush' function -; @info Read bytes opcode PUSHX -; @internalParam {numBlocks} 4 bytes blocks to read -; @internalParam {leftBytes} remaining bytes -; @in D => bytes to read -; @out E => value read - -start: - ; init vars - 0 => HASHPOS - 1 => D - $${var rounds} - - ; add bytes one by one - 0x0102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20n => A :CALL(initLoop) - 0x2122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F40n => A :CALL(initLoop) - 0x4142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F60n => A :CALL(initLoop) - - ; close hash - HASHPOS :HASHPLEN(0) - $ :HASHPDIGEST(0) - 0 :MSTORE(contractHashId) - - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - ;;;;; INIT TESTS ;;;;; - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - ; log init counters - CNT_BINARY => A - ; ${log(A, binaryCouners)} ; result: 1 - STEP => A - ; ${log(A, stepCounter)} ; result: 202 - - ;; Start test PUSH1 - ; PUSH1 reading 1 byte at position 0 in the bytecode - 0 => PC - 1 => D,E :CALL(readPush) - 0x01 => A - E :ASSERT - - ; PUSH1 reading 1 byte at position 20 in the bytecode - 20 => PC - 1 => D,E :CALL(readPush) - 0x15 => A - E :ASSERT - - ; PUSH1 reading 1 byte at position 31 in the bytecode - 31 => PC - 1 => D,E :CALL(readPush) - 0x20 => A - E :ASSERT - - ; PUSH1 reading 1 byte at position 32 in the bytecode - 32 => PC - 1 => D,E :CALL(readPush) - 0x21 => A - E :ASSERT - - ; PUSH1 reading 1 byte at position 33 in the bytecode - 33 => PC - 1 => D,E :CALL(readPush) - 0x22 => A - E :ASSERT - - ;; Start test PUSH2 - ; PUSH2 reading 2 byte at position 4 in the bytecode - 4 => PC - 2 => D,E :CALL(readPush) - 0x0506 => A - E :ASSERT - - ; PUSH2 reading 2 byte at position 34 in the bytecode - 34 => PC - 2 => D,E :CALL(readPush) - 0x2324 => A - E :ASSERT - - ;; Start test PUSH3 - ; PUSH3 reading 3 byte at position 60 in the bytecode - 60 => PC - 3 => D,E :CALL(readPush) - 0x3d3e3f => A - E :ASSERT - - ;; Start test PUSH4 - ; PUSH4 reading 4 byte at position 72 in the bytecode - 72 => PC - 4 => D,E :CALL(readPush) - 0x494a4b4c => A - E :ASSERT - - ;; Start test PUSH5 - ; PUSH5 reading 5 byte at position 42 in the bytecode - 42 => PC - 5 => D,E :CALL(readPush) - 0x2B2C2D2E2Fn => A - E :ASSERT - - ;; Start test PUSH6 - ; PUSH6 reading 6 byte at position 42 in the bytecode - 42 => PC - 6 => D,E :CALL(readPush) - 0x2B2C2D2E2F30n => A - E :ASSERT - - ;; Start test PUSH7 - ; PUSH7 reading 7 byte at position 42 in the bytecode - 42 => PC - 7 => D,E :CALL(readPush) - 0x2B2C2D2E2F3031n => A - E :ASSERT - - ;; Start test PUSH8 - ; PUSH8 reading 8 byte at position 42 in the bytecode - 42 => PC - 8 => D,E :CALL(readPush) - 0x2B2C2D2E2F303132n => A - E :ASSERT - - ;; Start test PUSH9 - ; PUSH9 reading 9 byte at position 42 in the bytecode - 42 => PC - 9 => D,E :CALL(readPush) - 0x2B2C2D2E2F30313233n => A - E :ASSERT - - ;; Start test PUSH10 - ; PUSH10 reading 10 byte at position 42 in the bytecode - 42 => PC - 10 => D,E :CALL(readPush) - 0x2B2C2D2E2F3031323334n => A - E :ASSERT - - ;; Start test PUSH11 - ; PUSH11 reading 11 byte at position 42 in the bytecode - 42 => PC - 11 => D,E :CALL(readPush) - 0x2B2C2D2E2F303132333435n => A - E :ASSERT - - ;; Start test PUSH12 - ; PUSH12 reading 12 byte at position 42 in the bytecode - 42 => PC - 12 => D,E :CALL(readPush) - 0x2B2C2D2E2F30313233343536n => A - E :ASSERT - - ;; Start test PUSH13 - ; PUSH13 reading 13 byte at position 42 in the bytecode - 42 => PC - 13 => D,E :CALL(readPush) - 0x2B2C2D2E2F3031323334353637n => A - E :ASSERT - - ;; Start test PUSH14 - ; PUSH14 reading 14 byte at position 42 in the bytecode - 42 => PC - 14 => D,E :CALL(readPush) - 0x2B2C2D2E2F303132333435363738n => A - E :ASSERT - - ;; Start test PUSH15 - ; PUSH15 reading 15 byte at position 42 in the bytecode - 42 => PC - 15 => D,E :CALL(readPush) - 0x2B2C2D2E2F30313233343536373839n => A - E :ASSERT - - ;; Start test PUSH16 - ; PUSH16 reading 16 byte at position 42 in the bytecode - 42 => PC - 16 => D,E :CALL(readPush) - 0x2B2C2D2E2F303132333435363738393An => A - E :ASSERT - - ;; Start test PUSH17 - ; PUSH17 reading 17 byte at position 42 in the bytecode - 42 => PC - 17 => D,E :CALL(readPush) - 0x2B2C2D2E2F303132333435363738393A3Bn => A - E :ASSERT - - ;; Start test PUSH18 - ; PUSH18 reading 18 byte at position 42 in the bytecode - 42 => PC - 18 => D,E :CALL(readPush) - 0x2B2C2D2E2F303132333435363738393A3B3Cn => A - E :ASSERT - - ;; Start test PUSH19 - ; PUSH19 reading 19 byte at position 42 in the bytecode - 42 => PC - 19 => D,E :CALL(readPush) - 0x2B2C2D2E2F303132333435363738393A3B3C3Dn => A - E :ASSERT - - ;; Start test PUSH20 - ; PUSH20 reading 20 byte at position 42 in the bytecode - 42 => PC - 20 => D,E :CALL(readPush) - 0x2B2C2D2E2F303132333435363738393A3B3C3D3En => A - E :ASSERT - - ;; Start test PUSH21 - ; PUSH21 reading 21 byte at position 42 in the bytecode - 42 => PC - 21 => D,E :CALL(readPush) - 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3Fn => A - E :ASSERT - - ;; Start test PUSH22 - ; PUSH22 reading 22 byte at position 42 in the bytecode - 42 => PC - 22 => D,E :CALL(readPush) - 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F40n => A - E :ASSERT - - ;; Start test PUSH23 - ; PUSH23 reading 23 byte at position 42 in the bytecode - 42 => PC - 23 => D,E :CALL(readPush) - 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F4041n => A - E :ASSERT - - ;; Start test PUSH24 - ; PUSH24 reading 24 byte at position 42 in the bytecode - 42 => PC - 24 => D,E :CALL(readPush) - 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142n => A - E :ASSERT - - ;; Start test PUSH25 - ; PUSH25 reading 25 byte at position 42 in the bytecode - 42 => PC - 25 => D,E :CALL(readPush) - 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F40414243n => A - E :ASSERT - - ;; Start test PUSH26 - ; PUSH26 reading 26 byte at position 42 in the bytecode - 42 => PC - 26 => D,E :CALL(readPush) - 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F4041424344n => A - E :ASSERT - - ;; Start test PUSH27 - ; PUSH27 reading 27 byte at position 42 in the bytecode - 42 => PC - 27 => D,E :CALL(readPush) - 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445n => A - E :ASSERT - - ;; Start test PUSH28 - ; PUSH28 reading 28 byte at position 42 in the bytecode - 42 => PC - 28 => D,E :CALL(readPush) - 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F40414243444546n => A - E :ASSERT - - ;; Start test PUSH29 - ; PUSH29 reading 29 byte at position 42 in the bytecode - 42 => PC - 29 => D,E :CALL(readPush) - 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F4041424344454647n => A - E :ASSERT - - ;; Start test PUSH30 - ; PUSH30 reading 30 byte at position 42 in the bytecode - 42 => PC - 30 => D,E :CALL(readPush) - 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748n => A - E :ASSERT - - ;; Start test PUSH31 - ; PUSH31 reading 31 byte at position 42 in the bytecode - 42 => PC - 31 => D,E :CALL(readPush) - 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F40414243444546474849n => A - E :ASSERT - - ;; Start test PUSH32 - ; PUSH32 reading 32 byte at position 42 in the bytecode - 42 => PC - 32 => D,E :CALL(readPush) - 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494An => A - E :ASSERT - - 0 => A,B,C,D,E,CTX, SP, PC, GAS, SR, HASHPOS, RR ; Set all registers to 0 - :JMP(finalizeExecution) - -initLoop: - $${rounds = 32} - 0 => B ; to allow $$ - -loopAdd32Byte: - $${rounds = rounds - 1} - ${(A >> (rounds * 8)) & 0xFF} => E :HASHP1(0) - ${rounds} :JMPZ(endLoop, loopAdd32Byte) - -endLoop: - :RETURN - -INCLUDE "../main/main.zkasm" diff --git a/test/read-push.zkasm b/test/read-push.zkasm index 2dd66de7..32358b8f 100644 --- a/test/read-push.zkasm +++ b/test/read-push.zkasm @@ -35,254 +35,254 @@ start: ;; Start test PUSH1 ; PUSH1 reading 1 byte at position 0 in the bytecode 0 => PC - 1 => D :CALL(readPush) + 1 => D,E :CALL(readPush) 0x01 => A E :ASSERT ; PUSH1 reading 1 byte at position 20 in the bytecode 20 => PC - 1 => D :CALL(readPush) + 1 => D,E :CALL(readPush) 0x15 => A E :ASSERT ; PUSH1 reading 1 byte at position 31 in the bytecode 31 => PC - 1 => D :CALL(readPush) + 1 => D,E :CALL(readPush) 0x20 => A E :ASSERT ; PUSH1 reading 1 byte at position 32 in the bytecode 32 => PC - 1 => D :CALL(readPush) + 1 => D,E :CALL(readPush) 0x21 => A E :ASSERT ; PUSH1 reading 1 byte at position 33 in the bytecode 33 => PC - 1 => D :CALL(readPush) + 1 => D,E :CALL(readPush) 0x22 => A E :ASSERT ;; Start test PUSH2 ; PUSH2 reading 2 byte at position 4 in the bytecode 4 => PC - 2 => D :CALL(readPush) + 2 => D,E :CALL(readPush) 0x0506 => A E :ASSERT ; PUSH2 reading 2 byte at position 34 in the bytecode 34 => PC - 2 => D :CALL(readPush) + 2 => D,E :CALL(readPush) 0x2324 => A E :ASSERT ;; Start test PUSH3 ; PUSH3 reading 3 byte at position 60 in the bytecode 60 => PC - 3 => D :CALL(readPush) + 3 => D,E :CALL(readPush) 0x3d3e3f => A E :ASSERT ;; Start test PUSH4 ; PUSH4 reading 4 byte at position 72 in the bytecode 72 => PC - 4 => D :CALL(readPush) + 4 => D,E :CALL(readPush) 0x494a4b4c => A E :ASSERT ;; Start test PUSH5 ; PUSH5 reading 5 byte at position 42 in the bytecode 42 => PC - 5 => D :CALL(readPush) + 5 => D,E :CALL(readPush) 0x2B2C2D2E2Fn => A E :ASSERT ;; Start test PUSH6 ; PUSH6 reading 6 byte at position 42 in the bytecode 42 => PC - 6 => D :CALL(readPush) + 6 => D,E :CALL(readPush) 0x2B2C2D2E2F30n => A E :ASSERT ;; Start test PUSH7 ; PUSH7 reading 7 byte at position 42 in the bytecode 42 => PC - 7 => D :CALL(readPush) + 7 => D,E :CALL(readPush) 0x2B2C2D2E2F3031n => A E :ASSERT ;; Start test PUSH8 ; PUSH8 reading 8 byte at position 42 in the bytecode 42 => PC - 8 => D :CALL(readPush) + 8 => D,E :CALL(readPush) 0x2B2C2D2E2F303132n => A E :ASSERT ;; Start test PUSH9 ; PUSH9 reading 9 byte at position 42 in the bytecode 42 => PC - 9 => D :CALL(readPush) + 9 => D,E :CALL(readPush) 0x2B2C2D2E2F30313233n => A E :ASSERT ;; Start test PUSH10 ; PUSH10 reading 10 byte at position 42 in the bytecode 42 => PC - 10 => D :CALL(readPush) + 10 => D,E :CALL(readPush) 0x2B2C2D2E2F3031323334n => A E :ASSERT ;; Start test PUSH11 ; PUSH11 reading 11 byte at position 42 in the bytecode 42 => PC - 11 => D :CALL(readPush) + 11 => D,E :CALL(readPush) 0x2B2C2D2E2F303132333435n => A E :ASSERT ;; Start test PUSH12 ; PUSH12 reading 12 byte at position 42 in the bytecode 42 => PC - 12 => D :CALL(readPush) + 12 => D,E :CALL(readPush) 0x2B2C2D2E2F30313233343536n => A E :ASSERT ;; Start test PUSH13 ; PUSH13 reading 13 byte at position 42 in the bytecode 42 => PC - 13 => D :CALL(readPush) + 13 => D,E :CALL(readPush) 0x2B2C2D2E2F3031323334353637n => A E :ASSERT ;; Start test PUSH14 ; PUSH14 reading 14 byte at position 42 in the bytecode 42 => PC - 14 => D :CALL(readPush) + 14 => D,E :CALL(readPush) 0x2B2C2D2E2F303132333435363738n => A E :ASSERT ;; Start test PUSH15 ; PUSH15 reading 15 byte at position 42 in the bytecode 42 => PC - 15 => D :CALL(readPush) + 15 => D,E :CALL(readPush) 0x2B2C2D2E2F30313233343536373839n => A E :ASSERT ;; Start test PUSH16 ; PUSH16 reading 16 byte at position 42 in the bytecode 42 => PC - 16 => D :CALL(readPush) + 16 => D,E :CALL(readPush) 0x2B2C2D2E2F303132333435363738393An => A E :ASSERT ;; Start test PUSH17 ; PUSH17 reading 17 byte at position 42 in the bytecode 42 => PC - 17 => D :CALL(readPush) + 17 => D,E :CALL(readPush) 0x2B2C2D2E2F303132333435363738393A3Bn => A E :ASSERT ;; Start test PUSH18 ; PUSH18 reading 18 byte at position 42 in the bytecode 42 => PC - 18 => D :CALL(readPush) + 18 => D,E :CALL(readPush) 0x2B2C2D2E2F303132333435363738393A3B3Cn => A E :ASSERT ;; Start test PUSH19 ; PUSH19 reading 19 byte at position 42 in the bytecode 42 => PC - 19 => D :CALL(readPush) + 19 => D,E :CALL(readPush) 0x2B2C2D2E2F303132333435363738393A3B3C3Dn => A E :ASSERT ;; Start test PUSH20 ; PUSH20 reading 20 byte at position 42 in the bytecode 42 => PC - 20 => D :CALL(readPush) + 20 => D,E :CALL(readPush) 0x2B2C2D2E2F303132333435363738393A3B3C3D3En => A E :ASSERT ;; Start test PUSH21 ; PUSH21 reading 21 byte at position 42 in the bytecode 42 => PC - 21 => D :CALL(readPush) + 21 => D,E :CALL(readPush) 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3Fn => A E :ASSERT ;; Start test PUSH22 ; PUSH22 reading 22 byte at position 42 in the bytecode 42 => PC - 22 => D :CALL(readPush) + 22 => D,E :CALL(readPush) 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F40n => A E :ASSERT ;; Start test PUSH23 ; PUSH23 reading 23 byte at position 42 in the bytecode 42 => PC - 23 => D :CALL(readPush) + 23 => D,E :CALL(readPush) 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F4041n => A E :ASSERT ;; Start test PUSH24 ; PUSH24 reading 24 byte at position 42 in the bytecode 42 => PC - 24 => D :CALL(readPush) + 24 => D,E :CALL(readPush) 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142n => A E :ASSERT ;; Start test PUSH25 ; PUSH25 reading 25 byte at position 42 in the bytecode 42 => PC - 25 => D :CALL(readPush) + 25 => D,E :CALL(readPush) 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F40414243n => A E :ASSERT ;; Start test PUSH26 ; PUSH26 reading 26 byte at position 42 in the bytecode 42 => PC - 26 => D :CALL(readPush) + 26 => D,E :CALL(readPush) 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F4041424344n => A E :ASSERT ;; Start test PUSH27 ; PUSH27 reading 27 byte at position 42 in the bytecode 42 => PC - 27 => D :CALL(readPush) + 27 => D,E :CALL(readPush) 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445n => A E :ASSERT ;; Start test PUSH28 ; PUSH28 reading 28 byte at position 42 in the bytecode 42 => PC - 28 => D :CALL(readPush) + 28 => D,E :CALL(readPush) 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F40414243444546n => A E :ASSERT ;; Start test PUSH29 ; PUSH29 reading 29 byte at position 42 in the bytecode 42 => PC - 29 => D :CALL(readPush) + 29 => D,E :CALL(readPush) 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F4041424344454647n => A E :ASSERT ;; Start test PUSH30 ; PUSH30 reading 30 byte at position 42 in the bytecode 42 => PC - 30 => D :CALL(readPush) + 30 => D,E :CALL(readPush) 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748n => A E :ASSERT ;; Start test PUSH31 ; PUSH31 reading 31 byte at position 42 in the bytecode 42 => PC - 31 => D :CALL(readPush) + 31 => D,E :CALL(readPush) 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F40414243444546474849n => A E :ASSERT ;; Start test PUSH32 ; PUSH32 reading 32 byte at position 42 in the bytecode 42 => PC - 32 => D :CALL(readPush) + 32 => D,E :CALL(readPush) 0x2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494An => A E :ASSERT From 8ad87a614e0ed77bf8f55a0d898198404f6d1615 Mon Sep 17 00:00:00 2001 From: krlosMata Date: Mon, 5 Feb 2024 15:54:58 +0100 Subject: [PATCH 5/6] run gha on develop-feijoa --- .github/workflows/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index ed4e69b8..80264b76 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -6,7 +6,7 @@ name: Test executor inputs on: workflow_dispatch: pull_request: - branches: [main, develop, develop-etrog, feature/fork-etrog, feature/l1-info-tree] + branches: [main, develop, develop-feijoa] jobs: build: From 100d36432f1e7b8d967be41a29602c7605ac7820 Mon Sep 17 00:00:00 2001 From: zkronos73 Date: Wed, 7 Feb 2024 12:50:37 +0100 Subject: [PATCH 6/6] adjust steps on counter verification --- main/utils.zkasm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/utils.zkasm b/main/utils.zkasm index ce283ed3..4910a645 100644 --- a/main/utils.zkasm +++ b/main/utils.zkasm @@ -1072,7 +1072,7 @@ _readPush1: $ => E :HASHP1(E),RETURN _readPush2: - %MAX_CNT_STEPS - STEP - 7 :JMPN(outOfCountersStep) + %MAX_CNT_STEPS - STEP - 4 :JMPN(outOfCountersStep) $ => E :MLOAD(contractHashId) $ => C :HASHP1(E)