Hyperledger Fabric network - using JAVA sdk - ERROR while creating channel - hyperledger-fabric

Environment:
MacOS : 10.13.6
Golang : 1.11.8
Hyperledger Fabric : 1.4
Java : 1.8
Description:
I try to run an official JavaSDK Fabric app example.
I can deploy and run the app normally with the default configuration.
Then I make some changes in configtx.yaml (just some rules about generating blocks) and generate the binary tool configtxgen, then I use:
./configtxgen -profile TwoOrgsOrdererGenesis -outputBlock genesis.block
./configtxgen -profile TwoOrgsChannel -outputCreateChannelTx channel.tx -channelID mychannel
commands to regenerate channel.tx and genesis.block.
I use these new files to start the fabric network, and follow the steps of this page, but I get the following error while creating channel:
*org.hyperledger.fabric.sdk.exception.TransactionException: Channel mychannel, send transaction failed on orderer OrdererClient{id: 4, channel: mychannel, name: orderer.example.com, url: grpc://localhost:7050}. Reason: Channel mychannel orderer orderer.example.com status returned failure code 400 (BAD_REQUEST) during orderer next
Caused by: org.hyperledger.fabric.sdk.exception.TransactionException: Channel mychannel orderer orderer.example.com status returned failure code 400 (BAD_REQUEST) during orderer next*
The logs of orderer container say:
2020-08-26 10:25:33.469 UTC [orderer.common.broadcast] ProcessMessage -> WARN 009 [channel: mychannel] Rejecting broadcast of config message from 192.168.0.1:56440 because of error: error validating channel creation transaction for new channel 'mychannel', could not succesfully apply update to template configuration: error authorizing update: error validating DeltaSet: attempted to set key [Value] /Channel/Application/Org1MSP/AnchorPeers to version 1, but key does not exist
Anyone know the solution?

You have to update your Anchor peers too like they said on script.
cryptogen generate --config=./crypto-config.yaml
mkdir config
configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./config/genesis.block
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./config/channel.tx -channelID mychannel
configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./config/Org1MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org1MSP
configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./config/Org2MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org2MSP
You can find details on build.sh script and have to uncomment out those lines.

Related

Error loading MSP configuration for org Org1MSP

I am facing a problem while creating the channel in HyperLedger Fabric Blockchain
ubuntu#Raghav:/mnt/c/fabric-samples/test-network$ ./network.sh createChannel
Creating channel 'mychannel'.
If network is not up, starting nodes with CLI timeout of '5' tries and CLI delay of '3' seconds and using database 'leveldb
Generating channel create transaction 'mychannel.tx'
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/mychannel.tx -channelID mychannel
The logs are the following ones:
2020-10-17 12:16:23.571 IST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-10-17 12:16:23.651 IST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /mnt/c/fabric-samples/test-network/configtx/configtx.yaml
2020-10-17 12:16:23.651 IST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 003 Generating new channel configtx
2020-10-17 12:16:23.668 IST [common.tools.configtxgen] main -> FATA 004 Error on outputChannelCreateTx: could not generate default config template: error parsing configuration: could not create application group: failed to create application org: 1 - Error loading MSP configuration for org Org1MSP: could not load a valid ca certificate from directory /mnt/c/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/msp/cacerts: stat /mnt/c/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/msp/cacerts: no such file or directory
+ res=1
Failed to generate channel configuration transaction...
Create channel failed

Channel creation fails in Hyperledger Fabric (without Docker)

I'm having some troubles creating a channel in Hyperledger Fabric v1.4.3 without the use of Docker. I could succesfully generate keys, certs, genesis block and the various artifacts by simply executing cryptogen and configtxgen, then start orderer and peer. However, when I try to create a channel with command
peer channel create -c mychannel -o 127.0.0.1:7050
it fails due to "BAD_REQUEST -- error validating channel creation transaction for new channel 'mychannel', could not succesfully apply update to template configuration: error authorizing update: error validating Readset: existing config does not contain element for [Group] /Channel/application/SampleOrg but was in the read set.
Below the list of commands (executed from fabric-samples/first-network directory):
# cryptogen generate --config=./crypto-config.yaml
# export FABRIC_CFG_PATH=$PWD
# mkdir channel-artifacts
# configtxgen -profile TwoOrgsOrdererGenesis -channelID byfn-sys-channel -outputBlock ./channel-artifacts/genesis.block
# export CHANNEL_NAME=mychannel
# configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME
# configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org1MSP
# configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org2MSP
# sudo mkdir -p /var/hyperledger/production
# sudo chown -R $(whoami):$(whoami) /var/hyperledger
# orderer start
# export set FABRIC_CFG_PATH=$HOME/fabric-samples/config
# peer node start >> peerlog.log 2>&1 &
# peer channel create -o 127.0.0.1:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx
This is the output of the the peer terminal, after the attempt of the channel creation:
2019-10-01 12:51:11.955 CEST [ChannelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
Error: got unexpected status: BAD_REQUEST -- error validating channel creation transaction for new channel 'mychannel', could not succesfully apply update to template configuration: error authorizing update: error validating ReadSet: existing config does not contain element for [Group]
/Channel/Application/Org1MSP but was in the read set
In the orderer terminal, subsequently:
2019-10-01 12:51:11.958 CEST [orderer.common.broadcast] ProcessMessage -> WARN 015 [channel: mychannel] Rejecting broadcast of config message from 127.0.0.1:48526 because of error: error validating channel creation transaction for new channel 'mychannel', could not successfully apply update to template configuration: error authorizing update: error validating ReadSet: existing config does not contain element for [Group]
/Channel/Application/Org1MSP but was in the read set
2019-10-01 12:51:11.958 CEST [comm.grpc.server] 1 -> INFO016 streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Broadcast grpc.peer_address=127.0.0.1:48526 grpc.code=OK grpc.call_duration=1.14698ms
2019-10-01 12:51:11.961 CEST [comm.deliver] Handle ->WARN017 Error reading from 127.0.0.1:48524: rpc error: code = Canceled desc = context canceled
2019-10-01 12:51:11.961 CEST [comm.grpc.server] 1 -> INFO 018 streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Deliver grpc.peer_address=127.0.0.1:48524 error="rpc error: code = Canceled desc = context canceled" grpc.code=Canceled grpc.call_duration=5.834477ms
Any help would be appreciated, I've tried all the solutions I've found online. Thank you in advance.
Edit
This is what I modified in orderer.yaml:
LocalMSPDir: /home/rfiorini/fabric-samples/first-network/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp
This is what I modified in core.yaml:
mspConfigPath: /home/rfiorini/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp

hyperledger : error creating a Channel Configuration Transaction

I have been following this link : http://hyperledger-fabric.readthedocs.io/en/latest/build_network.html#troubleshoot for starting my first network, using byfn.sh file, and have executed all steps till
export CHANNEL_NAME=mychannel && ../bin/configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME
The error that I am getting is:
himani#himani-HP-Notebook:~/fabric-samples/first-network$ export CHANNEL_NAME=mychannelthis && ../bin/configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME2018-06-07 11:42:00.552 IST [common/tools/configtxgen] main -> INFO 001 Loading configuration
2018-06-07 11:42:00.560 IST [common/tools/configtxgen] doOutputChannelCreateTx -> INFO 002 Generating new channel configtx
2018-06-07 11:42:00.560 IST [msp] getMspConfig -> INFO 003 Loading NodeOUs
2018-06-07 11:42:00.561 IST [msp] getMspConfig -> INFO 004 Loading NodeOUs
2018-06-07 11:42:00.579 IST [common/tools/configtxgen] main -> CRIT 005 Error on outputChannelCreateTx: config update generation failure: could not parse application to application group: setting up the MSP manager failed: the supplied identity is not valid: x509: certificate signed by unknown authority (possibly because of "x509: ECDSA verification failure" while trying to verify candidate authority certificate "ca.org1.example.com")
I have tried variations of the command,
export CHANNEL_NAME=mychannelanother && ../bin/configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME
export CHANNEL_NAME=mychannelanother && ../bin/configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $mychannelanother
export CHANNEL_NAME=mychannel && ../bin/configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $mychannel
I even tried creating a channel without using byfn.sh file, but got a different error
himani#himani-HP-Notebook:~/fabric-samples/first-network$ peer channel create -o orderer.example.com:7050 -c mychannel -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
No command 'peer' found, did you mean:
Command 'pear' from package 'php-pear' (main)
Command 'pee' from package 'moreutils' (universe)
Command 'peet' from package 'pipexec' (universe)
Command 'beer' from package 'gerstensaft' (universe)
peer: command not found
himani#himani-HP-Notebook:~/fabric-samples/first-network$ peer channel create -o orderer.example.com:7050 -c mychannelthis -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
No command 'peer' found, did you mean:
Command 'pear' from package 'php-pear' (main)
Command 'pee' from package 'moreutils' (universe)
Command 'beer' from package 'gerstensaft' (universe)
Command 'peet' from package 'pipexec' (universe)
peer: command not found
I modified the /home/himani/fabric-samples/first-network/crypto-config/ordererOrganizations/example.com/tlsca/tlsca.example.com-cert.pem doc by referring to this link : https://gerrit.hyperledger.org/r/#/c/18177/ , and executed the command again, but to no avail.
Are my certificates outdated? Where can I find the right ones? Is the issue something else?
UPDATE:
After referring to a solution provided to a similar problem, Hyperledger Fabric v1.1.0 byfn tutorial on Ubuntu 16.04, I brought down my network and tried to clean up artifacts but I couldn't execute those commands. Channel artifacts folder is empty.
I couldn't execute those commands
This command is meant to add files in channel-artifacts folder, but for some reason the folder was not created automatically. On creating one, with adequate permissions, the command executed and genesis block was created.
I don't know if you have solved it or not, but there are some mistakes there.
himani#himani-HP-Notebook:~/fabric-samples/first-network$ export CHANNEL_NAME=mychannelthis && ../bin/configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME2018-06-07 11:42:00.552 IST [common/tools/configtxgen] main -> INFO 001 Loading configuration
2018-06-07 11:42:00.560 IST [common/tools/configtxgen] doOutputChannelCreateTx -> INFO 002 Generating new channel configtx
2018-06-07 11:42:00.560 IST [msp] getMspConfig -> INFO 003 Loading NodeOUs
2018-06-07 11:42:00.561 IST [msp] getMspConfig -> INFO 004 Loading NodeOUs
2018-06-07 11:42:00.579 IST [common/tools/configtxgen] main -> CRIT 005 Error on outputChannelCreateTx: config update generation failure: could not parse application to application group: setting up the MSP manager failed: the supplied identity is not valid: x509: certificate signed by unknown authority (possibly because of "x509: ECDSA verification failure" while trying to verify candidate authority certificate "ca.org1.example.com")
if you are following the tutorial, CHANNEL_NAME should be mychannel.
for the 3rd variations, it should be like this
export CHANNEL_NAME=mychannel && ../bin/configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME
for creating channel, peer channel create can only be send inside docker container.
If you are sending directly from command line, try this
docker exec -it yourCliContainerName peer channel create -o orderer.example.com:7050 -c mychannelthis -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
but remember to start the container first.
hope this helps

Error trying to instantiate composer runtime. Error: No valid responses from any peers. for Multi organization hyperledger fabric 1.1

I am trying to setup hyperledger fabric + composer setup with multi organizations locally. The steps I followed to setup hyperledger network is below.
Generate crypto materials and channel
cryptogen generate --config=./crypto-config.yaml configtxgen -profile
OrdererGenesis -outputBlock ./channel-artifacts/genesis.block
configtxgen -profile Channel -CreateChannelTx
./channel-artifacts/channel.tx -channelID ehrchannel
configtxgen -profile Channel -outputAnchorPeersUpdate ./channel-artifacts/Hospital1MSPanchors.tx -channelID ehrchannel -asOrg Hospital1MSP
configtxgen -profile Channel -outputAnchorPeersUpdate ./channel-artifacts/Hospital2MSPanchors.tx -channelID ehrchannel -asOrg Hospital2MSP
Start docker containors for two organisations
Execute Below commands on cli containor
peer channel create -o orderer.ehr.com:7050 -c ehrchannel -f ./channel-artifacts/channel.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/ehr.com/orderers/orderer.ehr.com/msp/tlscacerts/tlsca.ehr.com-cert.pem
Having all peers join the channel with setting appropriate env veriables
- peer channel join -b ehrchannel.block
Updating anchor peers for two organisations by setting env variables
peer channel update -o orderer.ehr.com:7050 -c ehrchannel -f ./channel-artifacts/Hospital1MSPanchors.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/ehr.com/orderers/orderer.ehr.com/msp/tlscacerts/tlsca.ehr.com-cert.pem
After that I have followed Hyperledger composer document to configure composer.
But on step 17 on the doc, I am getting an error
composer network start -c PeerAdmin#ehr-network-hos1 -a marbles-network.bna -o endorsementPolicyFile=/tmp/composer/endorsement-policy.json -A admin1 -C admin2/admin-pub.pem -A admin2 -C admin2/admin-pub.pem
Starting business network from archive: marbles-network.bna
Business network definition:
Identifier: marbles-network#0.1.14
Description: Marble Trading Network
Processing these Network Admins:
userName: admin1
userName: admin2
✖ Starting business network definition. This may take a minute...
Error: Error trying to instantiate composer runtime. Error: No valid responses from any peers.
Response from attempted peer comms was an error: Error: 2 UNKNOWN: chaincode error (status: 500, message: cannot get package for chaincode (marbles-network:0.18.2))
Response from attempted peer comms was an error: Error: 2 UNKNOWN: chaincode error (status: 500, message: cannot get package for chaincode (marbles-network:0.18.2))
Response from attempted peer comms was an error: Error: 2 UNKNOWN: chaincode error (status: 500, message: cannot get package for chaincode (marbles-network:0.18.2))
Response from attempted peer comms was an error: Error: 2 UNKNOWN: chaincode error (status: 500, message: cannot get package for chaincode (marbles-network:0.18.2))
Command failed
What are the potential issues? Thank you so much in advance.
What versions of Composer and Fabric are you using ? If you are using Composer v0.18.2 you need to have the GA version of Fabric v1.1.
The releases document for Composer details the compatible versions of Composer and Fabric. https://github.com/hyperledger/composer/releases
Also you might have a typo in your command ... -A admin1 -C admin2/admin-pub.pem -A admin2 -C admin2/admin-pub.pem are you specifying the wrong folder for admin1 ?
Check fabric node logs to find clue:
docker logs [orderer/peer/...]

Hyperledger Fabric v1.1.0 byfn tutorial on Ubuntu 16.04

root#sungil:~/fabric-samples/first-network# export CHANNEL_NAME=mychannel
root#sungil:~/fabric-samples/first-network# ../bin/configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME
2018-03-19 13:11:51.489 KST [common/tools/configtxgen] main -> INFO 001 Loading configuration
2018-03-19 13:11:51.494 KST [common/tools/configtxgen] doOutputChannelCreateTx -> INFO 002 Generating new channel configtx
2018-03-19 13:11:51.495 KST [msp] getMspConfig -> INFO 003 Loading NodeOUs
2018-03-19 13:11:51.495 KST [msp] getMspConfig -> INFO 004 Loading NodeOUs
2018-03-19 13:11:51.510 KST [common/tools/configtxgen] main -> CRIT 005 Error on outputChannelCreateTx: config update generation failure: could not parse application to application group: setting up the MSP manager failed: the supplied identity is not valid: x509: certificate signed by unknown authority (possibly because of "x509: ECDSA verification failure" while trying to verify candidate authority certificate "ca.org2.example.com")
I installed hyperledger fabric v1.1.0-rc1 using byfn.sh.
(Reference:
http://hyperledger-fabric.readthedocs.io/en/lastest/build_network.html)
But I got some failure. It's Fabric CA problem?
[executed]
./byfn.sh -m generate
./byfn.sh -m up
../bin/cryptogen generate --config=./crypto-config.yaml
export FABRIC_CFG_PATH=$PWD
../bin/configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block
export CHANNEL_NAME=mychannel
./bin/configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME
my configtx.yaml is https://github.com/hyperledger/fabric-samples/blob/release-1.1/first-network/configtx.yaml
I faced a similar issue. What helped me was to start over.
Bring down the network: ./byfn.sh -m down
Clean up the generated artifacts
rm crypto-config
rm channel-artifacts
Then issue again the commands. This helped me, the channel.tx and other were successfully created. No need to change the configtx.yaml from the sample.
You don't have to delete files you just need to make sure that ./byfn.sh -m down was executed prior to steps in Crypto Generator section

Resources