From 8a98386f9eb7ac9f4d2c4e424ef656c016fc193c Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 11 Jun 2024 12:18:05 +0300 Subject: [PATCH 1/2] nit(transfer): Mark hops as non nullable. --- modules/apps/transfer/keeper/relay_test.go | 10 ++-- modules/apps/transfer/types/packet_test.go | 4 +- modules/apps/transfer/types/transfer.pb.go | 50 ++++++++++--------- .../applications/transfer/v1/transfer.proto | 6 ++- 4 files changed, 37 insertions(+), 33 deletions(-) diff --git a/modules/apps/transfer/keeper/relay_test.go b/modules/apps/transfer/keeper/relay_test.go index c95872b60cf..7e9e250fbe4 100644 --- a/modules/apps/transfer/keeper/relay_test.go +++ b/modules/apps/transfer/keeper/relay_test.go @@ -571,7 +571,7 @@ func (suite *KeeperTestSuite) TestPathForwarding() { sender := suite.chainA.SenderAccounts[0].SenderAccount receiver := suite.chainA.SenderAccounts[1].SenderAccount forwardingPath := types.ForwardingInfo{ - Hops: []*types.Hop{ + Hops: []types.Hop{ { PortId: path2.EndpointA.ChannelConfig.PortID, ChannelId: path2.EndpointA.ChannelID, @@ -1168,7 +1168,7 @@ func (suite *KeeperTestSuite) TestEscrowsAreSetAfterForwarding() { sender := suite.chainA.SenderAccounts[0].SenderAccount receiver := suite.chainA.SenderAccounts[1].SenderAccount forwardingPath := types.ForwardingInfo{ - Hops: []*types.Hop{ + Hops: []types.Hop{ { PortId: path2.EndpointB.ChannelConfig.PortID, ChannelId: path2.EndpointB.ChannelID, @@ -1253,7 +1253,7 @@ func (suite *KeeperTestSuite) TestHappyPathForwarding() { sender := suite.chainA.SenderAccounts[0].SenderAccount receiver := suite.chainA.SenderAccounts[1].SenderAccount forwardingPath := types.ForwardingInfo{ - Hops: []*types.Hop{ + Hops: []types.Hop{ { PortId: path2.EndpointB.ChannelConfig.PortID, ChannelId: path2.EndpointB.ChannelID, @@ -1364,7 +1364,7 @@ func (suite *KeeperTestSuite) TestSimplifiedHappyPathForwarding() { sender := suite.chainA.SenderAccounts[0].SenderAccount receiver := suite.chainA.SenderAccounts[1].SenderAccount forwardingPath := types.ForwardingInfo{ - Hops: []*types.Hop{ + Hops: []types.Hop{ { PortId: path2.EndpointB.ChannelConfig.PortID, ChannelId: path2.EndpointB.ChannelID, @@ -1563,7 +1563,7 @@ func (suite *KeeperTestSuite) TestAcknowledgementFailureScenario5Forwarding() { receiver = suite.chainA.SenderAccounts[0].SenderAccount // Receiver is the A chain account forwardingPath := types.ForwardingInfo{ - Hops: []*types.Hop{ + Hops: []types.Hop{ { PortId: path1.EndpointB.ChannelConfig.PortID, ChannelId: path1.EndpointB.ChannelID, diff --git a/modules/apps/transfer/types/packet_test.go b/modules/apps/transfer/types/packet_test.go index 9997751b69e..19c1d12e81d 100644 --- a/modules/apps/transfer/types/packet_test.go +++ b/modules/apps/transfer/types/packet_test.go @@ -234,7 +234,7 @@ func TestFungibleTokenPacketDataV2ValidateBasic(t *testing.T) { receiver, "", &types.ForwardingInfo{ - Hops: []*types.Hop{ + Hops: []types.Hop{ { PortId: "transfer", ChannelId: "channel-1", @@ -400,7 +400,7 @@ func TestFungibleTokenPacketDataV2ValidateBasic(t *testing.T) { receiver, "memo", &types.ForwardingInfo{ - Hops: []*types.Hop{ + Hops: []types.Hop{ { PortId: "transfer", ChannelId: "channel-1", diff --git a/modules/apps/transfer/types/transfer.pb.go b/modules/apps/transfer/types/transfer.pb.go index 75ee2e183d4..70af1be23e4 100644 --- a/modules/apps/transfer/types/transfer.pb.go +++ b/modules/apps/transfer/types/transfer.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" math "math" @@ -86,7 +87,7 @@ func (m *Params) GetReceiveEnabled() bool { // through which a packet must be forwarded, and the memo string to be used in the // final destination of the tokens. type ForwardingInfo struct { - Hops []*Hop `protobuf:"bytes,1,rep,name=hops,proto3" json:"hops,omitempty"` + Hops []Hop `protobuf:"bytes,1,rep,name=hops,proto3" json:"hops"` Memo string `protobuf:"bytes,2,opt,name=memo,proto3" json:"memo,omitempty"` } @@ -123,7 +124,7 @@ func (m *ForwardingInfo) XXX_DiscardUnknown() { var xxx_messageInfo_ForwardingInfo proto.InternalMessageInfo -func (m *ForwardingInfo) GetHops() []*Hop { +func (m *ForwardingInfo) GetHops() []Hop { if m != nil { return m.Hops } @@ -202,27 +203,28 @@ func init() { } var fileDescriptor_5041673e96e97901 = []byte{ - // 308 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x90, 0x3f, 0x4f, 0x3a, 0x31, - 0x1c, 0xc6, 0xb9, 0x1f, 0x84, 0x9f, 0x14, 0x83, 0x49, 0x17, 0x19, 0xf4, 0x02, 0x2c, 0x92, 0x18, - 0xaf, 0x41, 0x63, 0x74, 0x71, 0x31, 0xd1, 0xc0, 0xa6, 0x17, 0x27, 0x1d, 0x48, 0xff, 0x01, 0x4d, - 0xae, 0xfd, 0x36, 0x6d, 0x39, 0xe3, 0xbb, 0xf0, 0x65, 0x39, 0x32, 0x3a, 0x1a, 0x78, 0x23, 0xe6, - 0x0e, 0x72, 0x61, 0x72, 0x7b, 0xfa, 0xe9, 0xa7, 0xe9, 0x93, 0x07, 0x9d, 0x2b, 0xc6, 0x09, 0xb5, - 0x36, 0x53, 0x9c, 0x06, 0x05, 0xc6, 0x93, 0xe0, 0xa8, 0xf1, 0x33, 0xe9, 0x48, 0x3e, 0xaa, 0x72, - 0x62, 0x1d, 0x04, 0xc0, 0x27, 0x8a, 0xf1, 0x64, 0x5f, 0x4e, 0x2a, 0x21, 0x1f, 0x0d, 0x5e, 0x50, - 0xf3, 0x89, 0x3a, 0xaa, 0x3d, 0xee, 0xa3, 0x43, 0x2f, 0x8d, 0x98, 0x4a, 0x43, 0x59, 0x26, 0x45, - 0x37, 0xea, 0x45, 0xc3, 0x83, 0xb4, 0x5d, 0xb0, 0x87, 0x2d, 0xc2, 0x67, 0xe8, 0xc8, 0x49, 0x2e, - 0x55, 0x2e, 0x2b, 0xeb, 0x5f, 0x69, 0x75, 0x76, 0x78, 0x27, 0x0e, 0xde, 0x50, 0xe7, 0x11, 0xdc, - 0x3b, 0x75, 0x42, 0x99, 0xf9, 0xc4, 0xcc, 0x00, 0x5f, 0xa3, 0xc6, 0x02, 0xac, 0xef, 0x46, 0xbd, - 0xfa, 0xb0, 0x7d, 0xd9, 0x4f, 0xfe, 0x2a, 0x95, 0x8c, 0xc1, 0xa6, 0xa5, 0x8e, 0x31, 0x6a, 0x68, - 0xa9, 0xa1, 0xfc, 0xa6, 0x95, 0x96, 0x79, 0x70, 0x87, 0xea, 0x63, 0xb0, 0xf8, 0x18, 0xfd, 0xb7, - 0xe0, 0xc2, 0x54, 0x6d, 0xab, 0xb6, 0xd2, 0x66, 0x71, 0x9c, 0x08, 0x7c, 0x8a, 0x10, 0x5f, 0x50, - 0x63, 0x64, 0x56, 0xdc, 0x6d, 0x5f, 0xb6, 0x76, 0x64, 0x22, 0xee, 0x9f, 0xbf, 0xd6, 0x71, 0xb4, - 0x5a, 0xc7, 0xd1, 0xcf, 0x3a, 0x8e, 0x3e, 0x37, 0x71, 0x6d, 0xb5, 0x89, 0x6b, 0xdf, 0x9b, 0xb8, - 0xf6, 0x7a, 0x33, 0x57, 0x61, 0xb1, 0x64, 0x09, 0x07, 0x4d, 0x38, 0x78, 0x0d, 0x9e, 0x28, 0xc6, - 0x2f, 0xe6, 0x40, 0xf2, 0x5b, 0xa2, 0x41, 0x2c, 0x33, 0xe9, 0x8b, 0xd9, 0xf7, 0xe6, 0x0e, 0x1f, - 0x56, 0x7a, 0xd6, 0x2c, 0x97, 0xbe, 0xfa, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x05, 0xad, 0xe6, 0x9f, - 0x98, 0x01, 0x00, 0x00, + // 325 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0x41, 0x4b, 0xc3, 0x30, + 0x18, 0x86, 0x5b, 0x37, 0xa6, 0xcb, 0x64, 0x42, 0x10, 0x1c, 0xa2, 0x75, 0xdb, 0xc5, 0x81, 0xd8, + 0x30, 0x3d, 0x28, 0x88, 0x97, 0x81, 0xb2, 0xdd, 0xb4, 0x78, 0xf2, 0x32, 0xd2, 0x34, 0xeb, 0x02, + 0x6d, 0xbe, 0x90, 0x74, 0x15, 0xff, 0x85, 0x3f, 0x6b, 0xc7, 0x1d, 0x3d, 0x89, 0x6c, 0x7f, 0x44, + 0x9a, 0x8e, 0xb2, 0x93, 0xb7, 0x37, 0x4f, 0x9e, 0x97, 0x7c, 0xe4, 0x43, 0x57, 0x22, 0x64, 0x84, + 0x2a, 0x95, 0x08, 0x46, 0x33, 0x01, 0xd2, 0x90, 0x4c, 0x53, 0x69, 0x66, 0x5c, 0x93, 0x7c, 0x58, + 0x65, 0x5f, 0x69, 0xc8, 0x00, 0x9f, 0x89, 0x90, 0xf9, 0xbb, 0xb2, 0x5f, 0x09, 0xf9, 0xf0, 0xf4, + 0x38, 0x86, 0x18, 0xac, 0x48, 0x8a, 0x54, 0x76, 0xfa, 0x6f, 0xa8, 0xf1, 0x42, 0x35, 0x4d, 0x0d, + 0xee, 0xa1, 0x43, 0xc3, 0x65, 0x34, 0xe5, 0x92, 0x86, 0x09, 0x8f, 0x3a, 0x6e, 0xd7, 0x1d, 0x1c, + 0x04, 0xad, 0x82, 0x3d, 0x95, 0x08, 0x5f, 0xa2, 0x23, 0xcd, 0x19, 0x17, 0x39, 0xaf, 0xac, 0x3d, + 0x6b, 0xb5, 0xb7, 0x78, 0x2b, 0xf6, 0x29, 0x6a, 0x3f, 0x83, 0xfe, 0xa0, 0x3a, 0x12, 0x32, 0x9e, + 0xc8, 0x19, 0xe0, 0x07, 0x54, 0x9f, 0x83, 0x32, 0x1d, 0xb7, 0x5b, 0x1b, 0xb4, 0x6e, 0x7a, 0xfe, + 0x7f, 0xa3, 0xfa, 0x63, 0x50, 0xa3, 0xfa, 0xf2, 0xe7, 0xc2, 0x09, 0x6c, 0x09, 0x63, 0x54, 0x4f, + 0x79, 0x0a, 0xf6, 0xb1, 0x66, 0x60, 0x73, 0xff, 0x11, 0xd5, 0xc6, 0xa0, 0xf0, 0x09, 0xda, 0x57, + 0xa0, 0xb3, 0xa9, 0x28, 0x07, 0x6e, 0x06, 0x8d, 0xe2, 0x38, 0x89, 0xf0, 0x39, 0x42, 0x6c, 0x4e, + 0xa5, 0xe4, 0x49, 0x71, 0x57, 0x36, 0x9b, 0x5b, 0x32, 0x89, 0x46, 0xaf, 0xcb, 0xb5, 0xe7, 0xae, + 0xd6, 0x9e, 0xfb, 0xbb, 0xf6, 0xdc, 0xaf, 0x8d, 0xe7, 0xac, 0x36, 0x9e, 0xf3, 0xbd, 0xf1, 0x9c, + 0xf7, 0xbb, 0x58, 0x64, 0xf3, 0x45, 0xe8, 0x33, 0x48, 0x09, 0x03, 0x93, 0x82, 0x21, 0x22, 0x64, + 0xd7, 0x31, 0x90, 0xfc, 0x9e, 0xa4, 0x10, 0x2d, 0x12, 0x6e, 0x8a, 0x95, 0xec, 0xac, 0x22, 0xfb, + 0x54, 0xdc, 0x84, 0x0d, 0xfb, 0xa3, 0xb7, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x6b, 0x1c, 0xa2, + 0x4b, 0xb4, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -565,7 +567,7 @@ func (m *ForwardingInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Hops = append(m.Hops, &Hop{}) + m.Hops = append(m.Hops, Hop{}) if err := m.Hops[len(m.Hops)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/proto/ibc/applications/transfer/v1/transfer.proto b/proto/ibc/applications/transfer/v1/transfer.proto index 45dc9c0d2b5..2eac86c7f6c 100644 --- a/proto/ibc/applications/transfer/v1/transfer.proto +++ b/proto/ibc/applications/transfer/v1/transfer.proto @@ -2,6 +2,8 @@ syntax = "proto3"; package ibc.applications.transfer.v1; +import "gogoproto/gogo.proto"; + option go_package = "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"; // Params defines the set of IBC transfer parameters. @@ -21,7 +23,7 @@ message Params { // through which a packet must be forwarded, and the memo string to be used in the // final destination of the tokens. message ForwardingInfo { - repeated Hop hops = 1; + repeated Hop hops = 1 [(gogoproto.nullable) = false]; string memo = 2; } @@ -30,4 +32,4 @@ message ForwardingInfo { message Hop { string port_id = 1; string channel_id = 2; -} \ No newline at end of file +} From 94a08f0eadb9471b827a91368faaada508d8d414 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 11 Jun 2024 16:37:25 +0300 Subject: [PATCH 2/2] lint: fix additional linting issues --- modules/apps/transfer/keeper/relay_forwarding_test.go | 10 +++++----- modules/apps/transfer/keeper/relay_test.go | 2 -- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/modules/apps/transfer/keeper/relay_forwarding_test.go b/modules/apps/transfer/keeper/relay_forwarding_test.go index bdb1aa2b0ae..880e9dbcf89 100644 --- a/modules/apps/transfer/keeper/relay_forwarding_test.go +++ b/modules/apps/transfer/keeper/relay_forwarding_test.go @@ -28,7 +28,7 @@ func (suite *KeeperTestSuite) TestPathForwarding() { sender := suite.chainA.SenderAccounts[0].SenderAccount receiver := suite.chainA.SenderAccounts[1].SenderAccount forwardingPath := types.ForwardingInfo{ - Hops: []*types.Hop{ + Hops: []types.Hop{ { PortId: path2.EndpointA.ChannelConfig.PortID, ChannelId: path2.EndpointA.ChannelID, @@ -90,7 +90,7 @@ func (suite *KeeperTestSuite) TestEscrowsAreSetAfterForwarding() { sender := suite.chainA.SenderAccounts[0].SenderAccount receiver := suite.chainA.SenderAccounts[1].SenderAccount forwardingPath := types.ForwardingInfo{ - Hops: []*types.Hop{ + Hops: []types.Hop{ { PortId: path2.EndpointB.ChannelConfig.PortID, ChannelId: path2.EndpointB.ChannelID, @@ -173,7 +173,7 @@ func (suite *KeeperTestSuite) TestHappyPathForwarding() { sender := suite.chainA.SenderAccounts[0].SenderAccount receiver := suite.chainA.SenderAccounts[1].SenderAccount forwardingPath := types.ForwardingInfo{ - Hops: []*types.Hop{ + Hops: []types.Hop{ { PortId: path2.EndpointB.ChannelConfig.PortID, ChannelId: path2.EndpointB.ChannelID, @@ -281,7 +281,7 @@ func (suite *KeeperTestSuite) TestSimplifiedHappyPathForwarding() { sender := suite.chainA.SenderAccounts[0].SenderAccount receiver := suite.chainA.SenderAccounts[1].SenderAccount forwardingPath := types.ForwardingInfo{ - Hops: []*types.Hop{ + Hops: []types.Hop{ { PortId: path2.EndpointB.ChannelConfig.PortID, ChannelId: path2.EndpointB.ChannelID, @@ -478,7 +478,7 @@ func (suite *KeeperTestSuite) TestAcknowledgementFailureScenario5Forwarding() { receiver = suite.chainA.SenderAccounts[0].SenderAccount // Receiver is the A chain account forwardingPath := types.ForwardingInfo{ - Hops: []*types.Hop{ + Hops: []types.Hop{ { PortId: path1.EndpointB.ChannelConfig.PortID, ChannelId: path1.EndpointB.ChannelID, diff --git a/modules/apps/transfer/keeper/relay_test.go b/modules/apps/transfer/keeper/relay_test.go index 112f917ef2f..924e5179a36 100644 --- a/modules/apps/transfer/keeper/relay_test.go +++ b/modules/apps/transfer/keeper/relay_test.go @@ -556,7 +556,6 @@ func (suite *KeeperTestSuite) TestOnRecvPacket_ReceiverIsSource() { } } - func (suite *KeeperTestSuite) TestOnRecvPacketSetsTotalEscrowAmountForSourceIBCToken() { /* Given the following flow of tokens: @@ -1089,7 +1088,6 @@ func (suite *KeeperTestSuite) TestOnTimeoutPacketSetsTotalEscrowAmountForSourceI suite.Require().Equal(sdkmath.ZeroInt(), totalEscrowChainB.Amount) } - func (suite *KeeperTestSuite) TestPacketForwardsCompatibility() { // We are testing a scenario where a packet in the future has a new populated // field called "new_field". And this packet is being sent to this module which