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: add array of messages to a proposal #9810

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
5c75774
create v1 gov messages
cmwaters Oct 5, 2021
705a156
Merge branch 'master' into callum/gov-proposal-messages
cmwaters Oct 5, 2021
df8cd00
format proto
cmwaters Oct 6, 2021
18a68e3
generate v1beta1 folder
tac0turtle Oct 7, 2021
a4435c4
add v1 and v1beta1 gov types and clean up migrations
cmwaters Oct 8, 2021
2492d93
Merge branch 'master' into callum/gov-proposal-messages
cmwaters Oct 8, 2021
4c2f135
fix tests
cmwaters Oct 8, 2021
d395b05
Merge branch 'master' into callum/gov-proposal-messages
cmwaters Oct 8, 2021
de251e8
fix some more tests
cmwaters Oct 8, 2021
a375e71
fix gov cli test helper
cmwaters Oct 12, 2021
04a651f
attempt to fix some more tests
cmwaters Oct 15, 2021
f630127
Merge branch 'master' into callum/gov-proposal-messages
cmwaters Oct 26, 2021
c63d4f5
fix gov cli test
cmwaters Oct 26, 2021
fcbcf0f
Merge branch 'master' into callum/gov-proposal-messages
cmwaters Nov 1, 2021
0a69e03
merge with master
cmwaters Nov 1, 2021
3a45e1f
revert unnecessary changes
cmwaters Nov 1, 2021
60bcd5a
apply suggestions
cmwaters Nov 1, 2021
f9c867f
revert unnecessary changes
cmwaters Nov 1, 2021
2c64cee
revert a few more changes
cmwaters Nov 1, 2021
586ad76
Merge branch 'master' into callum/gov-proposal-messages
cmwaters Nov 3, 2021
38b5c5e
fix tests
cmwaters Nov 3, 2021
a35012b
fix even more tests
cmwaters Nov 3, 2021
bb96044
Merge branch 'master' into callum/gov-proposal-messages
cmwaters Nov 9, 2021
4d57275
Fix authz cli tests (#10519)
blushi Nov 10, 2021
12ed081
Merge branch 'master' into callum/gov-proposal-messages
cmwaters Nov 17, 2021
7b58936
fix compiler breakage
cmwaters Nov 17, 2021
766d99f
rename proto version from v1 to v1beta2
cmwaters Nov 17, 2021
0a3b09c
remove signal msg from gov
cmwaters Nov 17, 2021
f292d88
complete renamin to v1beta2
cmwaters Nov 17, 2021
8485e6c
fix migration and grpc tests
cmwaters Nov 18, 2021
89dbdf5
Merge branch 'master' into callum/gov-proposal-messages
cmwaters Nov 22, 2021
17e3400
Merge branch 'master' into callum/gov-proposal-messages
cmwaters Nov 23, 2021
9a5d243
run go mod tidy
cmwaters Nov 23, 2021
f2ce991
Merge branch 'master' into callum/gov-proposal-messages
cmwaters Nov 24, 2021
c37019b
minor update
cmwaters Nov 25, 2021
ed4c196
Merge branch 'master' into callum/gov-proposal-messages
cmwaters Nov 25, 2021
b9b4345
Merge branch 'master' into callum/gov-proposal-messages
cmwaters Dec 3, 2021
0c64c1a
add back v1beta1 query and tx proto files
cmwaters Dec 3, 2021
a6d4edd
generate new proto
cmwaters Dec 3, 2021
ab39d38
remove tx proto
cmwaters Dec 3, 2021
dbf7e9c
rename weights
cmwaters Dec 3, 2021
7faf1f2
Merge branch 'master' into callum/gov-proposal-messages
amaury1093 Dec 8, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25056,7 +25056,7 @@ definitions:
description: >-
QueryEvidenceResponse is the response type for the Query/Evidence RPC
method.
cosmos.gov.v1beta1.Deposit:
cosmos.gov.v1beta2.Deposit:
type: object
properties:
proposal_id:
Expand All @@ -25081,7 +25081,7 @@ definitions:
description: |-
Deposit defines an amount deposited by an account address to an active
proposal.
cosmos.gov.v1beta1.DepositParams:
cosmos.gov.v1beta2.DepositParams:
type: object
properties:
min_deposit:
Expand All @@ -25106,7 +25106,7 @@ definitions:
value: 2
months.
description: DepositParams defines the params for deposits on governance proposals.
cosmos.gov.v1beta1.Proposal:
cosmos.gov.v1beta2.Proposal:
type: object
properties:
proposal_id:
Expand Down Expand Up @@ -25334,7 +25334,7 @@ definitions:
type: string
format: date-time
description: Proposal defines the core field members of a governance proposal.
cosmos.gov.v1beta1.ProposalStatus:
cosmos.gov.v1beta2.ProposalStatus:
type: string
enum:
- PROPOSAL_STATUS_UNSPECIFIED
Expand All @@ -25358,7 +25358,7 @@ definitions:
been rejected.
- PROPOSAL_STATUS_FAILED: PROPOSAL_STATUS_FAILED defines a proposal status of a proposal that has
failed.
cosmos.gov.v1beta1.QueryDepositResponse:
cosmos.gov.v1beta2.QueryDepositResponse:
type: object
properties:
deposit:
Expand Down Expand Up @@ -25392,7 +25392,7 @@ definitions:
description: >-
QueryDepositResponse is the response type for the Query/Deposit RPC
method.
cosmos.gov.v1beta1.QueryDepositsResponse:
cosmos.gov.v1beta2.QueryDepositsResponse:
type: object
properties:
deposits:
Expand Down Expand Up @@ -25448,7 +25448,7 @@ definitions:
description: >-
QueryDepositsResponse is the response type for the Query/Deposits RPC
method.
cosmos.gov.v1beta1.QueryParamsResponse:
cosmos.gov.v1beta2.QueryParamsResponse:
type: object
properties:
voting_params:
Expand Down Expand Up @@ -25511,7 +25511,7 @@ definitions:
be
vetoed. Default value: 1/3.
description: QueryParamsResponse is the response type for the Query/Params RPC method.
cosmos.gov.v1beta1.QueryProposalResponse:
cosmos.gov.v1beta2.QueryProposalResponse:
type: object
properties:
proposal:
Expand Down Expand Up @@ -25754,7 +25754,7 @@ definitions:
description: >-
QueryProposalResponse is the response type for the Query/Proposal RPC
method.
cosmos.gov.v1beta1.QueryProposalsResponse:
cosmos.gov.v1beta2.QueryProposalsResponse:
type: object
properties:
proposals:
Expand Down Expand Up @@ -26021,7 +26021,7 @@ definitions:
description: |-
QueryProposalsResponse is the response type for the Query/Proposals RPC
method.
cosmos.gov.v1beta1.QueryTallyResultResponse:
cosmos.gov.v1beta2.QueryTallyResultResponse:
type: object
properties:
tally:
Expand All @@ -26039,7 +26039,7 @@ definitions:
description: >-
QueryTallyResultResponse is the response type for the Query/Tally RPC
method.
cosmos.gov.v1beta1.QueryVoteResponse:
cosmos.gov.v1beta2.QueryVoteResponse:
type: object
properties:
vote:
Expand Down Expand Up @@ -26097,7 +26097,7 @@ definitions:
Vote defines a vote on a governance proposal.
A Vote consists of a proposal ID, the voter, and the vote option.
description: QueryVoteResponse is the response type for the Query/Vote RPC method.
cosmos.gov.v1beta1.QueryVotesResponse:
cosmos.gov.v1beta2.QueryVotesResponse:
type: object
properties:
votes:
Expand Down Expand Up @@ -26176,7 +26176,7 @@ definitions:

was set, its value is undefined otherwise
description: QueryVotesResponse is the response type for the Query/Votes RPC method.
cosmos.gov.v1beta1.TallyParams:
cosmos.gov.v1beta2.TallyParams:
type: object
properties:
quorum:
Expand All @@ -26198,7 +26198,7 @@ definitions:
Minimum value of Veto votes to Total votes ratio for proposal to be
vetoed. Default value: 1/3.
description: TallyParams defines the params for tallying votes on governance proposals.
cosmos.gov.v1beta1.TallyResult:
cosmos.gov.v1beta2.TallyResult:
type: object
properties:
'yes':
Expand All @@ -26210,7 +26210,7 @@ definitions:
no_with_veto:
type: string
description: TallyResult defines a standard tally for a governance proposal.
cosmos.gov.v1beta1.Vote:
cosmos.gov.v1beta2.Vote:
type: object
properties:
proposal_id:
Expand Down Expand Up @@ -26264,7 +26264,7 @@ definitions:
description: |-
Vote defines a vote on a governance proposal.
A Vote consists of a proposal ID, the voter, and the vote option.
cosmos.gov.v1beta1.VoteOption:
cosmos.gov.v1beta2.VoteOption:
type: string
enum:
- VOTE_OPTION_UNSPECIFIED
Expand All @@ -26282,14 +26282,14 @@ definitions:
- VOTE_OPTION_ABSTAIN: VOTE_OPTION_ABSTAIN defines an abstain vote option.
- VOTE_OPTION_NO: VOTE_OPTION_NO defines a no vote option.
- VOTE_OPTION_NO_WITH_VETO: VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option.
cosmos.gov.v1beta1.VotingParams:
cosmos.gov.v1beta2.VotingParams:
type: object
properties:
voting_period:
type: string
description: Length of the voting period.
description: VotingParams defines the params for voting on governance proposals.
cosmos.gov.v1beta1.WeightedVoteOption:
cosmos.gov.v1beta2.WeightedVoteOption:
type: object
properties:
option:
Expand Down
2 changes: 1 addition & 1 deletion proto/cosmos/gov/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package cosmos.gov.v1beta1;
import "gogoproto/gogo.proto";
import "cosmos/gov/v1beta1/gov.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types";
option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1";

// GenesisState defines the gov module's genesis state.
message GenesisState {
Expand Down
2 changes: 1 addition & 1 deletion proto/cosmos/gov/v1beta1/gov.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "google/protobuf/any.proto";
import "google/protobuf/duration.proto";
import "cosmos_proto/cosmos.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types";
option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1";

option (gogoproto.goproto_stringer_all) = false;
option (gogoproto.stringer_all) = false;
Expand Down
2 changes: 1 addition & 1 deletion proto/cosmos/gov/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "google/api/annotations.proto";
import "cosmos/gov/v1beta1/gov.proto";
import "cosmos_proto/cosmos.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types";
option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1";

// Query defines the gRPC querier service for gov module
service Query {
Expand Down
96 changes: 0 additions & 96 deletions proto/cosmos/gov/v1beta1/tx.proto

This file was deleted.

9 changes: 1 addition & 8 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ import (
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
"github.com/cosmos/cosmos-sdk/x/slashing"
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
Expand Down Expand Up @@ -287,15 +286,9 @@ func NewSimApp(

app.AuthzKeeper = authzkeeper.NewKeeper(keys[authzkeeper.StoreKey], appCodec, app.msgSvcRouter)

// register the proposal types
govRouter := govtypes.NewRouter()
govRouter.AddRoute(govtypes.RouterKey, govtypes.ProposalHandler).
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper))
govKeeper := govkeeper.NewKeeper(
appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
&stakingKeeper, govRouter,
&stakingKeeper, app.msgSvcRouter,
)

app.GovKeeper = *govKeeper.SetHooks(
Expand Down
5 changes: 1 addition & 4 deletions simapp/params/weights.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ const (
DefaultWeightMsgDelegate int = 100
DefaultWeightMsgUndelegate int = 100
DefaultWeightMsgBeginRedelegate int = 100

DefaultWeightCommunitySpendProposal int = 5
DefaultWeightTextProposal int = 5
DefaultWeightParamChangeProposal int = 5
DefaultWeightMsgSubmitProposal int = 5

// feegrant
DefaultWeightGrantAllowance int = 100
Expand Down
1 change: 0 additions & 1 deletion simapp/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ func SimulationOperations(app App, cdc codec.JSONCodec, config simtypes.Config)
}

simState.ParamChanges = app.SimulationManager().GenerateParamChanges(config.Seed)
simState.Contents = app.SimulationManager().GetProposalContents(simState)
return app.SimulationManager().WeightedOperations(simState)
}

Expand Down
33 changes: 9 additions & 24 deletions types/module/simulation.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ type AppModuleSimulation interface {
// randomized genesis states
GenerateGenesisState(input *SimulationState)

// content functions used to simulate governance proposals
ProposalContents(simState SimulationState) []simulation.WeightedProposalContent

// randomized module parameters for param change proposals
RandomizedParams(r *rand.Rand) []simulation.ParamChange

Expand Down Expand Up @@ -47,17 +44,6 @@ func NewSimulationManager(modules ...AppModuleSimulation) *SimulationManager {
}
}

// GetProposalContents returns each module's proposal content generator function
// with their default operation weight and key.
func (sm *SimulationManager) GetProposalContents(simState SimulationState) []simulation.WeightedProposalContent {
wContents := make([]simulation.WeightedProposalContent, 0, len(sm.Modules))
for _, module := range sm.Modules {
wContents = append(wContents, module.ProposalContents(simState)...)
}

return wContents
}

// RegisterStoreDecoders registers each of the modules' store decoders into a map
func (sm *SimulationManager) RegisterStoreDecoders() {
for _, module := range sm.Modules {
Expand Down Expand Up @@ -99,14 +85,13 @@ func (sm *SimulationManager) WeightedOperations(simState SimulationState) []simu
// GenesisState generator function
type SimulationState struct {
AppParams simulation.AppParams
Cdc codec.JSONCodec // application codec
Rand *rand.Rand // random number
GenState map[string]json.RawMessage // genesis state
Accounts []simulation.Account // simulation accounts
InitialStake int64 // initial coins per account
NumBonded int64 // number of initially bonded accounts
GenTimestamp time.Time // genesis timestamp
UnbondTime time.Duration // staking unbond time stored to use it as the slashing maximum evidence duration
ParamChanges []simulation.ParamChange // simulated parameter changes from modules
Contents []simulation.WeightedProposalContent // proposal content generator functions with their default weight and app sim key
Cdc codec.JSONCodec // application codec
Rand *rand.Rand // random number
GenState map[string]json.RawMessage // genesis state
Accounts []simulation.Account // simulation accounts
InitialStake int64 // initial coins per account
NumBonded int64 // number of initially bonded accounts
GenTimestamp time.Time // genesis timestamp
UnbondTime time.Duration // staking unbond time stored to use it as the slashing maximum evidence duration
ParamChanges []simulation.ParamChange // simulated parameter changes from modules
}
Loading