Skip to content

Commit

Permalink
Integrate BFTSynchronizer
Browse files Browse the repository at this point in the history
Signed-off-by: Yoav Tock <tock@il.ibm.com>
Change-Id: I20182b39eafeb5465fb37d1248cdb70b025dc55c
  • Loading branch information
tock-ibm committed Feb 22, 2024
1 parent 0fc8c4c commit 76fbeac
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
3 changes: 2 additions & 1 deletion orderer/common/localconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ func (c *TopLevel) completeInitialization(configDir string) {
c.General.Cluster.ReplicationRetryTimeout = Defaults.General.Cluster.ReplicationRetryTimeout
case c.General.Cluster.CertExpirationWarningThreshold == 0:
c.General.Cluster.CertExpirationWarningThreshold = Defaults.General.Cluster.CertExpirationWarningThreshold
case c.General.Cluster.ReplicationPolicy == "":
case (c.General.Cluster.ReplicationPolicy != "simple") && (c.General.Cluster.ReplicationPolicy != "consensus"):
logger.Infof("General.Cluster.ReplicationPolicy is `%s`, setting to `%s`", c.General.Cluster.ReplicationPolicy, Defaults.General.Cluster.ReplicationPolicy)
c.General.Cluster.ReplicationPolicy = Defaults.General.Cluster.ReplicationPolicy

case c.General.Profile.Enabled && c.General.Profile.Address == "":
Expand Down
24 changes: 12 additions & 12 deletions orderer/consensus/smartbft/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,21 +212,22 @@ func bftSmartConsensusBuild(
var sync api.Synchronizer
switch c.localConfigCluster.ReplicationPolicy {
case "consensus":
sync = &Synchronizer{ // TODO make bft-synchronizer
selfID: rtc.id,
sync = &BFTSynchronizer{
selfID: rtc.id,
LatestConfig: func() (types.Configuration, []uint64) {
rtc := c.RuntimeConfig.Load().(RuntimeConfig)
return rtc.BFTConfig, rtc.Nodes
},
BlockToDecision: c.blockToDecision,
OnCommit: func(block *cb.Block) types.Reconfig {
c.pruneCommittedRequests(block)
return c.updateRuntimeConfig(block)
},
Support: c.support,
BlockPuller: c.BlockPuller,
ClusterSize: clusterSize,
Logger: c.Logger,
LatestConfig: func() (types.Configuration, []uint64) {
rtc := c.RuntimeConfig.Load().(RuntimeConfig)
return rtc.BFTConfig, rtc.Nodes
},
Support: c.support,
CryptoProvider: c.bccsp,
clusterDialer: c.clusterDialer,
localConfigCluster: c.localConfigCluster,
Logger: c.Logger,
}
case "simple":
sync = &Synchronizer{
Expand All @@ -238,7 +239,6 @@ func bftSmartConsensusBuild(
},
Support: c.support,
BlockPuller: c.BlockPuller,

ClusterSize: clusterSize, // TODO this must be dynamic as the cluster may change in size
Logger: c.Logger,
LatestConfig: func() (types.Configuration, []uint64) {
Expand All @@ -247,7 +247,7 @@ func bftSmartConsensusBuild(
},
}
default:

c.Logger.Panicf("unsupported ReplicationPolicy: %s", c.localConfigCluster.ReplicationPolicy)
}

channelDecorator := zap.String("channel", c.support.ChannelID())
Expand Down
2 changes: 2 additions & 0 deletions orderer/consensus/smartbft/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ func newBlockPuller(
Dialer: stdDialer,
}

logger.Infof("Built new block puller with cluster config: %+v, endpoints: %+v", clusterConfig, endpoints)

return bp, nil
}

Expand Down

0 comments on commit 76fbeac

Please sign in to comment.