Simplify tx gas price logic #3994
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Applies simplifications and savings to the tx gas price logic.
Changes
Simplifications:
deadlineargument in thegas_price()function anymore since it was alwaysNonebase_feewhich doesn't make sense in the context we need gas price estimation anywayGasPriceEstimating::estimate()instead ofGasPriceEstimating::estimate_with_limits()because we always used the defaults anywaySavings:
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_gasthat 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 enoughmax_fee_per_gasto be executable in n blocks time. However the multiplication also multiplied themax_priority_fee_per_gaswhich 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 requiresmax_fee_per_gasandmax_priority_fee_per_gasto 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.