Skip to content

Commit

Permalink
feat: Add server implementation of Group module (#10570)
Browse files Browse the repository at this point in the history
<!--
The default pull request template is for types feat, fix, or refactor.
For other templates, add one of the following parameters to the url:
- template=docs.md
- template=other.md
-->

## Description

Closes: #9897
Closes: #9905

Adds server implementation of Group module and wires it up in simapp

---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting))
- [x] provided a link to the relevant issue or specification
- [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules)
- [x] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [x] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [x] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed 
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
  • Loading branch information
likhita-809 committed Dec 10, 2021
1 parent fec3577 commit 3495691
Show file tree
Hide file tree
Showing 31 changed files with 7,014 additions and 725 deletions.
271 changes: 200 additions & 71 deletions docs/core/proto-docs.md

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/cosmos/btcutil v1.0.4
github.com/cosmos/cosmos-proto v0.0.0-20211123144845-528f5002c9f8
github.com/cosmos/cosmos-sdk/db v0.0.0
github.com/cosmos/cosmos-sdk/x/group v0.0.0-00010101000000-000000000000
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/iavl v0.17.3
github.com/cosmos/ledger-cosmos-go v0.11.1
Expand Down Expand Up @@ -65,6 +66,7 @@ require (
github.com/cenkalti/backoff/v4 v4.1.1 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cockroachdb/apd/v2 v2.0.2 // indirect
github.com/cosmos/ledger-go v0.9.2 // indirect
github.com/danieljoos/wincred v1.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
Expand Down Expand Up @@ -151,3 +153,5 @@ replace github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210
replace github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.7.0

replace github.com/cosmos/cosmos-sdk/db => ./db

replace github.com/cosmos/cosmos-sdk/x/group => ./x/group
85 changes: 83 additions & 2 deletions go.sum

Large diffs are not rendered by default.

57 changes: 57 additions & 0 deletions proto/cosmos/group/v1beta1/events.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
syntax = "proto3";

package cosmos.group.v1beta1;

import "cosmos_proto/cosmos.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/group";

// EventCreateGroup is an event emitted when a group is created.
message EventCreateGroup {

// group_id is the unique ID of the group.
uint64 group_id = 1;
}

// EventUpdateGroup is an event emitted when a group is updated.
message EventUpdateGroup {

// group_id is the unique ID of the group.
uint64 group_id = 1;
}

// EventCreateGroupAccount is an event emitted when a group account is created.
message EventCreateGroupAccount {

// address is the address of the group account.
string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];;
}

// EventUpdateGroupAccount is an event emitted when a group account is updated.
message EventUpdateGroupAccount {

// address is the address of the group account.
string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];;
}

// EventCreateProposal is an event emitted when a proposal is created.
message EventCreateProposal {

// proposal_id is the unique ID of the proposal.
uint64 proposal_id = 1;
}

// EventVote is an event emitted when a voter votes on a proposal.
message EventVote {

// proposal_id is the unique ID of the proposal.
uint64 proposal_id = 1;
}

// EventExec is an event emitted when a proposal is executed.
message EventExec {

// proposal_id is the unique ID of the proposal.
uint64 proposal_id = 1;
}

10 changes: 5 additions & 5 deletions proto/cosmos/group/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ message QueryGroupAccountInfoResponse {
GroupAccountInfo info = 1;
}

