Remove verify future commit as uncessessary

This commit is contained in:
Zaki Manian
2019-07-06 20:21:23 -07:00
parent 6746befb44
commit 2872df6634
-84
View File
@@ -638,90 +638,6 @@ func (vals *ValidatorSet) VerifyCommit(chainID string, blockID BlockID, height i
return errTooMuchChange{talliedVotingPower, vals.TotalVotingPower()*2/3 + 1}
}
// VerifyFutureCommit checks to see if a given future validator set has
// committed a block, and whether those who signed of this future validator set
// has sufficient overlap with this validator set.
//
// vals is the current validator set that we know. Over 2/3 of the power in
// this valset is expected to have signed this block.
//
// Justification for the 2/3: In Tendermint, 1/3 of the voting power can halt
// or fork the chain, but 1/3 can't make arbitrary state transitions. You
// still need > 2/3 Byzantine to make arbitrary state transitions.
//
// To preserve this property in the light client, we also require > 2/3 of the
// old vals to sign the future commit at H, that way we preserve the property
// that if they weren't being truthful about the validator set at H (block hash
// -> vals hash) or about the app state (block hash -> app hash) we can slash
// > 2/3. Otherwise, the lite client isn't providing the same security
// guarantees.
//
// newVals is the validator set that signed this block. Only votes from new are
// sufficient for 2/3 majority in the new set as well, for it to be a valid
// commit.
//
// NOTE: This doesn't check whether the commit is actually a future commit,
// because the current height isn't part of the ValidatorSet. Caller must
// check that the commit height is greater than the height for this validator
// set.
//
// NOTE: This function is strictly more restrictive than merely checking
// whether newVals.VerifyCommit(...), in fact it calls exactly that.
func (vals *ValidatorSet) VerifyFutureCommit(newVals *ValidatorSet, chainID string,
blockID BlockID, height int64, commit *Commit) error {
oldVals := vals
// Commit must be a valid commit for newVals.
err := newVals.VerifyCommit(chainID, blockID, height, commit)
if err != nil {
return err
}
// Check old voting power.
oldVotingPower := int64(0)
seen := map[int]bool{}
round := commit.Round()
for idx, precommit := range commit.Precommits {
if precommit == nil {
continue
}
if precommit.Height != height {
return cmn.NewError("Blocks don't match - %d vs %d", round, precommit.Round)
}
if precommit.Round != round {
return cmn.NewError("Invalid commit -- wrong round: %v vs %v", round, precommit.Round)
}
if precommit.Type != PrecommitType {
return cmn.NewError("Invalid commit -- not precommit @ index %v", idx)
}
// See if this validator is in oldVals.
oldIdx, val := oldVals.GetByAddress(precommit.ValidatorAddress)
if val == nil || seen[oldIdx] {
continue // missing or double vote...
}
seen[oldIdx] = true
// Validate signature.
precommitSignBytes := commit.VoteSignBytes(chainID, idx)
if !val.PubKey.VerifyBytes(precommitSignBytes, precommit.Signature) {
return cmn.NewError("Invalid commit -- invalid signature: %v", precommit)
}
// Good precommit!
if blockID.Equals(precommit.BlockID) {
oldVotingPower += val.VotingPower
} else {
// It's OK that the BlockID doesn't match. We include stray
// precommits to measure validator availability.
}
}
if oldVotingPower <= oldVals.TotalVotingPower()*2/3 {
return errTooMuchChange{oldVotingPower, oldVals.TotalVotingPower()*2/3 + 1}
}
return nil
}
//-----------------
// ErrTooMuchChange