-
Notifications
You must be signed in to change notification settings - Fork 302
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
Implement EIP-7623 "Increase calldata cost" #1095
Conversation
40bb192
to
2ca9f63
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1095 +/- ##
==========================================
- Coverage 94.31% 93.84% -0.47%
==========================================
Files 159 159
Lines 17298 17330 +32
==========================================
- Hits 16314 16263 -51
- Misses 984 1067 +83
Flags with carried forward coverage won't be shown. Click here to find out more.
|
2ca9f63
to
e93ca40
Compare
95cc90a
to
d09ea2f
Compare
e4267d7
to
23014df
Compare
test/unittests/state_tx_test.cpp
Outdated
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.
I would add one more test which tests two different case:
- Case in which tx gas cost is the intrinsic. So the ratio of calldata gas and execution gas is below threshold.
- Case where we are above threshold and we have tx cost calculated calculated based on
TOTAL_COST_FLOOR_PER_TOKEN
It should be possible just by extending call data size until we get into second case.
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.
I added 3 execution test cases. Please check if these are what you requested.
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. Thanks.
23014df
to
5c58a1b
Compare
@@ -497,6 +510,9 @@ TransactionReceipt transition(const StateView& state_view, const BlockInfo& bloc | |||
gas_used -= refund; | |||
assert(gas_used > 0); | |||
|
|||
// EIP-7623: The gas used by the transaction must be at least the min_gas_cost. | |||
gas_used = std::max(gas_used, tx_props.min_gas_cost); |
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 in the end gas used may be higher than transaction gas limit? wild
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.
Ah no, I guess not, because it's checked in transaction validity
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.
Correct. The tx gas limit must be big enough during validation to cover the minimal gas cost.
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.
Hm in EIP max operation left side is
STANDARD_TOKEN_COST * tokens_in_calldata
+ execution_gas_used
+ isContractCreation * (32000 + INITCODE_WORD_COST * words(calldata))
but here it is, I think
21000
+ STANDARD_TOKEN_COST * tokens_in_calldata
+ execution_gas_used
+ isContractCreation * (32000 + INITCODE_WORD_COST * words(calldata))
because 21000
was included in intrinsic_cost
?
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.
By the Yellow Paper and the names we used so far the intrinsic gas includes the base cost of 21000. The EIP extracts the base cost outside of the max function: 21000 + max(intrinsic_without_base, floor_gas)
.
Because also the EIP don't name any of these values, I decided to include the base cost in the min_gas_cost
. It is easier to use.
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.
Oh I see
This implements [EIP-7623](https://eips.ethereum.org/EIPS/eip-7623). In effect, during transaction validation we compute minimal transaction gas cost. After transaction execution the amount of gas used is increased to this value if lower.
Skip state tests having EIP-7702 (type 4) transactions. These are not supported yet what prevents clearly testing other new features.
5c58a1b
to
9899329
Compare
This implements EIP-7623.
In effect, during transaction validation we compute minimal transaction
gas cost. After transaction execution the amount of gas used is
increased to this value if lower.
Requires #1107 #1108. Merged