// QueryGroupMembersRequest is the Query/GroupMembersRequest request type.
// QueryGroupMembersRequest is the Query/GroupMembers request type.
message QueryGroupMembersRequest {

// group_id is the unique ID of the group.
Expand All @@ -93,7 +93,7 @@ message QueryGroupMembersResponse {
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// QueryGroupsByAdminRequest is the Query/GroupsByAdminRequest request type.
// QueryGroupsByAdminRequest is the Query/GroupsByAdmin request type.
message QueryGroupsByAdminRequest {

// admin is the account address of a group's admin.
Expand Down Expand Up @@ -187,7 +187,7 @@ message QueryProposalsByGroupAccountResponse {
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// QueryVoteByProposalVoterResponse is the Query/VoteByProposalVoter request type.
// QueryVoteByProposalVoterRequest is the Query/VoteByProposalVoter request type.
message QueryVoteByProposalVoterRequest {

// proposal_id is the unique ID of a proposal.
Expand All @@ -204,7 +204,7 @@ message QueryVoteByProposalVoterResponse {
Vote vote = 1;
}

// QueryVotesByProposalResponse is the Query/VotesByProposal request type.
// QueryVotesByProposalRequest is the Query/VotesByProposal request type.
message QueryVotesByProposalRequest {

// proposal_id is the unique ID of a proposal.
Expand All @@ -224,7 +224,7 @@ message QueryVotesByProposalResponse {
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// QueryVotesByVoterResponse is the Query/VotesByVoter request type.
// QueryVotesByVoterRequest is the Query/VotesByVoter request type.
message QueryVotesByVoterRequest {
// voter is a proposal voter account address.
string voter = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
Expand Down
66 changes: 33 additions & 33 deletions proto/cosmos/group/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,46 +13,46 @@ import "cosmos/group/v1beta1/types.proto";
service Msg {

// CreateGroup creates a new group with an admin account address, a list of members and some optional metadata.
rpc CreateGroup(MsgCreateGroupRequest) returns (MsgCreateGroupResponse);
rpc CreateGroup(MsgCreateGroup) returns (MsgCreateGroupResponse);

// UpdateGroupMembers updates the group members with given group id and admin address.
rpc UpdateGroupMembers(MsgUpdateGroupMembersRequest) returns (MsgUpdateGroupMembersResponse);
rpc UpdateGroupMembers(MsgUpdateGroupMembers) returns (MsgUpdateGroupMembersResponse);

// UpdateGroupAdmin updates the group admin with given group id and previous admin address.
rpc UpdateGroupAdmin(MsgUpdateGroupAdminRequest) returns (MsgUpdateGroupAdminResponse);
rpc UpdateGroupAdmin(MsgUpdateGroupAdmin) returns (MsgUpdateGroupAdminResponse);

// UpdateGroupMetadata updates the group metadata with given group id and admin address.
rpc UpdateGroupMetadata(MsgUpdateGroupMetadataRequest) returns (MsgUpdateGroupMetadataResponse);
rpc UpdateGroupMetadata(MsgUpdateGroupMetadata) returns (MsgUpdateGroupMetadataResponse);

// CreateGroupAccount creates a new group account using given DecisionPolicy.
rpc CreateGroupAccount(MsgCreateGroupAccountRequest) returns (MsgCreateGroupAccountResponse);
rpc CreateGroupAccount(MsgCreateGroupAccount) returns (MsgCreateGroupAccountResponse);

// UpdateGroupAccountAdmin updates a group account admin.
rpc UpdateGroupAccountAdmin(MsgUpdateGroupAccountAdminRequest) returns (MsgUpdateGroupAccountAdminResponse);
rpc UpdateGroupAccountAdmin(MsgUpdateGroupAccountAdmin) returns (MsgUpdateGroupAccountAdminResponse);

// UpdateGroupAccountDecisionPolicy allows a group account decision policy to be updated.
rpc UpdateGroupAccountDecisionPolicy(MsgUpdateGroupAccountDecisionPolicyRequest)
rpc UpdateGroupAccountDecisionPolicy(MsgUpdateGroupAccountDecisionPolicy)
returns (MsgUpdateGroupAccountDecisionPolicyResponse);

// UpdateGroupAccountMetadata updates a group account metadata.
rpc UpdateGroupAccountMetadata(MsgUpdateGroupAccountMetadataRequest) returns (MsgUpdateGroupAccountMetadataResponse);
rpc UpdateGroupAccountMetadata(MsgUpdateGroupAccountMetadata) returns (MsgUpdateGroupAccountMetadataResponse);

// CreateProposal submits a new proposal.
rpc CreateProposal(MsgCreateProposalRequest) returns (MsgCreateProposalResponse);
rpc CreateProposal(MsgCreateProposal) returns (MsgCreateProposalResponse);

// Vote allows a voter to vote on a proposal.
rpc Vote(MsgVoteRequest) returns (MsgVoteResponse);
rpc Vote(MsgVote) returns (MsgVoteResponse);

// Exec executes a proposal.
rpc Exec(MsgExecRequest) returns (MsgExecResponse);
rpc Exec(MsgExec) returns (MsgExecResponse);
}

//
// Groups
//

// MsgCreateGroupRequest is the Msg/CreateGroup request type.
message MsgCreateGroupRequest {
// MsgCreateGroup is the Msg/CreateGroup request type.
message MsgCreateGroup {

// admin is the account address of the group admin.
string admin = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
Expand All @@ -71,8 +71,8 @@ message MsgCreateGroupResponse {
uint64 group_id = 1;
}

// MsgUpdateGroupMembersRequest is the Msg/UpdateGroupMembers request type.
message MsgUpdateGroupMembersRequest {
// MsgUpdateGroupMembers is the Msg/UpdateGroupMembers request type.
message MsgUpdateGroupMembers {

// admin is the account address of the group admin.
string admin = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
Expand All @@ -88,8 +88,8 @@ message MsgUpdateGroupMembersRequest {
// MsgUpdateGroupMembersResponse is the Msg/UpdateGroupMembers response type.
message MsgUpdateGroupMembersResponse {}

// MsgUpdateGroupAdminRequest is the Msg/UpdateGroupAdmin request type.
message MsgUpdateGroupAdminRequest {
// MsgUpdateGroupAdmin is the Msg/UpdateGroupAdmin request type.
message MsgUpdateGroupAdmin {

// admin is the current account address of the group admin.
string admin = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
Expand All @@ -104,8 +104,8 @@ message MsgUpdateGroupAdminRequest {
// MsgUpdateGroupAdminResponse is the Msg/UpdateGroupAdmin response type.
message MsgUpdateGroupAdminResponse {}

// MsgUpdateGroupMetadataRequest is the Msg/UpdateGroupMetadata request type.
message MsgUpdateGroupMetadataRequest {
// MsgUpdateGroupMetadata is the Msg/UpdateGroupMetadata request type.
message MsgUpdateGroupMetadata {

// admin is the account address of the group admin.
string admin = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
Expand All @@ -124,8 +124,8 @@ message MsgUpdateGroupMetadataResponse {}
// Group Accounts
//

// MsgCreateGroupAccountRequest is the Msg/CreateGroupAccount request type.
message MsgCreateGroupAccountRequest {
// MsgCreateGroupAccount is the Msg/CreateGroupAccount request type.
message MsgCreateGroupAccount {
option (gogoproto.goproto_getters) = false;

// admin is the account address of the group admin.
Expand All @@ -148,8 +148,8 @@ message MsgCreateGroupAccountResponse {
string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// MsgUpdateGroupAccountAdminRequest is the Msg/UpdateGroupAccountAdmin request type.
message MsgUpdateGroupAccountAdminRequest {
// MsgUpdateGroupAccountAdmin is the Msg/UpdateGroupAccountAdmin request type.
message MsgUpdateGroupAccountAdmin {

// admin is the account address of the group admin.
string admin = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
Expand All @@ -164,8 +164,8 @@ message MsgUpdateGroupAccountAdminRequest {
// MsgUpdateGroupAccountAdminResponse is the Msg/UpdateGroupAccountAdmin response type.
message MsgUpdateGroupAccountAdminResponse {}

// MsgUpdateGroupAccountDecisionPolicyRequest is the Msg/UpdateGroupAccountDecisionPolicy request type.
message MsgUpdateGroupAccountDecisionPolicyRequest {
// MsgUpdateGroupAccountDecisionPolicy is the Msg/UpdateGroupAccountDecisionPolicy request type.
message MsgUpdateGroupAccountDecisionPolicy {
option (gogoproto.goproto_getters) = false;

// admin is the account address of the group admin.
Expand All @@ -181,8 +181,8 @@ message MsgUpdateGroupAccountDecisionPolicyRequest {
// MsgUpdateGroupAccountDecisionPolicyResponse is the Msg/UpdateGroupAccountDecisionPolicy response type.
message MsgUpdateGroupAccountDecisionPolicyResponse {}

// MsgUpdateGroupAccountMetadataRequest is the Msg/UpdateGroupAccountMetadata request type.
message MsgUpdateGroupAccountMetadataRequest {
// MsgUpdateGroupAccountMetadata is the Msg/UpdateGroupAccountMetadata request type.
message MsgUpdateGroupAccountMetadata {

// admin is the account address of the group admin.
string admin = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
Expand Down Expand Up @@ -215,8 +215,8 @@ enum Exec {
EXEC_TRY = 1;
}

// MsgCreateProposalRequest is the Msg/CreateProposal request type.
message MsgCreateProposalRequest {
// MsgCreateProposal is the Msg/CreateProposal request type.
message MsgCreateProposal {
option (gogoproto.goproto_getters) = false;

// address is the group account address.
Expand Down Expand Up @@ -245,8 +245,8 @@ message MsgCreateProposalResponse {
uint64 proposal_id = 1;
}

// MsgVoteRequest is the Msg/Vote request type.
message MsgVoteRequest {
// MsgVote is the Msg/Vote request type.
message MsgVote {

// proposal is the unique ID of the proposal.
uint64 proposal_id = 1;
Expand All @@ -267,8 +267,8 @@ message MsgVoteRequest {
// MsgVoteResponse is the Msg/Vote response type.
message MsgVoteResponse {}

// MsgExecRequest is the Msg/Exec request type.
message MsgExecRequest {
// MsgExec is the Msg/Exec request type.
message MsgExec {

// proposal is the unique ID of the proposal.
uint64 proposal_id = 1;
Expand Down
4 changes: 0 additions & 4 deletions proto/cosmos/group/v1beta1/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@ message GroupAccountInfo {

// decision_policy specifies the group account's decision policy.
google.protobuf.Any decision_policy = 6 [(cosmos_proto.accepts_interface) = "DecisionPolicy"];

// derivation_key is the "derivation" key of the group account,
// which is needed to derive the group root module key and execute proposals.
bytes derivation_key = 7;
}

// Proposal defines a group proposal. Any member of a group can submit a proposal
Expand Down
Loading

0 comments on commit 3495691

Please sign in to comment.