Skip to content

Commit

Permalink
Fix simpleBFT primary requests drops
Browse files Browse the repository at this point in the history
SimpleBFT primary needs to accept its own pre-prepare immediately
A test was also added.

Change-Id: I28b288c4c5812eb16a7ff1779f603564f6814f43
Signed-off-by: Gabor Hosszu <gabor@digitalasset.com>
Signed-off-by: Marko Vukolic <mvu@zurich.ibm.com>
  • Loading branch information
Marko Vukolic authored and gaborh-da committed Nov 28, 2016
1 parent 78d6360 commit a10012f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
5 changes: 5 additions & 0 deletions orderer/sbft/simplebft/preprepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@ func (s *SBFT) sendPreprepare(batch []*Request) {

s.sys.Persist("preprepare", m)
s.broadcast(&Msg{&Msg_Preprepare{m}})
s.handleCheckedPreprepare(m)
}

func (s *SBFT) handlePreprepare(pp *Preprepare, src uint64) {
if src == s.id {
log.Infof("Ignoring preprepare from self: %d", src)
return
}
if src != s.primaryID() {
log.Infof("preprepare from non-primary %d", src)
return
Expand Down
33 changes: 33 additions & 0 deletions orderer/sbft/simplebft/simplebft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -977,3 +977,36 @@ func TestResendViewChange(t *testing.T) {
}
}
}

func TestTenReplicasBombedWithRequests(t *testing.T) {
N := uint64(10)
requestNumber := 11
sys := newTestSystem(N)
var repls []*SBFT
var adapters []*testSystemAdapter
for i := uint64(0); i < N; i++ {
a := sys.NewAdapter(i)
s, err := New(i, &Config{N: N, F: 3, BatchDurationNsec: 2000000000, BatchSizeBytes: 3, RequestTimeoutNsec: 20000000000}, a)
if err != nil {
t.Fatal(err)
}
repls = append(repls, s)
adapters = append(adapters, a)
}

connectAll(sys)
for i := 0; i < requestNumber; i++ {
r := []byte{byte(i), 2, 3}
repls[2].Request(r)
}
sys.Run()
for _, a := range adapters {
i := 0
for _, b := range a.batches {
i = i + len(b.Payloads)
}
if i != requestNumber {
t.Fatalf("expected execution of %d requests but: %d", requestNumber, i)
}
}
}

0 comments on commit a10012f

Please sign in to comment.