From ae4fd98a7ff099a475151c1599e1e356580bd3ea Mon Sep 17 00:00:00 2001 From: Du Nguyen Date: Thu, 8 Sep 2022 09:41:27 +0700 Subject: [PATCH 01/24] add length validation of receiver address in msg transfer --- go.mod | 2 +- modules/apps/transfer/types/errors.go | 1 + modules/apps/transfer/types/msgs.go | 10 ++++++++++ modules/apps/transfer/types/msgs_test.go | 18 ++++++++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 2f009fc0f62..9952201890b 100644 --- a/go.mod +++ b/go.mod @@ -12,6 +12,7 @@ require ( github.com/golang/protobuf v1.5.2 github.com/gorilla/mux v1.8.0 github.com/grpc-ecosystem/grpc-gateway v1.16.0 + github.com/pkg/errors v0.9.1 github.com/rakyll/statik v0.1.7 github.com/spf13/cast v1.5.0 github.com/spf13/cobra v1.6.1 @@ -115,7 +116,6 @@ require ( github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.0.5 // indirect github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect - github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_golang v1.12.2 // indirect github.com/prometheus/client_model v0.2.0 // indirect diff --git a/modules/apps/transfer/types/errors.go b/modules/apps/transfer/types/errors.go index 0f0cb7c42a4..6bd8f5d71fd 100644 --- a/modules/apps/transfer/types/errors.go +++ b/modules/apps/transfer/types/errors.go @@ -14,4 +14,5 @@ var ( ErrSendDisabled = sdkerrors.Register(ModuleName, 7, "fungible token transfers from this chain are disabled") ErrReceiveDisabled = sdkerrors.Register(ModuleName, 8, "fungible token transfers to this chain are disabled") ErrMaxTransferChannels = sdkerrors.Register(ModuleName, 9, "max transfer channels") + // ErrMaxReceiverAddressLength = sdkerrors.Register(ModuleName, 10, "receiver address exceeds maximum length") ) diff --git a/modules/apps/transfer/types/msgs.go b/modules/apps/transfer/types/msgs.go index 9746237ef52..c5b5a78b861 100644 --- a/modules/apps/transfer/types/msgs.go +++ b/modules/apps/transfer/types/msgs.go @@ -5,11 +5,18 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/pkg/errors" clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types" host "github.com/cosmos/ibc-go/v6/modules/core/24-host" ) +// msg types +const ( + TypeMsgTransfer = "transfer" + MaximumReceiverAddress = 128 // maximum length of the receiver address in bytes +) + // NewMsgTransfer creates a new MsgTransfer instance // //nolint:interfacer @@ -47,6 +54,9 @@ func (msg MsgTransfer) ValidateBasic() error { if err := host.ChannelIdentifierValidator(msg.SourceChannel); err != nil { return sdkerrors.Wrap(err, "invalid source channel ID") } + if len(msg.Receiver) > MaximumReceiverAddress { + return errors.Errorf("receiver addresss exceeds maximum length") + } if !msg.Token.IsValid() { return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, msg.Token.String()) } diff --git a/modules/apps/transfer/types/msgs_test.go b/modules/apps/transfer/types/msgs_test.go index 970528c6251..5f55560ed9b 100644 --- a/modules/apps/transfer/types/msgs_test.go +++ b/modules/apps/transfer/types/msgs_test.go @@ -57,6 +57,24 @@ func TestMsgTransferGetSignBytes(t *testing.T) { // TestMsgTransferValidation tests ValidateBasic for MsgTransfer func TestMsgTransferValidation(t *testing.T) { + invalidReceiverAddress := `1234567890 + 1234567890 + 1234567890 + 1234567890 + 1234567890 + 1234567890 + 1234567890 + 1234567890 + 1234567890 + 1234567890 + 1234567890 + 1234567890 + 1234567890 + 1234567890 + 1234567890 + 1234567890 + 1234567890` + testCases := []struct { name string msg *MsgTransfer From d0fa335281599cf0db3e1efb42af7c2b28d2121a Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Fri, 6 Jan 2023 23:57:42 +0700 Subject: [PATCH 02/24] fix test. Next will add a test case that ensures that >2kb is rejected. --- modules/apps/transfer/types/msgs_test.go | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/modules/apps/transfer/types/msgs_test.go b/modules/apps/transfer/types/msgs_test.go index 5f55560ed9b..970528c6251 100644 --- a/modules/apps/transfer/types/msgs_test.go +++ b/modules/apps/transfer/types/msgs_test.go @@ -57,24 +57,6 @@ func TestMsgTransferGetSignBytes(t *testing.T) { // TestMsgTransferValidation tests ValidateBasic for MsgTransfer func TestMsgTransferValidation(t *testing.T) { - invalidReceiverAddress := `1234567890 - 1234567890 - 1234567890 - 1234567890 - 1234567890 - 1234567890 - 1234567890 - 1234567890 - 1234567890 - 1234567890 - 1234567890 - 1234567890 - 1234567890 - 1234567890 - 1234567890 - 1234567890 - 1234567890` - testCases := []struct { name string msg *MsgTransfer From ced226a858064ffcf9b5fa56a8edcb6418d06796 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Sat, 7 Jan 2023 00:00:01 +0700 Subject: [PATCH 03/24] correct length of receiver address --- modules/apps/transfer/types/msgs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/apps/transfer/types/msgs.go b/modules/apps/transfer/types/msgs.go index c5b5a78b861..d917ec2ca76 100644 --- a/modules/apps/transfer/types/msgs.go +++ b/modules/apps/transfer/types/msgs.go @@ -14,7 +14,7 @@ import ( // msg types const ( TypeMsgTransfer = "transfer" - MaximumReceiverAddress = 128 // maximum length of the receiver address in bytes + MaximumReceiverAddress = 2048 // maximum length of the receiver address in bytes ) // NewMsgTransfer creates a new MsgTransfer instance From e7ada1b3ed32d59fc76b1a19cbab417297e6ffcb Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Tue, 3 Oct 2023 16:12:03 +0300 Subject: [PATCH 04/24] lint --- modules/apps/transfer/types/msgs.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/apps/transfer/types/msgs.go b/modules/apps/transfer/types/msgs.go index f7a2b60929d..4a951a4ffb4 100644 --- a/modules/apps/transfer/types/msgs.go +++ b/modules/apps/transfer/types/msgs.go @@ -3,10 +3,11 @@ package types import ( "strings" + "github.com/pkg/errors" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/pkg/errors" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" host "github.com/cosmos/ibc-go/v8/modules/core/24-host" From 3d360332c7a8e88c8bf604cbd2fa86b598874edc Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Tue, 3 Oct 2023 16:50:44 +0300 Subject: [PATCH 05/24] tidy --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 5514bf6b472..a604d198f37 100644 --- a/go.mod +++ b/go.mod @@ -26,6 +26,7 @@ require ( github.com/golang/protobuf v1.5.3 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/hashicorp/go-metrics v0.5.1 + github.com/pkg/errors v0.9.1 github.com/spf13/cast v1.5.1 github.com/spf13/cobra v1.7.0 github.com/spf13/viper v1.16.0 @@ -146,7 +147,6 @@ require ( github.com/oklog/run v1.1.0 // indirect github.com/pelletier/go-toml/v2 v2.0.9 // indirect github.com/petermattis/goid v0.0.0-20230518223814-80aa455d8761 // indirect - github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_golang v1.16.0 // indirect github.com/prometheus/client_model v0.4.0 // indirect From 19690246c63f230178e5716315bbf426b1df3b48 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Sun, 15 Oct 2023 23:32:16 +0200 Subject: [PATCH 06/24] remove unused const / add test for recipient address length check --- modules/apps/transfer/types/msgs.go | 14 ++++---------- modules/apps/transfer/types/msgs_test.go | 1 + 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/modules/apps/transfer/types/msgs.go b/modules/apps/transfer/types/msgs.go index 4a951a4ffb4..8241dc5c0c1 100644 --- a/modules/apps/transfer/types/msgs.go +++ b/modules/apps/transfer/types/msgs.go @@ -3,8 +3,6 @@ package types import ( "strings" - "github.com/pkg/errors" - errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" @@ -14,11 +12,7 @@ import ( ibcerrors "github.com/cosmos/ibc-go/v8/modules/core/errors" ) -// msg types -const ( - TypeMsgTransfer = "transfer" - MaximumReceiverAddress = 2048 // maximum length of the receiver address in bytes -) +const MaximumReceiverAddress = 2048 // maximum length of the receiver address in bytes var ( _ sdk.Msg = (*MsgUpdateParams)(nil) @@ -85,9 +79,6 @@ func (msg MsgTransfer) ValidateBasic() error { if err := host.ChannelIdentifierValidator(msg.SourceChannel); err != nil { return errorsmod.Wrap(err, "invalid source channel ID") } - if len(msg.Receiver) > MaximumReceiverAddress { - return errors.Errorf("receiver addresss exceeds maximum length") - } if !msg.Token.IsValid() { return errorsmod.Wrap(ibcerrors.ErrInvalidCoins, msg.Token.String()) } @@ -102,6 +93,9 @@ func (msg MsgTransfer) ValidateBasic() error { if strings.TrimSpace(msg.Receiver) == "" { return errorsmod.Wrap(ibcerrors.ErrInvalidAddress, "missing recipient address") } + if len(msg.Receiver) > MaximumReceiverAddress { + return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "recipient addresss cannot exceed %d bytes", MaximumReceiverAddress) + } return ValidateIBCDenom(msg.Token.Denom) } diff --git a/modules/apps/transfer/types/msgs_test.go b/modules/apps/transfer/types/msgs_test.go index 3afae766edb..7aeccaf9eb4 100644 --- a/modules/apps/transfer/types/msgs_test.go +++ b/modules/apps/transfer/types/msgs_test.go @@ -65,6 +65,7 @@ func TestMsgTransferValidation(t *testing.T) { {"zero coin", types.NewMsgTransfer(validPort, validChannel, zeroCoin, sender, receiver, timeoutHeight, 0, ""), false}, {"missing sender address", types.NewMsgTransfer(validPort, validChannel, coin, emptyAddr, receiver, timeoutHeight, 0, ""), false}, {"missing recipient address", types.NewMsgTransfer(validPort, validChannel, coin, sender, "", timeoutHeight, 0, ""), false}, + {"too long recipient address", types.NewMsgTransfer(validPort, validChannel, coin, sender, "7146fd910a6340deec3e02ab18071d6501f6f4c824138064a39e6406861f32aa4d6cb9837890e266526bba749d7bbdaecb2d8074d45f23271cf42a5169b259b3f40d16a60b792fb0c44631321bb42f6a8ed4c7ac948c556f0dcfad771c6d2c7dfd0281afaf583edd6e6d0aca06170907a429033fa2c20c95b655659af2f1defdab8a9d5bff3420e560ddedb235282370ce7f1211859d3a42f9428c65d38d6d1dfb111b81e777e731988e1f6326dc48ca05c2afcfa1578f123d4b88f3fa8b19980e2a3a844205d4a1a8784f21c614a19cf9bdd21f477681dfb42e6417ad53a8a48a07e77fd2116cc78e7c6f817ca8676ed039806816a74c5648e6b2261f415deac4947b56c23062eb06a3ccf9de95083e7b52cbe058b2e9ddb42f983df24bd4750ed185fb49235a7ac965624870a90c0fe081b46f1b077d6b27a2be2a74c41c1505194e583e15e3174d33b892571b40f8cffa02831fdce8c2fa0429fcfdb3c4d691f7bc4049e12d2fdc63af0d4bf504e6135f361b5dccc235b1da862292c77d1f9232970b71d10208644a971787df4bbb98618e60c008d5ef86a68994277ac6f09937d85b62b6b95d49af1832d94f0cb74ee2f29bce9b49078da897db747dcb981bba4e074f2da7be4eee0d452c72d8bf33c43ca5b35f6cdd382a8c8852c2d308d3a6cfb7da6ad09515b18b734b942f3c8c73668f12bc3385e8651b1e2e9c474d2f2aa9e9e05f6ec66a9dffb16e62c03b94c68ca692500d5200512d1e6806abfca18dbf1812de659409b8f08ec9188c44423966ad8652a84deb8f875390ea18682f41694a630cfc277be93d13ddafb35d4bb2e31193858f5f0c03525788182300cdd910cd97afc2072735d2bddc73f0a68b7416a345e85291535c239fa8a1064c2a610b822fe1b9372a3e73581644274d7bb739f3005485348302fd7582978e5c9bdb5eec9fd34ba3e951cb1a54cdb5d4ac84b7d489d449143fc3caa7406e143759d3359f6614d03387386a17e6798d9022d8f394b50b03144954504b6561659adb176aa92d6a3eb90d442e45157d41dac5eec8828fcedc007abbe4e635b1fc6093f7baf83ced16599044b9b017511dc0a8815f25e68afdb0cc8788027616e51167ec2186e0098497b662ce16540cb4110a3d29fa07d81e7771c4ce1ef8fec018d622aee2be98e1a7331df43c1e88eff7cf4315ee763c081d9c2ca5e2d13df6a7271113f2ebb6b8153b1fe3c95ea2bc11a5d06b5a24a44747e71bb52cbabb213edb9f9cc3e8389cd642fd3c1feedbf81877142ac2f19ae5d76cb9d8b0129af1171f284ac86f78061544468229b6747231c331ebdd4c5e2b5e78edd5a5f1844a7d492f05e5b5d4b408eb48e72f16d32390e3a499ed6257d098f0a687cabbf4535052a7472271adac900175ce3b9ea3bea07c8341144a7b5f23ed8e868f56f8edce884b0a350", timeoutHeight, 0, ""), false}, {"empty coin", types.NewMsgTransfer(validPort, validChannel, sdk.Coin{}, sender, receiver, timeoutHeight, 0, ""), false}, } From 4b6c2cd0c1fc129b37ede21fb2ace3922de2b75e Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Sun, 15 Oct 2023 23:36:44 +0200 Subject: [PATCH 07/24] go mod tidy --- go.mod | 1 - 1 file changed, 1 deletion(-) diff --git a/go.mod b/go.mod index 63b12771ece..5d0c4ad234f 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,6 @@ require ( github.com/golang/protobuf v1.5.3 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/hashicorp/go-metrics v0.5.1 - github.com/pkg/errors v0.9.1 github.com/spf13/cast v1.5.1 github.com/spf13/cobra v1.7.0 github.com/spf13/viper v1.17.0 From fb527d6606d89a98b67ab8d72861398d0fcb9910 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Sun, 15 Oct 2023 23:40:55 +0200 Subject: [PATCH 08/24] Update msgs.go --- modules/apps/transfer/types/msgs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/apps/transfer/types/msgs.go b/modules/apps/transfer/types/msgs.go index 8241dc5c0c1..814793c73be 100644 --- a/modules/apps/transfer/types/msgs.go +++ b/modules/apps/transfer/types/msgs.go @@ -94,7 +94,7 @@ func (msg MsgTransfer) ValidateBasic() error { return errorsmod.Wrap(ibcerrors.ErrInvalidAddress, "missing recipient address") } if len(msg.Receiver) > MaximumReceiverAddress { - return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "recipient addresss cannot exceed %d bytes", MaximumReceiverAddress) + return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "recipient addresss must not exceed %d bytes", MaximumReceiverAddress) } return ValidateIBCDenom(msg.Token.Denom) } From 22815aa7a8c8e883433a91250db76774daa6afae Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Sun, 15 Oct 2023 23:56:53 +0200 Subject: [PATCH 09/24] change value of long string constant (might need to change it still) --- testing/values.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/values.go b/testing/values.go index 2741b1a5fed..519b337704e 100644 --- a/testing/values.go +++ b/testing/values.go @@ -43,7 +43,7 @@ const ( Title = "title" Description = "description" - LongString = "LoremipsumdolorsitameconsecteturadipiscingeliseddoeiusmodtemporincididuntutlaboreetdoloremagnaaliquUtenimadminimveniamquisnostrudexercitationullamcolaborisnisiutaliquipexeacommodoconsequDuisauteiruredolorinreprehenderitinvoluptateelitsseillumoloreufugiatnullaariaturEcepteurintoccaectupidatatonroidentuntnulpauifficiaeseruntmollitanimidestlaborum" + LongString = "LoremipsumdolorsitameconsecteturadipiscingeliseddoeiusmodtemporincididuntutlaboreetdoloremagnaaliquUtenimadminimveniamquisnostrudexercitationullamcolaborisnisiutaliquipexeacommodoconsequDuisauteiruredolorinreprehenderitinvoluptateelitsseillumoloreufugiatnullaariaturEcepteurintoccaectupidatatonroidentuntnulpauifficiaeseruntmollitanimidestlaborumLoremipsumdolorsitameconsecteturadipiscingeliseddoeiusmodtemporincididuntutlaboreetdoloremagnaaliquUtenimadminimveniamquisnostrudexercitationullamcolaborisnisiutaliquipexeacommodoconsequDuisauteiruredolorinreprehenderitinvoluptateelitsseillumoloreufugiatnullaariaturEcepteurintoccaectupidatatonroidentuntnulpauifficiaeseruntmollitanimidestlaborumLoremipsumdolorsitameconsecteturadipiscingeliseddoeiusmodtemporincididuntutlaboreetdoloremagnaaliquUtenimadminimveniamquisnostrudexercitationullamcolaborisnisiutaliquipexeacommodoconsequDuisauteiruredolorinreprehenderitinvoluptateelitsseillumoloreufugiatnullaariaturEcepteurintoccaectupidatatonroidentuntnulpauifficiaeseruntmollitanimidestlaborumLoremipsumdolorsitameconsecteturadipiscingeliseddoeiusmodtemporincididuntutlaboreetdoloremagnaaliquUtenimadminimveniamquisnostrudexercitationullamcolaborisnisiutaliquipexeacommodoconsequDuisauteiruredolorinreprehenderitinvoluptateelitsseillumoloreufugiatnullaariaturEcepteurintoccaectupidatatonroidentuntnulpauifficiaeseruntmollitanimidestlaborumLoremipsumdolorsitameconsecteturadipiscingeliseddoeiusmodtemporincididuntutlaboreetdoloremagnaaliquUtenimadminimveniamquisnostrudexercitationullamcolaborisnisiutaliquipexeacommodoconsequDuisauteiruredolorinreprehenderitinvoluptateelitsseillumoloreufugiatnullaariaturEcepteurintoccaectupidatatonroidentuntnulpauifficiaeseruntmollitanimidestlaborumLoremipsumdolorsitameconsecteturadipiscingeliseddoeiusmodtemporincididuntutlaboreetdoloremagnaaliquUtenimadminimveniamquisnostrudexercitationullamcolaborisnisiutaliquipexeacommodoconsequDuisauteiruredolorinreprehenderitinvoluptateelitsseillumoloreufugiatnullaariaturEcepteurintoccaectupidatatonroidentuntnulpauifficiaes" ) var ( From 0e1e1e09ee270224f1d933041c66d6c00ce25d2c Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Mon, 16 Oct 2023 00:01:32 +0200 Subject: [PATCH 10/24] rename variable --- modules/apps/transfer/types/msgs.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/apps/transfer/types/msgs.go b/modules/apps/transfer/types/msgs.go index 814793c73be..7c76b3858d4 100644 --- a/modules/apps/transfer/types/msgs.go +++ b/modules/apps/transfer/types/msgs.go @@ -12,7 +12,7 @@ import ( ibcerrors "github.com/cosmos/ibc-go/v8/modules/core/errors" ) -const MaximumReceiverAddress = 2048 // maximum length of the receiver address in bytes +const MaximumReceiverLength = 2048 // maximum length of the receiver address in bytes var ( _ sdk.Msg = (*MsgUpdateParams)(nil) @@ -93,8 +93,8 @@ func (msg MsgTransfer) ValidateBasic() error { if strings.TrimSpace(msg.Receiver) == "" { return errorsmod.Wrap(ibcerrors.ErrInvalidAddress, "missing recipient address") } - if len(msg.Receiver) > MaximumReceiverAddress { - return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "recipient addresss must not exceed %d bytes", MaximumReceiverAddress) + if len(msg.Receiver) > MaximumReceiverLength { + return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "recipient addresss must not exceed %d bytes", MaximumReceiverLength) } return ValidateIBCDenom(msg.Token.Denom) } From 4987dcd8f65b5460368c9d348b858590f7d855f9 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Mon, 16 Oct 2023 00:02:51 +0200 Subject: [PATCH 11/24] use testing value --- modules/apps/transfer/types/msgs_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/apps/transfer/types/msgs_test.go b/modules/apps/transfer/types/msgs_test.go index 7aeccaf9eb4..de288dbda0a 100644 --- a/modules/apps/transfer/types/msgs_test.go +++ b/modules/apps/transfer/types/msgs_test.go @@ -65,7 +65,7 @@ func TestMsgTransferValidation(t *testing.T) { {"zero coin", types.NewMsgTransfer(validPort, validChannel, zeroCoin, sender, receiver, timeoutHeight, 0, ""), false}, {"missing sender address", types.NewMsgTransfer(validPort, validChannel, coin, emptyAddr, receiver, timeoutHeight, 0, ""), false}, {"missing recipient address", types.NewMsgTransfer(validPort, validChannel, coin, sender, "", timeoutHeight, 0, ""), false}, - {"too long recipient address", types.NewMsgTransfer(validPort, validChannel, coin, sender, "7146fd910a6340deec3e02ab18071d6501f6f4c824138064a39e6406861f32aa4d6cb9837890e266526bba749d7bbdaecb2d8074d45f23271cf42a5169b259b3f40d16a60b792fb0c44631321bb42f6a8ed4c7ac948c556f0dcfad771c6d2c7dfd0281afaf583edd6e6d0aca06170907a429033fa2c20c95b655659af2f1defdab8a9d5bff3420e560ddedb235282370ce7f1211859d3a42f9428c65d38d6d1dfb111b81e777e731988e1f6326dc48ca05c2afcfa1578f123d4b88f3fa8b19980e2a3a844205d4a1a8784f21c614a19cf9bdd21f477681dfb42e6417ad53a8a48a07e77fd2116cc78e7c6f817ca8676ed039806816a74c5648e6b2261f415deac4947b56c23062eb06a3ccf9de95083e7b52cbe058b2e9ddb42f983df24bd4750ed185fb49235a7ac965624870a90c0fe081b46f1b077d6b27a2be2a74c41c1505194e583e15e3174d33b892571b40f8cffa02831fdce8c2fa0429fcfdb3c4d691f7bc4049e12d2fdc63af0d4bf504e6135f361b5dccc235b1da862292c77d1f9232970b71d10208644a971787df4bbb98618e60c008d5ef86a68994277ac6f09937d85b62b6b95d49af1832d94f0cb74ee2f29bce9b49078da897db747dcb981bba4e074f2da7be4eee0d452c72d8bf33c43ca5b35f6cdd382a8c8852c2d308d3a6cfb7da6ad09515b18b734b942f3c8c73668f12bc3385e8651b1e2e9c474d2f2aa9e9e05f6ec66a9dffb16e62c03b94c68ca692500d5200512d1e6806abfca18dbf1812de659409b8f08ec9188c44423966ad8652a84deb8f875390ea18682f41694a630cfc277be93d13ddafb35d4bb2e31193858f5f0c03525788182300cdd910cd97afc2072735d2bddc73f0a68b7416a345e85291535c239fa8a1064c2a610b822fe1b9372a3e73581644274d7bb739f3005485348302fd7582978e5c9bdb5eec9fd34ba3e951cb1a54cdb5d4ac84b7d489d449143fc3caa7406e143759d3359f6614d03387386a17e6798d9022d8f394b50b03144954504b6561659adb176aa92d6a3eb90d442e45157d41dac5eec8828fcedc007abbe4e635b1fc6093f7baf83ced16599044b9b017511dc0a8815f25e68afdb0cc8788027616e51167ec2186e0098497b662ce16540cb4110a3d29fa07d81e7771c4ce1ef8fec018d622aee2be98e1a7331df43c1e88eff7cf4315ee763c081d9c2ca5e2d13df6a7271113f2ebb6b8153b1fe3c95ea2bc11a5d06b5a24a44747e71bb52cbabb213edb9f9cc3e8389cd642fd3c1feedbf81877142ac2f19ae5d76cb9d8b0129af1171f284ac86f78061544468229b6747231c331ebdd4c5e2b5e78edd5a5f1844a7d492f05e5b5d4b408eb48e72f16d32390e3a499ed6257d098f0a687cabbf4535052a7472271adac900175ce3b9ea3bea07c8341144a7b5f23ed8e868f56f8edce884b0a350", timeoutHeight, 0, ""), false}, + {"too long recipient address", types.NewMsgTransfer(validPort, validChannel, coin, sender, ibctesting.LongString, timeoutHeight, 0, ""), false}, {"empty coin", types.NewMsgTransfer(validPort, validChannel, sdk.Coin{}, sender, receiver, timeoutHeight, 0, ""), false}, } From cc41f7d80a7860d40686fa94a97276af278141a7 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Mon, 16 Oct 2023 13:00:18 +0200 Subject: [PATCH 12/24] add function to generate random string of a given length --- .../apps/27-interchain-accounts/types/account_test.go | 2 +- testing/utils.go | 10 ++++++++++ testing/values.go | 3 ++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/modules/apps/27-interchain-accounts/types/account_test.go b/modules/apps/27-interchain-accounts/types/account_test.go index 2130a46edf4..9ff7dc19841 100644 --- a/modules/apps/27-interchain-accounts/types/account_test.go +++ b/modules/apps/27-interchain-accounts/types/account_test.go @@ -79,7 +79,7 @@ func (suite *TypesTestSuite) TestValidateAccountAddress() { }, { "address is too long", - ibctesting.LongString, + ibctesting.GenerateString(uint(types.DefaultMaxAddrLength) + 1), false, }, } diff --git a/testing/utils.go b/testing/utils.go index 302d0e70822..332940608e1 100644 --- a/testing/utils.go +++ b/testing/utils.go @@ -1,6 +1,7 @@ package ibctesting import ( + "rand" "testing" "github.com/stretchr/testify/require" @@ -23,3 +24,12 @@ func ApplyValSetChanges(tb testing.TB, valSet *tmtypes.ValidatorSet, valUpdates return newVals } + +// GenerateString generates a random string of the given length in bytes +func GenerateString(length uint) string { + bytes := make([]byte, length) + for i := range bytes { + bytes[i] = charset[rand.Intn(len(charset))] + } + return string(bytes) +} diff --git a/testing/values.go b/testing/values.go index 519b337704e..115f3b39281 100644 --- a/testing/values.go +++ b/testing/values.go @@ -43,7 +43,8 @@ const ( Title = "title" Description = "description" - LongString = "LoremipsumdolorsitameconsecteturadipiscingeliseddoeiusmodtemporincididuntutlaboreetdoloremagnaaliquUtenimadminimveniamquisnostrudexercitationullamcolaborisnisiutaliquipexeacommodoconsequDuisauteiruredolorinreprehenderitinvoluptateelitsseillumoloreufugiatnullaariaturEcepteurintoccaectupidatatonroidentuntnulpauifficiaeseruntmollitanimidestlaborumLoremipsumdolorsitameconsecteturadipiscingeliseddoeiusmodtemporincididuntutlaboreetdoloremagnaaliquUtenimadminimveniamquisnostrudexercitationullamcolaborisnisiutaliquipexeacommodoconsequDuisauteiruredolorinreprehenderitinvoluptateelitsseillumoloreufugiatnullaariaturEcepteurintoccaectupidatatonroidentuntnulpauifficiaeseruntmollitanimidestlaborumLoremipsumdolorsitameconsecteturadipiscingeliseddoeiusmodtemporincididuntutlaboreetdoloremagnaaliquUtenimadminimveniamquisnostrudexercitationullamcolaborisnisiutaliquipexeacommodoconsequDuisauteiruredolorinreprehenderitinvoluptateelitsseillumoloreufugiatnullaariaturEcepteurintoccaectupidatatonroidentuntnulpauifficiaeseruntmollitanimidestlaborumLoremipsumdolorsitameconsecteturadipiscingeliseddoeiusmodtemporincididuntutlaboreetdoloremagnaaliquUtenimadminimveniamquisnostrudexercitationullamcolaborisnisiutaliquipexeacommodoconsequDuisauteiruredolorinreprehenderitinvoluptateelitsseillumoloreufugiatnullaariaturEcepteurintoccaectupidatatonroidentuntnulpauifficiaeseruntmollitanimidestlaborumLoremipsumdolorsitameconsecteturadipiscingeliseddoeiusmodtemporincididuntutlaboreetdoloremagnaaliquUtenimadminimveniamquisnostrudexercitationullamcolaborisnisiutaliquipexeacommodoconsequDuisauteiruredolorinreprehenderitinvoluptateelitsseillumoloreufugiatnullaariaturEcepteurintoccaectupidatatonroidentuntnulpauifficiaeseruntmollitanimidestlaborumLoremipsumdolorsitameconsecteturadipiscingeliseddoeiusmodtemporincididuntutlaboreetdoloremagnaaliquUtenimadminimveniamquisnostrudexercitationullamcolaborisnisiutaliquipexeacommodoconsequDuisauteiruredolorinreprehenderitinvoluptateelitsseillumoloreufugiatnullaariaturEcepteurintoccaectupidatatonroidentuntnulpauifficiaes" + // character set used for generating a random string in GenerateString + charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" ) var ( From 2d34b40112e2731a043090d2ec3b7cb8602ad635 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Mon, 16 Oct 2023 13:14:40 +0200 Subject: [PATCH 13/24] fix package --- testing/utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/utils.go b/testing/utils.go index 332940608e1..a1178929e3f 100644 --- a/testing/utils.go +++ b/testing/utils.go @@ -1,7 +1,7 @@ package ibctesting import ( - "rand" + "math/rand" "testing" "github.com/stretchr/testify/require" From b989064820452a3626f9faf49deb9991da00bdef Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Mon, 16 Oct 2023 13:15:07 +0200 Subject: [PATCH 14/24] fix package --- testing/utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/utils.go b/testing/utils.go index 332940608e1..a1178929e3f 100644 --- a/testing/utils.go +++ b/testing/utils.go @@ -1,7 +1,7 @@ package ibctesting import ( - "rand" + "math/rand" "testing" "github.com/stretchr/testify/require" From e6cb1d59a827640762221c7359642705e73ed508 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Mon, 16 Oct 2023 13:33:26 +0200 Subject: [PATCH 15/24] add check for length of owner in MsgSendTx --- .../apps/27-interchain-accounts/controller/types/msgs.go | 6 ++++++ .../27-interchain-accounts/controller/types/msgs_test.go | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/modules/apps/27-interchain-accounts/controller/types/msgs.go b/modules/apps/27-interchain-accounts/controller/types/msgs.go index b600942bf01..8fbfa8f5489 100644 --- a/modules/apps/27-interchain-accounts/controller/types/msgs.go +++ b/modules/apps/27-interchain-accounts/controller/types/msgs.go @@ -12,6 +12,8 @@ import ( ibcerrors "github.com/cosmos/ibc-go/v8/modules/core/errors" ) +const MaximumOwnerLength = 2048 // maximum length of the owner in bytes + var ( _ sdk.Msg = (*MsgRegisterInterchainAccount)(nil) _ sdk.Msg = (*MsgSendTx)(nil) @@ -74,6 +76,10 @@ func (msg MsgSendTx) ValidateBasic() error { return errorsmod.Wrap(ibcerrors.ErrInvalidAddress, "owner address cannot be empty") } + if len(msg.Owner) > MaximumOwnerLength { + return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "owner addresss must not exceed %d bytes", MaximumOwnerLength) + } + if err := msg.PacketData.ValidateBasic(); err != nil { return errorsmod.Wrap(err, "invalid interchain account packet data") } diff --git a/modules/apps/27-interchain-accounts/controller/types/msgs_test.go b/modules/apps/27-interchain-accounts/controller/types/msgs_test.go index 13ef2c9ae1a..4f8701ce6f5 100644 --- a/modules/apps/27-interchain-accounts/controller/types/msgs_test.go +++ b/modules/apps/27-interchain-accounts/controller/types/msgs_test.go @@ -121,6 +121,13 @@ func TestMsgSendTxValidateBasic(t *testing.T) { }, false, }, + { + "owner address is too long", + func() { + msg.Owner = ibctesting.GenerateString(types.MaximumOwnerLength + 1) + }, + false, + }, { "relative timeout is not set", func() { From fa4296a40ca75d994210cf88aca2208c3e49ff14 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Mon, 16 Oct 2023 14:49:24 +0200 Subject: [PATCH 16/24] add check for length of version and counterparty version in channel handshake messages --- modules/core/04-channel/types/channel.go | 5 +++++ modules/core/04-channel/types/msgs.go | 6 ++++++ modules/core/04-channel/types/msgs_test.go | 6 ++++++ 3 files changed, 17 insertions(+) diff --git a/modules/core/04-channel/types/channel.go b/modules/core/04-channel/types/channel.go index d288a2a8842..ba1da3e8b99 100644 --- a/modules/core/04-channel/types/channel.go +++ b/modules/core/04-channel/types/channel.go @@ -7,6 +7,8 @@ import ( "github.com/cosmos/ibc-go/v8/modules/core/exported" ) +const MaximumVersionLength = 8192 // maximum length of the version in bytes + var ( _ exported.ChannelI = (*Channel)(nil) _ exported.CounterpartyChannelI = (*Counterparty)(nil) @@ -78,6 +80,9 @@ func (ch Channel) ValidateBasic() error { if err := host.ConnectionIdentifierValidator(ch.ConnectionHops[0]); err != nil { return errorsmod.Wrap(err, "invalid connection hop ID") } + if len(ch.Version) > MaximumVersionLength { + return errorsmod.Wrapf(ErrInvalidChannelVersion, "version must not exceed %d bytes", MaximumVersionLength) + } return ch.Counterparty.ValidateBasic() } diff --git a/modules/core/04-channel/types/msgs.go b/modules/core/04-channel/types/msgs.go index 812829307c0..c0cd1159120 100644 --- a/modules/core/04-channel/types/msgs.go +++ b/modules/core/04-channel/types/msgs.go @@ -123,6 +123,9 @@ func (msg MsgChannelOpenTry) ValidateBasic() error { if err := host.ChannelIdentifierValidator(msg.Channel.Counterparty.ChannelId); err != nil { return errorsmod.Wrap(err, "invalid counterparty channel ID") } + if len(msg.CounterpartyVersion) > MaximumVersionLength { + return errorsmod.Wrapf(ErrInvalidChannelVersion, "counterparty version must not exceed %d bytes", MaximumVersionLength) + } _, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { @@ -170,6 +173,9 @@ func (msg MsgChannelOpenAck) ValidateBasic() error { if len(msg.ProofTry) == 0 { return errorsmod.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty try proof") } + if len(msg.CounterpartyVersion) > MaximumVersionLength { + return errorsmod.Wrapf(ErrInvalidChannelVersion, "counterparty version must not exceed %d bytes", MaximumVersionLength) + } _, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) diff --git a/modules/core/04-channel/types/msgs_test.go b/modules/core/04-channel/types/msgs_test.go index 8570ad59065..aa0c47d6c56 100644 --- a/modules/core/04-channel/types/msgs_test.go +++ b/modules/core/04-channel/types/msgs_test.go @@ -18,6 +18,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" + ibctesting "github.com/cosmos/ibc-go/v8/testing" "github.com/cosmos/ibc-go/v8/testing/simapp" ) @@ -125,6 +126,7 @@ func (suite *TypesTestSuite) TestMsgChannelOpenInitValidateBasic() { {"too short connection id", types.NewMsgChannelOpenInit(portid, version, types.UNORDERED, invalidShortConnHops, cpportid, addr), false}, {"too long connection id", types.NewMsgChannelOpenInit(portid, version, types.UNORDERED, invalidLongConnHops, cpportid, addr), false}, {"connection id contains non-alpha", types.NewMsgChannelOpenInit(portid, version, types.UNORDERED, []string{invalidConnection}, cpportid, addr), false}, + {"too long version", types.NewMsgChannelOpenInit(portid, ibctesting.GenerateString(types.MaximumVersionLength+1), types.UNORDERED, connHops, cpportid, addr), false}, {"", types.NewMsgChannelOpenInit(portid, "", types.UNORDERED, connHops, cpportid, addr), true}, {"invalid counterparty port id", types.NewMsgChannelOpenInit(portid, version, types.UNORDERED, connHops, invalidPort, addr), false}, {"channel not in INIT state", &types.MsgChannelOpenInit{portid, tryOpenChannel, addr}, false}, @@ -162,7 +164,10 @@ func (suite *TypesTestSuite) TestMsgChannelOpenTryValidateBasic() { {"connection hops more than 1 ", types.NewMsgChannelOpenTry(portid, version, types.UNORDERED, invalidConnHops, cpportid, cpchanid, version, suite.proof, height, addr), false}, {"too short connection id", types.NewMsgChannelOpenTry(portid, version, types.UNORDERED, invalidShortConnHops, cpportid, cpchanid, version, suite.proof, height, addr), false}, {"too long connection id", types.NewMsgChannelOpenTry(portid, version, types.UNORDERED, invalidLongConnHops, cpportid, cpchanid, version, suite.proof, height, addr), false}, + {"too long connection id", types.NewMsgChannelOpenTry(portid, version, types.UNORDERED, invalidLongConnHops, cpportid, cpchanid, version, suite.proof, height, addr), false}, {"connection id contains non-alpha", types.NewMsgChannelOpenTry(portid, version, types.UNORDERED, []string{invalidConnection}, cpportid, cpchanid, version, suite.proof, height, addr), false}, + {"too long counterparty version", types.NewMsgChannelOpenTry(portid, version, types.UNORDERED, connHops, cpportid, cpchanid, ibctesting.GenerateString(types.MaximumVersionLength+1), suite.proof, height, addr), false}, + {"too long version", types.NewMsgChannelOpenTry(portid, ibctesting.GenerateString(types.MaximumVersionLength+1), types.UNORDERED, connHops, cpportid, cpchanid, version, suite.proof, height, addr), false}, {"", types.NewMsgChannelOpenTry(portid, "", types.UNORDERED, connHops, cpportid, cpchanid, version, suite.proof, height, addr), true}, {"invalid counterparty port id", types.NewMsgChannelOpenTry(portid, version, types.UNORDERED, connHops, invalidPort, cpchanid, version, suite.proof, height, addr), false}, {"invalid counterparty channel id", types.NewMsgChannelOpenTry(portid, version, types.UNORDERED, connHops, cpportid, invalidChannel, version, suite.proof, height, addr), false}, @@ -199,6 +204,7 @@ func (suite *TypesTestSuite) TestMsgChannelOpenAckValidateBasic() { {"too short channel id", types.NewMsgChannelOpenAck(portid, invalidShortChannel, chanid, version, suite.proof, height, addr), false}, {"too long channel id", types.NewMsgChannelOpenAck(portid, invalidLongChannel, chanid, version, suite.proof, height, addr), false}, {"channel id contains non-alpha", types.NewMsgChannelOpenAck(portid, invalidChannel, chanid, version, suite.proof, height, addr), false}, + {"too long counterparty version", types.NewMsgChannelOpenAck(portid, chanid, chanid, ibctesting.GenerateString(types.MaximumVersionLength+1), suite.proof, height, addr), false}, {"", types.NewMsgChannelOpenAck(portid, chanid, chanid, "", suite.proof, height, addr), true}, {"empty proof", types.NewMsgChannelOpenAck(portid, chanid, chanid, version, emptyProof, height, addr), false}, {"invalid counterparty channel id", types.NewMsgChannelOpenAck(portid, chanid, invalidShortChannel, version, suite.proof, height, addr), false}, From b3740cb3098d1156e2422d6d8e520dc226154205 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Mon, 16 Oct 2023 15:24:47 +0200 Subject: [PATCH 17/24] add length check for version fields in connection handshake messages --- modules/core/03-connection/types/msgs.go | 2 ++ modules/core/03-connection/types/msgs_test.go | 6 ++++++ modules/core/03-connection/types/version.go | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/modules/core/03-connection/types/msgs.go b/modules/core/03-connection/types/msgs.go index c46c783767e..ba36aea06c5 100644 --- a/modules/core/03-connection/types/msgs.go +++ b/modules/core/03-connection/types/msgs.go @@ -13,6 +13,8 @@ import ( "github.com/cosmos/ibc-go/v8/modules/core/exported" ) +const MaximumVersionFieldsLength = 4096 // maximum length in bytes for the fields in version + var ( _ sdk.Msg = (*MsgConnectionOpenInit)(nil) _ sdk.Msg = (*MsgConnectionOpenConfirm)(nil) diff --git a/modules/core/03-connection/types/msgs_test.go b/modules/core/03-connection/types/msgs_test.go index ba26c117c0e..726b3060c7a 100644 --- a/modules/core/03-connection/types/msgs_test.go +++ b/modules/core/03-connection/types/msgs_test.go @@ -99,6 +99,8 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenInit() { {"invalid counterparty connection ID", &types.MsgConnectionOpenInit{connectionID, types.NewCounterparty("clienttotest", "connectiontotest", prefix), version, 500, signer}, false}, {"empty counterparty prefix", types.NewMsgConnectionOpenInit("clienttotest", "clienttotest", emptyPrefix, version, 500, signer), false}, {"supplied version fails basic validation", types.NewMsgConnectionOpenInit("clienttotest", "clienttotest", prefix, &types.Version{}, 500, signer), false}, + {"too long version identifier", types.NewMsgConnectionOpenInit("clienttotest", "clienttotest", prefix, types.NewVersion(ibctesting.GenerateString(types.MaximumVersionFieldsLength+1), []string{"ORDER_ORDERED"}), 500, signer), false}, + {"too long version feature", types.NewMsgConnectionOpenInit("clienttotest", "clienttotest", prefix, types.NewVersion(types.DefaultIBCVersionIdentifier, []string{ibctesting.GenerateString(types.MaximumVersionFieldsLength + 1)}), 500, signer), false}, {"empty singer", types.NewMsgConnectionOpenInit("clienttotest", "clienttotest", prefix, version, 500, ""), false}, {"success", types.NewMsgConnectionOpenInit("clienttotest", "clienttotest", prefix, version, 500, signer), true}, } @@ -158,6 +160,8 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenTry() { {"empty singer", types.NewMsgConnectionOpenTry("clienttotesta", "connectiontotest", "clienttotest", clientState, prefix, []*types.Version{ibctesting.ConnectionVersion}, 500, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, ""), false}, {"success", types.NewMsgConnectionOpenTry("clienttotesta", "connectiontotest", "clienttotest", clientState, prefix, []*types.Version{ibctesting.ConnectionVersion}, 500, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, signer), true}, {"invalid version", types.NewMsgConnectionOpenTry("clienttotesta", "connectiontotest", "clienttotest", clientState, prefix, []*types.Version{{}}, 500, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, signer), false}, + {"too long version identifier", types.NewMsgConnectionOpenTry("clienttotesta", "connectiontotest", "clienttotest", clientState, prefix, []*types.Version{types.NewVersion(ibctesting.GenerateString(types.MaximumVersionFieldsLength+1), []string{"ORDER_ORDERED"})}, 500, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, signer), false}, + {"too long version feature", types.NewMsgConnectionOpenTry("clienttotesta", "connectiontotest", "clienttotest", clientState, prefix, []*types.Version{types.NewVersion(types.DefaultIBCVersionIdentifier, []string{ibctesting.GenerateString(types.MaximumVersionFieldsLength + 1)})}, 500, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, signer), false}, } for _, tc := range testCases { @@ -204,6 +208,8 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenAck() { {"empty proofConsensus", types.NewMsgConnectionOpenAck(connectionID, connectionID, clientState, suite.proof, suite.proof, emptyProof, clientHeight, clientHeight, ibctesting.ConnectionVersion, signer), false}, {"invalid consensusHeight", types.NewMsgConnectionOpenAck(connectionID, connectionID, clientState, suite.proof, suite.proof, suite.proof, clientHeight, clienttypes.ZeroHeight(), ibctesting.ConnectionVersion, signer), false}, {"invalid version", types.NewMsgConnectionOpenAck(connectionID, connectionID, clientState, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, &types.Version{}, signer), false}, + {"too long version identifier", types.NewMsgConnectionOpenAck(connectionID, connectionID, clientState, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, types.NewVersion(ibctesting.GenerateString(types.MaximumVersionFieldsLength+1), []string{"ORDER_ORDERED"}), signer), false}, + {"too long version feature", types.NewMsgConnectionOpenAck(connectionID, connectionID, clientState, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, types.NewVersion(types.DefaultIBCVersionIdentifier, []string{ibctesting.GenerateString(types.MaximumVersionFieldsLength + 1)}), signer), false}, {"empty signer", types.NewMsgConnectionOpenAck(connectionID, connectionID, clientState, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, ibctesting.ConnectionVersion, ""), false}, {"success", types.NewMsgConnectionOpenAck(connectionID, connectionID, clientState, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, ibctesting.ConnectionVersion, signer), true}, } diff --git a/modules/core/03-connection/types/version.go b/modules/core/03-connection/types/version.go index 00aadcb8682..7f86cd4db12 100644 --- a/modules/core/03-connection/types/version.go +++ b/modules/core/03-connection/types/version.go @@ -56,10 +56,16 @@ func ValidateVersion(version *Version) error { if strings.TrimSpace(version.Identifier) == "" { return errorsmod.Wrap(ErrInvalidVersion, "version identifier cannot be blank") } + if len(version.Identifier) > MaximumVersionFieldsLength { + return errorsmod.Wrapf(ErrInvalidVersion, "version identifier must not exceed %d bytes", MaximumVersionFieldsLength) + } for i, feature := range version.Features { if strings.TrimSpace(feature) == "" { return errorsmod.Wrapf(ErrInvalidVersion, "feature cannot be blank, index %d", i) } + if len(feature) > MaximumVersionFieldsLength { + return errorsmod.Wrapf(ErrInvalidVersion, "feature must not exceed %d bytes, index %d", MaximumVersionFieldsLength, i) + } } return nil From cd8b722a5e7898b56eb11310550e31d83a6bfda4 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Wed, 18 Oct 2023 16:22:44 +0200 Subject: [PATCH 18/24] fix(statemachine)!: add check for length of counterparty payee in `MsgRegisterCounterpartyPayee` (#4870) * add check for length of counterparty payee in MsgRegisterCounterpartyPayee * change test value --- modules/apps/29-fee/types/msgs.go | 6 ++++++ modules/apps/29-fee/types/msgs_test.go | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/modules/apps/29-fee/types/msgs.go b/modules/apps/29-fee/types/msgs.go index 095d36a604d..6d5b34b7007 100644 --- a/modules/apps/29-fee/types/msgs.go +++ b/modules/apps/29-fee/types/msgs.go @@ -12,6 +12,8 @@ import ( ibcerrors "github.com/cosmos/ibc-go/v8/modules/core/errors" ) +const MaximumCounterpartyPayeeLength = 2048 // maximum length of the counterparty payee in bytes + var ( _ sdk.Msg = (*MsgRegisterPayee)(nil) _ sdk.Msg = (*MsgRegisterCounterpartyPayee)(nil) @@ -100,6 +102,10 @@ func (msg MsgRegisterCounterpartyPayee) ValidateBasic() error { return ErrCounterpartyPayeeEmpty } + if len(msg.CounterpartyPayee) > MaximumCounterpartyPayeeLength { + return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "counterparty payee addresss must not exceed %d bytes", MaximumCounterpartyPayeeLength) + } + return nil } diff --git a/modules/apps/29-fee/types/msgs_test.go b/modules/apps/29-fee/types/msgs_test.go index 4c59160cb1e..6f1d2bce4eb 100644 --- a/modules/apps/29-fee/types/msgs_test.go +++ b/modules/apps/29-fee/types/msgs_test.go @@ -139,6 +139,13 @@ func TestMsgRegisterCountepartyPayeeValidation(t *testing.T) { }, false, }, + { + "invalid counterparty payee address: too long", + func() { + msg.CounterpartyPayee = ibctesting.GenerateString(types.MaximumCounterpartyPayeeLength + 1) + }, + false, + }, } for i, tc := range testCases { From cdf3cb778ef987dcf5bc7c4404f733c329e4db77 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Wed, 18 Oct 2023 16:25:28 +0200 Subject: [PATCH 19/24] add check for length of owner address (#4874) --- .../apps/27-interchain-accounts/controller/types/msgs.go | 6 ++++++ .../27-interchain-accounts/controller/types/msgs_test.go | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/modules/apps/27-interchain-accounts/controller/types/msgs.go b/modules/apps/27-interchain-accounts/controller/types/msgs.go index b600942bf01..1187b579ff3 100644 --- a/modules/apps/27-interchain-accounts/controller/types/msgs.go +++ b/modules/apps/27-interchain-accounts/controller/types/msgs.go @@ -12,6 +12,8 @@ import ( ibcerrors "github.com/cosmos/ibc-go/v8/modules/core/errors" ) +const MaximumOwnerLength = 2048 // maximum length of the owner in bytes + var ( _ sdk.Msg = (*MsgRegisterInterchainAccount)(nil) _ sdk.Msg = (*MsgSendTx)(nil) @@ -41,6 +43,10 @@ func (msg MsgRegisterInterchainAccount) ValidateBasic() error { return errorsmod.Wrap(ibcerrors.ErrInvalidAddress, "owner address cannot be empty") } + if len(msg.Owner) > MaximumOwnerLength { + return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "owner addresss must not exceed %d bytes", MaximumOwnerLength) + } + return nil } diff --git a/modules/apps/27-interchain-accounts/controller/types/msgs_test.go b/modules/apps/27-interchain-accounts/controller/types/msgs_test.go index 13ef2c9ae1a..33a02068464 100644 --- a/modules/apps/27-interchain-accounts/controller/types/msgs_test.go +++ b/modules/apps/27-interchain-accounts/controller/types/msgs_test.go @@ -64,6 +64,13 @@ func TestMsgRegisterInterchainAccountValidateBasic(t *testing.T) { }, false, }, + { + "owner address is too long", + func() { + msg.Owner = ibctesting.GenerateString(types.MaximumOwnerLength + 1) + }, + false, + }, } for i, tc := range testCases { From 69a879925c6a2e4e674e3a8930112e7f0f619498 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Fri, 20 Oct 2023 14:22:50 +0800 Subject: [PATCH 20/24] sdk for testnet-ibc --- go.mod | 14 +++++++------- go.sum | 28 ++++++++++++++-------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/go.mod b/go.mod index 60eeea0edb9..aa5db0ec921 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/cometbft/cometbft v0.38.0 github.com/cosmos/cosmos-db v1.0.0 github.com/cosmos/cosmos-proto v1.0.0-beta.3 - github.com/cosmos/cosmos-sdk v0.50.0-rc.1 + github.com/cosmos/cosmos-sdk v0.50.0-rc.1.0.20231019221833-0c9930dfe36f github.com/cosmos/gogoproto v1.4.11 github.com/cosmos/ibc-go/modules/capability v1.0.0-rc6 github.com/cosmos/ics23/go v0.10.0 @@ -30,7 +30,7 @@ require ( github.com/spf13/cobra v1.7.0 github.com/spf13/viper v1.17.0 github.com/stretchr/testify v1.8.4 - google.golang.org/genproto/googleapis/api v0.0.0-20230920204549-e6e6cdab5c13 + google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 google.golang.org/grpc v1.59.0 google.golang.org/protobuf v1.31.0 gopkg.in/yaml.v2 v2.4.0 @@ -69,7 +69,7 @@ require ( github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect github.com/cosmos/iavl v1.0.0-rc.1 // indirect - github.com/cosmos/ledger-cosmos-go v0.13.0 // indirect + github.com/cosmos/ledger-cosmos-go v0.13.2 // indirect github.com/creachadair/atomicfile v0.3.1 // indirect github.com/creachadair/tomledit v0.0.24 // indirect github.com/danieljoos/wincred v1.1.2 // indirect @@ -167,8 +167,8 @@ require ( github.com/tendermint/go-amino v0.16.0 // indirect github.com/tidwall/btree v1.6.0 // indirect github.com/ulikunitz/xz v0.5.11 // indirect - github.com/zondax/hid v0.9.1 // indirect - github.com/zondax/ledger-go v0.14.1 // indirect + github.com/zondax/hid v0.9.2 // indirect + github.com/zondax/ledger-go v0.14.3 // indirect go.etcd.io/bbolt v1.3.7 // indirect go.opencensus.io v0.24.0 // indirect go.uber.org/multierr v1.10.0 // indirect @@ -183,8 +183,8 @@ require ( golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/api v0.143.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c // indirect + google.golang.org/genproto v0.0.0-20231012201019-e917dd12ba7a // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect gotest.tools/v3 v3.5.1 // indirect diff --git a/go.sum b/go.sum index 8e0b42b54af..efbaf967e34 100644 --- a/go.sum +++ b/go.sum @@ -353,8 +353,8 @@ github.com/cosmos/cosmos-db v1.0.0 h1:EVcQZ+qYag7W6uorBKFPvX6gRjw6Uq2hIh4hCWjuQ0 github.com/cosmos/cosmos-db v1.0.0/go.mod h1:iBvi1TtqaedwLdcrZVYRSSCb6eSy61NLj4UNmdIgs0U= github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I= -github.com/cosmos/cosmos-sdk v0.50.0-rc.1 h1:1Z+SgLg8S2+DoiePz9aO5dSjJUgag8VFhFUSD/HGvOU= -github.com/cosmos/cosmos-sdk v0.50.0-rc.1/go.mod h1:JbgPLZrh+yX+4+n1CPJ/uL9HrhZw6QVg0q7cTq2Iwq0= +github.com/cosmos/cosmos-sdk v0.50.0-rc.1.0.20231019221833-0c9930dfe36f h1:Jw8KbHt1CQZF7xx09Xkd/2DXMTCkUV335dzenSLPN84= +github.com/cosmos/cosmos-sdk v0.50.0-rc.1.0.20231019221833-0c9930dfe36f/go.mod h1:FxbXMhS/Fz47QeviJ3yi1JgB0qCzgclMQ8s7MjD/I88= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE= @@ -368,8 +368,8 @@ github.com/cosmos/ibc-go/modules/capability v1.0.0-rc6 h1:K3lWRr/WJkPdSWErxhQL1x github.com/cosmos/ibc-go/modules/capability v1.0.0-rc6/go.mod h1:DBP9jg+NoXU2buK5QDyf87lMjcQYN8qFlByNeNJmuhs= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= -github.com/cosmos/ledger-cosmos-go v0.13.0 h1:ex0CvCxToSR7j5WjrghPu2Bu9sSXKikjnVvUryNnx4s= -github.com/cosmos/ledger-cosmos-go v0.13.0/go.mod h1:ZcqYgnfNJ6lAXe4HPtWgarNEY+B74i+2/8MhZw4ziiI= +github.com/cosmos/ledger-cosmos-go v0.13.2 h1:aY0KZSmUwNKbBm9OvbIjvf7Ozz2YzzpAbgvN2C8x2T0= +github.com/cosmos/ledger-cosmos-go v0.13.2/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= @@ -1028,10 +1028,10 @@ github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/zondax/hid v0.9.1 h1:gQe66rtmyZ8VeGFcOpbuH3r7erYtNEAezCAYu8LdkJo= -github.com/zondax/hid v0.9.1/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= -github.com/zondax/ledger-go v0.14.1 h1:Pip65OOl4iJ84WTpA4BKChvOufMhhbxED3BaihoZN4c= -github.com/zondax/ledger-go v0.14.1/go.mod h1:fZ3Dqg6qcdXWSOJFKMG8GCTnD7slO/RL2feOQv8K320= +github.com/zondax/hid v0.9.2 h1:WCJFnEDMiqGF64nlZz28E9qLVZ0KSJ7xpc5DLEyma2U= +github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= +github.com/zondax/ledger-go v0.14.3 h1:wEpJt2CEcBJ428md/5MgSLsXLBos98sBOyxNmCjfUCw= +github.com/zondax/ledger-go v0.14.3/go.mod h1:IKKaoxupuB43g4NxeQmbLXv7T9AlQyie1UpHb342ycI= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ= go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= @@ -1588,12 +1588,12 @@ google.golang.org/genproto v0.0.0-20221010155953-15ba04fc1c0e/go.mod h1:3526vdqw google.golang.org/genproto v0.0.0-20221014173430-6e2ab493f96b/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= google.golang.org/genproto v0.0.0-20221025140454-527a21cfbd71/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= -google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 h1:SeZZZx0cP0fqUyA+oRzP9k7cSwJlvDFiROO72uwD6i0= -google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97/go.mod h1:t1VqOqqvce95G3hIDCT5FeO3YUc6Q4Oe24L/+rNMxRk= -google.golang.org/genproto/googleapis/api v0.0.0-20230920204549-e6e6cdab5c13 h1:U7+wNaVuSTaUqNvK2+osJ9ejEZxbjHHk8F2b6Hpx0AE= -google.golang.org/genproto/googleapis/api v0.0.0-20230920204549-e6e6cdab5c13/go.mod h1:RdyHbowztCGQySiCvQPgWQWgWhGnouTdCflKoDBt32U= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c h1:jHkCUWkseRf+W+edG5hMzr/Uh1xkDREY4caybAq4dpY= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c/go.mod h1:4cYg8o5yUbm77w8ZX00LhMVNl/YVBFJRYWDc0uYWMs0= +google.golang.org/genproto v0.0.0-20231012201019-e917dd12ba7a h1:fwgW9j3vHirt4ObdHoYNwuO24BEZjSzbh+zPaNWoiY8= +google.golang.org/genproto v0.0.0-20231012201019-e917dd12ba7a/go.mod h1:EMfReVxb80Dq1hhioy0sOsY9jCE46YDgHlJ7fWVUWRE= +google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 h1:W18sezcAYs+3tDZX4F80yctqa12jcP1PUS2gQu1zTPU= +google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97/go.mod h1:iargEX0SFPm3xcfMI0d1domjg0ZF4Aa0p2awqyxhvF0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b h1:ZlWIi1wSK56/8hn4QcBp/j9M7Gt3U/3hZw3mC7vDICo= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:swOH3j0KzcDDgGUWr+SNpyTen5YrXjS3eyPzFYKc6lc= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= From 3717da081a702cc62f946b586f9ab97387f4b45d Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Fri, 20 Oct 2023 14:39:01 +0800 Subject: [PATCH 21/24] go mod tidy all --- e2e/go.mod | 14 +++++++------- e2e/go.sum | 28 ++++++++++++++-------------- modules/apps/callbacks/go.mod | 14 +++++++------- modules/apps/callbacks/go.sum | 28 ++++++++++++++-------------- 4 files changed, 42 insertions(+), 42 deletions(-) diff --git a/e2e/go.mod b/e2e/go.mod index 0c45bb07404..85106774d4b 100644 --- a/e2e/go.mod +++ b/e2e/go.mod @@ -7,7 +7,7 @@ require ( cosmossdk.io/math v1.1.3-rc.1 cosmossdk.io/x/upgrade v0.0.0-20230915171831-2196edacb99d github.com/cometbft/cometbft v0.38.0 - github.com/cosmos/cosmos-sdk v0.50.0-rc.1 + github.com/cosmos/cosmos-sdk v0.50.0-rc.1.0.20231019221833-0c9930dfe36f github.com/cosmos/gogoproto v1.4.11 github.com/cosmos/ibc-go/v8 v8.0.0-20230906115913-46ee5f92e1af github.com/docker/docker v24.0.6+incompatible @@ -68,7 +68,7 @@ require ( github.com/cosmos/iavl v1.0.0-rc.1 // indirect github.com/cosmos/ibc-go/modules/capability v1.0.0-rc6 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect - github.com/cosmos/ledger-cosmos-go v0.13.0 // indirect + github.com/cosmos/ledger-cosmos-go v0.13.2 // indirect github.com/danieljoos/wincred v1.1.2 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect @@ -183,8 +183,8 @@ require ( github.com/tendermint/go-amino v0.16.0 // indirect github.com/tidwall/btree v1.6.0 // indirect github.com/ulikunitz/xz v0.5.11 // indirect - github.com/zondax/hid v0.9.1 // indirect - github.com/zondax/ledger-go v0.14.1 // indirect + github.com/zondax/hid v0.9.2 // indirect + github.com/zondax/ledger-go v0.14.3 // indirect go.etcd.io/bbolt v1.3.7 // indirect go.opencensus.io v0.24.0 // indirect go.uber.org/multierr v1.11.0 // indirect @@ -200,9 +200,9 @@ require ( golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/api v0.143.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20230920204549-e6e6cdab5c13 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c // indirect + google.golang.org/genproto v0.0.0-20231012201019-e917dd12ba7a // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/e2e/go.sum b/e2e/go.sum index 80c5c012fbf..195edd5825e 100644 --- a/e2e/go.sum +++ b/e2e/go.sum @@ -355,8 +355,8 @@ github.com/cosmos/cosmos-db v1.0.0 h1:EVcQZ+qYag7W6uorBKFPvX6gRjw6Uq2hIh4hCWjuQ0 github.com/cosmos/cosmos-db v1.0.0/go.mod h1:iBvi1TtqaedwLdcrZVYRSSCb6eSy61NLj4UNmdIgs0U= github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I= -github.com/cosmos/cosmos-sdk v0.50.0-rc.1 h1:1Z+SgLg8S2+DoiePz9aO5dSjJUgag8VFhFUSD/HGvOU= -github.com/cosmos/cosmos-sdk v0.50.0-rc.1/go.mod h1:JbgPLZrh+yX+4+n1CPJ/uL9HrhZw6QVg0q7cTq2Iwq0= +github.com/cosmos/cosmos-sdk v0.50.0-rc.1.0.20231019221833-0c9930dfe36f h1:Jw8KbHt1CQZF7xx09Xkd/2DXMTCkUV335dzenSLPN84= +github.com/cosmos/cosmos-sdk v0.50.0-rc.1.0.20231019221833-0c9930dfe36f/go.mod h1:FxbXMhS/Fz47QeviJ3yi1JgB0qCzgclMQ8s7MjD/I88= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE= @@ -370,8 +370,8 @@ github.com/cosmos/ibc-go/modules/capability v1.0.0-rc6 h1:K3lWRr/WJkPdSWErxhQL1x github.com/cosmos/ibc-go/modules/capability v1.0.0-rc6/go.mod h1:DBP9jg+NoXU2buK5QDyf87lMjcQYN8qFlByNeNJmuhs= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= -github.com/cosmos/ledger-cosmos-go v0.13.0 h1:ex0CvCxToSR7j5WjrghPu2Bu9sSXKikjnVvUryNnx4s= -github.com/cosmos/ledger-cosmos-go v0.13.0/go.mod h1:ZcqYgnfNJ6lAXe4HPtWgarNEY+B74i+2/8MhZw4ziiI= +github.com/cosmos/ledger-cosmos-go v0.13.2 h1:aY0KZSmUwNKbBm9OvbIjvf7Ozz2YzzpAbgvN2C8x2T0= +github.com/cosmos/ledger-cosmos-go v0.13.2/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= @@ -1049,10 +1049,10 @@ github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/zondax/hid v0.9.1 h1:gQe66rtmyZ8VeGFcOpbuH3r7erYtNEAezCAYu8LdkJo= -github.com/zondax/hid v0.9.1/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= -github.com/zondax/ledger-go v0.14.1 h1:Pip65OOl4iJ84WTpA4BKChvOufMhhbxED3BaihoZN4c= -github.com/zondax/ledger-go v0.14.1/go.mod h1:fZ3Dqg6qcdXWSOJFKMG8GCTnD7slO/RL2feOQv8K320= +github.com/zondax/hid v0.9.2 h1:WCJFnEDMiqGF64nlZz28E9qLVZ0KSJ7xpc5DLEyma2U= +github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= +github.com/zondax/ledger-go v0.14.3 h1:wEpJt2CEcBJ428md/5MgSLsXLBos98sBOyxNmCjfUCw= +github.com/zondax/ledger-go v0.14.3/go.mod h1:IKKaoxupuB43g4NxeQmbLXv7T9AlQyie1UpHb342ycI= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ= go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= @@ -1616,12 +1616,12 @@ google.golang.org/genproto v0.0.0-20221010155953-15ba04fc1c0e/go.mod h1:3526vdqw google.golang.org/genproto v0.0.0-20221014173430-6e2ab493f96b/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= google.golang.org/genproto v0.0.0-20221025140454-527a21cfbd71/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= -google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 h1:SeZZZx0cP0fqUyA+oRzP9k7cSwJlvDFiROO72uwD6i0= -google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97/go.mod h1:t1VqOqqvce95G3hIDCT5FeO3YUc6Q4Oe24L/+rNMxRk= -google.golang.org/genproto/googleapis/api v0.0.0-20230920204549-e6e6cdab5c13 h1:U7+wNaVuSTaUqNvK2+osJ9ejEZxbjHHk8F2b6Hpx0AE= -google.golang.org/genproto/googleapis/api v0.0.0-20230920204549-e6e6cdab5c13/go.mod h1:RdyHbowztCGQySiCvQPgWQWgWhGnouTdCflKoDBt32U= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c h1:jHkCUWkseRf+W+edG5hMzr/Uh1xkDREY4caybAq4dpY= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c/go.mod h1:4cYg8o5yUbm77w8ZX00LhMVNl/YVBFJRYWDc0uYWMs0= +google.golang.org/genproto v0.0.0-20231012201019-e917dd12ba7a h1:fwgW9j3vHirt4ObdHoYNwuO24BEZjSzbh+zPaNWoiY8= +google.golang.org/genproto v0.0.0-20231012201019-e917dd12ba7a/go.mod h1:EMfReVxb80Dq1hhioy0sOsY9jCE46YDgHlJ7fWVUWRE= +google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 h1:W18sezcAYs+3tDZX4F80yctqa12jcP1PUS2gQu1zTPU= +google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97/go.mod h1:iargEX0SFPm3xcfMI0d1domjg0ZF4Aa0p2awqyxhvF0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b h1:ZlWIi1wSK56/8hn4QcBp/j9M7Gt3U/3hZw3mC7vDICo= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:swOH3j0KzcDDgGUWr+SNpyTen5YrXjS3eyPzFYKc6lc= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= diff --git a/modules/apps/callbacks/go.mod b/modules/apps/callbacks/go.mod index 9863d496582..8f2f8f7d8e1 100644 --- a/modules/apps/callbacks/go.mod +++ b/modules/apps/callbacks/go.mod @@ -24,7 +24,7 @@ require ( cosmossdk.io/x/upgrade v0.0.0-20230915171831-2196edacb99d github.com/cometbft/cometbft v0.38.0 github.com/cosmos/cosmos-db v1.0.0 - github.com/cosmos/cosmos-sdk v0.50.0-rc.1 + github.com/cosmos/cosmos-sdk v0.50.0-rc.1.0.20231019221833-0c9930dfe36f github.com/cosmos/gogoproto v1.4.11 github.com/cosmos/ibc-go/modules/capability v1.0.0-rc6 github.com/cosmos/ibc-go/v8 v8.0.0 @@ -69,7 +69,7 @@ require ( github.com/cosmos/gogogateway v1.2.0 // indirect github.com/cosmos/iavl v1.0.0-rc.1 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect - github.com/cosmos/ledger-cosmos-go v0.13.0 // indirect + github.com/cosmos/ledger-cosmos-go v0.13.2 // indirect github.com/creachadair/atomicfile v0.3.1 // indirect github.com/creachadair/tomledit v0.0.24 // indirect github.com/danieljoos/wincred v1.1.2 // indirect @@ -169,8 +169,8 @@ require ( github.com/tendermint/go-amino v0.16.0 // indirect github.com/tidwall/btree v1.6.0 // indirect github.com/ulikunitz/xz v0.5.11 // indirect - github.com/zondax/hid v0.9.1 // indirect - github.com/zondax/ledger-go v0.14.1 // indirect + github.com/zondax/hid v0.9.2 // indirect + github.com/zondax/ledger-go v0.14.3 // indirect go.etcd.io/bbolt v1.3.7 // indirect go.opencensus.io v0.24.0 // indirect go.uber.org/multierr v1.10.0 // indirect @@ -185,9 +185,9 @@ require ( golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/api v0.143.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20230920204549-e6e6cdab5c13 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c // indirect + google.golang.org/genproto v0.0.0-20231012201019-e917dd12ba7a // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b // indirect google.golang.org/grpc v1.59.0 // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect diff --git a/modules/apps/callbacks/go.sum b/modules/apps/callbacks/go.sum index 8e0b42b54af..efbaf967e34 100644 --- a/modules/apps/callbacks/go.sum +++ b/modules/apps/callbacks/go.sum @@ -353,8 +353,8 @@ github.com/cosmos/cosmos-db v1.0.0 h1:EVcQZ+qYag7W6uorBKFPvX6gRjw6Uq2hIh4hCWjuQ0 github.com/cosmos/cosmos-db v1.0.0/go.mod h1:iBvi1TtqaedwLdcrZVYRSSCb6eSy61NLj4UNmdIgs0U= github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I= -github.com/cosmos/cosmos-sdk v0.50.0-rc.1 h1:1Z+SgLg8S2+DoiePz9aO5dSjJUgag8VFhFUSD/HGvOU= -github.com/cosmos/cosmos-sdk v0.50.0-rc.1/go.mod h1:JbgPLZrh+yX+4+n1CPJ/uL9HrhZw6QVg0q7cTq2Iwq0= +github.com/cosmos/cosmos-sdk v0.50.0-rc.1.0.20231019221833-0c9930dfe36f h1:Jw8KbHt1CQZF7xx09Xkd/2DXMTCkUV335dzenSLPN84= +github.com/cosmos/cosmos-sdk v0.50.0-rc.1.0.20231019221833-0c9930dfe36f/go.mod h1:FxbXMhS/Fz47QeviJ3yi1JgB0qCzgclMQ8s7MjD/I88= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE= @@ -368,8 +368,8 @@ github.com/cosmos/ibc-go/modules/capability v1.0.0-rc6 h1:K3lWRr/WJkPdSWErxhQL1x github.com/cosmos/ibc-go/modules/capability v1.0.0-rc6/go.mod h1:DBP9jg+NoXU2buK5QDyf87lMjcQYN8qFlByNeNJmuhs= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= -github.com/cosmos/ledger-cosmos-go v0.13.0 h1:ex0CvCxToSR7j5WjrghPu2Bu9sSXKikjnVvUryNnx4s= -github.com/cosmos/ledger-cosmos-go v0.13.0/go.mod h1:ZcqYgnfNJ6lAXe4HPtWgarNEY+B74i+2/8MhZw4ziiI= +github.com/cosmos/ledger-cosmos-go v0.13.2 h1:aY0KZSmUwNKbBm9OvbIjvf7Ozz2YzzpAbgvN2C8x2T0= +github.com/cosmos/ledger-cosmos-go v0.13.2/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= @@ -1028,10 +1028,10 @@ github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/zondax/hid v0.9.1 h1:gQe66rtmyZ8VeGFcOpbuH3r7erYtNEAezCAYu8LdkJo= -github.com/zondax/hid v0.9.1/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= -github.com/zondax/ledger-go v0.14.1 h1:Pip65OOl4iJ84WTpA4BKChvOufMhhbxED3BaihoZN4c= -github.com/zondax/ledger-go v0.14.1/go.mod h1:fZ3Dqg6qcdXWSOJFKMG8GCTnD7slO/RL2feOQv8K320= +github.com/zondax/hid v0.9.2 h1:WCJFnEDMiqGF64nlZz28E9qLVZ0KSJ7xpc5DLEyma2U= +github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= +github.com/zondax/ledger-go v0.14.3 h1:wEpJt2CEcBJ428md/5MgSLsXLBos98sBOyxNmCjfUCw= +github.com/zondax/ledger-go v0.14.3/go.mod h1:IKKaoxupuB43g4NxeQmbLXv7T9AlQyie1UpHb342ycI= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ= go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= @@ -1588,12 +1588,12 @@ google.golang.org/genproto v0.0.0-20221010155953-15ba04fc1c0e/go.mod h1:3526vdqw google.golang.org/genproto v0.0.0-20221014173430-6e2ab493f96b/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= google.golang.org/genproto v0.0.0-20221025140454-527a21cfbd71/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= -google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 h1:SeZZZx0cP0fqUyA+oRzP9k7cSwJlvDFiROO72uwD6i0= -google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97/go.mod h1:t1VqOqqvce95G3hIDCT5FeO3YUc6Q4Oe24L/+rNMxRk= -google.golang.org/genproto/googleapis/api v0.0.0-20230920204549-e6e6cdab5c13 h1:U7+wNaVuSTaUqNvK2+osJ9ejEZxbjHHk8F2b6Hpx0AE= -google.golang.org/genproto/googleapis/api v0.0.0-20230920204549-e6e6cdab5c13/go.mod h1:RdyHbowztCGQySiCvQPgWQWgWhGnouTdCflKoDBt32U= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c h1:jHkCUWkseRf+W+edG5hMzr/Uh1xkDREY4caybAq4dpY= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c/go.mod h1:4cYg8o5yUbm77w8ZX00LhMVNl/YVBFJRYWDc0uYWMs0= +google.golang.org/genproto v0.0.0-20231012201019-e917dd12ba7a h1:fwgW9j3vHirt4ObdHoYNwuO24BEZjSzbh+zPaNWoiY8= +google.golang.org/genproto v0.0.0-20231012201019-e917dd12ba7a/go.mod h1:EMfReVxb80Dq1hhioy0sOsY9jCE46YDgHlJ7fWVUWRE= +google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 h1:W18sezcAYs+3tDZX4F80yctqa12jcP1PUS2gQu1zTPU= +google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97/go.mod h1:iargEX0SFPm3xcfMI0d1domjg0ZF4Aa0p2awqyxhvF0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b h1:ZlWIi1wSK56/8hn4QcBp/j9M7Gt3U/3hZw3mC7vDICo= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:swOH3j0KzcDDgGUWr+SNpyTen5YrXjS3eyPzFYKc6lc= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= From 7292bc0afddf00eef4312992c550b8ac311d5d91 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Thu, 19 Oct 2023 22:31:35 +0200 Subject: [PATCH 22/24] add length check of memo field --- modules/apps/transfer/types/errors.go | 1 + modules/apps/transfer/types/msgs.go | 5 +++++ modules/apps/transfer/types/msgs_test.go | 1 + 3 files changed, 7 insertions(+) diff --git a/modules/apps/transfer/types/errors.go b/modules/apps/transfer/types/errors.go index d62134b27cd..b3e45aa2ae2 100644 --- a/modules/apps/transfer/types/errors.go +++ b/modules/apps/transfer/types/errors.go @@ -15,4 +15,5 @@ var ( ErrReceiveDisabled = errorsmod.Register(ModuleName, 8, "fungible token transfers to this chain are disabled") ErrMaxTransferChannels = errorsmod.Register(ModuleName, 9, "max transfer channels") ErrInvalidAuthorization = errorsmod.Register(ModuleName, 10, "invalid transfer authorization") + ErrInvalidMemo = errorsmod.Register(ModuleName, 11, "invalid memo") ) diff --git a/modules/apps/transfer/types/msgs.go b/modules/apps/transfer/types/msgs.go index 33915637017..93558d313d6 100644 --- a/modules/apps/transfer/types/msgs.go +++ b/modules/apps/transfer/types/msgs.go @@ -12,6 +12,8 @@ import ( ibcerrors "github.com/cosmos/ibc-go/v8/modules/core/errors" ) +const MaximumMemoLength = 32768 // maximum length of the memo in bytes + var ( _ sdk.Msg = (*MsgUpdateParams)(nil) _ sdk.Msg = (*MsgTransfer)(nil) @@ -91,6 +93,9 @@ func (msg MsgTransfer) ValidateBasic() error { if strings.TrimSpace(msg.Receiver) == "" { return errorsmod.Wrap(ibcerrors.ErrInvalidAddress, "missing recipient address") } + if len(msg.Memo) > MaximumMemoLength { + return errorsmod.Wrapf(ErrInvalidMemo, "memo must not exceed %d bytes", MaximumMemoLength) + } return ValidateIBCDenom(msg.Token.Denom) } diff --git a/modules/apps/transfer/types/msgs_test.go b/modules/apps/transfer/types/msgs_test.go index 3afae766edb..2e769659fba 100644 --- a/modules/apps/transfer/types/msgs_test.go +++ b/modules/apps/transfer/types/msgs_test.go @@ -60,6 +60,7 @@ func TestMsgTransferValidation(t *testing.T) { {"port id contains non-alpha", types.NewMsgTransfer(invalidPort, validChannel, coin, sender, receiver, timeoutHeight, 0, ""), false}, {"too short channel id", types.NewMsgTransfer(validPort, invalidShortChannel, coin, sender, receiver, timeoutHeight, 0, ""), false}, {"too long channel id", types.NewMsgTransfer(validPort, invalidLongChannel, coin, sender, receiver, timeoutHeight, 0, ""), false}, + {"too long memo", types.NewMsgTransfer(validPort, validChannel, coin, sender, receiver, timeoutHeight, 0, ibctesting.GenerateString(types.MaximumMemoLength+1)), false}, {"channel id contains non-alpha", types.NewMsgTransfer(validPort, invalidChannel, coin, sender, receiver, timeoutHeight, 0, ""), false}, {"invalid denom", types.NewMsgTransfer(validPort, validChannel, invalidDenomCoin, sender, receiver, timeoutHeight, 0, ""), false}, {"zero coin", types.NewMsgTransfer(validPort, validChannel, zeroCoin, sender, receiver, timeoutHeight, 0, ""), false}, From aee1b61129ee5ec59dbdae2eaa6a90f9b2607c1b Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Fri, 20 Oct 2023 15:01:46 +0800 Subject: [PATCH 23/24] resolve conflict --- modules/apps/transfer/types/msgs.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/apps/transfer/types/msgs.go b/modules/apps/transfer/types/msgs.go index c9712f35630..9de6e387d0d 100644 --- a/modules/apps/transfer/types/msgs.go +++ b/modules/apps/transfer/types/msgs.go @@ -12,7 +12,7 @@ import ( ibcerrors "github.com/cosmos/ibc-go/v8/modules/core/errors" ) -const MaximumMemoLength = 32768 // maximum length of the memo in bytes +const MaximumMemoLength = 32768 // maximum length of the memo in bytes const MaximumReceiverLength = 2048 // maximum length of the receiver address in bytes var ( @@ -94,13 +94,11 @@ func (msg MsgTransfer) ValidateBasic() error { if strings.TrimSpace(msg.Receiver) == "" { return errorsmod.Wrap(ibcerrors.ErrInvalidAddress, "missing recipient address") } -<<<<<<< HEAD if len(msg.Memo) > MaximumMemoLength { return errorsmod.Wrapf(ErrInvalidMemo, "memo must not exceed %d bytes", MaximumMemoLength) -======= + } if len(msg.Receiver) > MaximumReceiverLength { return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "recipient addresss must not exceed %d bytes", MaximumReceiverLength) ->>>>>>> notional/address-length-limit } return ValidateIBCDenom(msg.Token.Denom) } From 0b00e034c9ffe678a03fffd2fdc8e33200c7383f Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Fri, 20 Oct 2023 16:33:38 +0800 Subject: [PATCH 24/24] fumpt what needs it --- modules/apps/transfer/types/msgs.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/apps/transfer/types/msgs.go b/modules/apps/transfer/types/msgs.go index 9de6e387d0d..29359e2f30d 100644 --- a/modules/apps/transfer/types/msgs.go +++ b/modules/apps/transfer/types/msgs.go @@ -12,8 +12,10 @@ import ( ibcerrors "github.com/cosmos/ibc-go/v8/modules/core/errors" ) -const MaximumMemoLength = 32768 // maximum length of the memo in bytes -const MaximumReceiverLength = 2048 // maximum length of the receiver address in bytes +const ( + MaximumMemoLength = 32768 // maximum length of the memo in bytes + MaximumReceiverLength = 2048 // maximum length of the receiver address in bytes +) var ( _ sdk.Msg = (*MsgUpdateParams)(nil)