Hyperledger - peer unable to instantiate chaincode after joining channel - hyperledger-fabric

I currently have a running Kafka-based hyperledger running on docker.
The full container list is as such:
2x orderer
2x peer
1x certificate-authority
3x zookeeper
4x kafka nodes
1x cli tools
I have sucessfully created a channel using cli by the following command
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/fabric/msp/users/Admin#company/msp" peer0.company peer channel create -o orderer0.company:7050 -c messagebus -f /etc/hyperledger/configtx/channel.tx
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/fabric/msp/users/Admin#company/msp" peer0.company peer channel join -b messagebus.block
I can see the peer is joined using the following command:
docker exec cli peer channel list
2019-01-07 16:54:41.784 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
Channels peers has joined:
messagebus
I then want to init and instantiate my chaincode as such
#install the chaincode
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/company/users/Admin#company/msp" cli peer chaincode install -n testnet -v 1.0 -p "$CC_SRC_PATH" -l "$LANGUAGE"
2019-01-07 16:46:23.154 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2019-01-07 16:46:23.154 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2019-01-07 16:46:23.615 UTC [chaincodeCmd] install -> INFO 005 Installed remotely response:<status:200 payload:"OK" >
#instantiate the chaincode
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/company/users/Admin#company/msp" cli peer chaincode instantiate -o orderer0.company:7050 -C messagebus -n testnet -l "$LANGUAGE" -v 1.0 -c '{"Args":[""]}' -P "OR ('Org1MSP.member','Org2MSP.member')"
2019-01-07 16:46:24.210 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2019-01-07 16:46:24.210 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
Error: error endorsing chaincode: rpc error: code = Unknown desc = access denied: channel [messagebus] creator org [Org1MSP]
As the final line shows, the access is denied to the channel.
I am also unable to join a Java SDK client to the channel and receive similar access denied errors.
I see the following logs in the peer0 container:
2019-01-07 16:46:23.611 UTC [endorser] callChaincode -> INFO 0f1 [][bfb2e2d4] Entry chaincode: name:"lscc"
2019-01-07 16:46:23.614 UTC [lscc] executeInstall -> INFO 0f2 Installed Chaincode [gmex] Version [1.0] to peer
2019-01-07 16:46:23.614 UTC [endorser] callChaincode -> INFO 0f3 [][bfb2e2d4] Exit chaincode: name:"lscc" (2ms)
2019-01-07 16:46:23.614 UTC [comm.grpc.server] 1 -> INFO 0f4 unary call completed {"grpc.start_time": "2019-01-07T16:46:23.61Z", "grpc.service": "protos.Endorser", "grpc.method": "ProcessProposal", "grpc.peer_address": "XXX.XXX.X.XXX:123", "grpc.code": "OK", "grpc.call_duration": "3.771114ms"}
2019-01-07 16:46:24.214 UTC [protoutils] ValidateProposalMessage -> WARN 0f5 channel [messagebus]: MSP error: 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.company")
this leads me to believe the peer is not correctly setup... however it is able to create the channel successfully.
Any pointers would be appreciated

Related

Resolving "proposal response was not successful" error in Hyperledger Fabric tutorial

