Machine configuration: M1 Mac and is also tested to be working with Ubuntu 22.04 LTS version(amd-x86).
This is a guide to run Fabric with BDLS configured orderer using fabric-samples/test-network-nano-bash.
Follow these guides to install prerequisites for running fabric on your machine. You will not need docker installed as we won't run test-network with docker. Also no need to install softHSM as we won't be running softHSM integration tests.
Before you move onto next steps, make sure you have build-essential and yq correctly installed. You can install them using following command.
$ sudo apt install build-essential
$ sudo snap install yqIf your yq install using snap doesn't work, directly download the latest binary for your OS. For linux-x86 architecture:
wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq &&\
chmod +x /usr/bin/yq-
A working directory is required - for example, Go Developers use the $HOME/go/src/github.com/<your_github_userid> directory. This is a Golang Community recommendation for Go projects. Create and change directory to
fabric-bdlswhere we will work throughout this guide. -
Get
fabric-samplesinstall script which we will use to clone latestfabric-samples, fabric binaries and configuration files.
$ curl -sSLO https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/install-fabric.sh && chmod +x install-fabric.sh- Run this install script to get latest
fabric-samplesrepository, fabric binaries infabric-samples/binand configuration files infabric-samples/config
$ ./install-fabric.sh samples binary- Change directory to
fabric-samples. Edit theexternalBuildersoption insidefabric-samples/config/configtx.yamlfile because of this.
$ yq -i 'del(.chaincode.externalBuilders) | .chaincode.externalBuilders[0].name = "ccaas_builder" | .chaincode.externalBuilders[0].path = env(PWD) + "/builders/ccaas" | .chaincode.externalBuilders[0].propagateEnvironment[0] = "CHAINCODE_AS_A_SERVICE_BUILDER_CONFIG"' config/core.yamlIf you don't have yq then install using this guide for your OS.
- Also it is recommended to run configure external builders to run chaincode without docker. Here is why!
$ cd test-network-nano-bash
$ ./configureExternalBuilders.sh- Change directory to
fabric-bdlsand clonehyperledger-labs/bdlsrenamed asfabric.
$ git clone https://github.com/hyperledger-labs/bdls fabric- Change directory to
fabric-bdls/fabricand make sure you're onBDLS-RAFT-TPS-readycbranch. Now we will make new fabric binaries includingordererwhich incorporates BDLS protocol as BFT consensus protocol. Run following commands insidefabric-bdls/fabricrepository.
$ make configtxlator configtxgen cryptogen orderer osnadmin peer discover ledgerutil - Change directory to
fabric-bdls/fabric-samples. Comment out (or delete) line [189-284] containing thekafkarelated configuration fromfabric-samples/config/orderer.yaml.
Also set FABRIC_CFG_PATH environment variable so that orderer can read the required configuration correctly.
$ export FABRIC_CFG_PATH=${PWD}/../config- Edit the
fabric-samples/test-network-nano-bash/bft-config/configtx.yamlfile to re-configure the orderer parameters for BDLS. Use following values:
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: 500
# Absolute Max Bytes: The absolute maximum number of bytes allowed for
# the serialized messages in a batch.
AbsoluteMaxBytes: 10 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: 2 MB- Now that we've configured both the
fabric-bdls/fabricandfabric-bdls/fabric-samplesrepository, we are ready to start the orderers. Change directory tofabric-bdls/fabric-samples/test-network-nano-bashand split the terminal window into 4. Make sure all the terminals are inside thefabric-samples/test-network-nano-bashdirectory
-
In the first orderer terminal, run
./generate_artifacts.sh BFTto generate crypto material (calls cryptogen) and application channel genesis block and configuration transactions (calls configtxgen) for BFT configured orderer. The artifacts will be created in the crypto-config and channel-artifacts directories. -
Now in each of the orderer terminal windows run ./orderer1.sh, ./orderer2.sh, ./orderer3.sh, ./orderer4.sh respectively.
-
Open a different terminal inside
test-network-nano-bashand run./join_orderers.sh BFT. You should see something like this.
The orderer terminal windows will not change for intentional sleep duration of 8s after which you will start seeing logs indicating creation of blocks with test transactions and finally after all the 200 blocks are created you will also see the final TPS value for this integration where in-flight blocks is 1.
