Skip to content

Commit

Permalink
chore: Undo split to packet-server in 04-channel/v1. Move v2 testing …
Browse files Browse the repository at this point in the history
…functions to endpoint_v2. Fix comments in module.go for channel/v2. (#7495)
  • Loading branch information
DimitrisJim authored Oct 22, 2024
1 parent e0a60a0 commit ead49f2
Show file tree
Hide file tree
Showing 9 changed files with 283 additions and 331 deletions.
5 changes: 0 additions & 5 deletions modules/core/02-client/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ const (
// AllowAllClients is the value that if set in AllowedClients param
// would allow any wired up light client modules to be allowed
AllowAllClients = "*"

// CounterpartyKey is the key used to store counterparty in the client store.
// the counterparty key is imported from types instead of host because
// the counterparty key is not a part of the ics-24 host specification
CounterpartyKey = "counterparty"
)

// FormatClientIdentifier returns the client identifier with the sequence appended.
Expand Down
1 change: 0 additions & 1 deletion modules/core/04-channel/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
)

msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
msgservice.RegisterMsgServiceDesc(registry, &_PacketMsg_serviceDesc)
}

// SubModuleCdc references the global x/ibc/core/04-channel module codec. Note, the codec should
Expand Down
514 changes: 239 additions & 275 deletions modules/core/04-channel/types/tx.pb.go

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions modules/core/04-channel/v2/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import (
"github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types"
)

// Name returns the IBC client name
// Name returns the IBC channel/v2 name
func Name() string {
return types.SubModuleName
}

// GetQueryCmd returns no root query command for the IBC client
// GetQueryCmd returns the root query command for IBC channels v2.
func GetQueryCmd() *cobra.Command {
return cli.GetQueryCmd()
}

// GetTxCmd returns the root tx command for 02-client.
// GetTxCmd returns the root tx command for IBC channels v2.
func GetTxCmd() *cobra.Command {
return cli.NewTxCmd()
}
7 changes: 3 additions & 4 deletions modules/core/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ import (
)

var (
_ clienttypes.MsgServer = (*Keeper)(nil)
_ connectiontypes.MsgServer = (*Keeper)(nil)
_ channeltypes.MsgServer = (*Keeper)(nil)
_ channeltypes.PacketMsgServer = (*Keeper)(nil)
_ clienttypes.MsgServer = (*Keeper)(nil)
_ connectiontypes.MsgServer = (*Keeper)(nil)
_ channeltypes.MsgServer = (*Keeper)(nil)
)

// CreateClient defines a rpc handler method for MsgCreateClient.
Expand Down
1 change: 0 additions & 1 deletion modules/core/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
clienttypes.RegisterMsgServer(cfg.MsgServer(), am.keeper)
connectiontypes.RegisterMsgServer(cfg.MsgServer(), am.keeper)
channeltypes.RegisterMsgServer(cfg.MsgServer(), am.keeper)
channeltypes.RegisterPacketMsgServer(cfg.MsgServer(), am.keeper)
channeltypesv2.RegisterMsgServer(cfg.MsgServer(), am.keeper.ChannelKeeperV2)

