mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-05 04:55:18 +00:00
cs: set missing_validators(_power) metrics to 0 for 1st block (#4194)
also
- do not send any LastCommitInfo.Votes for 1st block.
- use cs.LastValidators (not cs.Validators) in recordMetrics when counting missing validators
note:
remember that the first LastCommit is intentionally empty, so it makes
sense for LastCommitInfo.Votes to also be empty. Because we can't really
tell if validator signed or not. Similar for ^ metrics, we can't say if
particular validator was missing or not.
Closes #4192
This commit is contained in:
@@ -310,57 +310,51 @@ func execBlockOnProxyApp(
|
||||
|
||||
func getBeginBlockValidatorInfo(block *types.Block, stateDB dbm.DB) (abci.LastCommitInfo, []abci.Evidence) {
|
||||
voteInfos := make([]abci.VoteInfo, block.LastCommit.Size())
|
||||
byzVals := make([]abci.Evidence, len(block.Evidence.Evidence))
|
||||
var lastValSet *types.ValidatorSet
|
||||
var err error
|
||||
// block.Height=1 -> LastCommitInfo.Votes are empty.
|
||||
// Remember that the first LastCommit is intentionally empty, so it makes
|
||||
// sense for LastCommitInfo.Votes to also be empty.
|
||||
if block.Height > 1 {
|
||||
lastValSet, err = LoadValidators(stateDB, block.Height-1)
|
||||
lastValSet, err := LoadValidators(stateDB, block.Height-1)
|
||||
if err != nil {
|
||||
panic(err) // shouldn't happen
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Sanity check that commit size matches validator set size -
|
||||
// only applies after first block
|
||||
commitSize := block.LastCommit.Size()
|
||||
valSetLen := len(lastValSet.Validators)
|
||||
// Sanity check that commit size matches validator set size - only applies
|
||||
// after first block.
|
||||
var (
|
||||
commitSize = block.LastCommit.Size()
|
||||
valSetLen = len(lastValSet.Validators)
|
||||
)
|
||||
if commitSize != valSetLen {
|
||||
// sanity check
|
||||
panic(fmt.Sprintf("commit size (%d) doesn't match valset length (%d) at height %d\n\n%v\n\n%v",
|
||||
commitSize, valSetLen, block.Height, block.LastCommit.Signatures, lastValSet.Validators))
|
||||
}
|
||||
} else {
|
||||
lastValSet = types.NewValidatorSet(nil)
|
||||
}
|
||||
|
||||
for i, val := range lastValSet.Validators {
|
||||
if i >= len(block.LastCommit.Signatures) {
|
||||
break
|
||||
}
|
||||
commitSig := block.LastCommit.Signatures[i]
|
||||
voteInfo := abci.VoteInfo{
|
||||
Validator: types.TM2PB.Validator(val),
|
||||
SignedLastBlock: !commitSig.Absent(),
|
||||
}
|
||||
voteInfos[i] = voteInfo
|
||||
|
||||
for i, val := range lastValSet.Validators {
|
||||
commitSig := block.LastCommit.Signatures[i]
|
||||
voteInfos[i] = abci.VoteInfo{
|
||||
Validator: types.TM2PB.Validator(val),
|
||||
SignedLastBlock: !commitSig.Absent(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
byzVals := make([]abci.Evidence, len(block.Evidence.Evidence))
|
||||
for i, ev := range block.Evidence.Evidence {
|
||||
// We need the validator set. We already did this in validateBlock.
|
||||
// TODO: Should we instead cache the valset in the evidence itself and add
|
||||
// `SetValidatorSet()` and `ToABCI` methods ?
|
||||
valset, err := LoadValidators(stateDB, ev.Height())
|
||||
if err != nil {
|
||||
panic(err) // shouldn't happen
|
||||
panic(err)
|
||||
}
|
||||
byzVals[i] = types.TM2PB.Evidence(ev, valset, block.Time)
|
||||
}
|
||||
|
||||
commitInfo := abci.LastCommitInfo{
|
||||
return abci.LastCommitInfo{
|
||||
Round: int32(block.LastCommit.Round),
|
||||
Votes: voteInfos,
|
||||
}
|
||||
return commitInfo, byzVals
|
||||
|
||||
}, byzVals
|
||||
}
|
||||
|
||||
func validateValidatorUpdates(abciUpdates []abci.ValidatorUpdate,
|
||||
|
||||
Reference in New Issue
Block a user