Skip to content

Conversation

@MartinquaXD
Copy link
Contributor

@MartinquaXD MartinquaXD commented Dec 18, 2025

Description

Applies simplifications and savings to the tx gas price logic.

Changes

Simplifications:

  • don't take a deadline argument in the gas_price() function anymore since it was always None
  • stop fetching the block in the alloy gas price estimator since it's only used for the base_fee which doesn't make sense in the context we need gas price estimation anyway
  • use GasPriceEstimating::estimate() instead of GasPriceEstimating::estimate_with_limits() because we always used the defaults anyway

Savings:
Rely on gas price estimator to provide a reasonable gas price instead of bumping the gas price once per block until the submissions deadline. The alloy gas price estimator that we use actually already returns a max_fee_per_gas that is twice as high as the current base fee (see here) which already be sufficient for the tight deadlines we now have. Additionally the logic that increased the gas price for every block until the deadline (price * PRICE_BUMP.powi(blocks_until_deadline)) was only ever intended to make sure the transaction has a high enough max_fee_per_gas to be executable in n blocks time. However the multiplication also multiplied the max_priority_fee_per_gas which caused us to pay significantly more even if the tx gets mined in the very next block. (Note that multiplying both values is correct for the case where we have to submit a cancellation because the node requires max_fee_per_gas and max_priority_fee_per_gas to have increased to accept the replacement).

How to test

Briefly tested in on mainnet (most of our volume) and bnb (very costly l2). On mainnet the tx fee didn't change much which was to be expected because the repeated multiplying the tx gas price doesn't matter too much there because the tx submission deadline is so short => only a few gas price bumps.
On BNB it reduced the gas cost per tx from 1.9$ to 3ct. 🙈
There was no increased submission delay for those very few transactions I did.

@MartinquaXD MartinquaXD requested a review from a team as a code owner December 18, 2025 14:33
@MartinquaXD MartinquaXD added the hotfix Labels PRs that should be applied into production right away label Dec 19, 2025
@MartinquaXD MartinquaXD added this pull request to the merge queue Dec 19, 2025
Merged via the queue into main with commit ed665bd Dec 19, 2025
20 checks passed
@MartinquaXD MartinquaXD deleted the simplify-gas-costs branch December 19, 2025 11:45
@github-actions github-actions bot locked and limited conversation to collaborators Dec 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

hotfix Labels PRs that should be applied into production right away

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants