diff --git a/first-network/base/docker-compose-base.yaml b/first-network/base/docker-compose-base.yaml index 1de6d1a7dd..4c55ff9612 100644 --- a/first-network/base/docker-compose-base.yaml +++ b/first-network/base/docker-compose-base.yaml @@ -9,28 +9,14 @@ services: orderer.example.com: container_name: orderer.example.com - image: hyperledger/fabric-orderer:$IMAGE_TAG - environment: - - FABRIC_LOGGING_SPEC=INFO - - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0 - - ORDERER_GENERAL_GENESISMETHOD=file - - ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block - - ORDERER_GENERAL_LOCALMSPID=OrdererMSP - - ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp - # enabled TLS - - ORDERER_GENERAL_TLS_ENABLED=true - - ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key - - ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt - - ORDERER_GENERAL_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt] - - ORDERER_KAFKA_TOPIC_REPLICATIONFACTOR=1 - - ORDERER_KAFKA_VERBOSE=true - working_dir: /opt/gopath/src/github.com/hyperledger/fabric - command: orderer + extends: + file: peer-base.yaml + service: orderer-base volumes: - - ../channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block - - ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp:/var/hyperledger/orderer/msp - - ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/:/var/hyperledger/orderer/tls - - orderer.example.com:/var/hyperledger/production/orderer + - ../channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block + - ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp:/var/hyperledger/orderer/msp + - ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/:/var/hyperledger/orderer/tls + - orderer.example.com:/var/hyperledger/production/orderer ports: - 7050:7050 diff --git a/first-network/base/peer-base.yaml b/first-network/base/peer-base.yaml index d42e3cb3d5..6f6dd3e12c 100644 --- a/first-network/base/peer-base.yaml +++ b/first-network/base/peer-base.yaml @@ -25,3 +25,26 @@ services: - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer command: peer node start + + orderer-base: + image: hyperledger/fabric-orderer:$IMAGE_TAG + environment: + - FABRIC_LOGGING_SPEC=INFO + - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0 + - ORDERER_GENERAL_GENESISMETHOD=file + - ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block + - ORDERER_GENERAL_LOCALMSPID=OrdererMSP + - ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp + # enabled TLS + - ORDERER_GENERAL_TLS_ENABLED=true + - ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key + - ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt + - ORDERER_GENERAL_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt] + - ORDERER_KAFKA_TOPIC_REPLICATIONFACTOR=1 + - ORDERER_KAFKA_VERBOSE=true + - ORDERER_GENERAL_CLUSTER_CLIENTCERTIFICATE=/var/hyperledger/orderer/tls/server.crt + - ORDERER_GENERAL_CLUSTER_CLIENTPRIVATEKEY=/var/hyperledger/orderer/tls/server.key + - ORDERER_GENERAL_CLUSTER_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt] + working_dir: /opt/gopath/src/github.com/hyperledger/fabric + command: orderer + diff --git a/first-network/byfn.sh b/first-network/byfn.sh index 73d3b74085..965e4db07b 100755 --- a/first-network/byfn.sh +++ b/first-network/byfn.sh @@ -48,7 +48,7 @@ function printHelp() { echo " -f - specify which docker-compose file use (defaults to docker-compose-cli.yaml)" echo " -s - the database backend to use: goleveldb (default) or couchdb" echo " -l - the chaincode language: golang (default) or node" - echo " -o - the consensus-type of the ordering service: solo (default) or kafka" + echo " -o - the consensus-type of the ordering service: solo (default), kafka, or etcdraft" echo " -i - the tag to be used to launch the network (defaults to \"latest\")" echo " -v - verbose mode" echo " byfn.sh -h (print this message)" @@ -159,12 +159,16 @@ function networkUp() { if [ "${IF_COUCHDB}" == "couchdb" ]; then if [ "$CONSENSUS_TYPE" == "kafka" ]; then IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_KAFKA -f $COMPOSE_FILE_COUCH up -d 2>&1 + elif [ "$CONSENSUS_TYPE" == "etcdraft" ]; then + IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_RAFT2 -f $COMPOSE_FILE_COUCH up -d 2>&1 else IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH up -d 2>&1 fi else if [ "$CONSENSUS_TYPE" == "kafka" ]; then IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_KAFKA up -d 2>&1 + elif [ "$CONSENSUS_TYPE" == "etcdraft" ]; then + IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_RAFT2 up -d 2>&1 else IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE up -d 2>&1 fi @@ -176,10 +180,16 @@ function networkUp() { if [ "$CONSENSUS_TYPE" == "kafka" ]; then sleep 1 - echo "Sleeping 10s to allow kafka cluster to complete booting" + echo "Sleeping 10s to allow $CONSENSUS_TYPE cluster to complete booting" sleep 9 fi + if [ "$CONSENSUS_TYPE" == "etcdraft" ]; then + sleep 1 + echo "Sleeping 15s to allow $CONSENSUS_TYPE cluster to complete booting" + sleep 14 + fi + # now run the end to end script docker exec cli scripts/script.sh $CHANNEL_NAME $CLI_DELAY $LANGUAGE $CLI_TIMEOUT $VERBOSE if [ $? -ne 0 ]; then @@ -208,12 +218,16 @@ function upgradeNetwork() { if [ "${IF_COUCHDB}" == "couchdb" ]; then if [ "$CONSENSUS_TYPE" == "kafka" ]; then COMPOSE_FILES="-f $COMPOSE_FILE -f $COMPOSE_FILE_KAFKA -f $COMPOSE_FILE_COUCH" + elif [ "$CONSENSUS_TYPE" == "etcdraft" ]; then + COMPOSE_FILES="-f $COMPOSE_FILE -f $COMPOSE_FILE_RAFT2 -f $COMPOSE_FILE_COUCH" else COMPOSE_FILES="-f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH" fi else if [ "$CONSENSUS_TYPE" == "kafka" ]; then COMPOSE_FILES="-f $COMPOSE_FILE -f $COMPOSE_FILE_KAFKA" + elif [ "$CONSENSUS_TYPE" == "etcdraft" ]; then + COMPOSE_FILES="-f $COMPOSE_FILE -f $COMPOSE_FILE_RAFT2" else COMPOSE_FILES="-f $COMPOSE_FILE" fi @@ -263,7 +277,7 @@ function upgradeNetwork() { function networkDown() { # stop org3 containers also in addition to org1 and org2, in case we were running sample to add org3 # stop kafka and zookeeper containers in case we're running with kafka consensus-type - docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH -f $COMPOSE_FILE_KAFKA -f $COMPOSE_FILE_ORG3 down --volumes --remove-orphans + docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH -f $COMPOSE_FILE_KAFKA -f $COMPOSE_FILE_RAFT2 -f $COMPOSE_FILE_ORG3 down --volumes --remove-orphans # Don't remove the generated artifacts -- note, the ledgers are always removed if [ "$MODE" != "restart" ]; then @@ -413,6 +427,8 @@ function generateChannelArtifacts() { configtxgen -profile TwoOrgsOrdererGenesis -channelID byfn-sys-channel -outputBlock ./channel-artifacts/genesis.block elif [ "$CONSENSUS_TYPE" == "kafka" ]; then configtxgen -profile SampleDevModeKafka -channelID byfn-sys-channel -outputBlock ./channel-artifacts/genesis.block + elif [ "$CONSENSUS_TYPE" == "etcdraft" ]; then + configtxgen -profile SampleMultiNodeEtcdRaft -channelID byfn-sys-channel -outputBlock ./channel-artifacts/genesis.block else set +x echo "unrecognized CONSESUS_TYPE='$CONSENSUS_TYPE'. exiting" @@ -484,6 +500,8 @@ COMPOSE_FILE_COUCH=docker-compose-couch.yaml COMPOSE_FILE_ORG3=docker-compose-org3.yaml # kafka and zookeeper compose file COMPOSE_FILE_KAFKA=docker-compose-kafka.yaml +# two additional etcd/raft orderers +COMPOSE_FILE_RAFT2=docker-compose-etcdraft2.yaml # # use golang as the default language for chaincode LANGUAGE=golang @@ -540,7 +558,7 @@ while getopts "h?c:t:d:f:s:l:i:o:v" opt; do i) IMAGETAG=$(go env GOARCH)"-"$OPTARG ;; - o) + o) CONSENSUS_TYPE=$OPTARG ;; v) diff --git a/first-network/configtx.yaml b/first-network/configtx.yaml index 028614d039..a366fea253 100644 --- a/first-network/configtx.yaml +++ b/first-network/configtx.yaml @@ -359,3 +359,43 @@ Profiles: Organizations: - *Org1 - *Org2 + + SampleMultiNodeEtcdRaft: + <<: *ChannelDefaults + Capabilities: + <<: *ChannelCapabilities + Orderer: + <<: *OrdererDefaults + OrdererType: etcdraft + EtcdRaft: + Consenters: + - Host: orderer.example.com + Port: 7050 + ClientTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt + ServerTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt + - Host: orderer2.example.com + Port: 7050 + ClientTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer2.example.com/tls/server.crt + ServerTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer2.example.com/tls/server.crt + - Host: orderer3.example.com + Port: 7050 + ClientTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer3.example.com/tls/server.crt + ServerTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer3.example.com/tls/server.crt + Addresses: + - orderer.example.com:7050 + - orderer2.example.com:7050 + - orderer3.example.com:7050 + + Organizations: + - *OrdererOrg + Capabilities: + <<: *OrdererCapabilities + Application: + <<: *ApplicationDefaults + Organizations: + - <<: *OrdererOrg + Consortiums: + SampleConsortium: + Organizations: + - *Org1 + - *Org2 diff --git a/first-network/crypto-config.yaml b/first-network/crypto-config.yaml index 73b444d8cd..ffd87ffb76 100644 --- a/first-network/crypto-config.yaml +++ b/first-network/crypto-config.yaml @@ -17,6 +17,8 @@ OrdererOrgs: # --------------------------------------------------------------------------- Specs: - Hostname: orderer + - Hostname: orderer2 + - Hostname: orderer3 # --------------------------------------------------------------------------- # "PeerOrgs" - Definition of organizations managing peer nodes # --------------------------------------------------------------------------- diff --git a/first-network/docker-compose-etcdraft2.yaml b/first-network/docker-compose-etcdraft2.yaml new file mode 100644 index 0000000000..18a185aee3 --- /dev/null +++ b/first-network/docker-compose-etcdraft2.yaml @@ -0,0 +1,45 @@ +# Copyright IBM Corp. All Rights Reserved. +# +# SPDX-License-Identifier: Apache-2.0 +# + +version: '2' + +volumes: + orderer2.example.com: + orderer3.example.com: + +networks: + byfn: + +services: + + orderer2.example.com: + extends: + file: base/peer-base.yaml + service: orderer-base + container_name: orderer2.example.com + networks: + - byfn + volumes: + - ./channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block + - ./crypto-config/ordererOrganizations/example.com/orderers/orderer2.example.com/msp:/var/hyperledger/orderer/msp + - ./crypto-config/ordererOrganizations/example.com/orderers/orderer2.example.com/tls/:/var/hyperledger/orderer/tls + - orderer2.example.com:/var/hyperledger/production/orderer + ports: + - 8050:7050 + + orderer3.example.com: + extends: + file: base/peer-base.yaml + service: orderer-base + container_name: orderer3.example.com + networks: + - byfn + volumes: + - ./channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block + - ./crypto-config/ordererOrganizations/example.com/orderers/orderer3.example.com/msp:/var/hyperledger/orderer/msp + - ./crypto-config/ordererOrganizations/example.com/orderers/orderer3.example.com/tls/:/var/hyperledger/orderer/tls + - orderer3.example.com:/var/hyperledger/production/orderer + ports: + - 9050:7050 diff --git a/first-network/eyfn.sh b/first-network/eyfn.sh index c915189b36..ad2c376932 100755 --- a/first-network/eyfn.sh +++ b/first-network/eyfn.sh @@ -136,7 +136,7 @@ function networkUp () { # Tear down running network function networkDown () { - docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_KAFKA -f $COMPOSE_FILE_ORG3 -f $COMPOSE_FILE_COUCH down --volumes --remove-orphans + docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_KAFKA -f $COMPOSE_FILE_RAFT2 -f $COMPOSE_FILE_ORG3 -f $COMPOSE_FILE_COUCH down --volumes --remove-orphans # Don't remove containers, images, etc if restarting if [ "$MODE" != "restart" ]; then #Cleanup the chaincode containers @@ -247,6 +247,8 @@ COMPOSE_FILE_ORG3=docker-compose-org3.yaml COMPOSE_FILE_COUCH_ORG3=docker-compose-couch-org3.yaml # kafka and zookeeper compose file COMPOSE_FILE_KAFKA=docker-compose-kafka.yaml +# two additional etcd/raft orderers +COMPOSE_FILE_RAFT2=docker-compose-etcdraft2.yaml # use golang as the default language for chaincode LANGUAGE=golang # default image tag