Skip to content

Commit

Permalink
Merge pull request #367 from 0xPolygonHermez/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
krlosMata authored Mar 26, 2024
2 parents 3d54f35 + 2be6d91 commit 8a8944b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 12 deletions.
3 changes: 2 additions & 1 deletion main/constants.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 8
CONST %FORK_ID = 9
CONST %L1INFO_TREE_LEVELS = 32
CONST %CALLDATA_RESERVED_CTX = 1
CONSTL %FOUR_GOLDILOCKS = 0xffffffff00000001ffffffff00000001ffffffff00000001ffffffff00000001n
Expand Down Expand Up @@ -142,3 +142,4 @@ CONST %CHANGE_L2_BLOCK_TX_TYPE = 0x0b
CONST %DELTA_TIMESTAMP_NUM_BYTES = 4
CONST %INDEX_L1INFOTREE_NUM_BYTES = 4
CONST %TX_TYPE_NUM_BYTES = 1
CONSTL %L1_INFO_DATA_ZERO = 0x3cac317908c699fe873a7f6ee4e8cd63fbe9918b2315c97be91585590168e301n
10 changes: 5 additions & 5 deletions main/process-change-l2-block.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ verifyTimestampAndL1InfoRoot:
$ => SR :SSTORE

; check indexL1InfoTree != 0 to verify data L1InfoTree
$ :MLOAD(indexL1InfoTree), JMPZ(skipSetGERL1InfoTree)
$ :MLOAD(indexL1InfoTree), JMPZ(skipSetGERL1InfoTree)

${getL1InfoGER(mem.indexL1InfoTree)} => A :MSTORE(gerL1InfoTree)
${getL1InfoBlockHash(mem.indexL1InfoTree)} => B :MSTORE(blockHashL1InfoTree)
${getL1InfoTimestamp(mem.indexL1InfoTree)} => C :MSTORE(timestampL1InfoTree)
:CALL(verifyMerkleProof)
${getL1InfoGER(mem.indexL1InfoTree)} => A :MSTORE(gerL1InfoTree)
${getL1InfoBlockHash(mem.indexL1InfoTree)} => B :MSTORE(blockHashL1InfoTree)
${getL1InfoTimestamp(mem.indexL1InfoTree)} => C :MSTORE(timestampL1InfoTree)
:CALL(verifyMerkleProof)

; Verify (currentTimestamp + deltaTimestamp) >= l1InfoRoot.timestamp
$ => A :MLOAD(timestamp)
Expand Down
16 changes: 14 additions & 2 deletions main/utils.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,8 @@ invalidChangeL2BlockLimitTimestamp:
$${eventLog(onError, invalid_change_l2_block_limit_timestamp)} :JMP(handleBatchError)
invalidChangeL2BlockMinTimestamp:
$${eventLog(onError, invalid_change_l2_block_min_timestamp)} :JMP(handleBatchError)
invalidL1InfoTreeIndex:
$${eventLog(onError, invalid_l1_info_tree_index)} :JMP(handleBatchError)
outOfGas:
$${eventLog(onError, OOG)} :JMP(handleError)
invalidJump:
Expand Down Expand Up @@ -1666,9 +1668,12 @@ verifyMerkleProof:
; 1 keccak for the leaf and 32 for the L1InfoTree
%MAX_CNT_KECCAK_F - CNT_KECCAK_F - E - 33 :JMPN(outOfCountersKeccak)
; 7 steps at most per bit + 21 statics
%MAX_CNT_STEPS - STEP - 7 * 32 - 21 :JMPN(outOfCountersStep)
%MAX_CNT_STEPS - STEP - 7 * 32 - 25 :JMPN(outOfCountersStep)
; check binaries
%MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary)

RR :MSTORE(tmpZkPCVerifyMerkleProof)
0 :MSTORE(isL1InfoDataZero)

;;;;;;;;;;;;;;;;;;;;;
;; compute leaf value
Expand All @@ -1692,8 +1697,14 @@ verifyMerkleProof:

; compute l1InfoTree Leaf value
HASHPOS :HASHKLEN(E)
$ => C :HASHKDIGEST(E) ; initial value
$ => C, A :HASHKDIGEST(E) ; initial value
; allow to set value to all zeroes if all its values are zero
%L1_INFO_DATA_ZERO => B
$ :EQ, JMPNC(continueVerifyMerkleProof)
1 :MSTORE(isL1InfoDataZero)
0 => C

continueVerifyMerkleProof:
; initialization registers for smt verify
0 => D, A

Expand Down Expand Up @@ -2261,6 +2272,7 @@ hashBranchEnd31:
verifyMerkleProofEnd:
$ => A :MLOAD(l1InfoRoot)
C :ASSERT
$ :MLOAD(isL1InfoDataZero), JMPNZ(invalidL1InfoTreeIndex)

verifyMerkleProofReturn:
$ => RR :MLOAD(tmpZkPCVerifyMerkleProof)
Expand Down
2 changes: 2 additions & 0 deletions main/vars.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ VAR GLOBAL isLoadingRLP ; flag to determine if the function is called from RLP l
VAR GLOBAL globalCalldataMemoryOffset ; Aux variable to store current calldata memory offset at calldata CTX's memory

VAR GLOBAL txIndex ; index of the current tx in the block
VAR GLOBAL isL1InfoDataZero; indicates if the l1 info data value to be prove has zero value

VAR CTX txGasLimit ; transaction parameter: 'gas limit'
VAR CTX txDestAddr ; transaction parameter: 'to'
VAR CTX storageAddr ; address which the storage will be modified
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@0xpolygonhermez/zkevm-rom",
"version": "5.0.0",
"version": "6.0.0",
"description": "zkROM source code",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -43,9 +43,9 @@
"yargs": "^17.5.1"
},
"devDependencies": {
"@0xpolygonhermez/zkevm-commonjs": "github:0xPolygonHermez/zkevm-commonjs#v5.0.0-fork.8",
"@0xpolygonhermez/zkevm-proverjs": "github:0xPolygonHermez/zkevm-proverjs#493569b08869a496e5de379c83263e4a10d5e585",
"@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#v5.0.0-fork.8",
"@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",
"chai": "^4.3.6",
"chalk": "^3.0.0",
"eslint": "^8.25.0",
Expand Down

0 comments on commit 8a8944b

Please sign in to comment.