This repository has been archived by the owner on Aug 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start on new protobuf group spec regen-network/regen-ledger#95
- Loading branch information
Showing
22 changed files
with
9,847 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# modules to build in CI | ||
SUBDIRS = incubator/orm | ||
SUBDIRS = incubator/orm incubator/group | ||
|
||
test: test-unit | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.PHONY: vendor proto-gen protoc-gen-gocosmos test | ||
|
||
protoc-gen-gocosmos: | ||
@echo "Installing protoc-gen-gocosmos..." | ||
@go install github.com/regen-network/cosmos-proto/protoc-gen-gocosmos | ||
|
||
vendor: | ||
go mod vendor | ||
|
||
proto-gen: vendor | ||
./protocgen.sh | ||
|
||
test: | ||
@go test -mod=readonly -race ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Group Module | ||
|
||
## Group | ||
|
||
A group is simply an aggregation of accounts with associated weights. It is not | ||
an account and doesn't have a balance. It doesn't in and of itself have any | ||
sort of voting or decision power. It does have an "administrator" which has | ||
the power to add, remove and update members in the group. Note that a | ||
group account could be an administrator of a group. | ||
|
||
## Group Account | ||
|
||
A group account is an account associated with a group and a decision policy. | ||
Group accounts are abstracted from groups because a single group may have | ||
multiple decision policies for different types of actions. Managing group | ||
membership separately from decision policies results in the least overhead | ||
and keeps membership consistent across different policies. The pattern that | ||
is recommended is to have a single master group account for a given group, | ||
and then to create separate group accounts with different decision policies | ||
and delegate the desired permissions to from the master account to | ||
those "sub-accounts" using the `msg_authorization` module. | ||
|
||
|
||
## Decision Policy | ||
|
||
A decision policy is the mechanism by which members of a group can vote on | ||
proposals. | ||
|
||
All decision policies generally would have a minimum and maximum voting window. | ||
The minimum voting window is the minimum amount of time that must pass in order | ||
for a proposal to potentially pass, and it may be set to 0. The maximum voting | ||
window is the maximum time that a proposal may be voted on before it is closed. | ||
Both of these values must be less than a chain-wide max voting window parameter. | ||
|
||
### Threshold decision policy | ||
|
||
A threshold decision policy defines a threshold of yes votes (based on a tally | ||
of voter weights) that must be achieved in order for a proposal to pass. For | ||
this decision policy, abstain and veto are simply treated as no's. | ||
|
||
## Proposal | ||
|
||
Any member of a group can submit a proposal for a group account to decide upon. | ||
A proposal consists of a set of `sdk.Msg`s that will be executed if the proposal | ||
passes as well as any comment associated with the proposal. | ||
|
||
## Voting | ||
|
||
There are four choices to choose while voting - yes, no, abstain and veto. Not | ||
all decision policies will support them. Votes can contain an optional comment. | ||
During the voting window, accounts that have already voted may change their vote. | ||
In the current implementation, the voting window begins as soon as a proposal | ||
is submitted. | ||
|
||
## Executing Proposals | ||
|
||
Proposals will not be automatically executed by the chain in this current design, | ||
but rather a user must submit a `MsgExec` transaction to attempt to execute the | ||
proposal based on the current votes and decision policy. A future upgrade could | ||
automate this propose and have the group account (or a fee granter) pay. | ||
|
||
## Changing Group Membership | ||
|
||
In the current implementation, changing a group's membership (adding or removing members or changing their power) | ||
will cause all existing proposals for group accounts linked to this group | ||
to be invalidated. They will simply fail if someone calls `MsgExec` and will | ||
eventually be garbage collected. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package group | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
) | ||
|
||
type Codec struct { | ||
codec.Marshaler | ||
|
||
// Keep reference to the amino codec to allow backwards compatibility along | ||
// with type, and interface registration. | ||
amino *codec.Codec | ||
} | ||
|
||
func NewCodec(amino *codec.Codec) *Codec { | ||
return &Codec{Marshaler: codec.NewHybridCodec(amino), amino: amino} | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
// RegisterCodec registers all the necessary crisis module concrete types and | ||
// interfaces with the provided codec reference. | ||
func RegisterCodec(cdc *codec.Codec) { | ||
cdc.RegisterConcrete(MsgCreateGroup{}, "ccosmos-sdk/MsgCreateGroup", nil) | ||
} | ||
|
||
// generic sealed codec to be used throughout module | ||
var ModuleCdc *Codec | ||
|
||
func init() { | ||
ModuleCdc = NewCodec(codec.New()) | ||
RegisterCodec(ModuleCdc.amino) | ||
codec.RegisterCrypto(ModuleCdc.amino) | ||
ModuleCdc.amino.Seal() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package group | ||
|
||
import sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||
|
||
var ( | ||
ErrEmpty = sdkerrors.Register(ModuleName, 1, "value is empty") | ||
ErrDuplicate = sdkerrors.Register(ModuleName, 2, "duplicate value") | ||
ErrMaxLimit = sdkerrors.Register(ModuleName, 3, "limit exceeded") | ||
ErrType = sdkerrors.Register(ModuleName, 4, "invalid type") | ||
ErrInvalid = sdkerrors.Register(ModuleName, 5, "invalid value") | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package group | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
// GenesisState is the state that must be provided at genesis. | ||
type GenesisState struct { | ||
Params Params `json:"params" yaml:"params"` | ||
} | ||
|
||
// NewGenesisState creates a new genesis state with default values. | ||
func NewGenesisState() GenesisState { | ||
return GenesisState{ | ||
Params: DefaultParams(), | ||
} | ||
} | ||
|
||
func (s GenesisState) Validate() error { | ||
return s.Params.Validate() | ||
} | ||
|
||
// ExportGenesis returns a GenesisState for a given context and Keeper. | ||
func ExportGenesis(ctx sdk.Context, k Keeper) GenesisState { | ||
return GenesisState{ | ||
Params: k.getParams(ctx), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module github.com/cosmos/modules/incubator/group | ||
|
||
go 1.13 | ||
|
||
require ( | ||
github.com/cosmos/cosmos-sdk v0.34.4-0.20200211145837-56c586897525 | ||
github.com/cosmos/modules/incubator/orm v0.0.0-20200117100147-88228b5fa693 | ||
github.com/gogo/protobuf v1.3.1 | ||
github.com/gorilla/mux v1.7.3 | ||
github.com/pkg/errors v0.9.1 | ||
github.com/spf13/cobra v0.0.5 | ||
github.com/stretchr/testify v1.4.0 | ||
github.com/tendermint/tendermint v0.33.0 | ||
github.com/tendermint/tm-db v0.4.0 | ||
gopkg.in/yaml.v2 v2.2.8 | ||
) | ||
|
||
replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.2-alpha.regen.1 | ||
|
||
//replace github.com/cosmos/modules/incubator/orm => github.com/regen-network/cosmos-modules/incubator/orm v0.0.0-20200206151518-3155fe39bfb9 | ||
replace github.com/cosmos/modules/incubator/orm => ../orm |
Oops, something went wrong.