2018-05-23 13:25:56 -07:00
|
|
|
package slashing
|
|
|
|
|
|
|
|
import (
|
2018-06-28 17:54:47 -07:00
|
|
|
abci "github.com/tendermint/tendermint/abci/types"
|
2018-12-10 06:27:25 -08:00
|
|
|
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
2020-06-12 07:25:12 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/slashing/keeper"
|
2018-05-23 13:25:56 -07:00
|
|
|
)
|
|
|
|
|
2019-07-19 06:43:38 -07:00
|
|
|
// BeginBlocker check for infraction evidence or downtime of validators
|
|
|
|
// on every begin block
|
2020-06-12 07:25:12 -07:00
|
|
|
func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, k keeper.Keeper) {
|
2019-02-07 17:41:23 -08:00
|
|
|
// Iterate over all the validators which *should* have signed this block
|
2018-10-12 04:15:13 -07:00
|
|
|
// store whether or not they have actually signed it and slash/unbond any
|
2018-06-29 20:34:55 -07:00
|
|
|
// which have missed too many blocks in a row (downtime slashing)
|
2018-10-03 08:48:23 -07:00
|
|
|
for _, voteInfo := range req.LastCommitInfo.GetVotes() {
|
2019-07-19 06:43:38 -07:00
|
|
|
k.HandleValidatorSignature(ctx, voteInfo.Validator.Address, voteInfo.Validator.Power, voteInfo.SignedLastBlock)
|
2018-06-29 20:34:55 -07:00
|
|
|
}
|
2018-05-23 13:25:56 -07:00
|
|
|
}
|