-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve out of gas error log (#3874)
* Add additional information for out of gas error * Add guide entry for troubleshooting gas errors * Add changelog entry * Apply suggestions from code review Co-authored-by: Romain Ruetschi <romain@informal.systems> Signed-off-by: Luca Joss <43531661+ljoss17@users.noreply.github.com> --------- Signed-off-by: Luca Joss <43531661+ljoss17@users.noreply.github.com> Co-authored-by: Romain Ruetschi <romain@informal.systems>
- Loading branch information
Showing
7 changed files
with
113 additions
and
28 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
.changelog/unreleased/improvements/ibc-relayer/3530-out-of-gas-error-log.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- Improve the log diagnostic when an out of gas error is thrown. | ||
And a new entry related to gas error has been added to the Hermes | ||
guide. | ||
([\#3530](https://github.com/informalsystems/hermes/issues/3530)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Gas errors | ||
|
||
This section will expand on the out of gas error which can happen when simulating or sending Txs. The related configurations are: | ||
|
||
```toml | ||
default_gas = 100000 | ||
max_gas = 4000000 | ||
gas_multiplier = 1.1 | ||
``` | ||
|
||
Before sending a transaction, Hermes will retrieve an estimation of the gas required with the simulation capability of the chain. After retrieving the gas amount from the simulation, the `gas_multiplier` will be applied since the simulation might be slightly lower than the required amount of gas. | ||
Since the `max_gas` is applied after the gas_multiplier, it can happen that the value `simulated_gas * gas_multiplier > max_gas`, in which case the `max_gas` value is used. | ||
|
||
Note that if the simulation fails with a recoverable error, Hermes will use the configured `default_gas`. | ||
|
||
## Simulating Tx | ||
|
||
The first instance where an error can happen is when the tracasction simulation succeeds but the gas amount retrieved exceeds the configured `max_gas`, Hermes will throw an unrecoverable error: | ||
|
||
``` | ||
<chain> gas estimate <simulated_gas> from simulated Tx exceeds the maximum configured <max_gas> | ||
``` | ||
|
||
This can be fixed by increasing the configured `max_gas`. | ||
|
||
## Broadcasting Tx | ||
|
||
> __NOTE__: This issue will only arise with Cosmos chains as this is a Cosmos SDK error. | ||
The second instance when an error can happen is when sending the transaction. If the gas included for the transaction is not enough Hermes will throw an error: | ||
|
||
``` | ||
out of gas in location: <location>; gasWanted: <max gas Hermes>, gasUsed: <gas wanted>: out of gas | ||
``` | ||
|
||
Two cases need to be verified in order to fix this issue. | ||
|
||
### Caused by max_gas | ||
|
||
If simulated gas is close to the `max_gas` configured, after multiplying the value with the `gas_multiplier`, it can be the case that the `max_gas` is used instead. And since the simulated gas might be slightly lower than the required gas, this can cause an out of gas error. | ||
This can be fixed by increasing the configured `max_gas`. | ||
|
||
### Caused by default_gas | ||
|
||
When the transaction simulation fails with a recoverable error, the `default_gas` will be used. If the `default_gas` is too low an out of gas error will be thrown. This can be fixed by increasing the `default_gas`. | ||
But there can also be a case similar to the one explained in the previous section [Caused by max_gas](./gas-errors.md#caused-by-max_gas). | ||
|
||
If the `default_gas` is too close to the `max_gas`, the `max_gas` will be used instead of `default_gas * gas_multiplier`, causing an out of gas error. In this situation both `max_gas` and `default_gas` need to be verified, and one or both need to be increased. |