Skip to content
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

fix: ibc quota check enabled #1913

Merged
merged 14 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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