Skip to content

Commit 5286641

Browse files
feat: disable inflow quota (#2022)
* feat: disable inflow quota * changelog * lint * update ibc e2e test
1 parent 38bb99e commit 5286641

File tree

6 files changed

+33
-19
lines changed

6 files changed

+33
-19
lines changed

CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ the Github PR referenced in the following format:
2222
2323
Types of changes (Stanzas):
2424
25+
State Machine Breaking: for any changes that result in a divergent application state.
2526
Features: for new features.
2627
Improvements: for changes in existing functionality.
2728
Deprecated: for soon-to-be removed features.
2829
Bug Fixes: for any bug fixes.
2930
Client Breaking: for breaking Protobuf, CLI, gRPC and REST routes used by clients.
3031
API Breaking: for breaking exported Go APIs used by developers.
31-
State Machine Breaking: for any changes that result in a divergent application state.
3232
3333
To release a new version, ensure an appropriate release branch exists. Add a
3434
release version and date to the existing Unreleased section which takes the form
@@ -46,7 +46,13 @@ Ref: https://keepachangelog.com/en/1.0.0/
4646

4747
## [Unreleased]
4848

49-
## [v4.3.0](https://github.com/umee-network/umee/releases/tag/v4.3.0) - 2023-04-5
49+
## [v4.4.0](https://github.com/umee-network/umee/releases/tag/v4.3.0) - 2023-05-05
50+
51+
### State Machine Breaking
52+
53+
- [2022](https://github.com/umee-network/umee/pull/2022) Disable IBC ICS-20 inflow of only x/leverage registered tokens.
54+
55+
## [v4.3.0](https://github.com/umee-network/umee/releases/tag/v4.3.0) - 2023-04-05
5056

5157
### Features
5258

tests/e2e/e2e_ibc_test.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ func (s *IntegrationTestSuite) TestIBCTokenTransfer() {
164164
s.checkSupply(gaiaAPIEndpoint, umeeIBCHash, token.Amount)
165165
})
166166

167-
// Non registered tokens (not exists in oracle for quota test)
168-
// IBC Transfer will failed because it is not registered in leverage on receiver chain (UMEE)
167+
// IBC inbound transfer of non x/leverage registered tokens must fail, because
168+
// because we won't have price for it.
169169
s.Run("send_stake_to_umee", func() {
170170
// require the recipient account receives the IBC tokens (IBC packets ACKd)
171171
var (
@@ -186,12 +186,15 @@ func (s *IntegrationTestSuite) TestIBCTokenTransfer() {
186186
func() bool {
187187
balances, err = queryUmeeAllBalances(umeeAPIEndpoint, recipient)
188188
s.Require().NoError(err)
189-
return math.ZeroInt().Equal(balances.AmountOf(stakeIBCHash))
189+
// uncomment whene we re-enable inflow limit
190+
// return math.ZeroInt().Equal(balances.AmountOf(stakeIBCHash))
191+
return token.Amount.Equal(balances.AmountOf(stakeIBCHash))
190192
},
191193
time.Minute,
192194
5*time.Second,
193195
)
194-
s.checkSupply(umeeAPIEndpoint, stakeIBCHash, math.ZeroInt())
196+
// s.checkSupply(umeeAPIEndpoint, stakeIBCHash, math.ZeroInt())
197+
s.checkSupply(umeeAPIEndpoint, stakeIBCHash, token.Amount)
195198
})
196199

197200
var ibcStakeERC20Addr string

x/uibc/ics20/ibc_module.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,12 @@ func (am IBCModule) OnRecvPacket(
4646
}
4747

4848
// Allowing only registered token for ibc transfer
49-
isSourceChain := ibctransfertypes.SenderChainIsSource(packet.GetSourcePort(), packet.GetSourceChannel(), data.Denom)
50-
ackErr := CheckIBCInflow(ctx, packet, am.lkeeper, data.Denom, isSourceChain)
51-
if ackErr != nil {
52-
return ackErr
53-
}
49+
// TODO: re-enable inflow checks
50+
// isSourceChain := ibctransfertypes.SenderChainIsSource(packet.GetSourcePort(), packet.GetSourceChannel(), data.Denom)
51+
// ackErr := CheckIBCInflow(ctx, packet, am.lkeeper, data.Denom, isSourceChain)
52+
// if ackErr != nil {
53+
// return ackErr
54+
// }
5455

5556
ack := am.IBCModule.OnRecvPacket(ctx, packet, relayer)
5657
if ack.Success() {
@@ -79,8 +80,12 @@ func CheckIBCInflow(ctx sdk.Context,
7980
// construct the denomination trace from the full raw denomination and get the ibc_denom
8081
ibcDenom := ibctransfertypes.ParseDenomTrace(prefixedDenom).IBCDenom()
8182
_, err := lkeeper.GetTokenSettings(ctx, ibcDenom)
82-
if err != nil && ltypes.ErrNotRegisteredToken.Is(err) {
83-
return channeltypes.NewErrorAcknowledgement(err)
83+
if err != nil {
84+
if ltypes.ErrNotRegisteredToken.Is(err) {
85+
return channeltypes.NewErrorAcknowledgement(err)
86+
}
87+
// other leverage keeper error -> log the error and allow the inflow transfer.
88+
ctx.Logger().Error("IBC inflows: can't load token registry", "err", err)
8489
}
8590
}
8691

x/uibc/quota/ibc_module.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (im ICS20Middleware) OnAcknowledgementPacket(ctx sdk.Context, packet channe
4848
if _, ok := ack.Response.(*channeltypes.Acknowledgement_Error); ok {
4949
params := im.keeper.GetParams(ctx)
5050
if params.IbcStatus == uibc.IBCTransferStatus_IBC_TRANSFER_STATUS_QUOTA_ENABLED {
51-
err := im.RevertQuotaUpdate(ctx, packet.Data)
51+
err := im.revertQuotaUpdate(ctx, packet.Data)
5252
emitOnRevertQuota(&ctx, "acknowledgement", packet.Data, err)
5353
}
5454
}
@@ -58,14 +58,14 @@ func (im ICS20Middleware) OnAcknowledgementPacket(ctx sdk.Context, packet channe
5858

5959
// OnTimeoutPacket implements types.Middleware
6060
func (im ICS20Middleware) OnTimeoutPacket(ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress) error {
61-
err := im.RevertQuotaUpdate(ctx, packet.Data)
61+
err := im.revertQuotaUpdate(ctx, packet.Data)
6262
emitOnRevertQuota(&ctx, "timeout", packet.Data, err)
6363

6464
return im.IBCModule.OnTimeoutPacket(ctx, packet, relayer)
6565
}
6666

67-
// RevertQuotaUpdate Notifies the contract that a sent packet wasn't properly received
68-
func (im ICS20Middleware) RevertQuotaUpdate(
67+
// revertQuotaUpdate must be called on packet acknnowledgemenet error to revert necessary changes.
68+
func (im ICS20Middleware) revertQuotaUpdate(
6969
ctx sdk.Context,
7070
packetData []byte,
7171
) error {

x/uibc/quota/keeper/ics4_wrapper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
* Implementation of ICS4Wrapper interface
1717
******/
1818

19-
// SendPacket wraps IBC ChannelKeeper's SendPacket function
19+
// SendPacket wraps IBC ChannelKeeper's SendPacket function to record quota outflows.
2020
func (k Keeper) SendPacket(ctx sdk.Context,
2121
chanCap *capabilitytypes.Capability,
2222
sourcePort string,

x/uibc/quota/keeper/quota.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func (k Keeper) ResetAllQuotas(ctx sdk.Context) error {
128128
return nil
129129
}
130130

131-
// CheckAndUpdateQuota checks if adding a newOutflow is doesn't exceed the max quota and
131+
// CheckAndUpdateQuota checks if adding a newOutflow doesn't exceed the max quota and
132132
// updates the current quota metrics.
133133
func (k Keeper) CheckAndUpdateQuota(ctx sdk.Context, denom string, newOutflow sdkmath.Int) error {
134134
params := k.GetParams(ctx)

0 commit comments

Comments
 (0)