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

Add buffer to gasPrices on Arbitrum estimator #8449

Merged
merged 2 commits into from
Mar 8, 2023

Conversation

dimriou
Copy link
Collaborator

@dimriou dimriou commented Feb 15, 2023

No description provided.

// the block's base fee. If the base fee increases rapidly there is a chance the suggested gas price will fall under that value, resulting in a fee too low error.
// We use gasPriceWithBuffer to increase the estimated gas price by some percentage to avoid fee too low errors. Eventually, only the base fee will be paid, regardless of the price.
func (a *arbitrumEstimator) gasPriceWithBuffer(gasPrice *assets.Wei, maxGasPriceWei *assets.Wei) *assets.Wei {
gasPrice = gasPrice.AddPercentage(25)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@prashantkumar1982 we could potentially make the 25% value configurable, although I'm a bit worried about having an ENV var that is specifically dedicated to 1 chain.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think its ok not to have it be configurable, but can it be at least in a named constant?

@github-actions
Copy link
Contributor

I see that you haven't updated any CHANGELOG files. Would it make sense to do so?

Copy link
Contributor

@prashantkumar1982 prashantkumar1982 left a comment

Choose a reason for hiding this comment

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

Change looks good.
However this should definitely cause the unit-tests to fail. You will need to fix them.
Also add 1 more test-case where maxGasPriceWei is lower than 25% buffer, so we ensure the final max is equal to the limit.

@dimriou
Copy link
Collaborator Author

dimriou commented Feb 15, 2023

Yes this is a draft PR. I just wanted to align on whether we should use a configurable percentage or not.
Something else that comes to mind is whether this PR will result in increased not sufficient balance errors that we've seen before since it increases the upfront cost by 25%.

samsondav
samsondav previously approved these changes Feb 16, 2023
// the block's base fee. If the base fee increases rapidly there is a chance the suggested gas price will fall under that value, resulting in a fee too low error.
// We use gasPriceWithBuffer to increase the estimated gas price by some percentage to avoid fee too low errors. Eventually, only the base fee will be paid, regardless of the price.
func (a *arbitrumEstimator) gasPriceWithBuffer(gasPrice *assets.Wei, maxGasPriceWei *assets.Wei) *assets.Wei {
gasPrice = gasPrice.AddPercentage(25)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think its ok not to have it be configurable, but can it be at least in a named constant?

@dimriou dimriou force-pushed the bci-720_fix_arbitrum_estimator branch from 100185d to 6d5e9bd Compare February 17, 2023 11:37
@dimriou dimriou marked this pull request as ready for review February 17, 2023 11:39
@dimriou dimriou force-pushed the bci-720_fix_arbitrum_estimator branch 2 times, most recently from ac6cff1 to f2bd2ab Compare February 17, 2023 17:19
// the block's base fee. If the base fee increases rapidly there is a chance the suggested gas price will fall under that value, resulting in a fee too low error.
// We use gasPriceWithBuffer to increase the estimated gas price by some percentage to avoid fee too low errors. Eventually, only the base fee will be paid, regardless of the price.
func (a *arbitrumEstimator) gasPriceWithBuffer(gasPrice *assets.Wei, maxGasPriceWei *assets.Wei) *assets.Wei {
const gasPriceBufferPercentage = 25
Copy link
Contributor

Choose a reason for hiding this comment

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

Thinking more about it.
Could we bump up the buffer to 100%?
It still only requires wallet to hold funds good enough for 2 txs, doesn't sound too much.
we anyways will not pay that, so no harm being generous here.
It will also help avoid Low Fee error more easily.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't like bumping to 100% because that would mean we completely mask the problem. Since this is an Arbitrum issue, we need to draw the line somewhere and say "Ok, a certain percentage is somewhat understandable, but if the RPC suggests estimations that are more than 25% off, then this should be fixed on their end". Maybe we could reach up to 50% if we feel it's acceptable.

@dimriou dimriou force-pushed the bci-720_fix_arbitrum_estimator branch from f2bd2ab to 5b996ed Compare March 8, 2023 15:48
@dimriou dimriou force-pushed the bci-720_fix_arbitrum_estimator branch from 5b996ed to ee3a66f Compare March 8, 2023 15:50
@cl-sonarqube-production
Copy link

SonarQube Quality Gate

Quality Gate failed

Failed condition 75.0% 75.0% Coverage on New Code (is less than 90%)

See analysis details on SonarQube

@prashantkumar1982 prashantkumar1982 merged commit 9c3f5d5 into develop Mar 8, 2023
@prashantkumar1982 prashantkumar1982 deleted the bci-720_fix_arbitrum_estimator branch March 8, 2023 16:12
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