From 91ad6beedd001ec626a8c819a0aee52aa318f290 Mon Sep 17 00:00:00 2001 From: Ignasi Date: Thu, 19 Jan 2023 10:26:37 +0100 Subject: [PATCH 1/2] Check savemem before other checks --- main/opcodes/calldata-returndata-code.zkasm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main/opcodes/calldata-returndata-code.zkasm b/main/opcodes/calldata-returndata-code.zkasm index 9d9c188a..eb10876f 100644 --- a/main/opcodes/calldata-returndata-code.zkasm +++ b/main/opcodes/calldata-returndata-code.zkasm @@ -284,7 +284,8 @@ opCODECOPY: C :MSTORE(lastMemOffset) ; store lastMemLength for memory expansion gas cost E :MSTORE(lastMemLength) - + ; compute memory expansion gas cost + :CALL(saveMem); in: [lastMemOffset, lastMemLength] ; check out-of-gas GAS - %GAS_FASTEST_STEP => GAS :JMPN(outOfGas) ;${3*((E+31)/32)} @@ -301,8 +302,7 @@ opCODECOPY: GAS - A => GAS :JMPN(outOfGas) - ; compute memory expansion gas cost - :CALL(saveMem); in: [lastMemOffset, lastMemLength] + ; if offset is above data len, length => offset D => A $ => B :MLOAD(bytecodeLength) From a87267331adf82c745e7fda301a54b68166e5ee7 Mon Sep 17 00:00:00 2001 From: Ignasi Date: Thu, 19 Jan 2023 16:53:05 +0100 Subject: [PATCH 2/2] Fix rom to new proverjs fea2scalar 32 bytes limitation --- counters/tests/addBatchHashByteByByte.zkasm | 6 +++--- main/opcodes/calldata-returndata-code.zkasm | 5 ++++- package.json | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/counters/tests/addBatchHashByteByByte.zkasm b/counters/tests/addBatchHashByteByByte.zkasm index 83be5e69..58fd66e3 100644 --- a/counters/tests/addBatchHashByteByByte.zkasm +++ b/counters/tests/addBatchHashByteByByte.zkasm @@ -8,13 +8,13 @@ operation: ;@in: A: bytes to add ;@in D: bytes length 12 => A - 80 => D + 31 => D :CALL(addBatchHashByteByByte) %ADDBATCHHASH_STEP*D - STEP:JMPN(failedCounters) - 305 - CNT_BINARY :JMPNZ(failedCounters) + 155 - CNT_BINARY :JMPNZ(failedCounters) ;%ADDBATCHHASH_CNT_BINARY*D + D - CNT_BINARY :JMPNZ(failedCounters) - 81 - CNT_ARITH :JMPNZ(failedCounters) + 31 - CNT_ARITH :JMPNZ(failedCounters) ;%ADDBATCHHASH_CNT_ARITH*D - CNT_ARITH :JMPNZ(failedCounters) %ADDBATCHHASH_CNT_KECCAK_F - CNT_KECCAK_F :JMPNZ(failedCounters) %ADDBATCHHASH_CNT_MEM_ALIGN - CNT_MEM_ALIGN :JMPNZ(failedCounters) diff --git a/main/opcodes/calldata-returndata-code.zkasm b/main/opcodes/calldata-returndata-code.zkasm index eb10876f..47983565 100644 --- a/main/opcodes/calldata-returndata-code.zkasm +++ b/main/opcodes/calldata-returndata-code.zkasm @@ -618,7 +618,10 @@ opRETURNDATACOPYfinal: opRETURNDATACOPYEmpty: ; offset return data + len return data must be 0 - E + C => B + E => A + C => B + $ => B :ADD, JMPC(outOfGas) + 0 => A $ :EQ, JMPC(readCode, outOfGas) /** diff --git a/package.json b/package.json index ca997aa9..b92973c5 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "yargs": "^17.5.1" }, "devDependencies": { - "@0xpolygonhermez/zkevm-proverjs": "github:0xPolygonHermez/zkevm-proverjs#a5584acbcfef38924c52d5788d326da3cec623dc", + "@0xpolygonhermez/zkevm-proverjs": "github:0xPolygonHermez/zkevm-proverjs#develop", "@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#develop", "chai": "^4.3.6", "chalk": "^3.0.0",