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

Hardcoded priority fee causes txs on Polygon to fail #3370

Closed
wschwab opened this issue Sep 19, 2022 · 8 comments
Closed

Hardcoded priority fee causes txs on Polygon to fail #3370

wschwab opened this issue Sep 19, 2022 · 8 comments
Assignees
Labels
investigate Under investigation and may be a bug.

Comments

@wschwab
Copy link

wschwab commented Sep 19, 2022

Ethers Version

5.7.1

Search Terms

priority fee, polygon, gas estimation

Describe the Problem

Ethers currently hardcodes the priority fee, where applicable, at 1.5 gwei: source

This creates a quandary on Polygon's main chain, since there is an enforced minimum 30 gwei priority fee there. (I'm looking for a source I can link, though I have confirmed this with Polygon. Update: I still don't have a link to docs or something like this, but here is an announcement on an official forum.) This is probably why users are experiencing issues submitting txs on Polygon: issue

I wasn't sure if this should be called a feature request or a bug, and opted for bug, since the functionality of gas estimation isn't working as expected on a major chain.

fwiw, hardcoding 30 gwei priority is way too high for Ethereum, but would it possible to make a ternary that checks if network.chainId is 137 (Polygon main), and if not, use 1.5, and if yes, 30? Something like:

maxPriorityFeePerGas = network.chainId !== 137 ? BigNumber.from("1500000000") : BigNumber.from("30000000000");

(I mean that more for illustrative purposes than as actual code.)

Thanks for reading!

Code Snippet

// copied from the issue linked above
// assumes network.chainId === 137

signer.populateTransaction(txParams)
signer.sendTransaction(txParams)

Contract ABI

No response

Errors

\"message\":\"transaction underpriced\"

Environment

Polygon

Environment (Other)

n/a

@wschwab wschwab added the investigate Under investigation and may be a bug. label Sep 19, 2022
@wschwab wschwab changed the title Bug Report Title Hardcoded priority fee causes txs on Polygon to fail Sep 19, 2022
@ZeroEkkusu
Copy link

ZeroEkkusu commented Sep 28, 2022

In case it is helpful for investigation, foundry-rs/foundry#3368 is not merged yet, but it fixes the issue in Foundry/ethers-rs by handling Polygon separately.

@pcaversaccio
Copy link

any update on this issue @ricmoo? It impacts the users for my hardhat plugin xdeployer directly - see the discussion here: pcaversaccio/xdeployer#53.

@ricmoo
Copy link
Member

ricmoo commented Jan 31, 2023

This is a known issue with BSC/Polygon, since they do not correctly implement the EIP-1559 standard.

Unfortunately for those networks, it is necessary to use a gas station (much like Ethereum did prior to EIP-1559). There isn't really a way to get good data (especially during times of congestion) from the blockchain directly.

My best advice would be that someone creates a sub-class of Signer, and overrides the getFeeData method to use a gas station instead. This is one reason why getFeeData is present there. :)

If someone creates a sub-class of Signer, let me know and I'll link to it from the docs. But I don't know there is much that ethers can do directly.

Closing for now, but please feel free to continue commenting. I monitor closed issues. :)

@ricmoo ricmoo closed this as completed Jan 31, 2023
@sambacha
Copy link

This is a known issue with BSC/Polygon, since they do not correctly implement the EIP-1559 standard.

Unfortunately for those networks, it is necessary to use a gas station (much like Ethereum did prior to EIP-1559). There isn't really a way to get good data (especially during times of congestion) from the blockchain directly.

My best advice would be that someone creates a sub-class of Signer, and overrides the getFeeData method to use a gas station instead. This is one reason why getFeeData is present there. :)

If someone creates a sub-class of Signer, let me know and I'll link to it from the docs. But I don't know there is much that ethers can do directly.

Closing for now, but please feel free to continue commenting. I monitor closed issues. :)

What do you think of this approach: Synthetixio/js-monorepo#915

Uses a Moving Avg. for deriving priority fee. Not sure how good the rest of the implementation is for gas pricing though the approach for deriving a priority fee using only block information is portable across chains (YMMV).

Thanks @ricmoo

@ricmoo
Copy link
Member

ricmoo commented Jun 11, 2023

So, I think you need to use a gas station to get accurate pricing information. If there is an official gas station or you can get polygon in touch with me, I’ve considered making a custom Network for Polygon, which would support a gas station for gas pricing. :)

@ricmoo
Copy link
Member

ricmoo commented Jun 11, 2023

(Oh, and it only affects networks like Polygon and BNB; other networks which capitalize on EIP-1559 economic incentives already work out of the box ;))

@pcaversaccio
Copy link

So, I think you need to use a gas station to get accurate pricing information. If there is an official gas station or you can get polygon in touch with me, I’ve considered making a custom Network for Polygon, which would support a gas station for gas pricing. :)

@wschwab is from Polygon ;)

@wschwab
Copy link
Author

wschwab commented Jun 19, 2023

@ricmoo I'd be happy to help however I can

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.
Projects
None yet
Development

No branches or pull requests

5 participants