Skip to content

Commit

Permalink
fix(network): out of gas issue when approving many request (#3114)
Browse files Browse the repository at this point in the history
* add gas auto

* comment

* use constant

* changelog

* minor lint fix

Co-authored-by: aljo242 <[email protected]>
  • Loading branch information
lumtis and aljo242 authored Nov 18, 2022
1 parent 73124ac commit 552b25f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

### Fixes


- [#3114](https://github.com/ignite/cli/pull/3114) Fix out of gas issue when approving many requests
- [#3068](https://github.com/ignite/cli/pull/3068) Fix REST codegen method casing bug
- [#3031](https://github.com/ignite/cli/pull/3031) Move keeper hooks to after all keepers initialized in `app.go`
template.
Expand Down
1 change: 1 addition & 0 deletions ignite/cmd/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ func getNetworkCosmosClient(cmd *cobra.Command) (cosmosclient.Client, error) {
cosmosclient.WithUseFaucet(spnFaucetAddress, networktypes.SPNDenom, 5),
cosmosclient.WithKeyringServiceName(cosmosaccount.KeyringServiceName),
cosmosclient.WithKeyringDir(getKeyringDir(cmd)),
cosmosclient.WithGas(cosmosclient.GasAuto),
}

keyringBackend := getKeyringBackend(cmd)
Expand Down
7 changes: 5 additions & 2 deletions ignite/pkg/cosmosclient/cosmosclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ var (
)

const (
// GasAuto allows to calculate gas automatically when sending transaction
GasAuto = "auto"

defaultNodeAddress = "http://localhost:26657"
defaultGasAdjustment = 1.0
defaultGasLimit = 300000
Expand Down Expand Up @@ -560,7 +563,7 @@ func (c Client) CreateTx(goCtx context.Context, account cosmosaccount.Account, m
}

var gas uint64
if c.gas != "" && c.gas != "auto" {
if c.gas != "" && c.gas != GasAuto {
gas, err = strconv.ParseUint(c.gas, 10, 64)
if err != nil {
return TxService{}, errors.WithStack(err)
Expand All @@ -571,7 +574,7 @@ func (c Client) CreateTx(goCtx context.Context, account cosmosaccount.Account, m
return TxService{}, errors.WithStack(err)
}
// the simulated gas can vary from the actual gas needed for a real transaction
// we add an additional amount to ensure sufficient gas is provided
// we add an amount to ensure sufficient gas is provided
gas += 20000
}
txf = txf.WithGas(gas)
Expand Down

0 comments on commit 552b25f

Please sign in to comment.