clienttypes.RegisterQueryServer(cfg.QueryServer(), clientkeeper.NewQueryServer(am.keeper.ClientKeeper))
Expand Down
23 changes: 9 additions & 14 deletions proto/ibc/core/channel/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,18 @@ service Msg {
// MsgChannelCloseConfirm.
rpc ChannelCloseConfirm(MsgChannelCloseConfirm) returns (MsgChannelCloseConfirmResponse);

// RecvPacket defines a rpc handler method for MsgRecvPacket.
rpc RecvPacket(MsgRecvPacket) returns (MsgRecvPacketResponse);

// TimeoutOnClose defines a rpc handler method for MsgTimeoutOnClose.
rpc TimeoutOnClose(MsgTimeoutOnClose) returns (MsgTimeoutOnCloseResponse);

// Timeout defines a rpc handler method for MsgTimeout.
rpc Timeout(MsgTimeout) returns (MsgTimeoutResponse);

// Acknowledgement defines a rpc handler method for MsgAcknowledgement.
rpc Acknowledgement(MsgAcknowledgement) returns (MsgAcknowledgementResponse);

// ChannelUpgradeInit defines a rpc handler method for MsgChannelUpgradeInit.
rpc ChannelUpgradeInit(MsgChannelUpgradeInit) returns (MsgChannelUpgradeInitResponse);

Expand Down Expand Up @@ -64,20 +73,6 @@ service Msg {
rpc PruneAcknowledgements(MsgPruneAcknowledgements) returns (MsgPruneAcknowledgementsResponse);
}

// PacketMsg defines the ibc/channel PacketMsg service.
service PacketMsg {
option (cosmos.msg.v1.service) = true;

// RecvPacket defines a rpc handler method for MsgRecvPacket.
rpc RecvPacket(MsgRecvPacket) returns (MsgRecvPacketResponse);

// Timeout defines a rpc handler method for MsgTimeout.
rpc Timeout(MsgTimeout) returns (MsgTimeoutResponse);

// Acknowledgement defines a rpc handler method for MsgAcknowledgement.
rpc Acknowledgement(MsgAcknowledgement) returns (MsgAcknowledgementResponse);
}

// ResponseResultType defines the possible outcomes of the execution of a message
enum ResponseResultType {
option (gogoproto.goproto_enum_prefix) = false;
Expand Down
28 changes: 0 additions & 28 deletions testing/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types"
connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types"
channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types"
channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types"
commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types"
host "github.com/cosmos/ibc-go/v9/modules/core/24-host"
"github.com/cosmos/ibc-go/v9/modules/core/exported"
Expand Down Expand Up @@ -176,33 +175,6 @@ func (endpoint *Endpoint) FreezeClient() {
endpoint.Chain.App.GetIBCKeeper().ClientKeeper.SetClientState(endpoint.Chain.GetContext(), endpoint.ClientID, tmClientState)
}

// ProvideCounterparty will construct and execute a MsgProvideCounterparty on the associated endpoint.
func (endpoint *Endpoint) ProvideCounterparty() (err error) {
msg := channeltypesv2.NewMsgProvideCounterparty(endpoint.ChannelID, endpoint.Counterparty.ChannelID, endpoint.Chain.SenderAccount.GetAddress().String())

// setup counterparty
_, err = endpoint.Chain.SendMsgs(msg)

return err
}

// CreateChannel will construct and execute a new MsgCreateChannel on the associated endpoint.
func (endpoint *Endpoint) CreateChannel() (err error) {
endpoint.IncrementNextChannelSequence()
msg := channeltypesv2.NewMsgCreateChannel(endpoint.ClientID, MerklePath, endpoint.Chain.SenderAccount.GetAddress().String())

// create channel
res, err := endpoint.Chain.SendMsgs(msg)
if err != nil {
return err
}

endpoint.ChannelID, err = ParseChannelIDFromEvents(res.Events)
require.NoError(endpoint.Chain.TB, err)

return nil
}

// UpgradeChain will upgrade a chain's chainID to the next revision number.
// It will also update the counterparty client.
// TODO: implement actual upgrade chain functionality via scheduling an upgrade
Expand Down
29 changes: 29 additions & 0 deletions testing/endpoint_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,35 @@ import (
hostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2"
)

// ProvideCounterparty will construct and execute a MsgProvideCounterparty on the associated endpoint.
func (endpoint *Endpoint) ProvideCounterparty() (err error) {
msg := channeltypesv2.NewMsgProvideCounterparty(endpoint.ChannelID, endpoint.Counterparty.ChannelID, endpoint.Chain.SenderAccount.GetAddress().String())

// setup counterparty
_, err = endpoint.Chain.SendMsgs(msg)

return err
}

// CreateChannel will construct and execute a new MsgCreateChannel on the associated endpoint.
func (endpoint *Endpoint) CreateChannel() (err error) {
endpoint.IncrementNextChannelSequence()
msg := channeltypesv2.NewMsgCreateChannel(endpoint.ClientID, MerklePath, endpoint.Chain.SenderAccount.GetAddress().String())

// create channel
res, err := endpoint.Chain.SendMsgs(msg)
if err != nil {
return err
}

endpoint.ChannelID, err = ParseChannelIDFromEvents(res.Events)
if err != nil {
return err
}

return nil
}

// MsgSendPacket sends a packet on the associated endpoint. The constructed packet is returned.
func (endpoint *Endpoint) MsgSendPacket(timeoutTimestamp uint64, payload channeltypesv2.Payload) (channeltypesv2.Packet, error) {
msgSendPacket := channeltypesv2.NewMsgSendPacket(endpoint.ChannelID, timeoutTimestamp, endpoint.Chain.SenderAccount.GetAddress().String(), payload)
Expand Down

0 comments on commit ead49f2

Please sign in to comment.