Skip to content

Commit

Permalink
Merge pull request #51 from hermeznetwork/feature/solve-notations
Browse files Browse the repository at this point in the history
Feature/solve notations
  • Loading branch information
ignasirv authored May 16, 2022
2 parents 71c3443 + 7594157 commit 66df67d
Show file tree
Hide file tree
Showing 10 changed files with 19,494 additions and 14,010 deletions.
32,938 changes: 19,167 additions & 13,771 deletions build/rom.json

Large diffs are not rendered by default.

109 changes: 55 additions & 54 deletions main/loadtx_rlp.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ loadTx_rlp:
; We get a new hashId
$ => E :MLOAD(lastHashIdUsed)
E+1 => E :MSTORE(lastHashIdUsed)
; Pointer to next RLP bytes to read
0 => C


Expand All @@ -12,8 +13,8 @@ loadTx_rlp:
;;;;;;;;;

1 => D
$ => A :MLOAD(txsListLength)
$ => B :MLOAD(batchL2DataRead)
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
Expand All @@ -24,8 +25,8 @@ loadTx_rlp:

longList:
A - 0xf7 => D
$ => A :MLOAD(txsListLength)
$ => B :MLOAD(batchL2DataRead)
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
Expand All @@ -36,7 +37,7 @@ shortList:
A - 0xc0 => A

endList:
A + C :MSTORE(txListLength)
A + C :MSTORE(txRLPLength)


;;;;;;;;;
Expand All @@ -46,8 +47,8 @@ endList:

nonceREAD:
1 => D
$ => A :MLOAD(txsListLength)
$ => B :MLOAD(batchL2DataRead)
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
Expand All @@ -59,8 +60,8 @@ nonceREAD:
shortNonce:
A - 0x80 => D
D :MSTORE(lengthNonce)
$ => A :MLOAD(txsListLength)
$ => B :MLOAD(batchL2DataRead)
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
Expand All @@ -78,8 +79,8 @@ endNonce:

gasPriceREAD:
1 => D
$ => A :MLOAD(txsListLength)
$ => B :MLOAD(batchL2DataRead)
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
Expand All @@ -91,8 +92,8 @@ gasPriceREAD:
:JMP(invalidTxRLP)
shortGasPrice:
A - 0x80 => D
$ => A :MLOAD(txsListLength)
$ => B :MLOAD(batchL2DataRead)
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
Expand All @@ -111,8 +112,8 @@ endGasPrice:

gasREAD:
1 => D
$ => A :MLOAD(txsListLength)
$ => B :MLOAD(batchL2DataRead)
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
Expand All @@ -123,8 +124,8 @@ gasREAD:
:JMP(invalidTxRLP)
shortGas:
A - 0x80 => D
$ => A :MLOAD(txsListLength)
$ => B :MLOAD(batchL2DataRead)
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
Expand All @@ -141,8 +142,8 @@ endGas:

toREAD:
1 => D
$ => A :MLOAD(txsListLength)
$ => B :MLOAD(batchL2DataRead)
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
Expand All @@ -156,13 +157,13 @@ toREAD:


noTo:
1 :MSTORE(txIsCreateContract)
1 :MSTORE(isCreateContract)
:JMP(endTo)

shortTo:
A - 0x80 => D
$ => A :MLOAD(txsListLength)
$ => B :MLOAD(batchL2DataRead)
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
Expand All @@ -181,8 +182,8 @@ endTo:

valueREAD:
1 => D
$ => A :MLOAD(txsListLength)
$ => B :MLOAD(batchL2DataRead)
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
Expand All @@ -194,8 +195,8 @@ valueREAD:
:JMP(invalidTxRLP)
shortValue:
A - 0x80 => D
$ => A :MLOAD(txsListLength)
$ => B :MLOAD(batchL2DataRead)
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
Expand All @@ -214,8 +215,8 @@ endValue:
dataREAD:
1 => D
1024 => SP
$ => A :MLOAD(txsListLength)
$ => B :MLOAD(batchL2DataRead)
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
Expand All @@ -228,33 +229,33 @@ dataREAD:
:JMP(invalidTxRLP)

