Skip to content

Commit 653675c

Browse files
committed
[FAB-13150] Re-enable etcdraft for v2.0 development
This change set re-enables etcdraft to resume v2.0 development after v1.4 branch is cut. Change-Id: I384247a9de2763a207bbde4fa8e519d703241ad5 Signed-off-by: yacovm <yacovm@il.ibm.com>
1 parent eb990d8 commit 653675c

File tree

6 files changed

+113
-10
lines changed

6 files changed

+113
-10
lines changed

common/tools/configtxgen/encoder/encoder_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ func TestNewOrdererGroup(t *testing.T) {
256256
})
257257

258258
t.Run("etcd/raft-based Orderer", func(t *testing.T) {
259-
t.Skip()
260259
config := configtxgentest.Load(genesisconfig.SampleDevModeEtcdRaftProfile)
261260
group, _ := NewOrdererGroup(config.Orderer)
262261
consensusType := group.GetValues()[channelconfig.ConsensusTypeKey]

integration/e2e/cft_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"github.com/tedsuo/ifrit/grouper"
2626
)
2727

28-
var _ = PDescribe("EndToEnd Crash Fault Tolerance", func() {
28+
var _ = Describe("EndToEnd Crash Fault Tolerance", func() {
2929
var (
3030
testDir string
3131
client *docker.Client

integration/e2e/e2e_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ var _ = Describe("EndToEnd", func() {
151151
})
152152
})
153153

154-
PDescribe("basic single node etcdraft network with 2 orgs", func() {
154+
Describe("basic single node etcdraft network with 2 orgs", func() {
155155
BeforeEach(func() {
156156
network = nwo.New(nwo.BasicEtcdRaft(), testDir, client, BasePort(), components)
157157
network.GenerateConfigTree()
@@ -172,7 +172,7 @@ var _ = Describe("EndToEnd", func() {
172172
})
173173
})
174174

175-
PDescribe("three node etcdraft network with 2 orgs", func() {
175+
Describe("three node etcdraft network with 2 orgs", func() {
176176
BeforeEach(func() {
177177
network = nwo.New(nwo.MultiNodeEtcdRaft(), testDir, client, BasePort(), components)
178178
network.GenerateConfigTree()
@@ -250,7 +250,7 @@ var _ = Describe("EndToEnd", func() {
250250
})
251251
})
252252

253-
PDescribe("etcd raft, checking valid configuration update of type B", func() {
253+
Describe("etcd raft, checking valid configuration update of type B", func() {
254254
BeforeEach(func() {
255255
network = nwo.New(nwo.BasicEtcdRaft(), testDir, client, BasePort(), components)
256256
network.GenerateConfigTree()
@@ -299,7 +299,7 @@ var _ = Describe("EndToEnd", func() {
299299
})
300300
})
301301

302-
PDescribe("basic single node etcdraft network with 2 orgs and 2 channels", func() {
302+
Describe("basic single node etcdraft network with 2 orgs and 2 channels", func() {
303303
BeforeEach(func() {
304304
network = nwo.New(nwo.MultiChannelEtcdRaft(), testDir, client, BasePort(), components)
305305
network.GenerateConfigTree()

orderer/common/server/etcdraft_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
)
2222

2323
func TestSpawnEtcdRaft(t *testing.T) {
24-
t.Skip()
2524
gt := NewGomegaWithT(t)
2625

2726
cwd, err := filepath.Abs(".")

orderer/common/server/main.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"syscall"
2020
"time"
2121

22+
"github.com/golang/protobuf/proto"
2223
"github.com/hyperledger/fabric/common/channelconfig"
2324
"github.com/hyperledger/fabric/common/crypto"
2425
"github.com/hyperledger/fabric/common/flogging"
@@ -353,8 +354,24 @@ func initializeBootstrapChannel(genesisBlock *cb.Block, lf blockledger.Factory)
353354
}
354355
}
355356

356-
func isClusterType(_ *cb.Block) bool {
357-
return false
357+
func isClusterType(genesisBlock *cb.Block) bool {
358+
if genesisBlock.Data == nil || len(genesisBlock.Data.Data) == 0 {
359+
logger.Fatalf("Empty genesis block")
360+
}
361+
env := &cb.Envelope{}
362+
if err := proto.Unmarshal(genesisBlock.Data.Data[0], env); err != nil {
363+
logger.Fatalf("Failed to unmarshal the genesis block's envelope: %v", err)
364+
}
365+
bundle, err := channelconfig.NewBundleFromEnvelope(env)
366+
if err != nil {
367+
logger.Fatalf("Failed creating bundle from the genesis block: %v", err)
368+
}
369+
ordConf, exists := bundle.OrdererConfig()
370+
if !exists {
371+
logger.Fatalf("Orderer config doesn't exist in bundle derived from genesis block")
372+
}
373+
_, exists = clusterTypes[ordConf.ConsensusType()]
374+
return exists
358375
}
359376

360377
func initializeGrpcServer(conf *localconfig.TopLevel, serverConfig comm.ServerConfig) *comm.GRPCServer {

sampleconfig/configtx.yaml

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,61 @@ Orderer: &OrdererDefaults
287287
- kafka1:9092
288288
- kafka2:9092
289289

290+
# EtcdRaft defines configuration which must be set when the "etcdraft"
291+
# orderertype is chosen.
292+
EtcdRaft:
293+
# The set of Raft replicas for this network. For the etcd/raft-based
294+
# implementation, we expect every replica to also be an OSN. Therefore,
295+
# a subset of the host:port items enumerated in this list should be
296+
# replicated under the Orderer.Addresses key above.
297+
Consenters:
298+
- Host: raft0.example.com
299+
Port: 7050
300+
ClientTLSCert: path/to/ClientTLSCert0
301+
ServerTLSCert: path/to/ServerTLSCert0
302+
- Host: raft1.example.com
303+
Port: 7050
304+
ClientTLSCert: path/to/ClientTLSCert1
305+
ServerTLSCert: path/to/ServerTLSCert1
306+
- Host: raft2.example.com
307+
Port: 7050
308+
ClientTLSCert: path/to/ClientTLSCert2
309+
ServerTLSCert: path/to/ServerTLSCert2
310+
311+
# Options to be specified for all the etcd/raft nodes. The values here
312+
# are the defaults for all new channels and can be modified on a
313+
# per-channel basis via configuration updates.
314+
Options:
315+
# TickInterval is the time interval between two Node.Tick
316+
# invocations.
317+
# Unit: millisecond
318+
TickInterval: 100
319+
320+
# ElectionTick is the number of Node.Tick invocations that must pass
321+
# between elections. That is, if a follower does not receive any
322+
# message from the leader of current term before ElectionTick has
323+
# elapsed, it will become candidate and start an election.
324+
# ElectionTick must be greater than HeartbeatTick.
325+
ElectionTick: 10
326+
327+
# HeartbeatTick is the number of Node.Tick invocations that must
328+
# pass between heartbeats. That is, a leader sends heartbeat
329+
# messages to maintain its leadership every HeartbeatTick ticks.
330+
HeartbeatTick: 1
331+
332+
# MaxInflightMsgs limits the max number of in-flight append messages
333+
# during optimistic replication phase.
334+
MaxInflightMsgs: 256
335+
336+
# MaxSizePerMsg limits the max size of each append message. Smaller
337+
# value lowers the raft recovery cost(initial probing and message
338+
# lost during normal operation). On the other side, it might affect
339+
# the throughput during normal replication.
340+
MaxSizePerMsg: 1048576
341+
342+
# SnapshotInterval defines number of blocks per which a snapshot is taken
343+
SnapshotInterval: 500
344+
290345
# Organizations lists the orgs participating on the orderer side of the
291346
# network.
292347
Organizations:
@@ -491,4 +546,37 @@ Profiles:
491546
Application:
492547
<<: *ApplicationDefaults
493548
Organizations:
494-
- *SampleOrg
549+
- *SampleOrg
550+
551+
# SampleDevModeEtcdRaft defines a configuration that differs from the
552+
# SampleDevModeSolo one only in that it uses the etcd/raft-based orderer.
553+
SampleDevModeEtcdRaft:
554+
<<: *ChannelDefaults
555+
Orderer:
556+
<<: *OrdererDefaults
557+
OrdererType: etcdraft
558+
Organizations:
559+
- <<: *SampleOrg
560+
Policies:
561+
<<: *SampleOrgPolicies
562+
Admins:
563+
Type: Signature
564+
Rule: "OR('SampleOrg.member')"
565+
Application:
566+
<<: *ApplicationDefaults
567+
Organizations:
568+
- <<: *SampleOrg
569+
Policies:
570+
<<: *SampleOrgPolicies
571+
Admins:
572+
Type: Signature
573+
Rule: "OR('SampleOrg.member')"
574+
Consortiums:
575+
SampleConsortium:
576+
Organizations:
577+
- <<: *SampleOrg
578+
Policies:
579+
<<: *SampleOrgPolicies
580+
Admins:
581+
Type: Signature
582+
Rule: "OR('SampleOrg.member')"

0 commit comments

Comments
 (0)