In Hyperledger Fabric v2.1, in the test-network repo sample - Error in channel creation - hyperledger-fabric

I'm trying to create a channel from the test-network sample of Hyperledger Fabric v2.1. I have installed all the latest fabric binaries & Docker images. The channel-artifacts, 2 peers and a ordering node were successfully created.
However, the command ./network.sh createChannel gives the following error.
Error: failed to create deliver client for orderer: failed to load config for OrdererClient: unable to load orderer.tls.rootcert.file: open /home/fabric/HLF/fabric-sample: no such file or directory
!!!!!!!!!!!!!!! Channel creation failed !!!!!!!!!!!!!!!!

I believe CreateChannel is roughly 5 steps.
Generate a CreateChannel Transaction
Generate an Anchor peer transaction
Create the channel with the genesis block
Join the peers to the channel and
Update one peer in each organization to Anchor peer.
Any chance you can share the output of ./network.sh createChannel, I'd like to see how far you got before you ran into this error.

I was able to solve this issue by removing the spaces from name of parent directory in which the "fabric-samples" repo were installed. This was the final output was:
2020-05-14 16:56:04.064 IST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-05-14 16:56:04.130 IST [channelCmd] update -> INFO 002 Successfully submitted channel update
===================== Anchor peers updated for org 'Org2MSP' on channel 'mychannel' =====================
========= Channel successfully joined ===========

In my opinion, The problem is with the directory fabric-samples kindly re-download the binaries and try again.
Download using curl via:
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/release-2.1/scripts/bootstrap.sh | bash -s -- 2.1.0 1.5.2
Hope this helps, otherwise see the directory structures and path exports.

Related

Channel: mychannel received discovery error: failed constructing descriptor for chaincodes: <name:"chaincode" >

I am working on setting up multihost hyperledger fabric network.
org1, org2, org3 , orderer. After chaincode install I am trying to invoke chaincode from my node application using node sdk, It throws error as below:
enter image description here
Fabric version - 2.2.2
Fabric network version - 2.2.11

required chaincodes are not installed on sufficient peers

I'm working with hyperledger fabric on the IBM Blockchain Platform service. I've been able to test chain codes with no problems, however, after the last update, I started to get the error required chain codes are not installed on sufficient peers that looks simple but the problem is that the chaincode is in fact installed in all peers.
Log for Peer1
2021-10-28 20:12:53.535 UTC [lifecycle] CheckCommitReadiness -> INFO 111c Successfully
checked commit readiness of chaincode name 'test-cc' on channel 'testchannel2' with
definition {sequence: 5, endorsement info: (version: '0.0.9', plugin: 'escc', init
required: false), validation info: (plugin: 'vscc', policy:
'12202f4368616e6e656c2f4170706c69636174696f6e2f456e646f7273656d656e74'), collections: ()}
Log for Peer2
2021-10-28 20:12:25.575 UTC [lifecycle] CheckCommitReadiness -> INFO 7bf1 Successfully
checked commit readiness of chaincode name 'test-cc' on channel 'testchannel2' with
definition {sequence: 5, endorsement info: (version: '0.0.9', plugin: 'escc', init
required: false), validation info: (plugin: 'vscc', policy:
'12202f4368616e6e656c2f4170706c69636174696f6e2f456e646f7273656d656e74'), collections: ()}
However, when I execute the newly committed chaincode, I get:
2021-10-28 20:20:00.004 UTC [discovery] chaincodeQuery -> ERRO 1126 Failed constructing
descriptor for chaincode chaincodes:<name:"test-cc" > ,: required chaincodes are not
installed on sufficient peers
Any ideas?
CheckCommitReadiness only checks if the chaincode definition has been approved. It does not check if the chaincode has actually been installed on the peers. Use queryinstalled for that. If you find that the chaincode is indeed installed on each peer, then the next thing to check is that the discovery service can see each of the peers where the chaincode is installed. To check that, look in the peer logs for the "Membership view" messages. If the "Membership view" is incomplete, then it is likely a gossip configuration issue across the peers.
The problem was related to how I was deploying the CC. IBM Blockchain platform has a way to install CC on peer copying from another, simply uploading the CC again (for each peer). I tried again using the "copy from another" peer method and it worked. So, perhaps I was choosing a different version when uploading from my laptop.

Hyperledger build network - cannot create peer channel

I'm currently following hyperledger fabric document v1.4.6 to build first network(https://hyperledger-fabric.readthedocs.io/en/release-1.4/build_network.html#manually-generate-the-artifacts)
I first put the network down with ./byfn.sh down then tried creating the network.
However, when i go into docker cli and perform
peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
this creates a error saying
InitCmd -> ERRO 001 Cannot run peer because cannot init crypto, folder "/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin#org1.example.com/msp" does not exist
So I tried again with network up (./byfn.sh up) now with the same procedure it creates different error saying
Error: got unexpected status: BAD_REQUEST -- error applying config update to existing channel 'mychannel': error authorizing update: error validating ReadSet: proposed update requires that key [Group] /Channel/Application/Org1MSP be at version 0, but it is currently at version 1
at the same command
First, I'm not sure whether I should be having the network up or down and second how to fix the problem.
Thank you
If you want to perform the manual steps, you need to start from here (with any previous fabric networks down/removed) and follow all the steps in the order as listed on that page.

Can I use `peer channel fetch config` with only orderer nodes, no peer nodes?

