-
-
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
Ethers still tries to estimate gas even when passing manual gasLimit #2603
Comments
The automatic gasLimit population is only performed for send transactions, and your method is a call (as it is a That error means the call is reverting, although I agree, it’s weird it would mention unpredictable gas. |
This should be fixed now, as the error checking spelunks through the object looking for the component that has both a |
This breaks my test code for catching call exceptions, which was working with
|
@nataouze That was a bug; a call should never through a call exception (in ethers v5; in v6 it comes back as a CALL_EXCEPTION Error with a data property); it is always supposed to return the data the node sent back, but due to changes in the error format some backends were breaking that. But against Geth that should not have happened, for example. To detect an error was thrown by a contract, the canonical way is to check the length of the bytes returned; if it is congruent to 0 mod 32 then it is not an error and if it is congruent to 4 mod 32 then it is an error, with the first 4 bytes as the selector. Your tests should have received a lot of false negatives in the previous version of ethers? Does that make sense? |
@ricmoo I am not totally clear on what you describe. I didn't get false negatives in the past. For context, I am using hardhat evm (hardhat@2.9.2). My tests are using waffle, in this case the matcher |
Thanks for the fix @ricmoo. I've (finally) verified it -- see NomicFoundation/hardhat#2248 (comment) |
Describe the bug
I'm trying to call a contract method with an unpredictable gas limit, however if I try to call it and pass the
gasLimit
manually I get get a "Error: cannot estimate gas; transaction may fail or may require manual gas limit" error.Maybe I'm missing something but shouldn't ethers skip estimating gas if it's passed manually?
Reproduction steps
You can test with the following contract in rinkeby:
Result
Environment:
Node: v14.17.4
This happens in both node and browser environments.
Search Terms
gas limit, estimate gas
The text was updated successfully, but these errors were encountered: