Skip to content

Commit

Permalink
fix: ibc transfer memo and receiver length check (#2551)
Browse files Browse the repository at this point in the history
  • Loading branch information
gsk967 authored and robert-zaremba committed Jun 18, 2024
1 parent a748e05 commit 26173a9
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 17 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ Ref: https://keepachangelog.com/en/1.0.0/

# Changelog

## Unreleased
## v6.5.0

### Bug Fixes

- [2551](https://github.com/umee-network/umee/pull/2551) Restrict length of IBC transfer memo and receiver fields.

### Features

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ See [Release procedure](CONTRIBUTING.md#release-procedure) for more information
| v6.3.x || v0.47.7+ | v7.3.1 | --- | umee/v2.3.0+ | --- | v1.5.0 |
| v6.4.x | x | v0.47.10+ | v7.3.2 | --- | umee/v2.4.1+ | --- | v1.5.2 |
| v6.5.x | x | v0.47.11+ | v7.5.1 | --- | umee/v2.4.3+ | --- | v1.5.2 |
| v6.6.x | x | v0.47.11+ | v7.5.1 | --- | umee/v2.4.3+ | --- | v1.5.2 |

#### Price Feeder

Expand Down
9 changes: 3 additions & 6 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

The Release Procedure is defined in the [CONTRIBUTING](CONTRIBUTING.md#release-procedure) document.

## v6.5.0
## v6.6.0

Highlights:

Expand All @@ -18,15 +18,12 @@ Highlights:

### Auction module

We propose a new Cosmos SDK module, that will provide mechanism for protocol owned auctions.

UX Chain will now auction a portion of collected fees and introduce a token burning mechanism, unlocking a way to a potentially deflationary UX token.

We propose a new Cosmos SDK module, that will provide mechanism for protocol owned auctions. UX Chain will now auction a portion of collected fees and introduce a token burning mechanism, unlocking a way to a potentially deflationary UX token.
Documentation: [x/auction/README.md](https://github.com/umee-network/umee/blob/v6.5.0/x/auction/README.md)

### Validators

**Upgrade Title** (for Cosmovisor): **v6.5**.
**Upgrade Title** (for Cosmovisor): **v6.6**.

Update Price Feeder to `umee/2.4.3+`.

Expand Down
9 changes: 5 additions & 4 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ func (app UmeeApp) RegisterUpgradeHandlers() {
app.registerUpgrade6_0(upgradeInfo)
app.registerOutdatedPlaceholderUpgrade("v6.1")
app.registerOutdatedPlaceholderUpgrade("v6.2")
app.registerUpgrade("v6.3", upgradeInfo, nil, nil, nil)
app.registerUpgrade("v6.3", upgradeInfo)
app.registerUpgrade6_4(upgradeInfo)
app.registerUpgrade("v6.5", upgradeInfo)

app.registerUpgrade6_5(upgradeInfo)
app.registerUpgrade6_6(upgradeInfo)
}

func (app *UmeeApp) registerUpgrade6_5(upgradeInfo upgradetypes.Plan) {
planName := "v6.5"
func (app *UmeeApp) registerUpgrade6_6(upgradeInfo upgradetypes.Plan) {
planName := "v6.6"

app.UpgradeKeeper.SetUpgradeHandler(planName,
func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/e2e_ibc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
appparams "github.com/umee-network/umee/v6/app/params"
setup "github.com/umee-network/umee/v6/tests/e2e/setup"
"github.com/umee-network/umee/v6/tests/grpc"
"github.com/umee-network/umee/v6/tests/tsdk"
"github.com/umee-network/umee/v6/util/coin"
ibcutil "github.com/umee-network/umee/v6/util/ibc"
"github.com/umee-network/umee/v6/util/sdkutil"
"github.com/umee-network/umee/v6/x/uibc"
)

Expand Down Expand Up @@ -166,9 +166,9 @@ func (s *E2ETest) TestIBCTokenTransfer() {
// supply don't change
s.checkSupply(gaiaAPIEndpoint, umeeIBCHash, math.ZeroInt())

// << Recevier Addr = maximum length + 1
// << Receiver Addr = maximum length + 1
// send $110 UMEE from umee to gaia (token_quota is 100$)
recvAddr := sdkutil.GenerateString(ibcutil.MaximumMemoLength + 1)
recvAddr := tsdk.GenerateString(ibcutil.MaximumMemoLength + 1)
s.SendIBC(s.Chain.ID, setup.GaiaChainID, recvAddr, exceedUmee, true, "", "")
// check the ibc (umee) quota after ibc txs - this one should have failed
// supply don't change
Expand Down
13 changes: 13 additions & 0 deletions tests/tsdk/string.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package tsdk

import "math/rand"

func GenerateString(length uint) string {
// character set used for generating a random string in GenerateString
charset := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
bytes := make([]byte, length)
for i := range bytes {
bytes[i] = charset[rand.Intn(len(charset))] //nolint
}
return string(bytes)
}
15 changes: 15 additions & 0 deletions tests/tsdk/string_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package tsdk_test

import (
"testing"

"github.com/umee-network/umee/v6/tests/tsdk"
"gotest.tools/v3/assert"
)

// TestGenerateString checks the randomness and length properties of the generated string.
func TestGenerateString(t *testing.T) {
length := 10
str := tsdk.GenerateString(uint(length))
assert.Equal(t, len(str), length, "Generated string length should match the input length")
}
12 changes: 9 additions & 3 deletions util/ibc/ibc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/cometbft/cometbft/crypto"
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
"github.com/umee-network/umee/v6/util/sdkutil"
"github.com/umee-network/umee/v6/tests/tsdk"
"gotest.tools/v3/assert"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -35,15 +35,21 @@ func TestGetFundsFromPacket(t *testing.T) {
assert.Equal(t, famount.String(), amount)

// invalid address
data.Receiver = sdkutil.GenerateString(MaximumReceiverLength + 1)
data.Receiver = tsdk.GenerateString(MaximumReceiverLength + 1)
_, _, err = GetFundsFromPacket(data.GetBytes())
assert.ErrorContains(t, err, "recipient address must not exceed")

// invalid memo
data.Receiver = AddressFromString("a4")
data.Memo = sdkutil.GenerateString(MaximumMemoLength + 1)
data.Memo = tsdk.GenerateString(MaximumMemoLength + 1)
_, _, err = GetFundsFromPacket(data.GetBytes())
assert.ErrorContains(t, err, "memo must not exceed")

// valid address and memo
data.Receiver = tsdk.GenerateString(MaximumReceiverLength)
data.Memo = tsdk.GenerateString(MaximumMemoLength)
_, _, err = GetFundsFromPacket(data.GetBytes())
assert.NilError(t, err, "Should handle valid inputs without error")
}

func TestGetLocalDenom(t *testing.T) {
Expand Down

0 comments on commit 26173a9

Please sign in to comment.