From 42e50ea79b13651b83a0eaaaaf1323e7a8eecf69 Mon Sep 17 00:00:00 2001 From: Ignasi Date: Tue, 9 Apr 2024 17:56:53 +0200 Subject: [PATCH 1/4] Add folder name at parrallel test generation to avoid name collisions --- main/utils.zkasm | 2 +- package.json | 4 ++-- tools/parallel-testing/gen-parallel-tests.js | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/main/utils.zkasm b/main/utils.zkasm index 3970d2c5..78109c32 100644 --- a/main/utils.zkasm +++ b/main/utils.zkasm @@ -135,7 +135,7 @@ __MSTOREX_afterSave: ; E === 32 * RR + A (RCX) ; E - 32 * RR === A - ; secure: E < MAX_MEM_EXPASION_BYTES < 32 bits, RR < 32 bits, 32*RR < 37 bits, all < 38 bits + ; secure: E < MAX_MEM_EXPANSION_BYTES < 32 bits, RR < 32 bits, 32*RR < 37 bits, all < 38 bits E - 32 * RR :ASSERT RCX + %MEM_ALIGN_LEN * C + %MEM_ALIGN_LEFT_ALIGNMENT => C :JMP_EQ(%MEM_ALIGN_LEN * 32 + %MEM_ALIGN_LEFT_ALIGNMENT, __MSTORE32_offset0_len32) diff --git a/package.json b/package.json index a87d20a0..704c0ace 100644 --- a/package.json +++ b/package.json @@ -44,8 +44,8 @@ }, "devDependencies": { "@0xpolygonhermez/zkevm-commonjs": "github:0xPolygonHermez/zkevm-commonjs#v7.0.0-rc.1-fork.10", - "@0xpolygonhermez/zkevm-proverjs": "github:0xPolygonHermez/zkevm-proverjs#feature/renaming", - "@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#v7.0.0-rc.1-fork.10", + "@0xpolygonhermez/zkevm-proverjs": "github:0xPolygonHermez/zkevm-proverjs#feature/fix-batchHashData", + "@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#feature/fix-test", "chai": "^4.3.6", "chalk": "^3.0.0", "eslint": "^8.25.0", diff --git a/tools/parallel-testing/gen-parallel-tests.js b/tools/parallel-testing/gen-parallel-tests.js index 7d81888a..95f28ede 100644 --- a/tools/parallel-testing/gen-parallel-tests.js +++ b/tools/parallel-testing/gen-parallel-tests.js @@ -25,14 +25,15 @@ async function genTestsFiles() { fs.mkdirSync(testsFolder); } for (const inputPath of inputs) { - const name = inputPath.split('/').slice(-1)[0].replace('json', 'test.js'); + const fileName = path.basename(inputPath, '.json'); + const folderName = path.basename(path.dirname(inputPath)); const sample = fs.readFileSync(sampleDir, 'utf-8'); let test = sample.replace('%%INPUT_PATH%%', `${inputPath}`); // Replace skip vcounters flag if (argv.skipVCounters) { test = test.replace('%%SKIP_VCOUNTERS%%', 'yes'); } - fs.writeFileSync(`${testsFolder}/${name}`, test); + fs.writeFileSync(`${testsFolder}/${folderName}__${fileName}.test.js`, test); } expect(true).to.be.equal(true); } From c8d3a44111b06192a5e47b2ceb9cbe3d7f3e0c7e Mon Sep 17 00:00:00 2001 From: Ignasi Date: Wed, 10 Apr 2024 10:00:05 +0200 Subject: [PATCH 2/4] Check timestamp after setting L1InfoTreeRoot + index --- main/process-change-l2-block-utils.zkasm | 2 ++ main/process-change-l2-block.zkasm | 25 +++++++++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/main/process-change-l2-block-utils.zkasm b/main/process-change-l2-block-utils.zkasm index ee433aac..381ae430 100644 --- a/main/process-change-l2-block-utils.zkasm +++ b/main/process-change-l2-block-utils.zkasm @@ -1,4 +1,5 @@ ; Computes L1InfoTree leaf value computedL1InfoTreeData = keccak(gerL1InfoTree, blockHashL1InfoTree, timestampL1InfoTree) +; @out label: computedL1InfoTreeData computeL1InfoTreeValue: %MAX_CNT_KECCAK_F - CNT_KECCAK_F - 1 :JMPN(outOfCountersKeccak) @@ -30,6 +31,7 @@ computeNewCurrentL1InfoRootFromHistoric: ; compute "new" currentL1InfoRoot from computed merkle root, currentL1InfoTreeRoot = keccak(computedMerkleRoot, computedL1InfoTreeData) ; @in C: computed merkle root +; @out label: currentL1InfoTreeRoot computeNewCurrentL1InfoRoot: %MAX_CNT_KECCAK_F - CNT_KECCAK_F - 1 :JMPN(outOfCountersKeccak) $ => E :MLOAD(nextHashKId) diff --git a/main/process-change-l2-block.zkasm b/main/process-change-l2-block.zkasm index fc20cacc..d4dcfb9f 100644 --- a/main/process-change-l2-block.zkasm +++ b/main/process-change-l2-block.zkasm @@ -52,7 +52,7 @@ continueProcessChangeL2Block: $ :MLOAD(isForced), JMPZ(verifyTimestampAndL1InfoRoot) ; forced batch - ; - update timestamp only if currentTimestamp < limitTimestamp + ; - update timestamp only if currentTimestamp < forcedTimestamp ; - set blockHash to default $ => C :MLOAD(forcedBlockHashL1InfoTree) C :MSTORE(blockHashL1InfoTree) @@ -77,26 +77,29 @@ verifyTimestampAndL1InfoRoot: A - $ - 1 :F_MLOAD(currentL1InfoTreeIndex), JMPN(invalidL1InfoTreeIndex) ${getL1InfoGER(mem.indexL1InfoTree)} :MSTORE(gerL1InfoTree) ${getL1InfoBlockHash(mem.indexL1InfoTree)} :MSTORE(blockHashL1InfoTree) - ${getL1InfoMinTimestamp(mem.indexL1InfoTree)} => B :MSTORE(timestampL1InfoTree) - ; Verify (currentTimestamp + deltaTimestamp) >= l1InfoRoot.minTimestamp - $ => A :MLOAD(timestamp) - $ :LT, JMPC(invalidChangeL2BlockMinTimestamp) + ${getL1InfoMinTimestamp(mem.indexL1InfoTree)} :MSTORE(timestampL1InfoTree) + ; Compute infoTreeData - :CALL(computeL1InfoTreeValue) + :CALL(computeL1InfoTreeValue) ; out: [@label: computedL1InfoTreeData] $ :MLOAD(currentL1InfoTreeIndex), JMPNZ(previousL1InfoTreeIndexIsNotZero) ; if previous L1 Info TreeIndex is zero, currentL1InfoTreeRoot = keccak(HistoricRoot, blockHashL1InfoTree) :CALL(computeNewCurrentL1InfoRootFromHistoric) - $ => A :MLOAD(indexL1InfoTree) - ; Update currentL1InfoTreeIndex - A :MSTORE(currentL1InfoTreeIndex), JMP(initSetGERL1InfoTree) + :JMP(updateCurrentL1InfoTreeIndex) previousL1InfoTreeIndexIsNotZero: + ; if previous L1 Info TreeIndex is NOT zero, currentL1InfoTreeRoot = keccak(computedMerkleRoot, blockHashL1InfoTree) :CALL(computeMerkleProof) ; out: [C: computed merkle root] ; Compute newL1InfoTreeRoot - :CALL(computeNewCurrentL1InfoRoot) + :CALL(computeNewCurrentL1InfoRoot) ; in: [C: computed merkle root], out: [@label: currentL1InfoTreeRoot] +updateCurrentL1InfoTreeIndex: ; Update currentL1InfoTreeIndex $ => A :MLOAD(indexL1InfoTree) - A :MSTORE(currentL1InfoTreeIndex), JMP(initSetGERL1InfoTree) + A :MSTORE(currentL1InfoTreeIndex) + ; Verify (currentTimestamp + deltaTimestamp) >= l1InfoRoot.minTimestamp + ; This verification is done after updating the currentL1InfoTreeIndex and the currentL1InfoTreeRoot to correctly set batch outputs at execution finalization + $ => A :MLOAD(timestamp) + $ => B :MLOAD(timestampL1InfoTree) + $ :LT, JMPC(invalidChangeL2BlockMinTimestamp, initSetGERL1InfoTree) setNewTimestamp: ; Set forcedTimestamp (now new Timestamp) from forced batch data From 5d78a2bf7d5822318bcadd541a6c4ab699a11a8f Mon Sep 17 00:00:00 2001 From: Ignasi Date: Wed, 17 Apr 2024 16:02:09 +0200 Subject: [PATCH 3/4] Update package --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 704c0ace..65038ba8 100644 --- a/package.json +++ b/package.json @@ -43,9 +43,9 @@ "yargs": "^17.5.1" }, "devDependencies": { - "@0xpolygonhermez/zkevm-commonjs": "github:0xPolygonHermez/zkevm-commonjs#v7.0.0-rc.1-fork.10", - "@0xpolygonhermez/zkevm-proverjs": "github:0xPolygonHermez/zkevm-proverjs#feature/fix-batchHashData", - "@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#feature/fix-test", + "@0xpolygonhermez/zkevm-commonjs": "github:0xPolygonHermez/zkevm-commonjs#feature/fix-73", + "@0xpolygonhermez/zkevm-proverjs": "github:0xPolygonHermez/zkevm-proverjs#develop-feijoa", + "@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#feature/fix-73", "chai": "^4.3.6", "chalk": "^3.0.0", "eslint": "^8.25.0", From 7cd0a9116d016a673c29bdb0c8dd7577cf34ef49 Mon Sep 17 00:00:00 2001 From: Carlos Matallana <44141767+krlosMata@users.noreply.github.com> Date: Thu, 18 Apr 2024 13:05:37 +0200 Subject: [PATCH 4/4] Update package.json --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 65038ba8..024df269 100644 --- a/package.json +++ b/package.json @@ -43,9 +43,9 @@ "yargs": "^17.5.1" }, "devDependencies": { - "@0xpolygonhermez/zkevm-commonjs": "github:0xPolygonHermez/zkevm-commonjs#feature/fix-73", + "@0xpolygonhermez/zkevm-commonjs": "github:0xPolygonHermez/zkevm-commonjs#develop-feijoa", "@0xpolygonhermez/zkevm-proverjs": "github:0xPolygonHermez/zkevm-proverjs#develop-feijoa", - "@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#feature/fix-73", + "@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#develop-feijoa", "chai": "^4.3.6", "chalk": "^3.0.0", "eslint": "^8.25.0",