Skip to content
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

EVM: Fix tx fee calculations in validation and miner #2517

Merged
merged 4 commits into from
Oct 3, 2023

Conversation

sieniven
Copy link
Contributor

@sieniven sieniven commented Oct 2, 2023

Summary

  • Fixes to prepay fees when calculating the maximum prepay fees of EIP1559 txs
  • Fix stateless pre-validation of EVM tx calculation of prepay fees to use maximum prepay fee validation for account balance check
  • For stateful validation and adding of EVM txs into the txqueues, current prepay fee calculations is used, which calculates the tx prepay fees with the context of the base fee of the current / target block
  • When EVM txs are included in the mempool, the PR fixes the fee calculations to align with Ethereum, which the replace-by-fee replace conditions are based on the promised tip fees that will go to the miner
  • The old pipeline calculates the evm tx fees based on prepay fees of the current block, which uses effective gas price which is incorrect since it is a stateful calculation and does not guarantee that the tx with the highest promised priority fees that would go to the miner is selected
  • In addition, fee calculation should not be stateful as it may cause incorrect txs to be replaced
  • New design of EVM tx fee calculation in the mempool:
    • Promised miner fees for Legacy/EIP2930 txs will always use INITIAL_BLOCK_FEES (10 gwei) for the stateless fee calculations
    • Promised miner fees for EIP1559 calculation will use the specified priority fee per gas
    • Thus fees calculated for Legacy/EIP2930 txs which might not be the fees that eventually go into the miner since block base fees may differ on the block that the tx is minted
    • This ensures that evm txs that are replaced by the same type (for example, Legacy replaced with Legacy) will always be correct
  • However the downside of the stateless fee calculation is that if the tx replacement is not of the same type, for example: a Legacy/EIP2930 tx is replaced with a EIP1559 tx, the fee replacement will take the assumption that miner promised fees for Legacy/EIP2930 txs is gasPrice - INITIAL_BLOCK_FEES, which may not be the most accurate RBF of the EVM tx

Implications

  • Storage

    • Database reindex required
    • Database reindex optional
    • Database reindex not required
    • None
  • Consensus

    • Network upgrade required
    • Includes backward compatible changes
    • Includes consensus workarounds
    • Includes consensus refactors
    • None

Bushstar
Bushstar previously approved these changes Oct 2, 2023
Bushstar
Bushstar previously approved these changes Oct 2, 2023
@sieniven sieniven requested a review from Bushstar October 2, 2023 15:30
@prasannavl prasannavl merged commit 22f13aa into master Oct 3, 2023
@prasannavl prasannavl deleted the evm/fix-miner-tip-fees branch October 3, 2023 00:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants