Align EVM fee accounting with wei-denominated base fees#5420
Conversation
EdHastingsCasperAssociation
left a comment
There was a problem hiding this comment.
lgtm for now; we can refine if necessary as we move forward
|
In |
| @@ -0,0 +1,6 @@ | |||
| # AGENTS.md | |||
There was a problem hiding this comment.
Is this a universal solution? Should all/most/some AI solutions work with this file?
There was a problem hiding this comment.
Yes, pretty much a standardized file. All major coding agents respect it, to my knowledge - https://agents.md/
|
Summary
This PR fixes EVM gas fee denomination across Casper’s mote-based accounting and Ethereum’s wei-based gas-price model.
Casper accounts and fee/refund handling operate in motes:
Ethereum gas prices operate in wei:
To bridge the two:
The PR introduces an explicit
[evm].wei_per_motechainspec value and uses it to scale Casper’s EVM base fee into Ethereum-visible wei, then convert consumed EVM gas fees back into motes for Casper balance accounting.Ethereum Fee Background
Ethereum’s EVM uses gas prices denominated in wei per gas.
For the transaction variants currently supported:
gas_price.max_fee_per_gasmax_priority_fee_per_gasUnder EIP-1559-style rules, the effective gas price is:
The
BASEFEEopcode returns the current block base fee, also denominated in wei.Relevant specs:
Casper Policy Difference
Casper currently does not prioritize EVM transactions by gas-price bidding. Therefore, accepting a fixed-price EVM overbid would charge the user more without giving them any scheduling benefit.
This PR makes that explicit:
Dynamic-fee transactions still use
max_fee_per_gasas a sender cap, but priority fees are rejected:This may be revisited later if we introduce EVM gas-price-aware transaction ordering to be closer to the ETH mainnet transaction handling.
Implementation
[evm].base_feeremains a chainspec policy value denominated in motes per EVM gas.A new chainspec field defines the conversion ratio:
Runtime derives the EVM-visible base fee as:
That wei-denominated value is used for:
revmblock contextbasefee.BASEFEEopcode behavior.effectiveGasPrice.After EVM execution, fees are converted back into motes:
The ceil is intentional because balances cannot represent fractional motes. Any non-zero sub-mote EVM fee is charged as one mote.