-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
sendTransaction throws too much gas on contract to contract transactions. #316
Comments
I do indeed block gasLimit on constant calls, but you are right, perhaps I shouldn’t? Although it really shouldn’t be necessary. Maybe I’ll pull the gasEstimate for constant calls. The reason this never happened on v3 though, is because v3 always hard-coded the gasLimit to 1.5 million, which led to lots of other issues (e.g “insufficient funds”, if you had enough for 1.3 million gas, and were calling a contract that would only require 34,000). Your problem is certainly caused by estimateGas returning too high a value; for some reason it has guessed your tax will fail. Is there any reason the function might throw? Maybe the from or value is not being forwarded properly? Can you post the function code? Also, which provider is it using? |
I think the true problem lies with geth, that it calculates more gas than actually needed. That being said perhaps if estimateGas errors it should let gas use the default which would be the block gas limit of the pending block. In reference to the JSON-RPC documentation:
I'm sure the calls don't exceed the block gas limit. I'm using the jsonRpcProvider with our own clique POA chain. The genesis is configured to have a block gas limit of 16 million even.
which calls (I've even commented the require statement to make sure)
|
Here on my project, sometimes the transaction works and sometimes the transaction fail with |
Experiencing the same issue, sending a TX that usually sets 85548 and uses 42774 yet I'm getting an estimation error of over 7 mil |
I think this issue is stale, and has been addressed in v5 by allowing the gasLimit to be overridden. If not though, please re-open. Thanks! :) |
Hi , It's me again possibly with a real issue this time. 😄
In my contract I have functions that call external contracts, these should work fine. I don't have any issues with ethers v3 using these contracts in my client app.
My deploy script (from my previous issue) uses ethers v4, and whenever I call such a function I get an error from estimateGas inside sendTransaction:
If I then add a gasLimit it works, so my guess is estimateGas is calculating the transaction to use inifinite gas:
//This works! await controller.setOrganisationController(ethers.utils.formatBytes32String('DiD'), '0x'+controllerProfile, {gasPrice: '0x0', gasLimit: ethers.utils.hexlify(8000000)})
Additionally on calls to constant functions that work the same way I'm getting call exceptions:
Here I can not add a gasLimit, because I can't override the gasLimit for calls.
This getter for example works perfect
console.log(await controller.admins(wallet.address))
I haven't had this issue with these contracts with ethers 3.0.0 before.
I want to check if it is perhaps my blockchain config (which I doubt , because it works with truffle migrations thought) but when trying to use ganache with my ethersjs deploy script I'm getting:
The text was updated successfully, but these errors were encountered: