-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add testnet handler upgrade v4.1.1
- Loading branch information
Showing
8 changed files
with
114 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
package v4 | ||
|
||
// UpgradeName defines the on-chain upgrade name for the Migaloo v3.0.2 upgrade. | ||
// this upgrade includes the fix for pfm | ||
// UpgradeName mainnet v4.1.0 | ||
const UpgradeName = "v4.1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package v4 | ||
|
||
// UpgradeName testnet v4.1.1 rc3 | ||
const UpgradeName = "v4.1.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package v4 | ||
|
||
import ( | ||
feeburnkeeper "github.com/White-Whale-Defi-Platform/migaloo-chain/v4/x/feeburn/keeper" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" | ||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" | ||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" | ||
) | ||
|
||
// CreateUpgradeHandler small security fix, can be a no-op, running mm.RunMigarions just to be sure | ||
func CreateUpgradeHandler( | ||
mm *module.Manager, | ||
configurator module.Configurator, | ||
accountKeeper authkeeper.AccountKeeper, | ||
feeBurnKeeper feeburnkeeper.Keeper, | ||
|
||
) upgradetypes.UpgradeHandler { | ||
return func(ctx sdk.Context, _plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { | ||
|
||
// Burning module permissions | ||
moduleAccI := accountKeeper.GetModuleAccount(ctx, authtypes.FeeCollectorName) | ||
moduleAcc := moduleAccI.(*authtypes.ModuleAccount) | ||
moduleAcc.Permissions = []string{authtypes.Burner} | ||
accountKeeper.SetModuleAccount(ctx, moduleAcc) | ||
|
||
// set default fee_burn_percent to 50 | ||
feeBurnParams := feeBurnKeeper.GetParams(ctx) | ||
feeBurnParams.TxFeeBurnPercent = "50" | ||
|
||
_ = feeBurnKeeper.SetParams(ctx, feeBurnParams) | ||
return mm.RunMigrations(ctx, configurator, fromVM) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package v4_test | ||
|
||
import ( | ||
"testing" | ||
|
||
apptesting "github.com/White-Whale-Defi-Platform/migaloo-chain/v4/app" | ||
abci "github.com/cometbft/cometbft/abci/types" | ||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" | ||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
const ( | ||
v4UpgradeHeight = int64(10) | ||
) | ||
|
||
type UpgradeTestSuite struct { | ||
apptesting.KeeperTestHelper | ||
} | ||
|
||
func TestUpgradeTestSuite(t *testing.T) { | ||
suite.Run(t, new(UpgradeTestSuite)) | ||
} | ||
|
||
func (suite *UpgradeTestSuite) TestUpgrade() { | ||
suite.Setup(suite.T(), apptesting.SimAppChainID) | ||
dummyUpgrade(suite) | ||
feeBurnParam := suite.App.FeeBurnKeeper.GetParams(suite.Ctx) | ||
suite.Require().Equal("50", feeBurnParam.GetTxFeeBurnPercent()) | ||
} | ||
|
||
func dummyUpgrade(s *UpgradeTestSuite) { | ||
s.Ctx = s.Ctx.WithBlockHeight(v4UpgradeHeight - 1) | ||
plan := upgradetypes.Plan{Name: "v4.1.1", Height: v4UpgradeHeight} | ||
err := s.App.UpgradeKeeper.ScheduleUpgrade(s.Ctx, plan) | ||
s.Require().NoError(err) | ||
_, exists := s.App.UpgradeKeeper.GetUpgradePlan(s.Ctx) | ||
s.Require().True(exists) | ||
|
||
s.Ctx = s.Ctx.WithBlockHeight(v4UpgradeHeight) | ||
|
||
s.Require().NotPanics(func() { | ||
beginBlockRequest := abci.RequestBeginBlock{} | ||
s.App.BeginBlocker(s.Ctx, beginBlockRequest) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters