From d340f62b03f696087525ec49e8b2a2e4707c424f Mon Sep 17 00:00:00 2001 From: Parameswaran Selvam Date: Tue, 31 Jan 2023 11:16:48 -0800 Subject: [PATCH] test network nano bash updated with smartbft consensus Signed-off-by: Parameswaran Selvam --- test-network-nano-bash/configtx.yaml | 129 ++++++++++++------- test-network-nano-bash/generate_artifacts.sh | 3 + test-network-nano-bash/network.sh | 24 +++- test-network-nano-bash/orderer1.sh | 10 +- test-network-nano-bash/orderer2.sh | 10 +- test-network-nano-bash/orderer3.sh | 10 +- test-network-nano-bash/orderer4.sh | 35 +++++ 7 files changed, 166 insertions(+), 55 deletions(-) create mode 100755 test-network-nano-bash/orderer4.sh diff --git a/test-network-nano-bash/configtx.yaml b/test-network-nano-bash/configtx.yaml index 0a0c05d6..98d9e8c7 100644 --- a/test-network-nano-bash/configtx.yaml +++ b/test-network-nano-bash/configtx.yaml @@ -215,52 +215,6 @@ Application: &ApplicationDefaults ################################################################################ Orderer: &OrdererDefaults - # Orderer Type: The orderer implementation to start - OrdererType: etcdraft - - EtcdRaft: - Consenters: - - Host: 127.0.0.1 - Port: 6050 - 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: 127.0.0.1 - Port: 6051 - 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: 127.0.0.1 - Port: 6052 - 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 - - # Options to be specified for all the etcd/raft nodes. The values here - # are the defaults for all new channels and can be modified on a - # per-channel basis via configuration updates. - Options: - # TickInterval is the time interval between two Node.Tick invocations. - #TickInterval: 500ms default - TickInterval: 2500ms - - # ElectionTick is the number of Node.Tick invocations that must pass - # between elections. That is, if a follower does not receive any - # message from the leader of current term before ElectionTick has - # elapsed, it will become candidate and start an election. - # ElectionTick must be greater than HeartbeatTick. - # ElectionTick: 10 default - ElectionTick: 5 - - # HeartbeatTick is the number of Node.Tick invocations that must - # pass between heartbeats. That is, a leader sends heartbeat - # messages to maintain its leadership every HeartbeatTick ticks. - HeartbeatTick: 1 - - # MaxInflightBlocks limits the max number of in-flight append messages - # during optimistic replication phase. - MaxInflightBlocks: 5 - - # SnapshotIntervalSize defines number of bytes per which a snapshot is taken - SnapshotIntervalSize: 16 MB - # Batch Timeout: The amount of time to wait before creating a batch BatchTimeout: 2s @@ -352,6 +306,27 @@ Profiles: - *OrdererOrg Capabilities: <<: *OrdererCapabilities + OrdererType: etcdraft + EtcdRaft: + Consenters: + - Host: 127.0.0.1 + Port: 6050 + 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: 127.0.0.1 + Port: 6051 + 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: 127.0.0.1 + Port: 6052 + 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 + Options: + TickInterval: 2500ms + ElectionTick: 5 + HeartbeatTick: 1 + MaxInflightBlocks: 5 + SnapshotIntervalSize: 16 MB Consortiums: SampleConsortium: Organizations: @@ -385,3 +360,65 @@ Profiles: - *Org2 Capabilities: <<: *ApplicationCapabilities + BFTTwoOrgsApplicationGenesis: + <<: *ChannelDefaults + Orderer: + <<: *OrdererDefaults + Addresses: + - 127.0.0.1:6050 + - 127.0.0.1:6051 + - 127.0.0.1:6052 + - 127.0.0.1:6053 + Organizations: + - *OrdererOrg + Capabilities: *OrdererCapabilities + OrdererType: BFT + SmartBFT: + RequestBatchMaxCount: 100 + RequestBatchMaxInterval: 50ms + RequestForwardTimeout: 2s + RequestComplainTimeout: 20s + RequestAutoRemoveTimeout: 3m0s + ViewChangeResendInterval: 5s + ViewChangeTimeout: 20s + LeaderHeartbeatTimeout: 1m0s + CollectTimeout: 1s + RequestBatchMaxBytes: 10485760 + IncomingMessageBufferSize: 200 + RequestPoolSize: 400 + LeaderHeartbeatCount: 10 + ConsenterMapping: + - ID: 1 + Host: 127.0.0.1 + Port: 6050 + MSPID: OrdererMSP + Identity: crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp/signcerts/orderer.example.com-cert.pem + 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 + - ID: 2 + Host: 127.0.0.1 + Port: 6051 + MSPID: OrdererMSP + Identity: crypto-config/ordererOrganizations/example.com/orderers/orderer2.example.com/msp/signcerts/orderer2.example.com-cert.pem + 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 + - ID: 3 + Host: 127.0.0.1 + Port: 6052 + MSPID: OrdererMSP + Identity: crypto-config/ordererOrganizations/example.com/orderers/orderer3.example.com/msp/signcerts/orderer3.example.com-cert.pem + 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 + - ID: 4 + Host: 127.0.0.1 + Port: 6053 + MSPID: OrdererMSP + Identity: crypto-config/ordererOrganizations/example.com/orderers/orderer4.example.com/msp/signcerts/orderer4.example.com-cert.pem + ClientTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer4.example.com/tls/server.crt + ServerTLSCert: crypto-config/ordererOrganizations/example.com/orderers/orderer4.example.com/tls/server.crt + Application: + <<: *ApplicationDefaults + Organizations: + - *Org1 + - *Org2 + Capabilities: *ApplicationCapabilities diff --git a/test-network-nano-bash/generate_artifacts.sh b/test-network-nano-bash/generate_artifacts.sh index 98ea91b9..1c534a57 100755 --- a/test-network-nano-bash/generate_artifacts.sh +++ b/test-network-nano-bash/generate_artifacts.sh @@ -29,3 +29,6 @@ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate channel-artifacts/O echo "Generating anchor peer update transaction for Org2" configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate channel-artifacts/Org2MSPanchors.tx -channelID mychannel -asOrg Org2MSP + +echo "Generating application channel genesis block with BFT consensus" +configtxgen -profile BFTTwoOrgsApplicationGenesis -outputBlock ./channel-artifacts/mychannel.block -channelID mychannel diff --git a/test-network-nano-bash/network.sh b/test-network-nano-bash/network.sh index fddd1125..8e148699 100755 --- a/test-network-nano-bash/network.sh +++ b/test-network-nano-bash/network.sh @@ -65,13 +65,25 @@ networkStart() { mkdir -p "${PWD}"/logs echo "Starting orderers..." - ./orderer1.sh > ./logs/orderer1.log 2>&1 & - ./orderer2.sh > ./logs/orderer2.log 2>&1 & - ./orderer3.sh > ./logs/orderer3.log 2>&1 & + ./orderer1.sh ${ORDERER_TYPE} > ./logs/orderer1.log 2>&1 & + ./orderer2.sh ${ORDERER_TYPE} > ./logs/orderer2.log 2>&1 & + ./orderer3.sh ${ORDERER_TYPE} > ./logs/orderer3.log 2>&1 & +if [ "$ORDERER_TYPE" = "smartbft" ]; then + ./orderer4.sh ${ORDERER_TYPE} > ./logs/orderer4.log 2>&1 & +fi echo "Waiting ${CLI_DELAY}s..." sleep ${CLI_DELAY} + if [ "$ORDERER_TYPE" = "smartbft" ]; then + ../bin/osnadmin channel join --channelID mychannel --config-block ./channel-artifacts/mychannel.block -o localhost:9443 + ../bin/osnadmin channel join --channelID mychannel --config-block ./channel-artifacts/mychannel.block -o localhost:9444 + ../bin/osnadmin channel join --channelID mychannel --config-block ./channel-artifacts/mychannel.block -o localhost:9445 + ../bin/osnadmin channel join --channelID mychannel --config-block ./channel-artifacts/mychannel.block -o localhost:9446 + echo "smartbft orderers cluster should be up now..." + wait + fi + echo "Starting peers..." ./peer1.sh > ./logs/peer1.log 2>&1 & ./peer2.sh > ./logs/peer2.log 2>&1 & @@ -119,6 +131,8 @@ else shift fi +ORDERER_TYPE="etcdraft" + # parse flags while [ $# -ge 1 ] ; do key="$1" @@ -127,6 +141,10 @@ while [ $# -ge 1 ] ; do CLI_DELAY="$2" shift ;; + -c ) + ORDERER_TYPE="$2" + shift + ;; -h ) printHelp "$MODE" exit 0 diff --git a/test-network-nano-bash/orderer1.sh b/test-network-nano-bash/orderer1.sh index 2ab10b17..b4adb7ce 100755 --- a/test-network-nano-bash/orderer1.sh +++ b/test-network-nano-bash/orderer1.sh @@ -17,8 +17,14 @@ export ORDERER_GENERAL_TLS_PRIVATEKEY="${PWD}"/crypto-config/ordererOrganization export ORDERER_GENERAL_TLS_CERTIFICATE="${PWD}"/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt # following setting is not really needed at runtime since channel config has ca root certs, but we need to override the default in orderer.yaml export ORDERER_GENERAL_TLS_ROOTCAS="${PWD}"/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt -export ORDERER_GENERAL_BOOTSTRAPMETHOD=file -export ORDERER_GENERAL_BOOTSTRAPFILE="${PWD}"/channel-artifacts/genesis.block +if [ $# -gt 0 ] && [ "$1" = "smartbft" ] +then + export ORDERER_GENERAL_BOOTSTRAPMETHOD=none + export ORDERER_CHANNELPARTICIPATION_ENABLED=true +else + export ORDERER_GENERAL_BOOTSTRAPMETHOD=file + export ORDERER_GENERAL_BOOTSTRAPFILE="${PWD}"/channel-artifacts/genesis.block +fi export ORDERER_FILELEDGER_LOCATION="${PWD}"/data/orderer export ORDERER_CONSENSUS_WALDIR="${PWD}"/data/orderer/etcdraft/wal export ORDERER_CONSENSUS_SNAPDIR="${PWD}"/data/orderer/etcdraft/wal diff --git a/test-network-nano-bash/orderer2.sh b/test-network-nano-bash/orderer2.sh index 267c924a..24932c24 100755 --- a/test-network-nano-bash/orderer2.sh +++ b/test-network-nano-bash/orderer2.sh @@ -17,8 +17,14 @@ export ORDERER_GENERAL_TLS_PRIVATEKEY="${PWD}"/crypto-config/ordererOrganization export ORDERER_GENERAL_TLS_CERTIFICATE="${PWD}"/crypto-config/ordererOrganizations/example.com/orderers/orderer2.example.com/tls/server.crt # following setting is not really needed at runtime since channel config has ca root certs, but we need to override the default in orderer.yaml export ORDERER_GENERAL_TLS_ROOTCAS="${PWD}"/crypto-config/ordererOrganizations/example.com/orderers/orderer2.example.com/tls/ca.crt -export ORDERER_GENERAL_BOOTSTRAPMETHOD=file -export ORDERER_GENERAL_BOOTSTRAPFILE="${PWD}"/channel-artifacts/genesis.block +if [ $# -gt 0 ] && [ "$1" = "smartbft" ] +then + export ORDERER_GENERAL_BOOTSTRAPMETHOD=none + export ORDERER_CHANNELPARTICIPATION_ENABLED=true +else + export ORDERER_GENERAL_BOOTSTRAPMETHOD=file + export ORDERER_GENERAL_BOOTSTRAPFILE="${PWD}"/channel-artifacts/genesis.block +fi export ORDERER_FILELEDGER_LOCATION="${PWD}"/data/orderer2 export ORDERER_CONSENSUS_WALDIR="${PWD}"/data/orderer2/etcdraft/wal export ORDERER_CONSENSUS_SNAPDIR="${PWD}"/data/orderer2/etcdraft/wal diff --git a/test-network-nano-bash/orderer3.sh b/test-network-nano-bash/orderer3.sh index c5a55f7a..74ab828c 100755 --- a/test-network-nano-bash/orderer3.sh +++ b/test-network-nano-bash/orderer3.sh @@ -17,8 +17,14 @@ export ORDERER_GENERAL_TLS_PRIVATEKEY="${PWD}"/crypto-config/ordererOrganization export ORDERER_GENERAL_TLS_CERTIFICATE="${PWD}"/crypto-config/ordererOrganizations/example.com/orderers/orderer3.example.com/tls/server.crt # following setting is not really needed at runtime since channel config has ca root certs, but we need to override the default in orderer.yaml export ORDERER_GENERAL_TLS_ROOTCAS="${PWD}"/crypto-config/ordererOrganizations/example.com/orderers/orderer3.example.com/tls/ca.crt -export ORDERER_GENERAL_BOOTSTRAPMETHOD=file -export ORDERER_GENERAL_BOOTSTRAPFILE="${PWD}"/channel-artifacts/genesis.block +if [ $# -gt 0 ] && [ "$1" = "smartbft" ] +then + export ORDERER_GENERAL_BOOTSTRAPMETHOD=none + export ORDERER_CHANNELPARTICIPATION_ENABLED=true +else + export ORDERER_GENERAL_BOOTSTRAPMETHOD=file + export ORDERER_GENERAL_BOOTSTRAPFILE="${PWD}"/channel-artifacts/genesis.block +fi export ORDERER_FILELEDGER_LOCATION="${PWD}"/data/orderer3 export ORDERER_CONSENSUS_WALDIR="${PWD}"/data/orderer3/etcdraft/wal export ORDERER_CONSENSUS_SNAPDIR="${PWD}"/data/orderer3/etcdraft/wal diff --git a/test-network-nano-bash/orderer4.sh b/test-network-nano-bash/orderer4.sh new file mode 100755 index 00000000..00724a98 --- /dev/null +++ b/test-network-nano-bash/orderer4.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env sh +# +# SPDX-License-Identifier: Apache-2.0 +# +set -eu + +# look for binaries in local dev environment /build/bin directory and then in local samples /bin directory +export PATH="${PWD}"/../../fabric/build/bin:"${PWD}"/../bin:"$PATH" +export FABRIC_CFG_PATH="${PWD}"/../config + +export FABRIC_LOGGING_SPEC=debug:cauthdsl,policies,msp,common.configtx,common.channelconfig=info +export ORDERER_GENERAL_LISTENPORT=6053 +export ORDERER_GENERAL_LOCALMSPID=OrdererMSP +export ORDERER_GENERAL_LOCALMSPDIR="${PWD}"/crypto-config/ordererOrganizations/example.com/orderers/orderer4.example.com/msp +export ORDERER_GENERAL_TLS_ENABLED=true +export ORDERER_GENERAL_TLS_PRIVATEKEY="${PWD}"/crypto-config/ordererOrganizations/example.com/orderers/orderer4.example.com/tls/server.key +export ORDERER_GENERAL_TLS_CERTIFICATE="${PWD}"/crypto-config/ordererOrganizations/example.com/orderers/orderer4.example.com/tls/server.crt +# following setting is not really needed at runtime since channel config has ca root certs, but we need to override the default in orderer.yaml +export ORDERER_GENERAL_TLS_ROOTCAS="${PWD}"/crypto-config/ordererOrganizations/example.com/orderers/orderer4.example.com/tls/ca.crt +if [ $# -gt 0 ] && [ "$1" = "smartbft" ] +then + export ORDERER_GENERAL_BOOTSTRAPMETHOD=none + export ORDERER_CHANNELPARTICIPATION_ENABLED=true +else + export ORDERER_GENERAL_BOOTSTRAPMETHOD=file + export ORDERER_GENERAL_BOOTSTRAPFILE="${PWD}"/channel-artifacts/genesis.block +fi +export ORDERER_FILELEDGER_LOCATION="${PWD}"/data/orderer4 +export ORDERER_CONSENSUS_WALDIR="${PWD}"/data/orderer4/etcdraft/wal +export ORDERER_CONSENSUS_SNAPDIR="${PWD}"/data/orderer4/etcdraft/wal +export ORDERER_OPERATIONS_LISTENADDRESS=127.0.0.1:8446 +export ORDERER_ADMIN_LISTENADDRESS=127.0.0.1:9446 + +# start orderer +orderer