From 81390fbbbfb3e1ba2757cb7cce6b723ff65acfb8 Mon Sep 17 00:00:00 2001 From: Arkadi Piven Date: Tue, 9 May 2023 17:06:29 +0300 Subject: [PATCH] Fix nano-bash-bft sample to work with channel-participation. remove dependency on deprecated system-channel. Signed-off-by: Arkadi Piven Signed-off-by: arkadipiven --- test-network-nano-bash/README.md | 27 +- .../bft-config/configtx.yaml | 320 +++++++++++ .../chaincode_interaction.sh | 16 + test-network-nano-bash/configtx.yaml | 539 ++++++++---------- test-network-nano-bash/create_channel.sh | 12 - test-network-nano-bash/generate_artifacts.sh | 19 +- .../install&approve&commit_chaincode_peer1.sh | 22 + test-network-nano-bash/join_orderers.sh | 28 + test-network-nano-bash/network.sh | 37 +- test-network-nano-bash/orderer1.sh | 17 +- test-network-nano-bash/orderer2.sh | 17 +- test-network-nano-bash/orderer3.sh | 17 +- test-network-nano-bash/orderer4.sh | 38 ++ 13 files changed, 742 insertions(+), 367 deletions(-) create mode 100644 test-network-nano-bash/bft-config/configtx.yaml create mode 100755 test-network-nano-bash/chaincode_interaction.sh delete mode 100755 test-network-nano-bash/create_channel.sh create mode 100755 test-network-nano-bash/install&approve&commit_chaincode_peer1.sh create mode 100755 test-network-nano-bash/join_orderers.sh create mode 100755 test-network-nano-bash/orderer4.sh diff --git a/test-network-nano-bash/README.md b/test-network-nano-bash/README.md index 67216ae4..2095d9be 100644 --- a/test-network-nano-bash/README.md +++ b/test-network-nano-bash/README.md @@ -39,11 +39,10 @@ yq -i 'del(.chaincode.externalBuilders) | .chaincode.externalBuilders[0].name = ``` # Instructions for starting network - ## Running each component separately -Open terminal windows for 3 ordering nodes, 4 peer nodes, and 4 peer admins as seen in the following terminal setup. The first two peers and peer admins belong to Org1, the latter two peer and peer admins belong to Org2. -Note, you can start with two ordering nodes and a single Org1 peer node and single Org1 peer admin terminal if you would like to keep things even more minimal (two ordering nodes are required to achieve consensus (2 of 3), while a single peer from Org1 can be utilized since the endorsement policy is set as any single organization). +Open terminal windows for 3 ordering nodes or 4 if running BFT Consensus, 4 peer nodes, and 4 peer admins as seen in the following terminal setup. The first two peers and peer admins belong to Org1, the latter two peer and peer admins belong to Org2. +Note, you can start with two ordering nodes and a single Org1 peer node and single Org1 peer admin terminal if you would like to keep things even more minimal (two ordering nodes are required to achieve Raft consensus (2 of 3), while a single peer from Org1 can be utilized since the endorsement policy is set as any single organization). ![Terminal setup](terminal_setup.png) The following instructions will have you run simple bash scripts that set environment variable overrides for a component and then runs the component. @@ -51,25 +50,29 @@ The scripts contain only simple single-line commands so that they are easy to re If you have trouble running bash scripts in your environment, you can just as easily copy and paste the individual commands from the script files instead of running the script files. - cd to the `test-network-nano-bash` directory in each terminal window -- In the first orderer terminal, run `./generate_artifacts.sh` to generate crypto material (calls cryptogen) and system and application channel genesis block and configuration transactions (calls configtxgen). The artifacts will be created in the `crypto-config` and `channel-artifacts` directories. -- In the three orderer terminals, run `./orderer1.sh`, `./orderer2.sh`, `./orderer3.sh` respectively -- In the four peer terminals, run `./peer1.sh`, `./peer2.sh`, `./peer3.sh`, `./peer4.sh` respectively +- In the first orderer terminal, run `./generate_artifacts.sh` to generate crypto material (calls cryptogen) and application channel genesis block and configuration transactions (calls configtxgen). The artifacts will be created in the `crypto-config` and `channel-artifacts` directories. If you are running BFT consensus then run `./generate_artifacts.sh BFT`. +- In the three orderer terminals, run `./orderer1.sh`, `./orderer2.sh`, `./orderer3.sh` respectively. If you are running BFT consensus then run `./orderer4.sh` in the fourth orderer terminal also. +- In the four peer terminals, run `./peer1.sh`, `./peer2.sh`, `./peer3.sh`, `./peer4.sh` respectively. - Note that each orderer and peer write their data (including their ledgers) to their own subdirectory under the `data` directory -- In the four peer admin terminals, run `source peer1admin.sh && ./create_channel.sh`, `source peer2admin.sh && ./join_channel.sh`, `source peer3admin.sh && ./join_channel.sh`, `source peer4admin.sh && ./join_channel.sh` respectively +- Open a different terminal and run `./join_orderers.sh`. If you are running BFT Consensus then run `./join_orderers.sh BFT` instead. +- In the four peer admin terminals, run `source peer1admin.sh && ./join_channel.sh`, `source peer2admin.sh && ./join_channel.sh`, `source peer3admin.sh && ./join_channel.sh`, `source peer4admin.sh && ./join_channel.sh` respectively. Note the syntax of running the scripts. The peer admin scripts set the admin environment variables and must be run with the `source` command in order that the exported environment variables can be utilized by any subsequent user commands. -The `create_channel.sh` script creates the application channel `mychannel`, updates the channel configuration for the gossip anchor peer, and joins the peer to `mychannel`. -The `join_channel.sh` script joins a peer to `mychannel`. - ## Starting the network with one command Using the individual scripts above gives you more control of the process of starting a Fabric network and demonstrates how all the required components fit together, however the same network can also be started using a single script for convenience. +For Raft consensus type: ```shell ./network.sh start ``` +For BFT consensus type: +```shell +./network.sh start -o BFT +``` + After the network has started, use seperate terminals to run peer commands. You will need to configure the peer environment for each new terminal. For example to run against peer1, use: @@ -85,6 +88,8 @@ To deploy and invoke the chaincode, utilize the peer1 admin terminal that you ha 1. Using a chaincode container 2. Running the chaincode as a service +For your convenience you can run `install&approve&commit_chaincode_peer1.sh` from peer1admin terminal to run basic chaincode as a container and activate it. The output of the script is redirected to the logs folder. + ## 1. Using a chaincode container Package and install the chaincode on peer1: @@ -175,7 +180,7 @@ peer chaincode invoke -o 127.0.0.1:6050 -C mychannel -n basic -c '{"Args":["Upda peer chaincode query -C mychannel -n basic -c '{"Args":["ReadAsset","1"]}' ``` - +For your convenience you can run `chaincode_interaction.sh` from peer1admin terminal to make this simple transaction. The ouput of the script is redirected to the logs folder.\ Congratulations, you have deployed a minimal Fabric network! Inspect the scripts if you would like to see the minimal set of commands that were required to deploy the network. # Stopping the network diff --git a/test-network-nano-bash/bft-config/configtx.yaml b/test-network-nano-bash/bft-config/configtx.yaml new file mode 100644 index 00000000..b6d3cbf2 --- /dev/null +++ b/test-network-nano-bash/bft-config/configtx.yaml @@ -0,0 +1,320 @@ +# Copyright IBM Corp. All Rights Reserved. +# +# SPDX-License-Identifier: Apache-2.0 +# + +--- +################################################################################ +# +# Section: Organizations +# +# - This section defines the different organizational identities which will +# be referenced later in the configuration. +# +################################################################################ +Organizations: + - &OrdererOrg + # SampleOrg defines an MSP using the sampleconfig. It should never be used + # in production but may be used as a template for other definitions + Name: OrdererOrg + # ID to load the MSP definition as + ID: OrdererMSP + # MSPDir is the filesystem path which contains the MSP configuration + MSPDir: ../crypto-config/ordererOrganizations/example.com/msp + # Policies defines the set of policies at this level of the config tree + # For organization policies, their canonical path is usually + # /Channel/// + Policies: + Readers: + Type: Signature + Rule: "OR('OrdererMSP.member')" + Writers: + Type: Signature + Rule: "OR('OrdererMSP.member')" + Admins: + Type: Signature + Rule: "OR('OrdererMSP.admin')" + OrdererEndpoints: + - 127.0.0.1:6050 + - 127.0.0.1:6051 + - 127.0.0.1:6052 + - 127.0.0.1:6053 + - &Org1 + Name: Org1MSP + # ID to load the MSP definition as + ID: Org1MSP + MSPDir: ../crypto-config/peerOrganizations/org1.example.com/msp + # Policies defines the set of policies at this level of the config tree + # For organization policies, their canonical path is usually + # /Channel/// + Policies: + Readers: + Type: Signature + Rule: "OR('Org1MSP.admin', 'Org1MSP.peer', 'Org1MSP.client')" + Writers: + Type: Signature + Rule: "OR('Org1MSP.admin', 'Org1MSP.client')" + Admins: + Type: Signature + Rule: "OR('Org1MSP.admin')" + Endorsement: + Type: Signature + Rule: "OR('Org1MSP.peer')" + # leave this flag set to true. + AnchorPeers: + # AnchorPeers defines the location of peers which can be used + # for cross org gossip communication. Note, this value is only + # encoded in the genesis block in the Application section context + - Host: 127.0.0.1 + Port: 7051 + - &Org2 + Name: Org2MSP + # ID to load the MSP definition as + ID: Org2MSP + MSPDir: ../crypto-config/peerOrganizations/org2.example.com/msp + # Policies defines the set of policies at this level of the config tree + # For organization policies, their canonical path is usually + # /Channel/// + Policies: + Readers: + Type: Signature + Rule: "OR('Org2MSP.admin', 'Org2MSP.peer', 'Org2MSP.client')" + Writers: + Type: Signature + Rule: "OR('Org2MSP.admin', 'Org2MSP.client')" + Admins: + Type: Signature + Rule: "OR('Org2MSP.admin')" + Endorsement: + Type: Signature + Rule: "OR('Org2MSP.peer')" + AnchorPeers: + # AnchorPeers defines the location of peers which can be used + # for cross org gossip communication. Note, this value is only + # encoded in the genesis block in the Application section context + - Host: 127.0.0.1 + Port: 7055 +################################################################################ +# +# SECTION: Capabilities +# +# - This section defines the capabilities of fabric network. This is a new +# concept as of v1.1.0 and should not be utilized in mixed networks with +# v1.0.x peers and orderers. Capabilities define features which must be +# present in a fabric binary for that binary to safely participate in the +# fabric network. For instance, if a new MSP type is added, newer binaries +# might recognize and validate the signatures from this type, while older +# binaries without this support would be unable to validate those +# transactions. This could lead to different versions of the fabric binaries +# having different world states. Instead, defining a capability for a channel +# informs those binaries without this capability that they must cease +# processing transactions until they have been upgraded. For v1.0.x if any +# capabilities are defined (including a map with all capabilities turned off) +# then the v1.0.x peer will deliberately crash. +# +################################################################################ +Capabilities: + # Channel capabilities apply to both the orderers and the peers and must be + # supported by both. + # Set the value of the capability to true to require it. + Channel: &ChannelCapabilities + # V2_0 capability ensures that orderers and peers behave according + # to v2.0 channel capabilities. Orderers and peers from + # prior releases would behave in an incompatible way, and are therefore + # not able to participate in channels at v2.0 capability. + # Prior to enabling V2.0 channel capabilities, ensure that all + # orderers and peers on a channel are at v2.0.0 or later. + V3_0: true + # Orderer capabilities apply only to the orderers, and may be safely + # used with prior release peers. + # Set the value of the capability to true to require it. + Orderer: &OrdererCapabilities + # V2_0 orderer capability ensures that orderers behave according + # to v2.0 orderer capabilities. Orderers from + # prior releases would behave in an incompatible way, and are therefore + # not able to participate in channels at v2.0 orderer capability. + # Prior to enabling V2.0 orderer capabilities, ensure that all + # orderers on channel are at v2.0.0 or later. + V2_0: true + # Application capabilities apply only to the peer network, and may be safely + # used with prior release orderers. + # Set the value of the capability to true to require it. + Application: &ApplicationCapabilities + # V2.5 for Application enables the new non-backwards compatible + # features of fabric v2.5, namely the ability to purge private data. + # Prior to enabling V2.5 application capabilities, ensure that all + # peers on a channel are at v2.5.0 or later. + V2_5: true +################################################################################ +# +# SECTION: Application +# +# - This section defines the values to encode into a config transaction or +# genesis block for application related parameters +# +################################################################################ +Application: &ApplicationDefaults + # Organizations is the list of orgs which are defined as participants on + # the application side of the network + Organizations: + # Policies defines the set of policies at this level of the config tree + # For Application policies, their canonical path is + # /Channel/Application/ + Policies: + Readers: + Type: ImplicitMeta + Rule: "ANY Readers" + Writers: + Type: ImplicitMeta + Rule: "ANY Writers" + Admins: + Type: ImplicitMeta + Rule: "MAJORITY Admins" + LifecycleEndorsement: + Type: Signature + Rule: "OR('Org1MSP.peer','Org2MSP.peer')" + Endorsement: + Type: Signature + Rule: "OR('Org1MSP.peer','Org2MSP.peer')" + Capabilities: + <<: *ApplicationCapabilities +################################################################################ +# +# SECTION: Orderer +# +# - This section defines the values to encode into a config transaction or +# genesis block for orderer related parameters +# +################################################################################ +Orderer: &OrdererDefaults + # Batch Timeout: The amount of time to wait before creating a batch + BatchTimeout: 2s + # Batch Size: Controls the number of messages batched into a block + BatchSize: + # Max Message Count: The maximum number of messages to permit in a batch + MaxMessageCount: 10 + # Absolute Max Bytes: The absolute maximum number of bytes allowed for + # the serialized messages in a batch. + AbsoluteMaxBytes: 99 MB + # Preferred Max Bytes: The preferred maximum number of bytes allowed for + # the serialized messages in a batch. A message larger than the preferred + # max bytes will result in a batch larger than preferred max bytes. + PreferredMaxBytes: 512 KB + # Organizations is the list of orgs which are defined as participants on + # the orderer side of the network + Organizations: + # Policies defines the set of policies at this level of the config tree + # For Orderer policies, their canonical path is + # /Channel/Orderer/ + Policies: + Readers: + Type: ImplicitMeta + Rule: "ANY Readers" + Writers: + Type: ImplicitMeta + Rule: "ANY Writers" + Admins: + Type: ImplicitMeta + Rule: "MAJORITY Admins" + # BlockValidation specifies what signatures must be included in the block + # from the orderer for the peer to validate it. + BlockValidation: + Type: ImplicitMeta + Rule: "ANY Writers" +################################################################################ +# +# CHANNEL +# +# This section defines the values to encode into a config transaction or +# genesis block for channel related parameters. +# +################################################################################ +Channel: &ChannelDefaults + # Policies defines the set of policies at this level of the config tree + # For Channel policies, their canonical path is + # /Channel/ + Policies: + # Who may invoke the 'Deliver' API + Readers: + Type: ImplicitMeta + Rule: "ANY Readers" + # Who may invoke the 'Broadcast' API + Writers: + Type: ImplicitMeta + Rule: "ANY Writers" + # By default, who may modify elements at this config level + Admins: + Type: ImplicitMeta + Rule: "MAJORITY Admins" + # Capabilities describes the channel level capabilities, see the + # dedicated Capabilities section elsewhere in this file for a full + # description + Capabilities: + <<: *ChannelCapabilities +################################################################################ +# +# Profile +# +# - Different configuration profiles may be encoded here to be specified +# as parameters to the configtxgen tool +# +################################################################################ +Profiles: + ChannelUsingBFT: + <<: *ChannelDefaults + Orderer: + <<: *OrdererDefaults + 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: 100000 + 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 \ No newline at end of file diff --git a/test-network-nano-bash/chaincode_interaction.sh b/test-network-nano-bash/chaincode_interaction.sh new file mode 100755 index 00000000..bc455f7d --- /dev/null +++ b/test-network-nano-bash/chaincode_interaction.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env sh + +# The sleep commands were added because the queries depend on each other and have some latency. + +. peer1admin.sh + +peer chaincode invoke -o 127.0.0.1:6050 -C mychannel -n basic -c '{"Args":["CreateAsset","1","blue","35","tom","1000"]}' --tls --cafile "${PWD}"/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt >> ./logs/chaincode_interaction.log 2>&1 +sleep 2 + +peer chaincode query -C mychannel -n basic -c '{"Args":["ReadAsset","1"]}' >> ./logs/chaincode_interaction.log 2>&1 +sleep 2 + +peer chaincode invoke -o 127.0.0.1:6050 -C mychannel -n basic -c '{"Args":["UpdateAsset","1","blue","35","jerry","1000"]}' --tls --cafile "${PWD}"/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt >> ./logs/chaincode_interaction.log 2>&1 +sleep 2 + +peer chaincode query -C mychannel -n basic -c '{"Args":["ReadAsset","1"]}' >> ./logs/chaincode_interaction.log 2>&1 \ No newline at end of file diff --git a/test-network-nano-bash/configtx.yaml b/test-network-nano-bash/configtx.yaml index 0a0c05d6..412dce81 100644 --- a/test-network-nano-bash/configtx.yaml +++ b/test-network-nano-bash/configtx.yaml @@ -13,108 +13,87 @@ # ################################################################################ Organizations: - + - &OrdererOrg # SampleOrg defines an MSP using the sampleconfig. It should never be used # in production but may be used as a template for other definitions - - &OrdererOrg - # DefaultOrg defines the organization which is used in the sampleconfig - # of the fabric.git development environment - Name: OrdererOrg - - # ID to load the MSP definition as - ID: OrdererMSP - - # MSPDir is the filesystem path which contains the MSP configuration - MSPDir: crypto-config/ordererOrganizations/example.com/msp - - # Policies defines the set of policies at this level of the config tree - # For organization policies, their canonical path is usually - # /Channel/// - Policies: - Readers: - Type: Signature - Rule: "OR('OrdererMSP.member')" - Writers: - Type: Signature - Rule: "OR('OrdererMSP.member')" - Admins: - Type: Signature - Rule: "OR('OrdererMSP.admin')" - - OrdererEndpoints: - - 127.0.0.1:6050 - - 127.0.0.1:6051 - - 127.0.0.1:6052 - - - &Org1 - # DefaultOrg defines the organization which is used in the sampleconfig - # of the fabric.git development environment - Name: Org1MSP - - # ID to load the MSP definition as - ID: Org1MSP - - MSPDir: crypto-config/peerOrganizations/org1.example.com/msp - - # Policies defines the set of policies at this level of the config tree - # For organization policies, their canonical path is usually - # /Channel/// - Policies: - Readers: - Type: Signature - Rule: "OR('Org1MSP.admin', 'Org1MSP.peer', 'Org1MSP.client')" - Writers: - Type: Signature - Rule: "OR('Org1MSP.admin', 'Org1MSP.client')" - Admins: - Type: Signature - Rule: "OR('Org1MSP.admin')" - Endorsement: - Type: Signature - Rule: "OR('Org1MSP.peer')" - - # leave this flag set to true. - AnchorPeers: - # AnchorPeers defines the location of peers which can be used - # for cross org gossip communication. Note, this value is only - # encoded in the genesis block in the Application section context - - Host: 127.0.0.1 - Port: 7051 - - - &Org2 - # DefaultOrg defines the organization which is used in the sampleconfig - # of the fabric.git development environment - Name: Org2MSP - - # ID to load the MSP definition as - ID: Org2MSP - - MSPDir: crypto-config/peerOrganizations/org2.example.com/msp - - # Policies defines the set of policies at this level of the config tree - # For organization policies, their canonical path is usually - # /Channel/// - Policies: - Readers: - Type: Signature - Rule: "OR('Org2MSP.admin', 'Org2MSP.peer', 'Org2MSP.client')" - Writers: - Type: Signature - Rule: "OR('Org2MSP.admin', 'Org2MSP.client')" - Admins: - Type: Signature - Rule: "OR('Org2MSP.admin')" - Endorsement: - Type: Signature - Rule: "OR('Org2MSP.peer')" - - AnchorPeers: - # AnchorPeers defines the location of peers which can be used - # for cross org gossip communication. Note, this value is only - # encoded in the genesis block in the Application section context - - Host: 127.0.0.1 - Port: 7055 - + Name: OrdererOrg + # ID to load the MSP definition as + ID: OrdererMSP + # MSPDir is the filesystem path which contains the MSP configuration + MSPDir: crypto-config/ordererOrganizations/example.com/msp + # Policies defines the set of policies at this level of the config tree + # For organization policies, their canonical path is usually + # /Channel/// + Policies: + Readers: + Type: Signature + Rule: "OR('OrdererMSP.member')" + Writers: + Type: Signature + Rule: "OR('OrdererMSP.member')" + Admins: + Type: Signature + Rule: "OR('OrdererMSP.admin')" + OrdererEndpoints: + - 127.0.0.1:6050 + - 127.0.0.1:6051 + - 127.0.0.1:6052 + - 127.0.0.1:6053 + - &Org1 + Name: Org1MSP + # ID to load the MSP definition as + ID: Org1MSP + MSPDir: crypto-config/peerOrganizations/org1.example.com/msp + # Policies defines the set of policies at this level of the config tree + # For organization policies, their canonical path is usually + # /Channel/// + Policies: + Readers: + Type: Signature + Rule: "OR('Org1MSP.admin', 'Org1MSP.peer', 'Org1MSP.client')" + Writers: + Type: Signature + Rule: "OR('Org1MSP.admin', 'Org1MSP.client')" + Admins: + Type: Signature + Rule: "OR('Org1MSP.admin')" + Endorsement: + Type: Signature + Rule: "OR('Org1MSP.peer')" + # leave this flag set to true. + AnchorPeers: + # AnchorPeers defines the location of peers which can be used + # for cross org gossip communication. Note, this value is only + # encoded in the genesis block in the Application section context + - Host: 127.0.0.1 + Port: 7051 + - &Org2 + Name: Org2MSP + # ID to load the MSP definition as + ID: Org2MSP + MSPDir: crypto-config/peerOrganizations/org2.example.com/msp + # Policies defines the set of policies at this level of the config tree + # For organization policies, their canonical path is usually + # /Channel/// + Policies: + Readers: + Type: Signature + Rule: "OR('Org2MSP.admin', 'Org2MSP.peer', 'Org2MSP.client')" + Writers: + Type: Signature + Rule: "OR('Org2MSP.admin', 'Org2MSP.client')" + Admins: + Type: Signature + Rule: "OR('Org2MSP.admin')" + Endorsement: + Type: Signature + Rule: "OR('Org2MSP.peer')" + AnchorPeers: + # AnchorPeers defines the location of peers which can be used + # for cross org gossip communication. Note, this value is only + # encoded in the genesis block in the Application section context + - Host: 127.0.0.1 + Port: 7055 ################################################################################ # # SECTION: Capabilities @@ -135,40 +114,37 @@ Organizations: # ################################################################################ Capabilities: - # Channel capabilities apply to both the orderers and the peers and must be - # supported by both. - # Set the value of the capability to true to require it. - Channel: &ChannelCapabilities - # V2_0 capability ensures that orderers and peers behave according - # to v2.0 channel capabilities. Orderers and peers from - # prior releases would behave in an incompatible way, and are therefore - # not able to participate in channels at v2.0 capability. - # Prior to enabling V2.0 channel capabilities, ensure that all - # orderers and peers on a channel are at v2.0.0 or later. - V2_0: true - - # Orderer capabilities apply only to the orderers, and may be safely - # used with prior release peers. - # Set the value of the capability to true to require it. - Orderer: &OrdererCapabilities - # V2_0 orderer capability ensures that orderers behave according - # to v2.0 orderer capabilities. Orderers from - # prior releases would behave in an incompatible way, and are therefore - # not able to participate in channels at v2.0 orderer capability. - # Prior to enabling V2.0 orderer capabilities, ensure that all - # orderers on channel are at v2.0.0 or later. - V2_0: true - - # Application capabilities apply only to the peer network, and may be safely - # used with prior release orderers. - # Set the value of the capability to true to require it. - Application: &ApplicationCapabilities - # V2.5 for Application enables the new non-backwards compatible - # features of fabric v2.5, namely the ability to purge private data. - # Prior to enabling V2.5 application capabilities, ensure that all - # peers on a channel are at v2.5.0 or later. - V2_5: true - + # Channel capabilities apply to both the orderers and the peers and must be + # supported by both. + # Set the value of the capability to true to require it. + Channel: &ChannelCapabilities + # V2_0 capability ensures that orderers and peers behave according + # to v2.0 channel capabilities. Orderers and peers from + # prior releases would behave in an incompatible way, and are therefore + # not able to participate in channels at v2.0 capability. + # Prior to enabling V2.0 channel capabilities, ensure that all + # orderers and peers on a channel are at v2.0.0 or later. + V2_0: true + # Orderer capabilities apply only to the orderers, and may be safely + # used with prior release peers. + # Set the value of the capability to true to require it. + Orderer: &OrdererCapabilities + # V2_0 orderer capability ensures that orderers behave according + # to v2.0 orderer capabilities. Orderers from + # prior releases would behave in an incompatible way, and are therefore + # not able to participate in channels at v2.0 orderer capability. + # Prior to enabling V2.0 orderer capabilities, ensure that all + # orderers on channel are at v2.0.0 or later. + V2_0: true + # Application capabilities apply only to the peer network, and may be safely + # used with prior release orderers. + # Set the value of the capability to true to require it. + Application: &ApplicationCapabilities + # V2.5 for Application enables the new non-backwards compatible + # features of fabric v2.5, namely the ability to purge private data. + # Prior to enabling V2.5 application capabilities, ensure that all + # peers on a channel are at v2.5.0 or later. + V2_5: true ################################################################################ # # SECTION: Application @@ -178,33 +154,30 @@ Capabilities: # ################################################################################ Application: &ApplicationDefaults - - # Organizations is the list of orgs which are defined as participants on - # the application side of the network - Organizations: - - # Policies defines the set of policies at this level of the config tree - # For Application policies, their canonical path is - # /Channel/Application/ - Policies: - Readers: - Type: ImplicitMeta - Rule: "ANY Readers" - Writers: - Type: ImplicitMeta - Rule: "ANY Writers" - Admins: - Type: ImplicitMeta - Rule: "MAJORITY Admins" - LifecycleEndorsement: - Type: Signature - Rule: "OR('Org1MSP.peer','Org2MSP.peer')" - Endorsement: - Type: Signature - Rule: "OR('Org1MSP.peer','Org2MSP.peer')" - - Capabilities: - <<: *ApplicationCapabilities + # Organizations is the list of orgs which are defined as participants on + # the application side of the network + Organizations: + # Policies defines the set of policies at this level of the config tree + # For Application policies, their canonical path is + # /Channel/Application/ + Policies: + Readers: + Type: ImplicitMeta + Rule: "ANY Readers" + Writers: + Type: ImplicitMeta + Rule: "ANY Writers" + Admins: + Type: ImplicitMeta + Rule: "MAJORITY Admins" + LifecycleEndorsement: + Type: Signature + Rule: "OR('Org1MSP.peer','Org2MSP.peer')" + Endorsement: + Type: Signature + Rule: "OR('Org1MSP.peer','Org2MSP.peer')" + Capabilities: + <<: *ApplicationCapabilities ################################################################################ # # SECTION: Orderer @@ -214,94 +187,40 @@ 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 - - # Batch Size: Controls the number of messages batched into a block - BatchSize: - - # Max Message Count: The maximum number of messages to permit in a batch - MaxMessageCount: 10 - - # Absolute Max Bytes: The absolute maximum number of bytes allowed for - # the serialized messages in a batch. - AbsoluteMaxBytes: 99 MB - - # Preferred Max Bytes: The preferred maximum number of bytes allowed for - # the serialized messages in a batch. A message larger than the preferred - # max bytes will result in a batch larger than preferred max bytes. - PreferredMaxBytes: 512 KB - - # Organizations is the list of orgs which are defined as participants on - # the orderer side of the network - Organizations: - - # Policies defines the set of policies at this level of the config tree - # For Orderer policies, their canonical path is - # /Channel/Orderer/ - Policies: - Readers: - Type: ImplicitMeta - Rule: "ANY Readers" - Writers: - Type: ImplicitMeta - Rule: "ANY Writers" - Admins: - Type: ImplicitMeta - Rule: "MAJORITY Admins" - # BlockValidation specifies what signatures must be included in the block - # from the orderer for the peer to validate it. - BlockValidation: - Type: ImplicitMeta - Rule: "ANY Writers" - + # Batch Timeout: The amount of time to wait before creating a batch + BatchTimeout: 2s + # Batch Size: Controls the number of messages batched into a block + BatchSize: + # Max Message Count: The maximum number of messages to permit in a batch + MaxMessageCount: 10 + # Absolute Max Bytes: The absolute maximum number of bytes allowed for + # the serialized messages in a batch. + AbsoluteMaxBytes: 99 MB + # Preferred Max Bytes: The preferred maximum number of bytes allowed for + # the serialized messages in a batch. A message larger than the preferred + # max bytes will result in a batch larger than preferred max bytes. + PreferredMaxBytes: 512 KB + # Organizations is the list of orgs which are defined as participants on + # the orderer side of the network + Organizations: + # Policies defines the set of policies at this level of the config tree + # For Orderer policies, their canonical path is + # /Channel/Orderer/ + Policies: + Readers: + Type: ImplicitMeta + Rule: "ANY Readers" + Writers: + Type: ImplicitMeta + Rule: "ANY Writers" + Admins: + Type: ImplicitMeta + Rule: "MAJORITY Admins" + # BlockValidation specifies what signatures must be included in the block + # from the orderer for the peer to validate it. + BlockValidation: + Type: ImplicitMeta + Rule: "ANY Writers" ################################################################################ # # CHANNEL @@ -311,29 +230,27 @@ Orderer: &OrdererDefaults # ################################################################################ Channel: &ChannelDefaults - # Policies defines the set of policies at this level of the config tree - # For Channel policies, their canonical path is - # /Channel/ - Policies: - # Who may invoke the 'Deliver' API - Readers: - Type: ImplicitMeta - Rule: "ANY Readers" - # Who may invoke the 'Broadcast' API - Writers: - Type: ImplicitMeta - Rule: "ANY Writers" - # By default, who may modify elements at this config level - Admins: - Type: ImplicitMeta - Rule: "MAJORITY Admins" - - # Capabilities describes the channel level capabilities, see the - # dedicated Capabilities section elsewhere in this file for a full - # description - Capabilities: - <<: *ChannelCapabilities - + # Policies defines the set of policies at this level of the config tree + # For Channel policies, their canonical path is + # /Channel/ + Policies: + # Who may invoke the 'Deliver' API + Readers: + Type: ImplicitMeta + Rule: "ANY Readers" + # Who may invoke the 'Broadcast' API + Writers: + Type: ImplicitMeta + Rule: "ANY Writers" + # By default, who may modify elements at this config level + Admins: + Type: ImplicitMeta + Rule: "MAJORITY Admins" + # Capabilities describes the channel level capabilities, see the + # dedicated Capabilities section elsewhere in this file for a full + # description + Capabilities: + <<: *ChannelCapabilities ################################################################################ # # Profile @@ -343,45 +260,39 @@ Channel: &ChannelDefaults # ################################################################################ Profiles: - - TwoOrgsOrdererGenesis: - <<: *ChannelDefaults - Orderer: - <<: *OrdererDefaults - Organizations: - - *OrdererOrg - Capabilities: - <<: *OrdererCapabilities - Consortiums: - SampleConsortium: - Organizations: - - *Org1 - - *Org2 - TwoOrgsChannel: - Consortium: SampleConsortium - <<: *ChannelDefaults - Application: - <<: *ApplicationDefaults - Organizations: - - *Org1 - - *Org2 - Capabilities: - <<: *ApplicationCapabilities - Org1Channel: - Consortium: SampleConsortium - <<: *ChannelDefaults - Application: - <<: *ApplicationDefaults - Organizations: - - *Org1 - Capabilities: - <<: *ApplicationCapabilities - Org2Channel: - Consortium: SampleConsortium - <<: *ChannelDefaults - Application: - <<: *ApplicationDefaults - Organizations: - - *Org2 - Capabilities: - <<: *ApplicationCapabilities + ChannelUsingRaft: + <<: *ChannelDefaults + Orderer: + <<: *OrdererDefaults + Organizations: + - *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 + Application: + <<: *ApplicationDefaults + Organizations: + - *Org1 + - *Org2 + Capabilities: + <<: *ApplicationCapabilities \ No newline at end of file diff --git a/test-network-nano-bash/create_channel.sh b/test-network-nano-bash/create_channel.sh deleted file mode 100755 index d032edea..00000000 --- a/test-network-nano-bash/create_channel.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env sh -# -# SPDX-License-Identifier: Apache-2.0 -# -set -eu - -# create channel and add anchor peer -peer channel create -c mychannel -o 127.0.0.1:6050 -f "${PWD}"/channel-artifacts/mychannel.tx --outputBlock "${PWD}"/channel-artifacts/mychannel.block --tls --cafile "${PWD}"/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt -peer channel update -o 127.0.0.1:6050 -c mychannel -f "${PWD}"/channel-artifacts/Org1MSPanchors.tx --tls --cafile "${PWD}"/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt - -# join peer to channel -peer channel join -b "${PWD}"/channel-artifacts/mychannel.block diff --git a/test-network-nano-bash/generate_artifacts.sh b/test-network-nano-bash/generate_artifacts.sh index 98ea91b9..9ad83240 100755 --- a/test-network-nano-bash/generate_artifacts.sh +++ b/test-network-nano-bash/generate_artifacts.sh @@ -18,14 +18,17 @@ cryptogen generate --config="${PWD}"/crypto-config.yaml # set FABRIC_CFG_PATH to configtx.yaml directory that contains the profiles export FABRIC_CFG_PATH="${PWD}" -echo "Generating orderer genesis block" -configtxgen -profile TwoOrgsOrdererGenesis -channelID test-system-channel-name -outputBlock channel-artifacts/genesis.block +ordererType="etcdraft" +if [ $# -gt 0 ] && [ "$1" = "BFT" ] +then + profile="ChannelUsingBFT" + ordererType="BFT" + export FABRIC_CFG_PATH="${PWD}/bft-config" +else + profile="ChannelUsingRaft" +fi -echo "Generating channel create config transaction" -configtxgen -channelID mychannel -outputCreateChannelTx channel-artifacts/mychannel.tx -profile TwoOrgsChannel +echo "Generating application channel genesis block with ${ordererType} consensus" +configtxgen -profile ${profile} -outputBlock ./channel-artifacts/mychannel.block -channelID mychannel -echo "Generating anchor peer update transaction for Org1" -configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate channel-artifacts/Org1MSPanchors.tx -channelID mychannel -asOrg Org1MSP -echo "Generating anchor peer update transaction for Org2" -configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate channel-artifacts/Org2MSPanchors.tx -channelID mychannel -asOrg Org2MSP diff --git a/test-network-nano-bash/install&approve&commit_chaincode_peer1.sh b/test-network-nano-bash/install&approve&commit_chaincode_peer1.sh new file mode 100755 index 00000000..1ab1322d --- /dev/null +++ b/test-network-nano-bash/install&approve&commit_chaincode_peer1.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env sh +# +# SPDX-License-Identifier: Apache-2.0 +# + +# 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" + + +. peer1admin.sh + +# Install Chaincode on Peer1 +peer lifecycle chaincode package basic.tar.gz --path ../asset-transfer-basic/chaincode-go --lang golang --label basic_1 >> ./logs/install\&approve\&commit_chaincode_peer_1.log 2>&1 +peer lifecycle chaincode install basic.tar.gz >> ./logs/install\&approve\&commit_chaincode_peer_1.log 2>&1 + +# Extract the CHAINCODE_ID from the logs +id=$(sed -n '2s/.*Chaincode code package identifier: //p' ./logs/install\&approve\&commit_chaincode_peer_1.log) +export CHAINCODE_ID="$id" + +# Approve the chaincode using Peer1Admin +peer lifecycle chaincode approveformyorg -o 127.0.0.1:6050 --channelID mychannel --name basic --version 1 --package-id "${CHAINCODE_ID}" --sequence 1 --tls --cafile "${PWD}"/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt >> ./logs/install\&approve\&commit_chaincode_peer_1.log 2>&1 +peer lifecycle chaincode commit -o 127.0.0.1:6050 --channelID mychannel --name basic --version 1 --sequence 1 --tls --cafile "${PWD}"/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt >> ./logs/install\&approve\&commit_chaincode_peer_1.log 2>&1 diff --git a/test-network-nano-bash/join_orderers.sh b/test-network-nano-bash/join_orderers.sh new file mode 100755 index 00000000..c7a540cc --- /dev/null +++ b/test-network-nano-bash/join_orderers.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env sh + +set -eu + +export PATH="${PWD}"/../../fabric/build/bin:"${PWD}"/../bin:"$PATH" +export FABRIC_CFG_PATH="${PWD}"/../config + +ORDERER_CONSENSUS_TYPE="etcdraft" +if [ $# -gt 0 ] +then + if [ "$1" != "BFT" ] && [ "$1" != "etcdraft" ] + then + echo "Unsupported input consensus type ${1}" + exit 1 + fi + if [ "$1" = "BFT" ] + then + ORDERER_CONSENSUS_TYPE="BFT" + fi +fi + +osnadmin channel join --channelID mychannel --config-block ./channel-artifacts/mychannel.block -o localhost:9443 +osnadmin channel join --channelID mychannel --config-block ./channel-artifacts/mychannel.block -o localhost:9444 +osnadmin channel join --channelID mychannel --config-block ./channel-artifacts/mychannel.block -o localhost:9445 + +if [ "$ORDERER_CONSENSUS_TYPE" = "BFT" ]; then + osnadmin channel join --channelID mychannel --config-block ./channel-artifacts/mychannel.block -o localhost:9446 +fi diff --git a/test-network-nano-bash/network.sh b/test-network-nano-bash/network.sh index fddd1125..fb2fa80f 100755 --- a/test-network-nano-bash/network.sh +++ b/test-network-nano-bash/network.sh @@ -57,7 +57,7 @@ networkStart() { CREATE_CHANNEL=false else echo "Generating artifacts..." - ./generate_artifacts.sh + ./generate_artifacts.sh "${ORDERER_TYPE}" CREATE_CHANNEL=true fi @@ -65,9 +65,14 @@ 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 & + + #start one additional orderer for BFT consensus + if [ "$ORDERER_TYPE" = "BFT" ]; then + ./orderer4.sh "${ORDERER_TYPE}" > ./logs/orderer4.log 2>&1 & + fi echo "Waiting ${CLI_DELAY}s..." sleep ${CLI_DELAY} @@ -82,19 +87,25 @@ networkStart() { sleep ${CLI_DELAY} if [ "${CREATE_CHANNEL}" = "true" ]; then + echo "Joining orderers to channel..." + if [ "$ORDERER_TYPE" = "BFT" ]; then + ./join_orderers.sh BFT + else + ./join_orderers.sh + fi + echo "Creating channel (peer1)..." - . ./peer1admin.sh && ./create_channel.sh + . peer1admin.sh && ./join_channel.sh echo "Joining channel (peer2)..." - . ./peer2admin.sh && ./join_channel.sh + . peer2admin.sh && ./join_channel.sh echo "Joining channel (peer3)..." - . ./peer3admin.sh && ./join_channel.sh - + . peer3admin.sh && ./join_channel.sh + echo "Joining channel (peer4)..." - . ./peer4admin.sh && ./join_channel.sh + . peer4admin.sh && ./join_channel.sh fi - echo "Fabric network running. Use Ctrl-C to stop." wait @@ -119,6 +130,8 @@ else shift fi +ORDERER_TYPE="etcdraft" + # parse flags while [ $# -ge 1 ] ; do key="$1" @@ -127,6 +140,10 @@ while [ $# -ge 1 ] ; do CLI_DELAY="$2" shift ;; + -o ) + 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..1176b6cd 100755 --- a/test-network-nano-bash/orderer1.sh +++ b/test-network-nano-bash/orderer1.sh @@ -17,11 +17,20 @@ 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 +export ORDERER_GENERAL_BOOTSTRAPMETHOD=none +export ORDERER_CHANNELPARTICIPATION_ENABLED=true 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 +if [ $# -gt 0 ] +then + if [ "$1" != "BFT" ] && [ "$1" != "etcdraft" ] + then + echo "Unsupported input consensus type ${1}" + exit 1 + fi + export ORDERER_CONSENSUS_TYPE=${1} +fi +export ORDERER_CONSENSUS_WALDIR="${PWD}"/data/orderer/consensus/wal +export ORDERER_CONSENSUS_SNAPDIR="${PWD}"/data/orderer/consensus/snap export ORDERER_OPERATIONS_LISTENADDRESS=127.0.0.1:8443 export ORDERER_ADMIN_LISTENADDRESS=127.0.0.1:9443 diff --git a/test-network-nano-bash/orderer2.sh b/test-network-nano-bash/orderer2.sh index 267c924a..c360477b 100755 --- a/test-network-nano-bash/orderer2.sh +++ b/test-network-nano-bash/orderer2.sh @@ -17,11 +17,20 @@ 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 +export ORDERER_GENERAL_BOOTSTRAPMETHOD=none +export ORDERER_CHANNELPARTICIPATION_ENABLED=true 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 +if [ $# -gt 0 ] +then + if [ "$1" != "BFT" ] && [ "$1" != "etcdraft" ] + then + echo "Unsupported input consensus type ${1}" + exit 1 + fi + export ORDERER_CONSENSUS_TYPE=${1} +fi +export ORDERER_CONSENSUS_WALDIR="${PWD}"/data/orderer2/consensus/wal +export ORDERER_CONSENSUS_SNAPDIR="${PWD}"/data/orderer2/consensus/snap export ORDERER_OPERATIONS_LISTENADDRESS=127.0.0.1:8444 export ORDERER_ADMIN_LISTENADDRESS=127.0.0.1:9444 diff --git a/test-network-nano-bash/orderer3.sh b/test-network-nano-bash/orderer3.sh index c5a55f7a..5151ee4d 100755 --- a/test-network-nano-bash/orderer3.sh +++ b/test-network-nano-bash/orderer3.sh @@ -17,11 +17,20 @@ 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 +export ORDERER_GENERAL_BOOTSTRAPMETHOD=none +export ORDERER_CHANNELPARTICIPATION_ENABLED=true 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 +if [ $# -gt 0 ] +then + if [ "$1" != "BFT" ] && [ "$1" != "etcdraft" ] + then + echo "Unsupported input consensus type ${1}" + exit 1 + fi + export ORDERER_CONSENSUS_TYPE=${1} +fi +export ORDERER_CONSENSUS_WALDIR="${PWD}"/data/orderer3/consensus/wal +export ORDERER_CONSENSUS_SNAPDIR="${PWD}"/data/orderer3/consensus/snap export ORDERER_OPERATIONS_LISTENADDRESS=127.0.0.1:8445 export ORDERER_ADMIN_LISTENADDRESS=127.0.0.1:9445 diff --git a/test-network-nano-bash/orderer4.sh b/test-network-nano-bash/orderer4.sh new file mode 100755 index 00000000..0a118c67 --- /dev/null +++ b/test-network-nano-bash/orderer4.sh @@ -0,0 +1,38 @@ +#!/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 +export ORDERER_GENERAL_BOOTSTRAPMETHOD=none +export ORDERER_CHANNELPARTICIPATION_ENABLED=true +export ORDERER_FILELEDGER_LOCATION="${PWD}"/data/orderer4 +if [ $# -gt 0 ] +then + if [ "$1" != "BFT" ] && [ "$1" != "etcdraft" ] + then + echo "Unsupported input consensus type ${1}" + exit 1 + fi + export ORDERER_CONSENSUS_TYPE=${1} +fi +export ORDERER_CONSENSUS_WALDIR="${PWD}"/data/orderer4/consensus/wal +export ORDERER_CONSENSUS_SNAPDIR="${PWD}"/data/orderer4/consensus/snap +export ORDERER_OPERATIONS_LISTENADDRESS=127.0.0.1:8450 +export ORDERER_ADMIN_LISTENADDRESS=127.0.0.1:9446 + +# start orderer +orderer