I've brought up an etcdraft based orderer cluster with 3 nodes and no peer nodes are deployed for now. And now I want to modify the orderer cluster like removing or adding members. Instructions I've found require firstly fetching the current config with the 'peer channel fetch config' command.
My question is how I can do to fetch the current system channel config with 'peer channel fetch config' command before/without any peer up and running, or is there any other way to achieve this.
fabric version: 1.4.4
You need to invoke it against an orderer since you also need to do this for the system channel, and peers don't have the system channel in them.
Use something like:
peer channel fetch config mychannel.block -c mychannel --orderer orderer.example.com:7050 --cafile ca.crt

Hyperledger-composer unable to change BlockTimeout

I am working on prototyping a game using hyperledger-composer. I need to decrease the block time out however the instructions provided in the fabric-dev-servers do not work.
I followed the howtobuild.txt found in ~/fabric-dev-servers/fabric-scripts/hlfv12/composer however installing the network using composer network start --networkName .... the network fails to start with the error:
Error: Error trying to start business network. Error: Failed to connect to any peer event hubs. It is required that at least 1 event hub has been connected to receive the commit event
the versions i am uising are composer#20 and fabric docker images with the tag 1.2.1 (as downloaded by) ./startFabric.sh
The steps I have taken are exactly as follows:
cd ~/fabric-dev-servers/fabric-scripts/hlfv12/composer
nano configtx.yaml
inside this file I
Move the profile block to the bottom of the ymal (to stop the weird error)
change BatchTimeout to 200ms
changed MaxMessageCount to 1
after saving the file I do
rm -r crypto-config
cryptogen generate --config=./crypto-config.yaml
get the new key and update docker-composer.yml and docker-compose-dev.yml
$(ls -1 crypto-config/peerOrganizations/org1.example.com/ca/*_sk`
get key from keystore
ls -1 crypto-config/peerOrganizations/org1.example.com/users/Admin#org1.example.com/msp/keystore/*_sk
update peerAdminCard sell script with the new key
nano ../createPeerAdminCard.sh
Generate
configtxgen -profile ComposerChannel -outputCreateChannelTx ./composer-channel.tx -channelID composerchannel`
configtxgen -profile ComposerOrdererGenesis -outputBlock ./composer-genesis.block
create peer admin card
cd ../ && ./createPeerAdminCard.sh
At this point it starts downloading the fabric docker images, which all run successfully
I then create my BNA file and try to start the network
cd /my/buisness/network
composer archive create -t dir -n .
composer network install --card PeerAdmin#hlfv1 --archiveFile my-game#0.0.1.bna
composer network start --networkName my-game --networkVersion 0.0.1 --networkAdmin admin --networkAdminEnrollSecret adminpw --card PeerAdmin#hlfv1 --file networkadmin.card
which gives the error
Error: Error trying to start business network. Error: Failed to connect to any peer event hubs. It is required that at least 1 event hub has been connected to receive the commit event
The Debugging steps i have taken are as follows
After viewing the peer logs i can see delivering blocks to the orderer fails because composerchannel does not exist, so i manually try to create and join the channel manually
docker exec peer0.org1.example.com peer channel create -o orderer.example.com:7050 -c composerchannel -f /etc/hyperledger/configtx/composer-channel.tx
which is a success
2019-03-23 00:07:38.131 UTC [cli/common] readBlock -> INFO 05e Received block: 0
I then try to join the peer to the channel
docker exec peer0.org1.example.com peer channel join -o orderer.example.com:7050 -b composerchannel.block --tls --cafile /etc/hyperledger/msp/users/Admin#org1.example.com/tls/ca.crt --keyfile /etc/hyperledger/msp/users/Admin#org1.example.com/tls/client.key --certfile /etc/hyperledger/msp/users/Admin#org1.example.com/tls/client.crt
which gives the error
proposal failed (err: bad proposal response 500: access denied for [JoinChain][composerchannel]: [Failed verifying that proposal's creator satisfies local MSP principal during channelless check policy with policy [Admins]: [This identity is not an admin]])
There are a lot of different 'Admin' Pems inside the /etc/hyperledger/msp and /etc/hyperledger/tls so I'm pretty much trying all combinations
I'm at a loss, I've been on google for hours trying to find anyone with the same issue but have come up short. Any help will be appreciated.
UPDATE
Turns out explicitly defining the certificates where not needed. running this command allowed me to join the channel.
docker exec peer0.org1.example.com peer channel join -o orderer.example.com:7050 -b composerchannel.block --clientauth --tls
at this point all the docker containers were running and the channel was working. i manage to be able to start the network and everything ran fine (i could request the chaincode, ledger was updating fine etc). However it still seems to take 2 seconds to process a transaction. Again i did some debugging to make sure the config on the order was correct.
fetch config block from channel on orderer
docker exec peer0.org1.example.com peer channel fetch config config_block.pb -o http_s_://orderer.example.com:7050 -c composerchannel --tls --cafile /etc/hyperledger/peer/msp/tlscacerts/tlsca.org1.example.com-cert.pem
copy out of container to local machine
docker cp 5eeaf8c650f8:/root/config_block.pb config_block.pb
convert from proto-buf to json (using configtxlator binary found in fabric-samples)
configtxlator docker exec peer0.org1.example.com proto_decode --input config_block.pb --type common.Block | jq .data.data[0].payload.data.config > config.json
After getting the config of the channel i could see that the BatchTimeout was 200ms and BatchAmount was 1, yet i still have the 2 seconds timeout per transaction.
While working with Hyperledger composer now you have to keep in mind that it is obselete. I have followed these same steps many times in the past and built custom networks. I think your issue could be of version mismatch. Try downgrading composer to 0.19.
Additionally, did you try doing a docker ps to make sure that all the required containers are running?
Also, before doing the configtxgen command there's a simple command
export FABRIC_CFG_PATH=$PWD
Did you do this?

Resources