veryShortData:
1 :MSTORE(txNData)
1 :MSTORE(txCalldataLen)
31 => D
$ => A :SHL
A :MSTORE(SP++)
:JMP(endData)

shortData:
A - 0x80 => B :MSTORE(txNData)
A - 0x80 => B :MSTORE(txCalldataLen)
:JMP(readData)

longData:
A - 0xb7 => D
$ => A :MLOAD(txsListLength)
$ => B :MLOAD(batchL2DataRead)
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
A :HASHW(E) ; Main Hash
C+D => C
A => B :MSTORE(txNData)
A => B :MSTORE(txCalldataLen)

readData:
32 => D
B - D :JMPC(readDataFinal)
B - D :MSTORE(txDataRead)
$ => A :MLOAD(txsListLength)
$ => B :MLOAD(batchL2DataRead)
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
Expand All @@ -268,8 +269,8 @@ readData:
readDataFinal:
B - 1 :JMPC(endData)
B => D
$ => A :MLOAD(txsListLength)
$ => B :MLOAD(batchL2DataRead)
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
Expand All @@ -290,8 +291,8 @@ endData:

chainREAD:
1 => D
$ => A :MLOAD(txsListLength)
$ => B :MLOAD(batchL2DataRead)
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
Expand All @@ -302,8 +303,8 @@ chainREAD:
:JMP(invalidTxRLP)
shortChainId:
A - 0x80 => D
$ => A :MLOAD(txsListLength)
$ => B :MLOAD(batchL2DataRead)
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
Expand All @@ -318,12 +319,12 @@ endChainId:
;;;;;;;;;

2 => D
$ => A :MLOAD(txsListLength)
$ => B :MLOAD(batchL2DataRead)
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
A - 0x8080 :JMPC(invalidTxRLP)
A - 0x8080 :JMPC(invalidTxRLP) ; // TODO: ${comp_eq(A, 0x8080)}
0x8080 - A :JMPC(invalidTxRLP)
A :HASHW(E)
C+D => C
Expand All @@ -332,9 +333,9 @@ endChainId:
;; Size Verification
;;;;;;;;;
C => A
$ => B :MLOAD(txListLength)
$ => B :MLOAD(txRLPLength)
A - B :JMPC(invalidTxRLP)
B - A :JMPC(invalidTxRLP)
B - A :JMPC(invalidTxRLP) ; // TODO: ${comp_eq(A, 0x8080)}
:HASHE(E)

;;;;;;;;;
Expand All @@ -343,8 +344,8 @@ endChainId:

rREADTx:
32 => D
$ => A :MLOAD(txsListLength)
$ => B :MLOAD(batchL2DataRead)
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
Expand All @@ -357,8 +358,8 @@ rREADTx:

sREADTx:
32 => D
$ => A :MLOAD(txsListLength)
$ => B :MLOAD(batchL2DataRead)
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
Expand All @@ -371,8 +372,8 @@ sREADTx:

vREADTx:
1 => D
$ => A :MLOAD(txsListLength)
$ => B :MLOAD(batchL2DataRead)
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
Expand All @@ -382,8 +383,8 @@ vREADTx:
;;;;;;;;;
;; Update bytes read and txs to be processed
;;;;;;;;;
$ => A :MLOAD(batchL2DataRead)
A + C => A :MSTORE(batchL2DataRead)
$ => A :MLOAD(batchL2DataParsed)
A + C => A :MSTORE(batchL2DataParsed)
$ => A :MLOAD(pendingTxs)
A + 1 => A :MSTORE(pendingTxs)
:JMP(txLoopRLP)
Expand Down
Loading

0 comments on commit 66df67d

Please sign in to comment.