diff --git a/main/opcodes/logs.zkasm b/main/opcodes/logs.zkasm index ca8f75fa..9a3d9ea9 100644 --- a/main/opcodes/logs.zkasm +++ b/main/opcodes/logs.zkasm @@ -8,7 +8,7 @@ * - stack output: none */ VAR GLOBAL opLogAux - + VAR GLOBAL logNextHashPIdAux opLOG0: ; checks zk-counters %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) @@ -45,7 +45,7 @@ opLOG1: %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary) SP - 3 :JMPN(stackUnderflow) - GAS - %LOG_GAS => GAS :JMPN(outOfGas) + GAS - %LOG_GAS - %LOG_TOPIC_GAS => GAS :JMPN(outOfGas) $ => A :MLOAD(isStaticCall), JMPNZ(invalidStaticTx) SP - 1 => SP $ => E :MLOAD(SP--) @@ -53,7 +53,7 @@ opLOG1: E :MSTORE(lastMemOffset) C :MSTORE(lastMemLength), CALL(saveMem) 1 :MSTORE(numTopics) - 8 :MSTORE(arithA) + %LOG_DATA_GAS :MSTORE(arithA) C :MSTORE(arithB), CALL(mulARITH) $ => B :MLOAD(arithRes1) GAS => A @@ -66,7 +66,7 @@ opLOG2: %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary) SP - 4 :JMPN(stackUnderflow) - GAS - %LOG_GAS => GAS :JMPN(outOfGas) + GAS - %LOG_GAS - %LOG_TOPIC_GAS*2 => GAS :JMPN(outOfGas) $ => A :MLOAD(isStaticCall), JMPNZ(invalidStaticTx) SP - 1 => SP $ => E :MLOAD(SP--) @@ -74,7 +74,7 @@ opLOG2: E :MSTORE(lastMemOffset) C :MSTORE(lastMemLength), CALL(saveMem) 2 :MSTORE(numTopics) - 8 :MSTORE(arithA) + %LOG_DATA_GAS :MSTORE(arithA) C :MSTORE(arithB), CALL(mulARITH) $ => B :MLOAD(arithRes1) GAS => A @@ -87,7 +87,7 @@ opLOG3: %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary) SP - 5 :JMPN(stackUnderflow) - GAS - %LOG_GAS => GAS :JMPN(outOfGas) + GAS - %LOG_GAS - %LOG_TOPIC_GAS*3 => GAS :JMPN(outOfGas) $ => A :MLOAD(isStaticCall), JMPNZ(invalidStaticTx) SP - 1 => SP $ => E :MLOAD(SP--) @@ -95,7 +95,7 @@ opLOG3: E :MSTORE(lastMemOffset) C :MSTORE(lastMemLength), CALL(saveMem) 3 :MSTORE(numTopics) - 8 :MSTORE(arithA) + %LOG_DATA_GAS :MSTORE(arithA) C :MSTORE(arithB), CALL(mulARITH) $ => B :MLOAD(arithRes1) GAS => A @@ -108,7 +108,7 @@ opLOG4: %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary) SP - 6 :JMPN(stackUnderflow) - GAS - %LOG_GAS => GAS :JMPN(outOfGas) + GAS - %LOG_GAS - %LOG_TOPIC_GAS*4 => GAS :JMPN(outOfGas) $ => A :MLOAD(isStaticCall), JMPNZ(invalidStaticTx) SP - 1 => SP $ => E :MLOAD(SP--) @@ -116,7 +116,7 @@ opLOG4: E :MSTORE(lastMemOffset) C :MSTORE(lastMemLength), CALL(saveMem) 4 :MSTORE(numTopics) - 8 :MSTORE(arithA) + %LOG_DATA_GAS :MSTORE(arithA) C :MSTORE(arithB), CALL(mulARITH) $ => B :MLOAD(arithRes1) GAS => A @@ -136,6 +136,12 @@ initLogLoop: 0 => HASHPOS 32 => D $ => B :MLOAD(currentLogIndex) + $ => E :MLOAD(nextHashPId) + ; Update nextHashPId + E + 1 :MSTORE(nextHashPId) + ; store nextHashPId to aux variable + E :MSTORE(logNextHashPIdAux) + logLoop: ; checks zk-counters %MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep) @@ -144,7 +150,7 @@ logLoop: C - 32 :JMPN(opLogFinal) :CALL(MLOAD32); in: [E: offset] out: [A: value] E :MSTORE(opLogAux) - $ => E :MLOAD(nextHashPId) + $ => E :MLOAD(logNextHashPIdAux) A :HASHP(E) $ => E :MLOAD(opLogAux) $${storeLog(B, 0, A)} ; storeLog(indexLog, isTopic, bytesToStore) @@ -156,14 +162,14 @@ opLogFinal: $${storeLog(B, 0, A)}; storeLog(indexLog, isTopic, bytesToStore) 32 - C => D :CALL(SHRarith); in: [A: value, D: #bytes to right shift] out: [A: shifted result] C => D - $ => E :MLOAD(nextHashPId) + $ => E :MLOAD(logNextHashPIdAux) A :HASHP(E) :JMP(opSaveTopicsInit) ; instruction added to allow executing $$ function opSaveTopicsInit: ; save topics $ => A :MLOAD(numTopics) - $ => E :MLOAD(nextHashPId) + $ => E :MLOAD(logNextHashPIdAux) 32 => D opSaveTopicsLoop: @@ -174,7 +180,6 @@ opSaveTopicsLoop: ; check stack underflow SP - 1 => SP ; check out-of-gas - GAS - %LOG_TOPIC_GAS => GAS :JMPN(outOfGas) $ => C :MLOAD(SP) ; [topic => C] C :HASHP(E) $${storeLog(B, 1, C)} ; storeLog(indexLog, isTopic, bytesToStore) @@ -182,8 +187,6 @@ opSaveTopicsLoop: finishSaveTopics: %MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary) - ; Update nextHashPId - E + 1 :MSTORE(nextHashPId) ; Compute hash of the log HASHPOS :HASHPLEN(E) $ => D :HASHPDIGEST(E), CALL(fillBlockInfoTreeWithLog); in: [D: linearPoseidon(log_data + log_topics)] diff --git a/package.json b/package.json index 56c0e7da..3d8d13e1 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "devDependencies": { "@0xpolygonhermez/zkevm-commonjs": "github:0xPolygonHermez/zkevm-commonjs#v4.0.0-fork.7", "@0xpolygonhermez/zkevm-proverjs": "github:0xPolygonHermez/zkevm-proverjs#develop-eldelberry", - "@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#feature/change-block-gas-limit", + "@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#develop-eldelberry", "chai": "^4.3.6", "chalk": "^3.0.0", "eslint": "^8.25.0",