Skip to content

Commit

Permalink
BFT Block Puller: BFTDeliverer (#4365)
Browse files Browse the repository at this point in the history
* BFT Block Puller: censorship monitor

BFT header receivers that pull headers from the orderers, and keep the time and number of the last one.
The header receivers verify each block as it arrives.
The header receivers will receive (or ask for) full config blocks - in a later commit.
The header receivers will maintain their own private block verifier (bundle) - in a later commit.

A BFT censorship monitor which periodically compares the progress of headers relative to blocks.
The monitor triggers an alert if a header is ahead of the block stream for more than a certain time.

The BFTDeliverer is only a skeleton

Signed-off-by: Yoav Tock <tock@il.ibm.com>
Change-Id: I5180a98640073b87effb478fd86b6fa7d4df5dee

* BFT Block Puller: BFTDeliverer

- A BFTDeliverer that fetches blocks and maintains a BFTCensorshipMonitor.
- Abstract the creation of a BFTCensorshipMonitor via an abstract factory, so that we can use a mock for it in testing.
- Add a "shuffledEndpoints" method to the connection source and test it.
- Unit testing of BFTDeliverer.

Signed-off-by: Yoav Tock <tock@il.ibm.com>
Change-Id: Ifead3f9e6c803c4d9fabc63acce11c6da472b88d

---------

Signed-off-by: Yoav Tock <tock@il.ibm.com>
  • Loading branch information
tock-ibm authored Nov 15, 2023
1 parent 0514a3d commit 5b1ac91
Show file tree
Hide file tree
Showing 28 changed files with 4,020 additions and 298 deletions.
407 changes: 407 additions & 0 deletions internal/pkg/peer/blocksprovider/bft_censorship_monitor.go

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions internal/pkg/peer/blocksprovider/bft_censorship_monitor_factory.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package blocksprovider

import "github.com/hyperledger/fabric/internal/pkg/peer/orderers"

// BFTCensorshipMonitorFactory creates an instance of a BFTCensorshipMonitor. It is an implementation of the
// CensorshipDetectorFactory interface which abstracts the creation of a BFTCensorshipMonitor.
type BFTCensorshipMonitorFactory struct{}

func (f *BFTCensorshipMonitorFactory) Create(
chainID string,
verifier BlockVerifier,
requester DeliverClientRequester,
progressReporter BlockProgressReporter,
fetchSources []*orderers.Endpoint,
blockSourceIndex int,
timeoutConf TimeoutConfig,
) CensorshipDetector {
return NewBFTCensorshipMonitor(chainID, verifier, requester, progressReporter, fetchSources, blockSourceIndex, timeoutConf)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package blocksprovider_test

import (
"testing"

"github.com/hyperledger/fabric/internal/pkg/peer/blocksprovider"
"github.com/stretchr/testify/require"
)

func TestNewBFTCensorshipMonitorFactory(t *testing.T) {
s := newMonitorTestSetup(t, 5)
f := &blocksprovider.BFTCensorshipMonitorFactory{}
mon := f.Create(s.channelID, s.fakeBlockVerifier, s.fakeRequester, s.fakeProgressReporter, s.sources, 0, blocksprovider.TimeoutConfig{})
require.NotNil(t, mon)
}
Loading

0 comments on commit 5b1ac91

Please sign in to comment.