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

Ethers Makes Unnecessary getGasPrice Request in populateTransaction Method for Legacy Transactions #4940

Open
IvanKodak opened this issue Feb 6, 2025 · 3 comments
Assignees
Labels
investigate Under investigation and may be a bug. v6 Issues regarding v6

Comments

@IvanKodak
Copy link

Ethers Version

6.13.5

Search Terms

populateTransaction

Describe the Problem

Hello,

I noticed that Ethers requests the gas price in the populateTransaction method even when it is already provided in the arguments.

Could you please review the code snippet I attached? I think need to add a check similar to the EIP-1559 transaction scenario: if feeData is provided through function arguments, the request for it should be skipped.

Code Snippet

if ((pop.type === 2 || pop.type == null) && (pop.maxFeePerGas != null && pop.maxPriorityFeePerGas != null)) {
            // Fully-formed EIP-1559 transaction (skip getFeeData)
            pop.type = 2;

        } else if (pop.type === 0 || pop.type === 1) {
            // Explicit Legacy or EIP-2930 transaction

            // We need to get fee data to determine things
            const feeData = await provider.getFeeData();

            assert(feeData.gasPrice != null, "network does not support gasPrice", "UNSUPPORTED_OPERATION", {
                operation: "getGasPrice" });

            // Populate missing gasPrice
            if (pop.gasPrice == null) { pop.gasPrice = feeData.gasPrice; }

        }

Contract ABI

Errors

Environment

No response

Environment (Other)

No response

@IvanKodak IvanKodak added investigate Under investigation and may be a bug. v6 Issues regarding v6 labels Feb 6, 2025
@ricmoo
Copy link
Member

ricmoo commented Feb 6, 2025

Off the top of my head, this sounds fair. I’ll look into it tomorrow for the upcoming minor release. :)

@IvanKodak
Copy link
Author

Off the top of my head, this sounds fair. I’ll look into it tomorrow for the upcoming minor release. :)

Thanks

@tornadocontrib
Copy link

Happy to watch someone else pointing out the issue #4687, hope the polygon support could be also fixed as the polygon oracle formula is also somewhat similar with default maxPriorityFeePerGas ( both oracle and rpc method uses eth_feeHistory inside ) #4909

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

3 participants