Skip to content

Commit

Permalink
fix bytes/bits
Browse files Browse the repository at this point in the history
  • Loading branch information
laisolizq committed May 19, 2022
1 parent 5fb4d14 commit 982bf5d
Show file tree
Hide file tree
Showing 19 changed files with 332 additions and 319 deletions.
120 changes: 60 additions & 60 deletions main/loadtx_rlp.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ loadTx_rlp:
1 => D
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
A - B - C - D :JMPN(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
A :HASHK(E) ; Main Hash
C + D => C
A - 0xc0 :JMPC(invalidTxRLP)
A - 0xf8 :JMPC(shortList)
A - 0xc0 :JMPN(invalidTxRLP)
A - 0xf8 :JMPN(shortList)

longList:
A - 0xf7 => D
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
A - B - C - D :JMPN(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
A :HASHK(E) ; Main Hash
Expand All @@ -54,14 +54,14 @@ nonceREAD:
1 => D
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
A - B - C - D :JMPN(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
A :HASHK(E) ; Main Hash
C + D => C
A - 0x80 :JMPC(endNonce)
A - 0x81 :JMPC(nonce0)
A - 0x89 :JMPC(shortNonce)
A - 0x80 :JMPN(endNonce)
A - 0x81 :JMPN(nonce0)
A - 0x89 :JMPN(shortNonce)
:JMP(invalidTxRLP)

nonce0:
Expand All @@ -74,7 +74,7 @@ shortNonce:
D :MSTORE(lengthNonce)
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
A - B - C - D :JMPN(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
A :HASHK(E) ; Main Hash
Expand All @@ -93,15 +93,15 @@ gasPriceREAD:
1 => D
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
A - B - C - D :JMPN(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
A :HASHK(E) ; Main Hash
C + D => C

A - 0x80 :JMPC(endGasPrice)
A - 0x81 :JMPC(gasPrice0)
A - 0xa1 :JMPC(shortGasPrice)
A - 0x80 :JMPN(endGasPrice)
A - 0x81 :JMPN(gasPrice0)
A - 0xa1 :JMPN(shortGasPrice)
:JMP(invalidTxRLP)

gasPrice0:
Expand All @@ -110,10 +110,10 @@ gasPrice0:

shortGasPrice:
A - 0x80 => D
D - 1 :JMPC(endGasPrice)
D - 1 :JMPN(endGasPrice)
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
A - B - C - D :JMPN(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
A :HASHK(E) ; Main Hash
Expand All @@ -133,25 +133,25 @@ gasREAD:
1 => D
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
A - B - C - D :JMPN(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
A :HASHK(E) ; Main Hash
C + D => C
A - 0x80 :JMPC(endGas)
A - 0x81 :JMPC(gas0)
A - 0xa1 :JMPC(shortGas)
A - 0x80 :JMPN(endGas)
A - 0x81 :JMPN(gas0)
A - 0xa1 :JMPN(shortGas)
:JMP(invalidTxRLP)

gas0:
0 => A :JMPC(endGas)
0 => A :JMPN(endGas)

shortGas:
A - 0x80 => D
D - 1 :JMPC(endGas)
D - 1 :JMPN(endGas)
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
A - B - C - D :JMPN(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
A :HASHK(E) ; Main Hash
Expand All @@ -169,15 +169,15 @@ toREAD:
1 => D
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
A - B - C - D :JMPN(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
A :HASHK(E) ; Main Hash
C + D => C
A - 0x80 :JMPC(invalidTxRLP)
A - 0x81 :JMPC(noTo)
A - 0x94 :JMPC(invalidTxRLP)
A - 0x95 :JMPC(shortTo)
A - 0x80 :JMPN(invalidTxRLP)
A - 0x81 :JMPN(noTo)
A - 0x94 :JMPN(invalidTxRLP)
A - 0x95 :JMPN(shortTo)
:JMP(invalidTxRLP)


Expand All @@ -189,7 +189,7 @@ shortTo:
A - 0x80 => D
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
A - B - C - D :JMPN(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
A :HASHK(E) ; Main Hash
Expand All @@ -209,27 +209,27 @@ valueREAD:
1 => D
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
A - B - C - D :JMPN(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
A :HASHK(E) ; Main Hash
C + D => C

A - 0x80 :JMPC(endValue)
A - 0x81 :JMPC(value0)
A - 0xa1 :JMPC(shortValue)
A - 0x80 :JMPN(endValue)
A - 0x81 :JMPN(value0)
A - 0xa1 :JMPN(shortValue)
:JMP(invalidTxRLP)

value0:
0 => A
:JMPC(endValue)
:JMPN(endValue)

shortValue:
A - 0x80 => D
D - 1 :JMPC(endValue)
D - 1 :JMPN(endValue)
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
A - B - C - D :JMPN(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
A :HASHK(E) ; Main Hash
Expand All @@ -249,15 +249,15 @@ dataREAD:
1024 => SP
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
A - B - C - D :JMPN(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
A :HASHK(E) ; Main Hash
C + D => C
A - 0x80 :JMPC(veryShortData)
A - 0x81 :JMPC(endData)
A - 0xb8 :JMPC(shortData)
A - 0xc0 :JMPC(longData)
A - 0x80 :JMPN(veryShortData)
A - 0x81 :JMPN(endData)
A - 0xb8 :JMPN(shortData)
A - 0xc0 :JMPN(longData)
:JMP(invalidTxRLP)

veryShortData:
Expand All @@ -275,7 +275,7 @@ longData:
A - 0xb7 => D
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
A - B - C - D :JMPN(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
A :HASHK(E) ; Main Hash
Expand All @@ -284,11 +284,11 @@ longData:

readData:
32 => D
B - D :JMPC(readDataFinal)
B - D :JMPN(readDataFinal)
B - D :MSTORE(txDataRead)
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
A - B - C - D :JMPN(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
A :HASHK(E) ; Main Hash
Expand All @@ -299,11 +299,11 @@ readData:


readDataFinal:
B - 1 :JMPC(endData)
B - 1 :JMPN(endData)
B => D
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
A - B - C - D :JMPN(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
A :HASHK(E) ; Main Hash
Expand All @@ -325,26 +325,26 @@ chainREAD:
1 => D
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
A - B - C - D :JMPN(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
A :HASHK(E) ; Main Hash
C+D => C
A - 0x80 :JMPC(endChainId)
A - 0x81 :JMPC(chanId0)
A - 0x89 :JMPC(shortChainId)
A - 0x80 :JMPN(endChainId)
A - 0x81 :JMPN(chanId0)
A - 0x89 :JMPN(shortChainId)
:JMP(invalidTxRLP)

chanId0:
0 => A
:JMPC(endChainId)
:JMPN(endChainId)

shortChainId:
A - 0x80 => D
D - 1 :JMPC(endChainId)
D - 1 :JMPN(endChainId)
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
A - B - C - D :JMPN(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
A :HASHK(E) ; Main Hash
Expand All @@ -360,11 +360,11 @@ endChainId:
2 => D
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
A - B - C - D :JMPN(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
A - 0x8080 :JMPC(invalidTxRLP) ; // TODO: ${comp_eq(A, 0x8080)}
0x8080 - A :JMPC(invalidTxRLP)
A - 0x8080 :JMPN(invalidTxRLP) ; // TODO: ${comp_eq(A, 0x8080)}
0x8080 - A :JMPN(invalidTxRLP)
A :HASHK(E)
C+D => C

Expand All @@ -373,8 +373,8 @@ endChainId:
;;;;;;;;;
C => A
$ => B :MLOAD(txRLPLength)
A - B :JMPC(invalidTxRLP)
B - A :JMPC(invalidTxRLP) ; // TODO: ${comp_eq(A, 0x8080)}
A - B :JMPN(invalidTxRLP)
B - A :JMPN(invalidTxRLP) ; // TODO: ${comp_eq(A, 0x8080)}
; check ctx.hashK[addr].data.length == HASHPOS and ctx.hashK[addr].digest = keccak256(data)
HASHPOS :HASHKLEN(E)

Expand All @@ -386,7 +386,7 @@ rREADTx:
32 => D
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
A - B - C - D :JMPN(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
A :MSTORE(txR)
Expand All @@ -400,7 +400,7 @@ sREADTx:
32 => D
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
A - B - C - D :JMPN(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
A :MSTORE(txS)
Expand All @@ -414,7 +414,7 @@ vREADTx:
1 => D
$ => A :MLOAD(batchL2DataLength)
$ => B :MLOAD(batchL2DataParsed)
A - B - C - D :JMPC(invalidTxRLP)
A - B - C - D :JMPN(invalidTxRLP)
${getTxs(p,D)} => A
$${ p = p + D}
A :MSTORE(txV)
Expand Down
10 changes: 5 additions & 5 deletions main/main.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ txLoopRLP:

$ => A :MLOAD(batchL2DataLength)
$ => C :MLOAD(batchL2DataParsed)
C - A :JMPC(loadTx_rlp)
C - A :JMPN(loadTx_rlp)
:JMP(endCheckRLP)

endCheckRLP:
Expand All @@ -113,7 +113,7 @@ endCheckRLP:
txLoop:
$ => A :MLOAD(pendingTxs)
A-1 => A :MSTORE(pendingTxs)
A :JMPC(processTxsEnd)
A :JMPN(processTxsEnd)

$ => A :MLOAD(ctxTxToUse) ; Set the CTX and store in system
A+1 => CTX :MSTORE(ctxTxToUse)
Expand Down Expand Up @@ -154,7 +154,7 @@ processTxsEnd:
$${p = 0}

appendTxs:
B - C - 32 :JMPC(finalAppendTxs)
B - C - 32 :JMPN(finalAppendTxs)
32 => D
${getTxs(p,D)} => A
$${p = p + D}
Expand All @@ -164,7 +164,7 @@ appendTxs:

finalAppendTxs:
B - C => D
D - 1 :JMPC(endAppendTxs)
D - 1 :JMPN(endAppendTxs)
${getTxs(p,D)} => A
$${ p = p + D}
A :HASHK(E)
Expand Down Expand Up @@ -223,7 +223,7 @@ endAppendTxs:
0 => A,B,C,D,E,CTX, SP, PC, GAS, MAXMEM, SR, HASHPOS, RR ; Set all registers to 0

finalWait:
${beforeLast()} : JMPC(finalWait)
${beforeLast()} : JMPN(finalWait)
: JMP(start)

INCLUDE "loadtx_rlp.zkasm"
Expand Down
Loading

0 comments on commit 982bf5d

Please sign in to comment.