Skip to content

Commit

Permalink
Problem: simulate gas is less than required with feegrants (#1364)
Browse files Browse the repository at this point in the history
* Problem: simulate gas is less than require with feegrants

* Update CHANGELOG.md
  • Loading branch information
mmsqe authored Dec 18, 2023
1 parent cfe8b93 commit 523748e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* [\#1324](https://github.com/cosmos/relayer/pull/1324) Add log-level in global config.
* [\#1325](https://github.com/cosmos/relayer/pull/1325) Ignore only file not exist error when loadConfigFile.
* [\#1326](https://github.com/cosmos/relayer/pull/1326) Avoid sending channel close confirm message after channel get closed successfully.
* [\#1364](https://github.com/cosmos/relayer/pull/1364) Include feegrant message when calculate gas.

## v0.9.3

Expand Down
20 changes: 10 additions & 10 deletions relayer/chains/cosmos/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,16 +621,6 @@ func (cc *CosmosProvider) buildMessages(
txf = txf.WithSequence(sequence)
}

adjusted := gas

if gas == 0 {
_, adjusted, err = cc.CalculateGas(ctx, txf, txSignerKey, cMsgs...)

if err != nil {
return nil, 0, sdk.Coins{}, err
}
}

//Cannot feegrant your own TX
if txSignerKey != feegranterKey && feegranterKey != "" {
granterAddr, err := cc.GetKeyAddressForKey(feegranterKey)
Expand All @@ -641,6 +631,16 @@ func (cc *CosmosProvider) buildMessages(
txf = txf.WithFeeGranter(granterAddr)
}

adjusted := gas

if gas == 0 {
_, adjusted, err = cc.CalculateGas(ctx, txf, txSignerKey, cMsgs...)

if err != nil {
return nil, 0, sdk.Coins{}, err
}
}

// Set the gas amount on the transaction factory
txf = txf.WithGas(adjusted)

Expand Down

0 comments on commit 523748e

Please sign in to comment.