Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
feat!: support for custom proposal-based voting periods (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderbez authored May 20, 2022
1 parent a4201aa commit a2fcb7a
Show file tree
Hide file tree
Showing 17 changed files with 745 additions and 203 deletions.
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.

3 changes: 2 additions & 1 deletion x/gov/client/testutil/cli_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build norace
// +build norace

package testutil
Expand All @@ -21,7 +22,7 @@ func TestIntegrationTestSuite(t *testing.T) {

genesisState := types.DefaultGenesisState()
genesisState.DepositParams = types.NewDepositParams(sdk.NewCoins(sdk.NewCoin(cfg.BondDenom, types.DefaultMinDepositTokens)), time.Duration(15)*time.Second)
genesisState.VotingParams = types.NewVotingParams(time.Duration(5) * time.Second)
genesisState.VotingParams = types.NewVotingParams(time.Duration(5)*time.Second, []types.ProposalVotingPeriod{})
bz, err := cfg.Codec.MarshalJSON(genesisState)
require.NoError(t, err)
cfg.GenesisState["gov"] = bz
Expand Down
Loading

0 comments on commit a2fcb7a

Please sign in to comment.