don't verify own block parts

This commit is contained in:
Ethan Buchman 2016-03-11 21:38:15 -05:00
parent 5e42c96267
commit 79c9a9f03a
2 changed files with 8 additions and 7 deletions

View File

@ -655,7 +655,7 @@ func (cs *ConsensusState) handleMsg(mi msgInfo, rs RoundState) {
err = cs.setProposal(msg.Proposal) err = cs.setProposal(msg.Proposal)
case *BlockPartMessage: case *BlockPartMessage:
// if the proposal is complete, we'll enterPrevote or tryFinalizeCommit // if the proposal is complete, we'll enterPrevote or tryFinalizeCommit
_, err = cs.addProposalBlockPart(msg.Height, msg.Part) _, err = cs.addProposalBlockPart(msg.Height, msg.Part, peerKey != "")
if err != nil && msg.Round != cs.Round { if err != nil && msg.Round != cs.Round {
err = nil err = nil
} }
@ -1291,7 +1291,7 @@ func (cs *ConsensusState) setProposal(proposal *types.Proposal) error {
// NOTE: block is not necessarily valid. // NOTE: block is not necessarily valid.
// Asynchronously triggers either enterPrevote (before we timeout of propose) or tryFinalizeCommit, once we have the full block. // Asynchronously triggers either enterPrevote (before we timeout of propose) or tryFinalizeCommit, once we have the full block.
func (cs *ConsensusState) addProposalBlockPart(height int, part *types.Part) (added bool, err error) { func (cs *ConsensusState) addProposalBlockPart(height int, part *types.Part, verify bool) (added bool, err error) {
// Blocks might be reused, so round mismatch is OK // Blocks might be reused, so round mismatch is OK
if cs.Height != height { if cs.Height != height {
return false, nil return false, nil
@ -1302,7 +1302,7 @@ func (cs *ConsensusState) addProposalBlockPart(height int, part *types.Part) (ad
return false, nil // TODO: bad peer? Return error? return false, nil // TODO: bad peer? Return error?
} }
added, err = cs.ProposalBlockParts.AddPart(part) added, err = cs.ProposalBlockParts.AddPart(part, verify)
if err != nil { if err != nil {
return added, err return added, err
} }

View File

@ -188,7 +188,7 @@ func (ps *PartSet) Total() int {
return ps.total return ps.total
} }
func (ps *PartSet) AddPart(part *Part) (bool, error) { func (ps *PartSet) AddPart(part *Part, verify bool) (bool, error) {
ps.mtx.Lock() ps.mtx.Lock()
defer ps.mtx.Unlock() defer ps.mtx.Unlock()
@ -203,9 +203,10 @@ func (ps *PartSet) AddPart(part *Part) (bool, error) {
} }
// Check hash proof // Check hash proof
// TODO: minor gains for not checking part sets we made if verify {
if !part.Proof.Verify(part.Index, ps.total, part.Hash(), ps.Hash()) { if !part.Proof.Verify(part.Index, ps.total, part.Hash(), ps.Hash()) {
return false, ErrPartSetInvalidProof return false, ErrPartSetInvalidProof
}
} }
// Add part // Add part