Skip to content
This repository was archived by the owner on May 12, 2025. It is now read-only.

Fix gas fee calculation to account for gasTipCap#200

Merged
eelanagaraj merged 3 commits into
eelanagaraj/g-hardfork-prepfrom
eelanagaraj/fix-dynamic-tx-fee-calc
Aug 4, 2023
Merged

Fix gas fee calculation to account for gasTipCap#200
eelanagaraj merged 3 commits into
eelanagaraj/g-hardfork-prepfrom
eelanagaraj/fix-dynamic-tx-fee-calc

Conversation

@eelanagaraj

@eelanagaraj eelanagaraj commented Aug 3, 2023

Copy link
Copy Markdown
Contributor

Description

Current gas calculation logic in Rosetta is incorrect for DynamicFeeTx and CeloDynamicFeeTx when GasTipCap < GasFeeCap - BaseFee. This PR fixes the logic by using EffectiveGasTip to directly compute the tip paid to the coinbase and sums this with the calculated BaseFee to get the correct total tx gas price.

Details:

  • GasPrice is the tx fee limit
  • Dynamic & CeloDynamic txs can also specify GasTipCap
  • BaseFee calculation is the same for all of the txs (GPM)
  • Tip calculation is different:
    • legacy: GasPrice - BaseFee
    • dynamic: min(GasTipCap, GasFeeCap - BaseFee)
      • tx.EffectiveGasTip should compute the tip properly for both legacy & new dynamic types since GasTipCap==GasFeeCap==GasPrice for legacy txs (so should be backwards compatible)

Testing

  • Fixes a reconciliation error seen with a DynamicFeeTx on the global testnet
  • Passed reconciliation tests for at least the first 10k blocks on mainnet

Will run full reconciliation tests on this for the global testnet + ideally on baklava (as part of full G-fork release testing).

@eelanagaraj eelanagaraj marked this pull request as ready for review August 3, 2023 16:19

@gastonponti gastonponti left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment thread analyzer/txtracer.go Outdated
@eelanagaraj eelanagaraj merged commit 07bd55e into eelanagaraj/g-hardfork-prep Aug 4, 2023
@eelanagaraj eelanagaraj deleted the eelanagaraj/fix-dynamic-tx-fee-calc branch August 4, 2023 12:45
eelanagaraj pushed a commit that referenced this pull request Aug 23, 2023
* Fix gas fee calculation to account for gasTipCap

* Add comment for header.baseFee usage

* Rename totalTip to effectiveTip
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants