Skip to content

Commit 7e9de68

Browse files
committed
[FAB-1844] Move common SBFT config parameters
https://jira.hyperledger.org/browse/FAB-1844 There are SBFT config parameters that are shared between replicas. These were moved to the Genesis block of the config. Change-Id: I2b72d3977f20aaccc9996aedafee214a39c0cdfe Signed-off-by: Gabor Hosszu <[email protected]>
1 parent a429da3 commit 7e9de68

File tree

4 files changed

+57
-53
lines changed

4 files changed

+57
-53
lines changed

orderer/localconfig/config.go

+23-22
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ type Genesis struct {
6767
OrdererType string
6868
BatchTimeout time.Duration
6969
BatchSize BatchSize
70+
SbftShared SbftShared
7071
}
7172

7273
// BatchSize contains configuration affecting the size of batches
@@ -101,16 +102,18 @@ type Kafka struct {
101102
Version sarama.KafkaVersion
102103
}
103104

104-
// Sbft contains config for the SBFT orderer
105-
type Sbft struct {
106-
PeerCommAddr string
107-
CertFile string
108-
KeyFile string
109-
DataDir string
105+
// SbftLocal contains config for the SBFT peer/replica
106+
type SbftLocal struct {
107+
PeerCommAddr string
108+
CertFile string
109+
KeyFile string
110+
DataDir string
111+
}
112+
113+
// SbftShared contains config for the SBFT network
114+
type SbftShared struct {
110115
N uint64
111116
F uint64
112-
BatchDurationNsec uint64
113-
BatchSizeBytes uint64
114117
RequestTimeoutNsec uint64
115118
Peers map[string]string // Address to Cert mapping
116119
}
@@ -132,7 +135,7 @@ type TopLevel struct {
132135
FileLedger FileLedger
133136
Kafka Kafka
134137
Genesis Genesis
135-
Sbft Sbft
138+
SbftLocal SbftLocal
136139
}
137140

138141
var defaults = TopLevel{
@@ -175,20 +178,18 @@ var defaults = TopLevel{
175178
AbsoluteMaxBytes: 100000000,
176179
PreferredMaxBytes: 512 * 1024,
177180
},
181+
SbftShared: SbftShared{
182+
N: 1,
183+
F: 0,
184+
RequestTimeoutNsec: uint64(time.Second.Nanoseconds()),
185+
Peers: map[string]string{":6101": "sbft/testdata/cert1.pem"},
186+
},
178187
},
179-
// TODO move the appropriate parts to Genesis
180-
// and use BatchSizeMaxBytes
181-
Sbft: Sbft{
182-
PeerCommAddr: ":6101",
183-
CertFile: "sbft/testdata/cert1.pem",
184-
KeyFile: "sbft/testdata/key.pem",
185-
DataDir: "/tmp",
186-
N: 1,
187-
F: 0,
188-
BatchDurationNsec: 1000,
189-
BatchSizeBytes: 1000000000,
190-
RequestTimeoutNsec: 1000000000,
191-
Peers: map[string]string{":6101": "sbft/testdata/cert1.pem"},
188+
SbftLocal: SbftLocal{
189+
PeerCommAddr: ":6101",
190+
CertFile: "sbft/testdata/cert1.pem",
191+
KeyFile: "sbft/testdata/key.pem",
192+
DataDir: "/tmp",
192193
},
193194
}
194195

orderer/main.go

+9-8
Original file line numberDiff line numberDiff line change
@@ -164,19 +164,20 @@ func main() {
164164
}
165165

166166
func makeSbftConsensusConfig(conf *config.TopLevel) *sbft.ConsensusConfig {
167-
cfg := simplebft.Config{N: conf.Sbft.N, F: conf.Sbft.F, BatchDurationNsec: conf.Sbft.BatchDurationNsec,
168-
BatchSizeBytes: conf.Sbft.BatchSizeBytes,
169-
RequestTimeoutNsec: conf.Sbft.RequestTimeoutNsec}
167+
cfg := simplebft.Config{N: conf.Genesis.SbftShared.N, F: conf.Genesis.SbftShared.F,
168+
BatchDurationNsec: uint64(conf.Genesis.BatchTimeout),
169+
BatchSizeBytes: uint64(conf.Genesis.BatchSize.AbsoluteMaxBytes),
170+
RequestTimeoutNsec: conf.Genesis.SbftShared.RequestTimeoutNsec}
170171
peers := make(map[string][]byte)
171-
for addr, cert := range conf.Sbft.Peers {
172+
for addr, cert := range conf.Genesis.SbftShared.Peers {
172173
peers[addr], _ = sbftcrypto.ParseCertPEM(cert)
173174
}
174175
return &sbft.ConsensusConfig{Consensus: &cfg, Peers: peers}
175176
}
176177

177178
func makeSbftStackConfig(conf *config.TopLevel) *backend.StackConfig {
178-
return &backend.StackConfig{ListenAddr: conf.Sbft.PeerCommAddr,
179-
CertFile: conf.Sbft.CertFile,
180-
KeyFile: conf.Sbft.KeyFile,
181-
DataDir: conf.Sbft.DataDir}
179+
return &backend.StackConfig{ListenAddr: conf.SbftLocal.PeerCommAddr,
180+
CertFile: conf.SbftLocal.CertFile,
181+
KeyFile: conf.SbftLocal.KeyFile,
182+
DataDir: conf.SbftLocal.DataDir}
182183
}

orderer/network_test.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -305,19 +305,19 @@ func generateConfigEnv(peerNum uint64, grpcPort int, peerCommPort string, certFi
305305
panicOnError(err)
306306
envs := []string{}
307307
envs = append(envs, fmt.Sprintf("ORDERER_CFG_PATH=%s", ordererDir))
308-
envs = append(envs, fmt.Sprintf("ORDERER_GENESIS_ORDERERTYPE=%s", "sbft"))
309308
envs = append(envs, fmt.Sprintf("ORDERER_GENERAL_LISTENPORT=%d", grpcPort))
310-
envs = append(envs, fmt.Sprintf("ORDERER_SBFT_PEERCOMMADDR=%s", peerCommPort))
311-
envs = append(envs, fmt.Sprintf("ORDERER_SBFT_CERTFILE=%s", certFile))
312-
envs = append(envs, fmt.Sprintf("ORDERER_SBFT_KEYFILE=%s", keyfile))
313-
envs = append(envs, fmt.Sprintf("ORDERER_SBFT_DATADIR=%s", tempDir))
314-
envs = append(envs, fmt.Sprintf("ORDERER_SBFT_BATCHDURATIONNSEC=%d", 1000))
315-
envs = append(envs, fmt.Sprintf("ORDERER_SBFT_BATCHSIZEBYTES=%d", 1000000000))
316-
envs = append(envs, fmt.Sprintf("ORDERER_SBFT_REQUESTTIMEOUTNSEC=%d", 1000000000))
317-
envs = append(envs, fmt.Sprintf("ORDERER_SBFT_N=%d", peerNum))
318-
envs = append(envs, fmt.Sprintf("ORDERER_SBFT_F=%d", (peerNum-1)/3))
309+
envs = append(envs, fmt.Sprintf("ORDERER_GENESIS_ORDERERTYPE=%s", "sbft"))
310+
envs = append(envs, fmt.Sprintf("ORDERER_GENESIS_BATCHTIMEOUT=%d", 1000))
311+
envs = append(envs, fmt.Sprintf("ORDERER_GENESIS_BATCHSIZE_ABSOLUTEMAXBYTES=%d", 1000000000))
312+
envs = append(envs, fmt.Sprintf("ORDERER_GENESIS_SBFTSHARED_REQUESTTIMEOUTNSEC=%d", 1000000000))
313+
envs = append(envs, fmt.Sprintf("ORDERER_GENESIS_SBFTSHARED_N=%d", peerNum))
314+
envs = append(envs, fmt.Sprintf("ORDERER_GENESIS_SBFTSHARED_F=%d", (peerNum-1)/3))
319315
js, _ := json.Marshal(peersWithCerts)
320-
envs = append(envs, fmt.Sprintf("ORDERER_SBFT_PEERS=%s", js))
316+
envs = append(envs, fmt.Sprintf("ORDERER_GENESIS_SBFTSHARED_PEERS=%s", js))
317+
envs = append(envs, fmt.Sprintf("ORDERER_SBFTLOCAL_PEERCOMMADDR=%s", peerCommPort))
318+
envs = append(envs, fmt.Sprintf("ORDERER_SBFTLOCAL_CERTFILE=%s", certFile))
319+
envs = append(envs, fmt.Sprintf("ORDERER_SBFTLOCAL_KEYFILE=%s", keyfile))
320+
envs = append(envs, fmt.Sprintf("ORDERER_SBFTLOCAL_DATADIR=%s", tempDir))
321321
return envs
322322
}
323323

orderer/orderer.yaml

+14-12
Original file line numberDiff line numberDiff line change
@@ -116,28 +116,18 @@ Kafka:
116116

117117
################################################################################
118118
#
119-
# SECTION: Sbft
119+
# SECTION: Sbft local
120120
#
121121
# - This section applies to the configuration of the Sbft-backed orderer
122122
#
123123
################################################################################
124-
Sbft:
124+
SbftLocal:
125125
# Address to use for SBFT internal communication
126126
PeerCommAddr: ":6101"
127127
CertFile: "sbft/testdata/cert1.pem"
128128
KeyFile: "sbft/testdata/key.pem"
129129
# Directory for SBFT data (persistence)
130130
DataDir: "/tmp"
131-
# Number of peers
132-
"N": 1
133-
# Fault tolerance
134-
F: 0
135-
BatchDurationNsec: 1000
136-
BatchSizeBytes: 1000000000
137-
RequestTimeoutNsec: 1000000000
138-
# Peers (PeerCommAddr) with the path of their cert
139-
Peers:
140-
":6101": "sbft/testdata/cert1.pem"
141131

142132
################################################################################
143133
#
@@ -169,3 +159,15 @@ Genesis:
169159
# the serialized messages in a batch. A message larger than the preferred
170160
# max bytes will result in a batch larger than preferred max bytes.
171161
PreferredMaxBytes: 512 KB
162+
163+
# Defines the SBFT parameters when 'sbft' is specified as the 'OrdererType'
164+
SbftShared:
165+
# Number of peers
166+
"N": 1
167+
# Fault tolerance
168+
F: 0
169+
# Timeout of requests (seconds)
170+
RequestTimeoutNsec: 1000000000
171+
# Peers (PeerCommAddr) with the path of their cert
172+
Peers:
173+
":6101": "sbft/testdata/cert1.pem"

0 commit comments

Comments
 (0)