Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no overwrite timestamp, add REPEAT #190

Merged
merged 2 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion main/constants.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ CONST %MAX_CNT_STEPS = 2**23 - %MIN_STEPS_FINISH_BATCH
CONST %MAX_CNT_ARITH = %MAX_CNT_STEPS / 32
CONST %MAX_CNT_BINARY = %MAX_CNT_STEPS / 32
CONST %MAX_CNT_MEM_ALIGN = %MAX_CNT_STEPS / 32
CONST %MAX_CNT_KECCAK_F = (%MAX_CNT_STEPS / 158418) * 9
CONST %MAX_CNT_KECCAK_F = (%MAX_CNT_STEPS / 155286) * 44
CONST %MAX_CNT_PADDING_PG = (%MAX_CNT_STEPS / 56)
CONST %MAX_CNT_POSEIDON_G = (%MAX_CNT_STEPS / 30)
CONST %MIN_CNT_KECCAK_BATCH = 1 ; minimum necessary keccaks to compute global hash
Expand Down
2 changes: 1 addition & 1 deletion main/ecrecover/ecrecover.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ ecrecover_v_y2_same_parity:
; check keccak counters
$ => A :MLOAD(cntKeccakPreProcess)
%MAX_CNT_KECCAK_F - CNT_KECCAK_F - A - 1 :JMPN(outOfCountersKeccak)

$ => A :MLOAD(mulPointEc_p3_x)

A :HASHK(E)
Expand Down
2 changes: 1 addition & 1 deletion main/end.zkasm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
finalWait:
${beforeLast()} :JMPN(finalWait)
; Set all registers to 0 except inputs: B (oldstateRoot), C (oldAccInputHash), SP (oldNumBatch) & GAS (chainID)
0 => A, D, E, CTX, PC, MAXMEM, SR, HASHPOS, RR :JMP(start)
0 => A, D, E, CTX, PC, MAXMEM, SR, HASHPOS, RR, RCX :JMP(start)
2 changes: 1 addition & 1 deletion main/load-tx-rlp.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ vREADTx:
A + 1 => A :MSTORE(pendingTxs)
;; compute signature
$ => A :HASHKDIGEST(E)
A :MSTORE(txHash)
A :MSTORE(txHash)
:JMP(txLoopRLP)

;;;;;;;;;
Expand Down
7 changes: 7 additions & 0 deletions main/main.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ setGlobalExitRoot:

%ADDRESS_GLOBAL_EXIT_ROOT_MANAGER_L2 => A
%SMT_KEY_SC_STORAGE => B

; read timestamp given the globalExitRoot
$ => D :SLOAD

; skip overwrite timestamp if it is different than 0
-D :JMPN(skipSetGlobalExitRoot)

$ => D :MLOAD(timestamp)
$ => SR :SSTORE ; Store 'timestamp' in storage position 'keccak256(globalExitRoot, 0)'

Expand Down
14 changes: 6 additions & 8 deletions main/process-tx.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ create2end:
$ => CTX :MLOAD(currentCTX)
HASHPOS :HASHKLEN(E)
$ => C :HASHKDIGEST(E)

; new hash with position 0 is started
0 => HASHPOS
$ => E :MLOAD(lastHashKIdUsed)
Expand Down Expand Up @@ -454,14 +454,12 @@ callContract:
E :MSTORE(contractHashId)
E+1 :MSTORE(nextHashPId)

; check steps used by checkHashBytecodeLoop
; compute steps that will be consumed by 'checkHashBytecodeLoop'
%MAX_CNT_STEPS - STEP - 2 * B :JMPN(outOfCountersStep)
; check steps used by REPEAT
%MAX_CNT_STEPS - STEP - B - 4 :JMPN(outOfCountersStep)

checkHashBytecodeLoop:
B - 1 - HASHPOS :JMPN(checkHashBytecodeEnd) ; finish reading bytecode
${getBytecode(A, HASHPOS, 1)} :HASHP(E) ; hash contract bytecode
:JMP(checkHashBytecodeLoop)
; set repeat itarations: RCX register + 1
B - 1 => RCX :JMPN(checkHashBytecodeEnd)
${getBytecode(A, HASHPOS, 1)} :HASHP(E), REPEAT(RCX) ; hash contract bytecode

checkHashBytecodeEnd:
HASHPOS :HASHPLEN(E)
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
"url": "https://github.com/0xPolygonHermez/zkevm-rom.git"
},
"dependencies": {
"@0xpolygonhermez/zkasmcom": "https://github.com/0xPolygonHermez/zkasmcom.git#v0.5.0.0",
"@0xpolygonhermez/zkasmcom": "https://github.com/0xPolygonHermez/zkasmcom.git#440fdcb20acf0444173242a2150139f126284d3e",
"yargs": "^17.5.1"
},
"devDependencies": {
"@0xpolygonhermez/zkevm-proverjs": "github:0xPolygonHermez/zkevm-proverjs#cedc278e4fbc93b84e8ea4008d9fa4ab590ce08f",
"@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#develop",
"@0xpolygonhermez/zkevm-proverjs": "github:0xPolygonHermez/zkevm-proverjs#a049538a517e73fecebdf94eafa435e545d2a688",
"@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#v0.5.1.0",
"chai": "^4.3.6",
"chalk": "^3.0.0",
"eslint": "^8.25.0",
Expand Down