Merge PR #4629: Emit Warning Events when Validator Misses Blocks

This commit is contained in:
Aditya 2019-06-28 17:53:30 +00:00 committed by Alexander Bezobchuk
parent a57915600c
commit f9dea984c2
6 changed files with 40 additions and 7 deletions

View File

@ -0,0 +1 @@
#4629 Added warning event that gets emitted if validator misses a block.

View File

@ -84,7 +84,9 @@ single slashing period is capped as described in [overview.md](overview.md) unde
## Uptime tracking
At the beginning of each block, we update the signing info for each validator and check if they've dipped below the liveness threshold over the tracked window. If so, they will be slashed by `LivenessSlashAmount` and will be Jailed for `LivenessJailPeriod`. Liveness slashes do NOT lead to a tombstombing.
At the beginning of each block, we update the signing info for each validator and check if they've dipped below the liveness threshold over the tracked window. If so, they will be slashed by `LivenessSlashAmount` and will be Jailed for `LivenessJailPeriod`. Liveness slashes do NOT lead to a tombstombing.
If a validator misses a block, a warning event will get emitted.
```
height := block.Height
@ -108,6 +110,18 @@ for val in block.Validators:
signInfo.MissedBlocksCounter--
// else previous == val not in block.AbsentValidators, no change
// Emit warning events if Validator misses block
if val in block.AbsentValidators {
ctx.EventManager().EmitEvent(
NewEvent(
EventTypeLiveness,
NewAttribute(AttributeKeyAddress, consAddr),
NewAttribute(AttributeKeyMissedBlocks, signInfo.MissedBlocksCounter),
NewAttribute(AttributeKeyHeight, ctx.BlockHeight())
),
)
}
// validator must be active for at least SIGNED_BLOCKS_WINDOW
// before they can be automatically unbonded for failing to be
// included in 50% of the recent LastCommits

View File

@ -13,6 +13,12 @@ The slashing module emits the following events/tags:
- [0] Only included if the validator is jailed.
| Type | Attribute Key | Attribute Value |
|----------|---------------|-----------------------------|
| liveness | address | {validatorConsensusAddress} |
| liveness | missed_blocks | {missedBlocksCounter} |
| liveness | height | {blockHeight} |
## Handlers
### MsgUnjail

View File

@ -311,4 +311,4 @@ func (pst *thePast) getOp(ver int64) (Op, bool) {
return Op{}, false
}
return pst.ops[ver-1], true
}
}

View File

@ -184,6 +184,15 @@ func (k Keeper) HandleValidatorSignature(ctx sdk.Context, addr crypto.Address, p
}
if missed {
ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeLiveness,
sdk.NewAttribute(types.AttributeKeyAddress, consAddr.String()),
sdk.NewAttribute(types.AttributeKeyMissedBlocks, fmt.Sprintf("%d", signInfo.MissedBlocksCounter)),
sdk.NewAttribute(types.AttributeKeyHeight, fmt.Sprintf("%d", height)),
),
)
logger.Info(fmt.Sprintf("Absent validator %s (%v) at height %d, %d missed, threshold %d", addr, pubkey, height, signInfo.MissedBlocksCounter, k.MinSignedPerWindow(ctx)))
}

View File

@ -2,12 +2,15 @@ package types
// Slashing module event types
var (
EventTypeSlash = "slash"
EventTypeSlash = "slash"
EventTypeLiveness = "liveness"
AttributeKeyAddress = "address"
AttributeKeyPower = "power"
AttributeKeyReason = "reason"
AttributeKeyJailed = "jailed"
AttributeKeyAddress = "address"
AttributeKeyHeight = "height"
AttributeKeyPower = "power"
AttributeKeyReason = "reason"
AttributeKeyJailed = "jailed"
AttributeKeyMissedBlocks = "missed_blocks"
AttributeValueDoubleSign = "double_sign"
AttributeValueMissingSignature = "missing_signature"