From 84c176ae8d6f144f9a6d32953fd5502611dc6eb9 Mon Sep 17 00:00:00 2001 From: srdtrk <59252793+srdtrk@users.noreply.github.com> Date: Tue, 12 Nov 2024 17:42:14 +0800 Subject: [PATCH 1/6] docs: land on v9 by default (#7553) --- docs/docusaurus.config.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js index 0620421a31a..e953a05c3c8 100644 --- a/docs/docusaurus.config.js +++ b/docs/docusaurus.config.js @@ -49,13 +49,17 @@ const config = { // Exclude template markdown files from the docs exclude: ["**/*.template.md"], // Select the latest version - lastVersion: "v8.5.x", + lastVersion: "v9.0.x", // Assign banners to specific versions versions: { current: { path: "main", banner: "unreleased", }, + "v9.0.x": { + path: "v9", + banner: "none", + }, "v8.5.x": { path: "v8", banner: "none", From 083cfb17d1a4128809a523c5d352eba695b96dc0 Mon Sep 17 00:00:00 2001 From: Vasilev Ivan <20002mc@gmail.com> Date: Tue, 12 Nov 2024 13:58:42 +0300 Subject: [PATCH 2/6] test: ensure that the packet commit changes if the packed fields changes (#7514) * test: ensure that the packet commit changes if the packed fields changes * test: fix lint and sequence * test: tweak test slightly * chore: fix linter complaint. --------- Co-authored-by: DimitrisJim --- modules/core/04-channel/types/packet_test.go | 34 +++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/modules/core/04-channel/types/packet_test.go b/modules/core/04-channel/types/packet_test.go index 1338f45c8d1..fca1d9a357d 100644 --- a/modules/core/04-channel/types/packet_test.go +++ b/modules/core/04-channel/types/packet_test.go @@ -13,16 +13,44 @@ import ( ) func TestCommitPacket(t *testing.T) { - packet := types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp) - registry := codectypes.NewInterfaceRegistry() clienttypes.RegisterInterfaces(registry) types.RegisterInterfaces(registry) cdc := codec.NewProtoCodec(registry) + packet := types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp) commitment := types.CommitPacket(cdc, packet) require.NotNil(t, commitment) + + testCases := []struct { + name string + packet types.Packet + }{ + { + name: "diff data", + packet: types.NewPacket(unknownPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), + }, + { + name: "diff timeout revision number", + packet: types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, clienttypes.NewHeight(timeoutHeight.RevisionNumber+1, timeoutHeight.RevisionHeight), timeoutTimestamp), + }, + { + name: "diff timeout revision height", + packet: types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, clienttypes.NewHeight(timeoutHeight.RevisionNumber, timeoutHeight.RevisionHeight+1), timeoutTimestamp), + }, + { + name: "diff timeout timestamp", + packet: types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, uint64(1)), + }, + } + + for _, tc := range testCases { + testCommitment := types.CommitPacket(cdc, tc.packet) + require.NotNil(t, testCommitment) + + require.NotEqual(t, commitment, testCommitment) + } } func TestPacketValidateBasic(t *testing.T) { @@ -44,8 +72,6 @@ func TestPacketValidateBasic(t *testing.T) { } for i, tc := range testCases { - tc := tc - err := tc.packet.ValidateBasic() if tc.expPass { require.NoError(t, err, "Msg %d failed: %s", i, tc.errMsg) From cb299784471e7c484dc124ab2b900ef7f98609df Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 12 Nov 2024 14:54:00 +0200 Subject: [PATCH 3/6] chore: drop usage of 'channeltypesv2'. --- modules/core/04-channel/v2/keeper/events.go | 18 ++-- .../core/04-channel/v2/keeper/export_test.go | 12 +-- .../04-channel/v2/keeper/msg_server_test.go | 92 +++++++++---------- 3 files changed, 61 insertions(+), 61 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/events.go b/modules/core/04-channel/v2/keeper/events.go index 720fb93e11b..b20273d74bf 100644 --- a/modules/core/04-channel/v2/keeper/events.go +++ b/modules/core/04-channel/v2/keeper/events.go @@ -5,31 +5,31 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" ) // EmitSendPacketEvents emits events for the SendPacket handler. -func EmitSendPacketEvents(ctx context.Context, packet channeltypesv2.Packet) { +func EmitSendPacketEvents(ctx context.Context, packet types.Packet) { // TODO: https://github.com/cosmos/ibc-go/issues/7386 } // EmitRecvPacketEvents emits events for the RecvPacket handler. -func EmitRecvPacketEvents(ctx context.Context, packet channeltypesv2.Packet) { +func EmitRecvPacketEvents(ctx context.Context, packet types.Packet) { // TODO: https://github.com/cosmos/ibc-go/issues/7386 } // EmitAcknowledgePacketEvents emits events for the AcknowledgePacket handler. -func EmitAcknowledgePacketEvents(ctx context.Context, packet channeltypesv2.Packet) { +func EmitAcknowledgePacketEvents(ctx context.Context, packet types.Packet) { // TODO: https://github.com/cosmos/ibc-go/issues/7386 } // EmitTimeoutPacketEvents emits events for the TimeoutPacket handler. -func EmitTimeoutPacketEvents(ctx context.Context, packet channeltypesv2.Packet) { +func EmitTimeoutPacketEvents(ctx context.Context, packet types.Packet) { // TODO: https://github.com/cosmos/ibc-go/issues/7386 } // EmitWriteAcknowledgementEvents emits events for WriteAcknowledgement. -func EmitWriteAcknowledgementEvents(ctx context.Context, packet channeltypesv2.Packet, ack channeltypesv2.Acknowledgement) { +func EmitWriteAcknowledgementEvents(ctx context.Context, packet types.Packet, ack types.Acknowledgement) { // TODO: https://github.com/cosmos/ibc-go/issues/7386 } @@ -39,12 +39,12 @@ func (*Keeper) EmitCreateChannelEvent(ctx context.Context, channelID string) { sdkCtx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - channeltypesv2.EventTypeCreateChannel, - sdk.NewAttribute(channeltypesv2.AttributeKeyChannelID, channelID), + types.EventTypeCreateChannel, + sdk.NewAttribute(types.AttributeKeyChannelID, channelID), ), sdk.NewEvent( sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, channeltypesv2.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), ), }) } diff --git a/modules/core/04-channel/v2/keeper/export_test.go b/modules/core/04-channel/v2/keeper/export_test.go index d772eac3bef..aae6048ed2a 100644 --- a/modules/core/04-channel/v2/keeper/export_test.go +++ b/modules/core/04-channel/v2/keeper/export_test.go @@ -7,7 +7,7 @@ package keeper import ( "context" - channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" "github.com/cosmos/ibc-go/v9/modules/core/exported" ) @@ -15,7 +15,7 @@ func (k *Keeper) SendPacketTest( ctx context.Context, sourceChannel string, timeoutTimestamp uint64, - payloads []channeltypesv2.Payload, + payloads []types.Payload, ) (uint64, string, error) { return k.sendPacket( ctx, @@ -27,7 +27,7 @@ func (k *Keeper) SendPacketTest( func (k *Keeper) RecvPacketTest( ctx context.Context, - packet channeltypesv2.Packet, + packet types.Packet, proof []byte, proofHeight exported.Height, ) error { @@ -41,8 +41,8 @@ func (k *Keeper) RecvPacketTest( func (k *Keeper) AcknowledgePacketTest( ctx context.Context, - packet channeltypesv2.Packet, - acknowledgement channeltypesv2.Acknowledgement, + packet types.Packet, + acknowledgement types.Acknowledgement, proof []byte, proofHeight exported.Height, ) error { @@ -57,7 +57,7 @@ func (k *Keeper) AcknowledgePacketTest( func (k *Keeper) TimeoutPacketTest( ctx context.Context, - packet channeltypesv2.Packet, + packet types.Packet, proof []byte, proofHeight exported.Height, ) error { diff --git a/modules/core/04-channel/v2/keeper/msg_server_test.go b/modules/core/04-channel/v2/keeper/msg_server_test.go index 2fa079e1e1f..3ea899c28af 100644 --- a/modules/core/04-channel/v2/keeper/msg_server_test.go +++ b/modules/core/04-channel/v2/keeper/msg_server_test.go @@ -9,7 +9,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" - channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" ibctesting "github.com/cosmos/ibc-go/v9/testing" @@ -20,7 +20,7 @@ import ( func (suite *KeeperTestSuite) TestRegisterCounterparty() { var ( path *ibctesting.Path - msg *channeltypesv2.MsgRegisterCounterparty + msg *types.MsgRegisterCounterparty ) cases := []struct { name string @@ -31,7 +31,7 @@ func (suite *KeeperTestSuite) TestRegisterCounterparty() { "success", func() { // set it before handler - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetChannel(suite.chainA.GetContext(), msg.ChannelId, channeltypesv2.NewChannel(path.EndpointA.ClientID, "", ibctesting.MerklePath)) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetChannel(suite.chainA.GetContext(), msg.ChannelId, types.NewChannel(path.EndpointA.ClientID, "", ibctesting.MerklePath)) }, nil, }, @@ -53,9 +53,9 @@ func (suite *KeeperTestSuite) TestRegisterCounterparty() { "failure: channel must already exist", func() { suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.DeleteCreator(suite.chainA.GetContext(), path.EndpointA.ChannelID) - suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.ChannelStore(suite.chainA.GetContext(), path.EndpointA.ChannelID).Delete([]byte(channeltypesv2.ChannelKey)) + suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.ChannelStore(suite.chainA.GetContext(), path.EndpointA.ChannelID).Delete([]byte(types.ChannelKey)) }, - channeltypesv2.ErrChannelNotFound, + types.ErrChannelNotFound, }, } @@ -70,7 +70,7 @@ func (suite *KeeperTestSuite) TestRegisterCounterparty() { suite.Require().NoError(path.EndpointB.CreateChannel()) signer := path.EndpointA.Chain.SenderAccount.GetAddress().String() - msg = channeltypesv2.NewMsgRegisterCounterparty(path.EndpointA.ChannelID, path.EndpointB.ChannelID, signer) + msg = types.NewMsgRegisterCounterparty(path.EndpointA.ChannelID, path.EndpointB.ChannelID, signer) tc.malleate() @@ -102,9 +102,9 @@ func (suite *KeeperTestSuite) TestRegisterCounterparty() { func (suite *KeeperTestSuite) TestMsgSendPacket() { var ( path *ibctesting.Path - expectedPacket channeltypesv2.Packet + expectedPacket types.Packet timeoutTimestamp uint64 - payload channeltypesv2.Payload + payload types.Payload ) testCases := []struct { @@ -121,8 +121,8 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { name: "success: valid timeout timestamp", malleate: func() { // ensure a message timeout. - timeoutTimestamp = uint64(suite.chainA.GetContext().BlockTime().Add(channeltypesv2.MaxTimeoutDelta - 10*time.Second).Unix()) - expectedPacket = channeltypesv2.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, timeoutTimestamp, payload) + timeoutTimestamp = uint64(suite.chainA.GetContext().BlockTime().Add(types.MaxTimeoutDelta - 10*time.Second).Unix()) + expectedPacket = types.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, timeoutTimestamp, payload) }, expError: nil, }, @@ -132,15 +132,15 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { // ensure a message timeout. timeoutTimestamp = uint64(1) }, - expError: channeltypesv2.ErrTimeoutElapsed, + expError: types.ErrTimeoutElapsed, }, { name: "failure: timeout timestamp exceeds max allowed input", malleate: func() { // ensure message timeout exceeds max allowed input. - timeoutTimestamp = uint64(suite.chainA.GetContext().BlockTime().Add(channeltypesv2.MaxTimeoutDelta + 10*time.Second).Unix()) + timeoutTimestamp = uint64(suite.chainA.GetContext().BlockTime().Add(types.MaxTimeoutDelta + 10*time.Second).Unix()) }, - expError: channeltypesv2.ErrInvalidTimeout, + expError: types.ErrInvalidTimeout, }, { name: "failure: timeout timestamp less than current block timestamp", @@ -148,7 +148,7 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { // ensure message timeout exceeds max allowed input. timeoutTimestamp = uint64(suite.chainA.GetContext().BlockTime().Unix()) - 1 }, - expError: channeltypesv2.ErrTimeoutElapsed, + expError: types.ErrTimeoutElapsed, }, { name: "failure: inactive client", @@ -160,7 +160,7 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { { name: "failure: application callback error", malleate: func() { - path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnSendPacket = func(ctx context.Context, sourceID string, destinationID string, sequence uint64, data channeltypesv2.Payload, signer sdk.AccAddress) error { + path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnSendPacket = func(ctx context.Context, sourceID string, destinationID string, sequence uint64, data types.Payload, signer sdk.AccAddress) error { return mock.MockApplicationCallbackError } }, @@ -171,7 +171,7 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { malleate: func() { path.EndpointA.ChannelID = ibctesting.InvalidID }, - expError: channeltypesv2.ErrChannelNotFound, + expError: types.ErrChannelNotFound, }, { name: "failure: route to non existing app", @@ -194,7 +194,7 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { timeoutTimestamp = suite.chainA.GetTimeoutTimestampSecs() payload = mockv2.NewMockPayload(mockv2.ModuleNameA, mockv2.ModuleNameB) - expectedPacket = channeltypesv2.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, timeoutTimestamp, payload) + expectedPacket = types.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, timeoutTimestamp, payload) tc.malleate() @@ -209,7 +209,7 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { packetCommitment := ck.GetPacketCommitment(path.EndpointA.Chain.GetContext(), path.EndpointA.ChannelID, 1) suite.Require().NotNil(packetCommitment) - suite.Require().Equal(channeltypesv2.CommitPacket(expectedPacket), packetCommitment, "packet commitment is not stored correctly") + suite.Require().Equal(types.CommitPacket(expectedPacket), packetCommitment, "packet commitment is not stored correctly") nextSequenceSend, ok := ck.GetNextSequenceSend(path.EndpointA.Chain.GetContext(), path.EndpointA.ChannelID) suite.Require().True(ok) @@ -228,8 +228,8 @@ func (suite *KeeperTestSuite) TestMsgSendPacket() { func (suite *KeeperTestSuite) TestMsgRecvPacket() { var ( path *ibctesting.Path - packet channeltypesv2.Packet - expectedAck channeltypesv2.Acknowledgement + packet types.Packet + expectedAck types.Acknowledgement ) testCases := []struct { @@ -245,15 +245,15 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { { name: "success: failed recv result", malleate: func() { - failedRecvResult := channeltypesv2.RecvPacketResult{ - Status: channeltypesv2.PacketStatus_Failure, + failedRecvResult := types.RecvPacketResult{ + Status: types.PacketStatus_Failure, Acknowledgement: mock.MockFailPacketData, } // a failed ack should be returned by the application. expectedAck.AcknowledgementResults[0].RecvPacketResult = failedRecvResult - path.EndpointB.Chain.GetSimApp().MockModuleV2B.IBCApp.OnRecvPacket = func(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.Payload, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult { + path.EndpointB.Chain.GetSimApp().MockModuleV2B.IBCApp.OnRecvPacket = func(ctx context.Context, sourceChannel string, destinationChannel string, data types.Payload, relayer sdk.AccAddress) types.RecvPacketResult { return failedRecvResult } }, @@ -261,15 +261,15 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { { name: "success: async recv result", malleate: func() { - asyncResult := channeltypesv2.RecvPacketResult{ - Status: channeltypesv2.PacketStatus_Async, + asyncResult := types.RecvPacketResult{ + Status: types.PacketStatus_Async, Acknowledgement: nil, } // an async ack should be returned by the application. expectedAck.AcknowledgementResults[0].RecvPacketResult = asyncResult - path.EndpointB.Chain.GetSimApp().MockModuleV2B.IBCApp.OnRecvPacket = func(ctx context.Context, sourceChannel string, destinationChannel string, data channeltypesv2.Payload, relayer sdk.AccAddress) channeltypesv2.RecvPacketResult { + path.EndpointB.Chain.GetSimApp().MockModuleV2B.IBCApp.OnRecvPacket = func(ctx context.Context, sourceChannel string, destinationChannel string, data types.Payload, relayer sdk.AccAddress) types.RecvPacketResult { return asyncResult } }, @@ -278,7 +278,7 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { name: "success: NoOp", malleate: func() { suite.chainB.App.GetIBCKeeper().ChannelKeeperV2.SetPacketReceipt(suite.chainB.GetContext(), packet.DestinationChannel, packet.Sequence) - expectedAck = channeltypesv2.Acknowledgement{} + expectedAck = types.Acknowledgement{} }, }, { @@ -287,7 +287,7 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { // change the destination id to a non-existent channel. packet.DestinationChannel = ibctesting.InvalidID }, - expError: channeltypesv2.ErrChannelNotFound, + expError: types.ErrChannelNotFound, }, { name: "failure: invalid proof", @@ -315,8 +315,8 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { suite.Require().NoError(err) // default expected ack is a single successful recv result for moduleB. - expectedAck = channeltypesv2.Acknowledgement{ - AcknowledgementResults: []channeltypesv2.AcknowledgementResult{ + expectedAck = types.Acknowledgement{ + AcknowledgementResults: []types.AcknowledgementResult{ { AppName: mockv2.ModuleNameB, RecvPacketResult: mockv2.MockRecvPacketResult, @@ -340,13 +340,13 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { ackWritten := ck.HasPacketAcknowledgement(path.EndpointB.Chain.GetContext(), packet.DestinationChannel, packet.Sequence) - if len(expectedAck.AcknowledgementResults) == 0 || expectedAck.AcknowledgementResults[0].RecvPacketResult.Status == channeltypesv2.PacketStatus_Async { + if len(expectedAck.AcknowledgementResults) == 0 || expectedAck.AcknowledgementResults[0].RecvPacketResult.Status == types.PacketStatus_Async { // ack should not be written for async app or if the packet receipt was already present. suite.Require().False(ackWritten) } else { // successful or failed acknowledgement // ack should be written for synchronous app (default mock application behaviour). suite.Require().True(ackWritten) - expectedBz := channeltypesv2.CommitAcknowledgement(expectedAck) + expectedBz := types.CommitAcknowledgement(expectedAck) actualAckBz := ck.GetPacketAcknowledgement(path.EndpointB.Chain.GetContext(), packet.DestinationChannel, packet.Sequence) suite.Require().Equal(expectedBz, actualAckBz) @@ -364,8 +364,8 @@ func (suite *KeeperTestSuite) TestMsgRecvPacket() { func (suite *KeeperTestSuite) TestMsgAcknowledgement() { var ( path *ibctesting.Path - packet channeltypesv2.Packet - ack channeltypesv2.Acknowledgement + packet types.Packet + ack types.Acknowledgement ) testCases := []struct { name string @@ -383,7 +383,7 @@ func (suite *KeeperTestSuite) TestMsgAcknowledgement() { // Modify the callback to return an error. // This way, we can verify that the callback is not executed in a No-op case. - path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnAcknowledgementPacket = func(context.Context, string, string, channeltypesv2.Payload, []byte, sdk.AccAddress) error { + path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnAcknowledgementPacket = func(context.Context, string, string, types.Payload, []byte, sdk.AccAddress) error { return mock.MockApplicationCallbackError } }, @@ -391,7 +391,7 @@ func (suite *KeeperTestSuite) TestMsgAcknowledgement() { { name: "failure: callback fails", malleate: func() { - path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnAcknowledgementPacket = func(context.Context, string, string, channeltypesv2.Payload, []byte, sdk.AccAddress) error { + path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnAcknowledgementPacket = func(context.Context, string, string, types.Payload, []byte, sdk.AccAddress) error { return mock.MockApplicationCallbackError } }, @@ -403,14 +403,14 @@ func (suite *KeeperTestSuite) TestMsgAcknowledgement() { // change the source id to a non-existent channel. packet.SourceChannel = "not-existent-channel" }, - expError: channeltypesv2.ErrChannelNotFound, + expError: types.ErrChannelNotFound, }, { name: "failure: invalid commitment", malleate: func() { suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), packet.SourceChannel, packet.Sequence, []byte("foo")) }, - expError: channeltypesv2.ErrInvalidPacket, + expError: types.ErrInvalidPacket, }, { name: "failure: failed membership verification", @@ -438,8 +438,8 @@ func (suite *KeeperTestSuite) TestMsgAcknowledgement() { suite.Require().NoError(err) // Construct expected acknowledgement - ack = channeltypesv2.Acknowledgement{ - AcknowledgementResults: []channeltypesv2.AcknowledgementResult{ + ack = types.Acknowledgement{ + AcknowledgementResults: []types.AcknowledgementResult{ { AppName: mockv2.ModuleNameB, RecvPacketResult: mockv2.MockRecvPacketResult, @@ -465,7 +465,7 @@ func (suite *KeeperTestSuite) TestMsgAcknowledgement() { func (suite *KeeperTestSuite) TestMsgTimeout() { var ( path *ibctesting.Path - packet channeltypesv2.Packet + packet types.Packet ) testCases := []struct { @@ -484,16 +484,16 @@ func (suite *KeeperTestSuite) TestMsgTimeout() { // Modify the callback to return a different error. // This way, we can verify that the callback is not executed in a No-op case. - path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnTimeoutPacket = func(context.Context, string, string, channeltypesv2.Payload, sdk.AccAddress) error { + path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnTimeoutPacket = func(context.Context, string, string, types.Payload, sdk.AccAddress) error { return mock.MockApplicationCallbackError } }, - expError: channeltypesv2.ErrNoOpMsg, + expError: types.ErrNoOpMsg, }, { name: "failure: callback fails", malleate: func() { - path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnTimeoutPacket = func(context.Context, string, string, channeltypesv2.Payload, sdk.AccAddress) error { + path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnTimeoutPacket = func(context.Context, string, string, types.Payload, sdk.AccAddress) error { return mock.MockApplicationCallbackError } }, @@ -505,14 +505,14 @@ func (suite *KeeperTestSuite) TestMsgTimeout() { // change the source id to a non-existent channel. packet.SourceChannel = "not-existent-channel" }, - expError: channeltypesv2.ErrChannelNotFound, + expError: types.ErrChannelNotFound, }, { name: "failure: invalid commitment", malleate: func() { suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.SetPacketCommitment(suite.chainA.GetContext(), packet.SourceChannel, packet.Sequence, []byte("foo")) }, - expError: channeltypesv2.ErrInvalidPacket, + expError: types.ErrInvalidPacket, }, { name: "failure: unable to timeout if packet has been received", From 5031af8893f1a74772173ecbdefc1ab48a043546 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 12 Nov 2024 15:10:31 +0200 Subject: [PATCH 4/6] chore: fix post-merge test failure. --- modules/core/04-channel/types/packet_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/core/04-channel/types/packet_test.go b/modules/core/04-channel/types/packet_test.go index f889deb9ce4..f26192b8712 100644 --- a/modules/core/04-channel/types/packet_test.go +++ b/modules/core/04-channel/types/packet_test.go @@ -5,6 +5,7 @@ import ( "github.com/stretchr/testify/require" + clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" ) @@ -36,7 +37,7 @@ func TestCommitPacket(t *testing.T) { } for _, tc := range testCases { - testCommitment := types.CommitPacket(cdc, tc.packet) + testCommitment := types.CommitPacket(tc.packet) require.NotNil(t, testCommitment) require.NotEqual(t, commitment, testCommitment) From 00505238557a6d9eab1013e07e43a75f401680f8 Mon Sep 17 00:00:00 2001 From: Aditya <14364734+AdityaSripal@users.noreply.github.com> Date: Tue, 12 Nov 2024 14:38:31 +0100 Subject: [PATCH 5/6] ICS24: Change Provable keys (#7517) * refactor packet keys * provable keys * chore: fix packet commitments prefix function. --------- Co-authored-by: DimitrisJim --- modules/core/24-host/v2/packet_keys.go | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/modules/core/24-host/v2/packet_keys.go b/modules/core/24-host/v2/packet_keys.go index b7c540b2abd..a95814198f8 100644 --- a/modules/core/24-host/v2/packet_keys.go +++ b/modules/core/24-host/v2/packet_keys.go @@ -6,25 +6,24 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// PacketReceiptKey returns the store key of under which a packet -// receipt is stored -func PacketReceiptKey(channelID string, sequence uint64) []byte { - return []byte(fmt.Sprintf("receipts/channels/%s/sequences/%s", channelID, sdk.Uint64ToBigEndian(sequence))) -} - -// PacketAcknowledgementKey returns the store key of under which a packet acknowledgement is stored. -func PacketAcknowledgementKey(channelID string, sequence uint64) []byte { - return []byte(fmt.Sprintf("acks/channels/%s/sequences/%s", channelID, sdk.Uint64ToBigEndian(sequence))) +// PacketCommitmentKey returns the store key of under which a packet commitment is stored. +func PacketCommitmentKey(channelID string, sequence uint64) []byte { + return append(append([]byte(channelID), byte(1)), sdk.Uint64ToBigEndian(sequence)...) } // PacketCommitmentPrefixKey returns the store key prefix under which packet commitments for a particular channel are stored. func PacketCommitmentPrefixKey(channelID string) []byte { - return []byte(fmt.Sprintf("commitments/channels/%s", channelID)) + return append([]byte(channelID), byte(1)) } -// PacketCommitmentKey returns the store key of under which a packet commitment is stored. -func PacketCommitmentKey(channelID string, sequence uint64) []byte { - return []byte(fmt.Sprintf("commitments/channels/%s/sequences/%s", channelID, sdk.Uint64ToBigEndian(sequence))) +// PacketReceiptKey returns the store key of under which a packet receipt is stored. +func PacketReceiptKey(channelID string, sequence uint64) []byte { + return append(append([]byte(channelID), byte(2)), sdk.Uint64ToBigEndian(sequence)...) +} + +// PacketAcknowledgementKey returns the store key of under which a packet acknowledgement is stored. +func PacketAcknowledgementKey(channelID string, sequence uint64) []byte { + return append(append([]byte(channelID), byte(3)), sdk.Uint64ToBigEndian(sequence)...) } // NextSequenceSendKey returns the store key for the next sequence send of a given channelID. From d416dc36de108ae19eb76b2b81733ddc3f68c5c7 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Tue, 12 Nov 2024 16:02:55 +0200 Subject: [PATCH 6/6] chore: amend event emitted for create channel. (#7557) --- modules/core/04-channel/v2/keeper/events.go | 5 +++-- modules/core/04-channel/v2/keeper/msg_server.go | 2 +- modules/core/04-channel/v2/types/events.go | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/events.go b/modules/core/04-channel/v2/keeper/events.go index b20273d74bf..1c2140d2835 100644 --- a/modules/core/04-channel/v2/keeper/events.go +++ b/modules/core/04-channel/v2/keeper/events.go @@ -33,14 +33,15 @@ func EmitWriteAcknowledgementEvents(ctx context.Context, packet types.Packet, ac // TODO: https://github.com/cosmos/ibc-go/issues/7386 } -// EmitCreateChannelEvent emits a channel create event. -func (*Keeper) EmitCreateChannelEvent(ctx context.Context, channelID string) { +// emitCreateChannelEvent emits a channel create event. +func (*Keeper) emitCreateChannelEvent(ctx context.Context, channelID, clientID string) { sdkCtx := sdk.UnwrapSDKContext(ctx) sdkCtx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeCreateChannel, sdk.NewAttribute(types.AttributeKeyChannelID, channelID), + sdk.NewAttribute(types.AttributeKeyClientID, clientID), ), sdk.NewEvent( sdk.EventTypeMessage, diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index 6bda4404531..39d376aac30 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -29,7 +29,7 @@ func (k *Keeper) CreateChannel(goCtx context.Context, msg *types.MsgCreateChanne k.SetCreator(ctx, channelID, msg.Signer) k.SetNextSequenceSend(ctx, channelID, 1) - k.EmitCreateChannelEvent(goCtx, channelID) + k.emitCreateChannelEvent(goCtx, channelID, msg.ClientId) return &types.MsgCreateChannelResponse{ChannelId: channelID}, nil } diff --git a/modules/core/04-channel/v2/types/events.go b/modules/core/04-channel/v2/types/events.go index 6166f0422d1..78bf04df189 100644 --- a/modules/core/04-channel/v2/types/events.go +++ b/modules/core/04-channel/v2/types/events.go @@ -9,6 +9,7 @@ import ( // IBC channel events const ( AttributeKeyChannelID = "channel_id" + AttributeKeyClientID = "client_id" ) // IBC channel events vars