Async Ack Fixes (#7735)

* Add function to query ack proofs

* fix bugs

* fix swagger

* fix final queries

* docs and add test case

* Rename QueryUnrelayedAcks to more accurate QueryUnreceivedAcks

* Apply suggestions from code review

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>

* address rest of reviews

* consistent spelling

Co-authored-by: Jack Zampolin <jack.zampolin@gmail.com>
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>
This commit is contained in:
Aditya 2020-11-02 15:13:48 +00:00 committed by GitHub
parent aff88bbe99
commit e9801edb99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 11002 additions and 3295 deletions

View File

@ -94,7 +94,7 @@
}
},
{
"url": "./tmp-swagger-gen/ibc/channel/query.swagger.json",
"url": "./tmp-swagger-gen/ibc/core/channel/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "IBCChannelParams"
@ -102,7 +102,7 @@
}
},
{
"url": "./tmp-swagger-gen/ibc/client/query.swagger.json",
"url": "./tmp-swagger-gen/ibc/core/client/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "IBCClientParams"
@ -110,7 +110,7 @@
}
},
{
"url": "./tmp-swagger-gen/ibc/connection/query.swagger.json",
"url": "./tmp-swagger-gen/ibc/core/connection/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "IBCConnectionParams"
@ -118,7 +118,7 @@
}
},
{
"url": "./tmp-swagger-gen/ibc/transfer/query.swagger.json",
"url": "./tmp-swagger-gen/ibc/applications/transfer/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "IBCTransferParams"

File diff suppressed because it is too large Load Diff

View File

@ -286,7 +286,7 @@ keepers. Thus, the `OnRecvPacket` callback only needs to worry about making the
changes given the packet data without worrying about whether the packet is valid or not.
Modules must return an acknowledgement as a byte string and return it to the IBC handler.
The IBC handler will then commit this acknowledgment of the packet so that a relayer may relay the
The IBC handler will then commit this acknowledgement of the packet so that a relayer may relay the
acknowledgement back to the sender module.
```go
@ -354,7 +354,7 @@ with some additional data that could be useful for remediation if the packet pro
Since the modules are responsible for agreeing on an encoding/decoding standard for packet data and
acknowledgements, IBC will pass in the acknowledgements as `[]byte` to this callback. The callback
is responsible for decoding the acknowledgment and processing it.
is responsible for decoding the acknowledgement and processing it.
```go
OnAcknowledgementPacket(

View File

@ -114,9 +114,11 @@ message Packet {
uint64 timeout_timestamp = 8 [(gogoproto.moretags) = "yaml:\"timeout_timestamp\""];
}
// PacketAckCommitment defines the genesis type necessary to retrieve and store
// acknowlegements.
message PacketAckCommitment {
// PacketState defines the generic type necessary to retrieve and store
// packet commitments, acknowledgements, and receipts.
// Caller is responsible for knowing the context necessary to interpret this
// state as a commitment, acknowledgement, or a receipt.
message PacketState {
option (gogoproto.goproto_getters) = false;
// channel port identifier.
@ -125,8 +127,8 @@ message PacketAckCommitment {
string channel_id = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""];
// packet sequence.
uint64 sequence = 3;
// packet commitment hash.
bytes hash = 4;
// embedded data that represents packet state.
bytes data = 4;
}
// Acknowledgement is the recommended acknowledgement format to be used by
@ -142,4 +144,4 @@ message Acknowledgement {
bytes result = 21;
string error = 22;
}
}
}

View File

@ -9,14 +9,14 @@ import "ibc/core/channel/v1/channel.proto";
// GenesisState defines the ibc channel submodule's genesis state.
message GenesisState {
repeated IdentifiedChannel channels = 1 [(gogoproto.casttype) = "IdentifiedChannel", (gogoproto.nullable) = false];
repeated PacketAckCommitment acknowledgements = 2
[(gogoproto.casttype) = "PacketAckCommitment", (gogoproto.nullable) = false];
repeated PacketAckCommitment commitments = 3 [(gogoproto.nullable) = false];
repeated PacketSequence send_sequences = 4
repeated PacketState acknowledgements = 2 [(gogoproto.nullable) = false];
repeated PacketState commitments = 3 [(gogoproto.nullable) = false];
repeated PacketState receipts = 4 [(gogoproto.nullable) = false];
repeated PacketSequence send_sequences = 5
[(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"send_sequences\""];
repeated PacketSequence recv_sequences = 5
repeated PacketSequence recv_sequences = 6
[(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"recv_sequences\""];
repeated PacketSequence ack_sequences = 6
repeated PacketSequence ack_sequences = 7
[(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"ack_sequences\""];
}

View File

@ -47,29 +47,41 @@ service Query {
"/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/{sequence}";
}
// PacketCommitments returns the all the packet commitments hashes associated
// PacketCommitments returns all the packet commitments hashes associated
// with a channel.
rpc PacketCommitments(QueryPacketCommitmentsRequest) returns (QueryPacketCommitmentsResponse) {
option (google.api.http).get = "/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments";
}
// PacketReceipt queries if a given packet sequence has been received on the queried chain
rpc PacketReceipt(QueryPacketReceiptRequest) returns (QueryPacketReceiptResponse) {
option (google.api.http).get = "/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_receipts/{sequence}";
}
// PacketAcknowledgement queries a stored packet acknowledgement hash.
rpc PacketAcknowledgement(QueryPacketAcknowledgementRequest) returns (QueryPacketAcknowledgementResponse) {
option (google.api.http).get = "/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_acks/{sequence}";
}
// UnreceivedPackets returns all the unrelayed IBC packets associated with a
// PacketAcknowledgements returns all the packet acknowledgements associated
// with a channel.
rpc PacketAcknowledgements(QueryPacketAcknowledgementsRequest) returns (QueryPacketAcknowledgementsResponse) {
option (google.api.http).get = "/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_acknowledgements";
}
// UnreceivedPackets returns all the unreceived IBC packets associated with a
// channel and sequences.
rpc UnreceivedPackets(QueryUnreceivedPacketsRequest) returns (QueryUnreceivedPacketsResponse) {
option (google.api.http).get = "/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/"
"{packet_commitment_sequences}/unreceived_packets";
}
// UnrelayedAcks returns all the unrelayed IBC acknowledgements associated with a
// UnreceivedAcks returns all the unreceived IBC acknowledgements associated with a
// channel and sequences.
rpc UnrelayedAcks(QueryUnrelayedAcksRequest) returns (QueryUnrelayedAcksResponse) {
rpc UnreceivedAcks(QueryUnreceivedAcksRequest) returns (QueryUnreceivedAcksResponse) {
option (google.api.http).get = "/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/"
"{packet_commitment_sequences}/unrelayed_acks";
"{packet_ack_sequences}/unreceived_acks";
}
// NextSequenceReceive returns the next receive sequence for a given channel.
@ -192,7 +204,7 @@ message QueryPacketCommitmentRequest {
}
// QueryPacketCommitmentResponse defines the client query response for a packet
// which also includes a proof, its path and the height form which the proof was
// which also includes a proof and the height from which the proof was
// retrieved
message QueryPacketCommitmentResponse {
// packet associated with the request fields
@ -217,13 +229,36 @@ message QueryPacketCommitmentsRequest {
// QueryPacketCommitmentsResponse is the request type for the
// Query/QueryPacketCommitments RPC method
message QueryPacketCommitmentsResponse {
repeated ibc.core.channel.v1.PacketAckCommitment commitments = 1;
repeated ibc.core.channel.v1.PacketState commitments = 1;
// pagination response
cosmos.base.query.v1beta1.PageResponse pagination = 2;
// query block height
ibc.core.client.v1.Height height = 3 [(gogoproto.nullable) = false];
}
// QueryPacketReceiptRequest is the request type for the
// Query/PacketReceipt RPC method
message QueryPacketReceiptRequest {
// port unique identifier
string port_id = 1;
// channel unique identifier
string channel_id = 2;
// packet sequence
uint64 sequence = 3;
}
// QueryPacketReceiptResponse defines the client query response for a packet receipt
// which also includes a proof, and the height from which the proof was
// retrieved
message QueryPacketReceiptResponse {
// success flag for if receipt exists
bool received = 2;
// merkle proof of existence
bytes proof = 3;
// height at which the proof was retrieved
ibc.core.client.v1.Height proof_height = 4 [(gogoproto.nullable) = false];
}
// QueryPacketAcknowledgementRequest is the request type for the
// Query/PacketAcknowledgement RPC method
message QueryPacketAcknowledgementRequest {
@ -236,7 +271,7 @@ message QueryPacketAcknowledgementRequest {
}
// QueryPacketAcknowledgementResponse defines the client query response for a
// packet which also includes a proof, its path and the height form which the
// packet which also includes a proof and the height from which the
// proof was retrieved
message QueryPacketAcknowledgementResponse {
// packet associated with the request fields
@ -247,6 +282,27 @@ message QueryPacketAcknowledgementResponse {
ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false];
}
// QueryPacketAcknowledgementsRequest is the request type for the
// Query/QueryPacketCommitments RPC method
message QueryPacketAcknowledgementsRequest {
// port unique identifier
string port_id = 1;
// channel unique identifier
string channel_id = 2;
// pagination request
cosmos.base.query.v1beta1.PageRequest pagination = 3;
}
// QueryPacketAcknowledgemetsResponse is the request type for the
// Query/QueryPacketAcknowledgements RPC method
message QueryPacketAcknowledgementsResponse {
repeated ibc.core.channel.v1.PacketState acknowledgements = 1;
// pagination response
cosmos.base.query.v1beta1.PageResponse pagination = 2;
// query block height
ibc.core.client.v1.Height height = 3 [(gogoproto.nullable) = false];
}
// QueryUnreceivedPacketsRequest is the request type for the
// Query/UnreceivedPackets RPC method
message QueryUnreceivedPacketsRequest {
@ -267,21 +323,21 @@ message QueryUnreceivedPacketsResponse {
ibc.core.client.v1.Height height = 2 [(gogoproto.nullable) = false];
}
// QueryUnrelayedAcksRequest is the request type for the
// Query/UnrelayedAcks RPC method
message QueryUnrelayedAcksRequest {
// QueryUnreceivedAcks is the request type for the
// Query/UnreceivedAcks RPC method
message QueryUnreceivedAcksRequest {
// port unique identifier
string port_id = 1;
// channel unique identifier
string channel_id = 2;
// list of commitment sequences
repeated uint64 packet_commitment_sequences = 3;
// list of acknowledgement sequences
repeated uint64 packet_ack_sequences = 3;
}
// QueryUnrelayedAcksResponse is the response type for the
// Query/UnrelayedAcks RPC method
message QueryUnrelayedAcksResponse {
// list of unrelayed acknowledgement sequences
// QueryUnreceivedAcksResponse is the response type for the
// Query/UnreceivedAcks RPC method
message QueryUnreceivedAcksResponse {
// list of unreceived acknowledgement sequences
repeated uint64 sequences = 1;
// query block height
ibc.core.client.v1.Height height = 2 [(gogoproto.nullable) = false];

View File

@ -24,8 +24,10 @@ func GetQueryCmd() *cobra.Command {
GetCmdQueryChannelClientState(),
GetCmdQueryPacketCommitment(),
GetCmdQueryPacketCommitments(),
GetCmdQueryPacketReceipt(),
GetCmdQueryPacketAcknowledgement(),
GetCmdQueryUnreceivedPackets(),
GetCmdQueryUnrelayedAcks(),
GetCmdQueryUnreceivedAcks(),
GetCmdQueryNextSequenceReceive(),
// TODO: next sequence Send ?
)

View File

@ -211,14 +211,14 @@ func GetCmdQueryPacketCommitments() *cobra.Command {
return cmd
}
// GetCmdQueryPacketCommitment defines the command to query a channel end
// GetCmdQueryPacketCommitment defines the command to query a packet commitment
func GetCmdQueryPacketCommitment() *cobra.Command {
cmd := &cobra.Command{
Use: "packet-commitment [port-id] [channel-id] [sequence]",
Short: "Query a packet commitment",
Long: "Query a packet commitment",
Example: fmt.Sprintf(
"%s query %s %s end [port-id] [channel-id]", version.AppName, host.ModuleName, types.SubModuleName,
"%s query %s %s packet-commitment [port-id] [channel-id] [sequence]", version.AppName, host.ModuleName, types.SubModuleName,
),
Args: cobra.ExactArgs(3),
RunE: func(cmd *cobra.Command, args []string) error {
@ -252,6 +252,88 @@ func GetCmdQueryPacketCommitment() *cobra.Command {
return cmd
}
// GetCmdQueryPacketReceipt defines the command to query a packet receipt
func GetCmdQueryPacketReceipt() *cobra.Command {
cmd := &cobra.Command{
Use: "packet-receipt [port-id] [channel-id] [sequence]",
Short: "Query a packet receipt",
Long: "Query a packet receipt",
Example: fmt.Sprintf(
"%s query %s %s packet-receipt [port-id] [channel-id] [sequence]", version.AppName, host.ModuleName, types.SubModuleName,
),
Args: cobra.ExactArgs(3),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)
clientCtx, err := client.ReadQueryCommandFlags(clientCtx, cmd.Flags())
if err != nil {
return err
}
portID := args[0]
channelID := args[1]
prove, _ := cmd.Flags().GetBool(flags.FlagProve)
seq, err := strconv.ParseUint(args[2], 10, 64)
if err != nil {
return err
}
res, err := utils.QueryPacketReceipt(clientCtx, portID, channelID, seq, prove)
if err != nil {
return err
}
return clientCtx.PrintOutput(res)
},
}
cmd.Flags().Bool(flags.FlagProve, true, "show proofs for the query results")
flags.AddQueryFlagsToCmd(cmd)
return cmd
}
// GetCmdQueryPacketAcknowledgement defines the command to query a packet acknowledgement
func GetCmdQueryPacketAcknowledgement() *cobra.Command {
cmd := &cobra.Command{
Use: "packet-ack [port-id] [channel-id] [sequence]",
Short: "Query a packet acknowledgement",
Long: "Query a packet acknowledgement",
Example: fmt.Sprintf(
"%s query %s %s packet-ack [port-id] [channel-id] [sequence]", version.AppName, host.ModuleName, types.SubModuleName,
),
Args: cobra.ExactArgs(3),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)
clientCtx, err := client.ReadQueryCommandFlags(clientCtx, cmd.Flags())
if err != nil {
return err
}
portID := args[0]
channelID := args[1]
prove, _ := cmd.Flags().GetBool(flags.FlagProve)
seq, err := strconv.ParseUint(args[2], 10, 64)
if err != nil {
return err
}
res, err := utils.QueryPacketAcknowledgement(clientCtx, portID, channelID, seq, prove)
if err != nil {
return err
}
return clientCtx.PrintOutput(res)
},
}
cmd.Flags().Bool(flags.FlagProve, true, "show proofs for the query results")
flags.AddQueryFlagsToCmd(cmd)
return cmd
}
// GetCmdQueryUnreceivedPackets defines the command to query all the unreceived
// packets on the receiving chain
func GetCmdQueryUnreceivedPackets() *cobra.Command {
@ -264,7 +346,7 @@ The return value represents:
- Unreceived packet commitments: no acknowledgement exists on receiving chain for the given packet commitment sequence on sending chain.
`,
Example: fmt.Sprintf("%s query %s %s unreceived-packets [port-id] [channel-id] --sequences=1,2,3", version.AppName, host.ModuleName, types.SubModuleName),
Args: cobra.ExactArgs(3),
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)
clientCtx, err := client.ReadQueryCommandFlags(clientCtx, cmd.Flags())
@ -304,18 +386,18 @@ The return value represents:
return cmd
}
// GetCmdQueryUnrelayedAcks defines the command to query all the unrelayed acks on the original sending chain
func GetCmdQueryUnrelayedAcks() *cobra.Command {
// GetCmdQueryUnreceivedAcks defines the command to query all the unreceived acks on the original sending chain
func GetCmdQueryUnreceivedAcks() *cobra.Command {
cmd := &cobra.Command{
Use: "unrelayed-acks [port-id] [channel-id]",
Short: "Query all the unrelayed acks associated with a channel",
Long: `Given a list of packet commitment sequences from counterparty, determine if an ack on executing chain has not been relayed to counterparty.
Use: "unreceived-acks [port-id] [channel-id]",
Short: "Query all the unreceived acks associated with a channel",
Long: `Given a list of acknowledgement sequences from counterparty, determine if an ack on the counterparty chain has been received on the executing chain.
The return value represents:
- Unrelayed packet acknowledgement: packet commitment exists on original sending chain and ack exists on receiving (executing) chain.
- Unreceived packet acknowledgement: packet commitment exists on original sending (executing) chain and ack exists on receiving chain.
`,
Example: fmt.Sprintf("%s query %s %s unrelayed-acks [port-id] [channel-id] --sequences=1,2,3", version.AppName, host.ModuleName, types.SubModuleName),
Args: cobra.ExactArgs(3),
Example: fmt.Sprintf("%s query %s %s unreceived-acks [port-id] [channel-id] --sequences=1,2,3", version.AppName, host.ModuleName, types.SubModuleName),
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)
clientCtx, err := client.ReadQueryCommandFlags(clientCtx, cmd.Flags())
@ -334,13 +416,13 @@ The return value represents:
seqs[i] = uint64(seqSlice[i])
}
req := &types.QueryUnrelayedAcksRequest{
PortId: args[0],
ChannelId: args[1],
PacketCommitmentSequences: seqs,
req := &types.QueryUnreceivedAcksRequest{
PortId: args[0],
ChannelId: args[1],
PacketAckSequences: seqs,
}
res, err := queryClient.UnrelayedAcks(context.Background(), req)
res, err := queryClient.UnreceivedAcks(context.Background(), req)
if err != nil {
return err
}

View File

@ -15,45 +15,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/ibc/core/exported"
)
// QueryPacketCommitment returns a packet commitment.
// If prove is true, it performs an ABCI store query in order to retrieve the merkle proof. Otherwise,
// it uses the gRPC query client.
func QueryPacketCommitment(
clientCtx client.Context, portID, channelID string,
sequence uint64, prove bool,
) (*types.QueryPacketCommitmentResponse, error) {
if prove {
return queryPacketCommitmentABCI(clientCtx, portID, channelID, sequence)
}
queryClient := types.NewQueryClient(clientCtx)
req := &types.QueryPacketCommitmentRequest{
PortId: portID,
ChannelId: channelID,
Sequence: sequence,
}
return queryClient.PacketCommitment(context.Background(), req)
}
func queryPacketCommitmentABCI(
clientCtx client.Context, portID, channelID string, sequence uint64,
) (*types.QueryPacketCommitmentResponse, error) {
key := host.KeyPacketCommitment(portID, channelID, sequence)
value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key)
if err != nil {
return nil, err
}
// check if packet commitment exists
if len(value) == 0 {
return nil, sdkerrors.Wrapf(types.ErrPacketCommitmentNotFound, "portID (%s), channelID (%s), sequence (%d)", portID, channelID, sequence)
}
return types.NewQueryPacketCommitmentResponse(value, proofBz, proofHeight), nil
}
// QueryChannel returns a channel end.
// If prove is true, it performs an ABCI store query in order to retrieve the merkle proof. Otherwise,
// it uses the gRPC query client.
@ -232,6 +193,79 @@ func queryNextSequenceRecvABCI(clientCtx client.Context, portID, channelID strin
return types.NewQueryNextSequenceReceiveResponse(sequence, proofBz, proofHeight), nil
}
// QueryPacketCommitment returns a packet commitment.
// If prove is true, it performs an ABCI store query in order to retrieve the merkle proof. Otherwise,
// it uses the gRPC query client.
func QueryPacketCommitment(
clientCtx client.Context, portID, channelID string,
sequence uint64, prove bool,
) (*types.QueryPacketCommitmentResponse, error) {
if prove {
return queryPacketCommitmentABCI(clientCtx, portID, channelID, sequence)
}
queryClient := types.NewQueryClient(clientCtx)
req := &types.QueryPacketCommitmentRequest{
PortId: portID,
ChannelId: channelID,
Sequence: sequence,
}
return queryClient.PacketCommitment(context.Background(), req)
}
func queryPacketCommitmentABCI(
clientCtx client.Context, portID, channelID string, sequence uint64,
) (*types.QueryPacketCommitmentResponse, error) {
key := host.KeyPacketCommitment(portID, channelID, sequence)
value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key)
if err != nil {
return nil, err
}
// check if packet commitment exists
if len(value) == 0 {
return nil, sdkerrors.Wrapf(types.ErrPacketCommitmentNotFound, "portID (%s), channelID (%s), sequence (%d)", portID, channelID, sequence)
}
return types.NewQueryPacketCommitmentResponse(value, proofBz, proofHeight), nil
}
// QueryPacketReceipt returns data about a packet receipt.
// If prove is true, it performs an ABCI store query in order to retrieve the merkle proof. Otherwise,
// it uses the gRPC query client.
func QueryPacketReceipt(
clientCtx client.Context, portID, channelID string,
sequence uint64, prove bool,
) (*types.QueryPacketReceiptResponse, error) {
if prove {
return queryPacketReceiptABCI(clientCtx, portID, channelID, sequence)
}
queryClient := types.NewQueryClient(clientCtx)
req := &types.QueryPacketReceiptRequest{
PortId: portID,
ChannelId: channelID,
Sequence: sequence,
}
return queryClient.PacketReceipt(context.Background(), req)
}
func queryPacketReceiptABCI(
clientCtx client.Context, portID, channelID string, sequence uint64,
) (*types.QueryPacketReceiptResponse, error) {
key := host.KeyPacketReceipt(portID, channelID, sequence)
value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key)
if err != nil {
return nil, err
}
return types.NewQueryPacketReceiptResponse(value != nil, proofBz, proofHeight), nil
}
// QueryPacketAcknowledgement returns the data about a packet acknowledgement.
// If prove is true, it performs an ABCI store query in order to retrieve the merkle proof. Otherwise,
// it uses the gRPC query client

View File

@ -14,10 +14,13 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs types.GenesisState) {
k.SetChannel(ctx, channel.PortId, channel.ChannelId, ch)
}
for _, ack := range gs.Acknowledgements {
k.SetPacketAcknowledgement(ctx, ack.PortId, ack.ChannelId, ack.Sequence, ack.Hash)
k.SetPacketAcknowledgement(ctx, ack.PortId, ack.ChannelId, ack.Sequence, ack.Data)
}
for _, commitment := range gs.Commitments {
k.SetPacketCommitment(ctx, commitment.PortId, commitment.ChannelId, commitment.Sequence, commitment.Hash)
k.SetPacketCommitment(ctx, commitment.PortId, commitment.ChannelId, commitment.Sequence, commitment.Data)
}
for _, receipt := range gs.Receipts {
k.SetPacketReceipt(ctx, receipt.PortId, receipt.ChannelId, receipt.Sequence)
}
for _, ss := range gs.SendSequences {
k.SetNextSequenceSend(ctx, ss.PortId, ss.ChannelId, ss.Sequence)
@ -36,6 +39,7 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) types.GenesisState {
Channels: k.GetAllChannels(ctx),
Acknowledgements: k.GetAllPacketAcks(ctx),
Commitments: k.GetAllPacketCommitments(ctx),
Receipts: k.GetAllPacketReceipts(ctx),
SendSequences: k.GetAllPacketSendSeqs(ctx),
RecvSequences: k.GetAllPacketRecvSeqs(ctx),
AckSequences: k.GetAllPacketAckSeqs(ctx),

View File

@ -237,7 +237,7 @@ func (q Keeper) PacketCommitments(c context.Context, req *types.QueryPacketCommi
ctx := sdk.UnwrapSDKContext(c)
commitments := []*types.PacketAckCommitment{}
commitments := []*types.PacketState{}
store := prefix.NewStore(ctx.KVStore(q.storeKey), []byte(host.PacketCommitmentPrefixPath(req.PortId, req.ChannelId)))
pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error {
@ -248,7 +248,7 @@ func (q Keeper) PacketCommitments(c context.Context, req *types.QueryPacketCommi
return err
}
commitment := types.NewPacketAckCommitment(req.PortId, req.ChannelId, sequence, value)
commitment := types.NewPacketState(req.PortId, req.ChannelId, sequence, value)
commitments = append(commitments, &commitment)
return nil
})
@ -265,6 +265,28 @@ func (q Keeper) PacketCommitments(c context.Context, req *types.QueryPacketCommi
}, nil
}
// PacketReceipt implements the Query/PacketReceipt gRPC method
func (q Keeper) PacketReceipt(c context.Context, req *types.QueryPacketReceiptRequest) (*types.QueryPacketReceiptResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}
if err := validategRPCRequest(req.PortId, req.ChannelId); err != nil {
return nil, err
}
if req.Sequence == 0 {
return nil, status.Error(codes.InvalidArgument, "packet sequence cannot be 0")
}
ctx := sdk.UnwrapSDKContext(c)
_, recvd := q.GetPacketReceipt(ctx, req.PortId, req.ChannelId, req.Sequence)
selfHeight := clienttypes.GetSelfHeight(ctx)
return types.NewQueryPacketReceiptResponse(recvd, nil, selfHeight), nil
}
// PacketAcknowledgement implements the Query/PacketAcknowledgement gRPC method
func (q Keeper) PacketAcknowledgement(c context.Context, req *types.QueryPacketAcknowledgementRequest) (*types.QueryPacketAcknowledgementResponse, error) {
if req == nil {
@ -290,9 +312,49 @@ func (q Keeper) PacketAcknowledgement(c context.Context, req *types.QueryPacketA
return types.NewQueryPacketAcknowledgementResponse(acknowledgementBz, nil, selfHeight), nil
}
// PacketAcknowledgements implements the Query/PacketAcknowledgements gRPC method
func (q Keeper) PacketAcknowledgements(c context.Context, req *types.QueryPacketAcknowledgementsRequest) (*types.QueryPacketAcknowledgementsResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}
if err := validategRPCRequest(req.PortId, req.ChannelId); err != nil {
return nil, err
}
ctx := sdk.UnwrapSDKContext(c)
acks := []*types.PacketState{}
store := prefix.NewStore(ctx.KVStore(q.storeKey), []byte(host.PacketAcknowledgementPrefixPath(req.PortId, req.ChannelId)))
pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error {
keySplit := strings.Split(string(key), "/")
sequence, err := strconv.ParseUint(keySplit[len(keySplit)-1], 10, 64)
if err != nil {
return err
}
ack := types.NewPacketState(req.PortId, req.ChannelId, sequence, value)
acks = append(acks, &ack)
return nil
})
if err != nil {
return nil, err
}
selfHeight := clienttypes.GetSelfHeight(ctx)
return &types.QueryPacketAcknowledgementsResponse{
Acknowledgements: acks,
Pagination: pageRes,
Height: selfHeight,
}, nil
}
// UnreceivedPackets implements the Query/UnreceivedPackets gRPC method. Given
// a list of counterparty packet commitments, the querier checks if the packet
// has already been received by checking if an acknowledgement exists on this
// has already been received by checking if a receipt exists on this
// chain for the packet sequence. All packets that haven't been received yet
// are returned in the response
// Usage: To use this method correctly, first query all packet commitments on
@ -306,9 +368,6 @@ func (q Keeper) PacketAcknowledgement(c context.Context, req *types.QueryPacketA
// commitments is correct and will not function properly if the list
// is not up to date. Ideally the query height should equal the latest height
// on the counterparty's client which represents this chain.
// TODO: Replace GetPacketAcknowledgement with GetPacketReceipt once async
// acknowledgements issue is implemented.
// Issue #7254: https://github.com/cosmos/cosmos-sdk/issues/7254
func (q Keeper) UnreceivedPackets(c context.Context, req *types.QueryUnreceivedPacketsRequest) (*types.QueryUnreceivedPacketsResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
@ -327,8 +386,8 @@ func (q Keeper) UnreceivedPackets(c context.Context, req *types.QueryUnreceivedP
return nil, status.Errorf(codes.InvalidArgument, "packet sequence %d cannot be 0", i)
}
// if acknowledgement exists on the receiving chain, then packet has already been received
if _, found := q.GetPacketAcknowledgement(ctx, req.PortId, req.ChannelId, seq); !found {
// if packet receipt exists on the receiving chain, then packet has already been received
if _, found := q.GetPacketReceipt(ctx, req.PortId, req.ChannelId, seq); !found {
unreceivedSequences = append(unreceivedSequences, seq)
}
@ -341,24 +400,24 @@ func (q Keeper) UnreceivedPackets(c context.Context, req *types.QueryUnreceivedP
}, nil
}
// UnrelayedAcks implements the Query/UnrelayedAcks gRPC method. Given
// UnreceivedAcks implements the Query/UnreceivedAcks gRPC method. Given
// a list of counterparty packet acknowledgements, the querier checks if the packet
// has already been received by checking if the packet commitment still exists on this
// chain (original sender) for the packet sequence.
// All acknowledgmeents that haven't been received yet are returned in the response.
// Usage: To use this method correctly, first query all packet commitments on
// the sending chain using the Query/PacketCommitments gRPC method.
// Then input the returned sequences into the QueryUnrelayedPacketsRequest
// and send the request to this Query/UnrelayedPackets on the **receiving**
// Usage: To use this method correctly, first query all packet acknowledgements on
// the original receiving chain (ie the chain that wrote the acks) using the Query/PacketAcknowledgements gRPC method.
// Then input the returned sequences into the QueryUnreceivedAcksRequest
// and send the request to this Query/UnreceivedAcks on the **original sending**
// chain. This gRPC method will then return the list of packet sequences whose
// acknowledgements are already written on the receiving chain but haven't yet
// been relayed back to the sending chain.
// been received back to the sending chain.
//
// NOTE: The querier makes the assumption that the provided list of packet
// acknowledgements is correct and will not function properly if the list
// is not up to date. Ideally the query height should equal the latest height
// on the counterparty's client which represents this chain.
func (q Keeper) UnrelayedAcks(c context.Context, req *types.QueryUnrelayedAcksRequest) (*types.QueryUnrelayedAcksResponse, error) {
func (q Keeper) UnreceivedAcks(c context.Context, req *types.QueryUnreceivedAcksRequest) (*types.QueryUnreceivedAcksResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}
@ -369,24 +428,24 @@ func (q Keeper) UnrelayedAcks(c context.Context, req *types.QueryUnrelayedAcksRe
ctx := sdk.UnwrapSDKContext(c)
var unrelayedSequences = []uint64{}
var unreceivedSequences = []uint64{}
for i, seq := range req.PacketCommitmentSequences {
for i, seq := range req.PacketAckSequences {
if seq == 0 {
return nil, status.Errorf(codes.InvalidArgument, "packet sequence %d cannot be 0", i)
}
// if packet commitment still exists on the original sending chain, then packet ack has not been received
// since processing the ack will delete the packet commitment
if _, found := q.GetPacketAcknowledgement(ctx, req.PortId, req.ChannelId, seq); found {
unrelayedSequences = append(unrelayedSequences, seq)
if commitment := q.GetPacketCommitment(ctx, req.PortId, req.ChannelId, seq); len(commitment) != 0 {
unreceivedSequences = append(unreceivedSequences, seq)
}
}
selfHeight := clienttypes.GetSelfHeight(ctx)
return &types.QueryUnrelayedAcksResponse{
Sequences: unrelayedSequences,
return &types.QueryUnreceivedAcksResponse{
Sequences: unreceivedSequences,
Height: selfHeight,
}, nil
}

View File

@ -649,7 +649,7 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitment() {
func (suite *KeeperTestSuite) TestQueryPacketCommitments() {
var (
req *types.QueryPacketCommitmentsRequest
expCommitments = []*types.PacketAckCommitment{}
expCommitments = []*types.PacketState{}
)
testCases := []struct {
@ -677,7 +677,7 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitments() {
{
"success, empty res",
func() {
expCommitments = []*types.PacketAckCommitment{}
expCommitments = []*types.PacketState{}
req = &types.QueryPacketCommitmentsRequest{
PortId: "test-port-id",
@ -696,11 +696,11 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitments() {
func() {
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED)
expCommitments = make([]*types.PacketAckCommitment, 9)
expCommitments = make([]*types.PacketState, 9)
for i := uint64(0); i < 9; i++ {
commitment := types.NewPacketAckCommitment(channelA.PortID, channelA.ID, i, []byte(fmt.Sprintf("hash_%d", i)))
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), commitment.PortId, commitment.ChannelId, commitment.Sequence, commitment.Hash)
commitment := types.NewPacketState(channelA.PortID, channelA.ID, i, []byte(fmt.Sprintf("hash_%d", i)))
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), commitment.PortId, commitment.ChannelId, commitment.Sequence, commitment.Data)
expCommitments[i] = &commitment
}
@ -738,6 +738,108 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitments() {
}
}
func (suite *KeeperTestSuite) TestQueryPacketReceipt() {
var (
req *types.QueryPacketReceiptRequest
expReceived bool
)
testCases := []struct {
msg string
malleate func()
expPass bool
}{
{
"empty request",
func() {
req = nil
},
false,
},
{
"invalid port ID",
func() {
req = &types.QueryPacketReceiptRequest{
PortId: "",
ChannelId: "test-channel-id",
Sequence: 1,
}
},
false,
},
{
"invalid channel ID",
func() {
req = &types.QueryPacketReceiptRequest{
PortId: "test-port-id",
ChannelId: "",
Sequence: 1,
}
},
false,
},
{"invalid sequence",
func() {
req = &types.QueryPacketReceiptRequest{
PortId: "test-port-id",
ChannelId: "test-channel-id",
Sequence: 0,
}
},
false,
},
{
"success: receipt not found",
func() {
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED)
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketReceipt(suite.chainA.GetContext(), channelA.PortID, channelA.ID, 1)
req = &types.QueryPacketReceiptRequest{
PortId: channelA.PortID,
ChannelId: channelA.ID,
Sequence: 3,
}
expReceived = false
},
true,
},
{
"success: receipt found",
func() {
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED)
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketReceipt(suite.chainA.GetContext(), channelA.PortID, channelA.ID, 1)
req = &types.QueryPacketReceiptRequest{
PortId: channelA.PortID,
ChannelId: channelA.ID,
Sequence: 1,
}
expReceived = true
},
true,
},
}
for _, tc := range testCases {
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
suite.SetupTest() // reset
tc.malleate()
ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
res, err := suite.chainA.QueryServer.PacketReceipt(ctx, req)
if tc.expPass {
suite.Require().NoError(err)
suite.Require().NotNil(res)
suite.Require().Equal(expReceived, res.Received)
} else {
suite.Require().Error(err)
}
})
}
}
func (suite *KeeperTestSuite) TestQueryPacketAcknowledgement() {
var (
req *types.QueryPacketAcknowledgementRequest
@ -835,6 +937,98 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgement() {
}
}
func (suite *KeeperTestSuite) TestQueryPacketAcknowledgements() {
var (
req *types.QueryPacketAcknowledgementsRequest
expAcknowledgements = []*types.PacketState{}
)
testCases := []struct {
msg string
malleate func()
expPass bool
}{
{
"empty request",
func() {
req = nil
},
false,
},
{
"invalid ID",
func() {
req = &types.QueryPacketAcknowledgementsRequest{
PortId: "",
ChannelId: "test-channel-id",
}
},
false,
},
{
"success, empty res",
func() {
expAcknowledgements = []*types.PacketState{}
req = &types.QueryPacketAcknowledgementsRequest{
PortId: "test-port-id",
ChannelId: "test-channel-id",
Pagination: &query.PageRequest{
Key: nil,
Limit: 2,
CountTotal: true,
},
}
},
true,
},
{
"success",
func() {
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED)
expAcknowledgements = make([]*types.PacketState, 9)
for i := uint64(0); i < 9; i++ {
ack := types.NewPacketState(channelA.PortID, channelA.ID, i, []byte(fmt.Sprintf("hash_%d", i)))
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(suite.chainA.GetContext(), ack.PortId, ack.ChannelId, ack.Sequence, ack.Data)
expAcknowledgements[i] = &ack
}
req = &types.QueryPacketAcknowledgementsRequest{
PortId: channelA.PortID,
ChannelId: channelA.ID,
Pagination: &query.PageRequest{
Key: nil,
Limit: 11,
CountTotal: true,
},
}
},
true,
},
}
for _, tc := range testCases {
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
suite.SetupTest() // reset
tc.malleate()
ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
res, err := suite.chainA.QueryServer.PacketAcknowledgements(ctx, req)
if tc.expPass {
suite.Require().NoError(err)
suite.Require().NotNil(res)
suite.Require().Equal(expAcknowledgements, res.Acknowledgements)
} else {
suite.Require().Error(err)
}
})
}
}
func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() {
var (
req *types.QueryUnreceivedPacketsRequest
@ -885,7 +1079,7 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() {
false,
},
{
"basic success unrelayed packet commitments",
"basic success unreceived packet commitments",
func() {
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED)
@ -901,13 +1095,11 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() {
true,
},
{
"basic success unrelayed packet commitments, nothing to relay",
"basic success unreceived packet commitments, nothing to relay",
func() {
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED)
// ack exists
ack := types.NewPacketAckCommitment(channelA.PortID, channelA.ID, 1, []byte("hash"))
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(suite.chainA.GetContext(), channelA.PortID, channelA.ID, 1, ack.Hash)
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketReceipt(suite.chainA.GetContext(), channelA.PortID, channelA.ID, 1)
expSeq = []uint64{}
req = &types.QueryUnreceivedPacketsRequest{
@ -919,19 +1111,18 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() {
true,
},
{
"success multiple unrelayed packet commitments",
"success multiple unreceived packet commitments",
func() {
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED)
expSeq = []uint64{} // reset
packetCommitments := []uint64{}
// set ack for every other sequence
// set packet receipt for every other sequence
for seq := uint64(1); seq < 10; seq++ {
packetCommitments = append(packetCommitments, seq)
if seq%2 == 0 {
ack := types.NewPacketAckCommitment(channelA.PortID, channelA.ID, seq, []byte("hash"))
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(suite.chainA.GetContext(), channelA.PortID, channelA.ID, seq, ack.Hash)
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketReceipt(suite.chainA.GetContext(), channelA.PortID, channelA.ID, seq)
} else {
expSeq = append(expSeq, seq)
}
@ -967,9 +1158,9 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() {
}
}
func (suite *KeeperTestSuite) TestQueryUnrelayedAcks() {
func (suite *KeeperTestSuite) TestQueryUnreceivedAcks() {
var (
req *types.QueryUnrelayedAcksRequest
req *types.QueryUnreceivedAcksRequest
expSeq = []uint64{}
)
@ -988,7 +1179,7 @@ func (suite *KeeperTestSuite) TestQueryUnrelayedAcks() {
{
"invalid port ID",
func() {
req = &types.QueryUnrelayedAcksRequest{
req = &types.QueryUnreceivedAcksRequest{
PortId: "",
ChannelId: "test-channel-id",
}
@ -998,7 +1189,7 @@ func (suite *KeeperTestSuite) TestQueryUnrelayedAcks() {
{
"invalid channel ID",
func() {
req = &types.QueryUnrelayedAcksRequest{
req = &types.QueryUnreceivedAcksRequest{
PortId: "test-port-id",
ChannelId: "",
}
@ -1008,70 +1199,65 @@ func (suite *KeeperTestSuite) TestQueryUnrelayedAcks() {
{
"invalid seq",
func() {
req = &types.QueryUnrelayedAcksRequest{
PortId: "test-port-id",
ChannelId: "test-channel-id",
PacketCommitmentSequences: []uint64{0},
req = &types.QueryUnreceivedAcksRequest{
PortId: "test-port-id",
ChannelId: "test-channel-id",
PacketAckSequences: []uint64{0},
}
},
false,
},
{
"basic success unrelayed packet acks",
"basic success unreceived packet acks",
func() {
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED)
// ack exists
ack := types.NewPacketAckCommitment(channelA.PortID, channelA.ID, 1, []byte("hash"))
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(suite.chainA.GetContext(), channelA.PortID, channelA.ID, 1, ack.Hash)
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), channelA.PortID, channelA.ID, 1, []byte("commitment"))
expSeq = []uint64{1}
req = &types.QueryUnrelayedAcksRequest{
PortId: channelA.PortID,
ChannelId: channelA.ID,
PacketCommitmentSequences: []uint64{1},
req = &types.QueryUnreceivedAcksRequest{
PortId: channelA.PortID,
ChannelId: channelA.ID,
PacketAckSequences: []uint64{1},
}
},
true,
},
{
"basic success unrelayed packet acknowledgements, nothing to relay",
"basic success unreceived packet acknowledgements, nothing to relay",
func() {
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED)
// no ack exists
expSeq = []uint64{}
req = &types.QueryUnrelayedAcksRequest{
PortId: channelA.PortID,
ChannelId: channelA.ID,
PacketCommitmentSequences: []uint64{1},
req = &types.QueryUnreceivedAcksRequest{
PortId: channelA.PortID,
ChannelId: channelA.ID,
PacketAckSequences: []uint64{1},
}
},
true,
},
{
"success multiple unrelayed packet acknowledgements",
"success multiple unreceived packet acknowledgements",
func() {
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED)
expSeq = []uint64{} // reset
packetCommitments := []uint64{}
packetAcks := []uint64{}
// set ack for every other sequence
// set packet commitment for every other sequence
for seq := uint64(1); seq < 10; seq++ {
packetCommitments = append(packetCommitments, seq)
packetAcks = append(packetAcks, seq)
if seq%2 == 0 {
ack := types.NewPacketAckCommitment(channelA.PortID, channelA.ID, seq, []byte("hash"))
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(suite.chainA.GetContext(), channelA.PortID, channelA.ID, seq, ack.Hash)
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), channelA.PortID, channelA.ID, seq, []byte("commitement"))
expSeq = append(expSeq, seq)
}
}
req = &types.QueryUnrelayedAcksRequest{
PortId: channelA.PortID,
ChannelId: channelA.ID,
PacketCommitmentSequences: packetCommitments,
req = &types.QueryUnreceivedAcksRequest{
PortId: channelA.PortID,
ChannelId: channelA.ID,
PacketAckSequences: packetAcks,
}
},
true,
@ -1085,7 +1271,7 @@ func (suite *KeeperTestSuite) TestQueryUnrelayedAcks() {
tc.malleate()
ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
res, err := suite.chainA.QueryServer.UnrelayedAcks(ctx, req)
res, err := suite.chainA.QueryServer.UnreceivedAcks(ctx, req)
if tc.expPass {
suite.Require().NoError(err)

View File

@ -258,9 +258,9 @@ func (k Keeper) IteratePacketCommitment(ctx sdk.Context, cb func(portID, channel
}
// GetAllPacketCommitments returns all stored PacketCommitments objects.
func (k Keeper) GetAllPacketCommitments(ctx sdk.Context) (commitments []types.PacketAckCommitment) {
func (k Keeper) GetAllPacketCommitments(ctx sdk.Context) (commitments []types.PacketState) {
k.IteratePacketCommitment(ctx, func(portID, channelID string, sequence uint64, hash []byte) bool {
pc := types.NewPacketAckCommitment(portID, channelID, sequence, hash)
pc := types.NewPacketState(portID, channelID, sequence, hash)
commitments = append(commitments, pc)
return false
})
@ -278,15 +278,34 @@ func (k Keeper) IteratePacketCommitmentAtChannel(ctx sdk.Context, portID, channe
// GetAllPacketCommitmentsAtChannel returns all stored PacketCommitments objects for a specified
// port ID and channel ID.
func (k Keeper) GetAllPacketCommitmentsAtChannel(ctx sdk.Context, portID, channelID string) (commitments []types.PacketAckCommitment) {
func (k Keeper) GetAllPacketCommitmentsAtChannel(ctx sdk.Context, portID, channelID string) (commitments []types.PacketState) {
k.IteratePacketCommitmentAtChannel(ctx, portID, channelID, func(_, _ string, sequence uint64, hash []byte) bool {
pc := types.NewPacketAckCommitment(portID, channelID, sequence, hash)
pc := types.NewPacketState(portID, channelID, sequence, hash)
commitments = append(commitments, pc)
return false
})
return commitments
}
// IteratePacketReceipt provides an iterator over all PacketReceipt objects. For each
// receipt, cb will be called. If the cb returns true, the iterator will close
// and stop.
func (k Keeper) IteratePacketReceipt(ctx sdk.Context, cb func(portID, channelID string, sequence uint64, receipt []byte) bool) {
store := ctx.KVStore(k.storeKey)
iterator := sdk.KVStorePrefixIterator(store, []byte(host.KeyPacketReceiptPrefix))
k.iterateHashes(ctx, iterator, cb)
}
// GetAllPacketReceipts returns all stored PacketReceipt objects.
func (k Keeper) GetAllPacketReceipts(ctx sdk.Context) (receipts []types.PacketState) {
k.IteratePacketReceipt(ctx, func(portID, channelID string, sequence uint64, receipt []byte) bool {
packetReceipt := types.NewPacketState(portID, channelID, sequence, receipt)
receipts = append(receipts, packetReceipt)
return false
})
return receipts
}
// IteratePacketAcknowledgement provides an iterator over all PacketAcknowledgement objects. For each
// aknowledgement, cb will be called. If the cb returns true, the iterator will close
// and stop.
@ -297,9 +316,9 @@ func (k Keeper) IteratePacketAcknowledgement(ctx sdk.Context, cb func(portID, ch
}
// GetAllPacketAcks returns all stored PacketAcknowledgements objects.
func (k Keeper) GetAllPacketAcks(ctx sdk.Context) (acks []types.PacketAckCommitment) {
func (k Keeper) GetAllPacketAcks(ctx sdk.Context) (acks []types.PacketState) {
k.IteratePacketAcknowledgement(ctx, func(portID, channelID string, sequence uint64, ack []byte) bool {
packetAck := types.NewPacketAckCommitment(portID, channelID, sequence, ack)
packetAck := types.NewPacketState(portID, channelID, sequence, ack)
acks = append(acks, packetAck)
return false
})

View File

@ -143,51 +143,69 @@ func (suite KeeperTestSuite) TestGetAllSequences() {
suite.Equal(expSeqs, ackSeqs)
}
// TestGetAllCommitmentsAcks creates a set of acks and packet commitments on two different
// TestGetAllPacketState creates a set of acks, packet commitments, and receipts on two different
// channels on chain A and tests their retrieval.
func (suite KeeperTestSuite) TestGetAllCommitmentsAcks() {
func (suite KeeperTestSuite) TestGetAllPacketState() {
_, _, connA, connB, channelA0, _ := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED)
channelA1, _ := suite.coordinator.CreateMockChannels(suite.chainA, suite.chainB, connA, connB, types.UNORDERED)
// channel 0 acks
ack1 := types.NewPacketAckCommitment(channelA0.PortID, channelA0.ID, 1, []byte("ack"))
ack2 := types.NewPacketAckCommitment(channelA0.PortID, channelA0.ID, 2, []byte("ack"))
ack1 := types.NewPacketState(channelA0.PortID, channelA0.ID, 1, []byte("ack"))
ack2 := types.NewPacketState(channelA0.PortID, channelA0.ID, 2, []byte("ack"))
// duplicate ack
ack2dup := types.NewPacketAckCommitment(channelA0.PortID, channelA0.ID, 2, []byte("ack"))
ack2dup := types.NewPacketState(channelA0.PortID, channelA0.ID, 2, []byte("ack"))
// channel 1 acks
ack3 := types.NewPacketAckCommitment(channelA1.PortID, channelA1.ID, 1, []byte("ack"))
ack3 := types.NewPacketState(channelA1.PortID, channelA1.ID, 1, []byte("ack"))
// create channel 0 receipts
rec1 := types.NewPacketState(channelA0.PortID, channelA0.ID, 1, []byte(""))
rec2 := types.NewPacketState(channelA0.PortID, channelA0.ID, 2, []byte(""))
// channel 1 receipts
rec3 := types.NewPacketState(channelA1.PortID, channelA1.ID, 1, []byte(""))
rec4 := types.NewPacketState(channelA1.PortID, channelA1.ID, 2, []byte(""))
// channel 0 packet commitments
comm1 := types.NewPacketAckCommitment(channelA0.PortID, channelA0.ID, 1, []byte("hash"))
comm2 := types.NewPacketAckCommitment(channelA0.PortID, channelA0.ID, 2, []byte("hash"))
comm1 := types.NewPacketState(channelA0.PortID, channelA0.ID, 1, []byte("hash"))
comm2 := types.NewPacketState(channelA0.PortID, channelA0.ID, 2, []byte("hash"))
// channel 1 packet commitments
comm3 := types.NewPacketAckCommitment(channelA1.PortID, channelA1.ID, 1, []byte("hash"))
comm4 := types.NewPacketAckCommitment(channelA1.PortID, channelA1.ID, 2, []byte("hash"))
comm3 := types.NewPacketState(channelA1.PortID, channelA1.ID, 1, []byte("hash"))
comm4 := types.NewPacketState(channelA1.PortID, channelA1.ID, 2, []byte("hash"))
expAcks := []types.PacketAckCommitment{ack1, ack2, ack3}
expCommitments := []types.PacketAckCommitment{comm1, comm2, comm3, comm4}
expAcks := []types.PacketState{ack1, ack2, ack3}
expReceipts := []types.PacketState{rec1, rec2, rec3, rec4}
expCommitments := []types.PacketState{comm1, comm2, comm3, comm4}
ctxA := suite.chainA.GetContext()
// set acknowledgements
for _, ack := range []types.PacketAckCommitment{ack1, ack2, ack2dup, ack3} {
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(ctxA, ack.PortId, ack.ChannelId, ack.Sequence, ack.Hash)
for _, ack := range []types.PacketState{ack1, ack2, ack2dup, ack3} {
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(ctxA, ack.PortId, ack.ChannelId, ack.Sequence, ack.Data)
}
// set packet receipts
for _, rec := range expReceipts {
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketReceipt(ctxA, rec.PortId, rec.ChannelId, rec.Sequence)
}
// set packet commitments
for _, comm := range expCommitments {
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(ctxA, comm.PortId, comm.ChannelId, comm.Sequence, comm.Hash)
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(ctxA, comm.PortId, comm.ChannelId, comm.Sequence, comm.Data)
}
acks := suite.chainA.App.IBCKeeper.ChannelKeeper.GetAllPacketAcks(ctxA)
receipts := suite.chainA.App.IBCKeeper.ChannelKeeper.GetAllPacketReceipts(ctxA)
commitments := suite.chainA.App.IBCKeeper.ChannelKeeper.GetAllPacketCommitments(ctxA)
suite.Require().Len(acks, len(expAcks))
suite.Require().Len(commitments, len(expCommitments))
suite.Require().Len(receipts, len(expReceipts))
suite.Require().Equal(expAcks, acks)
suite.Require().Equal(expReceipts, receipts)
suite.Require().Equal(expCommitments, commitments)
}
@ -275,7 +293,7 @@ func (suite *KeeperTestSuite) TestGetAllPacketCommitmentsAtChannel() {
suite.True(expectedSeqs[packet.Sequence])
suite.Equal(channelA.PortID, packet.PortId)
suite.Equal(channelA.ID, packet.ChannelId)
suite.Equal(hash, packet.Hash)
suite.Equal(hash, packet.Data)
// prevent duplicates from passing checks
expectedSeqs[packet.Sequence] = false

View File

@ -299,31 +299,33 @@ func (m *Packet) XXX_DiscardUnknown() {
var xxx_messageInfo_Packet proto.InternalMessageInfo
// PacketAckCommitment defines the genesis type necessary to retrieve and store
// acknowlegements.
type PacketAckCommitment struct {
// PacketState defines the generic type necessary to retrieve and store
// packet commitments, acknowledgements, and receipts.
// Caller is responsible for knowing the context necessary to interpret this
// state as a commitment, acknowledgement, or a receipt.
type PacketState struct {
// channel port identifier.
PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty" yaml:"port_id"`
// channel unique identifier.
ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"`
// packet sequence.
Sequence uint64 `protobuf:"varint,3,opt,name=sequence,proto3" json:"sequence,omitempty"`
// packet commitment hash.
Hash []byte `protobuf:"bytes,4,opt,name=hash,proto3" json:"hash,omitempty"`
// embedded data that represents packet state.
Data []byte `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"`
}
func (m *PacketAckCommitment) Reset() { *m = PacketAckCommitment{} }
func (m *PacketAckCommitment) String() string { return proto.CompactTextString(m) }
func (*PacketAckCommitment) ProtoMessage() {}
func (*PacketAckCommitment) Descriptor() ([]byte, []int) {
func (m *PacketState) Reset() { *m = PacketState{} }
func (m *PacketState) String() string { return proto.CompactTextString(m) }
func (*PacketState) ProtoMessage() {}
func (*PacketState) Descriptor() ([]byte, []int) {
return fileDescriptor_c3a07336710636a0, []int{4}
}
func (m *PacketAckCommitment) XXX_Unmarshal(b []byte) error {
func (m *PacketState) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *PacketAckCommitment) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
func (m *PacketState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_PacketAckCommitment.Marshal(b, m, deterministic)
return xxx_messageInfo_PacketState.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
@ -333,17 +335,17 @@ func (m *PacketAckCommitment) XXX_Marshal(b []byte, deterministic bool) ([]byte,
return b[:n], nil
}
}
func (m *PacketAckCommitment) XXX_Merge(src proto.Message) {
xxx_messageInfo_PacketAckCommitment.Merge(m, src)
func (m *PacketState) XXX_Merge(src proto.Message) {
xxx_messageInfo_PacketState.Merge(m, src)
}
func (m *PacketAckCommitment) XXX_Size() int {
func (m *PacketState) XXX_Size() int {
return m.Size()
}
func (m *PacketAckCommitment) XXX_DiscardUnknown() {
xxx_messageInfo_PacketAckCommitment.DiscardUnknown(m)
func (m *PacketState) XXX_DiscardUnknown() {
xxx_messageInfo_PacketState.DiscardUnknown(m)
}
var xxx_messageInfo_PacketAckCommitment proto.InternalMessageInfo
var xxx_messageInfo_PacketState proto.InternalMessageInfo
// Acknowledgement is the recommended acknowledgement format to be used by
// app-specific protocols.
@ -446,72 +448,71 @@ func init() {
proto.RegisterType((*IdentifiedChannel)(nil), "ibc.core.channel.v1.IdentifiedChannel")
proto.RegisterType((*Counterparty)(nil), "ibc.core.channel.v1.Counterparty")
proto.RegisterType((*Packet)(nil), "ibc.core.channel.v1.Packet")
proto.RegisterType((*PacketAckCommitment)(nil), "ibc.core.channel.v1.PacketAckCommitment")
proto.RegisterType((*PacketState)(nil), "ibc.core.channel.v1.PacketState")
proto.RegisterType((*Acknowledgement)(nil), "ibc.core.channel.v1.Acknowledgement")
}
func init() { proto.RegisterFile("ibc/core/channel/v1/channel.proto", fileDescriptor_c3a07336710636a0) }
var fileDescriptor_c3a07336710636a0 = []byte{
// 916 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x55, 0xcd, 0x6e, 0xdb, 0x46,
0x10, 0x16, 0x25, 0xea, 0x6f, 0x2c, 0xc9, 0xf2, 0xba, 0x56, 0x58, 0x36, 0x11, 0x15, 0xa2, 0x07,
0x23, 0x45, 0xa4, 0x38, 0x0d, 0xda, 0x22, 0xa7, 0x5a, 0x3f, 0x81, 0x89, 0x06, 0x92, 0x41, 0xc9,
0x87, 0xe6, 0xa2, 0xd2, 0xe4, 0x56, 0x22, 0x2c, 0x71, 0x55, 0x72, 0x65, 0xd7, 0x6f, 0x10, 0xe8,
0xd4, 0x17, 0x10, 0x50, 0xa0, 0xe8, 0xb5, 0xd7, 0xbe, 0x42, 0x8e, 0x39, 0xf6, 0x24, 0x14, 0xf6,
0xa1, 0x77, 0xbd, 0x40, 0x0b, 0xee, 0x2e, 0xf5, 0xe3, 0x04, 0x39, 0xf6, 0x94, 0x13, 0x77, 0xbe,
0xef, 0x9b, 0x99, 0x8f, 0x3b, 0x03, 0x12, 0x1e, 0xba, 0xe7, 0x76, 0xcd, 0x26, 0x3e, 0xae, 0xd9,
0x43, 0xcb, 0xf3, 0xf0, 0xa8, 0x76, 0x79, 0x14, 0x1d, 0xab, 0x13, 0x9f, 0x50, 0x82, 0xf6, 0xdd,
0x73, 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e9, 0x70, 0x7a, 0x5e, 0xb5, 0xc9, 0xb8, 0x66, 0x93, 0x60, 0x4c, 0x02, 0xf1, 0x78, 0x1c, 0x38,
0x17, 0xb5, 0x9f, 0x6b, 0xab, 0x7f, 0xf3, 0x93, 0x67, 0x8f, 0xa3, 0x9f, 0x3d, 0xbd, 0x9e, 0xe0,
0xe0, 0x3c, 0xc5, 0x7e, 0xce, 0x5f, 0xfe, 0x17, 0x00, 0x00, 0xff, 0xff, 0xfd, 0xef, 0x9f, 0xe3,
0x0d, 0x08, 0x00, 0x00,
// 904 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x55, 0xcb, 0x6e, 0xdb, 0x46,
0x14, 0x15, 0x25, 0xea, 0x75, 0x65, 0xc9, 0xf2, 0xa4, 0x56, 0x58, 0x36, 0x11, 0x15, 0xa2, 0x0b,
0x23, 0x45, 0xa4, 0x38, 0x0d, 0xda, 0x22, 0xab, 0x5a, 0x8f, 0xc0, 0x44, 0x03, 0xc9, 0xa0, 0xe4,
0x45, 0xb3, 0x51, 0x65, 0x72, 0x2a, 0x11, 0x96, 0x38, 0x2a, 0x39, 0xb2, 0xeb, 0x3f, 0x08, 0xb4,
0xea, 0x0f, 0x08, 0x28, 0x50, 0xb4, 0xbf, 0xd0, 0x5f, 0xc8, 0x32, 0xcb, 0xae, 0x88, 0xc2, 0x5e,
0x74, 0xaf, 0x1f, 0x68, 0xc1, 0x99, 0xa1, 0x1e, 0x4e, 0xe0, 0x65, 0x57, 0x59, 0x71, 0xee, 0x39,
0xe7, 0x3e, 0x74, 0xef, 0xd5, 0x0c, 0x3c, 0x72, 0xce, 0xac, 0x9a, 0x45, 0x3c, 0x5c, 0xb3, 0x46,
0x03, 0xd7, 0xc5, 0xe3, 0xda, 0xc5, 0x61, 0x74, 0xac, 0x4e, 0x3d, 0x42, 0x09, 0xba, 0xe7, 0x9c,
0x59, 0xd5, 0x50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 0xbe, 0x7d, 0x5e, 0xfb, 0xb9, 0xb6, 0x7a, 0x93, 0x9f, 0x3e, 0x7f, 0x12, 0x3d,
0xf2, 0xf4, 0x6a, 0x8a, 0xfd, 0xb3, 0x14, 0x7b, 0x94, 0xbf, 0xfc, 0x2f, 0x00, 0x00, 0xff, 0xff,
0xd7, 0x33, 0x69, 0x35, 0x05, 0x08, 0x00, 0x00,
}
func (m *Channel) Marshal() (dAtA []byte, err error) {
@ -761,7 +762,7 @@ func (m *Packet) MarshalToSizedBuffer(dAtA []byte) (int, error) {
return len(dAtA) - i, nil
}
func (m *PacketAckCommitment) Marshal() (dAtA []byte, err error) {
func (m *PacketState) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
@ -771,20 +772,20 @@ func (m *PacketAckCommitment) Marshal() (dAtA []byte, err error) {
return dAtA[:n], nil
}
func (m *PacketAckCommitment) MarshalTo(dAtA []byte) (int, error) {
func (m *PacketState) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *PacketAckCommitment) MarshalToSizedBuffer(dAtA []byte) (int, error) {
func (m *PacketState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if len(m.Hash) > 0 {
i -= len(m.Hash)
copy(dAtA[i:], m.Hash)
i = encodeVarintChannel(dAtA, i, uint64(len(m.Hash)))
if len(m.Data) > 0 {
i -= len(m.Data)
copy(dAtA[i:], m.Data)
i = encodeVarintChannel(dAtA, i, uint64(len(m.Data)))
i--
dAtA[i] = 0x22
}
@ -1003,7 +1004,7 @@ func (m *Packet) Size() (n int) {
return n
}
func (m *PacketAckCommitment) Size() (n int) {
func (m *PacketState) Size() (n int) {
if m == nil {
return 0
}
@ -1020,7 +1021,7 @@ func (m *PacketAckCommitment) Size() (n int) {
if m.Sequence != 0 {
n += 1 + sovChannel(uint64(m.Sequence))
}
l = len(m.Hash)
l = len(m.Data)
if l > 0 {
n += 1 + l + sovChannel(uint64(l))
}
@ -1911,7 +1912,7 @@ func (m *Packet) Unmarshal(dAtA []byte) error {
}
return nil
}
func (m *PacketAckCommitment) Unmarshal(dAtA []byte) error {
func (m *PacketState) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
@ -1934,10 +1935,10 @@ func (m *PacketAckCommitment) Unmarshal(dAtA []byte) error {
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: PacketAckCommitment: wiretype end group for non-group")
return fmt.Errorf("proto: PacketState: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: PacketAckCommitment: illegal tag %d (wire type %d)", fieldNum, wire)
return fmt.Errorf("proto: PacketState: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
@ -2025,7 +2026,7 @@ func (m *PacketAckCommitment) Unmarshal(dAtA []byte) error {
}
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType)
return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
@ -2052,9 +2053,9 @@ func (m *PacketAckCommitment) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Hash = append(m.Hash[:0], dAtA[iNdEx:postIndex]...)
if m.Hash == nil {
m.Hash = []byte{}
m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...)
if m.Data == nil {
m.Data = []byte{}
}
iNdEx = postIndex
default:

View File

@ -7,21 +7,21 @@ import (
host "github.com/cosmos/cosmos-sdk/x/ibc/core/24-host"
)
// NewPacketAckCommitment creates a new PacketAckCommitment instance.
func NewPacketAckCommitment(portID, channelID string, seq uint64, hash []byte) PacketAckCommitment {
return PacketAckCommitment{
// NewPacketState creates a new PacketState instance.
func NewPacketState(portID, channelID string, seq uint64, data []byte) PacketState {
return PacketState{
PortId: portID,
ChannelId: channelID,
Sequence: seq,
Hash: hash,
Data: data,
}
}
// Validate performs basic validation of fields returning an error upon any
// failure.
func (pa PacketAckCommitment) Validate() error {
if len(pa.Hash) == 0 {
return errors.New("hash bytes cannot be empty")
func (pa PacketState) Validate() error {
if pa.Data == nil {
return errors.New("data bytes cannot be nil")
}
return validateGenFields(pa.PortId, pa.ChannelId, pa.Sequence)
}
@ -43,7 +43,7 @@ func (ps PacketSequence) Validate() error {
// NewGenesisState creates a GenesisState instance.
func NewGenesisState(
channels []IdentifiedChannel, acks, commitments []PacketAckCommitment,
channels []IdentifiedChannel, acks, receipts, commitments []PacketState,
sendSeqs, recvSeqs, ackSeqs []PacketSequence,
) GenesisState {
return GenesisState{
@ -60,8 +60,9 @@ func NewGenesisState(
func DefaultGenesisState() GenesisState {
return GenesisState{
Channels: []IdentifiedChannel{},
Acknowledgements: []PacketAckCommitment{},
Commitments: []PacketAckCommitment{},
Acknowledgements: []PacketState{},
Receipts: []PacketState{},
Commitments: []PacketState{},
SendSequences: []PacketSequence{},
RecvSequences: []PacketSequence{},
AckSequences: []PacketSequence{},
@ -81,12 +82,24 @@ func (gs GenesisState) Validate() error {
if err := ack.Validate(); err != nil {
return fmt.Errorf("invalid acknowledgement %v ack index %d: %w", ack, i, err)
}
if len(ack.Data) == 0 {
return fmt.Errorf("invalid acknowledgement %v ack index %d: data bytes cannot be empty", ack, i)
}
}
for i, receipt := range gs.Receipts {
if err := receipt.Validate(); err != nil {
return fmt.Errorf("invalid acknowledgement %v ack index %d: %w", receipt, i, err)
}
}
for i, commitment := range gs.Commitments {
if err := commitment.Validate(); err != nil {
return fmt.Errorf("invalid commitment %v index %d: %w", commitment, i, err)
}
if len(commitment.Data) == 0 {
return fmt.Errorf("invalid acknowledgement %v ack index %d: data bytes cannot be empty", commitment, i)
}
}
for i, ss := range gs.SendSequences {

View File

@ -25,12 +25,13 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
// GenesisState defines the ibc channel submodule's genesis state.
type GenesisState struct {
Channels []IdentifiedChannel `protobuf:"bytes,1,rep,name=channels,proto3,casttype=IdentifiedChannel" json:"channels"`
Acknowledgements []PacketAckCommitment `protobuf:"bytes,2,rep,name=acknowledgements,proto3,casttype=PacketAckCommitment" json:"acknowledgements"`
Commitments []PacketAckCommitment `protobuf:"bytes,3,rep,name=commitments,proto3" json:"commitments"`
SendSequences []PacketSequence `protobuf:"bytes,4,rep,name=send_sequences,json=sendSequences,proto3" json:"send_sequences" yaml:"send_sequences"`
RecvSequences []PacketSequence `protobuf:"bytes,5,rep,name=recv_sequences,json=recvSequences,proto3" json:"recv_sequences" yaml:"recv_sequences"`
AckSequences []PacketSequence `protobuf:"bytes,6,rep,name=ack_sequences,json=ackSequences,proto3" json:"ack_sequences" yaml:"ack_sequences"`
Channels []IdentifiedChannel `protobuf:"bytes,1,rep,name=channels,proto3,casttype=IdentifiedChannel" json:"channels"`
Acknowledgements []PacketState `protobuf:"bytes,2,rep,name=acknowledgements,proto3" json:"acknowledgements"`
Commitments []PacketState `protobuf:"bytes,3,rep,name=commitments,proto3" json:"commitments"`
Receipts []PacketState `protobuf:"bytes,4,rep,name=receipts,proto3" json:"receipts"`
SendSequences []PacketSequence `protobuf:"bytes,5,rep,name=send_sequences,json=sendSequences,proto3" json:"send_sequences" yaml:"send_sequences"`
RecvSequences []PacketSequence `protobuf:"bytes,6,rep,name=recv_sequences,json=recvSequences,proto3" json:"recv_sequences" yaml:"recv_sequences"`
AckSequences []PacketSequence `protobuf:"bytes,7,rep,name=ack_sequences,json=ackSequences,proto3" json:"ack_sequences" yaml:"ack_sequences"`
}
func (m *GenesisState) Reset() { *m = GenesisState{} }
@ -73,20 +74,27 @@ func (m *GenesisState) GetChannels() []IdentifiedChannel {
return nil
}
func (m *GenesisState) GetAcknowledgements() []PacketAckCommitment {
func (m *GenesisState) GetAcknowledgements() []PacketState {
if m != nil {
return m.Acknowledgements
}
return nil
}
func (m *GenesisState) GetCommitments() []PacketAckCommitment {
func (m *GenesisState) GetCommitments() []PacketState {
if m != nil {
return m.Commitments
}
return nil
}
func (m *GenesisState) GetReceipts() []PacketState {
if m != nil {
return m.Receipts
}
return nil
}
func (m *GenesisState) GetSendSequences() []PacketSequence {
if m != nil {
return m.SendSequences
@ -178,37 +186,37 @@ func init() {
func init() { proto.RegisterFile("ibc/core/channel/v1/genesis.proto", fileDescriptor_cb06ec201f452595) }
var fileDescriptor_cb06ec201f452595 = []byte{
// 470 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0x41, 0x6f, 0xd3, 0x30,
0x18, 0x86, 0x9b, 0xb5, 0x94, 0xcd, 0x5b, 0x2b, 0xe6, 0x6d, 0x52, 0x28, 0x90, 0x94, 0x20, 0xa1,
0x4a, 0x68, 0x09, 0x83, 0x1d, 0x10, 0x37, 0xb2, 0x03, 0xea, 0x6d, 0xf2, 0x6e, 0x48, 0x68, 0x4a,
0x9d, 0x6f, 0x99, 0x95, 0x26, 0xee, 0x6a, 0xaf, 0xb0, 0x5f, 0x01, 0x3f, 0x6b, 0xc7, 0x1d, 0x39,
0x45, 0xa8, 0xfd, 0x03, 0xa8, 0x47, 0x4e, 0xc8, 0x89, 0x9b, 0xb5, 0x5a, 0x84, 0x60, 0xa7, 0xc4,
0x7e, 0xdf, 0xef, 0x79, 0x7c, 0xf9, 0xd0, 0x73, 0x36, 0xa0, 0x1e, 0xe5, 0x63, 0xf0, 0xe8, 0x79,
0x90, 0xa6, 0x30, 0xf4, 0x26, 0x07, 0x5e, 0x04, 0x29, 0x08, 0x26, 0xdc, 0xd1, 0x98, 0x4b, 0x8e,
0x77, 0xd8, 0x80, 0xba, 0xaa, 0xe2, 0xea, 0x8a, 0x3b, 0x39, 0xe8, 0xec, 0x46, 0x3c, 0xe2, 0x79,
0xee, 0xa9, 0xbf, 0xa2, 0xda, 0xa9, 0xa4, 0x2d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0x4f,
0x2d, 0xe3, 0x66, 0x6a, 0x19, 0xbf, 0xa6, 0x96, 0xf1, 0x63, 0x66, 0xd5, 0x6e, 0x66, 0x56, 0xed,
0xe7, 0xcc, 0xaa, 0x7d, 0x7c, 0x15, 0x31, 0x79, 0x71, 0x39, 0x74, 0x29, 0x4f, 0x3c, 0xca, 0x45,
0xc2, 0x85, 0xfe, 0x1c, 0x8b, 0x30, 0xf6, 0xbe, 0x7a, 0xd5, 0xf5, 0x3d, 0x3f, 0x3d, 0x5e, 0x1c,
0xa0, 0xbc, 0x1a, 0x83, 0x18, 0x36, 0xd5, 0xf1, 0xbd, 0xfc, 0x13, 0x00, 0x00, 0xff, 0xff, 0x70,
0xac, 0x09, 0x09, 0xef, 0x03, 0x00, 0x00,
}
func (m *GenesisState) Marshal() (dAtA []byte, err error) {
@ -242,7 +250,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x32
dAtA[i] = 0x3a
}
}
if len(m.RecvSequences) > 0 {
@ -256,7 +264,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x2a
dAtA[i] = 0x32
}
}
if len(m.SendSequences) > 0 {
@ -270,6 +278,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x2a
}
}
if len(m.Receipts) > 0 {
for iNdEx := len(m.Receipts) - 1; iNdEx >= 0; iNdEx-- {
{
size, err := m.Receipts[iNdEx].MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x22
}
}
@ -395,6 +417,12 @@ func (m *GenesisState) Size() (n int) {
n += 1 + l + sovGenesis(uint64(l))
}
}
if len(m.Receipts) > 0 {
for _, e := range m.Receipts {
l = e.Size()
n += 1 + l + sovGenesis(uint64(l))
}
}
if len(m.SendSequences) > 0 {
for _, e := range m.SendSequences {
l = e.Size()
@ -534,7 +562,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Acknowledgements = append(m.Acknowledgements, PacketAckCommitment{})
m.Acknowledgements = append(m.Acknowledgements, PacketState{})
if err := m.Acknowledgements[len(m.Acknowledgements)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
@ -568,12 +596,46 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Commitments = append(m.Commitments, PacketAckCommitment{})
m.Commitments = append(m.Commitments, PacketState{})
if err := m.Commitments[len(m.Commitments)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Receipts", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Receipts = append(m.Receipts, PacketState{})
if err := m.Receipts[len(m.Receipts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 5:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field SendSequences", wireType)
}
@ -607,7 +669,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error {
return err
}
iNdEx = postIndex
case 5:
case 6:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field RecvSequences", wireType)
}
@ -641,7 +703,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error {
return err
}
iNdEx = postIndex
case 6:
case 7:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field AckSequences", wireType)
}

View File

@ -48,11 +48,14 @@ func TestValidateGenesis(t *testing.T) {
),
),
},
[]types.PacketAckCommitment{
types.NewPacketAckCommitment(testPort2, testChannel2, 1, []byte("ack")),
[]types.PacketState{
types.NewPacketState(testPort2, testChannel2, 1, []byte("ack")),
},
[]types.PacketAckCommitment{
types.NewPacketAckCommitment(testPort1, testChannel1, 1, []byte("commit_hash")),
[]types.PacketState{
types.NewPacketState(testPort2, testChannel2, 1, []byte("")),
},
[]types.PacketState{
types.NewPacketState(testPort1, testChannel1, 1, []byte("commit_hash")),
},
[]types.PacketSequence{
types.NewPacketSequence(testPort1, testChannel1, 1),
@ -82,8 +85,8 @@ func TestValidateGenesis(t *testing.T) {
{
name: "invalid ack",
genState: types.GenesisState{
Acknowledgements: []types.PacketAckCommitment{
types.NewPacketAckCommitment(testPort2, testChannel2, 1, nil),
Acknowledgements: []types.PacketState{
types.NewPacketState(testPort2, testChannel2, 1, nil),
},
},
expPass: false,
@ -91,8 +94,8 @@ func TestValidateGenesis(t *testing.T) {
{
name: "invalid commitment",
genState: types.GenesisState{
Commitments: []types.PacketAckCommitment{
types.NewPacketAckCommitment(testPort1, testChannel1, 1, nil),
Commitments: []types.PacketState{
types.NewPacketState(testPort1, testChannel1, 1, nil),
},
},
expPass: false,

View File

@ -45,6 +45,17 @@ func NewQueryPacketCommitmentResponse(
}
}
// NewQueryPacketReceiptResponse creates a new QueryPacketReceiptResponse instance
func NewQueryPacketReceiptResponse(
recvd bool, proof []byte, height clienttypes.Height,
) *QueryPacketReceiptResponse {
return &QueryPacketReceiptResponse{
Received: recvd,
Proof: proof,
ProofHeight: height,
}
}
// NewQueryPacketAcknowledgementResponse creates a new QueryPacketAcknowledgementResponse instance
func NewQueryPacketAcknowledgementResponse(
acknowledgement []byte, proof []byte, height clienttypes.Height,

File diff suppressed because it is too large Load Diff

View File

@ -603,6 +603,104 @@ func local_request_Query_PacketCommitments_0(ctx context.Context, marshaler runt
}
func request_Query_PacketReceipt_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryPacketReceiptRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["channel_id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id")
}
protoReq.ChannelId, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err)
}
val, ok = pathParams["port_id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "port_id")
}
protoReq.PortId, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "port_id", err)
}
val, ok = pathParams["sequence"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "sequence")
}
protoReq.Sequence, err = runtime.Uint64(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sequence", err)
}
msg, err := client.PacketReceipt(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Query_PacketReceipt_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryPacketReceiptRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["channel_id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id")
}
protoReq.ChannelId, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err)
}
val, ok = pathParams["port_id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "port_id")
}
protoReq.PortId, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "port_id", err)
}
val, ok = pathParams["sequence"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "sequence")
}
protoReq.Sequence, err = runtime.Uint64(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sequence", err)
}
msg, err := server.PacketReceipt(ctx, &protoReq)
return msg, metadata, err
}
func request_Query_PacketAcknowledgement_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryPacketAcknowledgementRequest
var metadata runtime.ServerMetadata
@ -701,6 +799,100 @@ func local_request_Query_PacketAcknowledgement_0(ctx context.Context, marshaler
}
var (
filter_Query_PacketAcknowledgements_0 = &utilities.DoubleArray{Encoding: map[string]int{"channel_id": 0, "port_id": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}}
)
func request_Query_PacketAcknowledgements_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryPacketAcknowledgementsRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["channel_id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id")
}
protoReq.ChannelId, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err)
}
val, ok = pathParams["port_id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "port_id")
}
protoReq.PortId, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "port_id", err)
}
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PacketAcknowledgements_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.PacketAcknowledgements(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Query_PacketAcknowledgements_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryPacketAcknowledgementsRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["channel_id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id")
}
protoReq.ChannelId, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err)
}
val, ok = pathParams["port_id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "port_id")
}
protoReq.PortId, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "port_id", err)
}
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PacketAcknowledgements_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.PacketAcknowledgements(ctx, &protoReq)
return msg, metadata, err
}
func request_Query_UnreceivedPackets_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryUnreceivedPacketsRequest
var metadata runtime.ServerMetadata
@ -799,8 +991,8 @@ func local_request_Query_UnreceivedPackets_0(ctx context.Context, marshaler runt
}
func request_Query_UnrelayedAcks_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryUnrelayedAcksRequest
func request_Query_UnreceivedAcks_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryUnreceivedAcksRequest
var metadata runtime.ServerMetadata
var (
@ -832,24 +1024,24 @@ func request_Query_UnrelayedAcks_0(ctx context.Context, marshaler runtime.Marsha
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "port_id", err)
}
val, ok = pathParams["packet_commitment_sequences"]
val, ok = pathParams["packet_ack_sequences"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_commitment_sequences")
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_ack_sequences")
}
protoReq.PacketCommitmentSequences, err = runtime.Uint64Slice(val, ",")
protoReq.PacketAckSequences, err = runtime.Uint64Slice(val, ",")
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_commitment_sequences", err)
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_ack_sequences", err)
}
msg, err := client.UnrelayedAcks(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
msg, err := client.UnreceivedAcks(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Query_UnrelayedAcks_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryUnrelayedAcksRequest
func local_request_Query_UnreceivedAcks_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryUnreceivedAcksRequest
var metadata runtime.ServerMetadata
var (
@ -881,18 +1073,18 @@ func local_request_Query_UnrelayedAcks_0(ctx context.Context, marshaler runtime.
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "port_id", err)
}
val, ok = pathParams["packet_commitment_sequences"]
val, ok = pathParams["packet_ack_sequences"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_commitment_sequences")
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_ack_sequences")
}
protoReq.PacketCommitmentSequences, err = runtime.Uint64Slice(val, ",")
protoReq.PacketAckSequences, err = runtime.Uint64Slice(val, ",")
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_commitment_sequences", err)
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_ack_sequences", err)
}
msg, err := server.UnrelayedAcks(ctx, &protoReq)
msg, err := server.UnreceivedAcks(ctx, &protoReq)
return msg, metadata, err
}
@ -1119,6 +1311,26 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
})
mux.Handle("GET", pattern_Query_PacketReceipt_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Query_PacketReceipt_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_PacketReceipt_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_PacketAcknowledgement_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
@ -1139,6 +1351,26 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
})
mux.Handle("GET", pattern_Query_PacketAcknowledgements_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Query_PacketAcknowledgements_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_PacketAcknowledgements_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_UnreceivedPackets_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
@ -1159,7 +1391,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
})
mux.Handle("GET", pattern_Query_UnrelayedAcks_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
mux.Handle("GET", pattern_Query_UnreceivedAcks_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
@ -1168,14 +1400,14 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Query_UnrelayedAcks_0(rctx, inboundMarshaler, server, req, pathParams)
resp, md, err := local_request_Query_UnreceivedAcks_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_UnrelayedAcks_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
forward_Query_UnreceivedAcks_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
@ -1380,6 +1612,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
})
mux.Handle("GET", pattern_Query_PacketReceipt_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Query_PacketReceipt_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_PacketReceipt_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_PacketAcknowledgement_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
@ -1400,6 +1652,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
})
mux.Handle("GET", pattern_Query_PacketAcknowledgements_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Query_PacketAcknowledgements_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_PacketAcknowledgements_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Query_UnreceivedPackets_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
@ -1420,7 +1692,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
})
mux.Handle("GET", pattern_Query_UnrelayedAcks_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
mux.Handle("GET", pattern_Query_UnreceivedAcks_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
@ -1429,14 +1701,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Query_UnrelayedAcks_0(rctx, inboundMarshaler, client, req, pathParams)
resp, md, err := request_Query_UnreceivedAcks_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_UnrelayedAcks_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
forward_Query_UnreceivedAcks_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
@ -1478,11 +1750,15 @@ var (
pattern_Query_PacketCommitments_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "packet_commitments"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_Query_PacketReceipt_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "packet_receipts", "sequence"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_Query_PacketAcknowledgement_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "packet_acks", "sequence"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_Query_PacketAcknowledgements_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "packet_acknowledgements"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_Query_UnreceivedPackets_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "packet_commitments", "packet_commitment_sequences", "unreceived_packets"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_Query_UnrelayedAcks_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "packet_commitments", "packet_commitment_sequences", "unrelayed_acks"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_Query_UnreceivedAcks_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "packet_commitments", "packet_ack_sequences", "unreceived_acks"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_Query_NextSequenceReceive_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "next_sequence"}, "", runtime.AssumeColonVerbOpt(true)))
)
@ -1502,11 +1778,15 @@ var (
forward_Query_PacketCommitments_0 = runtime.ForwardResponseMessage
forward_Query_PacketReceipt_0 = runtime.ForwardResponseMessage
forward_Query_PacketAcknowledgement_0 = runtime.ForwardResponseMessage
forward_Query_PacketAcknowledgements_0 = runtime.ForwardResponseMessage
forward_Query_UnreceivedPackets_0 = runtime.ForwardResponseMessage
forward_Query_UnrelayedAcks_0 = runtime.ForwardResponseMessage
forward_Query_UnreceivedAcks_0 = runtime.ForwardResponseMessage
forward_Query_NextSequenceReceive_0 = runtime.ForwardResponseMessage
)

View File

@ -144,6 +144,11 @@ func PacketAcknowledgementPath(portID, channelID string, sequence uint64) string
return fmt.Sprintf("%s/", KeyPacketAckPrefix) + channelPath(portID, channelID) + fmt.Sprintf("/acknowledgements/%d", sequence)
}
// PacketAcknowledgementPrefixPath defines the prefix for commitments to packet data fields store path.
func PacketAcknowledgementPrefixPath(portID, channelID string) string {
return fmt.Sprintf("%s/", KeyPacketAckPrefix) + channelPath(portID, channelID)
}
// PacketReceiptPath defines the packet receipt store path
func PacketReceiptPath(portID, channelID string, sequence uint64) string {
return fmt.Sprintf("%s/", KeyPacketReceiptPrefix) + channelPath(portID, channelID) + fmt.Sprintf("/receipts/%d", sequence)

View File

@ -115,11 +115,14 @@ func (suite *IBCTestSuite) TestValidateGenesis() {
),
),
},
[]channeltypes.PacketAckCommitment{
channeltypes.NewPacketAckCommitment(port2, channel2, 1, []byte("ack")),
[]channeltypes.PacketState{
channeltypes.NewPacketState(port2, channel2, 1, []byte("ack")),
},
[]channeltypes.PacketAckCommitment{
channeltypes.NewPacketAckCommitment(port1, channel1, 1, []byte("commit_hash")),
[]channeltypes.PacketState{
channeltypes.NewPacketState(port2, channel2, 1, []byte("")),
},
[]channeltypes.PacketState{
channeltypes.NewPacketState(port1, channel1, 1, []byte("commit_hash")),
},
[]channeltypes.PacketSequence{
channeltypes.NewPacketSequence(port1, channel1, 1),
@ -174,8 +177,8 @@ func (suite *IBCTestSuite) TestValidateGenesis() {
ClientGenesis: clienttypes.DefaultGenesisState(),
ConnectionGenesis: connectiontypes.DefaultGenesisState(),
ChannelGenesis: channeltypes.GenesisState{
Acknowledgements: []channeltypes.PacketAckCommitment{
channeltypes.NewPacketAckCommitment("(portID)", channel1, 1, []byte("ack")),
Acknowledgements: []channeltypes.PacketState{
channeltypes.NewPacketState("(portID)", channel1, 1, []byte("ack")),
},
},
},
@ -249,11 +252,14 @@ func (suite *IBCTestSuite) TestInitGenesis() {
),
),
},
[]channeltypes.PacketAckCommitment{
channeltypes.NewPacketAckCommitment(port2, channel2, 1, []byte("ack")),
[]channeltypes.PacketState{
channeltypes.NewPacketState(port2, channel2, 1, []byte("ack")),
},
[]channeltypes.PacketAckCommitment{
channeltypes.NewPacketAckCommitment(port1, channel1, 1, []byte("commit_hash")),
[]channeltypes.PacketState{
channeltypes.NewPacketState(port2, channel2, 1, []byte("")),
},
[]channeltypes.PacketState{
channeltypes.NewPacketState(port1, channel1, 1, []byte("commit_hash")),
},
[]channeltypes.PacketSequence{
channeltypes.NewPacketSequence(port1, channel1, 1),

View File

@ -88,19 +88,29 @@ func (q Keeper) PacketCommitments(c context.Context, req *channeltypes.QueryPack
return q.ChannelKeeper.PacketCommitments(c, req)
}
// PacketReceipt implements the IBC QueryServer interface
func (q Keeper) PacketReceipt(c context.Context, req *channeltypes.QueryPacketReceiptRequest) (*channeltypes.QueryPacketReceiptResponse, error) {
return q.ChannelKeeper.PacketReceipt(c, req)
}
// PacketAcknowledgement implements the IBC QueryServer interface
func (q Keeper) PacketAcknowledgement(c context.Context, req *channeltypes.QueryPacketAcknowledgementRequest) (*channeltypes.QueryPacketAcknowledgementResponse, error) {
return q.ChannelKeeper.PacketAcknowledgement(c, req)
}
// PacketAcknowledgements implements the IBC QueryServer interface
func (q Keeper) PacketAcknowledgements(c context.Context, req *channeltypes.QueryPacketAcknowledgementsRequest) (*channeltypes.QueryPacketAcknowledgementsResponse, error) {
return q.ChannelKeeper.PacketAcknowledgements(c, req)
}
// UnreceivedPackets implements the IBC QueryServer interface
func (q Keeper) UnreceivedPackets(c context.Context, req *channeltypes.QueryUnreceivedPacketsRequest) (*channeltypes.QueryUnreceivedPacketsResponse, error) {
return q.ChannelKeeper.UnreceivedPackets(c, req)
}
// UnrelayedAcks implements the IBC QueryServer interface
func (q Keeper) UnrelayedAcks(c context.Context, req *channeltypes.QueryUnrelayedAcksRequest) (*channeltypes.QueryUnrelayedAcksResponse, error) {
return q.ChannelKeeper.UnrelayedAcks(c, req)
// UnreceivedAcks implements the IBC QueryServer interface
func (q Keeper) UnreceivedAcks(c context.Context, req *channeltypes.QueryUnreceivedAcksRequest) (*channeltypes.QueryUnreceivedAcksResponse, error) {
return q.ChannelKeeper.UnreceivedAcks(c, req)
}
// NextSequenceReceive implements the IBC QueryServer interface

View File

@ -375,7 +375,7 @@ func (suite *LocalhostTestSuite) TestVerifyPacketAcknowledgement() {
host.KeyPacketAcknowledgement(testPortID, testChannelID, testSequence), []byte("different"),
)
},
ack: []byte("acknowledgment"),
ack: []byte("acknowledgement"),
expPass: false,
},
{

File diff suppressed because it is too large Load Diff