Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/core/04-channel/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ 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: 275 additions & 239 deletions modules/core/04-channel/types/tx.pb.go

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions modules/core/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ import (
)

var (
_ clienttypes.MsgServer = (*Keeper)(nil)
_ connectiontypes.MsgServer = (*Keeper)(nil)
_ channeltypes.MsgServer = (*Keeper)(nil)
_ clienttypes.MsgServer = (*Keeper)(nil)
_ connectiontypes.MsgServer = (*Keeper)(nil)
_ channeltypes.MsgServer = (*Keeper)(nil)
_ channeltypes.PacketMsgServer = (*Keeper)(nil)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can also move to a packet_msg_server.go if people wanted. didn't since wanted to leave folder organization/shuffling for later

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to see this split out eventually and moved to packet-server. But can be done in future PR

)

// CreateClient defines a rpc handler method for MsgCreateClient.
Expand Down
2 changes: 2 additions & 0 deletions modules/core/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ 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)

clienttypes.RegisterQueryServer(cfg.QueryServer(), clientkeeper.NewQueryServer(am.keeper.ClientKeeper))
connectiontypes.RegisterQueryServer(cfg.QueryServer(), connectionkeeper.NewQueryServer(am.keeper.ConnectionKeeper))
channeltypes.RegisterQueryServer(cfg.QueryServer(), channelkeeper.NewQueryServer(am.keeper.ChannelKeeper))
Expand Down
21 changes: 21 additions & 0 deletions modules/core/packet-server/keeper/keeper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package keeper

import (
"github.com/cosmos/cosmos-sdk/codec"

"github.com/cosmos/ibc-go/v9/modules/core/packet-server/types"
)

type Keeper struct {
cdc codec.BinaryCodec
channelKeeper types.ChannelKeeper
clientKeeper types.ClientKeeper
}

func NewKeeper(cdc codec.BinaryCodec, channelKeeper types.ChannelKeeper, clientKeeper types.ClientKeeper) *Keeper {
return &Keeper{
cdc: cdc,
channelKeeper: channelKeeper,
clientKeeper: clientKeeper,
}
}
46 changes: 46 additions & 0 deletions modules/core/packet-server/types/expected_keepers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package types

import (
sdk "github.com/cosmos/cosmos-sdk/types"

clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types"
"github.com/cosmos/ibc-go/v9/modules/core/exported"
)

type ChannelKeeper interface {
// SetPacketCommitment writes the commitment hash under the commitment path
// This is a public path that is standardized by the IBC specification
SetPacketCommitment(ctx sdk.Context, portID string, channelID string, sequence uint64, commitment []byte)

// GetPacketCommitment returns the packet commitment hash under the commitment path
GetPacketCommitment(ctx sdk.Context, portID string, channelID string, sequence uint64) []byte

// DeletePacketCommitment deletes the packet commitment hash under the commitment path
DeletePacketCommitment(ctx sdk.Context, portID string, channelID string, sequence uint64)

// SetNextSequenceSend writes the next send sequence under the sequence path
// This is a public path that is standardized by the IBC specification
SetNextSequenceSend(ctx sdk.Context, portID, channelID string, sequence uint64)

// GetNextSequenceSend returns the next send sequence from the sequence path
GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool)

// SetPacketReceipt writes the packet receipt under the receipt path
// This is a public path that is standardized by the IBC specification
SetPacketReceipt(ctx sdk.Context, portID, channelID string, sequence uint64)

// SetPacketAcknowledgement writes the acknowledgement hash under the acknowledgement path
// This is a public path that is standardized by the IBC specification
SetPacketAcknowledgement(ctx sdk.Context, portID, channelID string, sequence uint64, ackHash []byte)
}

type ClientKeeper interface {
// VerifyMembership retrieves the light client module for the clientID and verifies the proof of the existence of a key-value pair at a specified height.
VerifyMembership(ctx sdk.Context, clientID string, height exported.Height, delayTimePeriod uint64, delayBlockPeriod uint64, proof []byte, path exported.Path, value []byte) error
// VerifyNonMembership retrieves the light client module for the clientID and verifies the absence of a given key at a specified height.
VerifyNonMembership(ctx sdk.Context, clientID string, height exported.Height, delayTimePeriod uint64, delayBlockPeriod uint64, proof []byte, path exported.Path) error
// GetCounterparty returns the counterparty client given the client ID on
// the executing chain
// This is a private path that is only used by the IBC lite module
GetCounterparty(ctx sdk.Context, clientID string) (clienttypes.Counterparty, bool)
}
27 changes: 27 additions & 0 deletions modules/core/packet-server/types/merkle.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package types

import (
commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types"
commitmenttypesv2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2"
)

// BuildMerklePath takes the merkle path prefix and an ICS24 path
// and builds a new path by appending the ICS24 path to the last element of the merkle path prefix.
func BuildMerklePath(prefix *commitmenttypesv2.MerklePath, path []byte) commitmenttypesv2.MerklePath {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def will add tests, just want to get keeper in branch so we can start working on packet handlers.

if prefix == nil || len(prefix.KeyPath) == 0 {
return commitmenttypes.NewMerklePath(path)
}
prefixKeys := prefix.KeyPath
lastElement := prefixKeys[len(prefixKeys)-1]
// append path to last element
newLastElement := cloneAppend(lastElement, path)
prefixKeys[len(prefixKeys)-1] = newLastElement
return commitmenttypes.NewMerklePath(prefixKeys...)
}

func cloneAppend(bz []byte, tail []byte) []byte {
res := make([]byte, len(bz)+len(tail))
copy(res, bz)
copy(res[len(bz):], tail)
return res
}
23 changes: 14 additions & 9 deletions proto/ibc/core/channel/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,9 @@ service Msg {
// MsgChannelCloseConfirm.
rpc ChannelCloseConfirm(MsgChannelCloseConfirm) returns (MsgChannelCloseConfirmResponse);

// 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);

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

// 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 @@ -73,6 +64,20 @@ 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