Plugable consensus PBFT for hyperledger/fabric
Fabric | Tests | Date |
---|---|---|
9bf243e | pass | Nov 28, 2017 |
go get -u github.com/amamina/chari
-
Add PBFT consenters into orderer, modify fabric/orderer/main.go
import
"github.com/amamina/chari"
add
consenters["pbft"] = chari.New()
afterconsenters["solo"] = solo.New() consenters["kafka"] = kafka.New(conf.Kafka.TLS, conf.Kafka.Retry, conf.Kafka.Version)
-
Support pbft in configtx.yaml, modify fabric/common/configtx/tool/provisional/provisional.go
add
ConsensusTypePBFT = "pbft"
after// ConsensusTypeSolo identifies the solo consensus implementation. ConsensusTypeSolo = "solo" // ConsensusTypeKafka identifies the Kafka-based consensus implementation. ConsensusTypeKafka = "kafka"
add
case ConsensusTypePBFT: //do nothing
afterswitch conf.Orderer.OrdererType { case ConsensusTypeSolo: case ConsensusTypeKafka: bs.ordererGroups = append(bs.ordererGroups, config.TemplateKafkaBrokers(conf.Orderer.Kafka.Brokers))
-
Change consensus to PBFT in configtx.yaml
OrdererType: pbft
-
Make docker image hyperledger/fabric-orderer Cause we have modify fabric/orderer/main.go, a new image hyperledger/fabric-orderer should be remake. There is a script to in chari/make, cd chari/make and $>make, it will auto to make image hyperledger/fabric-orderer:latest.
-
Configuration files Chari depends on tendermint, for provide some configuration files to startup tendermint, a tool called charigen in chari/charigen which will auto create configuration files.
Notice: charigen should be in the same dir of configtxgen and cryptogen.
-
Startup Orderer Chari supports PBFT instead of Kafka in orderer, so Kakfa no needs. Now, orderers must meet 3F +1, and additional configurations likes below should be added to orderer shell.
-p 3450:3450 \
-e BFT_P2P_PORT=3450 \
-e BFT_P2P_SEEDS=192.168.110.128:3450,192.168.110.128:3451,192.168.110.128:3452,192.168.110.128:3453 \
-v /etc/hyperledger/crypto-config/chari0:/etc/hyperledger/chari \
-v /etc/hyperledger/channel-artifacts/chari.genesis.json:/etc/hyperledger/chari/genesis.json \
The current version, when orderer shutdown and restart, the one will be ejected by other orderers, cause the missing blocks during down time will re-execute after orderer restart, this operation will be regarded as do evil by other orderers. To avoid this issue, the down orderer should delete and re-startup but not restart. In the next version will fix this issue.