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

Fallbacks for Polygon/Mumbai gas stations #4320

Open
vaivanov opened this issue Aug 16, 2023 · 8 comments
Open

Fallbacks for Polygon/Mumbai gas stations #4320

vaivanov opened this issue Aug 16, 2023 · 8 comments
Assignees
Labels
v6 Issues regarding v6

Comments

@vaivanov
Copy link

Ethers Version

6.7.1

Search Terms

gas, gas station, EIP-1559

Describe the Problem

When I'm trying to call getFeeData on Polygon Mumbai network and gas station doesn't work well at the moment (in example, https://gasstation-testnet.polygon.technology/v2 returns 503 error), I'm getting error "Error: error encountered with polygon gas station". I suggest to implement fallback for this case, or make getGasStationPlugin connection configurable for Polygon based networks.

Code Snippet

import { JsonRpcProvider } from 'ethers'

const provider = new JsonRpcProvider('https://rpc.ankr.com/polygon_mumbai');

await provider.getFeeData();

Contract ABI

No response

Errors

Error: error encountered with polygon gas station ("https://gasstation-testnet.polygon.technology/v2") (request={  }, response={  }, error={ "code": "UNSUPPORTED_OPERATION", "info": { "response": {  } }, "operation": "bodyJson" }, code=SERVER_ERROR, version=6.7.1)
    at makeError (/app/node_modules/ethers/lib.commonjs/utils/errors.js:125:21)
    at assert (/app/node_modules/ethers/lib.commonjs/utils/errors.js:142:15)
    at FetchUrlFeeDataNetworkPlugin.<anonymous> (/app/node_modules/ethers/lib.commonjs/providers/network.js:290:35)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async JsonRpcProvider.getFeeData (/app/node_modules/ethers/lib.commonjs/providers/abstract-provider.js:609:29)
....

Environment

Other (please specify)

Environment (Other)

Polygon, Mumbai

@vaivanov vaivanov added investigate Under investigation and may be a bug. v6 Issues regarding v6 labels Aug 16, 2023
@mohitvdx
Copy link

https://gasstation-testnet.polygon.technology/v2 works well now.
What fallback do you want to be added?

@vaivanov
Copy link
Author

vaivanov commented Aug 22, 2023

Hello,

This API serves as a centralized resource which may experience intermittent downtime. Upon reviewing my backend logs, I observed that the success rate was only 97% at the time of opening this issue. It's worth noting that the GasStation API shouldn't be a requirement for transaction execution. We can obtain information about the expected maxPriorityFeePerGas and maxFeePerGas directly from the network, just as it functions on other chains.

However, a challenge arises when the gas station encounters downtime or delivers rate-limited responses, preventing me from accurately estimating the gas required for transactions.

I propose the following solutions:

  • Implement a fallback mechanism to retrieve maxPriorityFeePerGas and maxFeePerGas from the network in situations where the gas station is unavailable and returns incorrect responses.
  • Make the connection of this plugin configurable. This would enable me to either disable the GasStation API or employ my own gas estimation solution.

Your understanding and consideration of these suggestions would be greatly appreciated.

Thank you.

@victoryeo
Copy link

We are using etherjsv6. We are also seeing the same gas station error on polygon network. This is a showstopper and needs to be fixed.

@vaivanov
Copy link
Author

vaivanov commented Feb 6, 2024

image

Error: error encountered with polygon gas station ("https://gasstation.polygon.technology/v2") (request={ }, response={ }, error={ "code": "UNSUPPORTED_OPERATION", "info": { "response": { } }, "operation": "bodyJson" }, code=SERVER_ERROR, version=6.7.1)

@ricmoo
Copy link
Member

ricmoo commented Feb 6, 2024

If the Polygon Gas Station is down, there isn’t really a reliable way to get the gas price other than running your own gas station of finding another public gas station.

@ricmoo
Copy link
Member

ricmoo commented Feb 6, 2024

(if you upgrade to the latest version, the error will contain more info on the error from the server)

@MatevzKlancar
Copy link

why does this api always return the same values for different variables? safeLow, standard and fast are always the same, for example:
{"safeLow":{"maxPriorityFee":30,"maxFee":30.000000911},"standard":{"maxPriorityFee":30,"maxFee":30.000000911},"fast":{"maxPriorityFee":30,"maxFee":30.000000911},"estimatedBaseFee":9.11e-7,"blockTime":2,"blockNumber":58464645}

@ricmoo
Copy link
Member

ricmoo commented Jun 22, 2024

@MatevzKlancar You will have to ask the Polygon team about that. I’m hoping someday this logic is built into the actual nodes though, so we don’t need to rely on gas station services…

@ricmoo ricmoo removed the investigate Under investigation and may be a bug. label Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v6 Issues regarding v6
Projects
None yet
Development

No branches or pull requests

5 participants