Skip to content

Commit

Permalink
feat: re add MsgCreateValidator check in ante (#271) (#277)
Browse files Browse the repository at this point in the history
(cherry picked from commit 7e8e420)

Co-authored-by: Facundo Medica <[email protected]>
  • Loading branch information
github-actions[bot] and facundomedica authored Aug 12, 2024
1 parent f412a11 commit b53fe10
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 53 deletions.
55 changes: 18 additions & 37 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -979,45 +979,26 @@ func (app *App) preBlocker(ph *ProposalHandler) func(sdk.Context, *abci.RequestF
}

func (app *App) RegisterUpgradeHandlers() {
// const UpgradeName = "v0.2.0"

// app.UpgradeKeeper.SetUpgradeHandler(
// UpgradeName,
// func(ctx context.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// // one time thing, changing the team address
// currentParams, err := app.DisputeKeeper.Params.Get(ctx)
// if err != nil {
// return nil, err
// }

// addrCdc := address.Bech32Codec{
// Bech32Prefix: sdk.GetConfig().GetBech32AccountAddrPrefix(),
// }

// currentParams.TeamAddress, err = addrCdc.StringToBytes("tellor18wjwgr0j8pv4ektdaxvzsykpntdylftwz8ml97")
// if err != nil {
// return nil, err
// }

// if err = app.DisputeKeeper.Params.Set(ctx, currentParams); err != nil {
// return nil, err
// }

// return app.ModuleManager().RunMigrations(ctx, app.Configurator(), fromVM)
// },
// )

// upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
// if err != nil {
// panic(err)
// }
const UpgradeName = "v0.3.0"

// if upgradeInfo.Name == UpgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
// storeUpgrades := storetypes.StoreUpgrades{}
app.UpgradeKeeper.SetUpgradeHandler(
UpgradeName,
func(ctx context.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return app.ModuleManager().RunMigrations(ctx, app.Configurator(), fromVM)
},
)

// // configure store loader that checks if version == upgradeHeight and applies store upgrades
// app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
// }
upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(err)
}

if upgradeInfo.Name == UpgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := storetypes.StoreUpgrades{}

// configure store loader that checks if version == upgradeHeight and applies store upgrades
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
}
}

// Name returns the name of the App
Expand Down
4 changes: 2 additions & 2 deletions x/reporter/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ func (t TrackStakeChangesDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul
var msgAmount math.Int
for _, msg := range tx.GetMsgs() {
switch msg := msg.(type) {
// case *stakingtypes.MsgCreateValidator:
// msgAmount = msg.Value.Amount
case *stakingtypes.MsgCreateValidator:
msgAmount = msg.Value.Amount
case *stakingtypes.MsgDelegate:
msgAmount = msg.Amount.Amount
case *stakingtypes.MsgBeginRedelegate:
Expand Down
28 changes: 14 additions & 14 deletions x/reporter/ante/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ func TestNewTrackStakeChangesDecorator(t *testing.T) {
msg sdk.Msg
err error
}{
// {
// name: "CreateValidator",
// msg: &stakingtypes.MsgCreateValidator{
// Value: sdk.Coin{Denom: "loya", Amount: math.NewInt(1)},
// },
// err: nil,
// },
// {
// name: "CreateValidator",
// msg: &stakingtypes.MsgCreateValidator{
// Value: sdk.Coin{Denom: "loya", Amount: math.NewInt(100)},
// },
// err: errors.New("amount increases total stake by more than the allowed 5% in a twelve hour period"),
// },
{
name: "CreateValidator",
msg: &stakingtypes.MsgCreateValidator{
Value: sdk.Coin{Denom: "loya", Amount: math.NewInt(1)},
},
err: nil,
},
{
name: "CreateValidator",
msg: &stakingtypes.MsgCreateValidator{
Value: sdk.Coin{Denom: "loya", Amount: math.NewInt(100)},
},
err: errors.New("amount increases total stake by more than the allowed 5% in a twelve hour period"),
},
{
name: "Delegate",
msg: &stakingtypes.MsgDelegate{
Expand Down

0 comments on commit b53fe10

Please sign in to comment.