Skip to content

Commit

Permalink
fix: ibc quota check enabled (#1913)
Browse files Browse the repository at this point in the history
* fix: checking quota if ibc quota check enabled

* chore: remove status check on timeout

* chore: address the pr comment
  • Loading branch information
gsk967 committed Apr 4, 2023
1 parent b36d784 commit 4826437
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 5 additions & 2 deletions x/uibc/quota/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ func (im IBCMiddleware) OnAcknowledgementPacket(ctx sdk.Context, packet channelt
return errors.Wrap(err, "cannot unmarshal ICS-20 transfer packet acknowledgement")
}
if _, ok := ack.Response.(*channeltypes.Acknowledgement_Error); ok {
err := im.RevertQuotaUpdate(ctx, packet.Data)
emitOnRevertQuota(&ctx, "acknowledgement", packet.Data, err)
params := im.keeper.GetParams(ctx)
if params.IbcStatus == uibc.IBCTransferStatus_IBC_TRANSFER_STATUS_QUOTA_ENABLED {
err := im.RevertQuotaUpdate(ctx, packet.Data)
emitOnRevertQuota(&ctx, "acknowledgement", packet.Data, err)
}
}

return im.IBCModule.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer)
Expand Down
8 changes: 6 additions & 2 deletions x/uibc/quota/keeper/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types"
ibcexported "github.com/cosmos/ibc-go/v6/modules/core/exported"
"github.com/umee-network/umee/v4/x/uibc"

ibcutil "github.com/umee-network/umee/v4/util/ibc"
)
Expand All @@ -24,8 +25,11 @@ func (k Keeper) SendPacket(ctx sdk.Context,
return 0, errors.Wrap(err, "bad packet in rate limit's SendPacket")
}

if err := k.CheckAndUpdateQuota(ctx, denom, funds); err != nil {
return 0, errors.Wrap(err, "bad packet in rate limit's SendPacket")
params := k.GetParams(ctx)
if params.IbcStatus == uibc.IBCTransferStatus_IBC_TRANSFER_STATUS_QUOTA_ENABLED {
if err := k.CheckAndUpdateQuota(ctx, denom, funds); err != nil {
return 0, errors.Wrap(err, "SendPacket over the IBC Quota")
}
}

return k.ics4Wrapper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data)
Expand Down

0 comments on commit 4826437

Please sign in to comment.