Skip to content

Commit

Permalink
parameter module refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jelysn committed Nov 30, 2023
1 parent 98f0a27 commit 9df8ee2
Show file tree
Hide file tree
Showing 62 changed files with 1,942 additions and 3,247 deletions.
10 changes: 3 additions & 7 deletions app/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,11 @@ func (min MinCommissionDecorator) AnteHandle(
simulate bool, next sdk.AnteHandler,
) (newCtx sdk.Context, err error) {
msgs := tx.GetMsgs()
minCommissionRate := sdk.NewDecWithPrec(5, 2) // 5% as a fraction
maxVotingPower := sdk.NewDec(100) // 100%

// Fetch parameter from parameter module
params, found := min.pk.GetAnteHandlerParam(ctx)
if found {
minCommissionRate = params.MinCommissionRate
maxVotingPower = params.MaxVotingPower
}
params := min.pk.GetParams(ctx)
minCommissionRate := params.MinCommissionRate
maxVotingPower := params.MaxVotingPower

validMsg := func(m sdk.Msg) error {
switch msg := m.(type) {
Expand Down
21 changes: 11 additions & 10 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,12 @@ func NewElysApp(
)
bApp.SetParamStore(&app.ConsensusParamsKeeper)

app.ParameterKeeper = *parametermodulekeeper.NewKeeper(
appCodec,
keys[parametermoduletypes.StoreKey],
keys[parametermoduletypes.MemStoreKey],
)

// add capability keeper and ScopeToModule for ibc module
app.CapabilityKeeper = capabilitykeeper.NewKeeper(
appCodec,
Expand Down Expand Up @@ -734,6 +740,7 @@ func NewElysApp(
tkeys[ammmoduletypes.TStoreKey],
app.GetSubspace(ammmoduletypes.ModuleName),
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
&app.ParameterKeeper,
app.BankKeeper,
app.AccountKeeper,
app.OracleKeeper,
Expand Down Expand Up @@ -802,12 +809,6 @@ func NewElysApp(
)
burnerModule := burnermodule.NewAppModule(appCodec, app.BurnerKeeper, app.AccountKeeper, app.BankKeeper)

app.ParameterKeeper = *parametermodulekeeper.NewKeeper(
appCodec,
keys[parametermoduletypes.StoreKey],
keys[parametermoduletypes.MemStoreKey],
app.GetSubspace(parametermoduletypes.ModuleName),
)
parameterModule := parametermodule.NewAppModule(appCodec, app.ParameterKeeper, app.AccountKeeper, app.BankKeeper)

wasmDir := filepath.Join(homePath, "wasm")
Expand Down Expand Up @@ -907,8 +908,8 @@ func NewElysApp(
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)).
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)).
AddRoute(oracletypes.RouterKey, oraclemodule.NewAssetInfoProposalHandler(&app.OracleKeeper)).
AddRoute(incentivemoduletypes.RouterKey, incentivemodule.NewPoolInfoProposalHandler(&app.IncentiveKeeper)).
AddRoute(parametermoduletypes.RouterKey, parametermodule.NewParameterChangeProposalHandler(&app.ParameterKeeper))
AddRoute(incentivemoduletypes.RouterKey, incentivemodule.NewPoolInfoProposalHandler(&app.IncentiveKeeper))

// The gov proposal types can be individually enabled
if len(enabledProposals) != 0 {
govRouter.AddRoute(wasmmodule.RouterKey, wasmmodule.NewWasmProposalHandler(app.WasmKeeper, enabledProposals))
Expand All @@ -924,6 +925,7 @@ func NewElysApp(
app.BankKeeper,
app.OracleKeeper,
app.AssetprofileKeeper,
&app.ParameterKeeper,
)

app.ClockKeeper = *clockmodulekeeper.NewKeeper(
Expand Down Expand Up @@ -1165,6 +1167,7 @@ func NewElysApp(
// so that other modules that want to create or claim capabilities afterwards in InitChain
// can do so safely.
genesisModuleOrder := []string{
parametermoduletypes.ModuleName,
capabilitytypes.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
Expand Down Expand Up @@ -1194,7 +1197,6 @@ func NewElysApp(
tokenomicsmoduletypes.ModuleName,
burnermoduletypes.ModuleName,
ammmoduletypes.ModuleName,
parametermoduletypes.ModuleName,
marginmoduletypes.ModuleName,
wasmmodule.ModuleName,
accountedpoolmoduletypes.ModuleName,
Expand Down Expand Up @@ -1493,7 +1495,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(incentivemoduletypes.ModuleName)
paramsKeeper.Subspace(burnermoduletypes.ModuleName)
paramsKeeper.Subspace(ammmoduletypes.ModuleName)
paramsKeeper.Subspace(parametermoduletypes.ModuleName)
paramsKeeper.Subspace(marginmoduletypes.ModuleName)
paramsKeeper.Subspace(accountedpoolmoduletypes.ModuleName)
paramsKeeper.Subspace(transferhooktypes.ModuleName)
Expand Down
3 changes: 0 additions & 3 deletions app/setup_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
leveragelptypes "github.com/elys-network/elys/x/leveragelp/types"
margintypes "github.com/elys-network/elys/x/margin/types"
oracletypes "github.com/elys-network/elys/x/oracle/types"
parametertypes "github.com/elys-network/elys/x/parameter/types"
stablestaketypes "github.com/elys-network/elys/x/stablestake/types"
tokenomicstypes "github.com/elys-network/elys/x/tokenomics/types"
transferhooktypes "github.com/elys-network/elys/x/transferhook/types"
Expand Down Expand Up @@ -77,8 +76,6 @@ func setUpgradeHandler(app *ElysApp) {
keyTable = margintypes.ParamKeyTable() //nolint:staticcheck
case oracletypes.ModuleName:
keyTable = oracletypes.ParamKeyTable() //nolint:staticcheck
case parametertypes.ModuleName:
keyTable = parametertypes.ParamKeyTable() //nolint:staticcheck
case tokenomicstypes.ModuleName:
keyTable = tokenomicstypes.ParamKeyTable() //nolint:staticcheck
case accountedpooltypes.ModuleName:
Expand Down
9 changes: 5 additions & 4 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,11 @@ genesis:
denom: "ueden"
amount: "1000000"
parameter:
anteHandlerParam:
minCommissionRate: "0.05"
maxVotingPower: "0.66"
minSelfDelegation: "1"
params:
min_commission_rate: "0.05"
max_voting_power: "0.66"
min_self_delegation: "1"
broker_address: ""
margin:
params:
leverage_max: "10"
Expand Down
2 changes: 1 addition & 1 deletion dockernet/src/init_chain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ set_elys_genesis() {
jq '.app_state.staking.params.unbonding_time = $newVal' --arg newVal "$UNBONDING_TIME" $genesis_config > json.tmp && mv json.tmp $genesis_config
jq '.app_state.gov.deposit_params.max_deposit_period = $newVal' --arg newVal "$MAX_DEPOSIT_PERIOD" $genesis_config > json.tmp && mv json.tmp $genesis_config
jq '.app_state.gov.voting_params.voting_period = $newVal' --arg newVal "$VOTING_PERIOD" $genesis_config > json.tmp && mv json.tmp $genesis_config
jq '.app_state.parameter.anteHandlerParamList[0].maxVotingPower = $newVal' --arg newVal "100.000000000000000000" $genesis_config > json.tmp && mv json.tmp $genesis_config
jq '.app_state.parameter.params.maxVotingPower = $newVal' --arg newVal "100.000000000000000000" $genesis_config > json.tmp && mv json.tmp $genesis_config
}

set_band_genesis() {
Expand Down
Loading

0 comments on commit 9df8ee2

Please sign in to comment.