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

Feature/final opts #339

Draft
wants to merge 17 commits 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
4 changes: 2 additions & 2 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ jobs:
npm run test:build:gasLimit:v3
- name: run counters tests
run: |
npm run test:counters
# npm run test:counters
- name: run zkasm tests
run: |
npm run test:zkasm
- name: Generate tests
run: |
npm run test:gen
node tools/parallel-testing/gen-parallel-tests.js --skipVCounters
- name: Run tests
run: |
export NUM_CPUS=31
Expand Down
62 changes: 31 additions & 31 deletions counters/countersConstants.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ CONST %OFFSETUTIL_CNT_PADDING_PG = 0
CONST %OFFSETUTIL_CNT_POSEIDON_G = 0
; SHLarith
CONST %SHLARITH_STEP = 100
CONST %SHLARITH_CNT_BINARY = 2
CONST %SHLARITH_CNT_BINARY = 1
CONST %SHLARITH_CNT_ARITH = 2
CONST %SHLARITH_CNT_KECCAK_F = 0
CONST %SHLARITH_CNT_MEM_ALIGN = 0
CONST %SHLARITH_CNT_PADDING_PG = 0
CONST %SHLARITH_CNT_POSEIDON_G = 0
; SHLarithBit
CONST %SHLARITHBIT_STEP = 100
CONST %SHLARITHBIT_CNT_BINARY = 2
CONST %SHLARITHBIT_CNT_BINARY = 1
CONST %SHLARITHBIT_CNT_ARITH = 1
CONST %SHLARITHBIT_CNT_KECCAK_F = 0
CONST %SHLARITHBIT_CNT_MEM_ALIGN = 0
Expand Down Expand Up @@ -80,17 +80,17 @@ CONST %MULARITH_CNT_MEM_ALIGN = 0
CONST %MULARITH_CNT_PADDING_PG = 0
CONST %MULARITH_CNT_POSEIDON_G = 0
; getLenBytes
CONST %GETLENBYTES_STEP = 20
CONST %GETLENBYTES_CNT_BINARY = 0
CONST %GETLENBYTES_CNT_ARITH = 0
CONST %GETLENBYTES_STEP = 800
CONST %GETLENBYTES_CNT_BINARY = 61
CONST %GETLENBYTES_CNT_ARITH = 19
CONST %GETLENBYTES_CNT_KECCAK_F = 0
CONST %GETLENBYTES_CNT_MEM_ALIGN = 0
CONST %GETLENBYTES_CNT_PADDING_PG = 0
CONST %GETLENBYTES_CNT_POSEIDON_G = 0
; getLenBits
CONST %GETLENBITS_STEP = 20
CONST %GETLENBITS_CNT_BINARY = 0
CONST %GETLENBITS_CNT_ARITH = 0
CONST %GETLENBITS_STEP = 3000
CONST %GETLENBITS_CNT_BINARY = 321
CONST %GETLENBITS_CNT_ARITH = 79
CONST %GETLENBITS_CNT_KECCAK_F = 0
CONST %GETLENBITS_CNT_MEM_ALIGN = 0
CONST %GETLENBITS_CNT_PADDING_PG = 0
Expand Down Expand Up @@ -209,10 +209,10 @@ CONST %OPCALLDATALOAD_CNT_PADDING_PG = 0 + %SHLARITH_CNT_PADDING_PG + %SHRARITH_
CONST %OPCALLDATALOAD_CNT_POSEIDON_G = 0 + %SHLARITH_CNT_POSEIDON_G + %SHRARITH_CNT_POSEIDON_G + %DIVARITH_CNT_POSEIDON_G
; opCALLDATACOPY - COMPLEX - hardcoded values at test
CONST %OPCALLDATACOPY_STEP = 500
CONST %OPCALLDATACOPY_CNT_BINARY = 16
CONST %OPCALLDATACOPY_CNT_ARITH = 8
CONST %OPCALLDATACOPY_CNT_BINARY = 8
CONST %OPCALLDATACOPY_CNT_ARITH = 2
CONST %OPCALLDATACOPY_CNT_KECCAK_F = 0
CONST %OPCALLDATACOPY_CNT_MEM_ALIGN = 2
CONST %OPCALLDATACOPY_CNT_MEM_ALIGN = 4
CONST %OPCALLDATACOPY_CNT_PADDING_PG = 0
CONST %OPCALLDATACOPY_CNT_POSEIDON_G = 0
; opRETURNDATACOPY - COMPLEX - hardcoded values at test
Expand All @@ -225,23 +225,23 @@ CONST %OPRETURNDATACOPY_CNT_PADDING_PG = 0
CONST %OPRETURNDATACOPY_CNT_POSEIDON_G = 0
; opCODECOPY - COMPLEX - hardcoded values at test
CONST %OPCODECOPY_STEP = 1700
CONST %OPCODECOPY_CNT_BINARY = 55
CONST %OPCODECOPY_CNT_ARITH = 4
CONST %OPCODECOPY_CNT_BINARY = 51
CONST %OPCODECOPY_CNT_ARITH = 2
CONST %OPCODECOPY_CNT_KECCAK_F = 0
CONST %OPCODECOPY_CNT_MEM_ALIGN = 43
CONST %OPCODECOPY_CNT_PADDING_PG = 0
CONST %OPCODECOPY_CNT_POSEIDON_G = 0
; opEXTCODECOPY - COMPLEX - hardcoded values at test
CONST %OPEXTCODECOPY_STEP = 2000
CONST %OPEXTCODECOPY_CNT_BINARY = 59
CONST %OPEXTCODECOPY_CNT_ARITH = 4
CONST %OPEXTCODECOPY_CNT_BINARY = 55
CONST %OPEXTCODECOPY_CNT_ARITH = 2
CONST %OPEXTCODECOPY_CNT_KECCAK_F = 0
CONST %OPEXTCODECOPY_CNT_MEM_ALIGN = 43
CONST %OPEXTCODECOPY_CNT_PADDING_PG = 0
CONST %OPEXTCODECOPY_CNT_POSEIDON_G = 8
; opCREATE - COMPLEX - hardcoded values at test
CONST %OPCREATE_STEP = 400
CONST %OPCREATE_CNT_BINARY = 13
CONST %OPCREATE_CNT_BINARY = 14
CONST %OPCREATE_CNT_ARITH = 1
CONST %OPCREATE_CNT_KECCAK_F = 0
CONST %OPCREATE_CNT_MEM_ALIGN = 0
Expand All @@ -257,63 +257,63 @@ CONST %OPCREATE2_CNT_PADDING_PG = 0
CONST %OPCREATE2_CNT_POSEIDON_G = 27
; opCALL - COMPLEX - hardcoded values at test
CONST %OPCALL_STEP = 600
CONST %OPCALL_CNT_BINARY = 22
CONST %OPCALL_CNT_BINARY = 23
CONST %OPCALL_CNT_ARITH = 3
CONST %OPCALL_CNT_KECCAK_F = 0
CONST %OPCALL_CNT_MEM_ALIGN = 0
CONST %OPCALL_CNT_PADDING_PG = 0
CONST %OPCALL_CNT_POSEIDON_G = 14
; opCALLCODE - COMPLEX - hardcoded values at test
CONST %OPCALLCODE_STEP = 600
CONST %OPCALLCODE_CNT_BINARY = 21
CONST %OPCALLCODE_CNT_BINARY = 22
CONST %OPCALLCODE_CNT_ARITH = 3
CONST %OPCALLCODE_CNT_KECCAK_F = 0
CONST %OPCALLCODE_CNT_MEM_ALIGN = 0
CONST %OPCALLCODE_CNT_PADDING_PG = 0
CONST %OPCALLCODE_CNT_POSEIDON_G = 10
; opRETURN - COMPLEX - hardcoded values at test
CONST %OPRETURN_STEP = 700
CONST %OPRETURN_CNT_BINARY = 25
CONST %OPRETURN_CNT_ARITH = 11
CONST %OPRETURN_CNT_BINARY = 14
CONST %OPRETURN_CNT_ARITH = 5
CONST %OPRETURN_CNT_KECCAK_F = 0
CONST %OPRETURN_CNT_MEM_ALIGN = 4
CONST %OPRETURN_CNT_MEM_ALIGN = 5
CONST %OPRETURN_CNT_PADDING_PG = 0
CONST %OPRETURN_CNT_POSEIDON_G = 0
; opREVERT - COMPLEX - hardcoded values at test
CONST %OPREVERT_STEP = 700
CONST %OPREVERT_CNT_BINARY = 25
CONST %OPREVERT_CNT_ARITH = 11
CONST %OPREVERT_CNT_BINARY = 14
CONST %OPREVERT_CNT_ARITH = 5
CONST %OPREVERT_CNT_KECCAK_F = 0
CONST %OPREVERT_CNT_MEM_ALIGN = 4
CONST %OPREVERT_CNT_MEM_ALIGN = 5
CONST %OPREVERT_CNT_PADDING_PG = 0
CONST %OPREVERT_CNT_POSEIDON_G = 0
; opDELEGATECALL - COMPLEX - hardcoded values at test
CONST %OPDELEGATECALL_STEP = 600
CONST %OPDELEGATECALL_CNT_BINARY = 18
CONST %OPDELEGATECALL_CNT_BINARY = 19
CONST %OPDELEGATECALL_CNT_ARITH = 3
CONST %OPDELEGATECALL_CNT_KECCAK_F = 0
CONST %OPDELEGATECALL_CNT_MEM_ALIGN = 0
CONST %OPDELEGATECALL_CNT_PADDING_PG = 0
CONST %OPDELEGATECALL_CNT_POSEIDON_G = 6
; opSTATICCALL - COMPLEX - hardcoded values at test
CONST %OPSTATICCALL_STEP = 600
CONST %OPSTATICCALL_CNT_BINARY = 18
CONST %OPSTATICCALL_CNT_BINARY = 19
CONST %OPSTATICCALL_CNT_ARITH = 3
CONST %OPSTATICCALL_CNT_KECCAK_F = 0
CONST %OPSTATICCALL_CNT_MEM_ALIGN = 0
CONST %OPSTATICCALL_CNT_PADDING_PG = 0
CONST %OPSTATICCALL_CNT_POSEIDON_G = 6
; opSHA3 - COMPLEX - hardcoded values at test
CONST %OPSHA3_STEP = 3300
CONST %OPSHA3_CNT_BINARY = 81
CONST %OPSHA3_CNT_ARITH = 9
CONST %OPSHA3_CNT_BINARY = 76
CONST %OPSHA3_CNT_ARITH = 7
CONST %OPSHA3_CNT_KECCAK_F = 15
CONST %OPSHA3_CNT_MEM_ALIGN = 63
CONST %OPSHA3_CNT_PADDING_PG = 0
CONST %OPSHA3_CNT_POSEIDON_G = 0
; MSTORE32
CONST %MSTORE32_STEP = 50 + %OFFSETUTIL_STEP
CONST %MSTORE32_CNT_BINARY = 1 + %OFFSETUTIL_CNT_BINARY
CONST %MSTORE32_CNT_BINARY = %OFFSETUTIL_CNT_BINARY
CONST %MSTORE32_CNT_ARITH = 0 + %OFFSETUTIL_CNT_ARITH
CONST %MSTORE32_CNT_KECCAK_F = 0 + %OFFSETUTIL_CNT_KECCAK_F
CONST %MSTORE32_CNT_MEM_ALIGN = 1 + %OFFSETUTIL_CNT_MEM_ALIGN
Expand All @@ -324,7 +324,7 @@ CONST %MSTOREX_STEP = 100 + %MSTORE32_STEP + %SHRARITH_STEP*3 + %SHLARITH_STEP*2
CONST %MSTOREX_CNT_BINARY = 0 + %MSTORE32_CNT_BINARY + %SHRARITH_CNT_BINARY*3 + %SHLARITH_CNT_BINARY*2 + %OFFSETUTIL_CNT_BINARY
CONST %MSTOREX_CNT_ARITH = 0 + %MSTORE32_CNT_ARITH + %SHRARITH_CNT_ARITH*3 + %SHLARITH_CNT_ARITH*2 + %OFFSETUTIL_CNT_ARITH
CONST %MSTOREX_CNT_KECCAK_F = 0 + %MSTORE32_CNT_KECCAK_F + %SHRARITH_CNT_KECCAK_F*3 + %SHLARITH_CNT_KECCAK_F*2 + %OFFSETUTIL_CNT_KECCAK_F
CONST %MSTOREX_CNT_MEM_ALIGN = 0 + %MSTORE32_CNT_MEM_ALIGN + %SHRARITH_CNT_MEM_ALIGN*3 + %SHLARITH_CNT_MEM_ALIGN*2 + %OFFSETUTIL_CNT_MEM_ALIGN
CONST %MSTOREX_CNT_MEM_ALIGN = 2 + %MSTORE32_CNT_MEM_ALIGN + %SHRARITH_CNT_MEM_ALIGN*3 + %SHLARITH_CNT_MEM_ALIGN*2 + %OFFSETUTIL_CNT_MEM_ALIGN
CONST %MSTOREX_CNT_PADDING_PG = 0 + %MSTORE32_CNT_PADDING_PG + %SHRARITH_CNT_PADDING_PG*3 + %SHLARITH_CNT_PADDING_PG*2 + %OFFSETUTIL_CNT_PADDING_PG
CONST %MSTOREX_CNT_POSEIDON_G = 0 + %MSTORE32_CNT_POSEIDON_G + %SHRARITH_CNT_POSEIDON_G*3 + %SHLARITH_CNT_POSEIDON_G*2 + %OFFSETUTIL_CNT_POSEIDON_G
; isEmptyAccount
Expand Down Expand Up @@ -353,7 +353,7 @@ CONST %SAVEMEM_CNT_PADDING_PG = 0 + %MULARITH_CNT_PADDING_PG + %DIVARITH_CNT_PAD
CONST %SAVEMEM_CNT_POSEIDON_G = 0 + %MULARITH_CNT_POSEIDON_G + %DIVARITH_CNT_POSEIDON_G
;addBatchHash
CONST %ADDBATCHHASH_STEP = 10 + %SHRARITH_STEP
CONST %ADDBATCHHASH_CNT_BINARY = 155
CONST %ADDBATCHHASH_CNT_BINARY = 186
CONST %ADDBATCHHASH_CNT_ARITH = 31
CONST %ADDBATCHHASH_CNT_KECCAK_F = 0 + %SHRARITH_CNT_KECCAK_F
CONST %ADDBATCHHASH_CNT_MEM_ALIGN = 0 + %SHRARITH_CNT_MEM_ALIGN
Expand Down
2 changes: 1 addition & 1 deletion counters/tests/MLOADX.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ operation:
:CALL(MLOADX)

