From e8ce6d3729fbb4101a57f1b1c874232164cbaab5 Mon Sep 17 00:00:00 2001 From: chatton Date: Tue, 30 Jul 2024 10:52:14 +0100 Subject: [PATCH 01/14] chore: adding version to UnmarshalPacketData interface --- .../controller/ibc_middleware.go | 12 +++++++++--- .../controller/ibc_middleware_test.go | 8 +++++--- .../apps/27-interchain-accounts/host/ibc_module.go | 12 +++++++++--- .../27-interchain-accounts/host/ibc_module_test.go | 7 +++++-- modules/apps/29-fee/ibc_middleware.go | 4 ++-- modules/apps/29-fee/ibc_middleware_test.go | 5 +++-- modules/apps/callbacks/ibc_middleware.go | 2 +- modules/apps/callbacks/ibc_middleware_test.go | 4 ++-- modules/apps/callbacks/types/callbacks.go | 4 ++-- modules/apps/transfer/ibc_module.go | 7 ++++--- modules/apps/transfer/ibc_module_test.go | 2 +- modules/core/05-port/types/module.go | 2 +- testing/mock/ibc_module.go | 6 +++--- 13 files changed, 47 insertions(+), 28 deletions(-) diff --git a/modules/apps/27-interchain-accounts/controller/ibc_middleware.go b/modules/apps/27-interchain-accounts/controller/ibc_middleware.go index 595930b231b..db7db8bc4e8 100644 --- a/modules/apps/27-interchain-accounts/controller/ibc_middleware.go +++ b/modules/apps/27-interchain-accounts/controller/ibc_middleware.go @@ -353,11 +353,17 @@ func (im IBCMiddleware) GetAppVersion(ctx sdk.Context, portID, channelID string) // UnmarshalPacketData attempts to unmarshal the provided packet data bytes // into an InterchainAccountPacketData. This function implements the optional // PacketDataUnmarshaler interface required for ADR 008 support. -func (IBCMiddleware) UnmarshalPacketData(_ sdk.Context, _, _ string, bz []byte) (interface{}, error) { +func (im IBCMiddleware) UnmarshalPacketData(ctx sdk.Context, portID string, channelID string, bz []byte) (interface{}, string, error) { var data icatypes.InterchainAccountPacketData err := data.UnmarshalJSON(bz) if err != nil { - return nil, err + return nil, "", err } - return data, nil + + version, ok := im.GetAppVersion(ctx, portID, channelID) + if !ok { + return nil, "", errorsmod.Wrapf(ibcerrors.ErrNotFound, "app version not found for port %s and channel %s", portID, channelID) + } + + return data, version, nil } diff --git a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go index afaf5c487ce..d76b26c064b 100644 --- a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go +++ b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go @@ -1314,16 +1314,18 @@ func (suite *InterchainAccountsTestSuite) TestPacketDataUnmarshalerInterface() { Memo: "", } - // Context, port identifier and channel identifier are unused for controller. - packetData, err := controller.IBCMiddleware{}.UnmarshalPacketData(suite.chainA.GetContext(), "", "", expPacketData.GetBytes()) + controllerMiddleware := controller.NewIBCMiddleware(suite.chainA.GetSimApp().ICAControllerKeeper) + packetData, version, err := controllerMiddleware.UnmarshalPacketData(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, expPacketData.GetBytes()) suite.Require().NoError(err) + suite.Require().Equal(version, path.EndpointA.ChannelConfig.Version) suite.Require().Equal(expPacketData, packetData) // test invalid packet data invalidPacketData := []byte("invalid packet data") // Context, port identifier and channel identifier are not used for controller. - packetData, err = controller.IBCMiddleware{}.UnmarshalPacketData(suite.chainA.GetContext(), "", "", invalidPacketData) + packetData, version, err = controllerMiddleware.UnmarshalPacketData(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, invalidPacketData) suite.Require().Error(err) + suite.Require().Empty(version) suite.Require().Nil(packetData) } } diff --git a/modules/apps/27-interchain-accounts/host/ibc_module.go b/modules/apps/27-interchain-accounts/host/ibc_module.go index 18339a7f9f8..65af63a3a30 100644 --- a/modules/apps/27-interchain-accounts/host/ibc_module.go +++ b/modules/apps/27-interchain-accounts/host/ibc_module.go @@ -186,11 +186,17 @@ func (IBCModule) OnChanUpgradeOpen(_ sdk.Context, _, _ string, _ channeltypes.Or // UnmarshalPacketData attempts to unmarshal the provided packet data bytes // into an InterchainAccountPacketData. This function implements the optional // PacketDataUnmarshaler interface required for ADR 008 support. -func (IBCModule) UnmarshalPacketData(_ sdk.Context, _, _ string, bz []byte) (interface{}, error) { +func (im IBCModule) UnmarshalPacketData(ctx sdk.Context, portID string, channelID string, bz []byte) (interface{}, string, error) { var data icatypes.InterchainAccountPacketData err := data.UnmarshalJSON(bz) if err != nil { - return nil, err + return nil, "", err } - return data, nil + + version, ok := im.keeper.GetAppVersion(ctx, portID, channelID) + if !ok { + return nil, "", errorsmod.Wrapf(ibcerrors.ErrNotFound, "app version not found for port %s and channel %s", portID, channelID) + } + + return data, version, nil } diff --git a/modules/apps/27-interchain-accounts/host/ibc_module_test.go b/modules/apps/27-interchain-accounts/host/ibc_module_test.go index cba05393f9b..07699ee0da0 100644 --- a/modules/apps/27-interchain-accounts/host/ibc_module_test.go +++ b/modules/apps/27-interchain-accounts/host/ibc_module_test.go @@ -917,15 +917,18 @@ func (suite *InterchainAccountsTestSuite) TestPacketDataUnmarshalerInterface() { } // Context, port identifier and channel identifier are unused for host. - packetData, err := icahost.IBCModule{}.UnmarshalPacketData(suite.chainA.GetContext(), "", "", expPacketData.GetBytes()) + icaHostModule := icahost.NewIBCModule(suite.chainA.GetSimApp().ICAHostKeeper) + packetData, version, err := icaHostModule.UnmarshalPacketData(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, expPacketData.GetBytes()) suite.Require().NoError(err) + suite.Require().Equal(version, path.EndpointA.ChannelConfig.Version) suite.Require().Equal(expPacketData, packetData) // test invalid packet data invalidPacketData := []byte("invalid packet data") // Context, port identifier and channel identifier are unused for host. - packetData, err = icahost.IBCModule{}.UnmarshalPacketData(suite.chainA.GetContext(), "", "", invalidPacketData) + packetData, version, err = icaHostModule.UnmarshalPacketData(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, invalidPacketData) suite.Require().Error(err) + suite.Require().Empty(version) suite.Require().Nil(packetData) } } diff --git a/modules/apps/29-fee/ibc_middleware.go b/modules/apps/29-fee/ibc_middleware.go index be979487ddb..dce52a87cdc 100644 --- a/modules/apps/29-fee/ibc_middleware.go +++ b/modules/apps/29-fee/ibc_middleware.go @@ -486,10 +486,10 @@ func (im IBCMiddleware) GetAppVersion(ctx sdk.Context, portID, channelID string) // UnmarshalPacketData attempts to use the underlying app to unmarshal the packet data. // If the underlying app does not support the PacketDataUnmarshaler interface, an error is returned. // This function implements the optional PacketDataUnmarshaler interface required for ADR 008 support. -func (im IBCMiddleware) UnmarshalPacketData(ctx sdk.Context, portID, channelID string, bz []byte) (interface{}, error) { +func (im IBCMiddleware) UnmarshalPacketData(ctx sdk.Context, portID string, channelID string, bz []byte) (interface{}, string, error) { unmarshaler, ok := im.app.(porttypes.PacketDataUnmarshaler) if !ok { - return nil, errorsmod.Wrapf(types.ErrUnsupportedAction, "underlying app does not implement %T", (*porttypes.PacketDataUnmarshaler)(nil)) + return nil, "", errorsmod.Wrapf(types.ErrUnsupportedAction, "underlying app does not implement %T", (*porttypes.PacketDataUnmarshaler)(nil)) } return unmarshaler.UnmarshalPacketData(ctx, portID, channelID, bz) diff --git a/modules/apps/29-fee/ibc_middleware_test.go b/modules/apps/29-fee/ibc_middleware_test.go index 7f1948482ba..4e2a9c27280 100644 --- a/modules/apps/29-fee/ibc_middleware_test.go +++ b/modules/apps/29-fee/ibc_middleware_test.go @@ -1580,8 +1580,9 @@ func (suite *FeeTestSuite) TestPacketDataUnmarshalerInterface() { suite.Require().True(ok) // Context, port identifier, channel identifier are not used in current wiring of fee. - packetData, err := feeModule.UnmarshalPacketData(suite.chainA.GetContext(), "", "", ibcmock.MockPacketData) + packetData, version, err := feeModule.UnmarshalPacketData(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID, ibcmock.MockPacketData) suite.Require().NoError(err) + suite.Require().NotEmpty(version) suite.Require().Equal(ibcmock.MockPacketData, packetData) } @@ -1590,7 +1591,7 @@ func (suite *FeeTestSuite) TestPacketDataUnmarshalerInterfaceError() { mockFeeMiddleware := ibcfee.NewIBCMiddleware(nil, feekeeper.Keeper{}) // Context, port identifier, channel identifier are not used in mockFeeMiddleware. - _, err := mockFeeMiddleware.UnmarshalPacketData(suite.chainA.GetContext(), "", "", ibcmock.MockPacketData) + _, _, err := mockFeeMiddleware.UnmarshalPacketData(suite.chainA.GetContext(), "", "", ibcmock.MockPacketData) expError := errorsmod.Wrapf(types.ErrUnsupportedAction, "underlying app does not implement %T", (*porttypes.PacketDataUnmarshaler)(nil)) suite.Require().ErrorIs(err, expError) } diff --git a/modules/apps/callbacks/ibc_middleware.go b/modules/apps/callbacks/ibc_middleware.go index dfe21cc8547..f3cf521dd1b 100644 --- a/modules/apps/callbacks/ibc_middleware.go +++ b/modules/apps/callbacks/ibc_middleware.go @@ -426,6 +426,6 @@ func (im IBCMiddleware) GetAppVersion(ctx sdk.Context, portID, channelID string) // UnmarshalPacketData defers to the underlying app to unmarshal the packet data. // This function implements the optional PacketDataUnmarshaler interface. -func (im IBCMiddleware) UnmarshalPacketData(ctx sdk.Context, portID, channelID string, bz []byte) (interface{}, error) { +func (im IBCMiddleware) UnmarshalPacketData(ctx sdk.Context, portID string, channelID string, bz []byte) (interface{}, string, error) { return im.app.UnmarshalPacketData(ctx, portID, channelID, bz) } diff --git a/modules/apps/callbacks/ibc_middleware_test.go b/modules/apps/callbacks/ibc_middleware_test.go index e87c2317fd0..6794450a078 100644 --- a/modules/apps/callbacks/ibc_middleware_test.go +++ b/modules/apps/callbacks/ibc_middleware_test.go @@ -1027,7 +1027,7 @@ func (s *CallbacksTestSuite) TestUnmarshalPacketDataV1() { // Unmarshal ICS20 v1 packet data into v2 packet data data := expPacketDataICS20V1.GetBytes() - packetData, err := unmarshalerStack.UnmarshalPacketData(s.chainA.GetContext(), portID, channelID, data) + packetData, _, err := unmarshalerStack.UnmarshalPacketData(s.chainA.GetContext(), portID, channelID, data) s.Require().NoError(err) s.Require().Equal(expPacketDataICS20V2, packetData) } @@ -1060,7 +1060,7 @@ func (s *CallbacksTestSuite) TestUnmarshalPacketDataV2() { // Unmarshal ICS20 v2 packet data data := expPacketDataICS20V2.GetBytes() - packetData, err := unmarshalerStack.UnmarshalPacketData(s.chainA.GetContext(), portID, channelID, data) + packetData, _, err := unmarshalerStack.UnmarshalPacketData(s.chainA.GetContext(), portID, channelID, data) s.Require().NoError(err) s.Require().Equal(expPacketDataICS20V2, packetData) } diff --git a/modules/apps/callbacks/types/callbacks.go b/modules/apps/callbacks/types/callbacks.go index 658887a47ac..7d107db1a0f 100644 --- a/modules/apps/callbacks/types/callbacks.go +++ b/modules/apps/callbacks/types/callbacks.go @@ -75,7 +75,7 @@ func GetSourceCallbackData( packet channeltypes.Packet, maxGas uint64, ) (CallbackData, error) { - packetData, err := packetDataUnmarshaler.UnmarshalPacketData(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetData()) + packetData, _, err := packetDataUnmarshaler.UnmarshalPacketData(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetData()) if err != nil { return CallbackData{}, errorsmod.Wrap(ErrCannotUnmarshalPacketData, err.Error()) } @@ -89,7 +89,7 @@ func GetDestCallbackData( packetDataUnmarshaler porttypes.PacketDataUnmarshaler, packet channeltypes.Packet, maxGas uint64, ) (CallbackData, error) { - packetData, err := packetDataUnmarshaler.UnmarshalPacketData(ctx, packet.GetDestPort(), packet.GetDestChannel(), packet.GetData()) + packetData, _, err := packetDataUnmarshaler.UnmarshalPacketData(ctx, packet.GetDestPort(), packet.GetDestChannel(), packet.GetData()) if err != nil { return CallbackData{}, errorsmod.Wrap(ErrCannotUnmarshalPacketData, err.Error()) } diff --git a/modules/apps/transfer/ibc_module.go b/modules/apps/transfer/ibc_module.go index 4af345c339a..39220cc75eb 100644 --- a/modules/apps/transfer/ibc_module.go +++ b/modules/apps/transfer/ibc_module.go @@ -312,11 +312,12 @@ func (IBCModule) OnChanUpgradeOpen(ctx sdk.Context, portID, channelID string, pr // UnmarshalPacketData attempts to unmarshal the provided packet data bytes // into a FungibleTokenPacketData. This function implements the optional // PacketDataUnmarshaler interface required for ADR 008 support. -func (im IBCModule) UnmarshalPacketData(ctx sdk.Context, portID, channelID string, bz []byte) (interface{}, error) { +func (im IBCModule) UnmarshalPacketData(ctx sdk.Context, portID string, channelID string, bz []byte) (interface{}, string, error) { ics20Version, found := im.keeper.GetICS4Wrapper().GetAppVersion(ctx, portID, channelID) if !found { - return types.FungibleTokenPacketDataV2{}, errorsmod.Wrapf(ibcerrors.ErrNotFound, "app version not found for port %s and channel %s", portID, channelID) + return types.FungibleTokenPacketDataV2{}, "", errorsmod.Wrapf(ibcerrors.ErrNotFound, "app version not found for port %s and channel %s", portID, channelID) } - return types.UnmarshalPacketData(bz, ics20Version) + ftpd, err := types.UnmarshalPacketData(bz, ics20Version) + return ftpd, ics20Version, err } diff --git a/modules/apps/transfer/ibc_module_test.go b/modules/apps/transfer/ibc_module_test.go index 4dd4a505fd5..ce0d3583b01 100644 --- a/modules/apps/transfer/ibc_module_test.go +++ b/modules/apps/transfer/ibc_module_test.go @@ -889,7 +889,7 @@ func (suite *TransferTestSuite) TestPacketDataUnmarshalerInterface() { unmarshalerStack, ok := transferStack.(porttypes.PacketDataUnmarshaler) suite.Require().True(ok) - packetData, err := unmarshalerStack.UnmarshalPacketData(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, data) + packetData, _, err := unmarshalerStack.UnmarshalPacketData(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, data) expPass := tc.expError == nil if expPass { diff --git a/modules/core/05-port/types/module.go b/modules/core/05-port/types/module.go index 8b2ccf94248..d1afbf5820e 100644 --- a/modules/core/05-port/types/module.go +++ b/modules/core/05-port/types/module.go @@ -199,5 +199,5 @@ type PacketDataUnmarshaler interface { // UnmarshalPacketData unmarshals the packet data into a concrete type // ctx, portID, channelID are provided as arguments, so that (if needed) // the packet data can be unmarshaled based on the channel version. - UnmarshalPacketData(ctx sdk.Context, portID, channelID string, bz []byte) (interface{}, error) + UnmarshalPacketData(ctx sdk.Context, portID string, channelID string, bz []byte) (interface{}, string, error) } diff --git a/testing/mock/ibc_module.go b/testing/mock/ibc_module.go index c698c05d1bd..03c21ffce4a 100644 --- a/testing/mock/ibc_module.go +++ b/testing/mock/ibc_module.go @@ -219,11 +219,11 @@ func (im IBCModule) OnChanUpgradeOpen(ctx sdk.Context, portID, channelID string, // UnmarshalPacketData returns the MockPacketData. This function implements the optional // PacketDataUnmarshaler interface required for ADR 008 support. -func (IBCModule) UnmarshalPacketData(_ sdk.Context, _, _ string, bz []byte) (interface{}, error) { +func (IBCModule) UnmarshalPacketData(ctx sdk.Context, portID string, channelID string, bz []byte) (interface{}, string, error) { if reflect.DeepEqual(bz, MockPacketData) { - return MockPacketData, nil + return MockPacketData, Version, nil } - return nil, MockApplicationCallbackError + return nil, "", MockApplicationCallbackError } // GetMockRecvCanaryCapabilityName generates a capability name for testing OnRecvPacket functionality. From 1f360b7977d1f7b315e13927206281790bb9de45 Mon Sep 17 00:00:00 2001 From: chatton Date: Tue, 30 Jul 2024 15:21:51 +0100 Subject: [PATCH 02/14] chore: addressing PR feedback --- modules/apps/callbacks/ibc_middleware_test.go | 6 ++++-- modules/apps/transfer/ibc_module_test.go | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/apps/callbacks/ibc_middleware_test.go b/modules/apps/callbacks/ibc_middleware_test.go index 6794450a078..46aab6ed33c 100644 --- a/modules/apps/callbacks/ibc_middleware_test.go +++ b/modules/apps/callbacks/ibc_middleware_test.go @@ -1027,8 +1027,9 @@ func (s *CallbacksTestSuite) TestUnmarshalPacketDataV1() { // Unmarshal ICS20 v1 packet data into v2 packet data data := expPacketDataICS20V1.GetBytes() - packetData, _, err := unmarshalerStack.UnmarshalPacketData(s.chainA.GetContext(), portID, channelID, data) + packetData, version, err := unmarshalerStack.UnmarshalPacketData(s.chainA.GetContext(), portID, channelID, data) s.Require().NoError(err) + s.Require().Equal(s.path.EndpointA.ChannelConfig.Version, version) s.Require().Equal(expPacketDataICS20V2, packetData) } @@ -1060,9 +1061,10 @@ func (s *CallbacksTestSuite) TestUnmarshalPacketDataV2() { // Unmarshal ICS20 v2 packet data data := expPacketDataICS20V2.GetBytes() - packetData, _, err := unmarshalerStack.UnmarshalPacketData(s.chainA.GetContext(), portID, channelID, data) + packetData, version, err := unmarshalerStack.UnmarshalPacketData(s.chainA.GetContext(), portID, channelID, data) s.Require().NoError(err) s.Require().Equal(expPacketDataICS20V2, packetData) + s.Require().Equal(s.path.EndpointA.ChannelConfig.Version, version) } func (s *CallbacksTestSuite) TestGetAppVersion() { diff --git a/modules/apps/transfer/ibc_module_test.go b/modules/apps/transfer/ibc_module_test.go index ce0d3583b01..0a22a96e8bd 100644 --- a/modules/apps/transfer/ibc_module_test.go +++ b/modules/apps/transfer/ibc_module_test.go @@ -889,7 +889,7 @@ func (suite *TransferTestSuite) TestPacketDataUnmarshalerInterface() { unmarshalerStack, ok := transferStack.(porttypes.PacketDataUnmarshaler) suite.Require().True(ok) - packetData, _, err := unmarshalerStack.UnmarshalPacketData(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, data) + packetData, version, err := unmarshalerStack.UnmarshalPacketData(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, data) expPass := tc.expError == nil if expPass { @@ -897,6 +897,7 @@ func (suite *TransferTestSuite) TestPacketDataUnmarshalerInterface() { v2PacketData, ok := packetData.(types.FungibleTokenPacketDataV2) suite.Require().True(ok) + suite.Require().Equal(path.EndpointA.ChannelConfig.Version, version) if v1PacketData, ok := initialPacketData.(types.FungibleTokenPacketData); ok { // Note: testing of the denom trace parsing/conversion should be done as part of testing internal conversion functions From d83c17c7f7e4a694ecb64553850b7a6849d0fb1e Mon Sep 17 00:00:00 2001 From: chatton Date: Tue, 30 Jul 2024 16:39:20 +0100 Subject: [PATCH 03/14] chore: adding application version to callback data --- modules/apps/callbacks/types/callbacks.go | 25 ++- .../apps/callbacks/types/callbacks_test.go | 197 +++++++++++------- modules/apps/callbacks/types/export_test.go | 4 +- 3 files changed, 132 insertions(+), 94 deletions(-) diff --git a/modules/apps/callbacks/types/callbacks.go b/modules/apps/callbacks/types/callbacks.go index 7d107db1a0f..0137a365241 100644 --- a/modules/apps/callbacks/types/callbacks.go +++ b/modules/apps/callbacks/types/callbacks.go @@ -66,6 +66,8 @@ type CallbackData struct { // execution fails due to out of gas. // This parameter is only used in event emissions, or logging. CommitGasLimit uint64 + // ApplicationVersion is the base application version. + ApplicationVersion string } // GetSourceCallbackData parses the packet data and returns the source callback data. @@ -75,12 +77,12 @@ func GetSourceCallbackData( packet channeltypes.Packet, maxGas uint64, ) (CallbackData, error) { - packetData, _, err := packetDataUnmarshaler.UnmarshalPacketData(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetData()) + packetData, version, err := packetDataUnmarshaler.UnmarshalPacketData(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetData()) if err != nil { return CallbackData{}, errorsmod.Wrap(ErrCannotUnmarshalPacketData, err.Error()) } - return getCallbackData(packetData, packet.GetSourcePort(), ctx.GasMeter().GasRemaining(), maxGas, SourceCallbackKey) + return getCallbackData(packetData, version, packet.GetSourcePort(), ctx.GasMeter().GasRemaining(), maxGas, SourceCallbackKey) } // GetDestCallbackData parses the packet data and returns the destination callback data. @@ -89,12 +91,12 @@ func GetDestCallbackData( packetDataUnmarshaler porttypes.PacketDataUnmarshaler, packet channeltypes.Packet, maxGas uint64, ) (CallbackData, error) { - packetData, _, err := packetDataUnmarshaler.UnmarshalPacketData(ctx, packet.GetDestPort(), packet.GetDestChannel(), packet.GetData()) + packetData, version, err := packetDataUnmarshaler.UnmarshalPacketData(ctx, packet.GetDestPort(), packet.GetDestChannel(), packet.GetData()) if err != nil { return CallbackData{}, errorsmod.Wrap(ErrCannotUnmarshalPacketData, err.Error()) } - return getCallbackData(packetData, packet.GetSourcePort(), ctx.GasMeter().GasRemaining(), maxGas, DestinationCallbackKey) + return getCallbackData(packetData, version, packet.GetSourcePort(), ctx.GasMeter().GasRemaining(), maxGas, DestinationCallbackKey) } // getCallbackData parses the packet data and returns the callback data. @@ -103,9 +105,9 @@ func GetDestCallbackData( // address and gas limit from the callback data. func getCallbackData( packetData interface{}, - srcPortID string, - remainingGas, - maxGas uint64, callbackKey string, + version, srcPortID string, + remainingGas, maxGas uint64, + callbackKey string, ) (CallbackData, error) { packetDataProvider, ok := packetData.(ibcexported.PacketDataProvider) if !ok { @@ -136,10 +138,11 @@ func getCallbackData( executionGasLimit, commitGasLimit := computeExecAndCommitGasLimit(callbackData, remainingGas, maxGas) return CallbackData{ - CallbackAddress: callbackAddress, - ExecutionGasLimit: executionGasLimit, - SenderAddress: packetSender, - CommitGasLimit: commitGasLimit, + CallbackAddress: callbackAddress, + ExecutionGasLimit: executionGasLimit, + SenderAddress: packetSender, + CommitGasLimit: commitGasLimit, + ApplicationVersion: version, }, nil } diff --git a/modules/apps/callbacks/types/callbacks_test.go b/modules/apps/callbacks/types/callbacks_test.go index cd9c67bd64b..735e7316ed3 100644 --- a/modules/apps/callbacks/types/callbacks_test.go +++ b/modules/apps/callbacks/types/callbacks_test.go @@ -25,6 +25,7 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { packetData interface{} remainingGas uint64 callbackKey string + version string ) // max gas is 1_000_000 @@ -38,6 +39,7 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { "success: source callback", func() { remainingGas = 2_000_000 + version = transfertypes.V1 packetData = transfertypes.FungibleTokenPacketData{ Denom: ibctesting.TestCoin.Denom, Amount: ibctesting.TestCoin.Amount.String(), @@ -47,10 +49,11 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { } }, types.CallbackData{ - CallbackAddress: sender, - SenderAddress: sender, - ExecutionGasLimit: 1_000_000, - CommitGasLimit: 1_000_000, + CallbackAddress: sender, + SenderAddress: sender, + ExecutionGasLimit: 1_000_000, + CommitGasLimit: 1_000_000, + ApplicationVersion: transfertypes.V1, }, nil, }, @@ -58,6 +61,7 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { "success: destination callback", func() { callbackKey = types.DestinationCallbackKey + version = transfertypes.V1 remainingGas = 2_000_000 packetData = transfertypes.FungibleTokenPacketData{ @@ -69,10 +73,11 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { } }, types.CallbackData{ - CallbackAddress: sender, - SenderAddress: "", - ExecutionGasLimit: 1_000_000, - CommitGasLimit: 1_000_000, + CallbackAddress: sender, + SenderAddress: "", + ExecutionGasLimit: 1_000_000, + CommitGasLimit: 1_000_000, + ApplicationVersion: transfertypes.V1, }, nil, }, @@ -80,6 +85,7 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { "success: destination callback with 0 user defined gas limit", func() { callbackKey = types.DestinationCallbackKey + version = transfertypes.V1 remainingGas = 2_000_000 packetData = transfertypes.FungibleTokenPacketData{ @@ -91,16 +97,18 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { } }, types.CallbackData{ - CallbackAddress: sender, - SenderAddress: "", - ExecutionGasLimit: 1_000_000, - CommitGasLimit: 1_000_000, + CallbackAddress: sender, + SenderAddress: "", + ExecutionGasLimit: 1_000_000, + CommitGasLimit: 1_000_000, + ApplicationVersion: transfertypes.V1, }, nil, }, { "success: source callback with gas limit < remaining gas < max gas", func() { + version = transfertypes.V1 packetData = transfertypes.FungibleTokenPacketData{ Denom: ibctesting.TestCoin.Denom, Amount: ibctesting.TestCoin.Amount.String(), @@ -112,10 +120,11 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { remainingGas = 100_000 }, types.CallbackData{ - CallbackAddress: sender, - SenderAddress: sender, - ExecutionGasLimit: 50_000, - CommitGasLimit: 50_000, + CallbackAddress: sender, + SenderAddress: sender, + ExecutionGasLimit: 50_000, + CommitGasLimit: 50_000, + ApplicationVersion: transfertypes.V1, }, nil, }, @@ -123,6 +132,7 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { "success: source callback with remaining gas < gas limit < max gas", func() { remainingGas = 100_000 + version = transfertypes.V1 packetData = transfertypes.FungibleTokenPacketData{ Denom: ibctesting.TestCoin.Denom, Amount: ibctesting.TestCoin.Amount.String(), @@ -132,10 +142,11 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { } }, types.CallbackData{ - CallbackAddress: sender, - SenderAddress: sender, - ExecutionGasLimit: 100_000, - CommitGasLimit: 200_000, + CallbackAddress: sender, + SenderAddress: sender, + ExecutionGasLimit: 100_000, + CommitGasLimit: 200_000, + ApplicationVersion: transfertypes.V1, }, nil, }, @@ -143,6 +154,7 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { "success: source callback with remaining gas < max gas < gas limit", func() { remainingGas = 100_000 + version = transfertypes.V1 packetData = transfertypes.FungibleTokenPacketData{ Denom: ibctesting.TestCoin.Denom, Amount: ibctesting.TestCoin.Amount.String(), @@ -152,10 +164,11 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { } }, types.CallbackData{ - CallbackAddress: sender, - SenderAddress: sender, - ExecutionGasLimit: 100_000, - CommitGasLimit: 1_000_000, + CallbackAddress: sender, + SenderAddress: sender, + ExecutionGasLimit: 100_000, + CommitGasLimit: 1_000_000, + ApplicationVersion: transfertypes.V1, }, nil, }, @@ -163,6 +176,7 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { "success: destination callback with remaining gas < max gas < gas limit", func() { callbackKey = types.DestinationCallbackKey + version = transfertypes.V1 remainingGas = 100_000 packetData = transfertypes.FungibleTokenPacketData{ @@ -174,10 +188,11 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { } }, types.CallbackData{ - CallbackAddress: sender, - SenderAddress: "", - ExecutionGasLimit: 100_000, - CommitGasLimit: 1_000_000, + CallbackAddress: sender, + SenderAddress: "", + ExecutionGasLimit: 100_000, + CommitGasLimit: 1_000_000, + ApplicationVersion: transfertypes.V1, }, nil, }, @@ -185,6 +200,7 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { "success: source callback with max gas < remaining gas < gas limit", func() { remainingGas = 2_000_000 + version = transfertypes.V1 packetData = transfertypes.FungibleTokenPacketData{ Denom: ibctesting.TestCoin.Denom, Amount: ibctesting.TestCoin.Amount.String(), @@ -194,10 +210,11 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { } }, types.CallbackData{ - CallbackAddress: sender, - SenderAddress: sender, - ExecutionGasLimit: 1_000_000, - CommitGasLimit: 1_000_000, + CallbackAddress: sender, + SenderAddress: sender, + ExecutionGasLimit: 1_000_000, + CommitGasLimit: 1_000_000, + ApplicationVersion: transfertypes.V1, }, nil, }, @@ -212,6 +229,7 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { { "failure: empty memo", func() { + version = transfertypes.V1 packetData = transfertypes.FungibleTokenPacketData{ Denom: ibctesting.TestCoin.Denom, Amount: ibctesting.TestCoin.Amount.String(), @@ -226,6 +244,7 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { { "failure: empty address", func() { + version = transfertypes.V1 packetData = transfertypes.FungibleTokenPacketData{ Denom: ibctesting.TestCoin.Denom, Amount: ibctesting.TestCoin.Amount.String(), @@ -240,6 +259,7 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { { "failure: space address", func() { + version = transfertypes.V1 packetData = transfertypes.FungibleTokenPacketData{ Denom: ibctesting.TestCoin.Denom, Amount: ibctesting.TestCoin.Amount.String(), @@ -256,6 +276,7 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { "success: source callback", func() { remainingGas = 2_000_000 + version = transfertypes.V1 packetData = transfertypes.FungibleTokenPacketData{ Denom: ibctesting.TestCoin.Denom, Amount: ibctesting.TestCoin.Amount.String(), @@ -265,10 +286,11 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { } }, types.CallbackData{ - CallbackAddress: sender, - SenderAddress: sender, - ExecutionGasLimit: 1_000_000, - CommitGasLimit: 1_000_000, + CallbackAddress: sender, + SenderAddress: sender, + ExecutionGasLimit: 1_000_000, + CommitGasLimit: 1_000_000, + ApplicationVersion: transfertypes.V1, }, nil, }, @@ -278,6 +300,7 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { callbackKey = types.DestinationCallbackKey remainingGas = 2_000_000 + version = transfertypes.V1 packetData = transfertypes.FungibleTokenPacketData{ Denom: ibctesting.TestCoin.Denom, Amount: ibctesting.TestCoin.Amount.String(), @@ -287,10 +310,11 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { } }, types.CallbackData{ - CallbackAddress: sender, - SenderAddress: "", - ExecutionGasLimit: 1_000_000, - CommitGasLimit: 1_000_000, + CallbackAddress: sender, + SenderAddress: "", + ExecutionGasLimit: 1_000_000, + CommitGasLimit: 1_000_000, + ApplicationVersion: transfertypes.V1, }, nil, }, @@ -313,10 +337,11 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { } }, types.CallbackData{ - CallbackAddress: sender, - SenderAddress: "", - ExecutionGasLimit: 1_000_000, - CommitGasLimit: 1_000_000, + CallbackAddress: sender, + SenderAddress: "", + ExecutionGasLimit: 1_000_000, + CommitGasLimit: 1_000_000, + ApplicationVersion: transfertypes.V2, }, nil, }, @@ -338,10 +363,11 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { remainingGas = 100_000 }, types.CallbackData{ - CallbackAddress: sender, - SenderAddress: sender, - ExecutionGasLimit: 50_000, - CommitGasLimit: 50_000, + CallbackAddress: sender, + SenderAddress: sender, + ExecutionGasLimit: 50_000, + CommitGasLimit: 50_000, + ApplicationVersion: transfertypes.V2, }, nil, }, @@ -362,10 +388,11 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { } }, types.CallbackData{ - CallbackAddress: sender, - SenderAddress: sender, - ExecutionGasLimit: 100_000, - CommitGasLimit: 200_000, + CallbackAddress: sender, + SenderAddress: sender, + ExecutionGasLimit: 100_000, + CommitGasLimit: 200_000, + ApplicationVersion: transfertypes.V2, }, nil, }, @@ -386,10 +413,11 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { } }, types.CallbackData{ - CallbackAddress: sender, - SenderAddress: sender, - ExecutionGasLimit: 100_000, - CommitGasLimit: 1_000_000, + CallbackAddress: sender, + SenderAddress: sender, + ExecutionGasLimit: 100_000, + CommitGasLimit: 1_000_000, + ApplicationVersion: transfertypes.V2, }, nil, }, @@ -412,10 +440,11 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { } }, types.CallbackData{ - CallbackAddress: sender, - SenderAddress: "", - ExecutionGasLimit: 100_000, - CommitGasLimit: 1_000_000, + CallbackAddress: sender, + SenderAddress: "", + ExecutionGasLimit: 100_000, + CommitGasLimit: 1_000_000, + ApplicationVersion: transfertypes.V2, }, nil, }, @@ -436,10 +465,11 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { } }, types.CallbackData{ - CallbackAddress: sender, - SenderAddress: sender, - ExecutionGasLimit: 1_000_000, - CommitGasLimit: 1_000_000, + CallbackAddress: sender, + SenderAddress: sender, + ExecutionGasLimit: 1_000_000, + CommitGasLimit: 1_000_000, + ApplicationVersion: transfertypes.V2, }, nil, }, @@ -513,10 +543,11 @@ func (s *CallbacksTypesTestSuite) TestGetCallbackData() { s.SetupTest() callbackKey = types.SourceCallbackKey + version = transfertypes.V2 tc.malleate() - callbackData, err := types.GetCallbackData(packetData, transfertypes.PortID, remainingGas, uint64(1_000_000), callbackKey) + callbackData, err := types.GetCallbackData(packetData, version, transfertypes.PortID, remainingGas, uint64(1_000_000), callbackKey) expPass := tc.expError == nil if expPass { @@ -557,10 +588,11 @@ func (s *CallbacksTypesTestSuite) TestGetSourceCallbackDataTransfer() { Memo: fmt.Sprintf(`{"src_callback": {"address": "%s"}}`, sender), }, types.CallbackData{ - CallbackAddress: sender, - SenderAddress: sender, - ExecutionGasLimit: 1_000_000, - CommitGasLimit: 1_000_000, + CallbackAddress: sender, + SenderAddress: sender, + ExecutionGasLimit: 1_000_000, + CommitGasLimit: 1_000_000, + ApplicationVersion: transfertypes.V1, }, func() { s.path.EndpointA.ChannelConfig.Version = transfertypes.V1 @@ -583,10 +615,11 @@ func (s *CallbacksTypesTestSuite) TestGetSourceCallbackDataTransfer() { Memo: fmt.Sprintf(`{"src_callback": {"address": "%s"}}`, sender), }, types.CallbackData{ - CallbackAddress: sender, - SenderAddress: sender, - ExecutionGasLimit: 1_000_000, - CommitGasLimit: 1_000_000, + CallbackAddress: sender, + SenderAddress: sender, + ExecutionGasLimit: 1_000_000, + CommitGasLimit: 1_000_000, + ApplicationVersion: transfertypes.V2, }, func() { s.path.EndpointA.ChannelConfig.Version = transfertypes.V2 @@ -644,10 +677,11 @@ func (s *CallbacksTypesTestSuite) TestGetDestCallbackDataTransfer() { Memo: fmt.Sprintf(`{"dest_callback": {"address": "%s"}}`, sender), }, types.CallbackData{ - CallbackAddress: sender, - SenderAddress: "", - ExecutionGasLimit: 1_000_000, - CommitGasLimit: 1_000_000, + CallbackAddress: sender, + SenderAddress: "", + ExecutionGasLimit: 1_000_000, + CommitGasLimit: 1_000_000, + ApplicationVersion: transfertypes.V1, }, func() { s.path.EndpointA.ChannelConfig.Version = transfertypes.V1 @@ -670,10 +704,11 @@ func (s *CallbacksTypesTestSuite) TestGetDestCallbackDataTransfer() { Memo: fmt.Sprintf(`{"dest_callback": {"address": "%s"}}`, sender), }, types.CallbackData{ - CallbackAddress: sender, - SenderAddress: "", - ExecutionGasLimit: 1_000_000, - CommitGasLimit: 1_000_000, + CallbackAddress: sender, + SenderAddress: "", + ExecutionGasLimit: 1_000_000, + CommitGasLimit: 1_000_000, + ApplicationVersion: transfertypes.V2, }, func() { s.path.EndpointA.ChannelConfig.Version = transfertypes.V2 diff --git a/modules/apps/callbacks/types/export_test.go b/modules/apps/callbacks/types/export_test.go index 4cc85624827..6d2434156cc 100644 --- a/modules/apps/callbacks/types/export_test.go +++ b/modules/apps/callbacks/types/export_test.go @@ -6,10 +6,10 @@ package types // GetCallbackData is a wrapper around getCallbackData to allow the function to be directly called in tests. func GetCallbackData( - packetData interface{}, srcPortID string, remainingGas, + packetData interface{}, version, srcPortID string, remainingGas, maxGas uint64, callbackKey string, ) (CallbackData, error) { - return getCallbackData(packetData, srcPortID, remainingGas, maxGas, callbackKey) + return getCallbackData(packetData, version, srcPortID, remainingGas, maxGas, callbackKey) } // GetCallbackAddress is a wrapper around getCallbackAddress to allow the function to be directly called in tests. From 54837addc6087d408a07278b1d4b95b4d1b02f25 Mon Sep 17 00:00:00 2001 From: chatton Date: Tue, 30 Jul 2024 16:50:27 +0100 Subject: [PATCH 04/14] chore: adding version as additional field in contract keeper interface functions --- modules/apps/callbacks/fee_transfer_test.go | 1 + modules/apps/callbacks/ibc_middleware.go | 10 +++--- modules/apps/callbacks/replay_test.go | 8 ++--- .../testing/simapp/contract_keeper.go | 32 ++++++++++++------- .../apps/callbacks/types/expected_keepers.go | 4 +++ 5 files changed, 34 insertions(+), 21 deletions(-) diff --git a/modules/apps/callbacks/fee_transfer_test.go b/modules/apps/callbacks/fee_transfer_test.go index 9e9e9eb62f8..44e342143b9 100644 --- a/modules/apps/callbacks/fee_transfer_test.go +++ b/modules/apps/callbacks/fee_transfer_test.go @@ -115,6 +115,7 @@ func (s *CallbacksTestSuite) TestIncentivizedTransferCallbacks() { _ sdk.AccAddress, contractAddress, _ string, + _ string, ) error { expAck := channeltypes.NewResultAcknowledgement([]byte{byte(1)}).Acknowledgement() s.Require().Equal(expAck, acknowledgement) diff --git a/modules/apps/callbacks/ibc_middleware.go b/modules/apps/callbacks/ibc_middleware.go index f3cf521dd1b..2fb1065fb58 100644 --- a/modules/apps/callbacks/ibc_middleware.go +++ b/modules/apps/callbacks/ibc_middleware.go @@ -110,7 +110,7 @@ func (im IBCMiddleware) SendPacket( callbackExecutor := func(cachedCtx sdk.Context) error { return im.contractKeeper.IBCSendPacketCallback( - cachedCtx, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data, callbackData.CallbackAddress, callbackData.SenderAddress, + cachedCtx, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data, callbackData.CallbackAddress, callbackData.SenderAddress, callbackData.ApplicationVersion, ) } @@ -151,7 +151,7 @@ func (im IBCMiddleware) OnAcknowledgementPacket( callbackExecutor := func(cachedCtx sdk.Context) error { return im.contractKeeper.IBCOnAcknowledgementPacketCallback( - cachedCtx, packet, acknowledgement, relayer, callbackData.CallbackAddress, callbackData.SenderAddress, + cachedCtx, packet, acknowledgement, relayer, callbackData.CallbackAddress, callbackData.SenderAddress, callbackData.ApplicationVersion, ) } @@ -184,7 +184,7 @@ func (im IBCMiddleware) OnTimeoutPacket(ctx sdk.Context, channelVersion string, } callbackExecutor := func(cachedCtx sdk.Context) error { - return im.contractKeeper.IBCOnTimeoutPacketCallback(cachedCtx, packet, relayer, callbackData.CallbackAddress, callbackData.SenderAddress) + return im.contractKeeper.IBCOnTimeoutPacketCallback(cachedCtx, packet, relayer, callbackData.CallbackAddress, callbackData.SenderAddress, callbackData.ApplicationVersion) } // callback execution errors are not allowed to block the packet lifecycle, they are only used in event emissions @@ -220,7 +220,7 @@ func (im IBCMiddleware) OnRecvPacket(ctx sdk.Context, channelVersion string, pac } callbackExecutor := func(cachedCtx sdk.Context) error { - return im.contractKeeper.IBCReceivePacketCallback(cachedCtx, packet, ack, callbackData.CallbackAddress) + return im.contractKeeper.IBCReceivePacketCallback(cachedCtx, packet, ack, callbackData.CallbackAddress, callbackData.ApplicationVersion) } // callback execution errors are not allowed to block the packet lifecycle, they are only used in event emissions @@ -263,7 +263,7 @@ func (im IBCMiddleware) WriteAcknowledgement( } callbackExecutor := func(cachedCtx sdk.Context) error { - return im.contractKeeper.IBCReceivePacketCallback(cachedCtx, packet, ack, callbackData.CallbackAddress) + return im.contractKeeper.IBCReceivePacketCallback(cachedCtx, packet, ack, callbackData.CallbackAddress, callbackData.ApplicationVersion) } // callback execution errors are not allowed to block the packet lifecycle, they are only used in event emissions diff --git a/modules/apps/callbacks/replay_test.go b/modules/apps/callbacks/replay_test.go index 1f63d6791d8..f414f47f5f5 100644 --- a/modules/apps/callbacks/replay_test.go +++ b/modules/apps/callbacks/replay_test.go @@ -37,7 +37,7 @@ func (s *CallbacksTestSuite) TestTransferTimeoutReplayProtection() { cachedCtx sdk.Context, packet channeltypes.Packet, _ sdk.AccAddress, - _, _ string, + _, _, _ string, ) error { // only replay the timeout packet twice. We could replay it more times callbackCount++ @@ -119,7 +119,7 @@ func (s *CallbacksTestSuite) TestTransferErrorAcknowledgementReplayProtection() packet channeltypes.Packet, ack []byte, _ sdk.AccAddress, - _, _ string, + _, _, _ string, ) error { // only replay the ack packet twice. We could replay it more times callbackCount++ @@ -197,7 +197,7 @@ func (s *CallbacksTestSuite) TestTransferSuccessAcknowledgementReplayProtection( packet channeltypes.Packet, ack []byte, _ sdk.AccAddress, - _, _ string, + _, _, _ string, ) error { // only replay the ack packet twice. We could replay it more times callbackCount++ @@ -265,7 +265,7 @@ func (s *CallbacksTestSuite) TestTransferRecvPacketReplayProtection() { cachedCtx sdk.Context, packet ibcexported.PacketI, _ ibcexported.Acknowledgement, - _ string, + _, _ string, ) error { callbackCount++ if callbackCount == 2 { diff --git a/modules/apps/callbacks/testing/simapp/contract_keeper.go b/modules/apps/callbacks/testing/simapp/contract_keeper.go index d2ca9dba2c6..7835859c41e 100644 --- a/modules/apps/callbacks/testing/simapp/contract_keeper.go +++ b/modules/apps/callbacks/testing/simapp/contract_keeper.go @@ -56,6 +56,7 @@ type ContractKeeper struct { packetData []byte, contractAddress, packetSenderAddress string, + version string, ) error IBCOnAcknowledgementPacketCallbackFn func( @@ -65,6 +66,7 @@ type ContractKeeper struct { relayer sdk.AccAddress, contractAddress, packetSenderAddress string, + version string, ) error IBCOnTimeoutPacketCallbackFn func( @@ -73,6 +75,7 @@ type ContractKeeper struct { relayer sdk.AccAddress, contractAddress, packetSenderAddress string, + version string, ) error IBCReceivePacketCallbackFn func( @@ -80,6 +83,7 @@ type ContractKeeper struct { packet ibcexported.PacketI, ack ibcexported.Acknowledgement, contractAddress string, + version string, ) error } @@ -113,19 +117,19 @@ func NewContractKeeper(key storetypes.StoreKey) *ContractKeeper { Counters: make(map[callbacktypes.CallbackType]int), } - k.IBCSendPacketCallbackFn = func(ctx sdk.Context, _, _ string, _ clienttypes.Height, _ uint64, _ []byte, contractAddress, _ string) error { + k.IBCSendPacketCallbackFn = func(ctx sdk.Context, _, _ string, _ clienttypes.Height, _ uint64, _ []byte, contractAddress, _, _ string) error { return k.ProcessMockCallback(ctx, callbacktypes.CallbackTypeSendPacket, contractAddress) } - k.IBCOnAcknowledgementPacketCallbackFn = func(ctx sdk.Context, _ channeltypes.Packet, _ []byte, _ sdk.AccAddress, contractAddress, _ string) error { + k.IBCOnAcknowledgementPacketCallbackFn = func(ctx sdk.Context, _ channeltypes.Packet, _ []byte, _ sdk.AccAddress, contractAddress, _, _ string) error { return k.ProcessMockCallback(ctx, callbacktypes.CallbackTypeAcknowledgementPacket, contractAddress) } - k.IBCOnTimeoutPacketCallbackFn = func(ctx sdk.Context, _ channeltypes.Packet, _ sdk.AccAddress, contractAddress, _ string) error { + k.IBCOnTimeoutPacketCallbackFn = func(ctx sdk.Context, _ channeltypes.Packet, _ sdk.AccAddress, contractAddress, _, _ string) error { return k.ProcessMockCallback(ctx, callbacktypes.CallbackTypeTimeoutPacket, contractAddress) } - k.IBCReceivePacketCallbackFn = func(ctx sdk.Context, _ ibcexported.PacketI, _ ibcexported.Acknowledgement, contractAddress string) error { + k.IBCReceivePacketCallbackFn = func(ctx sdk.Context, _ ibcexported.PacketI, _ ibcexported.Acknowledgement, contractAddress, _ string) error { return k.ProcessMockCallback(ctx, callbacktypes.CallbackTypeReceivePacket, contractAddress) } @@ -147,9 +151,10 @@ func (k ContractKeeper) IBCSendPacketCallback( timeoutTimestamp uint64, packetData []byte, contractAddress, - packetSenderAddress string, + packetSenderAddress, + version string, ) error { - return k.IBCSendPacketCallbackFn(ctx, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, packetData, contractAddress, packetSenderAddress) + return k.IBCSendPacketCallbackFn(ctx, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, packetData, contractAddress, packetSenderAddress, version) } // IBCOnAcknowledgementPacketCallback increments the stateful entry counter and the acknowledgement_packet callback counter. @@ -165,9 +170,10 @@ func (k ContractKeeper) IBCOnAcknowledgementPacketCallback( acknowledgement []byte, relayer sdk.AccAddress, contractAddress, - packetSenderAddress string, + packetSenderAddress, + version string, ) error { - return k.IBCOnAcknowledgementPacketCallbackFn(ctx, packet, acknowledgement, relayer, contractAddress, packetSenderAddress) + return k.IBCOnAcknowledgementPacketCallbackFn(ctx, packet, acknowledgement, relayer, contractAddress, packetSenderAddress, version) } // IBCOnTimeoutPacketCallback increments the stateful entry counter and the timeout_packet callback counter. @@ -182,9 +188,10 @@ func (k ContractKeeper) IBCOnTimeoutPacketCallback( packet channeltypes.Packet, relayer sdk.AccAddress, contractAddress, - packetSenderAddress string, + packetSenderAddress, + version string, ) error { - return k.IBCOnTimeoutPacketCallbackFn(ctx, packet, relayer, contractAddress, packetSenderAddress) + return k.IBCOnTimeoutPacketCallbackFn(ctx, packet, relayer, contractAddress, packetSenderAddress, version) } // IBCReceivePacketCallback increments the stateful entry counter and the receive_packet callback counter. @@ -198,9 +205,10 @@ func (k ContractKeeper) IBCReceivePacketCallback( ctx sdk.Context, packet ibcexported.PacketI, ack ibcexported.Acknowledgement, - contractAddress string, + contractAddress, + version string, ) error { - return k.IBCReceivePacketCallbackFn(ctx, packet, ack, contractAddress) + return k.IBCReceivePacketCallbackFn(ctx, packet, ack, contractAddress, version) } // ProcessMockCallback processes a mock callback. diff --git a/modules/apps/callbacks/types/expected_keepers.go b/modules/apps/callbacks/types/expected_keepers.go index 16aa14938d6..28a49b8877a 100644 --- a/modules/apps/callbacks/types/expected_keepers.go +++ b/modules/apps/callbacks/types/expected_keepers.go @@ -31,6 +31,7 @@ type ContractKeeper interface { packetData []byte, contractAddress, packetSenderAddress string, + version string, ) error // IBCOnAcknowledgementPacketCallback is called in the source chain when a packet acknowledgement // is received. The packetSenderAddress is determined by the underlying module, and may be empty if @@ -50,6 +51,7 @@ type ContractKeeper interface { relayer sdk.AccAddress, contractAddress, packetSenderAddress string, + version string, ) error // IBCOnTimeoutPacketCallback is called in the source chain when a packet is not received before // the timeout height. The packetSenderAddress is determined by the underlying module, and may be @@ -68,6 +70,7 @@ type ContractKeeper interface { relayer sdk.AccAddress, contractAddress, packetSenderAddress string, + version string, ) error // IBCReceivePacketCallback is called in the destination chain when a packet acknowledgement is written. // The contract is expected to handle the callback within the user defined gas limit, and handle any errors, @@ -79,5 +82,6 @@ type ContractKeeper interface { packet ibcexported.PacketI, ack ibcexported.Acknowledgement, contractAddress string, + version string, ) error } From 69077d539fc41b170d3b9df5300dae1a8c0a891c Mon Sep 17 00:00:00 2001 From: chatton Date: Wed, 31 Jul 2024 09:52:46 +0100 Subject: [PATCH 05/14] docs: updating docs to include version argument --- docs/architecture/adr-008-app-caller-cbs.md | 9 ++++++--- .../docs/04-middleware/02-callbacks/03-interfaces.md | 12 ++++++++---- .../04-middleware/02-callbacks/03-interfaces.md | 12 ++++++++---- .../04-middleware/02-callbacks/03-interfaces.md | 12 ++++++++---- 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/docs/architecture/adr-008-app-caller-cbs.md b/docs/architecture/adr-008-app-caller-cbs.md index 7e9971b4069..82d713619ec 100644 --- a/docs/architecture/adr-008-app-caller-cbs.md +++ b/docs/architecture/adr-008-app-caller-cbs.md @@ -212,7 +212,8 @@ type ContractKeeper interface { acknowledgement []byte, relayer sdk.AccAddress, contractAddress, - packetSenderAddress string, + packetSenderAddress, + version string, ) error // IBCOnTimeoutPacketCallback is called in the source chain when a packet is not received before // the timeout height. The packetSenderAddress is determined by the underlying module, and may be @@ -230,7 +231,8 @@ type ContractKeeper interface { packet channeltypes.Packet, relayer sdk.AccAddress, contractAddress, - packetSenderAddress string, + packetSenderAddress, + version string, ) error // IBCReceivePacketCallback is called in the destination chain when a packet acknowledgement is written. // The contract is expected to handle the callback within the user defined gas limit, and handle any errors, @@ -241,7 +243,8 @@ type ContractKeeper interface { cachedCtx sdk.Context, packet ibcexported.PacketI, ack ibcexported.Acknowledgement, - contractAddress string, + contractAddress, + version string, ) error } ``` diff --git a/docs/docs/04-middleware/02-callbacks/03-interfaces.md b/docs/docs/04-middleware/02-callbacks/03-interfaces.md index 6ec44417757..d16cf0becec 100644 --- a/docs/docs/04-middleware/02-callbacks/03-interfaces.md +++ b/docs/docs/04-middleware/02-callbacks/03-interfaces.md @@ -94,7 +94,8 @@ type ContractKeeper interface { timeoutTimestamp uint64, packetData []byte, contractAddress, - packetSenderAddress string, + packetSenderAddress, + version string, ) error // IBCOnAcknowledgementPacketCallback is called in the source chain when a packet acknowledgement // is received. The packetSenderAddress is determined by the underlying module, and may be empty if @@ -113,7 +114,8 @@ type ContractKeeper interface { acknowledgement []byte, relayer sdk.AccAddress, contractAddress, - packetSenderAddress string, + packetSenderAddress, + version string, ) error // IBCOnTimeoutPacketCallback is called in the source chain when a packet is not received before // the timeout height. The packetSenderAddress is determined by the underlying module, and may be @@ -131,7 +133,8 @@ type ContractKeeper interface { packet channeltypes.Packet, relayer sdk.AccAddress, contractAddress, - packetSenderAddress string, + packetSenderAddress, + version string, ) error // IBCReceivePacketCallback is called in the destination chain when a packet acknowledgement is written. // The contract is expected to handle the callback within the user defined gas limit, and handle any errors, @@ -142,7 +145,8 @@ type ContractKeeper interface { cachedCtx sdk.Context, packet ibcexported.PacketI, ack ibcexported.Acknowledgement, - contractAddress string, + contractAddress, + version string, ) error } ``` diff --git a/docs/versioned_docs/version-v7.7.x/04-middleware/02-callbacks/03-interfaces.md b/docs/versioned_docs/version-v7.7.x/04-middleware/02-callbacks/03-interfaces.md index 566e4ebb4e2..8da1b7c2246 100644 --- a/docs/versioned_docs/version-v7.7.x/04-middleware/02-callbacks/03-interfaces.md +++ b/docs/versioned_docs/version-v7.7.x/04-middleware/02-callbacks/03-interfaces.md @@ -91,7 +91,8 @@ type ContractKeeper interface { timeoutTimestamp uint64, packetData []byte, contractAddress, - packetSenderAddress string, + packetSenderAddress, + version string, ) error // IBCOnAcknowledgementPacketCallback is called in the source chain when a packet acknowledgement // is received. The packetSenderAddress is determined by the underlying module, and may be empty if @@ -110,7 +111,8 @@ type ContractKeeper interface { acknowledgement []byte, relayer sdk.AccAddress, contractAddress, - packetSenderAddress string, + packetSenderAddress, + version string, ) error // IBCOnTimeoutPacketCallback is called in the source chain when a packet is not received before // the timeout height. The packetSenderAddress is determined by the underlying module, and may be @@ -128,7 +130,8 @@ type ContractKeeper interface { packet channeltypes.Packet, relayer sdk.AccAddress, contractAddress, - packetSenderAddress string, + packetSenderAddress, + version string, ) error // IBCReceivePacketCallback is called in the destination chain when a packet acknowledgement is written. // The contract is expected to handle the callback within the user defined gas limit, and handle any errors, @@ -139,7 +142,8 @@ type ContractKeeper interface { cachedCtx sdk.Context, packet ibcexported.PacketI, ack ibcexported.Acknowledgement, - contractAddress string, + contractAddress, + version string, ) error } ``` diff --git a/docs/versioned_docs/version-v8.4.x/04-middleware/02-callbacks/03-interfaces.md b/docs/versioned_docs/version-v8.4.x/04-middleware/02-callbacks/03-interfaces.md index 566e4ebb4e2..8da1b7c2246 100644 --- a/docs/versioned_docs/version-v8.4.x/04-middleware/02-callbacks/03-interfaces.md +++ b/docs/versioned_docs/version-v8.4.x/04-middleware/02-callbacks/03-interfaces.md @@ -91,7 +91,8 @@ type ContractKeeper interface { timeoutTimestamp uint64, packetData []byte, contractAddress, - packetSenderAddress string, + packetSenderAddress, + version string, ) error // IBCOnAcknowledgementPacketCallback is called in the source chain when a packet acknowledgement // is received. The packetSenderAddress is determined by the underlying module, and may be empty if @@ -110,7 +111,8 @@ type ContractKeeper interface { acknowledgement []byte, relayer sdk.AccAddress, contractAddress, - packetSenderAddress string, + packetSenderAddress, + version string, ) error // IBCOnTimeoutPacketCallback is called in the source chain when a packet is not received before // the timeout height. The packetSenderAddress is determined by the underlying module, and may be @@ -128,7 +130,8 @@ type ContractKeeper interface { packet channeltypes.Packet, relayer sdk.AccAddress, contractAddress, - packetSenderAddress string, + packetSenderAddress, + version string, ) error // IBCReceivePacketCallback is called in the destination chain when a packet acknowledgement is written. // The contract is expected to handle the callback within the user defined gas limit, and handle any errors, @@ -139,7 +142,8 @@ type ContractKeeper interface { cachedCtx sdk.Context, packet ibcexported.PacketI, ack ibcexported.Acknowledgement, - contractAddress string, + contractAddress, + version string, ) error } ``` From 9d9b149293d3fbc64981c8357d9763f0cc5397ff Mon Sep 17 00:00:00 2001 From: chatton Date: Wed, 31 Jul 2024 09:56:01 +0100 Subject: [PATCH 06/14] docs: updating changelog to include note about callbacks version argument --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0dc1dec2208..3fdf8278705 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -76,6 +76,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (light-clients/06-solomachine) [\#6888](https://github.com/cosmos/ibc-go/pull/6888) Remove `TypeClientMisbehaviour` constant and the `Type` method on `Misbehaviour`. * (light-clients/06-solomachine, light-clients/07-tendermint) [\#6891](https://github.com/cosmos/ibc-go/pull/6891) The `VerifyMembership` and `VerifyNonMembership` functions of solomachine's `ClientState` have been made private. The `VerifyMembership`, `VerifyNonMembership`, `GetTimestampAtHeight`, `Status` and `Initialize` functions of tendermint's `ClientState` have been made private. * (core/04-channel) [\#6902](https://github.com/cosmos/ibc-go/pull/6902) Add channel version to core application callbacks. +* (apps/callbacks) [\#7000](https://github.com/cosmos/ibc-go/pull/7000) Add base application version to contract keeper callbacks. ### State Machine Breaking From 21bc83be0b74ba64827e07227233b5614b56e5b5 Mon Sep 17 00:00:00 2001 From: chatton Date: Wed, 31 Jul 2024 10:08:09 +0100 Subject: [PATCH 07/14] chore: adding application version to emmited events --- modules/apps/callbacks/types/events.go | 4 +- modules/apps/callbacks/types/events_test.go | 49 +++++++++++++-------- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/modules/apps/callbacks/types/events.go b/modules/apps/callbacks/types/events.go index b05fc96faa8..f7c5a772afa 100644 --- a/modules/apps/callbacks/types/events.go +++ b/modules/apps/callbacks/types/events.go @@ -42,7 +42,8 @@ const ( AttributeKeyCallbackDestChannelID = "packet_dest_channel" // AttributeKeyCallbackSequence denotes the sequence of the packet AttributeKeyCallbackSequence = "packet_sequence" - + // AttributeKeyCallbackBaseApplicationVersion denotes the callback base application version + AttributeKeyCallbackBaseApplicationVersion = "callback_base_application_version" // AttributeValueCallbackSuccess denotes that the callback is successfully executed AttributeValueCallbackSuccess = "success" // AttributeValueCallbackFailure denotes that the callback has failed to execute @@ -66,6 +67,7 @@ func EmitCallbackEvent( sdk.NewAttribute(AttributeKeyCallbackGasLimit, fmt.Sprintf("%d", callbackData.ExecutionGasLimit)), sdk.NewAttribute(AttributeKeyCallbackCommitGasLimit, fmt.Sprintf("%d", callbackData.CommitGasLimit)), sdk.NewAttribute(AttributeKeyCallbackSequence, fmt.Sprintf("%d", sequence)), + sdk.NewAttribute(AttributeKeyCallbackBaseApplicationVersion, callbackData.ApplicationVersion), } if err == nil { attributes = append(attributes, sdk.NewAttribute(AttributeKeyCallbackResult, AttributeValueCallbackSuccess)) diff --git a/modules/apps/callbacks/types/events_test.go b/modules/apps/callbacks/types/events_test.go index e0dab1bcecd..ae4ec7deaad 100644 --- a/modules/apps/callbacks/types/events_test.go +++ b/modules/apps/callbacks/types/events_test.go @@ -6,6 +6,7 @@ import ( abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/ibc-go/modules/apps/callbacks/types" + transfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/v9/testing" @@ -28,9 +29,10 @@ func (s *CallbacksTypesTestSuite) TestEvents() { ), types.CallbackTypeAcknowledgementPacket, types.CallbackData{ - CallbackAddress: ibctesting.TestAccAddress, - ExecutionGasLimit: 100_000, - CommitGasLimit: 200_000, + CallbackAddress: ibctesting.TestAccAddress, + ExecutionGasLimit: 100_000, + CommitGasLimit: 200_000, + ApplicationVersion: transfertypes.V1, }, nil, func() []abci.Event { @@ -46,6 +48,7 @@ func (s *CallbacksTypesTestSuite) TestEvents() { sdk.NewAttribute(types.AttributeKeyCallbackSourceChannelID, ibctesting.FirstChannelID), sdk.NewAttribute(types.AttributeKeyCallbackSequence, "1"), sdk.NewAttribute(types.AttributeKeyCallbackResult, types.AttributeValueCallbackSuccess), + sdk.NewAttribute(types.AttributeKeyCallbackBaseApplicationVersion, transfertypes.V1), ), }.ToABCIEvents() }, @@ -58,9 +61,10 @@ func (s *CallbacksTypesTestSuite) TestEvents() { ), types.CallbackTypeSendPacket, types.CallbackData{ - CallbackAddress: ibctesting.TestAccAddress, - ExecutionGasLimit: 100_000, - CommitGasLimit: 200_000, + CallbackAddress: ibctesting.TestAccAddress, + ExecutionGasLimit: 100_000, + CommitGasLimit: 200_000, + ApplicationVersion: transfertypes.V2, }, nil, func() []abci.Event { @@ -76,6 +80,7 @@ func (s *CallbacksTypesTestSuite) TestEvents() { sdk.NewAttribute(types.AttributeKeyCallbackSourceChannelID, ibctesting.FirstChannelID), sdk.NewAttribute(types.AttributeKeyCallbackSequence, "1"), sdk.NewAttribute(types.AttributeKeyCallbackResult, types.AttributeValueCallbackSuccess), + sdk.NewAttribute(types.AttributeKeyCallbackBaseApplicationVersion, transfertypes.V2), ), }.ToABCIEvents() }, @@ -88,9 +93,10 @@ func (s *CallbacksTypesTestSuite) TestEvents() { ), types.CallbackTypeTimeoutPacket, types.CallbackData{ - CallbackAddress: ibctesting.TestAccAddress, - ExecutionGasLimit: 100_000, - CommitGasLimit: 200_000, + CallbackAddress: ibctesting.TestAccAddress, + ExecutionGasLimit: 100_000, + CommitGasLimit: 200_000, + ApplicationVersion: transfertypes.V1, }, nil, func() []abci.Event { @@ -106,6 +112,7 @@ func (s *CallbacksTypesTestSuite) TestEvents() { sdk.NewAttribute(types.AttributeKeyCallbackSourceChannelID, ibctesting.FirstChannelID), sdk.NewAttribute(types.AttributeKeyCallbackSequence, "1"), sdk.NewAttribute(types.AttributeKeyCallbackResult, types.AttributeValueCallbackSuccess), + sdk.NewAttribute(types.AttributeKeyCallbackBaseApplicationVersion, transfertypes.V1), ), }.ToABCIEvents() }, @@ -118,9 +125,10 @@ func (s *CallbacksTypesTestSuite) TestEvents() { ), types.CallbackTypeReceivePacket, types.CallbackData{ - CallbackAddress: ibctesting.TestAccAddress, - ExecutionGasLimit: 100_000, - CommitGasLimit: 200_000, + CallbackAddress: ibctesting.TestAccAddress, + ExecutionGasLimit: 100_000, + CommitGasLimit: 200_000, + ApplicationVersion: transfertypes.V1, }, nil, func() []abci.Event { @@ -136,6 +144,7 @@ func (s *CallbacksTypesTestSuite) TestEvents() { sdk.NewAttribute(types.AttributeKeyCallbackDestChannelID, ibctesting.InvalidID), sdk.NewAttribute(types.AttributeKeyCallbackSequence, "1"), sdk.NewAttribute(types.AttributeKeyCallbackResult, types.AttributeValueCallbackSuccess), + sdk.NewAttribute(types.AttributeKeyCallbackBaseApplicationVersion, transfertypes.V1), ), }.ToABCIEvents() }, @@ -148,9 +157,10 @@ func (s *CallbacksTypesTestSuite) TestEvents() { ), "something", types.CallbackData{ - CallbackAddress: ibctesting.TestAccAddress, - ExecutionGasLimit: 100_000, - CommitGasLimit: 200_000, + CallbackAddress: ibctesting.TestAccAddress, + ExecutionGasLimit: 100_000, + CommitGasLimit: 200_000, + ApplicationVersion: transfertypes.V1, }, nil, func() []abci.Event { @@ -166,6 +176,7 @@ func (s *CallbacksTypesTestSuite) TestEvents() { sdk.NewAttribute(types.AttributeKeyCallbackSourceChannelID, ibctesting.FirstChannelID), sdk.NewAttribute(types.AttributeKeyCallbackSequence, "1"), sdk.NewAttribute(types.AttributeKeyCallbackResult, types.AttributeValueCallbackSuccess), + sdk.NewAttribute(types.AttributeKeyCallbackBaseApplicationVersion, transfertypes.V1), ), }.ToABCIEvents() }, @@ -178,9 +189,10 @@ func (s *CallbacksTypesTestSuite) TestEvents() { ), types.CallbackTypeAcknowledgementPacket, types.CallbackData{ - CallbackAddress: ibctesting.TestAccAddress, - ExecutionGasLimit: 100_000, - CommitGasLimit: 200_000, + CallbackAddress: ibctesting.TestAccAddress, + ExecutionGasLimit: 100_000, + CommitGasLimit: 200_000, + ApplicationVersion: transfertypes.V1, }, types.ErrNotPacketDataProvider, func() []abci.Event { @@ -197,6 +209,7 @@ func (s *CallbacksTypesTestSuite) TestEvents() { sdk.NewAttribute(types.AttributeKeyCallbackSequence, "1"), sdk.NewAttribute(types.AttributeKeyCallbackResult, types.AttributeValueCallbackFailure), sdk.NewAttribute(types.AttributeKeyCallbackError, types.ErrNotPacketDataProvider.Error()), + sdk.NewAttribute(types.AttributeKeyCallbackBaseApplicationVersion, transfertypes.V1), ), }.ToABCIEvents() }, From 880fb939be7cf9a93469e80411bb764ac5698858 Mon Sep 17 00:00:00 2001 From: chatton Date: Wed, 31 Jul 2024 10:12:39 +0100 Subject: [PATCH 08/14] docs: fix spacing --- docs/docs/04-middleware/02-callbacks/03-interfaces.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/04-middleware/02-callbacks/03-interfaces.md b/docs/docs/04-middleware/02-callbacks/03-interfaces.md index d16cf0becec..5cbf0d414f6 100644 --- a/docs/docs/04-middleware/02-callbacks/03-interfaces.md +++ b/docs/docs/04-middleware/02-callbacks/03-interfaces.md @@ -95,7 +95,7 @@ type ContractKeeper interface { packetData []byte, contractAddress, packetSenderAddress, - version string, + version string, ) error // IBCOnAcknowledgementPacketCallback is called in the source chain when a packet acknowledgement // is received. The packetSenderAddress is determined by the underlying module, and may be empty if @@ -146,7 +146,7 @@ type ContractKeeper interface { packet ibcexported.PacketI, ack ibcexported.Acknowledgement, contractAddress, - version string, + version string, ) error } ``` From bcdccad0b3f8fac566988f69e9ffb7a0c26c3f58 Mon Sep 17 00:00:00 2001 From: chatton Date: Wed, 31 Jul 2024 10:13:32 +0100 Subject: [PATCH 09/14] docs: fix spacing --- docs/architecture/adr-008-app-caller-cbs.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/architecture/adr-008-app-caller-cbs.md b/docs/architecture/adr-008-app-caller-cbs.md index 82d713619ec..312f98f3627 100644 --- a/docs/architecture/adr-008-app-caller-cbs.md +++ b/docs/architecture/adr-008-app-caller-cbs.md @@ -213,7 +213,7 @@ type ContractKeeper interface { relayer sdk.AccAddress, contractAddress, packetSenderAddress, - version string, + version string, ) error // IBCOnTimeoutPacketCallback is called in the source chain when a packet is not received before // the timeout height. The packetSenderAddress is determined by the underlying module, and may be @@ -232,7 +232,7 @@ type ContractKeeper interface { relayer sdk.AccAddress, contractAddress, packetSenderAddress, - version string, + version string, ) error // IBCReceivePacketCallback is called in the destination chain when a packet acknowledgement is written. // The contract is expected to handle the callback within the user defined gas limit, and handle any errors, From 02b2d7519c3bf8ad00c0b711702596ff30bae04d Mon Sep 17 00:00:00 2001 From: chatton Date: Wed, 31 Jul 2024 10:14:10 +0100 Subject: [PATCH 10/14] docs: fix spacing --- .../version-v8.4.x/04-middleware/02-callbacks/03-interfaces.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/versioned_docs/version-v8.4.x/04-middleware/02-callbacks/03-interfaces.md b/docs/versioned_docs/version-v8.4.x/04-middleware/02-callbacks/03-interfaces.md index 8da1b7c2246..0bd65e6e550 100644 --- a/docs/versioned_docs/version-v8.4.x/04-middleware/02-callbacks/03-interfaces.md +++ b/docs/versioned_docs/version-v8.4.x/04-middleware/02-callbacks/03-interfaces.md @@ -143,7 +143,7 @@ type ContractKeeper interface { packet ibcexported.PacketI, ack ibcexported.Acknowledgement, contractAddress, - version string, + version string, ) error } ``` From b0d5b00e60a05614f1ae43bb4f59ab0923a7cbc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Mon, 5 Aug 2024 11:17:49 +0200 Subject: [PATCH 11/14] chore: move changelog entry to callbacks module --- CHANGELOG.md | 1 - modules/apps/callbacks/CHANGELOG.md | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fdf8278705..0dc1dec2208 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -76,7 +76,6 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (light-clients/06-solomachine) [\#6888](https://github.com/cosmos/ibc-go/pull/6888) Remove `TypeClientMisbehaviour` constant and the `Type` method on `Misbehaviour`. * (light-clients/06-solomachine, light-clients/07-tendermint) [\#6891](https://github.com/cosmos/ibc-go/pull/6891) The `VerifyMembership` and `VerifyNonMembership` functions of solomachine's `ClientState` have been made private. The `VerifyMembership`, `VerifyNonMembership`, `GetTimestampAtHeight`, `Status` and `Initialize` functions of tendermint's `ClientState` have been made private. * (core/04-channel) [\#6902](https://github.com/cosmos/ibc-go/pull/6902) Add channel version to core application callbacks. -* (apps/callbacks) [\#7000](https://github.com/cosmos/ibc-go/pull/7000) Add base application version to contract keeper callbacks. ### State Machine Breaking diff --git a/modules/apps/callbacks/CHANGELOG.md b/modules/apps/callbacks/CHANGELOG.md index 507a19e93d1..8b76e98bda7 100644 --- a/modules/apps/callbacks/CHANGELOG.md +++ b/modules/apps/callbacks/CHANGELOG.md @@ -44,6 +44,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### API Breaking +* (apps/callbacks) [\#7000](https://github.com/cosmos/ibc-go/pull/7000) Add base application version to contract keeper callbacks. + ### State Machine Breaking ### Improvements From 2c902350dd7bc80e880a622ae24d0597fa15c2e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Mon, 5 Aug 2024 11:29:45 +0200 Subject: [PATCH 12/14] chore: update docs --- docs/architecture/adr-008-app-caller-cbs.md | 19 +++++++++++++++--- .../02-callbacks/03-interfaces.md | 20 +++++++++++++++---- .../02-callbacks/03-interfaces.md | 4 ---- .../02-callbacks/03-interfaces.md | 4 ---- .../apps/callbacks/types/expected_keepers.go | 12 +++++++++++ 5 files changed, 44 insertions(+), 15 deletions(-) diff --git a/docs/architecture/adr-008-app-caller-cbs.md b/docs/architecture/adr-008-app-caller-cbs.md index 312f98f3627..71e7261d45a 100644 --- a/docs/architecture/adr-008-app-caller-cbs.md +++ b/docs/architecture/adr-008-app-caller-cbs.md @@ -185,6 +185,9 @@ type ContractKeeper interface { // validation on the origin of a given packet. It is recommended to perform the same validation // on all source chain callbacks (SendPacket, AcknowledgementPacket, TimeoutPacket). This // defensively guards against exploits due to incorrectly wired SendPacket ordering in IBC stacks. + // + // The version provided is the base application version for the given packet send. This allows + // contracts to determine how to unmarshal the packetData. IBCSendPacketCallback( cachedCtx sdk.Context, sourcePort string, @@ -194,6 +197,7 @@ type ContractKeeper interface { packetData []byte, contractAddress, packetSenderAddress string, + version string, ) error // IBCOnAcknowledgementPacketCallback is called in the source chain when a packet acknowledgement // is received. The packetSenderAddress is determined by the underlying module, and may be empty if @@ -206,13 +210,16 @@ type ContractKeeper interface { // validation on the origin of a given packet. It is recommended to perform the same validation // on all source chain callbacks (SendPacket, AcknowledgementPacket, TimeoutPacket). This // defensively guards against exploits due to incorrectly wired SendPacket ordering in IBC stacks. + // + // The version provided is the base application version for the given packet send. This allows + // contracts to determine how to unmarshal the packetData. IBCOnAcknowledgementPacketCallback( cachedCtx sdk.Context, packet channeltypes.Packet, acknowledgement []byte, relayer sdk.AccAddress, contractAddress, - packetSenderAddress, + packetSenderAddress string, version string, ) error // IBCOnTimeoutPacketCallback is called in the source chain when a packet is not received before @@ -226,12 +233,15 @@ type ContractKeeper interface { // validation on the origin of a given packet. It is recommended to perform the same validation // on all source chain callbacks (SendPacket, AcknowledgementPacket, TimeoutPacket). This // defensively guards against exploits due to incorrectly wired SendPacket ordering in IBC stacks. + // + // The version provided is the base application version for the given packet send. This allows + // contracts to determine how to unmarshal the packetData. IBCOnTimeoutPacketCallback( cachedCtx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress, contractAddress, - packetSenderAddress, + packetSenderAddress string, version string, ) error // IBCReceivePacketCallback is called in the destination chain when a packet acknowledgement is written. @@ -239,11 +249,14 @@ type ContractKeeper interface { // out of gas, or panics gracefully. // This entry point is called with a cached context. If an error is returned, then the changes in // this context will not be persisted, but the packet lifecycle will not be blocked. + // + // The version provided is the base application version for the given packet send. This allows + // contracts to determine how to unmarshal the packetData. IBCReceivePacketCallback( cachedCtx sdk.Context, packet ibcexported.PacketI, ack ibcexported.Acknowledgement, - contractAddress, + contractAddress string, version string, ) error } diff --git a/docs/docs/04-middleware/02-callbacks/03-interfaces.md b/docs/docs/04-middleware/02-callbacks/03-interfaces.md index 5cbf0d414f6..9b7991d2cfd 100644 --- a/docs/docs/04-middleware/02-callbacks/03-interfaces.md +++ b/docs/docs/04-middleware/02-callbacks/03-interfaces.md @@ -86,6 +86,9 @@ type ContractKeeper interface { // validation on the origin of a given packet. It is recommended to perform the same validation // on all source chain callbacks (SendPacket, AcknowledgementPacket, TimeoutPacket). This // defensively guards against exploits due to incorrectly wired SendPacket ordering in IBC stacks. + // + // The version provided is the base application version for the given packet send. This allows + // contracts to determine how to unmarshal the packetData. IBCSendPacketCallback( cachedCtx sdk.Context, sourcePort string, @@ -94,7 +97,7 @@ type ContractKeeper interface { timeoutTimestamp uint64, packetData []byte, contractAddress, - packetSenderAddress, + packetSenderAddress string, version string, ) error // IBCOnAcknowledgementPacketCallback is called in the source chain when a packet acknowledgement @@ -108,13 +111,16 @@ type ContractKeeper interface { // validation on the origin of a given packet. It is recommended to perform the same validation // on all source chain callbacks (SendPacket, AcknowledgementPacket, TimeoutPacket). This // defensively guards against exploits due to incorrectly wired SendPacket ordering in IBC stacks. + // + // The version provided is the base application version for the given packet send. This allows + // contracts to determine how to unmarshal the packetData. IBCOnAcknowledgementPacketCallback( cachedCtx sdk.Context, packet channeltypes.Packet, acknowledgement []byte, relayer sdk.AccAddress, contractAddress, - packetSenderAddress, + packetSenderAddress string, version string, ) error // IBCOnTimeoutPacketCallback is called in the source chain when a packet is not received before @@ -128,12 +134,15 @@ type ContractKeeper interface { // validation on the origin of a given packet. It is recommended to perform the same validation // on all source chain callbacks (SendPacket, AcknowledgementPacket, TimeoutPacket). This // defensively guards against exploits due to incorrectly wired SendPacket ordering in IBC stacks. + // + // The version provided is the base application version for the given packet send. This allows + // contracts to determine how to unmarshal the packetData. IBCOnTimeoutPacketCallback( cachedCtx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress, contractAddress, - packetSenderAddress, + packetSenderAddress string, version string, ) error // IBCReceivePacketCallback is called in the destination chain when a packet acknowledgement is written. @@ -141,11 +150,14 @@ type ContractKeeper interface { // out of gas, or panics gracefully. // This entry point is called with a cached context. If an error is returned, then the changes in // this context will not be persisted, but the packet lifecycle will not be blocked. + // + // The version provided is the base application version for the given packet send. This allows + // contracts to determine how to unmarshal the packetData. IBCReceivePacketCallback( cachedCtx sdk.Context, packet ibcexported.PacketI, ack ibcexported.Acknowledgement, - contractAddress, + contractAddress string, version string, ) error } diff --git a/docs/versioned_docs/version-v7.7.x/04-middleware/02-callbacks/03-interfaces.md b/docs/versioned_docs/version-v7.7.x/04-middleware/02-callbacks/03-interfaces.md index 8da1b7c2246..b4f2d285534 100644 --- a/docs/versioned_docs/version-v7.7.x/04-middleware/02-callbacks/03-interfaces.md +++ b/docs/versioned_docs/version-v7.7.x/04-middleware/02-callbacks/03-interfaces.md @@ -92,7 +92,6 @@ type ContractKeeper interface { packetData []byte, contractAddress, packetSenderAddress, - version string, ) error // IBCOnAcknowledgementPacketCallback is called in the source chain when a packet acknowledgement // is received. The packetSenderAddress is determined by the underlying module, and may be empty if @@ -112,7 +111,6 @@ type ContractKeeper interface { relayer sdk.AccAddress, contractAddress, packetSenderAddress, - version string, ) error // IBCOnTimeoutPacketCallback is called in the source chain when a packet is not received before // the timeout height. The packetSenderAddress is determined by the underlying module, and may be @@ -131,7 +129,6 @@ type ContractKeeper interface { relayer sdk.AccAddress, contractAddress, packetSenderAddress, - version string, ) error // IBCReceivePacketCallback is called in the destination chain when a packet acknowledgement is written. // The contract is expected to handle the callback within the user defined gas limit, and handle any errors, @@ -143,7 +140,6 @@ type ContractKeeper interface { packet ibcexported.PacketI, ack ibcexported.Acknowledgement, contractAddress, - version string, ) error } ``` diff --git a/docs/versioned_docs/version-v8.4.x/04-middleware/02-callbacks/03-interfaces.md b/docs/versioned_docs/version-v8.4.x/04-middleware/02-callbacks/03-interfaces.md index 0bd65e6e550..b4f2d285534 100644 --- a/docs/versioned_docs/version-v8.4.x/04-middleware/02-callbacks/03-interfaces.md +++ b/docs/versioned_docs/version-v8.4.x/04-middleware/02-callbacks/03-interfaces.md @@ -92,7 +92,6 @@ type ContractKeeper interface { packetData []byte, contractAddress, packetSenderAddress, - version string, ) error // IBCOnAcknowledgementPacketCallback is called in the source chain when a packet acknowledgement // is received. The packetSenderAddress is determined by the underlying module, and may be empty if @@ -112,7 +111,6 @@ type ContractKeeper interface { relayer sdk.AccAddress, contractAddress, packetSenderAddress, - version string, ) error // IBCOnTimeoutPacketCallback is called in the source chain when a packet is not received before // the timeout height. The packetSenderAddress is determined by the underlying module, and may be @@ -131,7 +129,6 @@ type ContractKeeper interface { relayer sdk.AccAddress, contractAddress, packetSenderAddress, - version string, ) error // IBCReceivePacketCallback is called in the destination chain when a packet acknowledgement is written. // The contract is expected to handle the callback within the user defined gas limit, and handle any errors, @@ -143,7 +140,6 @@ type ContractKeeper interface { packet ibcexported.PacketI, ack ibcexported.Acknowledgement, contractAddress, - version string, ) error } ``` diff --git a/modules/apps/callbacks/types/expected_keepers.go b/modules/apps/callbacks/types/expected_keepers.go index 28a49b8877a..717a9d6108f 100644 --- a/modules/apps/callbacks/types/expected_keepers.go +++ b/modules/apps/callbacks/types/expected_keepers.go @@ -22,6 +22,9 @@ type ContractKeeper interface { // validation on the origin of a given packet. It is recommended to perform the same validation // on all source chain callbacks (SendPacket, AcknowledgementPacket, TimeoutPacket). This // defensively guards against exploits due to incorrectly wired SendPacket ordering in IBC stacks. + // + // The version provided is the base application version for the given packet send. This allows + // contracts to determine how to unmarshal the packetData. IBCSendPacketCallback( cachedCtx sdk.Context, sourcePort string, @@ -44,6 +47,9 @@ type ContractKeeper interface { // validation on the origin of a given packet. It is recommended to perform the same validation // on all source chain callbacks (SendPacket, AcknowledgementPacket, TimeoutPacket). This // defensively guards against exploits due to incorrectly wired SendPacket ordering in IBC stacks. + // + // The version provided is the base application version for the given packet send. This allows + // contracts to determine how to unmarshal the packetData. IBCOnAcknowledgementPacketCallback( cachedCtx sdk.Context, packet channeltypes.Packet, @@ -64,6 +70,9 @@ type ContractKeeper interface { // validation on the origin of a given packet. It is recommended to perform the same validation // on all source chain callbacks (SendPacket, AcknowledgementPacket, TimeoutPacket). This // defensively guards against exploits due to incorrectly wired SendPacket ordering in IBC stacks. + // + // The version provided is the base application version for the given packet send. This allows + // contracts to determine how to unmarshal the packetData. IBCOnTimeoutPacketCallback( cachedCtx sdk.Context, packet channeltypes.Packet, @@ -77,6 +86,9 @@ type ContractKeeper interface { // out of gas, or panics gracefully. // This entry point is called with a cached context. If an error is returned, then the changes in // this context will not be persisted, but the packet lifecycle will not be blocked. + // + // The version provided is the base application version for the given packet send. This allows + // contracts to determine how to unmarshal the packetData. IBCReceivePacketCallback( cachedCtx sdk.Context, packet ibcexported.PacketI, From 12aa19e30a6e5079937888ad83b41b030ca1de2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Mon, 5 Aug 2024 11:32:06 +0200 Subject: [PATCH 13/14] Apply suggestions from code review --- .../04-middleware/02-callbacks/03-interfaces.md | 8 ++++---- .../04-middleware/02-callbacks/03-interfaces.md | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/versioned_docs/version-v7.7.x/04-middleware/02-callbacks/03-interfaces.md b/docs/versioned_docs/version-v7.7.x/04-middleware/02-callbacks/03-interfaces.md index b4f2d285534..566e4ebb4e2 100644 --- a/docs/versioned_docs/version-v7.7.x/04-middleware/02-callbacks/03-interfaces.md +++ b/docs/versioned_docs/version-v7.7.x/04-middleware/02-callbacks/03-interfaces.md @@ -91,7 +91,7 @@ type ContractKeeper interface { timeoutTimestamp uint64, packetData []byte, contractAddress, - packetSenderAddress, + packetSenderAddress string, ) error // IBCOnAcknowledgementPacketCallback is called in the source chain when a packet acknowledgement // is received. The packetSenderAddress is determined by the underlying module, and may be empty if @@ -110,7 +110,7 @@ type ContractKeeper interface { acknowledgement []byte, relayer sdk.AccAddress, contractAddress, - packetSenderAddress, + packetSenderAddress string, ) error // IBCOnTimeoutPacketCallback is called in the source chain when a packet is not received before // the timeout height. The packetSenderAddress is determined by the underlying module, and may be @@ -128,7 +128,7 @@ type ContractKeeper interface { packet channeltypes.Packet, relayer sdk.AccAddress, contractAddress, - packetSenderAddress, + packetSenderAddress string, ) error // IBCReceivePacketCallback is called in the destination chain when a packet acknowledgement is written. // The contract is expected to handle the callback within the user defined gas limit, and handle any errors, @@ -139,7 +139,7 @@ type ContractKeeper interface { cachedCtx sdk.Context, packet ibcexported.PacketI, ack ibcexported.Acknowledgement, - contractAddress, + contractAddress string, ) error } ``` diff --git a/docs/versioned_docs/version-v8.4.x/04-middleware/02-callbacks/03-interfaces.md b/docs/versioned_docs/version-v8.4.x/04-middleware/02-callbacks/03-interfaces.md index b4f2d285534..566e4ebb4e2 100644 --- a/docs/versioned_docs/version-v8.4.x/04-middleware/02-callbacks/03-interfaces.md +++ b/docs/versioned_docs/version-v8.4.x/04-middleware/02-callbacks/03-interfaces.md @@ -91,7 +91,7 @@ type ContractKeeper interface { timeoutTimestamp uint64, packetData []byte, contractAddress, - packetSenderAddress, + packetSenderAddress string, ) error // IBCOnAcknowledgementPacketCallback is called in the source chain when a packet acknowledgement // is received. The packetSenderAddress is determined by the underlying module, and may be empty if @@ -110,7 +110,7 @@ type ContractKeeper interface { acknowledgement []byte, relayer sdk.AccAddress, contractAddress, - packetSenderAddress, + packetSenderAddress string, ) error // IBCOnTimeoutPacketCallback is called in the source chain when a packet is not received before // the timeout height. The packetSenderAddress is determined by the underlying module, and may be @@ -128,7 +128,7 @@ type ContractKeeper interface { packet channeltypes.Packet, relayer sdk.AccAddress, contractAddress, - packetSenderAddress, + packetSenderAddress string, ) error // IBCReceivePacketCallback is called in the destination chain when a packet acknowledgement is written. // The contract is expected to handle the callback within the user defined gas limit, and handle any errors, @@ -139,7 +139,7 @@ type ContractKeeper interface { cachedCtx sdk.Context, packet ibcexported.PacketI, ack ibcexported.Acknowledgement, - contractAddress, + contractAddress string, ) error } ``` From cddd27dd755638b4737115e2614efcf84ffd7173 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Mon, 5 Aug 2024 11:39:02 +0200 Subject: [PATCH 14/14] chore: add migration docs --- docs/docs/05-migrations/13-v8-to-v9.md | 58 ++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/docs/docs/05-migrations/13-v8-to-v9.md b/docs/docs/05-migrations/13-v8-to-v9.md index 1a4e2f26820..68f0cd912d1 100644 --- a/docs/docs/05-migrations/13-v8-to-v9.md +++ b/docs/docs/05-migrations/13-v8-to-v9.md @@ -26,6 +26,7 @@ There are four sections based on the four potential user groups of this document - [ICS20 v2](#ics20-v2) - [`DenomTrace` type refactoring](#denomtrace-type-refactoring) - [ICS27 - Interchain Accounts](#ics27---interchain-accounts) + - [Callbacks](#callbacks) - [IBC testing package](#ibc-testing-package) - [API deprecation notice](#api-deprecation-notice) - [Relayers](#relayers) @@ -289,6 +290,63 @@ func NewIBCMiddleware( - The [`InitModule` function](https://github.com/cosmos/ibc-go/blob/v8.0.0/modules/apps/27-interchain-accounts/module.go#L124-L143) has been removed. When adding the interchain accounts module to the chain, please set the desired params for controller and host submodules directly after calling `RunMigrations` in the upgrade handler. - The [`GetBytes()` function](https://github.com/cosmos/ibc-go/blob/v8.0.0/modules/apps/27-interchain-accounts/types/packet.go#L65-L68) of the `CosmosTx` type has been removed. +### Callbacks + +The `ContractKeeper` interface has been extended with the base application version. The base application version will be required by contracts to unmarshal the packet data. An example of this is unmarshaling ics20v2 packets which requires knowing the base version of a transfer stack (either v1 or v2). + +```diff + IBCSendPacketCallback( + cachedCtx sdk.Context, + sourcePort string, +@@ -31,6 +34,7 @@ type ContractKeeper interface { + packetData []byte, + contractAddress, + packetSenderAddress string, ++ version string, + ) error + // IBCOnAcknowledgementPacketCallback is called in the source chain when a packet acknowledgement + // is received. The packetSenderAddress is determined by the underlying module, and may be empty if +@@ -43,6 +47,9 @@ type ContractKeeper interface { + // validation on the origin of a given packet. It is recommended to perform the same validation + // on all source chain callbacks (SendPacket, AcknowledgementPacket, TimeoutPacket). This + // defensively guards against exploits due to incorrectly wired SendPacket ordering in IBC stacks. + IBCOnAcknowledgementPacketCallback( + cachedCtx sdk.Context, + packet channeltypes.Packet, +@@ -50,6 +57,7 @@ type ContractKeeper interface { + relayer sdk.AccAddress, + contractAddress, + packetSenderAddress string, ++ version string, + ) error + // IBCOnTimeoutPacketCallback is called in the source chain when a packet is not received before + // the timeout height. The packetSenderAddress is determined by the underlying module, and may be +@@ -62,22 +70,30 @@ type ContractKeeper interface { + // validation on the origin of a given packet. It is recommended to perform the same validation + // on all source chain callbacks (SendPacket, AcknowledgementPacket, TimeoutPacket). This + // defensively guards against exploits due to incorrectly wired SendPacket ordering in IBC stacks. + IBCOnTimeoutPacketCallback( + cachedCtx sdk.Context, + packet channeltypes.Packet, + relayer sdk.AccAddress, + contractAddress, + packetSenderAddress string, ++ version string, + ) error + // IBCReceivePacketCallback is called in the destination chain when a packet acknowledgement is written. + // The contract is expected to handle the callback within the user defined gas limit, and handle any errors, + // out of gas, or panics gracefully. + // This entry point is called with a cached context. If an error is returned, then the changes in + // this context will not be persisted, but the packet lifecycle will not be blocked. + IBCReceivePacketCallback( + cachedCtx sdk.Context, + packet ibcexported.PacketI, + ack ibcexported.Acknowledgement, + contractAddress string, ++ version string, + ) error +``` + ### IBC testing package - The `mock.PV` type has been removed in favour of [`cmttypes.MockPV`](https://github.com/cometbft/cometbft/blob/v0.38.5/types/priv_validator.go#L50) in [#5709](https://github.com/cosmos/ibc-go/pull/5709).