-
Notifications
You must be signed in to change notification settings - Fork 50
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/fix rlp push0 #286
Changes from all commits
d77f64a
a273144
04c8a1a
2c9cca7
a23dc63
b35e5a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,15 @@ | |
* - stack input: none | ||
* - stack output: [pushed_value] | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment applies to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree !! We will add specific comment for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also you need a newer link https://www.evm.codes/#5f?fork=shanghai |
||
|
||
opPUSH0: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it not consume any ZK counters? I would think that gas check at stack check do. Even POP requires 100 steps. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we would add them |
||
; check out-of-gas | ||
GAS - %GAS_QUICK_STEP => GAS :JMPN(outOfGas) | ||
; store stack output | ||
0 :MSTORE(SP++); [0 => SP] | ||
; check stack overflow | ||
%CALLDATA_OFFSET - SP :JMPN(stackOverflow, readCode) | ||
|
||
opPUSH1: | ||
; number of bytes to push to D | ||
1 => D | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -928,6 +928,7 @@ handleError: | |
handleBatchError: | ||
; restore init state root and finish batch | ||
$ => SR :MLOAD(batchSR) | ||
$ :MLOAD(isLoadingRLP),JMPNZ(invalidTxRLP) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be good to have a comment why RLP error processing is different There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In case There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This flag is not used outside the |
||
$${eventLog(onFinishTx)} | ||
$${eventLog(onFinishBatch)} :JMP(processTxsEnd) | ||
|
||
|
@@ -1153,19 +1154,20 @@ finalPush: | |
VAR GLOBAL tmpVarDaddB | ||
VAR GLOBAL tmpZkPCaddB | ||
VAR GLOBAL auxBytes | ||
|
||
;@info: adds data to batchHashdata byte by byte | ||
;@in: A: bytes to add | ||
;@in D: bytes length | ||
addBatchHashByteByByte: | ||
%MAX_CNT_STEPS - STEP - 10 :JMPN(handleOOCSatRLP) | ||
%MAX_CNT_STEPS - STEP - 10 :JMPN(outOfCountersStep) | ||
RR :MSTORE(tmpZkPCaddB) | ||
A :MSTORE(auxBytes) | ||
D :MSTORE(tmpVarDaddB) | ||
1 => D | ||
|
||
utilsAddBatchHashBytebyByteLoop: | ||
%MAX_CNT_STEPS - STEP - 50 :JMPN(handleOOCSatRLP) | ||
%MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(handleOOCBatRLP) | ||
%MAX_CNT_STEPS - STEP - 50 :JMPN(outOfCountersStep) | ||
%MAX_CNT_BINARY - CNT_BINARY - 1 :JMPN(outOfCountersBinary) | ||
32 - D => D | ||
$ => A :MLOAD(auxBytes), CALL(SHRarith); in: [A: value, D: #bytes to right shift] out: [A: shifted result] | ||
; get last byte in A | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? Seems like it can change behaviour (of
getTxs()
?) significantlyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p
is the pointer to the read transactions bytes viagetTxs()
.While reading RLP, we add bytes to the
batchHash
and perform some check afterwards, but the bytes are already added. So, if anything goes wrong we jump toinvalidTxRLP
to load the remaining bytes. The remaining bytes where added starting atp
, where thep
was set during the RLP parsing. This was always true before, but if we perform the check before the bytes are added to thebatchHash
, then it will not match thebatchHash
.The generic way to add the missing
batchHash
bytes was to simply set the pointerp
to starting byte to add, which is stored inbatchHashPos
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So as I understand this error processing is now called from more places (
utils
generating out-of-counters errors), including from the points wherep
is not updated yet, so it is initialized explicitly.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But for old cases, where this error processing is called after
p
is already set, wouldn't this code here add more bytes than needed?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exactly!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for old cases, new code will just only set the
p
where it was already read, so it will just only rewrite thep
with same value