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

feat!: support for custom proposal-based voting periods #239

Merged
merged 15 commits into from
May 20, 2022
174 changes: 105 additions & 69 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@
- [cosmos/base/snapshots/v1beta1/snapshot.proto](#cosmos/base/snapshots/v1beta1/snapshot.proto)
- [Metadata](#cosmos.base.snapshots.v1beta1.Metadata)
- [Snapshot](#cosmos.base.snapshots.v1beta1.Snapshot)
- [SnapshotExtensionMeta](#cosmos.base.snapshots.v1beta1.SnapshotExtensionMeta)
- [SnapshotExtensionPayload](#cosmos.base.snapshots.v1beta1.SnapshotExtensionPayload)
- [SnapshotIAVLItem](#cosmos.base.snapshots.v1beta1.SnapshotIAVLItem)
- [SnapshotItem](#cosmos.base.snapshots.v1beta1.SnapshotItem)
- [SnapshotStoreItem](#cosmos.base.snapshots.v1beta1.SnapshotStoreItem)

- [cosmos/base/store/v1beta1/commit_info.proto](#cosmos/base/store/v1beta1/commit_info.proto)
- [CommitID](#cosmos.base.store.v1beta1.CommitID)
Expand All @@ -172,11 +177,6 @@
- [cosmos/base/store/v1beta1/listening.proto](#cosmos/base/store/v1beta1/listening.proto)
- [StoreKVPair](#cosmos.base.store.v1beta1.StoreKVPair)

- [cosmos/base/store/v1beta1/snapshot.proto](#cosmos/base/store/v1beta1/snapshot.proto)
- [SnapshotIAVLItem](#cosmos.base.store.v1beta1.SnapshotIAVLItem)
- [SnapshotItem](#cosmos.base.store.v1beta1.SnapshotItem)
- [SnapshotStoreItem](#cosmos.base.store.v1beta1.SnapshotStoreItem)

- [cosmos/base/tendermint/v1beta1/query.proto](#cosmos/base/tendermint/v1beta1/query.proto)
- [GetBlockByHeightRequest](#cosmos.base.tendermint.v1beta1.GetBlockByHeightRequest)
- [GetBlockByHeightResponse](#cosmos.base.tendermint.v1beta1.GetBlockByHeightResponse)
Expand Down Expand Up @@ -343,6 +343,7 @@
- [Deposit](#cosmos.gov.v1beta1.Deposit)
- [DepositParams](#cosmos.gov.v1beta1.DepositParams)
- [Proposal](#cosmos.gov.v1beta1.Proposal)
- [ProposalVotingPeriod](#cosmos.gov.v1beta1.ProposalVotingPeriod)
- [TallyParams](#cosmos.gov.v1beta1.TallyParams)
- [TallyResult](#cosmos.gov.v1beta1.TallyResult)
- [TextProposal](#cosmos.gov.v1beta1.TextProposal)
Expand Down Expand Up @@ -2706,68 +2707,83 @@ Snapshot contains Tendermint state sync snapshot info.



<!-- end messages -->

<!-- end enums -->
<a name="cosmos.base.snapshots.v1beta1.SnapshotExtensionMeta"></a>

<!-- end HasExtensions -->
### SnapshotExtensionMeta
SnapshotExtensionMeta contains metadata about an external snapshotter.

<!-- end services -->

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `name` | [string](#string) | | |
| `format` | [uint32](#uint32) | | |


<a name="cosmos/base/store/v1beta1/commit_info.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## cosmos/base/store/v1beta1/commit_info.proto



<a name="cosmos.base.store.v1beta1.CommitID"></a>
<a name="cosmos.base.snapshots.v1beta1.SnapshotExtensionPayload"></a>

### CommitID
CommitID defines the committment information when a specific store is
committed.
### SnapshotExtensionPayload
SnapshotExtensionPayload contains payloads of an external snapshotter.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `version` | [int64](#int64) | | |
| `hash` | [bytes](#bytes) | | |
| `payload` | [bytes](#bytes) | | |






<a name="cosmos.base.store.v1beta1.CommitInfo"></a>
<a name="cosmos.base.snapshots.v1beta1.SnapshotIAVLItem"></a>

### CommitInfo
CommitInfo defines commit information used by the multi-store when committing
a version/height.
### SnapshotIAVLItem
SnapshotIAVLItem is an exported IAVL node.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `version` | [int64](#int64) | | |
| `store_infos` | [StoreInfo](#cosmos.base.store.v1beta1.StoreInfo) | repeated | |
| `key` | [bytes](#bytes) | | |
| `value` | [bytes](#bytes) | | |
| `version` | [int64](#int64) | | version is block height |
| `height` | [int32](#int32) | | height is depth of the tree. |






<a name="cosmos.base.store.v1beta1.StoreInfo"></a>
<a name="cosmos.base.snapshots.v1beta1.SnapshotItem"></a>

### SnapshotItem
SnapshotItem is an item contained in a rootmulti.Store snapshot.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `store` | [SnapshotStoreItem](#cosmos.base.snapshots.v1beta1.SnapshotStoreItem) | | |
| `iavl` | [SnapshotIAVLItem](#cosmos.base.snapshots.v1beta1.SnapshotIAVLItem) | | |
| `extension` | [SnapshotExtensionMeta](#cosmos.base.snapshots.v1beta1.SnapshotExtensionMeta) | | |
| `extension_payload` | [SnapshotExtensionPayload](#cosmos.base.snapshots.v1beta1.SnapshotExtensionPayload) | | |



### StoreInfo
StoreInfo defines store-specific commit information. It contains a reference
between a store name and the commit ID.



<a name="cosmos.base.snapshots.v1beta1.SnapshotStoreItem"></a>

### SnapshotStoreItem
SnapshotStoreItem contains metadata about a snapshotted store.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `name` | [string](#string) | | |
| `commit_id` | [CommitID](#cosmos.base.store.v1beta1.CommitID) | | |



Expand All @@ -2783,94 +2799,96 @@ between a store name and the commit ID.



<a name="cosmos/base/store/v1beta1/listening.proto"></a>
<a name="cosmos/base/store/v1beta1/commit_info.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## cosmos/base/store/v1beta1/listening.proto

## cosmos/base/store/v1beta1/commit_info.proto


<a name="cosmos.base.store.v1beta1.StoreKVPair"></a>

### StoreKVPair
StoreKVPair is a KVStore KVPair used for listening to state changes (Sets and Deletes)
It optionally includes the StoreKey for the originating KVStore and a Boolean flag to distinguish between Sets and
Deletes
<a name="cosmos.base.store.v1beta1.CommitID"></a>

Since: cosmos-sdk 0.43
### CommitID
CommitID defines the committment information when a specific store is
committed.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `store_key` | [string](#string) | | the store key for the KVStore this pair originates from |
| `delete` | [bool](#bool) | | true indicates a delete operation, false indicates a set operation |
| `key` | [bytes](#bytes) | | |
| `value` | [bytes](#bytes) | | |
| `version` | [int64](#int64) | | |
| `hash` | [bytes](#bytes) | | |





<!-- end messages -->

<!-- end enums -->
<a name="cosmos.base.store.v1beta1.CommitInfo"></a>

<!-- end HasExtensions -->
### CommitInfo
CommitInfo defines commit information used by the multi-store when committing
a version/height.

<!-- end services -->

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `version` | [int64](#int64) | | |
| `store_infos` | [StoreInfo](#cosmos.base.store.v1beta1.StoreInfo) | repeated | |


<a name="cosmos/base/store/v1beta1/snapshot.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## cosmos/base/store/v1beta1/snapshot.proto



<a name="cosmos.base.store.v1beta1.SnapshotIAVLItem"></a>
<a name="cosmos.base.store.v1beta1.StoreInfo"></a>

### SnapshotIAVLItem
SnapshotIAVLItem is an exported IAVL node.
### StoreInfo
StoreInfo defines store-specific commit information. It contains a reference
between a store name and the commit ID.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `key` | [bytes](#bytes) | | |
| `value` | [bytes](#bytes) | | |
| `version` | [int64](#int64) | | |
| `height` | [int32](#int32) | | |
| `name` | [string](#string) | | |
| `commit_id` | [CommitID](#cosmos.base.store.v1beta1.CommitID) | | |





<!-- end messages -->

<a name="cosmos.base.store.v1beta1.SnapshotItem"></a>
<!-- end enums -->

### SnapshotItem
SnapshotItem is an item contained in a rootmulti.Store snapshot.
<!-- end HasExtensions -->

<!-- end services -->

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `store` | [SnapshotStoreItem](#cosmos.base.store.v1beta1.SnapshotStoreItem) | | |
| `iavl` | [SnapshotIAVLItem](#cosmos.base.store.v1beta1.SnapshotIAVLItem) | | |


<a name="cosmos/base/store/v1beta1/listening.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## cosmos/base/store/v1beta1/listening.proto



<a name="cosmos.base.store.v1beta1.StoreKVPair"></a>

<a name="cosmos.base.store.v1beta1.SnapshotStoreItem"></a>
### StoreKVPair
StoreKVPair is a KVStore KVPair used for listening to state changes (Sets and Deletes)
It optionally includes the StoreKey for the originating KVStore and a Boolean flag to distinguish between Sets and
Deletes

### SnapshotStoreItem
SnapshotStoreItem contains metadata about a snapshotted store.
Since: cosmos-sdk 0.43


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `name` | [string](#string) | | |
| `store_key` | [string](#string) | | the store key for the KVStore this pair originates from |
| `delete` | [bool](#bool) | | true indicates a delete operation, false indicates a set operation |
| `key` | [bytes](#bytes) | | |
| `value` | [bytes](#bytes) | | |



Expand Down Expand Up @@ -5025,6 +5043,23 @@ Proposal defines the core field members of a governance proposal.



<a name="cosmos.gov.v1beta1.ProposalVotingPeriod"></a>

### ProposalVotingPeriod
ProposalVotingPeriod defines custom voting periods for a unique governance
proposal type.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `proposal_type` | [string](#string) | | e.g. "cosmos.params.v1beta1.ParameterChangeProposal" |
| `voting_period` | [google.protobuf.Duration](#google.protobuf.Duration) | | |






<a name="cosmos.gov.v1beta1.TallyParams"></a>

### TallyParams
Expand Down Expand Up @@ -5104,7 +5139,8 @@ VotingParams defines the params for voting on governance proposals.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `voting_period` | [google.protobuf.Duration](#google.protobuf.Duration) | | Length of the voting period. |
| `voting_period` | [google.protobuf.Duration](#google.protobuf.Duration) | | voting_period defines the length of the voting period. |
| `proposal_voting_periods` | [ProposalVotingPeriod](#cosmos.gov.v1beta1.ProposalVotingPeriod) | repeated | proposal_voting_periods defines custom voting periods for proposal types. |



Expand Down Expand Up @@ -6510,7 +6546,7 @@ Params defines the parameters for the staking module.
| `historical_entries` | [uint32](#uint32) | | historical_entries is the number of historical entries to persist. |
| `bond_denom` | [string](#string) | | bond_denom defines the bondable coin denomination. |
| `min_commission_rate` | [string](#string) | | min_commission_rate is the chain-wide minimum commission rate that a validator can charge their delegators |
| `min_self_delegation` | [string](#string) | | min_self_delegation is the chain-wide minimum self delegation a validator can have |
| `min_self_delegation` | [string](#string) | | min_self_delegation is the chain-wide minimum amount that a validator has to self delegate |



Expand Down
17 changes: 16 additions & 1 deletion proto/cosmos/gov/v1beta1/gov.proto
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,16 @@ message DepositParams {

// VotingParams defines the params for voting on governance proposals.
message VotingParams {
// Length of the voting period.
// voting_period defines the length of the voting period.
google.protobuf.Duration voting_period = 1 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true,
(gogoproto.jsontag) = "voting_period,omitempty",
(gogoproto.moretags) = "yaml:\"voting_period\""
];

// proposal_voting_periods defines custom voting periods for proposal types.
repeated ProposalVotingPeriod proposal_voting_periods = 2 [(gogoproto.nullable) = false];
}

// TallyParams defines the params for tallying votes on governance proposals.
Expand Down Expand Up @@ -198,3 +201,15 @@ message TallyParams {
(gogoproto.moretags) = "yaml:\"veto_threshold\""
];
}

// ProposalVotingPeriod defines custom voting periods for a unique governance
// proposal type.
message ProposalVotingPeriod {
string proposal_type = 1; // e.g. "cosmos.params.v1beta1.ParameterChangeProposal"
google.protobuf.Duration voting_period = 2 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true,
(gogoproto.jsontag) = "voting_period,omitempty",
(gogoproto.moretags) = "yaml:\"voting_period\""
];
}
10 changes: 6 additions & 4 deletions snapshots/types/snapshot.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions x/gov/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ func (q Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types
return &types.QueryParamsResponse{DepositParams: depositParmas}, nil

case types.ParamVoting:
votingParmas := q.GetVotingParams(ctx)
return &types.QueryParamsResponse{VotingParams: votingParmas}, nil
votingParams := q.GetVotingParams(ctx)
return &types.QueryParamsResponse{VotingParams: votingParams}, nil
alexanderbez marked this conversation as resolved.
Show resolved Hide resolved

case types.ParamTallying:
tallyParams := q.GetTallyParams(ctx)
Expand Down