Skip to content

Commit

Permalink
on remove: slash PoA validator 100%
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups committed Feb 22, 2024
1 parent ae1d552 commit ca0c1ed
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 33 deletions.
3 changes: 0 additions & 3 deletions keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,6 @@ func (f *testFixture) IncreaseBlock(amt int64, debug ...bool) ([]abci.ValidatorU
return nil, err
}

if err := f.appModule.EndBlock(f.ctx); err != nil {
return nil, err
}
}

return allUpdates, nil
Expand Down
11 changes: 8 additions & 3 deletions keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,20 +379,25 @@ func TestRemoveValidator(t *testing.T) {
} else {
require.NoError(err)

_, err := f.IncreaseBlock(5, true)
_, err := f.IncreaseBlock(3, true)
require.NoError(err)
}

amt, err := f.stakingKeeper.TotalBondedTokens(f.ctx)
require.NoError(err)
fmt.Println("total bonded tokens", amt)

notBondedPool := f.stakingKeeper.GetNotBondedPool(f.ctx)
bondDenom, err := f.stakingKeeper.BondDenom(f.ctx)
require.NoError(err)
bal := f.bankkeeper.GetBalance(f.ctx, notBondedPool.GetAddress(), bondDenom)
fmt.Println("notBondedPool", bal.Amount)

// BondedRatio
bondRatio, err := f.stakingKeeper.BondedRatio(f.ctx)
require.NoError(err)
fmt.Println("bonded ratio", bondRatio)
// require.EqualValues(sdkmath.LegacyOneDec(), bondRatio)
require.True(bondRatio.GTE(sdkmath.LegacyNewDecWithPrec(6666, 18)))
require.EqualValues(sdkmath.LegacyOneDec(), bondRatio)
})
}
}
Expand Down
25 changes: 0 additions & 25 deletions module/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

"github.com/strangelove-ventures/poa"
Expand Down Expand Up @@ -61,30 +60,6 @@ func (am AppModule) BeginBlocker(ctx context.Context) error {
return nil
}

func (am AppModule) EndBlocker(ctx context.Context) error {
sdkCtx := sdk.UnwrapSDKContext(ctx)
defer telemetry.ModuleMeasureSince(poa.ModuleName, sdkCtx.BlockTime(), telemetry.MetricKeyEndBlocker)

bondDenom, err := am.keeper.GetStakingKeeper().BondDenom(ctx)
if err != nil {
return err
}

notBondedAcc := authtypes.NewModuleAddress(stakingtypes.NotBondedPoolName)

bal := am.keeper.GetBankKeeper().
GetBalance(ctx, notBondedAcc, bondDenom).Amount

if bal.IsPositive() {
coins := sdk.NewCoins(sdk.NewCoin(bondDenom, bal))
if err := am.keeper.GetBankKeeper().BurnCoins(ctx, stakingtypes.NotBondedPoolName, coins); err != nil {
return nil
}
}

return nil
}

// resetCachedTotalPower resets the block power index to the current total power.
func (am AppModule) resetCachedTotalPower(ctx context.Context) error {
currValPower, err := am.keeper.GetStakingKeeper().GetLastTotalPower(ctx)
Expand Down
4 changes: 2 additions & 2 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,16 +451,16 @@ func NewSimApp(
distrtypes.ModuleName,
slashingtypes.ModuleName,
evidencetypes.ModuleName,
poa.ModuleName,
stakingtypes.ModuleName,
poa.ModuleName,
genutiltypes.ModuleName,
authz.ModuleName,
)
app.ModuleManager.SetOrderEndBlockers(
crisistypes.ModuleName,
govtypes.ModuleName,
poa.ModuleName,
stakingtypes.ModuleName,
poa.ModuleName,
genutiltypes.ModuleName,
feegrant.ModuleName,
group.ModuleName,
Expand Down

0 comments on commit ca0c1ed

Please sign in to comment.