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

eth_gasEstimate invalid params error on Kovan network via Infura provider #1795

Closed
robertmagier opened this issue Jul 22, 2021 · 4 comments
Closed
Labels
bug Verified to be an issue. duplicate Duplicate of another issue.

Comments

@robertmagier
Copy link

Describe the bug

eth_estimategas function will return invalid params error when running on Infura Kovan network. This happen when calling a Smart Contract function without specifying gas limit. I think it is an error because transaction is not reverting and will complete successfully when gas limit is provided.

This is kovan tx for which gas estimate is failing: Kovan Etherscan

Error message returned from Infura:

(node:23402) UnhandledPromiseRejectionWarning: Error: cannot estimate gas; transaction may fail or may require manual gas limit (error={"reason":"processing response error","code":"SERVER_ERROR","body":"{\"jsonrpc\":\"2.0\",\"id\":88,\"error\":{\"code\":-32602,\"message\":\"Invalid params\"}}","error":{"code":-32602},"requestBody":"{\"method\":\"eth_estimateGas\",\"params\":[{\"gasPrice\":\"0x165a0bc00\",\"type\":\"0x0\",\"from\":\"0x06f0462a9694c96e6c727797b8737b94b3ff5df4\",\"to\":\"0x6f652a2ec26bb3aaefae6fa9d18c9c5d3288e4d1\",\"data\":\"0x3209e9e60000000000000000000000000000000000000000000000000853a0d2313c0000\"}],\"id\":88,\"jsonrpc\":\"2.0\"}","requestMethod":"POST","url":"https://kovan.infura.io/v3/24ef6eb261d244fe8418a4c0dd3a8765"}, tx={"data":"0x3209e9e60000000000000000000000000000000000000000000000000853a0d2313c0000","to":{},"from":"0x06F0462a9694C96E6c727797B8737B94b3ff5dF4","gasPrice":{"type":"BigNumber","hex":"0x0165a0bc00"},"type":0,"nonce":{},"gasLimit":{},"chainId":{}}, code=UNPREDICTABLE_GAS_LIMIT, version=abstract-signer/5.4.0)
    at Logger.makeError (/home/robertmagier/projects/DJE/CoinFlip/node_modules/@ethersproject/logger/lib/index.js:187:21)
    at Logger.throwError (/home/robertmagier/projects/DJE/CoinFlip/node_modules/@ethersproject/logger/lib/index.js:196:20)
    at /home/robertmagier/projects/DJE/CoinFlip/node_modules/@ethersproject/abstract-signer/lib/index.js:353:47
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Promise.all (index 6)

I tried exactly same scenario on rinkeby and it works without problems, eth_gasestimate works fine.

Ethers version 5.4.1

@robertmagier robertmagier added the investigate Under investigation and may be a bug. label Jul 22, 2021
@MatheusDaros
Copy link

I am having the same problem with a private chain.

@zemse
Copy link
Collaborator

zemse commented Jul 25, 2021

Yes this is a problem, it's due to the type: 0 included. Seems infura is not happy with it.

await new ethers.providers.InfuraProvider('kovan').estimateGas({
  from: ethers.constants.AddressZero, 
  to: ethers.constants.AddressZero, 
  type: 0 // if this is excluded then the query works
})

Edit: even alchemy doesn't like that. type: 0 is also not accepted in an eth_call.

@NIC619
Copy link

NIC619 commented Jul 26, 2021

I think this is due to Kovan not upgraded to Berlin so it can not recognize the type param in transaction.

@ricmoo
Copy link
Member

ricmoo commented Jul 30, 2021

Oh yes. Sorry, I did not tag this issue in the fix. Please check out #1766 for more details.

You are absolutely correct, the issue was missing Berlin support. The JsonRpcProvider now detects non-eip-1559 networks and drops the type of is is 0.

This was addressed in 5.4.3.

I’ll close this issue and let the other issue handle any issues people have. I’ll close that ticket in a few days after people have had a chance to complain. :)

@ricmoo ricmoo closed this as completed Jul 30, 2021
@ricmoo ricmoo added bug Verified to be an issue. duplicate Duplicate of another issue. and removed investigate Under investigation and may be a bug. labels Jul 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified to be an issue. duplicate Duplicate of another issue.
Projects
None yet
Development

No branches or pull requests

5 participants