-
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
Effective gas implementation #290
Changes from all commits
42dd1a4
fbf5a82
d09f1c5
7d966f8
ac51215
fcb8126
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 |
---|---|---|
|
@@ -285,6 +285,11 @@ vREADTx: | |
A :MSTORE(txV) | ||
C + D => C :CALL(addBatchHashData) | ||
|
||
;; read effective percentage | ||
effectivePercentageTx: | ||
1 => D :CALL(getTxBytes) | ||
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. The description of 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.
|
||
A :MSTORE(effectivePercentageRLP) | ||
C + D => C :CALL(addBatchHashData) | ||
;;;;;;;;; | ||
;; D - Finish RLP parsing | ||
;;;;;;;;; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,8 @@ processTx: | |
; Minimum of 100000 steps left to process a tx | ||
%MAX_CNT_STEPS - STEP - 100000 :JMPN(outOfCountersStep) | ||
%MAX_CNT_BINARY - CNT_BINARY - 100 :JMPN(outOfCountersBinary) | ||
%MAX_CNT_ARITH - CNT_ARITH - 2 :JMPN(outOfCountersArith) | ||
|
||
$ => A :MLOAD(txHash) | ||
; Check the signature | ||
$ => B :MLOAD(txR) | ||
|
@@ -68,9 +70,33 @@ endCheckChainId: | |
:CALL(isColdAddress) ; add tx.origin to touched addresses | ||
0 :MSTORE(depth) ; Initial depth is 0 | ||
|
||
;; Set gasPrice global var | ||
;; Set gasPrice global var depending on effectivePercentage [0-255] -> txGasPrice = Floor((gasPrice * (effectivePercentage + 1)) / 256) | ||
; gasPrice => A | ||
$ => A :MLOAD(txGasPriceRLP) | ||
A :MSTORE(txGasPrice) | ||
; effectivePercentage => B | ||
$ => B :MLOAD(effectivePercentageRLP) | ||
; B -> [1, 256] | ||
B + 1 => B | ||
; A*B + C = D * 2**256 + op(E) | ||
0 => C | ||
; _effGasPriceShifted = gasPrice * (effectivePercentage + 1) | ||
$${var _effGasPriceShifted = A * B} | ||
; get value above 256 bits | ||
${_effGasPriceShifted >> 256} => D | ||
; compute ARITH | ||
${_effGasPriceShifted} => E :ARITH | ||
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. Should we have out of arith counters check for this code? 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, I agree we should add an arith checker at beginning of |
||
|
||
; txGasPrice = _effGasPriceShifted / 256 | ||
256 => B | ||
; (_effGasPriceShifted / 256)(A) * 256(B) + (_effGasPriceShifted % 256)(C) = D * 2**256 + op(E) | ||
${_effGasPriceShifted / 256} => A :MSTORE(txGasPrice) | ||
${_effGasPriceShifted % 256} => C | ||
; compute ARITH | ||
E :ARITH | ||
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. Maybe I still don't quite understand how this works, so correct where if I'm wrong. I believe the purpose of this ARITH is to contstrain the free calculations above ( This What would stop malicious prover to return arbitrary value into 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. Actually I think I understand now: it takes into account previous values of E and D and checks result of ARITH against them, because this expression doesn't have an assignment to register. |
||
; check divisor > remainder | ||
C => A | ||
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. To confirm: 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. Is the usage of 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. LT uses 1 binary, so yes. |
||
1 :LT | ||
|
||
;;;;;;;;;;;;;;;;;; | ||
;; D - Verify and increase nonce | ||
;;;;;;;;;;;;;;;;;; | ||
|
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.
This label is never called. Is this just a documentation?
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.
yes, it is there for clarity