Skip to content

Commit

Permalink
feat: add fork fix burning module permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
hoank101 committed Jan 30, 2024
1 parent b89af2d commit 5faf4a1
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,7 @@ func (app *MigalooApp) ModuleConfigurator() module.Configurator {

// BeginBlocker application updates every begin block
func (app *MigalooApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock {
BeginBlockForks(ctx, app)
return app.mm.BeginBlock(ctx, req)
}

Expand Down
13 changes: 13 additions & 0 deletions app/forks.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package app

import (
v4 "github.com/White-Whale-Defi-Platform/migaloo-chain/v4/app/upgrades/v4_1_1"
sdk "github.com/cosmos/cosmos-sdk/types"
)

// BeginBlockForks executes any necessary fork logic based upon the current block height.
func BeginBlockForks(ctx sdk.Context, app *MigalooApp) {
if ctx.BlockHeight() == v4.UpgradeHeight {
v4.UpdateAccountPermissionAndFeeBurnPercent(ctx, app.FeeBurnKeeper, app.AccountKeeper)
}
}
5 changes: 5 additions & 0 deletions app/upgrades/v4_1_1/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package v4

const (
UpgradeHeight = 226753
)
22 changes: 22 additions & 0 deletions app/upgrades/v4_1_1/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package v4

import (
feeburnkeeper "github.com/White-Whale-Defi-Platform/migaloo-chain/v4/x/feeburn/keeper"
sdk "github.com/cosmos/cosmos-sdk/types"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
)

func UpdateAccountPermissionAndFeeBurnPercent(ctx sdk.Context, fk feeburnkeeper.Keeper, ak authkeeper.AccountKeeper) {
// Burning module permissions
moduleAccI := ak.GetModuleAccount(ctx, authtypes.FeeCollectorName)
moduleAcc := moduleAccI.(*authtypes.ModuleAccount)
moduleAcc.Permissions = []string{authtypes.Burner}
ak.SetModuleAccount(ctx, moduleAcc)

// set default fee_burn_percent to 10
feeBurnParams := fk.GetParams(ctx)
feeBurnParams.TxFeeBurnPercent = "10"

_ = fk.SetParams(ctx, feeBurnParams)
}
4 changes: 2 additions & 2 deletions scripts/run-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ $BINARY add-genesis-account $KEY "1000000000000${DENOM}" --keyring-backend $KEYR
$BINARY add-genesis-account $KEY1 "1000000000000${DENOM}" --keyring-backend $KEYRING --home $HOME_DIR
$BINARY add-genesis-account $KEY2 "1000000000000${DENOM}" --keyring-backend $KEYRING --home $HOME_DIR

update_test_genesis '.app_state["gov"]["voting_params"]["voting_period"]="20s"'
update_test_genesis '.app_state["gov"]["params"]["voting_period"]="20s"'
update_test_genesis '.app_state["mint"]["params"]["mint_denom"]="'$DENOM'"'
update_test_genesis '.app_state["gov"]["deposit_params"]["min_deposit"]=[{"denom":"'$DENOM'","amount": "1000000"}]'
update_test_genesis '.app_state["gov"]["params"]["min_deposit"]=[{"denom":"'$DENOM'","amount": "1000000"}]'
update_test_genesis '.app_state["crisis"]["constant_fee"]={"denom":"'$DENOM'","amount":"1000"}'
update_test_genesis '.app_state["staking"]["params"]["bond_denom"]="'$DENOM'"'

Expand Down

0 comments on commit 5faf4a1

Please sign in to comment.