Skip to content

Commit

Permalink
Revert "feat: disable mint/distr/staking/gov module (#117)"
Browse files Browse the repository at this point in the history
This reverts commit 830e5e7.
  • Loading branch information
zakir-code committed Nov 7, 2023
1 parent b4bbb34 commit 420a9d3
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 127 deletions.
51 changes: 0 additions & 51 deletions app/upgrades/v6/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

"github.com/functionx/fx-core/v6/app/keepers"
govtypes "github.com/functionx/fx-core/v6/x/gov/types"
)

func CreateUpgradeHandler(
Expand All @@ -17,10 +16,6 @@ func CreateUpgradeHandler(
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
cacheCtx, commit := ctx.CacheContext()

if err := UpdateParams(cacheCtx, app); err != nil {
return nil, err
}

ctx.Logger().Info("start to run v6 migrations...", "module", "upgrade")
toVM, err := mm.RunMigrations(cacheCtx, configurator, fromVM)
if err != nil {
Expand All @@ -32,49 +27,3 @@ func CreateUpgradeHandler(
return toVM, nil
}
}

func UpdateParams(cacheCtx sdk.Context, app *keepers.AppKeepers) error {
mintParams := app.MintKeeper.GetParams(cacheCtx)
mintParams.InflationMax = sdk.ZeroDec()
mintParams.InflationMin = sdk.ZeroDec()
if err := mintParams.Validate(); err != nil {
return err
}
app.MintKeeper.SetParams(cacheCtx, mintParams)

distrParams := app.DistrKeeper.GetParams(cacheCtx)
distrParams.CommunityTax = sdk.ZeroDec()
distrParams.BaseProposerReward = sdk.ZeroDec()
distrParams.BonusProposerReward = sdk.ZeroDec()
if err := distrParams.ValidateBasic(); err != nil {
return err
}
app.DistrKeeper.SetParams(cacheCtx, distrParams)

stakingParams := app.StakingKeeper.GetParams(cacheCtx)
stakingParams.UnbondingTime = 1
if err := stakingParams.Validate(); err != nil {
return err
}
app.StakingKeeper.SetParams(cacheCtx, stakingParams)

govTallyParams := app.GovKeeper.GetTallyParams(cacheCtx)
govTallyParams.Quorum = sdk.OneDec().String() // 100%
govTallyParams.Threshold = sdk.OneDec().String() // 100%
govTallyParams.VetoThreshold = sdk.OneDec().String() // 100%
app.GovKeeper.SetTallyParams(cacheCtx, govTallyParams)

app.GovKeeper.IterateParams(cacheCtx, func(param *govtypes.Params) (stop bool) {
param.Quorum = sdk.OneDec().String() // 100%
param.Threshold = sdk.OneDec().String() // 100%
param.VetoThreshold = sdk.OneDec().String() // 100%
if err := param.ValidateBasic(); err != nil {
panic(err)
}
if err := app.GovKeeper.SetParams(cacheCtx, param); err != nil {
panic(err)
}
return false
})
return nil
}
62 changes: 0 additions & 62 deletions app/upgrades/v6/upgrade_test.go

This file was deleted.

13 changes: 0 additions & 13 deletions x/gov/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,6 @@ import (
"github.com/functionx/fx-core/v6/x/gov/types"
)

func (keeper Keeper) IterateParams(ctx sdk.Context, cb func(param *types.Params) (stop bool)) {
store := ctx.KVStore(keeper.storeKey)
iter := sdk.KVStorePrefixIterator(store, types.FxBaseParamsKeyPrefix)
defer iter.Close()
for ; iter.Valid(); iter.Next() {
var param types.Params
keeper.cdc.MustUnmarshal(iter.Value(), &param)
if cb(&param) {
break
}
}
}

// GetParams gets the gov module's parameters.
func (keeper Keeper) GetParams(ctx sdk.Context, msgType string) (params types.Params) {
store := ctx.KVStore(keeper.storeKey)
Expand Down
4 changes: 3 additions & 1 deletion x/gov/keeper/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ func (keeper Keeper) SubmitProposal(ctx sdk.Context, messages []sdk.Msg, fxMetad
return v1.Proposal{}, errortypes.ErrInvalidRequest.Wrapf("invalid fx metadata content: %s", err)
}
if err := keeper.AssertFXMetadata(fxMD); err != nil {
return v1.Proposal{}, err
if err != nil {
return v1.Proposal{}, err
}
}

// Will hold a comma-separated string of all Msg type URLs.
Expand Down

0 comments on commit 420a9d3

Please sign in to comment.