diff --git a/CHANGELOG.md b/CHANGELOG.md index ca989ff242..041ac626c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,6 +66,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.4.1 - 2024-04-30 + +### Improvements + +- [daef10a](https://github.com/umee-network/umee/commit/daef10ad4f774aae915ad33f4ab1134695146785) Update dependencies. + ## v6.4.0 - 2024-03-21 ### Features diff --git a/docs/VALIDATOR.md b/docs/VALIDATOR.md index 1b8820056c..d042ad95d2 100644 --- a/docs/VALIDATOR.md +++ b/docs/VALIDATOR.md @@ -84,8 +84,8 @@ Here are our testnet public endpoints: 1. Make sure you firstly tested your setup on Testnet. 2. Use one of the community snapshots: - * [Polkachu](https://polkachu.com/tendermint_snapshots/umee). - * [Autostake](https://autostake.com/networks/umee/#services). + - [Polkachu](https://polkachu.com/tendermint_snapshots/umee). + - [Autostake](https://autostake.com/networks/umee/#services). 3. Buy `uumee` to self delegate. 4. Make sure your Price Feeder is running correctly. If your [mainnet window misses](https://price-feeder.com/) are above 50% then something is wrong. Look for a help on Discord. diff --git a/go.mod b/go.mod index 13eef73935..4bff587ccf 100644 --- a/go.mod +++ b/go.mod @@ -164,6 +164,7 @@ require ( github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae // indirect github.com/mtibben/percent v0.2.1 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect + github.com/onsi/gomega v1.31.1 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0-rc2 // indirect github.com/opencontainers/runc v1.1.5 // indirect diff --git a/tests/e2e/e2e_ibc_test.go b/tests/e2e/e2e_ibc_test.go index 6246dc69a9..f70320f494 100644 --- a/tests/e2e/e2e_ibc_test.go +++ b/tests/e2e/e2e_ibc_test.go @@ -12,6 +12,8 @@ import ( setup "github.com/umee-network/umee/v6/tests/e2e/setup" "github.com/umee-network/umee/v6/tests/grpc" "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" ) @@ -164,6 +166,14 @@ func (s *E2ETest) TestIBCTokenTransfer() { // supply don't change s.checkSupply(gaiaAPIEndpoint, umeeIBCHash, math.ZeroInt()) + // << Recevier Addr = maximum length + 1 + // send $110 UMEE from umee to gaia (token_quota is 100$) + recvAddr := sdkutil.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 + s.checkSupply(gaiaAPIEndpoint, umeeIBCHash, math.ZeroInt()) + // send $110 ATOM from umee to gaia exceedAtom := mulCoin(atomQuota, "1.1") // supply will be not be decreased because sending amount is more than token quota so it will fail diff --git a/tests/e2e/setup/utils.go b/tests/e2e/setup/utils.go index d86c59c5b9..6332195f5d 100644 --- a/tests/e2e/setup/utils.go +++ b/tests/e2e/setup/utils.go @@ -142,10 +142,14 @@ func (s *E2ETestSuite) SendIBC(srcChainID, dstChainID, recipient string, token s if i < 4 { continue } - s.Require().Failf("failed to find transaction hash in output outBuf: %s errBuf: %s", outBuf.String(), errBuf.String()) + if !strings.Contains(outBuf.String(), "bad packet in rate limit's SendPacket") { + s.Require().Failf("failed to find transaction hash in output outBuf: %s errBuf: %s", + outBuf.String(), errBuf.String()) + } } - // s.Require().NotEmptyf(txHash, "failed to find transaction hash in output outBuf: %s errBuf: %s", outBuf.String(), errBuf.String()) + // s.Require().NotEmptyf(txHash, "failed to find transaction hash in output outBuf: %s + // errBuf: %s", outBuf.String(), errBuf.String()) // endpoint := s.UmeeREST() // if strings.Contains(srcChainID, "gaia") { // endpoint = s.GaiaREST() diff --git a/util/ibc/ibc.go b/util/ibc/ibc.go index 6c393ade3d..20bd2463f2 100644 --- a/util/ibc/ibc.go +++ b/util/ibc/ibc.go @@ -2,13 +2,33 @@ package ibc import ( "encoding/json" + "fmt" "strings" sdkmath "cosmossdk.io/math" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" + ibcerrors "github.com/cosmos/ibc-go/v7/modules/core/errors" ) +const ( + MaximumReceiverLength = 2048 // maximum length of the receiver address in bytes (value chosen arbitrarily) + MaximumMemoLength = 32768 // maximum length of the memo in bytes (value chosen arbitrarily) +) + +func ValidateRecvAddr(receiver string) error { + if len(receiver) > MaximumReceiverLength { + return ibcerrors.ErrInvalidAddress.Wrapf("recipient address must not exceed %d bytes", MaximumReceiverLength) + } + return nil +} + +func ValidateMemo(memo string) error { + if len(memo) > MaximumMemoLength { + return fmt.Errorf("memo must not exceed %d bytes", MaximumMemoLength) + } + return nil +} + // GetFundsFromPacket returns transfer amount and denom func GetFundsFromPacket(data []byte) (sdkmath.Int, string, error) { var packetData transfertypes.FungibleTokenPacketData @@ -17,9 +37,17 @@ func GetFundsFromPacket(data []byte) (sdkmath.Int, string, error) { return sdkmath.Int{}, "", err } + if err := ValidateRecvAddr(packetData.Receiver); err != nil { + return sdkmath.Int{}, "", err + } + + if err := ValidateMemo(packetData.Memo); err != nil { + return sdkmath.Int{}, "", err + } + amount, ok := sdkmath.NewIntFromString(packetData.Amount) if !ok { - return sdkmath.Int{}, "", sdkerrors.ErrInvalidRequest.Wrapf("invalid transfer amount %s", packetData.Amount) + return sdkmath.Int{}, "", ibcerrors.ErrInvalidRequest.Wrapf("invalid transfer amount %s", packetData.Amount) } return amount, GetLocalDenom(packetData.Denom), nil diff --git a/util/ibc/ibc_test.go b/util/ibc/ibc_test.go index 31575de31e..a6a810ea31 100644 --- a/util/ibc/ibc_test.go +++ b/util/ibc/ibc_test.go @@ -7,6 +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" "gotest.tools/v3/assert" sdk "github.com/cosmos/cosmos-sdk/types" @@ -32,6 +33,17 @@ func TestGetFundsFromPacket(t *testing.T) { assert.NilError(t, err) assert.Equal(t, denom, fdenom) assert.Equal(t, famount.String(), amount) + + // invalid address + data.Receiver = sdkutil.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) + _, _, err = GetFundsFromPacket(data.GetBytes()) + assert.ErrorContains(t, err, "memo must not exceed") } func TestGetLocalDenom(t *testing.T) { diff --git a/util/sdkutil/string.go b/util/sdkutil/string.go index 2bd831cd0b..e7f52bfc3d 100644 --- a/util/sdkutil/string.go +++ b/util/sdkutil/string.go @@ -2,6 +2,7 @@ package sdkutil import ( "fmt" + "math/rand" "strings" sdk "github.com/cosmos/cosmos-sdk/types" @@ -30,3 +31,13 @@ func FormatDec(d sdk.Dec) string { func FormatDecCoin(c sdk.DecCoin) string { return fmt.Sprintf("%s %s", FormatDec(c.Amount), c.Denom) } + +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) +}