I am running the Fabric sample 'fabcar' following this tutorial.
After running the startFabric.sh javascript command, I am getting this error:
Error: could not assemble transaction, err proposal response was not successful, error code 500, msg timeout expired while starting chaincode fabcar:1.0 for transaction
ubuntu#testvm1:~/fabric-samples/fabcar$ ./startFabric.sh javascript
# don't rewrite paths for Windows Git Bash users
export MSYS_NO_PATHCONV=1
docker-compose -f docker-compose.yml down
Removing network net_basic
docker-compose -f docker-compose.yml up -d ca.example.com
orderer.example.com peer0.org1.example.com couchdb
Creating ca.example.com ... done
Creating peer0.org1.example.com ... done
Creating orderer.example.com ...
Creating ca.example.com ...
Creating peer0.org1.example.com ...
# wait for Hyperledger Fabric to start
# incase of errors when running later commands, issue export
FABRIC_START_TIMEOUT=<larger number>
export FABRIC_START_TIMEOUT=10
#echo ${FABRIC_START_TIMEOUT}
sleep ${FABRIC_START_TIMEOUT}
# Create the channel
docker exec -e
"CORE_PEER_LOCALMSPID=Org1MSP"e"CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp
/users/Admin#org1.example.com/ms
p" peer0.org1.example.com peer channel create -o orderer.example.com:7050
-c mychannel -f /etc/hyperledger/configtx/channel.tx
2019-03-29 10:29:37.993 UTC [channelCmd] InitCmdFactory -> INFO 001
Endorser and orderer connections initialized
2019-03-29 10:29:38.034 UTC [cli.common] readBlock -> INFO 002 Received
block: 0
# Join peer0.org1.example.com to the channel.
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e
"CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#org1.example.com/m
sp" peer0.org1.example.com peer channel join -b mychannel.block
2019-03-29 10:29:38.267 UTC [channelCmd] InitCmdFactory -> INFO 001
Endorser and orderer connections initialized
2019-03-29 10:29:38.459 UTC [channelCmd] executeJoin -> INFO 002
Successfully submitted proposal to join channel
Creating cli ... done
2019-03-29 10:29:39.729 UTC [chaincodeCmd] checkChaincodeCmdParams ->
INFO 001 Using default escc
2019-03-29 10:29:39.729 UTC [chaincodeCmd] checkChaincodeCmdParams ->
INFO 002 Using default vscc
2019-03-29 10:29:39.767 UTC [chaincodeCmd] install -> INFO 003 Installed
remotely response:<status:200 payload:"OK" >
2019-03-29 10:29:39.982 UTC [chaincodeCmd] checkChaincodeCmdParams ->
INFO 001 Using default escc
2019-03-29 10:29:39.982 UTC [chaincodeCmd] check`enter code
here`ChaincodeCmdParams -> INFO 002 Using default vscc
Error: could not assemble transaction, err proposal response was not
successful, error code 500, msg timeout expired while starting chaincode
fabcar:1.0 for transaction

Instantiation of signed chaincode packages in Hyperledger Fabric

I am trying to apply the packaging method for the chaincode which enables me to enforce signatures from multiple organizations and make sure that chaincode cannot be effectively instantiated if signatures from relevant participants in the channel are not collected.
a) From Org1 context:
# peer chaincode package -n mycc -p github.com/chaincode/chaincode_example02/go/ -v 1 -s -S -i "AND('Org1.admin','Org2.admin')" ccpack.out
2018-12-03 22:49:46.032 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2018-12-03 22:49:46.032 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
root#bdc554f0a918:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode signpackage ccpack.out signedccpack.out
Wrote signed package to signedccpack.out successfully
root#bdc554f0a918:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode install signedccpack.out
2018-12-03 22:50:21.125 UTC [chaincodeCmd] install -> INFO 001 Installed remotely response:<status:200 payload:"OK" >
b) From Org2 context:
root#bdc554f0a918:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode signpackage ccpack.out signedccpack.out
Wrote signed package to signedccpack.out successfully
root#bdc554f0a918:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode install signedccpack.out
2018-12-03 22:50:32.414 UTC [chaincodeCmd] install -> INFO 001 Installed remotely response:<status:200 payload:"OK" >
c) From either Org context:
root#bdc554f0a918:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode instantiate -o orderer.example.com:7050 --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 -C channel1 -n mycc -v 1.0 -c '{"Args":["init","a", "100", "b","200"]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')"
2018-12-03 22:50:42.946 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2018-12-03 22:50:42.950 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
Error: could not assemble transaction, err proposal response was not successful, error code 500, msg cannot get package for chaincode (mycc:1.0)
d) The chaincode is present on Org1 Peer 1:
root#af99b3698322:/var/hyperledger/production/chaincodes# ls
mycc.1
e) The chaincode is present on Org2 Peer 1:
root#2fd1355259a8:/var/hyperledger/production/chaincodes# ls
mycc.1
Any recommendations as to the process or the cli syntax structure would be greatly appreciated.

Hyperledger Fabric: Error modifying example app from the docs

