confusion on setting fabric path - couchdb

I am trying to run this command
peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C mychannel -n ledger -c '{"Args":["CreateAsset","asset1","blue","5","tom","35"]}'
And i get this error
Fatal error when initializing core config : Could not find config file. Please make sure that FABRIC_CFG_PATH is set to a path which contains core.yaml
I am following this tutorial https://hyperledger-fabric.readthedocs.io/en/release-2.2/couchdb_tutorial.html#enable-couchdb-in-hyperledger-fabric and i am confused about where i did wrong.
my core.yml file is set into this location
core.png
I didnt change anything so far.

My path were at this folder. So i fixed it with this command.
ricky#rr:~/fabric/fabric-samples/test-network$ export PATH=${PWD}/../bin:$PATH
ricky#rr:~/fabric/fabric-samples/test-network$ export FABRIC_CFG_PATH=$PWD/../config/

Related

failed to load certificates while trying to create channel following Hyperledger Fabric 'First Network' Tutorial

I am following the tutorial on Windows 10 pro and have come across no other issues. I can even run ./byfn.sh up successfully.
When following the rest of the tutorial and trying to create a channel with:
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
I get the following error:
*Failed loading OrdererOU certificate at
[/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin#org1.example.com/msp/cacerts\ca.org1.example.com-cert.pem]: [could not read file /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin#org1.example.com/msp/cacerts\ca.org1.example.com-cert.pem: open /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin#org1.example.com/msp/cacerts\ca.org1.example.com-cert.pem: invalid argument]*
The error seems to be coming from the '\' in '\ca.org1.example.com-cert.pem'.
This seems to be an issue with linux system paths mixed with windows system paths but im not sure how I should go about modifying the path manually as I can not find any configuration that tells Fabric where to look for the certificates.
I ran into the same issue on my current project and I'm guessing this is an issue with Cryptogen tool (on a previous project, it wasn't happening)
To fix this i'm using this command:
find ./crypto-config -type f -name "config.yaml" -exec sed -i 's/\\/\//g' {} \;
The command look for all 'config.yaml' file in the subfolders of the crypto-config folder and replace all '\' to '/'
The error doesn't happen when i'm generating the certificates using the default crypto-config.yaml of the first-network sample.
I don't know why this is happening when crypto-config.yaml is modified.

how can I find policies hyperledger fabric on service without configtx?

I want to know polcies without configtx.yaml when hyperledger server is running. Because, I want to test how the permissions change as each layer of policy changes.
Is there any peer command for finding policies?
You should be able to use peer channel fetch config command. Something similar to:
peer channel fetch config myconfig.pb -o <my-orderer-and-port> -c <my-channel-name> --tls --cafile ordercafile.tls
This will return you a Protobuf file (myconfig.pb) and you can decode this into json using the configxlator command (you may need to download this binary as part of the fabric binaries). For example:
configtxlator proto_decode --input myconfig.pb --type common.Block --output ./myconfig.json
This will be a long JSON file but you might be able to use diff between versions and see if your changes have been applied.

How to configure a peer as admin peer in Hyperledger fabric network?

I have setup the fabric network on local machine , when I am trying to create a new channel using this command:
./peer channel create -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/channel.tx --tls --cafile /home/appinventiv/binaries/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
I get this error :
/Channel/Application not satisfied: Failed to reach implicit threshold of 1 sub-policies, required 1 remaining
and orderer debug logs shows this :
Evaluation Failed: Only 0 policies were satisfied, but needed 1 of [ Org2MSP.Admins Org1MSP.Admins ]
so I guess, peer has to be the Admin to create a channel.
Please correct me if I am wrong.
Have you set the environment variables to the correct values?
I'd recommend creating a .sh file and exporting everything from there, for example:
export CORE_PEER_ID=peer1
export CORE_PEER_FILESYSTEMPATH="./ledgers/peer1/ledger"
export CORE_PEER_MSPCONFIGPATH="$PWD/../fabric-ca/client/org1/admin/msp"
export CORE_PEER_LOCALMSPID=OrgMSP
export CORE_PEER_LISTENADDRESS=0.0.0.0:7051
export CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:7052
export CORE_PEER_EVENTS_ADDRESS=0.0.0.0:7053
export FABRIC_CFG_PATH="$PWD"
You should set up those with your values, since I may have a different setup and then run: (With the dot in front of ./ too)
. ./setEnv.sh

define the path to the chaincode hyperledger-fabric

I'am trying to change the change code for the hyperledger fabric "first-network", I want to put an other one.
Ididn't find where to define it and what to change.
I know that i have to change the name and put the path to the new chaincode, but i didn't find where
You can find that in docker-compose files folder chaincode (fabric-samples/chaincode) is mounted to /opt/gopath/src/github.com/chaincode
and in the script.sh variable CC_SRC_PATH is set to github.com/chaincode/chaincode_example02/go/ , so if you want to use your own chaincode in the first-network solution you should put it to folder chaincode and set up CC_SRC_PATH
this varibles is used in utils.sh file
peer chaincode install -n mycc -v ${VERSION} -l ${LANGUAGE} -p ${CC_SRC_PATH} >&log.txt

Create and join channel error ; Hypereldger fabric tutorial

I'm trying to a tutorial of hyperledger fabric on Mac. (http://hyperledger-fabric.readthedocs.io/en/latest/build_network.html#create-join-channel)
At 'Create & Join Channel' part, I have 2 questions.
1.I typed export CHANNEL_NAME=mychannel, but there is apparently no change. What does this command mean?
2.And later, I typedpeer 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 , the following error occurred. What if I do, the problem will be resolved?(There seems to be no such directory, so do I have to create? )
[main] main -> ERRO 001 Cannot run peer because cannot init crypto, missing /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin#org1.example.com/msp folder
Accordingly, I use Mac and installed all of the guided resources yesterday or day before yesterday, so I think resource version is correct.
I'd appreciate if you could answer these questions.
Question 1: export CHANNEL_NAME=mychannel Sets the CHANNEL_NAME variable to "mychannel".
Following that tutorial you linked, this just sets the variable ($CHANNEL_NAME) they have in their command:
peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME
However, you are right when you say changing that does nothing because you have hardcoded "mychannel" in your peer channel create command. Both your way and the tutorial way will have the same end result.
Question 2: The directory below points to where the peer certificates for the MSP are supposed to be, in your example. These files are generated with the ../bin/cryptogen generate --config=./crypto-config.yaml command from the tutorial. The error message is saying that the peer is unable to start due to that directory not existing, or containing the needed certs. I would ensure the peer container has those certs in that location, one way would be to Docker exec into it.
/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin#org1.example.com/msp

Resources