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

add recommendation review external #337

Draft
wants to merge 1 commit into
base: develop-eldelberry
Choose a base branch
from
Draft
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
1 change: 0 additions & 1 deletion main/constants.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ CONST %TX_GAS_LIMIT = 30000000
CONSTL %BLOCK_GAS_LIMIT = 2**50
CONST %MAX_MEM_EXPANSION_BYTES = 0x3fffe0
CONST %FORK_ID = 8
CONST %L1INFO_TREE_LEVELS = 32
CONST %CALLDATA_RESERVED_CTX = 1
CONSTL %FOUR_GOLDILOCKS = 0xffffffff00000001ffffffff00000001ffffffff00000001ffffffff00000001n

Expand Down
2 changes: 0 additions & 2 deletions main/l2-tx-hash.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ addL2HashTx:
;; Write 1 byte to l2TxHash: flag deployment = 1 ('0': no deployment transaction, '1': deployment transaction)
addL2HashTx_isDeploy:
; store temporary register values
A :MSTORE(tmpVar_A_L2HashTx)
E :MSTORE(tmpVar_E_L2HashTx)
HASHPOS :MSTORE(tmpVar_HASHPOS_L2HashTx)

Expand All @@ -76,7 +75,6 @@ addL2HashTx_isDeploy:
HASHPOS :MSTORE(l2HASHP)

; load temporary register values
$ => A :MLOAD(tmpVar_A_L2HashTx)
$ => E :MLOAD(tmpVar_E_L2HashTx)
$ => HASHPOS :MLOAD(tmpVar_HASHPOS_L2HashTx), RETURN

Expand Down
16 changes: 8 additions & 8 deletions main/load-change-l2-block.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ decodeChangeL2BlockTx:
%DELTA_TIMESTAMP_NUM_BYTES => D :CALL(getChangeL2TxBytes)
C + D => C :CALL(addBatchHashData)
A :MSTORE(deltaTimestamp)

; Decode indexL1InfoTree / 4 bytes
%INDEX_L1INFOTREE_NUM_BYTES => D :CALL(getChangeL2TxBytes)
C + D => C :CALL(addBatchHashData)
A :MSTORE(indexL1InfoTree)
1 :MSTORE(isChangeL2BlockTx), JMP(finishLoadChangeL2BlockTx)
1 :MSTORE(isChangeL2BlockTx)

finishLoadChangeL2BlockTx:
;; update bytes parsed
$ => A :MLOAD(batchL2DataParsed)
A + C :MSTORE(batchL2DataParsed)
;; increase number of transaction to process
$ => A :MLOAD(pendingTxs)
A + 1 :MSTORE(pendingTxs), JMP(txLoopRLP)
; update bytes parsed
$ => A :MLOAD(batchL2DataParsed)
A + C :MSTORE(batchL2DataParsed)
; increase number of transaction to process
$ => A :MLOAD(pendingTxs)
A + 1 :MSTORE(pendingTxs), JMP(txLoopRLP)
2 changes: 1 addition & 1 deletion main/load-tx-rlp.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ loadTx_rlp_continue:
; A new hash with position 0 is started
0 => HASHPOS
A :HASHK(E)
A - 0xc0 :JMPN(invalidTxRLP)
A - 0xc1 :JMPN(invalidTxRLP)
A - 0xf8 :JMPN(shortList)
; do not allow lists over 2**24 bytes length
; Transaction could not have more than 120.000 due to smart contract limitation (keccaks counters)
Expand Down
2 changes: 1 addition & 1 deletion main/modexp/modexp_utils.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ modexp_saveModLen:
; if last value == 0 --> modexp_saveModLen
$ :EQ,JMPC(modexp_saveModLen)
; else Mlen == modExpArrayIndex + 1
E + 1 :MSTORE(modexp_Mlen),JMP(modexp_getReturn)
E + 1 :MSTORE(modexp_Mlen)

