Skip to content

Commit 59da7ea

Browse files
committed
fix: Remove unused IBC msg handler - IBCv2 msgs are translated by encoders and handled by Cosmos SDK
1 parent b8d1fba commit 59da7ea

File tree

8 files changed

+3
-86
lines changed

8 files changed

+3
-86
lines changed

app/app.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,6 @@ func NewWasmApp(
594594
distrkeeper.NewQuerier(app.DistrKeeper),
595595
app.IBCKeeper.ChannelKeeper,
596596
app.IBCKeeper.ChannelKeeper,
597-
app.IBCKeeper.ChannelKeeperV2,
598597
app.TransferKeeper,
599598
app.MsgServiceRouter(),
600599
app.GRPCQueryRouter(),

x/wasm/keeper/genesis_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,6 @@ func setupKeeper(t *testing.T) (*Keeper, sdk.Context) {
695695
nil,
696696
nil,
697697
nil,
698-
nil,
699698
tempDir,
700699
nodeConfig,
701700
wasmtypes.VMConfig{},

x/wasm/keeper/handler_plugin.go

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ package keeper
33
import (
44
"errors"
55
"fmt"
6-
"time"
76

87
wasmvmtypes "github.com/CosmWasm/wasmvm/v2/types"
9-
channeltypesv2 "github.com/cosmos/ibc-go/v10/modules/core/04-channel/v2/types"
108

119
errorsmod "cosmossdk.io/errors"
1210

@@ -42,7 +40,6 @@ func NewDefaultMessageHandler(
4240
keeper *Keeper,
4341
router MessageRouter,
4442
ics4Wrapper types.ICS4Wrapper,
45-
channelKeeperV2 types.ChannelKeeperV2,
4643
bankKeeper types.Burner,
4744
cdc codec.Codec,
4845
portSource types.ICS20TransferPortSource,
@@ -55,7 +52,6 @@ func NewDefaultMessageHandler(
5552
return NewMessageHandlerChain(
5653
NewSDKMessageHandler(cdc, router, encoders),
5754
NewIBCRawPacketHandler(ics4Wrapper, keeper),
58-
NewIBC2RawPacketHandler(channelKeeperV2),
5955
NewBurnCoinMessageHandler(bankKeeper),
6056
)
6157
}
@@ -262,75 +258,6 @@ func (h IBCRawPacketHandler) DispatchMsg(ctx sdk.Context, _ sdk.AccAddress, cont
262258
}
263259
}
264260

265-
// IBC2RawPacketHandler handles IBC2Msg received from CosmWasm.
266-
type IBC2RawPacketHandler struct {
267-
channelKeeperV2 types.ChannelKeeperV2
268-
}
269-
270-
// NewIBCRawPacketHandler constructor
271-
func NewIBC2RawPacketHandler(channelKeeperV2 types.ChannelKeeperV2) IBC2RawPacketHandler {
272-
return IBC2RawPacketHandler{
273-
channelKeeperV2: channelKeeperV2,
274-
}
275-
}
276-
277-
// DispatchMsg publishes a raw IBC2 packet onto the channel.
278-
func (h IBC2RawPacketHandler) DispatchMsg(ctx sdk.Context,
279-
contractAddr sdk.AccAddress, contractIBC2PortID string, msg wasmvmtypes.CosmosMsg,
280-
) ([]sdk.Event, [][]byte, [][]*codectypes.Any, error) {
281-
if msg.IBC2 == nil {
282-
return nil, nil, nil, types.ErrUnknownMsg
283-
}
284-
switch {
285-
case msg.IBC2.SendPacket != nil:
286-
if contractIBC2PortID == "" {
287-
return nil, nil, nil, errorsmod.Wrapf(types.ErrUnsupportedForContract, "ibc2 not supported")
288-
}
289-
contractIBCChannelID := msg.IBC2.SendPacket.ChannelID
290-
if contractIBCChannelID == "" {
291-
return nil, nil, nil, errorsmod.Wrapf(types.ErrEmpty, "ibc2 channel")
292-
}
293-
294-
var payloads []channeltypesv2.Payload
295-
for _, payload := range msg.IBC2.SendPacket.Payloads {
296-
payloads = append(payloads, channeltypesv2.Payload{
297-
SourcePort: payload.SourcePort,
298-
DestinationPort: payload.DestinationPort,
299-
Version: payload.Version,
300-
Encoding: payload.Encoding,
301-
Value: payload.Value,
302-
})
303-
}
304-
ibcGoMsg := &channeltypesv2.MsgSendPacket{
305-
SourceClient: msg.IBC2.SendPacket.ChannelID,
306-
TimeoutTimestamp: uint64(time.Unix(0, int64(msg.IBC2.SendPacket.Timeout)).Unix()),
307-
Payloads: payloads,
308-
Signer: contractAddr.String(),
309-
}
310-
311-
ibcGoResp, err := h.channelKeeperV2.SendPacket(ctx, ibcGoMsg)
312-
if err != nil {
313-
return nil, nil, nil, errorsmod.Wrap(err, "channel")
314-
}
315-
moduleLogger(ctx).Debug("ibc2 packet set", "seq", ibcGoResp.Sequence)
316-
317-
resp := &types.MsgIBCSendResponse{Sequence: ibcGoResp.Sequence}
318-
val, err := resp.Marshal()
319-
if err != nil {
320-
return nil, nil, nil, errorsmod.Wrap(err, "failed to marshal IBC2 send response")
321-
}
322-
any, err := codectypes.NewAnyWithValue(resp)
323-
if err != nil {
324-
return nil, nil, nil, errorsmod.Wrap(err, "failed to convert IBC2 send response to Any")
325-
}
326-
msgResponses := [][]*codectypes.Any{{any}}
327-
328-
return nil, [][]byte{val}, msgResponses, nil
329-
default:
330-
return nil, nil, nil, types.ErrUnknownMsg
331-
}
332-
}
333-
334261
var _ Messenger = MessageHandlerFunc(nil)
335262

336263
// MessageHandlerFunc is a helper to construct a function based message handler.

x/wasm/keeper/keeper_cgo.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ func NewKeeper(
2828
distrKeeper types.DistributionKeeper,
2929
ics4Wrapper types.ICS4Wrapper,
3030
channelKeeper types.ChannelKeeper,
31-
channelKeeperV2 types.ChannelKeeperV2,
3231
portSource types.ICS20TransferPortSource,
3332
router MessageRouter,
3433
_ GRPCQueryRouter,
@@ -61,7 +60,7 @@ func NewKeeper(
6160
wasmLimits: vmConfig.WasmLimits,
6261
ibcRouterV2: ibcRouterV2,
6362
}
64-
keeper.messenger = NewDefaultMessageHandler(keeper, router, ics4Wrapper, channelKeeperV2, bankKeeper, cdc, portSource)
63+
keeper.messenger = NewDefaultMessageHandler(keeper, router, ics4Wrapper, bankKeeper, cdc, portSource)
6564
keeper.wasmVMQueryHandler = DefaultQueryPlugins(bankKeeper, stakingKeeper, distrKeeper, channelKeeper, keeper)
6665
preOpts, postOpts := splitOpts(opts)
6766
for _, o := range preOpts {

x/wasm/keeper/keeper_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ func TestInstantiateWithContractFactoryChildQueriesParent(t *testing.T) {
848848
router := baseapp.NewMsgServiceRouter()
849849
router.SetInterfaceRegistry(keepers.EncodingConfig.InterfaceRegistry)
850850
types.RegisterMsgServer(router, NewMsgServerImpl(keeper))
851-
keeper.messenger = NewDefaultMessageHandler(nil, router, nil, nil, nil, keepers.EncodingConfig.Codec, nil)
851+
keeper.messenger = NewDefaultMessageHandler(nil, router, nil, nil, keepers.EncodingConfig.Codec, nil)
852852
// overwrite wasmvm in response handler
853853
keeper.wasmVMResponseHandler = NewDefaultWasmVMContractResponseHandler(NewMessageDispatcher(keeper.messenger, keeper))
854854

x/wasm/keeper/options_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func TestConstructorOptions(t *testing.T) {
155155
opt := spec.srcOpt
156156
_, gotPostOptMarker := opt.(postOptsFn)
157157
require.Equal(t, spec.isPostOpt, gotPostOptMarker)
158-
k := NewKeeper(codec, runtime.NewKVStoreService(storeKey), authkeeper.AccountKeeper{}, &bankkeeper.BaseKeeper{}, stakingkeeper.Keeper{}, nil, nil, nil, nil, nil, nil, nil, tempDir, types.DefaultNodeConfig(), types.VMConfig{}, AvailableCapabilities, "", nil, spec.srcOpt)
158+
k := NewKeeper(codec, runtime.NewKVStoreService(storeKey), authkeeper.AccountKeeper{}, &bankkeeper.BaseKeeper{}, stakingkeeper.Keeper{}, nil, nil, nil, nil, nil, nil, tempDir, types.DefaultNodeConfig(), types.VMConfig{}, AvailableCapabilities, "", nil, spec.srcOpt)
159159
spec.verify(t, k)
160160
})
161161
}

x/wasm/keeper/test_common.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,6 @@ func createTestInput(
379379
distributionkeeper.NewQuerier(distKeeper),
380380
ibcKeeper.ChannelKeeper, // ICS4Wrapper
381381
ibcKeeper.ChannelKeeper,
382-
ibcKeeper.ChannelKeeperV2,
383382
wasmtesting.MockIBCTransferKeeper{},
384383
msgRouter,
385384
querier,

x/wasm/types/expected_keepers.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
clienttypes "github.com/cosmos/ibc-go/v10/modules/core/02-client/types"
77
connectiontypes "github.com/cosmos/ibc-go/v10/modules/core/03-connection/types"
88
channeltypes "github.com/cosmos/ibc-go/v10/modules/core/04-channel/types"
9-
channeltypesv2 "github.com/cosmos/ibc-go/v10/modules/core/04-channel/v2/types"
109
ibcexported "github.com/cosmos/ibc-go/v10/modules/core/exported"
1110

1211
sdk "github.com/cosmos/cosmos-sdk/types"
@@ -85,11 +84,6 @@ type ChannelKeeper interface {
8584
GetAllChannelsWithPortPrefix(ctx sdk.Context, portPrefix string) []channeltypes.IdentifiedChannel
8685
}
8786

88-
// ChannelKeeperV2 defines the expected IBC2 channel keeper
89-
type ChannelKeeperV2 interface {
90-
SendPacket(goCtx context.Context, msg *channeltypesv2.MsgSendPacket) (*channeltypesv2.MsgSendPacketResponse, error)
91-
}
92-
9387
// ICS4Wrapper defines the method for an IBC data package to be submitted.
9488
// The interface is implemented by the channel keeper on the lowest level in ibc-go. Middlewares or other abstractions
9589
// can add functionality on top of it. See ics4Wrapper in ibc-go.

0 commit comments

Comments
 (0)