%MLOADX_STEP - STEP :JMPN(failedCounters)
4 - CNT_BINARY :JMPNZ(failedCounters)
3 - CNT_BINARY :JMPNZ(failedCounters)
;%MLOADX_CNT_BINARY - CNT_BINARY :JMPNZ(failedCounters)
3 - CNT_ARITH :JMPNZ(failedCounters)
;%MLOADX_CNT_ARITH - CNT_ARITH :JMPNZ(failedCounters)
Expand Down
4 changes: 2 additions & 2 deletions counters/tests/MSTOREX.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ operation:
:CALL(MSTOREX)

%MSTOREX_STEP - STEP:JMPN(failedCounters)
11 - CNT_BINARY :JMPNZ(failedCounters)
0 - CNT_BINARY :JMPNZ(failedCounters)
;%MSTOREX_CNT_BINARY - CNT_BINARY :JMPNZ(failedCounters)
7 - CNT_ARITH :JMPNZ(failedCounters)
0 - CNT_ARITH :JMPNZ(failedCounters)
;%MSTOREX_CNT_ARITH - CNT_ARITH :JMPNZ(failedCounters)
%MSTOREX_CNT_KECCAK_F - CNT_KECCAK_F :JMPNZ(failedCounters)
%MSTOREX_CNT_MEM_ALIGN - CNT_MEM_ALIGN :JMPNZ(failedCounters)
Expand Down
2 changes: 1 addition & 1 deletion counters/tests/expAD.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ operation:
%EXPAD_STEP + 300 - STEP:JMPN(failedCounters)
23 - CNT_BINARY :JMPNZ(failedCounters)
;%EXPAD_CNT_BINARY - CNT_BINARY :JMPNZ(failedCounters)
5 - CNT_ARITH :JMPNZ(failedCounters)
3 - CNT_ARITH :JMPNZ(failedCounters)
;%EXPAD_CNT_ARITH - CNT_ARITH :JMPNZ(failedCounters)
%EXPAD_CNT_KECCAK_F - CNT_KECCAK_F :JMPNZ(failedCounters)
%EXPAD_CNT_MEM_ALIGN - CNT_MEM_ALIGN :JMPNZ(failedCounters)
Expand Down
12 changes: 6 additions & 6 deletions counters/tests/getLenBits.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ operation:
80 => C
:CALL(getLenBits)
%GETLENBITS_STEP + %DIVARITH_STEP*C - STEP:JMPN(failedCounters)
%GETLENBITS_CNT_BINARY + %DIVARITH_CNT_BINARY*C + C - CNT_BINARY :JMPNZ(failedCounters)
%GETLENBITS_CNT_ARITH + %DIVARITH_CNT_ARITH*C - 1 - CNT_ARITH :JMPNZ(failedCounters)
%GETLENBITS_CNT_KECCAK_F + %DIVARITH_CNT_KECCAK_F*C - CNT_KECCAK_F :JMPNZ(failedCounters)
%GETLENBITS_CNT_MEM_ALIGN + %DIVARITH_CNT_MEM_ALIGN*C - CNT_MEM_ALIGN :JMPNZ(failedCounters)
%GETLENBITS_CNT_PADDING_PG + %DIVARITH_CNT_PADDING_PG*C - CNT_PADDING_PG :JMPNZ(failedCounters)
%GETLENBITS_CNT_POSEIDON_G + %DIVARITH_CNT_POSEIDON_G*C - CNT_POSEIDON_G :JMPNZ(failedCounters)
%GETLENBITS_CNT_BINARY - CNT_BINARY :JMPNZ(failedCounters)
%GETLENBITS_CNT_ARITH - CNT_ARITH :JMPNZ(failedCounters)
%GETLENBITS_CNT_KECCAK_F - CNT_KECCAK_F :JMPNZ(failedCounters)
%GETLENBITS_CNT_MEM_ALIGN - CNT_MEM_ALIGN :JMPNZ(failedCounters)
%GETLENBITS_CNT_PADDING_PG - CNT_PADDING_PG :JMPNZ(failedCounters)
%GETLENBITS_CNT_POSEIDON_G - CNT_POSEIDON_G :JMPNZ(failedCounters)

