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

Remove fee history fallback #4210

Merged
merged 2 commits into from
Apr 27, 2024
Merged

Conversation

matthewwalsh0
Copy link
Member

@matthewwalsh0 matthewwalsh0 commented Apr 25, 2024

Explanation

Currently the GasFeeController has a series of fallbacks in order to estimate the current gas fees for a network.

Broadly speaking, these are currently:

  1. Retrieve the estimates from the gas API.
  2. Calculate the estimates using eth_feeHistory.
  3. Retrieve the estimates using eth_gasPrice.

Option 2 behaves similar to the gas API itself in that it retrieves the fee history for the last 5 blocks, then uses different percentiles in order to determine a low, medium, and high estimate. This includes validations to ensure a minimum priority fee however unlike the gas API, these constants or "settings" are not chain specific and can therefore be considerably incorrect, especially in the case of layer 2 networks where gas fee values are considerably smaller.

This results in a scenario where MetaMask consistently suggests high values for new networks that are not yet supported by the gas API, when a more suitable value could have been provided had a standard eth_gasPrice call been used instead.

As such, this PR ultimately removes the fee history logic (option 2) from the GasFeeController, meaning if the gas API does not support a network, a standard eth_gasPrice call is the only fallback.

References

Fixes #2385

Changelog

@metamask/gas-fee-controller

  • REMOVED: Remove fee history fallback in favour of eth_gasPrice call.

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

@matthewwalsh0
Copy link
Member Author

@metamaskbot publish-preview

Copy link
Contributor

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/accounts-controller": "13.0.0-preview-fb52b9eb",
  "@metamask-previews/address-book-controller": "4.0.1-preview-fb52b9eb",
  "@metamask-previews/announcement-controller": "6.1.0-preview-fb52b9eb",
  "@metamask-previews/approval-controller": "6.0.1-preview-fb52b9eb",
  "@metamask-previews/assets-controllers": "28.0.0-preview-fb52b9eb",
  "@metamask-previews/base-controller": "5.0.1-preview-fb52b9eb",
  "@metamask-previews/build-utils": "2.0.1-preview-fb52b9eb",
  "@metamask-previews/composable-controller": "6.0.1-preview-fb52b9eb",
  "@metamask-previews/controller-utils": "9.1.0-preview-fb52b9eb",
  "@metamask-previews/ens-controller": "10.0.1-preview-fb52b9eb",
  "@metamask-previews/eth-json-rpc-provider": "3.0.1-preview-fb52b9eb",
  "@metamask-previews/gas-fee-controller": "15.0.0-preview-fb52b9eb",
  "@metamask-previews/json-rpc-engine": "8.0.1-preview-fb52b9eb",
  "@metamask-previews/json-rpc-middleware-stream": "7.0.1-preview-fb52b9eb",
  "@metamask-previews/keyring-controller": "15.0.0-preview-fb52b9eb",
  "@metamask-previews/logging-controller": "3.0.1-preview-fb52b9eb",
  "@metamask-previews/message-manager": "8.0.1-preview-fb52b9eb",
  "@metamask-previews/name-controller": "6.0.1-preview-fb52b9eb",
  "@metamask-previews/network-controller": "18.1.0-preview-fb52b9eb",
  "@metamask-previews/notification-controller": "5.0.1-preview-fb52b9eb",
  "@metamask-previews/permission-controller": "9.0.2-preview-fb52b9eb",
  "@metamask-previews/permission-log-controller": "2.0.1-preview-fb52b9eb",
  "@metamask-previews/phishing-controller": "9.0.1-preview-fb52b9eb",
  "@metamask-previews/polling-controller": "6.0.1-preview-fb52b9eb",
  "@metamask-previews/preferences-controller": "10.0.0-preview-fb52b9eb",
  "@metamask-previews/queued-request-controller": "0.9.0-preview-fb52b9eb",
  "@metamask-previews/rate-limit-controller": "5.0.1-preview-fb52b9eb",
  "@metamask-previews/selected-network-controller": "12.0.1-preview-fb52b9eb",
  "@metamask-previews/signature-controller": "15.0.0-preview-fb52b9eb",
  "@metamask-previews/transaction-controller": "28.1.0-preview-fb52b9eb",
  "@metamask-previews/user-operation-controller": "8.0.0-preview-fb52b9eb"
}

Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

Fine with me. I was always unsure whether we really needed this kind of fallback long-term. I like to see code removed :)

@matthewwalsh0 matthewwalsh0 merged commit 9349754 into main Apr 27, 2024
139 checks passed
@matthewwalsh0 matthewwalsh0 deleted the feat/remove-fee-history-fallback branch April 27, 2024 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants