Skip to content

Commit

Permalink
backport #344, #372, #375, #386 (#388)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
4 people committed Sep 10, 2021
1 parent 1e0a7f0 commit d059913
Show file tree
Hide file tree
Showing 14 changed files with 456 additions and 137 deletions.
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,30 @@ Ref: https://keepachangelog.com/en/1.0.0/

# Changelog

## [Unreleased]

### API Breaking

* (core) [\#227](https://github.com/cosmos/ibc-go/pull/227) Remove sdk.Result from application callbacks.

## [v1.2.0](https://github.com/cosmos/ibc-go/releases/tag/v1.2.0) - 2021-09-10

### State Machine Breaking

* (24-host) [\#344](https://github.com/cosmos/ibc-go/pull/344) Increase port identifier limit to 128 characters.

### Improvements

* [\#373](https://github.com/cosmos/ibc-go/pull/375) Added optional field `PacketCommitmentSequences` to `QueryPacketAcknowledgementsRequest` to provide filtering of packet acknowledgements.

### Features

* [\#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.

### Dependencies

* [\#386](https://github.com/cosmos/ibc-go/pull/386) Bump [tendermint](github.com/tendermint/tendermint) from 0.34.12 to 0.34.13.

## [v1.0.0](https://github.com/cosmos/ibc-go/releases/tag/v1.0.0) - 2021-08-10

### Bug Fixes
Expand Down
1 change: 1 addition & 0 deletions docs/ibc/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,7 @@ Query/QueryPacketCommitments RPC method
| `port_id` | [string](#string) | | port unique identifier |
| `channel_id` | [string](#string) | | channel unique identifier |
| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination request |
| `packet_commitment_sequences` | [uint64](#uint64) | repeated | list of packet sequences |



Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require (
github.com/spf13/cobra v1.1.3
github.com/spf13/viper v1.8.0
github.com/stretchr/testify v1.7.0
github.com/tendermint/tendermint v0.34.12
github.com/tendermint/tendermint v0.34.13
github.com/tendermint/tm-db v0.6.4
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c
google.golang.org/grpc v1.38.0
Expand Down
69 changes: 66 additions & 3 deletions go.sum

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion modules/apps/transfer/types/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ const (
validPort = "testportid"
invalidPort = "(invalidport1)"
invalidShortPort = "p"
invalidLongPort = "invalidlongportinvalidlongportinvalidlongportinvalidlongportinvalid"
// 195 characters
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"

validChannel = "testchannel"
invalidChannel = "(invalidchannel1)"
Expand Down
1 change: 1 addition & 0 deletions modules/core/02-client/client/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func GetQueryCmd() *cobra.Command {
queryCmd.AddCommand(
GetCmdQueryClientStates(),
GetCmdQueryClientState(),
GetCmdQueryClientStatus(),
GetCmdQueryConsensusStates(),
GetCmdQueryConsensusState(),
GetCmdQueryHeader(),
Expand Down
33 changes: 33 additions & 0 deletions modules/core/02-client/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,39 @@ func GetCmdQueryClientState() *cobra.Command {
return cmd
}

// GetCmdQueryClientStatus defines the command to query the status of a client with a given id
func GetCmdQueryClientStatus() *cobra.Command {
cmd := &cobra.Command{
Use: "status [client-id]",
Short: "Query client status",
Long: "Query client activity status. Any client without an 'Active' status is considered inactive",
Example: fmt.Sprintf("%s query %s %s status [client-id]", version.AppName, host.ModuleName, types.SubModuleName),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

clientID := args[0]
queryClient := types.NewQueryClient(clientCtx)

req := &types.QueryClientStatusRequest{
ClientId: clientID,
}

clientStatusRes, err := queryClient.ClientStatus(cmd.Context(), req)
if err != nil {
return err
}

return clientCtx.PrintProto(clientStatusRes)
},
}

return cmd
}

// GetCmdQueryConsensusStates defines the command to query all the consensus states from a given
// client state.
func GetCmdQueryConsensusStates() *cobra.Command {
Expand Down
22 changes: 22 additions & 0 deletions modules/core/04-channel/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,27 @@ func (q Keeper) PacketAcknowledgements(c context.Context, req *types.QueryPacket
acks := []*types.PacketState{}
store := prefix.NewStore(ctx.KVStore(q.storeKey), []byte(host.PacketAcknowledgementPrefixPath(req.PortId, req.ChannelId)))

// if a list of packet sequences is provided then query for each specific ack and return a list <= len(req.PacketCommitmentSequences)
// otherwise, maintain previous behaviour and perform paginated query
for _, seq := range req.PacketCommitmentSequences {
acknowledgementBz, found := q.GetPacketAcknowledgement(ctx, req.PortId, req.ChannelId, seq)
if !found || len(acknowledgementBz) == 0 {
continue
}

ack := types.NewPacketState(req.PortId, req.ChannelId, seq, acknowledgementBz)
acks = append(acks, &ack)
}

if len(req.PacketCommitmentSequences) > 0 {
selfHeight := clienttypes.GetSelfHeight(ctx)
return &types.QueryPacketAcknowledgementsResponse{
Acknowledgements: acks,
Pagination: nil,
Height: selfHeight,
}, nil
}

pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error {
keySplit := strings.Split(string(key), "/")

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

ack := types.NewPacketState(req.PortId, req.ChannelId, sequence, value)
acks = append(acks, &ack)

return nil
})

Expand Down
27 changes: 27 additions & 0 deletions modules/core/04-channel/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,33 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgements() {
},
true,
},
{
"success, filtered res",
func() {
path := ibctesting.NewPath(suite.chainA, suite.chainB)
suite.coordinator.Setup(path)

var commitments []uint64

for i := uint64(0); i < 100; i++ {
ack := types.NewPacketState(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, i, []byte(fmt.Sprintf("hash_%d", i)))
suite.chainA.App.GetIBCKeeper().ChannelKeeper.SetPacketAcknowledgement(suite.chainA.GetContext(), ack.PortId, ack.ChannelId, ack.Sequence, ack.Data)

if i < 10 { // populate the store with 100 and query for 10 specific acks
expAcknowledgements = append(expAcknowledgements, &ack)
commitments = append(commitments, ack.Sequence)
}
}

req = &types.QueryPacketAcknowledgementsRequest{
PortId: path.EndpointA.ChannelConfig.PortID,
ChannelId: path.EndpointA.ChannelID,
PacketCommitmentSequences: commitments,
Pagination: nil,
}
},
true,
},
{
"success",
func() {
Expand Down
3 changes: 2 additions & 1 deletion modules/core/04-channel/types/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const (
// invalid constants used for testing
invalidPort = "(invalidport1)"
invalidShortPort = "p"
invalidLongPort = "invalidlongportinvalidlongportinvalidlongportidinvalidlongportidinvalid"
// 195 characters
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"

invalidChannel = "(invalidchannel1)"
invalidShortChannel = "invalid"
Expand Down
Loading

0 comments on commit d059913

Please sign in to comment.