Add Fabric Organizations to the Network
This topic contains information about joining Hyperledger Fabric organizations to an Oracle Blockchain Platform network.
Typical Workflow to Join a Fabric Organization to an Oracle Blockchain Platform Network
Here are the tasks that a Fabric organization and the Oracle Blockchain Platform founder organization need to perform to join a Fabric organization to the Oracle Blockchain Platform network.
| Task | Who Does This? | Description | More Information |
|---|---|---|---|
| Create the certificate file for the Fabric organization | Fabric organization | Find the Fabric organization’s Admin, CA, and TLS certificate information and use it to compose a JSON certificates file. | Create a Fabric Organization's Certificates File |
| Upload Fabric organization's certificate file to the Oracle Blockchain Platform network | Founder organization | Use the console to upload and import the Fabric organization's certificate file to add the Fabric organization to the network. | Import Certificates to Add Organizations to the Network |
| Create a channel | Founder organization | Create a new channel and add the Fabric organization to it. | Create a Channel |
| Export the ordering service settings from founder | Founder organization | Output the founder’s ordering services settings to a JSON file and send the file to the Fabric organization. | Join the Participant or Scaled-Out OSNs to the Founder's Ordering Service |
| Compose orderer certificate file | Fabric organization | Create a file named orderer.pem that includes the tlscacert information.
Go to the exported ordering service settings file and copy the tlscacert information. After you paste the tlscacert information into the orderer.pem file, you must replace all instances of \n with the newline character. The orderer.pem file must have the following format: |
Create a Fabric Organization's Certificates File |
| Provide ordering service settings | Founder organization | Open the ordering service settings file and find the ordering service’s address and port and give them to the Fabric organization. For example: |
NA |
| Add the Fabric organization to the network | Fabric organization | The Fabric organization copies certificates into its environment, sets environment variables, fetches the genesis block, joins the channel, and installs the chaincode. | Prepare the Fabric Environment to Use the Oracle Blockchain Platform Network |
Create a Fabric Organization's Certificates File
For a Fabric organization to join an Oracle Blockchain Platform network, it must write a certificates file containing its admincerts, cacerts, and tlscacerts information. The Oracle Blockchain Platform founder organization imports this file to add the Fabric organization to the network.
The Fabric certificates information is stored in PEM files located in the Fabric organization’s MSP folder. For example, network_name_example/crypto-config/peerOrganizations/example_org.com/msp/.
The certificate file must be in written in JSON and contain the following fields:
-
mspid — Specifies the name of the Fabric organization.
- type — Indicates that the organization is a network participant. This value must be Participant.
-
admincert — Contains the contents of the organization’s Admin certificates file:
Admin@example_org.com-cert.pem. When you copy the certificates information into the JSON file, you must replace each new line with \n. -
cacert — Contains the contents of the organization’s CA certificates file:
ca.example_org-cert.pem. When you copy the certificates information into the JSON file, you must replace each new line with \n. -
tlscert — Contains the contents of the organization’s TLS certificate file:
tlsca.example_org-cert.pem. When you copy the certificates information into the JSON file, you must replace each new line with \n.
{
"mspID": "examplemspID",
"type": "Participant",
"certs": {
"admincert": "-----BEGIN CERTIFICATE-----\nexample_certificate\nexample_certificate==\n-----END CERTIFICATE-----\n",
"cacert": "-----BEGIN CERTIFICATE-----\nexample_certificate\nexample_certificate==\n-----END CERTIFICATE-----\n",
"tlscacert": "-----BEGIN CERTIFICATE-----\nexample_certificate\nexample_certificate==\n-----END CERTIFICATE-----\n"
}
}
Prepare the Fabric Environment to Use the Oracle Blockchain Platform Network
You must modify the Fabric organization’s environment before it can use the Oracle Blockchain Platform network.
Confirm that the following prerequisite tasks were completed. For more information, see Typical Workflow to Join a Fabric Organization to an Oracle Blockchain Platform Network.
-
The Fabric organization’s certificate file was created and sent to the Oracle Blockchain Platform network founder.
-
The network founder uploaded the certificates file to add the Fabric organization to the network.
-
The network founder created a new channel and added the Fabric organization to it.
-
The network founder downloaded its ordering service settings and sent them to the Fabric organization.
-
The Fabric organization created the orderer certificate file.
-
The network founder gave the ordering service address and port to the Fabric organization.
You must add the Fabric organization and install and test the chaincode.
-
Navigate to the Fabric network directory and launch the peer container.
-
Fetch the channel’s genesis block with this command:
peer channel fetch 0 mychannel.block -o ${orderer_addr}:${orderer_port} -c mychannel --tls --cafile orderer.pem --logging-level debugWhere:
-
{orderer_addr} is the Founder’s orderer address.
-
{orderer_port} is the Founder’s port number.
-
-c mychannel is the name of the channel that the Founder created. This is the channel where the Fabric organization will send and receive transactions on the Oracle Blockchain Platform network.
-
orderer.pem is the Founder’s orderer certificate file.
-
-
Join the channel with this command:
peer channel join -b mychannel.block -o ${orderer_addr}:${orderer_port} --tls --cafile orderer.pem --logging-level debug -
Install the chaincode with this command:
peer chaincode install -n mycc -v 1.0 -l "golang" -p ${CC_SRC_PATH}Where CC_SRC_PATH is the folder that contains the chaincode.
-
Instantiate the chaincode with this command:
peer chaincode instantiate -o ${orderer_addr}:${orderer_port} --tls --cafile orderer.pem -C mychannel -n mycc -l golang -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P <policy_string> --logging-level debug -
Invoke the chaincode with this command:
peer chaincode invoke -o ${orderer_addr}:${orderer_port} --tls true --cafile orderer.pem -C mychannel -n mycc -c '{"Args":["invoke","a","b","10"]}' --logging-level debug -
Query the chaincode with this command:
peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}' --logging-level debug
OLD Update docker.compose.yaml and add folder mapping
Do the following:
-
Navigate to the organization’s directory.
-
Edit the docker-compose.yaml to change the configuration of peer0.
-
Add folder mapping to
- ./crypto-config/peerOrganizations/example_org.com:/home/example_org_directory.
For example:
/root/example_name/obcs_workspace/users/aaa/networks/example_org.com$ vim docker-compose.yaml
……
peer0.example_org.com:
image: hyperledger/fabric-peer
environment:
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=obcs_default
- OBCS_SHARED_DATA_PATH=$PWD
volumes:
- ./core.peer0.example_org.com.yaml:/etc/hyperledger/fabric/core.yaml
- /var/run/:/host/var/run/
- ./crypto-config/peerOrganizations/example_org.com/peers/peer0.example_org.com/msp:/etc/hyperledger/msp/peer
- '.:$PWD'
- ./crypto-config/peerOrganizations/example_org.com:/home/example_org_name
ports:
- 19000:7777
- 19001:7778
- 19002:7779
networks:
- default
……
OLD Copy the founder’s orderer certificate file to the peer container
Copy the Oracle Blockchain Platform network founder’s orderer certificates file (for example, tls-ca.pem) to peer0’s container.
For example:
/root/example_name/obcs_workspace/users/aaa/networks/example_org.com$ docker ps |
grep "peer0.example_org"
example_mspid hyperledger/fabric-peer
"peer node start" 2 hours ago Up 2 hours
0.0.0.0:19000->7777/tcp, 0.0.0.0:19001->7778/tcp, 0.0.0.0:19002->7779/tcp
aaaexample_org_peer0.example_org.com_1
/root/example_name/obcs_workspace/users/aaa/networks/example_org.com$ docker cp tls-ca.pem example_mspid:/home/
OLD Restart the peer container
You must restart the peer container after you’ve copied the founder’s orderer certificates file to the container.
For example:
/root/example_name/obcs_workspace/users/aaa/networks/example_org.com$ docker-compose stop peer0.example_org.com
Stopping aaaexample_org_peer0.example_org.com_1 ... done
/root/example_name/obcs_workspace/users/aaa/networks/example_org.com$ docker-compose up -d peer0.example_org.com
Starting aaaexample_org_peer0.example_org.com_1 ...
Starting aaaexample_org_peer0.example_org.com_1 ... done
/root/example_name/obcs_workspace/users/aaa/networks/example_org.com$
OLD Export environment variables, get the genesis block, and join the channel
Do the following:
-
Go to the peer’s container and export the required environment variables.
-
Execute the
peer channel fetchcommand to get the genesis block. -
Execute the
peer channel joincommand to join the network channel.
For example:
/root/example_path/obcs_workspace/users/aaa/networks/example_org.com$ docker ps |
grep "peer0.example_name"
example_mspid hyperledger/fabric-peer
"peer node start" 2 hours ago Up 4 minutes
0.0.0.0:19000->7777/tcp, 0.0.0.0:19001->7778/tcp, 0.0.0.0:19002->7779/tcp
aaaexample_org_peer0.example_org.com_1
/root/example_path/obcs_workspace/users/aaa/networks/example_org.com$ docker exec -it example_mspid bash
root@example_mspid:/# cd /home
root@example_mspid:/home# ls -al
total 8
drwxr-xr-x. 3 root root 37 Feb 2 15:42 .
drwxr-xr-x. 22 root root 4096 Feb 2 14:08 ..
drwxr-xr-x. 7 root root 61 Feb 1 09:22 example_org
-rw-r--r--. 1 root root 1570 Jan 29 05:33 tls-ca.pem
root@example_mspid:/home#
export CORE_PEER_MSPCONFIGPATH=/home/example_org/users/Admin@example_org.com/msp
root@example_mspid:/home#
peer channel fetch 0 example.block -o channel_number block -o oc-11-22-333-444.nat-den13.sample.com:7777 -c channel_number --tls --cafile /home/
tls-ca.pem
2018-02-01 14:12:57.853 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
……
2018-02-01 14:12:58.943 UTC [channelCmd] readBlock -> DEBU 00a Received block: 0
2018-02-01 14:12:58.944 UTC [main] main -> INFO 00b Exiting.....
root@example_mspid:/home#
peer channel join -b channel_number.block -o oc-11-22-333-444.nat-den13.sample.com:7777 --tls --cafile /home/tls-ca.pem
2018-02-01 15:15:24.283 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2018-02-01 15:15:24.414 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
2018-02-01 15:15:24.414 UTC [main] main -> INFO 003 Exiting.....