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 transfer memo and receiver length check (#2551) #2553

Merged
merged 4 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ Ref: https://keepachangelog.com/en/1.0.0/

## Unreleased

### Bug Fixes

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

### Features

- [2472](https://github.com/umee-network/umee/pull/2472) un-wire the `crisis` module from umee app.
Expand All @@ -66,6 +70,12 @@ Ref: https://keepachangelog.com/en/1.0.0/
- [2473](https://github.com/umee-network/umee/pull/2473) Correct x/ugov Amino registration for x/ugov messages (they don't have MessageName option).
- [2547](https://github.com/umee-network/umee/pull/2547) Fix the `MissCounters` grpc-web get api result.

## v6.5.0

### Bug Fixes

- [2551](https://github.com/umee-network/umee/pull/2551) Restrict length of IBC transfer memo and receiver fields.
robert-zaremba marked this conversation as resolved.
Show resolved Hide resolved

## v6.4.1 - 2024-04-30

### Improvements
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
11 changes: 4 additions & 7 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.

Documentation: [x/auction/README.md](https://github.com/umee-network/umee/blob/v6.5.0/x/auction/README.md)
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.6.0/x/auction/README.md)

### Validators

**Upgrade Title** (for Cosmovisor): **v6.5**.
**Upgrade Title** (for Cosmovisor): **v6.6**.
robert-zaremba marked this conversation as resolved.
Show resolved Hide resolved

Update Price Feeder to `umee/2.4.3+`.

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

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) {
robert-zaremba marked this conversation as resolved.
Show resolved Hide resolved
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)
}
robert-zaremba marked this conversation as resolved.
Show resolved Hide resolved
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")
}
robert-zaremba marked this conversation as resolved.
Show resolved Hide resolved
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
Loading