0 => A,B,C,D,E,CTX, SP, PC, GAS, SR, HASHPOS, RR ; Set all registers to 0
finalizeExecution:
Expand Down
14 changes: 7 additions & 7 deletions counters/tests/getLenBytes.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ operation:
0xFFFFFFFFFFFFFFFFFFFFn => B
19 => C
:CALL(getLenBytes)
%GETLENBYTES_STEP + %SHRARITH_STEP*C - STEP:JMPN(failedCounters)
%GETLENBYTES_CNT_BINARY + 60 - CNT_BINARY :JMPNZ(failedCounters)
%GETLENBYTES_STEP - STEP:JMPN(failedCounters)
%GETLENBYTES_CNT_BINARY - CNT_BINARY :JMPNZ(failedCounters)
;%GETLENBYTES_CNT_BINARY + %SHRARITH_CNT_BINARY*C + C + 1 - CNT_BINARY :JMPNZ(failedCounters)
%GETLENBYTES_CNT_ARITH + 19 - CNT_ARITH :JMPNZ(failedCounters)
%GETLENBYTES_CNT_ARITH - CNT_ARITH :JMPNZ(failedCounters)
;%GETLENBYTES_CNT_ARITH + %SHRARITH_CNT_ARITH*C - CNT_ARITH :JMPNZ(failedCounters)
%GETLENBYTES_CNT_KECCAK_F + %SHRARITH_CNT_KECCAK_F*C - CNT_KECCAK_F :JMPNZ(failedCounters)
%GETLENBYTES_CNT_MEM_ALIGN + %SHRARITH_CNT_MEM_ALIGN*C - CNT_MEM_ALIGN :JMPNZ(failedCounters)
%GETLENBYTES_CNT_PADDING_PG + %SHRARITH_CNT_PADDING_PG*C - CNT_PADDING_PG :JMPNZ(failedCounters)
%GETLENBYTES_CNT_POSEIDON_G + %SHRARITH_CNT_POSEIDON_G*C - CNT_POSEIDON_G :JMPNZ(failedCounters)
%GETLENBYTES_CNT_KECCAK_F - CNT_KECCAK_F :JMPNZ(failedCounters)
%GETLENBYTES_CNT_MEM_ALIGN - CNT_MEM_ALIGN :JMPNZ(failedCounters)
%GETLENBYTES_CNT_PADDING_PG - CNT_PADDING_PG :JMPNZ(failedCounters)
%GETLENBYTES_CNT_POSEIDON_G - CNT_POSEIDON_G :JMPNZ(failedCounters)

