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/pre eip155 #150

Merged
merged 2 commits into from
Oct 27, 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
14 changes: 9 additions & 5 deletions main/load-tx-rlp.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,10 @@ readDataFinal:
:CALL(addBatchHashByteByByte)

endData:

; Check all bytes read to detect pre EIP-155 tx
C => A
$ => B :MLOAD(txRLPLength)
$ :EQ,JMPC(setPreEIP155Flag)

;; Read RLP 'chainId'
; 64 bits max
Expand All @@ -237,11 +240,11 @@ chainREAD:
:CALL(addHashTx)
:CALL(addBatchHashData)
A - 0x80 :JMPN(endChainId)
A - 0x81 :JMPN(chanId0)
A - 0x81 :JMPN(chainId0)
A - 0x89 :JMPN(shortChainId)
:JMP(invalidTxRLP)

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

Expand All @@ -262,7 +265,9 @@ endChainId:
0x8080 => B
$ :EQ,JMPC(sizeVerification)
:JMP(invalidTxRLP)


setPreEIP155Flag:
1 :MSTORE(isPreEIP155)
;; size verification
; checks RLP lenght read at the RLP header with bytes read during RLP parsing
sizeVerification:
Expand Down Expand Up @@ -304,7 +309,6 @@ vREADTx:
;;;;;;;;;
;; D - Finish RLP parsing
;;;;;;;;;

;; update bytes parsed
$ => A :MLOAD(batchL2DataParsed)
A + C => A :MSTORE(batchL2DataParsed)
Expand Down
2 changes: 1 addition & 1 deletion main/main.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,10 @@ assertNewLocalExitRoot:
HASHPOS :HASHKLEN(0)

$ => A :MLOAD(globalHash)
${eventLog(onFinishBatch)}
assertNewStateRoot:
$ :HASHKDIGEST(0), ASSERT

${eventLog(onFinishBatch)}

;;;;;;;;;;;;;;;;;;
;; F - Finalize execution
Expand Down
8 changes: 5 additions & 3 deletions main/process-tx.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,13 @@ checkAndSaveFrom:
;; C - Verify chainID
;;;;;;;;;;;;;;;;;;

$ => A :MLOAD(isPreEIP155)
; Don't check chainId for legacy transactions
0 - A :JMPN(endCheckChainId)
$ => A :MLOAD(txChainId)
$ => B :MLOAD(chainId) ; A: chainId tx
$ :EQ,JMPC(endCheckChainId) ; If A == B --> endCheckChainId
:JMP(invalidIntrinsicTxChainId) ; If A != B --> invalidIntrinsicTx
$ :EQ,JMPC(endCheckChainId) ; If A == B --> endCheckChainId
:JMP(invalidIntrinsicTxChainId) ; If A != B --> invalidIntrinsicTx
endCheckChainId:

;; Reset warm/cold information
Expand Down Expand Up @@ -138,7 +141,6 @@ loopBytes:
%MAX_CNT_STEPS - STEP - 20 :JMPN(outOfCountersStep)
A - C - 1 :JMPN(endCalldataIntrinsicGas)
E => B
HASHPOS => D
1 => D
$ => E :MLOAD(batchHashDataId)
$ => D :HASHK(E)
Expand Down
3 changes: 2 additions & 1 deletion main/vars.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,5 @@ VAR CTX salt ; CREATE2 parameter 'salt' used to compute new contract address
VAR CTX gasCTX ; remaining gas in the origin CTX when a new context is created
VAR CTX sigDataSize ; hash position for the ethereum transaction hash
VAR CTX dataStarts; hash position where de transaction 'data' starts in the batchHashData
VAR CTX SPw ; aux variable to store Stack poimnter 'SP'
VAR CTX SPw ; aux variable to store Stack poimnter 'SP'
VAR CTX isPreEIP155 ; flag to check if the current tx is legacy, previous to Spurious Dragon (EIP-155)
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"yargs": "^17.5.1"
},
"devDependencies": {
"@0xpolygonhermez/zkevm-proverjs": "github:0xPolygonHermez/zkevm-proverjs#v0.4.1.0",
"@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#develop",
"@0xpolygonhermez/zkevm-proverjs": "github:0xPolygonHermez/zkevm-proverjs#feature/pre-EIP155",
"@0xpolygonhermez/zkevm-testvectors": "github:0xPolygonHermez/zkevm-testvectors#feature/pre-EIP155",
"chai": "^4.3.6",
"chalk": "^3.0.0",
"eslint": "^8.25.0",
Expand Down