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

Removing polygon gas station #4670

Closed
tornadocontrib opened this issue Mar 29, 2024 · 9 comments
Closed

Removing polygon gas station #4670

tornadocontrib opened this issue Mar 29, 2024 · 9 comments
Assignees
Labels
investigate Under investigation and may be a bug. v6 Issues regarding v6

Comments

@tornadocontrib
Copy link

Ethers Version

latest

Search Terms

No response

Describe the Problem

Have experienced numerous times of the polygon gas station API not responding or blocked and considering that we now have maxPriorityGas opted in we should be removing it and rely on the node data instead of the centralized API

Also related: #4320

Code Snippet

No response

Contract ABI

No response

Errors

No response

Environment

No response

Environment (Other)

No response

@tornadocontrib tornadocontrib added investigate Under investigation and may be a bug. v6 Issues regarding v6 labels Mar 29, 2024
@ricmoo
Copy link
Member

ricmoo commented Apr 10, 2024

I'm all for this, but can I get some feedback from Polygon (or do you work with Polygon)?

That change was co-ordinated with them directly... Trying to find the Telegram conversation to forward this issue to them for further comment...

@ricmoo ricmoo added the on-deck This Enhancement or Bug is currently being worked on. label Apr 10, 2024
@tornadocontrib
Copy link
Author

@ricmoo Reasons to remove their API endpoint is that 1. EIP-1559 works without centralized gas oracle API 2. Their API endpoint has blocked Tor endpoints which makes my wallet implementation useless on Tor. 3. Their API is slower than public polygon nodes. So we could move forward to remove the endpoint it would be great and thus we can remove another centralized resources being relied by ethers.js.

@ricmoo
Copy link
Member

ricmoo commented Apr 10, 2024

The reason it was added though is because the Polygon implementation of EIP-1559 doesn’t operate like the Ethereum network; the base fee doesn’t float with the protocol defined value (I believe in an attempt to keep fees low), so the priority fee is used to mimic the classic fee market, which is why the price oracle was added (again, at their request ;)).

As a result transactions would consistently fail during network congestion.

If this has changed though, I’d be thrilled to remove it. I’ve reached out to them and sent a link to this issue for comment. ;)

You can of course experiment with no price oracle by creating the Network instance sans the oracle plug-in, which will behave exactly like a standard EIP-1559 network, but unless there have been protocol changes, I suspect transactions will fail during times the priority fee is under turmoil…

@ricmoo
Copy link
Member

ricmoo commented Apr 10, 2024

Here is the original issue with some additional context.

@tornadocontrib
Copy link
Author

@ricmoo Ah I think I would end up running my own gas station API do you know how to replace the existing network plugins maybe initing new Network object would be the only answer?

@tornadocontrib
Copy link
Author

You can of course experiment with no price oracle by creating the Network instance sans the oracle plug-in, which will behave exactly like a standard EIP-1559 network, but unless there have been protocol changes, I suspect transactions will fail during times the priority fee is under turmoil…

Ah you already told me here thank you.

@ricmoo
Copy link
Member

ricmoo commented Apr 11, 2024

This should get you started for your own custom implementation of a Gas Station:

import { FetchUrlFeeDataNetworkPlugin } from "ethers";

const customFeeDataPlugin = new FetchUrlFeeDataNetworkPlugin("https://my-gas-station.com", (defaultFunc, provider, request) => {
  // An example

  // Get the standard values that would otherwise be returned without this plugin
  let { gasPrice, maxFeePerGas, maxPriorityFeePerGas } = await defaultFunc();

  // If your URL returns { maxPriorityFee }
  maxPriorityFee =  BigInt((await request.send()).maxPriorityFee);

  // Return the fee data
  return { gasPrice, maxFeePerGas, maxPriorityFeePerGas };
});

const network = new Network(name, chainId);
network.attachPlugin(customFeeDataPlugin);

// Now you can use this network object in a Provider; and if your network is static (the underlying
// network cannot change), enable those optimizations
const provider = new JsonRpcProvider(url, network, { staticNetwork: network });

@tornadocontrib
Copy link
Author

tornadocontrib commented Apr 12, 2024

@ricmoo Ended up coding an operating an on-chain mirror of the gas station myself which could be retrieved from any running polygon nodes without being blocked by cloudflare

https://polygonscan.com/address/0xf81a8d8d3581985d3969fe53bfa67074adfa8f3c#readContract

https://github.com/tornadocontrib/gas-price-oracle/blob/main/example/index.ts#L43

Using multicalls it is even much faster than before as well

Generally inspired by the Chainlink's on chain oracle btw https://data.chain.link/feeds/ethereum/mainnet/fast-gas-gwei.

Updates for every 25% gas price change or in 2 hour basis.

I think we should keep following the spirit of the decentralization though.

@ricmoo
Copy link
Member

ricmoo commented Apr 12, 2024

That’s a cool idea. You should reach out to Polygon and see if they would incorporate it (and possible manage the oracle themselves) into their official tool chain. :)

@ricmoo ricmoo removed the on-deck This Enhancement or Bug is currently being worked on. label Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigate Under investigation and may be a bug. v6 Issues regarding v6
Projects
None yet
Development

No branches or pull requests

2 participants