modexp_getReturn:
$ => RR :MLOAD(tmpZkPCmodexp)
Expand Down
2 changes: 1 addition & 1 deletion main/opcodes/arithmetic.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ opEXP:
* - stack input: [b,x]
* - stack output: [y]
*/
opSIGNEXTEND: ; following this impl https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/vm/src/evm/opcodes/functions.ts#L193
opSIGNEXTEND: ; following this impl https://github.com/0xPolygonHermez/ethereumjs-monorepo/blob/2349ebfab9d9a7d89cc91ff194b9ab4a30e7ebdc/packages/vm/src/evm/opcodes/functions.ts#L225
; checks zk-counters
%MAX_CNT_STEPS - STEP - 100 :JMPN(outOfCountersStep)
%MAX_CNT_BINARY - CNT_BINARY - 6 :JMPN(outOfCountersBinary)
Expand Down
4 changes: 2 additions & 2 deletions main/opcodes/comparison.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ opNOT:
; read one item from the stack
$ => A :MLOAD(SP-1)

0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn => B ; 2**256 - 1 =>
%MAX_UINT_256 => B
$ => A :XOR,MSTORE(SP-1), JMP(readCode) ; [ NOT a => SP]

/**
Expand Down Expand Up @@ -425,7 +425,7 @@ negativeValue:
%MAX_UINT_256 => B
$ => A :XOR ; [~A => A]
C => D :CALL(SHRarithBit) ; [shift (bits) => D]; [ A >> D => A]
$ => A :XOR, JMP(endSAR) ; [~A => A]
$ => A :XOR ; [~A => A]

endSAR:
; check shifted result is greater than 0
Expand Down
3 changes: 1 addition & 2 deletions main/opcodes/logs.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ opLOG4:
GAS => A
; check out-of-gas
$ :LT,JMPC(outOfGas)
GAS - B => GAS :JMP(initLogLoop)
GAS - B => GAS

initLogLoop:
; check poseidon counters
Expand Down Expand Up @@ -158,7 +158,6 @@ opLogFinal:
C => D
$ => E :MLOAD(nextHashPId)
A :HASHP(E)
:JMP(opSaveTopicsInit) ; instruction added to allow executing $$ function

opSaveTopicsInit:
; save topics
Expand Down
12 changes: 6 additions & 6 deletions main/utils.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,7 @@ saveMem:

saveMemGAS:
; store new memory length
B :MSTORE(memLength)
B => E
B => E :MSTORE(memLength)
; memory_size_word = (memory_byte_size + 31) / 32 in E
; ${(B+31)/32} => E
E + 31 => A
Expand Down Expand Up @@ -814,7 +813,6 @@ SHLarithinit:

SHLarith0:
0 => E
:JMP(SHLarithfinal)

SHLarithfinal:
E => A
Expand Down Expand Up @@ -1353,10 +1351,13 @@ checkBytecodeStartsEF:

; get 1 byte from memory
1 => C :CALL(MLOADX) ; in: [E: offset, C: length] out: [A: value , E: new offset]
31 => D :CALL(SHRarith) ; in: [A: value, D: #bytes to right shift] out: [A: shifted result]

; mask first byte
0xFF00000000000000000000000000000000000000000000000000000000000000n => B
$ => A :AND
; check if byte read is equal to 0xEF
%BYTECODE_STARTS_EF - A :JMPNZ(checkBytecodeStartsEFend)
0xEF00000000000000000000000000000000000000000000000000000000000000n => B
$ :EQ, JMPNC(checkBytecodeStartsEFend)
1 :MSTORE(startsWithEF)

checkBytecodeStartsEFend:
Expand Down Expand Up @@ -2279,7 +2280,6 @@ VAR GLOBAL readXFromCalldataResult
VAR GLOBAL tmpVarAReadXFromOffset
VAR GLOBAL tmpVarBReadXFromOffset
VAR GLOBAL tmpVarCReadXFromOffset
VAR GLOBAL tmpVarDReadXFromOffset
VAR GLOBAL tmpVarEReadXFromOffset
; @info Reads {readXFromCalldataOffset} bytes (max 32) from a given offset in calldata memory. If offset or offset + length exceeds txCalldataLen, zeros are added
; @internalParam {readXFromCalldataOffset} offset to read from calldata
Expand Down
Loading