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(x/gov): remove ability for validators to add votes #10

Merged
merged 5 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@

### FEATURES

### STATE BREAKING
* Forked `x/gov` module from Cosmos SDK v0.46.16 for custom modifications
([#4](https://github.com/atomone-hub/govgen/pull/4)).
* Removed ability for validators to vote on proposals
([#10](https://github.com/atomone-hub/govgen/pull/10)).

### STATE BREAKING
4 changes: 2 additions & 2 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func appModules(
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper),
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
Expand All @@ -124,7 +124,7 @@ func simulationModules(
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper),
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
Expand Down
16 changes: 8 additions & 8 deletions x/gov/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestTickExpiredDepositPeriod(t *testing.T) {
}

func TestTickMultipleExpiredDepositPeriod(t *testing.T) {
app := govgenhelpers.Setup(t)
app := govgenhelpers.SetupNoValset(false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
addrs := govgenhelpers.AddTestAddrs(app, ctx, 10, valTokens)

Expand Down Expand Up @@ -146,7 +146,7 @@ func TestTickMultipleExpiredDepositPeriod(t *testing.T) {
}

func TestTickPassedDepositPeriod(t *testing.T) {
app := govgenhelpers.Setup(t)
app := govgenhelpers.SetupNoValset(false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
addrs := govgenhelpers.AddTestAddrs(app, ctx, 10, valTokens)

Expand Down Expand Up @@ -203,7 +203,7 @@ func TestTickPassedDepositPeriod(t *testing.T) {
}

func TestTickPassedVotingPeriod(t *testing.T) {
app := govgenhelpers.Setup(t)
app := govgenhelpers.SetupNoValset(false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
addrs := govgenhelpers.AddTestAddrs(app, ctx, 10, valTokens)

Expand Down Expand Up @@ -271,7 +271,7 @@ func TestTickPassedVotingPeriod(t *testing.T) {
}

func TestProposalPassedEndblocker(t *testing.T) {
app := govgenhelpers.Setup(t)
app := govgenhelpers.SetupNoValset(false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
addrs := govgenhelpers.AddTestAddrs(app, ctx, 10, valTokens)

Expand Down Expand Up @@ -307,7 +307,7 @@ func TestProposalPassedEndblocker(t *testing.T) {
deposits := initialModuleAccCoins.Add(proposal.TotalDeposit...).Add(proposalCoins...)
require.True(t, moduleAccCoins.IsEqual(deposits))

err = app.GovKeeper.AddVote(ctx, proposal.ProposalId, addrs[0], types.NewNonSplitVoteOption(types.OptionYes))
err = app.GovKeeper.AddVote(ctx, proposal.ProposalId, addrs[1], types.NewNonSplitVoteOption(types.OptionYes))
require.NoError(t, err)

newHeader := ctx.BlockHeader()
Expand All @@ -322,9 +322,9 @@ func TestProposalPassedEndblocker(t *testing.T) {
}

func TestEndBlockerProposalHandlerFailed(t *testing.T) {
app := govgenhelpers.Setup(t)
app := govgenhelpers.SetupNoValset(false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
addrs := govgenhelpers.AddTestAddrs(app, ctx, 1, valTokens)
addrs := govgenhelpers.AddTestAddrs(app, ctx, 2, valTokens)

SortAddresses(addrs)

Expand All @@ -348,7 +348,7 @@ func TestEndBlockerProposalHandlerFailed(t *testing.T) {

handleAndCheck(t, gov.NewHandler(app.GovKeeper), ctx, newDepositMsg)

err = app.GovKeeper.AddVote(ctx, proposal.ProposalId, addrs[0], types.NewNonSplitVoteOption(types.OptionYes))
err = app.GovKeeper.AddVote(ctx, proposal.ProposalId, addrs[1], types.NewNonSplitVoteOption(types.OptionYes))
require.NoError(t, err)

newHeader := ctx.BlockHeader()
Expand Down
2 changes: 1 addition & 1 deletion x/gov/keeper/deposit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

func TestDeposits(t *testing.T) {
app := govgenhelpers.Setup(t)
app := govgenhelpers.SetupNoValset(false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

TestAddrs := govgenhelpers.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(10000000))
Expand Down
15 changes: 13 additions & 2 deletions x/gov/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/query"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)

func (suite *KeeperTestSuite) TestGRPCQueryProposal() {
Expand Down Expand Up @@ -337,7 +338,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryVote() {
func (suite *KeeperTestSuite) TestGRPCQueryVotes() {
app, ctx, queryClient := suite.app, suite.ctx, suite.queryClient

addrs := govgenhelpers.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(30000000))
addrs := govgenhelpers.AddTestAddrs(app, ctx, 2, sdk.NewInt(30000000))

var (
req *types.QueryVotesRequest
Expand Down Expand Up @@ -714,7 +715,17 @@ func (suite *KeeperTestSuite) TestGRPCQueryDeposits() {
func (suite *KeeperTestSuite) TestGRPCQueryTally() {
app, ctx, queryClient := suite.app, suite.ctx, suite.queryClient

addrs, _ := createValidators(suite.T(), ctx, app, []int64{5, 5, 5})
_, valAddrs := createValidators(suite.T(), ctx, app, []int64{5, 5, 5})
addrs := govgenhelpers.AddTestAddrs(app, ctx, 3, sdk.NewInt(50000000))

delTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 5)
val1, found := app.StakingKeeper.GetValidator(ctx, valAddrs[0])
suite.Require().True(found)

for _, addr := range addrs {
_, err := app.StakingKeeper.Delegate(ctx, addr, delTokens, stakingtypes.Unbonded, val1, true)
suite.Require().NoError(err)
}

var (
req *types.QueryTallyResultRequest
Expand Down
2 changes: 1 addition & 1 deletion x/gov/keeper/hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (h *MockGovHooksReceiver) AfterProposalVotingPeriodEnded(ctx sdk.Context, p
}

func TestHooks(t *testing.T) {
app := govgenhelpers.Setup(t)
app := govgenhelpers.SetupNoValset(false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

minDeposit := app.GovKeeper.GetDepositParams(ctx).MinDeposit
Expand Down
4 changes: 2 additions & 2 deletions x/gov/keeper/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func getQueriedVotes(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, quer
}

func TestQueries(t *testing.T) {
app := govgenhelpers.Setup(t)
app := govgenhelpers.SetupNoValset(false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
legacyQuerierCdc := app.LegacyAmino()
querier := keeper.NewQuerier(app.GovKeeper, legacyQuerierCdc)
Expand Down Expand Up @@ -304,7 +304,7 @@ func TestQueries(t *testing.T) {
}

func TestPaginatedVotesQuery(t *testing.T) {
app := govgenhelpers.Setup(t)
app := govgenhelpers.SetupNoValset(false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
legacyQuerierCdc := app.LegacyAmino()

Expand Down
Loading
Loading