Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring in upstream changes through v0.46.13 #572

Merged
merged 51 commits into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
a8556b6
fix: create snapshot dir for rocksdb backend (backport #15054) (#15065)
mergify[bot] Feb 17, 2023
5848fd3
chore: Add check for uneven stores' height (backport #14410) (#15115)
mergify[bot] Feb 21, 2023
8499d16
refactor!: remove store v2alpha1 (#15152)
julienrbrt Feb 24, 2023
3aaaf2c
build: use cometbft in v0.46 (#15090)
julienrbrt Feb 24, 2023
f1ec5fe
chore: bump cometbft to v0.34.27 final (#15206)
julienrbrt Feb 27, 2023
1229bd1
fix: Change proposer address cast for `sdk_block` conversion (backpor…
mergify[bot] Mar 2, 2023
578c160
fix: revert double close fix (#15255)
julienrbrt Mar 3, 2023
5023392
chore: prepare v0.46.11 release (#15259)
julienrbrt Mar 3, 2023
570392a
feat: add extend cb to avoid unmarshal state twice for sim test (back…
mmsqe Mar 9, 2023
f939979
feat: add extend cb with genesisState for sim test (backport: #15305)…
mmsqe Mar 10, 2023
f382e43
fix: add extra check in vesting (backport #15373) (#15383)
mergify[bot] Mar 14, 2023
e1da9c5
docs: update cosmwasm link (#15441)
tac0turtle Mar 17, 2023
431e42a
fix: remove extra `;` in service.proto (#15443)
julienrbrt Mar 17, 2023
8726f42
fix: flaky group genesis sim (backport #15447) (#15461)
mergify[bot] Mar 20, 2023
31adbba
feat: add delegator to withdraw address (backport #15462) (#15473)
mergify[bot] Mar 20, 2023
8d053c2
docs: improve proto vesting docs about time attributes (backport #154…
mergify[bot] Mar 20, 2023
cc39456
feat: add query `groups` in `x/group` (backport #14879) (#15476)
mergify[bot] Mar 20, 2023
cb26943
fix: Makefile rocksdb (backport #15422) (#15525)
mergify[bot] Mar 23, 2023
f89d955
fix(x/gov): Return ErrInvalidProposalContent in SubmitProposal when l…
yihuang Apr 3, 2023
152465b
fix: remove unnecessary cms typecasting (backport #14054) (#15669)
mergify[bot] Apr 3, 2023
5cd0b23
chore: prepare v0.46.12 release notes (#15685)
julienrbrt Apr 4, 2023
1a47cb2
fix: upstream error on empty version (backport #13355) (#15717)
mergify[bot] Apr 6, 2023
95f529e
feat: More flexibility for `CacheMultiStoreWithVersion` (backport #15…
mergify[bot] Apr 11, 2023
742856f
feat: add moduleStateCb to allow access moduleState in sim test (back…
mergify[bot] Apr 24, 2023
83eef6b
build(deps): bump cometbft to v0.34.28 (#15973)
julienrbrt Apr 28, 2023
5e199ca
chore(gov): improve proposal conversion error message (backport #1597…
mergify[bot] Apr 28, 2023
738220a
feat!: bootstrap comet cmd for local state sync (backport #16061) (#…
mergify[bot] May 10, 2023
dcf04af
chore(auth/vesting): fix typo in `create-period-vesting-account` cmd …
mergify[bot] May 10, 2023
10cc30f
feat: add local snapshots management commands (backport #16067) (#16103)
mergify[bot] May 12, 2023
5472fb5
fix: snapshot commands panic if snapshot don't exists (backport #1613…
mergify[bot] May 13, 2023
557da6e
feat: add Close method for resource cleanup in graceful shutdown (bac…
mergify[bot] May 19, 2023
5b02d46
feat: save restored snapshot locally (backport #16060) (#16262)
mergify[bot] May 24, 2023
a9abe1c
chore: update sidebar v0.46 (#16304)
julienrbrt May 26, 2023
59f6714
chore: add baseapp circuit breaker setter (#16289)
tac0turtle May 26, 2023
265b8a6
fix: allow any address in `ValidatePromptAddress` (backport #16312) (…
mergify[bot] May 26, 2023
863ad92
feat(group): add group event tally result (backport #16191) (#16306)
mergify[bot] May 26, 2023
5b4c593
fix: Revert "fix(x/gov): Return ErrInvalidProposalContent in SubmitPr…
yihuang May 30, 2023
26405d9
chore: prepare v0.46.13 (#16249)
julienrbrt Jun 2, 2023
67f33bd
chore: small snapshot commands & docs improvement (backport #16404) (…
mergify[bot] Jun 2, 2023
9f649b4
Merge tag 'v0.46.11' into prov/dwedul/bump-to-0.46.13
SpicyLemon Jun 2, 2023
7d43a5a
Add the quarantine and sanction stores to the import-export sim test.
SpicyLemon Jun 2, 2023
d605ffa
Merge tag 'v0.46.12' into prov/dwedul/bump-to-0.46.13
SpicyLemon Jun 2, 2023
7ee7809
refactor: avoid breaking change due to #16415 included in v0.50 (back…
mergify[bot] Jun 6, 2023
d4b7164
chore: prepare v0.46.13 (2/2) (#16443)
julienrbrt Jun 8, 2023
fd90480
fix: patch barberry (#16466)
julienrbrt Jun 8, 2023
476aaa4
Merge branch 'main-pio' into prov/dwedul/bump-to-0.46.13
SpicyLemon Jun 8, 2023
dec6c7c
Merge tag 'v0.46.13' into prov/dwedul/bump-to-0.46.13
SpicyLemon Jun 8, 2023
8f0c6d2
Better gov prop error handling.
SpicyLemon Jun 8, 2023
648bf54
Fix the group sims random genesis so it can't pick the same account t…
SpicyLemon Jun 8, 2023
be8a998
Add changelog entries.
SpicyLemon Jun 8, 2023
ca1fee0
Regen the swagger docs.
SpicyLemon Jun 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: add query groups in x/group (backport cosmos#14879) (cosmos…
…#15476)

Co-authored-by: atheeshp <[email protected]>
Co-authored-by: marbar3778 <[email protected]>
  • Loading branch information
3 people committed Mar 20, 2023
commit cc39456c98482ccc581260db4989fc59e4f2515b
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

### Features

* (x/groups) [#14879](https://github.com/cosmos/cosmos-sdk/pull/14879) Add `Query/Groups` query to get all the groups.

### Improvements

* (simapp) [#15305](https://github.com/cosmos/cosmos-sdk/pull/15305) Add `AppStateFnWithExtendedCb` with callback function to extend rawState and `AppStateRandomizedFnWithState` with extra genesisState argument which is the genesis state of the app.
Expand Down
27 changes: 27 additions & 0 deletions proto/cosmos/group/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ service Query {
rpc TallyResult(QueryTallyResultRequest) returns (QueryTallyResultResponse) {
option (google.api.http).get = "/cosmos/group/v1/proposals/{proposal_id}/tally";
};

// Groups queries all groups in state.
//
// Since: cosmos-sdk 0.47.1
rpc Groups(QueryGroupsRequest) returns (QueryGroupsResponse) {
option (google.api.http).get = "/cosmos/group/v1/groups";
};
}

// QueryGroupInfoRequest is the Query/GroupInfo request type.
Expand Down Expand Up @@ -311,3 +318,23 @@ message QueryTallyResultResponse {
// tally defines the requested tally.
TallyResult tally = 1 [(gogoproto.nullable) = false];
}

// QueryGroupsRequest is the Query/Groups request type.
//
// Since: cosmos-sdk 0.47.1
message QueryGroupsRequest {

// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 2;
}

// QueryGroupsResponse is the Query/Groups response type.
//
// Since: cosmos-sdk 0.47.1
message QueryGroupsResponse {
// `groups` is all the groups present in state.
repeated GroupInfo groups = 1;

// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
35 changes: 35 additions & 0 deletions x/group/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func QueryCmd(name string) *cobra.Command {
QueryVotesByVoterCmd(),
QueryGroupsByMemberCmd(),
QueryTallyResultCmd(),
QueryGroupsCmd(),
)

return queryCmd
Expand Down Expand Up @@ -504,3 +505,37 @@ func QueryVotesByVoterCmd() *cobra.Command {

return cmd
}

func QueryGroupsCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "groups",
Short: "Query for groups present in the state",
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

pageReq, err := client.ReadPageRequest(cmd.Flags())
if err != nil {
return err
}

queryClient := group.NewQueryClient(clientCtx)

res, err := queryClient.Groups(cmd.Context(), &group.QueryGroupsRequest{
Pagination: pageReq,
})
if err != nil {
return err
}

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)
flags.AddPaginationFlagsToCmd(cmd, "groups")

return cmd
}
49 changes: 49 additions & 0 deletions x/group/client/testutil/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,55 @@ func (s *IntegrationTestSuite) TestQueryGroupsByMembers() {
}
}

func (s *IntegrationTestSuite) TestQueryGroups() {
val := s.network.Validators[0]
clientCtx := val.ClientCtx
require := s.Require()

testCases := []struct {
name string
args []string
expectErr bool
expectErrMsg string
numItems int
expectGroups []*group.GroupInfo
}{
{
name: "valid req",
args: []string{fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
expectErr: false,
numItems: 5,
},
{
name: "valid req with pagination",
args: []string{
"--limit=2",
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
},
expectErr: false,
numItems: 2,
},
}

for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
cmd := client.QueryGroupsCmd()
out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args)
if tc.expectErr {
require.Contains(out.String(), tc.expectErrMsg)
} else {
require.NoError(err, out.String())

var resp group.QueryGroupsResponse
val.ClientCtx.Codec.MustUnmarshalJSON(out.Bytes(), &resp)

require.Len(resp.Groups, tc.numItems)
}
})
}
}

func (s *IntegrationTestSuite) TestQueryGroupMembers() {
val := s.network.Validators[0]
clientCtx := val.ClientCtx
Expand Down
23 changes: 23 additions & 0 deletions x/group/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper

import (
"context"
"math"

"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
Expand Down Expand Up @@ -346,3 +347,25 @@ func (k Keeper) TallyResult(goCtx context.Context, request *group.QueryTallyResu
Tally: tallyResult,
}, nil
}

// Groups returns all the groups present in the state.
func (k Keeper) Groups(goCtx context.Context, request *group.QueryGroupsRequest) (*group.QueryGroupsResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)

it, err := k.groupTable.PrefixScan(ctx.KVStore(k.key), 1, math.MaxUint64)
if err != nil {
return nil, err
}
defer it.Close()

var groups []*group.GroupInfo
pageRes, err := orm.Paginate(it, request.Pagination, &groups)
if err != nil {
return nil, err
}

return &group.QueryGroupsResponse{
Groups: groups,
Pagination: pageRes,
}, nil
}
Loading