Skip to content

Commit

Permalink
bot-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ajansari95 committed Jun 5, 2022
1 parent 5c4f117 commit 17010bc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Binary file added .DS_Store
Binary file not shown.
5 changes: 4 additions & 1 deletion tendermint/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions tendermint/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 17010bc

Please sign in to comment.