diff --git a/tendermint/listener.go b/tendermint/listener.go index 39a7939..f68ac55 100644 --- a/tendermint/listener.go +++ b/tendermint/listener.go @@ -41,6 +41,9 @@ func StartListening(initClientCtx client.Context, chain *relayer.Chain, brokers } checkValidatorStatusPeriod := int64(float64(slashingParamsResponse.Params.SignedBlocksWindow) * (1 - minSignedPerWindow) / 10) + // above lowerLimitForWarningValidator limit, if a validator has missed blocks then start sending warnings + lowerLimitForWarningValidator := int64((float64(slashingParamsResponse.Params.SignedBlocksWindow) * (1 - minSignedPerWindow)) * 0.7) + for { // For Tendermint, we can directly query without waiting for blocks since there is finality err := onNewBlock(ctx, initClientCtx, chain, &kafkaProducer, protoCodec) @@ -87,7 +90,7 @@ func StartListening(initClientCtx client.Context, chain *relayer.Chain, brokers } if processHeight%checkValidatorStatusPeriod == 0 { - CheckValidators(chain, processHeight) + CheckValidators(chain, processHeight, lowerLimitForWarningValidator) } err = handleTxSearchResult(initClientCtx, resultTxs, &kafkaProducer, protoCodec) diff --git a/tendermint/validator.go b/tendermint/validator.go index f042e4b..66e4b8b 100644 --- a/tendermint/validator.go +++ b/tendermint/validator.go @@ -11,7 +11,7 @@ import ( //Map to keep track of missed blocks during previous CheckValidators() call var missedBlockCounterForValidator = make(map[string]int64) -func CheckValidators(chain *relayer.Chain, processHeight int64) { +func CheckValidators(chain *relayer.Chain, processHeight int64, lowerLimitForWarningValidator int64) { //Get validators list from db validators, err := db.GetValidators() if err != nil { @@ -39,7 +39,9 @@ func CheckValidators(chain *relayer.Chain, processHeight int64) { logging.Error("Could not find the signing info about the validator", processHeight, "Validator Name:", validator.Name, "ERR:", err) } - if validatorSlashingInfo.ValSigningInfo.MissedBlocksCounter > missedBlockCounterForValidator[validator.Name] { + // only above lowerLimitForWarningValidator, warning will be sent + if validatorSlashingInfo.ValSigningInfo.MissedBlocksCounter > missedBlockCounterForValidator[validator.Name] && + validatorSlashingInfo.ValSigningInfo.MissedBlocksCounter > lowerLimitForWarningValidator { logging.Warn("Validator is about to be jailed", processHeight, "Validator Name:", validator.Name) } if validatorDetails.Validator.Jailed {