From 37cf6bc990c8435aa01fef46b1c3589fa9d9db05 Mon Sep 17 00:00:00 2001 From: Ignasi Date: Tue, 11 Jun 2024 16:37:22 +0200 Subject: [PATCH 01/13] Dont revert touched address on deploy collision --- main/process-tx.zkasm | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/main/process-tx.zkasm b/main/process-tx.zkasm index 72766493..696eaa44 100644 --- a/main/process-tx.zkasm +++ b/main/process-tx.zkasm @@ -330,9 +330,9 @@ deploy: %MAX_CNT_POSEIDON_G - CNT_POSEIDON_G - %MAX_CNT_POSEIDON_SLOAD_SSTORE*3 :JMPN(outOfCountersPoseidon) %MAX_CNT_BINARY - CNT_BINARY - 3 :JMPN(outOfCountersBinary) :CALL(isColdAddress) ; add address to touched addresses + A => E :CALL(checkpointTouched) ; new address is ward even after error ; check if address is deployable ( nonce == bytecode == 0) - A => E - + E => A ; read nonce 0 => C %SMT_KEY_NONCE => B diff --git a/package.json b/package.json index 123cf032..72f1326c 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "devDependencies": { "@0xpolygonhermez/zkevm-commonjs": "github:0xPolygonHermez/zkevm-commonjs#v6.0.0-fork.9", "@0xpolygonhermez/zkevm-proverjs": "github:0xPolygonHermez/zkevm-proverjs#39508f69cb191487a065ffbf76c647cd83b59720", - "@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#v6.0.1-fork.9", + "@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#feature/address-collision", "chai": "^4.3.6", "chalk": "^3.0.0", "eslint": "^8.25.0", From 9778f2ce4a35f42953b1ea72466b481bbb581a23 Mon Sep 17 00:00:00 2001 From: Laia Soler Date: Mon, 22 Jul 2024 16:06:25 +0200 Subject: [PATCH 02/13] update package test-vectors develop --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 72f1326c..49b53e29 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "devDependencies": { "@0xpolygonhermez/zkevm-commonjs": "github:0xPolygonHermez/zkevm-commonjs#v6.0.0-fork.9", "@0xpolygonhermez/zkevm-proverjs": "github:0xPolygonHermez/zkevm-proverjs#39508f69cb191487a065ffbf76c647cd83b59720", - "@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#feature/address-collision", + "@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#develop", "chai": "^4.3.6", "chalk": "^3.0.0", "eslint": "^8.25.0", From 277b6631e89bc71e80847066fb490bd45c7c4f47 Mon Sep 17 00:00:00 2001 From: Laia Soler Date: Mon, 22 Jul 2024 17:40:25 +0200 Subject: [PATCH 03/13] N=25 --- main/constants.zkasm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/constants.zkasm b/main/constants.zkasm index ac187c9a..70a54eaf 100644 --- a/main/constants.zkasm +++ b/main/constants.zkasm @@ -103,7 +103,7 @@ CONST %SSTORE_CLEARS_SCHEDULE = 15000 ; COUNTERS CONST %MIN_STEPS_FINISH_BATCH = 200 ; min steps to finish tx -CONST %TOTAL_STEPS_LIMIT = 2**23 +CONST %TOTAL_STEPS_LIMIT = 2**25 CONST %MAX_CNT_STEPS_LIMIT = %TOTAL_STEPS_LIMIT - %MIN_STEPS_FINISH_BATCH CONST %MAX_CNT_ARITH_LIMIT = %TOTAL_STEPS_LIMIT / 32 @@ -114,7 +114,7 @@ CONST %MAX_CNT_PADDING_PG_LIMIT = (%TOTAL_STEPS_LIMIT / 56) CONST %MAX_CNT_POSEIDON_G_LIMIT = (%TOTAL_STEPS_LIMIT / 30) CONST %MAX_CNT_SHA256_F_LIMIT = ((%TOTAL_STEPS_LIMIT - 1) / 31488) * 7 -CONST %SAFE_RANGE = 20 ; safe guard counters to not take into account (%RANGE = 1 / SAFE_RANGE) +CONST %SAFE_RANGE = 80 ; safe guard counters to not take into account (%RANGE = 1 / SAFE_RANGE) CONST %MAX_CNT_STEPS = %MAX_CNT_STEPS_LIMIT - (%MAX_CNT_STEPS_LIMIT / %SAFE_RANGE) CONST %MAX_CNT_ARITH = %MAX_CNT_ARITH_LIMIT - (%MAX_CNT_ARITH_LIMIT / %SAFE_RANGE) From b38f982ba581f8b4666225d460c837ac234f7916 Mon Sep 17 00:00:00 2001 From: Laia Soler Date: Mon, 22 Jul 2024 17:40:50 +0200 Subject: [PATCH 04/13] Banana N=25 --> fork 14 --- main/constants.zkasm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/constants.zkasm b/main/constants.zkasm index 70a54eaf..cbc7ecf7 100644 --- a/main/constants.zkasm +++ b/main/constants.zkasm @@ -6,7 +6,7 @@ CONST %BATCH_DIFFICULTY = 0 CONST %TX_GAS_LIMIT = 30000000 CONSTL %BLOCK_GAS_LIMIT = 2**50 CONST %MAX_MEM_EXPANSION_BYTES = 0x3fffe0 -CONST %FORK_ID = 9 +CONST %FORK_ID = 14 CONST %L1INFO_TREE_LEVELS = 32 CONST %CALLDATA_RESERVED_CTX = 1 CONSTL %FOUR_GOLDILOCKS = 0xffffffff00000001ffffffff00000001ffffffff00000001ffffffff00000001n From 5fc45fd0de202c2f6100f1f0b5d3368e43450547 Mon Sep 17 00:00:00 2001 From: Laia Soler Date: Mon, 22 Jul 2024 18:03:45 +0200 Subject: [PATCH 05/13] update test-vectors fork 14 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 49b53e29..942c6dce 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "devDependencies": { "@0xpolygonhermez/zkevm-commonjs": "github:0xPolygonHermez/zkevm-commonjs#v6.0.0-fork.9", "@0xpolygonhermez/zkevm-proverjs": "github:0xPolygonHermez/zkevm-proverjs#39508f69cb191487a065ffbf76c647cd83b59720", - "@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#develop", + "@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#feature/banana-25", "chai": "^4.3.6", "chalk": "^3.0.0", "eslint": "^8.25.0", From 9efa854f71a873682b6f08eaaf001ff78c39b558 Mon Sep 17 00:00:00 2001 From: Laia Soler Date: Wed, 24 Jul 2024 11:33:44 +0200 Subject: [PATCH 06/13] update sample tests parallel --- tools/parallel-testing/parallel-tests-sample/sample.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/parallel-testing/parallel-tests-sample/sample.test.js b/tools/parallel-testing/parallel-tests-sample/sample.test.js index fbc55079..6c9a44aa 100644 --- a/tools/parallel-testing/parallel-tests-sample/sample.test.js +++ b/tools/parallel-testing/parallel-tests-sample/sample.test.js @@ -13,7 +13,7 @@ const smMain = require('@0xpolygonhermez/zkevm-proverjs/src/sm/sm_main/sm_main') let rom = require('../../../build/rom.json'); -let stepsN = 2 ** 23; +let stepsN = 2 ** 25; let counters = false; const fileCachePil = path.join(__dirname, '../../../node_modules/@0xpolygonhermez/zkevm-proverjs/cache-main-pil.json'); From 9cb62807563335a4ddef972dc9b76a8d71384c2a Mon Sep 17 00:00:00 2001 From: Laia Soler Date: Fri, 2 Aug 2024 11:43:19 +0200 Subject: [PATCH 07/13] update fork 12 --- main/constants.zkasm | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/main/constants.zkasm b/main/constants.zkasm index cbc7ecf7..be9dc87e 100644 --- a/main/constants.zkasm +++ b/main/constants.zkasm @@ -6,7 +6,7 @@ CONST %BATCH_DIFFICULTY = 0 CONST %TX_GAS_LIMIT = 30000000 CONSTL %BLOCK_GAS_LIMIT = 2**50 CONST %MAX_MEM_EXPANSION_BYTES = 0x3fffe0 -CONST %FORK_ID = 14 +CONST %FORK_ID = 12 CONST %L1INFO_TREE_LEVELS = 32 CONST %CALLDATA_RESERVED_CTX = 1 CONSTL %FOUR_GOLDILOCKS = 0xffffffff00000001ffffffff00000001ffffffff00000001ffffffff00000001n diff --git a/package.json b/package.json index 942c6dce..fd1f6f55 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "devDependencies": { "@0xpolygonhermez/zkevm-commonjs": "github:0xPolygonHermez/zkevm-commonjs#v6.0.0-fork.9", "@0xpolygonhermez/zkevm-proverjs": "github:0xPolygonHermez/zkevm-proverjs#39508f69cb191487a065ffbf76c647cd83b59720", - "@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#feature/banana-25", + "@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#v8.0.0-rc.1-fork.12", "chai": "^4.3.6", "chalk": "^3.0.0", "eslint": "^8.25.0", From ee8acbeef606b498aba543242d0699648b8bb53f Mon Sep 17 00:00:00 2001 From: Laia Soler Date: Fri, 2 Aug 2024 16:46:38 +0200 Subject: [PATCH 08/13] update commonjs & test-vectors --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index fd1f6f55..b965decd 100644 --- a/package.json +++ b/package.json @@ -43,9 +43,9 @@ "yargs": "^17.5.1" }, "devDependencies": { - "@0xpolygonhermez/zkevm-commonjs": "github:0xPolygonHermez/zkevm-commonjs#v6.0.0-fork.9", + "@0xpolygonhermez/zkevm-commonjs": "github:0xPolygonHermez/zkevm-commonjs#v8.0.0-rc.1-fork.12", "@0xpolygonhermez/zkevm-proverjs": "github:0xPolygonHermez/zkevm-proverjs#39508f69cb191487a065ffbf76c647cd83b59720", - "@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#v8.0.0-rc.1-fork.12", + "@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#v8.0.0-rc.2-fork.12", "chai": "^4.3.6", "chalk": "^3.0.0", "eslint": "^8.25.0", From 3b2fac97cdae175688f1beb8a32ebdfd8ca0e77e Mon Sep 17 00:00:00 2001 From: Ignasi Date: Mon, 2 Sep 2024 17:13:58 +0200 Subject: [PATCH 09/13] Add edge case where last opcode is a push1 --- main/opcodes/stack-operations.zkasm | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/main/opcodes/stack-operations.zkasm b/main/opcodes/stack-operations.zkasm index c7b419c4..957d79b8 100644 --- a/main/opcodes/stack-operations.zkasm +++ b/main/opcodes/stack-operations.zkasm @@ -130,7 +130,9 @@ opAuxPUSHA: $ => B :MLOAD(bytecodeLength) PC + D - B :JMPN(opAuxPUSHA2) - B - PC => D + ; For the edge case where the last opcode of the bytecode is PUSH1, we will handle this specific situation separately, + ; where a 0 is pushed to the stack and the PC is incremented by 1. + B - PC => D :JMPZ(lastOpcodePUSH1) opAuxPUSHA2: ; check out-of-gas @@ -151,7 +153,9 @@ opAuxPUSHB: $ => A :MLOAD(isCreate), JMPNZ(opAuxPUSHBcreate) $ => B :MLOAD(txCalldataLen) PC + D - B :JMPN(opAuxPUSHB2) - B - PC => D + ; For the edge case where the last opcode of the bytecode is PUSH1, we will handle this specific situation separately, + ; where a 0 is pushed to the stack and the PC is incremented by 1. + B - PC => D :JMPZ(lastOpcodePUSH1) opAuxPUSHB2: ; set bytes length to read to C @@ -212,6 +216,16 @@ opfinalPUSHBcreate: ; return to current context $ => CTX :MLOAD(currentCTX), JMP(opAuxPUSHBend) +lastOpcodePUSH1: + ; check out-of-gas + GAS - %GAS_FASTEST_STEP => GAS :JMPN(outOfGas) + ; store stack output + 0 :MSTORE(SP++); [pushed_value(E) => SP] + ; check stack overflow + %MAX_STACK_SIZE - SP :JMPN(stackOverflow) + ; rectify PC + PC + 1 => PC :JMP(readCode) + /** * @link [https://www.evm.codes/#80?fork=berlin] * @zk-counters From 65c18921b07f11813f20159d5f019f4062dd6d58 Mon Sep 17 00:00:00 2001 From: Ignasi Date: Mon, 2 Sep 2024 17:16:25 +0200 Subject: [PATCH 10/13] Update package versions --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b965decd..842d3fba 100644 --- a/package.json +++ b/package.json @@ -44,8 +44,8 @@ }, "devDependencies": { "@0xpolygonhermez/zkevm-commonjs": "github:0xPolygonHermez/zkevm-commonjs#v8.0.0-rc.1-fork.12", - "@0xpolygonhermez/zkevm-proverjs": "github:0xPolygonHermez/zkevm-proverjs#39508f69cb191487a065ffbf76c647cd83b59720", - "@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#v8.0.0-rc.2-fork.12", + "@0xpolygonhermez/zkevm-proverjs": "github:0xPolygonHermez/zkevm-proverjs#feature/fix-ft-stop", + "@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#feature/new-tests", "chai": "^4.3.6", "chalk": "^3.0.0", "eslint": "^8.25.0", From 69d1ad4e0760e77554c1b9cf4958a35a53528cbd Mon Sep 17 00:00:00 2001 From: Ignasi Date: Tue, 3 Sep 2024 11:45:25 +0200 Subject: [PATCH 11/13] Improved fix --- main/opcodes/stack-operations.zkasm | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/main/opcodes/stack-operations.zkasm b/main/opcodes/stack-operations.zkasm index 957d79b8..9c55235d 100644 --- a/main/opcodes/stack-operations.zkasm +++ b/main/opcodes/stack-operations.zkasm @@ -127,18 +127,17 @@ opPUSH32: opAuxPUSHA: ; checks zk-counters %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) + ; check out-of-gas + GAS - %GAS_FASTEST_STEP => GAS :JMPN(outOfGas) $ => B :MLOAD(bytecodeLength) PC + D - B :JMPN(opAuxPUSHA2) - ; For the edge case where the last opcode of the bytecode is PUSH1, we will handle this specific situation separately, - ; where a 0 is pushed to the stack and the PC is incremented by 1. - B - PC => D :JMPZ(lastOpcodePUSH1) + B - PC => D,E :JMPZ(lastOpcodeIsPush) opAuxPUSHA2: - ; check out-of-gas - GAS - %GAS_FASTEST_STEP => GAS :JMPN(outOfGas) ; read bytes from calldata D => E :CALL(readPush); in: [D,E: bytes to read] out: [E: value read] +lastOpcodeIsPush: ; store stack output E :MSTORE(SP++); [pushed_value(E) => SP] ; check stack overflow @@ -153,9 +152,7 @@ opAuxPUSHB: $ => A :MLOAD(isCreate), JMPNZ(opAuxPUSHBcreate) $ => B :MLOAD(txCalldataLen) PC + D - B :JMPN(opAuxPUSHB2) - ; For the edge case where the last opcode of the bytecode is PUSH1, we will handle this specific situation separately, - ; where a 0 is pushed to the stack and the PC is incremented by 1. - B - PC => D :JMPZ(lastOpcodePUSH1) + B - PC => D opAuxPUSHB2: ; set bytes length to read to C @@ -216,16 +213,6 @@ opfinalPUSHBcreate: ; return to current context $ => CTX :MLOAD(currentCTX), JMP(opAuxPUSHBend) -lastOpcodePUSH1: - ; check out-of-gas - GAS - %GAS_FASTEST_STEP => GAS :JMPN(outOfGas) - ; store stack output - 0 :MSTORE(SP++); [pushed_value(E) => SP] - ; check stack overflow - %MAX_STACK_SIZE - SP :JMPN(stackOverflow) - ; rectify PC - PC + 1 => PC :JMP(readCode) - /** * @link [https://www.evm.codes/#80?fork=berlin] * @zk-counters From 11c8b0aac269a53eb5dde023b76d2d0b4423cfdc Mon Sep 17 00:00:00 2001 From: Ignasi Date: Thu, 19 Sep 2024 09:06:53 +0200 Subject: [PATCH 12/13] Update package --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 842d3fba..23d2eee5 100644 --- a/package.json +++ b/package.json @@ -43,9 +43,9 @@ "yargs": "^17.5.1" }, "devDependencies": { - "@0xpolygonhermez/zkevm-commonjs": "github:0xPolygonHermez/zkevm-commonjs#v8.0.0-rc.1-fork.12", + "@0xpolygonhermez/zkevm-commonjs": "github:0xPolygonHermez/zkevm-commonjs#v8.0.0-fork.12", "@0xpolygonhermez/zkevm-proverjs": "github:0xPolygonHermez/zkevm-proverjs#feature/fix-ft-stop", - "@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#feature/new-tests", + "@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#tmp-develop-2", "chai": "^4.3.6", "chalk": "^3.0.0", "eslint": "^8.25.0", From 969bb18baa2a9f47a8bc46fcea607803c3b8e336 Mon Sep 17 00:00:00 2001 From: Ignasi Date: Mon, 23 Sep 2024 11:23:10 +0200 Subject: [PATCH 13/13] Update package --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 23d2eee5..809ee4c0 100644 --- a/package.json +++ b/package.json @@ -44,8 +44,8 @@ }, "devDependencies": { "@0xpolygonhermez/zkevm-commonjs": "github:0xPolygonHermez/zkevm-commonjs#v8.0.0-fork.12", - "@0xpolygonhermez/zkevm-proverjs": "github:0xPolygonHermez/zkevm-proverjs#feature/fix-ft-stop", - "@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#tmp-develop-2", + "@0xpolygonhermez/zkevm-proverjs": "github:0xPolygonHermez/zkevm-proverjs#v8.0.0-fork.12", + "@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#v8.0.0-fork.12", "chai": "^4.3.6", "chalk": "^3.0.0", "eslint": "^8.25.0",