I got the "Write your First Application" stuff working great.
So I copied the files and renamed stuff to support a different chaincode app.
When I run startFabric.sh node (since my source is javascript), I eventually get:
# don't rewrite paths for Windows Git Bash users
export MSYS_NO_PATHCONV=1
docker-compose -f docker-compose.yml down
Removing network net_basic
WARNING: Network net_basic not found.
docker-compose -f docker-compose.yml up -d ca.example.com orderer.example.com peer0.org1.example.com couchdb
Creating network "net_basic" with the default driver
Creating couchdb
Creating orderer.example.com
Creating ca.example.com
Creating peer0.org1.example.com
# wait for Hyperledger Fabric to start
# incase of errors when running later commands, issue export FABRIC_START_TIMEOUT=<larger number>
export FABRIC_START_TIMEOUT=10
#echo ${FABRIC_START_TIMEOUT}
sleep ${FABRIC_START_TIMEOUT}
# Create the channel
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#org1.example.com/msp" peer0.org1.example.com peer channel create -o orderer.example.com:7050 -c mychannel -f /etc/hyperledger/configtx/channel.tx
2018-08-18 06:23:14.962 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2018-08-18 06:23:14.983 UTC [cli/common] readBlock -> INFO 002 Got status: &{NOT_FOUND}
2018-08-18 06:23:14.984 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-08-18 06:23:15.187 UTC [cli/common] readBlock -> INFO 004 Received block: 0
# Join peer0.org1.example.com to the channel.
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#org1.example.com/msp" peer0.org1.example.com peer channel join -b mychannel.block
2018-08-18 06:23:15.407 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2018-08-18 06:23:15.481 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
Creating cli
2018-08-18 06:23:16.314 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2018-08-18 06:23:16.314 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2018-08-18 06:23:16.316 UTC [container] WriteFolderToTarPackage -> INFO 003 rootDirectory = /opt/gopath/src/github.com/permissioned-jpgs/node
2018-08-18 06:23:16.353 UTC [chaincodeCmd] install -> INFO 004 Installed remotely response:<status:200 payload:"OK" >
2018-08-18 06:23:16.590 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2018-08-18 06:23:16.590 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
Error: endorsement failure during invoke. chaincode result: <nil>
Notice endorsement fails. Any ideas? I've checked everything I can think of and I'm completely stumped. Thanks!
My Docker ignorance is showing.
I just needed to view the logs for the peer node I was interacting with by doing: sudo docker logs -f dev-peer0.org1.example.com-fabcar-1.0
These logs showed me it was a problem with the Javascript I had written when customizing the chaincode, not a Fabric network config issue like I previously thought.

Error: Error getting chaincode code chaincode: <go, [env]>: failed with error: "exec: not started"

I have created hyperledger in azure blockchain and created fabric-ca, orderer and 2 peer nodes. I am able to create channel and 2 peers joined in the channel. I am not able to install chaincode. The commands are executed form Git bash. Getting below error while running the command from peer node. Please help...
root#d62e3aedc701:/# peer chaincode install -n balcc -v 1.0 -p Chaincode/fabric-samples/balance-transfer/artifacts/src/github.com/example_cc/go/
2018-05-25 05:32:42.702 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2018-05-25 05:32:42.702 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
Error: Error getting chaincode code chaincode: : failed with error: "exec: not started"
In my case, I just reinstall go and this problem fix.

Fail to instantiate the chaincode in first network of fabric-samples

The official hyperledger fabric v1.0.0 gives a simple demo by using docker.
What i am doing is to avoid docker and directly run them on the machine. Thanks to the answer from my previous question, I have successfully launched 1 solo orderer, two peers (each from one org), created and joined the channels from peers, installed the chaincode on two peers.
The client side's command to install chaincode is
peer chaincode install -n myC1 -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02
Both peers return the following message and I think it should be correct.
2017-09-11 16:34:26.361 SGT [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2017-09-11 16:34:26.361 SGT [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2017-09-11 16:34:26.556 SGT [main] main -> INFO 003 Exiting.....
However, when i try to instantiate the chaincode as follows
peer chaincode instantiate -o orderer.example.com:7040 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n myC1 -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P "OR ('Org1MSP.member','Org2MSP.member')
Client console returns the error message
2017-09-11 17:00:18.181 SGT [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2017-09-11 17:00:18.181 SGT [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
Error: Error endorsing chaincode: rpc error: code = Unknown desc = Failed to init chaincode(handler not found for chaincode myC1:1.0)
The console of Peer0.org2 gives NO error message. But Peer0.org1's console gives the following:
2017-09-11 17:00:18.183 SGT [chaincode] Launch -> ERRO 032 sending init failed(handler not found for chaincode myC1:1.0)
2017-09-11 17:00:18.184 SGT [endorser] simulateProposal -> ERRO 033 failed to invoke chaincode name:"lscc" on transaction a665c5305c5e3f158d272e4a39b04611e5335406e2a7c7057f11d32d8e07670e, error: Failed to init chaincode(handler not found for chaincode myC1:1.0)
Can any one help me to solve this problem and give me a simple explanation??

Resources