chore: x/gov v1 API audit changes (#11474)

## Description

ref: #11086 

---

### 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...

- [ ] 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
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules)
- [ ] 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`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] 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)
This commit is contained in:
likhita-809 2022-04-05 19:03:26 +05:30 committed by GitHub
parent 37a52afacd
commit 210e1092e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 852 additions and 121 deletions

View File

@ -5197,7 +5197,7 @@ func (VoteOption) EnumDescriptor() ([]byte, []int) {
type ProposalStatus int32
const (
// PROPOSAL_STATUS_UNSPECIFIED defines the default propopsal status.
// PROPOSAL_STATUS_UNSPECIFIED defines the default proposal status.
ProposalStatus_PROPOSAL_STATUS_UNSPECIFIED ProposalStatus = 0
// PROPOSAL_STATUS_DEPOSIT_PERIOD defines a proposal status during the deposit
// period.

View File

@ -8014,7 +8014,7 @@ type QueryVoteRequest struct {
// proposal_id defines the unique id of the proposal.
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
// voter defines the oter address for the proposals.
// voter defines the voter address for the proposals.
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
}

View File

@ -5546,7 +5546,7 @@ func (VoteOption) EnumDescriptor() ([]byte, []int) {
type ProposalStatus int32
const (
// PROPOSAL_STATUS_UNSPECIFIED defines the default propopsal status.
// PROPOSAL_STATUS_UNSPECIFIED defines the default proposal status.
ProposalStatus_PROPOSAL_STATUS_UNSPECIFIED ProposalStatus = 0
// PROPOSAL_STATUS_DEPOSIT_PERIOD defines a proposal status during the deposit
// period.

View File

@ -8013,7 +8013,7 @@ type QueryVoteRequest struct {
// proposal_id defines the unique id of the proposal.
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
// voter defines the oter address for the proposals.
// voter defines the voter address for the proposals.
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
}

View File

@ -60,7 +60,7 @@ message Proposal {
// ProposalStatus enumerates the valid statuses of a proposal.
enum ProposalStatus {
// PROPOSAL_STATUS_UNSPECIFIED defines the default propopsal status.
// PROPOSAL_STATUS_UNSPECIFIED defines the default proposal status.
PROPOSAL_STATUS_UNSPECIFIED = 0;
// PROPOSAL_STATUS_DEPOSIT_PERIOD defines a proposal status during the deposit
// period.

View File

@ -93,7 +93,7 @@ message QueryVoteRequest {
// proposal_id defines the unique id of the proposal.
uint64 proposal_id = 1;
// voter defines the oter address for the proposals.
// voter defines the voter address for the proposals.
string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

View File

@ -88,7 +88,7 @@ message Proposal {
enum ProposalStatus {
option (gogoproto.goproto_enum_prefix) = false;
// PROPOSAL_STATUS_UNSPECIFIED defines the default propopsal status.
// PROPOSAL_STATUS_UNSPECIFIED defines the default proposal status.
PROPOSAL_STATUS_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "StatusNil"];
// PROPOSAL_STATUS_DEPOSIT_PERIOD defines a proposal status during the deposit
// period.

View File

@ -98,7 +98,7 @@ message QueryVoteRequest {
// proposal_id defines the unique id of the proposal.
uint64 proposal_id = 1;
// voter defines the oter address for the proposals.
// voter defines the voter address for the proposals.
string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

View File

@ -90,8 +90,8 @@ $ %s query gov proposal 1
return cmd
}
// GetCmdQueryProposals implements a query proposals command. Command to Get a
// Proposal Information.
// GetCmdQueryProposals implements a query proposals command. Command to Get
// Proposals Information.
func GetCmdQueryProposals() *cobra.Command {
cmd := &cobra.Command{
Use: "proposals",
@ -179,7 +179,7 @@ $ %s query gov proposals --page=2 --limit=100
}
// GetCmdQueryVote implements the query proposal vote command. Command to Get a
// Proposal Information.
// Vote Information.
func GetCmdQueryVote() *cobra.Command {
cmd := &cobra.Command{
Use: "vote [proposal-id] [voter-addr]",
@ -337,7 +337,7 @@ $ %[1]s query gov votes 1 --page=2 --limit=100
}
// GetCmdQueryDeposit implements the query proposal deposit command. Command to
// get a specific Deposit Information
// get a specific Deposit Information.
func GetCmdQueryDeposit() *cobra.Command {
cmd := &cobra.Command{
Use: "deposit [proposal-id] [depositer-addr]",

View File

@ -48,7 +48,7 @@ var ProposalFlags = []string{
// NewTxCmd returns the transaction commands for this module
// governance ModuleClient is slightly different from other ModuleClients in that
// it contains a slice of "proposal" child commands. These commands are respective
// to proposal type handlers that are implemented in other modules but are mounted
// to the proposal type handlers that are implemented in other modules but are mounted
// under the governance CLI (eg. parameter change proposals).
func NewTxCmd(legacyPropCmds []*cobra.Command) *cobra.Command {
govTxCmd := &cobra.Command{

View File

@ -282,7 +282,7 @@ func (s *IntegrationTestSuite) TestCmdTally() {
func (s *IntegrationTestSuite) TestNewCmdSubmitProposal() {
val := s.network.Validators[0]
// Create an legacy proposal JSON, make sure it doesn't pass this new CLI
// Create a legacy proposal JSON, make sure it doesn't pass this new CLI
// command.
invalidProp := `{
"title": "",

View File

@ -34,7 +34,7 @@ func (p Proposer) String() string {
}
// QueryDepositsByTxQuery will query for deposits via a direct txs tags query. It
// will fetch and build deposits directly from the returned txs and return a
// will fetch and build deposits directly from the returned txs and returns a
// JSON marshalled result or any error that occurred.
//
// NOTE: SearchTxs is used to facilitate the txs query which does not currently
@ -103,7 +103,7 @@ func QueryDepositsByTxQuery(clientCtx client.Context, params v1.QueryProposalPar
}
// QueryVotesByTxQuery will query for votes via a direct txs tags query. It
// will fetch and build votes directly from the returned txs and return a JSON
// will fetch and build votes directly from the returned txs and returns a JSON
// marshalled result or any error that occurred.
func QueryVotesByTxQuery(clientCtx client.Context, params v1.QueryProposalVotesParams) ([]byte, error) {
var (

View File

@ -73,7 +73,7 @@ func (keeper Keeper) DeleteAndBurnDeposits(ctx sdk.Context, proposalID uint64) {
})
}
// IterateAllDeposits iterates over the all the stored deposits and performs a callback function
// IterateAllDeposits iterates over all the stored deposits and performs a callback function
func (keeper Keeper) IterateAllDeposits(ctx sdk.Context, cb func(deposit v1.Deposit) (stop bool)) {
store := ctx.KVStore(keeper.storeKey)
iterator := sdk.KVStorePrefixIterator(store, types.DepositsKeyPrefix)
@ -91,7 +91,7 @@ func (keeper Keeper) IterateAllDeposits(ctx sdk.Context, cb func(deposit v1.Depo
}
}
// IterateDeposits iterates over the all the proposals deposits and performs a callback function
// IterateDeposits iterates over all the proposals deposits and performs a callback function
func (keeper Keeper) IterateDeposits(ctx sdk.Context, proposalID uint64, cb func(deposit v1.Deposit) (stop bool)) {
store := ctx.KVStore(keeper.storeKey)
iterator := sdk.KVStorePrefixIterator(store, types.DepositsKey(proposalID))

View File

@ -10,7 +10,7 @@ import (
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
)
// SubmitProposal create new proposal given an array of messages
// SubmitProposal creates a new proposal given an array of messages
func (keeper Keeper) SubmitProposal(ctx sdk.Context, messages []sdk.Msg, metadata string) (v1.Proposal, error) {
err := keeper.assertMetadataLength(metadata)
if err != nil {
@ -91,7 +91,7 @@ func (keeper Keeper) SubmitProposal(ctx sdk.Context, messages []sdk.Msg, metadat
return proposal, nil
}
// GetProposal get proposal from store by ProposalID.
// GetProposal gets a proposal from store by ProposalID.
// Panics if can't unmarshal the proposal.
func (keeper Keeper) GetProposal(ctx sdk.Context, proposalID uint64) (v1.Proposal, bool) {
store := ctx.KVStore(keeper.storeKey)
@ -109,7 +109,7 @@ func (keeper Keeper) GetProposal(ctx sdk.Context, proposalID uint64) (v1.Proposa
return proposal, true
}
// SetProposal set a proposal to store.
// SetProposal sets a proposal to store.
// Panics if can't marshal the proposal.
func (keeper Keeper) SetProposal(ctx sdk.Context, proposal v1.Proposal) {
bz, err := keeper.MarshalProposal(proposal)

View File

@ -53,7 +53,7 @@ func (keeper Keeper) Tally(ctx sdk.Context, proposal v1.Proposal) (passes bool,
if val, ok := currValidators[valAddrStr]; ok {
// There is no need to handle the special case that validator address equal to voter address.
// Because voter's voting power will tally again even if there will deduct voter's voting power from validator.
// Because voter's voting power will tally again even if there will be deduction of voter's voting power from validator.
val.DelegatorDeductions = val.DelegatorDeductions.Add(delegation.GetShares())
currValidators[valAddrStr] = val

View File

@ -88,7 +88,7 @@ func (keeper Keeper) SetVote(ctx sdk.Context, vote v1.Vote) {
store.Set(types.VoteKey(vote.ProposalId, addr), bz)
}
// IterateAllVotes iterates over the all the stored votes and performs a callback function
// IterateAllVotes iterates over all the stored votes and performs a callback function
func (keeper Keeper) IterateAllVotes(ctx sdk.Context, cb func(vote v1.Vote) (stop bool)) {
store := ctx.KVStore(keeper.storeKey)
iterator := sdk.KVStorePrefixIterator(store, types.VotesKeyPrefix)
@ -104,7 +104,7 @@ func (keeper Keeper) IterateAllVotes(ctx sdk.Context, cb func(vote v1.Vote) (sto
}
}
// IterateVotes iterates over the all the proposals votes and performs a callback function
// IterateVotes iterates over all the proposals votes and performs a callback function
func (keeper Keeper) IterateVotes(ctx sdk.Context, proposalID uint64, cb func(vote v1.Vote) (stop bool)) {
store := ctx.KVStore(keeper.storeKey)
iterator := sdk.KVStorePrefixIterator(store, types.VotesKey(proposalID))

View File

@ -18,7 +18,7 @@ import (
)
// TestRandomizedGenState tests the normal scenario of applying RandomizedGenState.
// Abonormal scenarios are not tested here.
// Abnormal scenarios are not tested here.
func TestRandomizedGenState(t *testing.T) {
interfaceRegistry := codectypes.NewInterfaceRegistry()
cdc := codec.NewProtoCodec(interfaceRegistry)

View File

@ -99,7 +99,7 @@ func TestWeightedOperations(t *testing.T) {
}
// TestSimulateMsgSubmitProposal tests the normal scenario of a valid message of type TypeMsgSubmitProposal.
// Abnormal scenarios, where the message is created by an errors are not tested here.
// Abnormal scenarios, where errors occur, are not tested here.
func TestSimulateMsgSubmitProposal(t *testing.T) {
app, ctx := createTestApp(t, false)
@ -131,7 +131,7 @@ func TestSimulateMsgSubmitProposal(t *testing.T) {
}
// TestSimulateMsgDeposit tests the normal scenario of a valid message of type TypeMsgDeposit.
// Abnormal scenarios, where the message is created by an errors are not tested here.
// Abnormal scenarios, where errors occur, are not tested here.
func TestSimulateMsgDeposit(t *testing.T) {
app, ctx := createTestApp(t, false)
blockTime := time.Now().UTC()
@ -177,7 +177,7 @@ func TestSimulateMsgDeposit(t *testing.T) {
}
// TestSimulateMsgVote tests the normal scenario of a valid message of type TypeMsgVote.
// Abnormal scenarios, where the message is created by an errors are not tested here.
// Abnormal scenarios, where errors occur, are not tested here.
func TestSimulateMsgVote(t *testing.T) {
app, ctx := createTestApp(t, false)
blockTime := time.Now().UTC()
@ -221,7 +221,7 @@ func TestSimulateMsgVote(t *testing.T) {
}
// TestSimulateMsgVoteWeighted tests the normal scenario of a valid message of type TypeMsgVoteWeighted.
// Abnormal scenarios, where the message is created by an errors are not tested here.
// Abnormal scenarios, where errors occur, are not tested here.
func TestSimulateMsgVoteWeighted(t *testing.T) {
app, ctx := createTestApp(t, false)
blockTime := time.Now().UTC()

View File

@ -67,7 +67,7 @@ according to the final tally of the proposal:
* All refunded or burned deposits are removed from the state. Events are issued when
burning or refunding a deposit.
## Voting
## Vote
### Participants
@ -169,7 +169,7 @@ Later, we may add permissioned keys that could only sign txs from certain module
## Software Upgrade
If proposals are of type `SoftwareUpgradeProposal`, then nodes need to upgrade
their software to the new version that was voted. This process is divided in
their software to the new version that was voted. This process is divided into
two steps.
### Signal

View File

@ -20,7 +20,7 @@ to discuss and debate the proposal. In most cases, it is encouraged to have an o
system that supports the on-chain governance process. To accommodate for this, a
proposal contains a special `metadata` field, an array of bytes, which can be used to
add context to the proposal. The `metadata` field allows custom use for networks, however,
it is expected that the field contain a URL or some form of CID using a system such as
it is expected that the field contains a URL or some form of CID using a system such as
[IPFS](https://docs.ipfs.io/concepts/content-addressing/). To support the case of
interoperability across networks, the SDK recommends that the `metadata` represents
the following `JSON` template:
@ -93,7 +93,7 @@ type ProposalStatus byte
const (
StatusNil ProposalStatus = 0x00
StatusNil ProposalStatus = 0x00
StatusDepositPeriod ProposalStatus = 0x01 // Proposal is submitted. Participants can deposit on it but not vote
StatusVotingPeriod ProposalStatus = 0x02 // MinDeposit is reached, participants can vote
StatusPassed ProposalStatus = 0x03 // Proposal passed and successfully executed
@ -177,7 +177,7 @@ And the pseudocode for the `ProposalProcessingQueue`:
tallyingParam = load(GlobalParams, 'TallyingParam')
// Update tally if validator voted they voted
// Update tally if validator voted
for each validator in validators
if tmpValMap(validator).HasVoted
proposal.updateTally(tmpValMap(validator).Vote, (validator.TotalShares - tmpValMap(validator).Minus))

View File

@ -108,7 +108,7 @@ upon receiving txGovDeposit from sender do
// There is no proposal for this proposalID
throw
if (txGovDeposit.Deposit.Atoms <= 0) OR (sender.AtomBalance < txGovDeposit.Deposit.Atoms) OR (proposal.CurrentStatus != ProposalStatusOpen)
if (txGovDeposit.Deposit.Atoms <= 0) OR (sender.AtomBalance < txGovDeposit.Deposit.Atoms) OR (proposal.CurrentStatus != ProposalStatusOpen)
// deposit is negative or null
// OR sender has insufficient funds

File diff suppressed because it is too large Load Diff

View File

@ -37,6 +37,7 @@ staking token of the chain.
1. **[Concepts](01_concepts.md)**
* [Proposal submission](01_concepts.md#proposal-submission)
* [Deposit](01_concepts.md#Deposit)
* [Vote](01_concepts.md#vote)
* [Software Upgrade](01_concepts.md#software-upgrade)
2. **[State](02_state.md)**

View File

@ -75,7 +75,7 @@ func (VoteOption) EnumDescriptor() ([]byte, []int) {
type ProposalStatus int32
const (
// PROPOSAL_STATUS_UNSPECIFIED defines the default propopsal status.
// PROPOSAL_STATUS_UNSPECIFIED defines the default proposal status.
ProposalStatus_PROPOSAL_STATUS_UNSPECIFIED ProposalStatus = 0
// PROPOSAL_STATUS_DEPOSIT_PERIOD defines a proposal status during the deposit
// period.

View File

@ -253,7 +253,7 @@ func (m *QueryProposalsResponse) GetPagination() *query.PageResponse {
type QueryVoteRequest struct {
// proposal_id defines the unique id of the proposal.
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
// voter defines the oter address for the proposals.
// voter defines the voter address for the proposals.
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
}

View File

@ -76,7 +76,7 @@ func (VoteOption) EnumDescriptor() ([]byte, []int) {
type ProposalStatus int32
const (
// PROPOSAL_STATUS_UNSPECIFIED defines the default propopsal status.
// PROPOSAL_STATUS_UNSPECIFIED defines the default proposal status.
StatusNil ProposalStatus = 0
// PROPOSAL_STATUS_DEPOSIT_PERIOD defines a proposal status during the deposit
// period.

View File

@ -226,7 +226,7 @@ func (m *QueryProposalsResponse) GetPagination() *query.PageResponse {
type QueryVoteRequest struct {
// proposal_id defines the unique id of the proposal.
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
// voter defines the oter address for the proposals.
// voter defines the voter address for the proposals.
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
}