-
Notifications
You must be signed in to change notification settings - Fork 37
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
feat(levm): increase calldata cost - EIP-7623 #1665
Conversation
* Check for gas limit restriction for being too low * Adjust gas used if it is under the floor * Adds TxValidationError for gas limit too low
|
@@ -169,6 +169,9 @@ pub const ACCESS_LIST_ADDRESS_COST: u64 = 2400; | |||
// Precompile costs | |||
pub const ECRECOVER_COST: u64 = 3000; | |||
|
|||
// Floor price gas used | |||
pub const TOTAL_COST_FLOOR_PER_TOKEN: u64 = 10; |
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.
Does this variable come from the EIP? If so, it'd be nice to link to were it comes from.
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.
Done, 9edc75d
} | ||
|
||
fn add_intrinsic_gas(&mut self, initial_call_frame: &mut CallFrame) -> Result<(), VMError> { | ||
// Intrinsic gas is the gas consumed by the transaction before the execution of the opcodes. Section 6.2 in the Yellow Paper. |
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.
Great, thanks for clarfying from where this comes from.
crates/vm/levm/src/vm.rs
Outdated
// tokens_in_calldata = tx_calldata / 4 | ||
let tokens_in_calldata: u64 = gas_cost::tx_calldata(¤t_call_frame.calldata) | ||
.map_err(VMError::OutOfGas)? | ||
.checked_div(4) | ||
.ok_or(VMError::Internal(InternalError::DivisionError))?; | ||
|
||
// floor_gas_price = TX_BASE_COST + TOTAL_COST_FLOOR_PER_TOKEN * tokens_in_calldata |
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.
Same as above, where does this logic come from? Also, why divide by 4?
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.
Done, 0be370d
Benchmark Results ComparisonPR ResultsBenchmark Results: Factorial
Benchmark Results: Fibonacci
Main ResultsBenchmark Results: Factorial
Benchmark Results: Fibonacci
|
Before reviewing the PR:
The PR description looks very good! |
Motivation
This Pull Request exists to make a floor cost for the gas usage in the transactions. This is specified in EIP-7623, and aims to reduce the maximum block size to make room for additional blobs or potential block gas limit increases. Also, it introduces that the gas limit has to be at least the floor cost.
Description
Here, for the Prague Spec adds the check in the
prepare_execution
to the gas limit be greater or equal to the max value of the intrinsic gas orTX_BASE_COST + TOTAL_COST_FLOOR_PER_TOKEN * tokens_in_calldata
. WhereTOTAL_COST_FLOOR_PER_TOKEN
is a new constant with the value of 10.A new error is added when the gas limit is too low,
TxValidationError::GasLimitTooLow
.Then when creating the report, the gas usage for Prague is the max value of the gas usage or
TX_BASE_COST + TOTAL_COST_FLOOR_PER_TOKEN * tokens_in_calldata
.State
The only tests for this EIP that fail are the test with type 4 transactions. This is because we don't have implemented them.
Closes #1640