diff --git a/x/gov/genesis.go b/x/gov/genesis.go index 89c8d683c2..ebae2d8b12 100644 --- a/x/gov/genesis.go +++ b/x/gov/genesis.go @@ -58,10 +58,6 @@ func ExportGenesis(ctx sdk.Context, k *keeper.Keeper) *v1.GenesisState { proposals := k.GetProposals(ctx) params := k.GetParams(ctx) - depositParams := v1.NewDepositParams(params.MinDeposit, params.MaxDepositPeriod) //nolint:staticcheck - votingParams := v1.NewVotingParams(params.VotingPeriod) //nolint:staticcheck - tallyParams := v1.NewTallyParams(params.Quorum, params.Threshold, params.VetoThreshold) //nolint:staticcheck - var proposalsDeposits v1.Deposits var proposalsVotes v1.Votes for _, proposal := range proposals { @@ -77,9 +73,6 @@ func ExportGenesis(ctx sdk.Context, k *keeper.Keeper) *v1.GenesisState { Deposits: proposalsDeposits, Votes: proposalsVotes, Proposals: proposals, - DepositParams: &depositParams, - VotingParams: &votingParams, - TallyParams: &tallyParams, Params: ¶ms, } } diff --git a/x/gov/migrations/v4/json_test.go b/x/gov/migrations/v4/json_test.go index 0b58e63d76..d6a48b7a3f 100644 --- a/x/gov/migrations/v4/json_test.go +++ b/x/gov/migrations/v4/json_test.go @@ -20,9 +20,28 @@ func TestMigrateJSON(t *testing.T) { WithCodec(encodingConfig.Codec) govGenState := v1.DefaultGenesisState() + oldGovState := &v1.GenesisState{ + StartingProposalId: govGenState.StartingProposalId, + Deposits: govGenState.Deposits, + Votes: govGenState.Votes, + Proposals: govGenState.Proposals, + DepositParams: &v1.DepositParams{ + MinDeposit: govGenState.Params.MinDeposit, + MaxDepositPeriod: govGenState.Params.MaxDepositPeriod, + }, + VotingParams: &v1.VotingParams{ + VotingPeriod: govGenState.Params.VotingPeriod, + }, + TallyParams: &v1.TallyParams{ + Quorum: govGenState.Params.Quorum, + Threshold: govGenState.Params.Threshold, + VetoThreshold: govGenState.Params.VetoThreshold, + }, + } - migrated, err := v4.MigrateJSON(govGenState) + migrated, err := v4.MigrateJSON(oldGovState) require.NoError(t, err) + require.Equal(t, migrated, govGenState) bz, err := clientCtx.Codec.MarshalJSON(migrated) require.NoError(t, err) diff --git a/x/gov/types/v1/genesis.go b/x/gov/types/v1/genesis.go index cc407309fb..ef44bd4816 100644 --- a/x/gov/types/v1/genesis.go +++ b/x/gov/types/v1/genesis.go @@ -2,22 +2,14 @@ package v1 import ( "errors" - "fmt" "github.com/cosmos/cosmos-sdk/codec/types" ) // NewGenesisState creates a new genesis state for the governance module func NewGenesisState(startingProposalID uint64, params Params) *GenesisState { - dp := NewDepositParams(params.MinDeposit, params.MaxDepositPeriod) - vp := NewVotingParams(params.VotingPeriod) - tp := NewTallyParams(params.Quorum, params.Threshold, params.VetoThreshold) - return &GenesisState{ StartingProposalId: startingProposalID, - DepositParams: &dp, - VotingParams: &vp, - TallyParams: &tp, Params: ¶ms, } } @@ -41,18 +33,6 @@ func ValidateGenesis(data *GenesisState) error { return errors.New("starting proposal id must be greater than 0") } - if err := validateTallyParams(*data.TallyParams); err != nil { - return fmt.Errorf("invalid tally params: %w", err) - } - - if err := validateVotingParams(*data.VotingParams); err != nil { - return fmt.Errorf("invalid voting params: %w", err) - } - - if err := validateDepositParams(*data.DepositParams); err != nil { - return fmt.Errorf("invalid deposit params: %w", err) - } - return data.Params.ValidateBasic() }