0 => A,B,C,D,E,CTX, SP, PC, GAS, SR, HASHPOS, RR ; Set all registers to 0
finalizeExecution:
Expand Down
4 changes: 2 additions & 2 deletions counters/tests/opEXP.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ operation:
:JMP(opEXP)
checkCounters:
400 - STEP:JMPN(failedCounters)
29 - CNT_BINARY :JMPNZ(failedCounters)
30 - CNT_BINARY :JMPNZ(failedCounters)
;%OPEXP_CNT_BINARY - CNT_BINARY :JMPNZ(failedCounters)
6 - CNT_ARITH :JMPNZ(failedCounters)
4 - CNT_ARITH :JMPNZ(failedCounters)
;%OPEXP_CNT_ARITH - CNT_ARITH :JMPNZ(failedCounters)
%OPEXP_CNT_KECCAK_F - CNT_KECCAK_F :JMPNZ(failedCounters)
%OPEXP_CNT_MEM_ALIGN - CNT_MEM_ALIGN :JMPNZ(failedCounters)
Expand Down
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
12 changes: 4 additions & 8 deletions main/opcodes/arithmetic.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -294,14 +294,12 @@ opEXP:

; check out-of-gas
$ => C :MLOAD(SP--); [a => C]
$ => B :MLOAD(SP); [exp => B]
$ => B, D :MLOAD(SP), CALL(getLenBytes) ; [exp => B] ; in: [B: number] out: [A: byte length of B]

; check out-of-gas
:CALL(getLenBytes) ; in: [B: number] out: [A: byte length of B]
GAS - %GAS_SLOW_STEP - %EXP_BYTE_GAS * A => GAS :JMPN(outOfGas)

; compute exponentiation
B => D
C => A
zkPC+1 => RR :JMP(expAD) ; in: [A, D] out: [A: A ** D]
A :MSTORE(SP++), JMP(readCode) ; [a ** exp => SP]
Expand All @@ -315,7 +313,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 All @@ -329,14 +327,12 @@ opSIGNEXTEND: ; following this impl https://github.com/ethereumjs/ethereumjs-mon
30 => A
; if signByte is 31 or more, means basically let the number as it is
$ :LT, JMPC(opSIGNEXTENDEnd)
B * 8 + 7 => D, RR; B is less than 31, no need for binary
:CALL(@exp_num + RR)
B * 8 + 7 => RR; B is less than 31, no need for binary
:CALL(@exp_num + RR) ; out:[B: 2**RR]
B => A
$ => D :MLOAD(SP); [x => D]
;Store mask
1 => B
$ => C :SUB ; mask

D => B ; number to convert
$ => B :AND ; check sign bit
0 => A
Expand Down
Loading
Loading