github.com/cosmos/cosmos-sdk@v0.50.10/x/slashing/abci.go (about) 1 package slashing 2 3 import ( 4 "context" 5 6 "cosmossdk.io/core/comet" 7 8 "github.com/cosmos/cosmos-sdk/telemetry" 9 sdk "github.com/cosmos/cosmos-sdk/types" 10 "github.com/cosmos/cosmos-sdk/x/slashing/keeper" 11 "github.com/cosmos/cosmos-sdk/x/slashing/types" 12 ) 13 14 // BeginBlocker check for infraction evidence or downtime of validators 15 // on every begin block 16 func BeginBlocker(ctx context.Context, k keeper.Keeper) error { 17 defer telemetry.ModuleMeasureSince(types.ModuleName, telemetry.Now(), telemetry.MetricKeyBeginBlocker) 18 19 // Iterate over all the validators which *should* have signed this block 20 // store whether or not they have actually signed it and slash/unbond any 21 // which have missed too many blocks in a row (downtime slashing) 22 sdkCtx := sdk.UnwrapSDKContext(ctx) 23 for _, voteInfo := range sdkCtx.VoteInfos() { 24 err := k.HandleValidatorSignature(ctx, voteInfo.Validator.Address, voteInfo.Validator.Power, comet.BlockIDFlag(voteInfo.BlockIdFlag)) 25 if err != nil { 26 return err 27 } 28 } 29 return nil 30 }