Skip to content

Commit db9ca82

Browse files
author
Alan Chen
committed
consensus/istanbul: we don't have to send COMMIT for old proposal anymore
1 parent 21d4941 commit db9ca82

File tree

2 files changed

+3
-36
lines changed

2 files changed

+3
-36
lines changed

consensus/istanbul/core/preprepare.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,6 @@ func (c *core) handlePreprepare(msg *message, src istanbul.Validator) error {
5858
// Ensure we have the same view with the preprepare message
5959
// If it is old message, see if we need to broadcast COMMIT
6060
if err := c.checkMessage(msgPreprepare, preprepare.View); err != nil {
61-
if err == errOldMessage {
62-
// Get validator set for the given proposal
63-
valSet := c.backend.ParentValidators(preprepare.Proposal).Copy()
64-
previousProposer := c.backend.GetProposer(preprepare.Proposal.Number().Uint64() - 1)
65-
valSet.CalcProposer(previousProposer, preprepare.View.Round.Uint64())
66-
// Broadcast COMMIT if it is an existing block
67-
// 1. The proposer needs to be a proposer matches the given (Sequence + Round)
68-
// 2. The given block must exist
69-
if valSet.IsProposer(src.Address()) && c.backend.HasBlock(preprepare.Proposal.Hash(), preprepare.Proposal.Number()) {
70-
c.sendCommitForOldBlock(preprepare.View, preprepare.Proposal.Hash())
71-
return nil
72-
}
73-
}
7461
return err
7562
}
7663

consensus/istanbul/core/preprepare_test.go

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func TestHandlePreprepare(t *testing.T) {
111111
false,
112112
},
113113
{
114-
// ErrInvalidMessage
114+
// errOldMessage
115115
func() *testSystem {
116116
sys := NewTestSystemWithBackend(N, F)
117117

@@ -130,26 +130,6 @@ func TestHandlePreprepare(t *testing.T) {
130130
errOldMessage,
131131
false,
132132
},
133-
{
134-
// ErrInvalidMessage
135-
func() *testSystem {
136-
sys := NewTestSystemWithBackend(N, F)
137-
138-
for i, backend := range sys.backends {
139-
c := backend.engine.(*core)
140-
c.valSet = backend.peers
141-
if i != 0 {
142-
c.state = StatePreprepared
143-
c.current.SetSequence(big.NewInt(10))
144-
c.current.SetRound(big.NewInt(10))
145-
}
146-
}
147-
return sys
148-
}(),
149-
makeBlock(5), //only height 5 will retrun true on backend.HasBlock, see testSystemBackend.HashBlock
150-
nil,
151-
true,
152-
},
153133
}
154134

155135
OUTER:
@@ -293,8 +273,8 @@ func TestHandlePreprepareWithLock(t *testing.T) {
293273
t.Errorf("error mismatch: have %v, want nil", err)
294274
}
295275
if test.proposal == test.lockProposal {
296-
if c.state != StatePrepared {
297-
t.Errorf("state mismatch: have %v, want %v", c.state, StatePrepared)
276+
if c.state != StatePreprepared {
277+
t.Errorf("state mismatch: have %v, want %v", c.state, StatePreprepared)
298278
}
299279
if !reflect.DeepEqual(curView, c.currentView()) {
300280
t.Errorf("view mismatch: have %v, want %v", c.currentView(), curView)

0 commit comments

Comments
 (0)