monkey-see-monkey-do-fixes

This commit is contained in:
Sergio Mena
2022-11-30 21:19:15 +01:00
parent a7b3736cb0
commit 30bcc5230a
6 changed files with 11 additions and 11 deletions
+1 -1
View File
@@ -255,7 +255,7 @@ func (pool *BlockPool) RedoRequest(height int64) p2p.ID {
// height of the extended commit and the height of the block do not match, we
// do not add the block and return an error.
// TODO: ensure that blocks come in order for each peer.
func (pool *BlockPool) AddBlock(peerID p2p.ID, block *types.Block, extCommit *types.ExtendedCommit, blockSize int) {
func (pool *BlockPool) AddBlock(peerID p2p.ID, block *types.Block, extCommit *types.ExtendedCommit, blockSize int) error {
pool.mtx.Lock()
defer pool.mtx.Unlock()
+1 -1
View File
@@ -1691,7 +1691,7 @@ func (m *VoteMessage) ValidateBasic() error {
// here.
return m.Vote.ValidateWithExtension()
}
g
// String returns a string representation.
func (m *VoteMessage) String() string {
return fmt.Sprintf("[Vote %v]", m.Vote)
+2 -2
View File
@@ -2070,7 +2070,7 @@ func (cs *State) addVote(vote *types.Vote, peerID p2p.ID) (added bool, err error
// Verify VoteExtension if precommit and not nil
// https://github.com/tendermint/tendermint/issues/8487
if vote.Type == tmproto.PrecommitType && !vote.BlockID.IsNil() {
if vote.Type == tmproto.PrecommitType && len(vote.BlockID.Hash) != 0 {
if err = cs.blockExec.VerifyVoteExtension(vote); err != nil {
return false, err
}
@@ -2237,7 +2237,7 @@ func (cs *State) signVote(
BlockID: types.BlockID{Hash: hash, PartSetHeader: header},
}
if msgType == tmproto.PrecommitType && !vote.BlockID.IsNil() {
if msgType == tmproto.PrecommitType && len(vote.BlockID.Hash) != 0 {
// if the signedMessage type is for a non-nil precommit, add
// VoteExtension
ext, err := cs.blockExec.ExtendVote(vote)
+1 -1
View File
@@ -1121,7 +1121,7 @@ func (ec *ExtendedCommit) ValidateBasic() error {
}
if ec.Height >= 1 {
if ec.BlockID.IsNil() {
if len(ec.BlockID.Hash) == 0 {
return errors.New("commit cannot be for nil block")
}
+4 -4
View File
@@ -34,10 +34,10 @@ func VerifyCommit(chainID string, vals *ValidatorSet, blockID BlockID,
votingPowerNeeded := vals.TotalVotingPower() * 2 / 3
// ignore all absent signatures
ignore := func(c CommitSig) bool { return c.Absent() }
ignore := func(c CommitSig) bool { return c.BlockIDFlag == BlockIDFlagAbsent }
// only count the signatures that are for the block
count := func(c CommitSig) bool { return c.ForBlock() }
count := func(c CommitSig) bool { return c.BlockIDFlag == BlockIDFlagCommit }
// attempt to batch verify
if shouldBatchVerify(vals, commit) {
@@ -67,7 +67,7 @@ func VerifyCommitLight(chainID string, vals *ValidatorSet, blockID BlockID,
votingPowerNeeded := vals.TotalVotingPower() * 2 / 3
// ignore all commit signatures that are not for the block
ignore := func(c CommitSig) bool { return !c.ForBlock() }
ignore := func(c CommitSig) bool { return c.BlockIDFlag != BlockIDFlagCommit }
// count all the remaining signatures
count := func(c CommitSig) bool { return true }
@@ -111,7 +111,7 @@ func VerifyCommitLightTrusting(chainID string, vals *ValidatorSet, commit *Commi
votingPowerNeeded := totalVotingPowerMulByNumerator / int64(trustLevel.Denominator)
// ignore all commit signatures that are not for the block
ignore := func(c CommitSig) bool { return !c.ForBlock() }
ignore := func(c CommitSig) bool { return c.BlockIDFlag != BlockIDFlagCommit }
// count all the remaining signatures
count := func(c CommitSig) bool { return true }
+2 -2
View File
@@ -297,7 +297,7 @@ func (vote *Vote) ValidateBasic() error {
// We should only ever see vote extensions in non-nil precommits, otherwise
// this is a violation of the specification.
// https://github.com/tendermint/tendermint/issues/8487
if vote.Type != tmproto.PrecommitType || (vote.Type == tmproto.PrecommitType && vote.BlockID.IsNil()) {
if vote.Type != tmproto.PrecommitType || (vote.Type == tmproto.PrecommitType && len(vote.BlockID.Hash) == 0) {
if len(vote.Extension) > 0 {
return errors.New("unexpected vote extension")
}
@@ -318,7 +318,7 @@ func (vote *Vote) ValidateWithExtension() error {
}
// We should always see vote extension signatures in non-nil precommits
if vote.Type == tmproto.PrecommitType && !vote.BlockID.IsNil() {
if vote.Type == tmproto.PrecommitType && len(vote.BlockID.Hash) != 0 {
if len(vote.ExtensionSignature) == 0 {
return errors.New("vote extension signature is missing")
}