Skip to content

Commit d059913

Browse files
crodriguezvegacolin-axnerdamiannolandependabot[bot]
authored
backport #344, #372, #375, #386 (#388)
* cherrypick pull request 344. * adding client status cli query (#372) * adding client status cli query * adding query client status cli to changelog * updating long CLI help usage * cherrypick of pull request 375 * Bump github.com/tendermint/tendermint from 0.34.12 to 0.34.13 (#386) Bumps [github.com/tendermint/tendermint](https://github.com/tendermint/tendermint) from 0.34.12 to 0.34.13. - [Release notes](https://github.com/tendermint/tendermint/releases) - [Changelog](https://github.com/tendermint/tendermint/blob/v0.34.13/CHANGELOG.md) - [Commits](tendermint/tendermint@v0.34.12...v0.34.13) --- updated-dependencies: - dependency-name: github.com/tendermint/tendermint dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> Co-authored-by: Damian Nolan <damiannolan@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 1e0a7f0 commit d059913

File tree

14 files changed

+456
-137
lines changed

14 files changed

+456
-137
lines changed

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,30 @@ Ref: https://keepachangelog.com/en/1.0.0/
3434

3535
# Changelog
3636

37+
## [Unreleased]
38+
39+
### API Breaking
40+
41+
* (core) [\#227](https://github.com/cosmos/ibc-go/pull/227) Remove sdk.Result from application callbacks.
42+
43+
## [v1.2.0](https://github.com/cosmos/ibc-go/releases/tag/v1.2.0) - 2021-09-10
44+
45+
### State Machine Breaking
46+
47+
* (24-host) [\#344](https://github.com/cosmos/ibc-go/pull/344) Increase port identifier limit to 128 characters.
48+
49+
### Improvements
50+
51+
* [\#373](https://github.com/cosmos/ibc-go/pull/375) Added optional field `PacketCommitmentSequences` to `QueryPacketAcknowledgementsRequest` to provide filtering of packet acknowledgements.
52+
53+
### Features
54+
55+
* [\#372](https://github.com/cosmos/ibc-go/pull/372) New CLI command `query ibc client status <client id>` to get the current activity status of a client.
56+
57+
### Dependencies
58+
59+
* [\#386](https://github.com/cosmos/ibc-go/pull/386) Bump [tendermint](github.com/tendermint/tendermint) from 0.34.12 to 0.34.13.
60+
3761
## [v1.0.0](https://github.com/cosmos/ibc-go/releases/tag/v1.0.0) - 2021-08-10
3862

3963
### Bug Fixes

docs/ibc/proto-docs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,7 @@ Query/QueryPacketCommitments RPC method
11661166
| `port_id` | [string](#string) | | port unique identifier |
11671167
| `channel_id` | [string](#string) | | channel unique identifier |
11681168
| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination request |
1169+
| `packet_commitment_sequences` | [uint64](#uint64) | repeated | list of packet sequences |
11691170

11701171

11711172

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ require (
1818
github.com/spf13/cobra v1.1.3
1919
github.com/spf13/viper v1.8.0
2020
github.com/stretchr/testify v1.7.0
21-
github.com/tendermint/tendermint v0.34.12
21+
github.com/tendermint/tendermint v0.34.13
2222
github.com/tendermint/tm-db v0.6.4
2323
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c
2424
google.golang.org/grpc v1.38.0

go.sum

Lines changed: 66 additions & 3 deletions
Large diffs are not rendered by default.

modules/apps/transfer/types/msgs_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ const (
1616
validPort = "testportid"
1717
invalidPort = "(invalidport1)"
1818
invalidShortPort = "p"
19-
invalidLongPort = "invalidlongportinvalidlongportinvalidlongportinvalidlongportinvalid"
19+
// 195 characters
20+
invalidLongPort = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis eros neque, ultricies vel ligula ac, convallis porttitor elit. Maecenas tincidunt turpis elit, vel faucibus nisl pellentesque sodales"
2021

2122
validChannel = "testchannel"
2223
invalidChannel = "(invalidchannel1)"

modules/core/02-client/client/cli/cli.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ func GetQueryCmd() *cobra.Command {
2020
queryCmd.AddCommand(
2121
GetCmdQueryClientStates(),
2222
GetCmdQueryClientState(),
23+
GetCmdQueryClientStatus(),
2324
GetCmdQueryConsensusStates(),
2425
GetCmdQueryConsensusState(),
2526
GetCmdQueryHeader(),

modules/core/02-client/client/cli/query.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,39 @@ func GetCmdQueryClientState() *cobra.Command {
8989
return cmd
9090
}
9191

92+
// GetCmdQueryClientStatus defines the command to query the status of a client with a given id
93+
func GetCmdQueryClientStatus() *cobra.Command {
94+
cmd := &cobra.Command{
95+
Use: "status [client-id]",
96+
Short: "Query client status",
97+
Long: "Query client activity status. Any client without an 'Active' status is considered inactive",
98+
Example: fmt.Sprintf("%s query %s %s status [client-id]", version.AppName, host.ModuleName, types.SubModuleName),
99+
Args: cobra.ExactArgs(1),
100+
RunE: func(cmd *cobra.Command, args []string) error {
101+
clientCtx, err := client.GetClientQueryContext(cmd)
102+
if err != nil {
103+
return err
104+
}
105+
106+
clientID := args[0]
107+
queryClient := types.NewQueryClient(clientCtx)
108+
109+
req := &types.QueryClientStatusRequest{
110+
ClientId: clientID,
111+
}
112+
113+
clientStatusRes, err := queryClient.ClientStatus(cmd.Context(), req)
114+
if err != nil {
115+
return err
116+
}
117+
118+
return clientCtx.PrintProto(clientStatusRes)
119+
},
120+
}
121+
122+
return cmd
123+
}
124+
92125
// GetCmdQueryConsensusStates defines the command to query all the consensus states from a given
93126
// client state.
94127
func GetCmdQueryConsensusStates() *cobra.Command {

modules/core/04-channel/keeper/grpc_query.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,27 @@ func (q Keeper) PacketAcknowledgements(c context.Context, req *types.QueryPacket
327327
acks := []*types.PacketState{}
328328
store := prefix.NewStore(ctx.KVStore(q.storeKey), []byte(host.PacketAcknowledgementPrefixPath(req.PortId, req.ChannelId)))
329329

330+
// if a list of packet sequences is provided then query for each specific ack and return a list <= len(req.PacketCommitmentSequences)
331+
// otherwise, maintain previous behaviour and perform paginated query
332+
for _, seq := range req.PacketCommitmentSequences {
333+
acknowledgementBz, found := q.GetPacketAcknowledgement(ctx, req.PortId, req.ChannelId, seq)
334+
if !found || len(acknowledgementBz) == 0 {
335+
continue
336+
}
337+
338+
ack := types.NewPacketState(req.PortId, req.ChannelId, seq, acknowledgementBz)
339+
acks = append(acks, &ack)
340+
}
341+
342+
if len(req.PacketCommitmentSequences) > 0 {
343+
selfHeight := clienttypes.GetSelfHeight(ctx)
344+
return &types.QueryPacketAcknowledgementsResponse{
345+
Acknowledgements: acks,
346+
Pagination: nil,
347+
Height: selfHeight,
348+
}, nil
349+
}
350+
330351
pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error {
331352
keySplit := strings.Split(string(key), "/")
332353

@@ -337,6 +358,7 @@ func (q Keeper) PacketAcknowledgements(c context.Context, req *types.QueryPacket
337358

338359
ack := types.NewPacketState(req.PortId, req.ChannelId, sequence, value)
339360
acks = append(acks, &ack)
361+
340362
return nil
341363
})
342364

modules/core/04-channel/keeper/grpc_query_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,33 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgements() {
10251025
},
10261026
true,
10271027
},
1028+
{
1029+
"success, filtered res",
1030+
func() {
1031+
path := ibctesting.NewPath(suite.chainA, suite.chainB)
1032+
suite.coordinator.Setup(path)
1033+
1034+
var commitments []uint64
1035+
1036+
for i := uint64(0); i < 100; i++ {
1037+
ack := types.NewPacketState(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, i, []byte(fmt.Sprintf("hash_%d", i)))
1038+
suite.chainA.App.GetIBCKeeper().ChannelKeeper.SetPacketAcknowledgement(suite.chainA.GetContext(), ack.PortId, ack.ChannelId, ack.Sequence, ack.Data)
1039+
1040+
if i < 10 { // populate the store with 100 and query for 10 specific acks
1041+
expAcknowledgements = append(expAcknowledgements, &ack)
1042+
commitments = append(commitments, ack.Sequence)
1043+
}
1044+
}
1045+
1046+
req = &types.QueryPacketAcknowledgementsRequest{
1047+
PortId: path.EndpointA.ChannelConfig.PortID,
1048+
ChannelId: path.EndpointA.ChannelID,
1049+
PacketCommitmentSequences: commitments,
1050+
Pagination: nil,
1051+
}
1052+
},
1053+
true,
1054+
},
10281055
{
10291056
"success",
10301057
func() {

modules/core/04-channel/types/msgs_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ const (
3232
// invalid constants used for testing
3333
invalidPort = "(invalidport1)"
3434
invalidShortPort = "p"
35-
invalidLongPort = "invalidlongportinvalidlongportinvalidlongportidinvalidlongportidinvalid"
35+
// 195 characters
36+
invalidLongPort = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis eros neque, ultricies vel ligula ac, convallis porttitor elit. Maecenas tincidunt turpis elit, vel faucibus nisl pellentesque sodales"
3637

3738
invalidChannel = "(invalidchannel1)"
3839
invalidShortChannel = "invalid"

0 commit comments

Comments
 (0)