Hyperledge Composer publish definitions failed - hyperledger-composer

This is not a duplicates, at least I have the right version of Composer, I have also read the 3 stackflow composer questions.
I tried to publish definition, the Basic-Sample-Network package came from the git respository, the Basic-sample-network.bna archive file, here's the command :
composer network deploy -p hlfv1.json -a basic-sample-network.bna -i admin -s adminpw
The error (seems to be a generic error message):
Identifier: basic-sample-network#0.1.3
Description: The Hello World of Hyperledger Composer samples
events.js:160
throw er; // Unhandled 'error' event
^
Error: event message must be properly signed by an identity from the same organization as the peer: [failed deserializing event creator: [Expected MSP ID Org1MSP, received ]]
at ClientDuplexStream._emitStatusIfDone (/usr/local/lib/node_modules/composer-cli/node_modules/grpc/src/node/src/client.js:189:19)
at ClientDuplexStream._receiveStatus (/usr/local/lib/node_modules/composer-cli/node_modules/grpc/src/node/src/client.js:169:8)
at /usr/local/lib/node_modules/composer-cli/node_modules/grpc/src/node/src/client.js:634:14
Here're my environments :
composer -v :
composer-cli v0.10.0
composer-admin v0.10.0
composer-client v0.10.0
composer-common v0.10.0
composer-runtime-hlf v0.10.0
composer-runtime-hlfv1 v0.10.0
npm c 3.10.10
hlfv1.json profile :
{
"type": "hlfv1",
"orderers": [
{ "url" : "grpc://localhost:7050" }
],
"ca": { "url": "http://localhost:7054",
"name": "ca.org1.example.com"
},
"peers": [
{
"requestURL": "grpc://localhost:7051",
"eventURL": "grpc://localhost:7053"
}
],
"keyValStore": "${HOME}/.composer-credentials",
"channel": "composerchannel",
"mspID": "Org1MSP",
"timeout": "300"
}
Note I used the fabric-tool script the start the fabric and to generate the profile (hlfv1.json).
docker ps:
570ae25a586e hyperledger/fabric-peer:x86_64-1.0.0 "peer node start -..." 30 minutes ago Up 30 minutes 0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp peer0.org1.example.com
513431e5d217 hyperledger/fabric-ca:x86_64-1.0.0 "sh -c 'fabric-ca-..." 31 minutes ago Up 31 minutes 0.0.0.0:7054->7054/tcp ca.org1.example.com
2e7bf444481d hyperledger/fabric-couchdb:x86_64-1.0.0 "tini -- /docker-e..." 31 minutes ago Up 31 minutes 4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp couchdb
5d5ba67cc602 hyperledger/fabric-orderer:x86_64-1.0.0 "orderer" 31 minutes ago Up 30 minutes 0.0.0.0:7050->7050/tcp orderer.example.com

If you follow the developer tutorial you will see that the id PeerAdmin must be used to deploy the network.
https://hyperledger.github.io/composer/tutorials/developer-guide.html

Problem fixed.
The confusion was providing the connectionProfileName, the -p option, based on reading the document, I thought I have to provide a file with connection information (even thought the provided profile information contain all necessary information), I didn't know it was actually picking up the profile file from ~/.composer-connection-profiles folder based on the name provided in the -p option.

Related

Error starting hyperledger-composer network after Fabric and Composer version upgrade

I've come across an error starting the hyperledger-composer network that isn't answered in the composer-wiki.
✖ Starting business network definition. This may take a minute...
Error: Error trying to start business network. Error: No valid responses from any peers.
Response from attempted peer comms was an error: Error: transaction returned with failure: can't find PEM header: undefined
Command failed
Checking pre-requisites,
Fabric 1.2
Composer 0.20.4
Node 8.12.0
Docker 18.01.1
"composer network install" was successful, with file appearing in the docker peer at /var/hyperleder/production/chaincodes
After running the "composer network start" command, a "docker ps" shows new docker instance with name:
dev-peer0.org1.example.com-<<business-network-name>>-0.0.7
But any attempt to ping this results in a failure like this:
Error: Error trying to ping. Error: make sure the chaincode <<business-network-name>> has been successfully instantiated and try again: getccdata composerchannel/<<business-network-name>> responded with error: could not find chaincode with name '<<business-network-name>>'
Checking the log of the dev-peer0, it ends with the following:
2018-11-05T05:03:18.227Z [4264161f] ERROR :Composer :Init() can't find PEM header: undefined
2018-11-05T05:03:18.227Z [4264161f] VERBOSE :Composer :#PERF Init() Total (ms) duration for txnID [4264161fc30a61c70884d4c7efb460fea6a755d07bc4852875c393346795227a]: 929.00
2018-11-05T05:03:18.228Z ERROR [lib/handler.js] [composerchannel-4264161f]Calling chaincode Init() returned error response [can't find PEM header: undefined]. Sending ERROR message back to peer
The corresponding error in the peer0 log is a big larger:
2018-11-05 05:03:18.229 UTC [endorser] SimulateProposal -> ERRO 439d [composerchannel][4264161f] failed to invoke chaincode name:"lscc" , error: transaction returned with failure: can't find PEM header: undefined
github.com/hyperledger/fabric/core/chaincode.(*ChaincodeSupport).Execute
/opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/chaincode_support.go:202
github.com/hyperledger/fabric/core/endorser.(*SupportImpl).Execute
/opt/gopath/src/github.com/hyperledger/fabric/core/endorser/support.go:131
github.com/hyperledger/fabric/core/endorser.(*Endorser).callChaincode
/opt/gopath/src/github.com/hyperledger/fabric/core/endorser/endorser.go:173
github.com/hyperledger/fabric/core/endorser.(*Endorser).SimulateProposal
/opt/gopath/src/github.com/hyperledger/fabric/core/endorser/endorser.go:287
github.com/hyperledger/fabric/core/endorser.(*Endorser).ProcessProposal
/opt/gopath/src/github.com/hyperledger/fabric/core/endorser/endorser.go:501
github.com/hyperledger/fabric/core/handlers/auth/filter.(*expirationCheckFilter).ProcessProposal
/opt/gopath/src/github.com/hyperledger/fabric/core/handlers/auth/filter/expiration.go:61
github.com/hyperledger/fabric/core/handlers/auth/filter.(*filter).ProcessProposal
/opt/gopath/src/github.com/hyperledger/fabric/core/handlers/auth/filter/filter.go:31
github.com/hyperledger/fabric/protos/peer._Endorser_ProcessProposal_Handler
/opt/gopath/src/github.com/hyperledger/fabric/protos/peer/peer.pb.go:112
github.com/hyperledger/fabric/vendor/google.golang.org/grpc.(*Server).processUnaryRPC
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/server.go:923
github.com/hyperledger/fabric/vendor/google.golang.org/grpc.(*Server).handleStream
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/server.go:1148
github.com/hyperledger/fabric/vendor/google.golang.org/grpc.(*Server).serveStreams.func1.1
/opt/gopath/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/server.go:637
runtime.goexit
/opt/go/src/runtime/asm_amd64.s:2361
2018-11-05 05:03:18.229 UTC [endorser] SimulateProposal -> DEBU 439e [composerchannel][4264161f] Exit
Since this last worked I have updated composer from 0.19 to 0.20.4, and taken Fabric from 1.1 to 1.2.
Googling suggests that this kind of error "can't find PEM header: undefined" is associated with a change in key signing. After tearing down Fabric I re-ran ./createPeerAdminCard.sh - is there another card or similar that needs to be re-created to accomodate the latest versions?
Thanks to #R Thatcher for putting me onto the right direction. This was all down to mismatching cards, and was resolved by clearing out everything and starting again.
Specifically, in /fabric-dev-servers:
./stopFabric.sh
./teardownFabric.sh
composer card list
composer card delete -c admin#<business-network-name>
composer card delete -c PeerAdmin#hlfv1
./startFabric.sh
./createPeerAdminCard.sh
Then changing into the composer/business-network-name directory:
composer network install --card PeerAdmin#hlfv1 --archiveFile business-network-name\#0.0.7.bna
composer network start -c PeerAdmin#hlfv1 -n business-network-name -V 0.0.7 -A admin -S adminpw --file networkadmin.card
composer card import --file networkadmin.card --card admin#business-network-name
composer network ping -c admin#business-network-name
So yes, it was about mismatching cards and not cleaning these up as part of a new deployment.
Although not part of the original problem, it's also worth noting that the -A and -S parameters of the composer network start command HAD to be set to admin and adminpw respectively. See composer issue #3781.
Answering the the last remark from #Capn Sparrow
"the -A and -S parameters of the composer network start command HAD to be set to admin and adminpw respectively."
This is the correct and expected behaviour :-)
with the composer network start command the -A and -S are specifying an existing user in the CA that we want a new set of Credentials (certificate and keys) for which is then bound to a Composer System participant.
When you use the 'standard development fabric' this has a CA configured with a user called 'admin' with a secret of 'adminpw'. If you had build your own Fabric from scratch you could choose the name and secret of your first default user. Alternatively you could work with the fabric-ca client software to create additional users in the CA.

Error running query from hyperledger composer Queries tutorial against couchdb Fabric runtime

I am trying to connect the dots between Composer and Fabric to build a proof of concept application that supports multiple orgs. So, I am using the Composer tutorials to build the business network and then the "Deploying to a multi-organization business network" tutorial (which references the Fabric "Build your first network" tutorial, but tells you to use a different git repo than the BYFN tutorial, which I did).
I was able to use the Developer tutorial from Composer to build the simple trade business network, and then copy the archive to the folder where I built out the multi-org business network with Fabric (which requires couchdb, which I'd want to use anyway in order to be able to do more complex querying), start it all up and then use the explorer REST API to create participants, assets, and trade transactions. This all worked fine.
Then, I moved onto the Composer Queries tutorial to add the queries.qry, generate a new archive, copied & updated the fabric install of the archive, stopped & updated & restarted the REST API server. I can see the queries in the REST API now so I know it has picked up the new code. However, regardless of which of the queries I try to run through the REST API explorer, they all return the same error:
{
"error": {
"statusCode": 500,
"name": "Error",
"message": "Error trying to query business network. Error: chaincode error (status: 500, message: Error: Couch DB Error:invalid_operator, Status Code:400, Reason:Invalid operator: $class)",
"stack": "Error: Error trying to query business network. Error: chaincode error (status: 500, message: Error: Couch DB Error:invalid_operator, Status Code:400, Reason:Invalid operator: $class)\n at channel.queryByChaincode.then.catch (/usr/local/lib/node_modules/composer-rest-server/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:809:34)\n at <anonymous>"
}
}
The simplest of the queries from the tutorial is a simple get all with no arguments, so the problem can't be what I'm passing in (as there is literally nothing to pass in). The problem has to be something systemic.
Example: the get all commodities query
query selectCommodities {
description: "Select all commodities"
statement:
SELECT org.acme.biznet.Commodity
}
The error message says it doesn't like $class in the response.
The response from the GET all commodities endpoint (which doesn't use the query) is:
[
{
"$class": "org.acme.biznet.Commodity",
"tradingSymbol": "KPX",
"description": "KnitPicks",
"mainExchange": "SP",
"quantity": 50,
"owner": "resource:org.acme.biznet.Trader#4567"
},
{
"$class": "org.acme.biznet.Commodity",
"tradingSymbol": "KPX2",
"description": "KnitPicks",
"mainExchange": "SP",
"quantity": 120,
"owner": "resource:org.acme.biznet.Trader#4567"
}
]
and the API doc for the selectCommodities query sample response is of the same format:
[
{
"$class": "org.acme.biznet.Commodity",
"tradingSymbol": "string",
"description": "string",
"mainExchange": "string",
"quantity": 0,
"owner": {}
}
]
so I am not sure what is wrong, but it seems like it would have to be either a problem with the query itself not being compatible with CouchDB, or a problem in the translation layer from the query in Composer to the low level Fabric API? The latter theory is supported by the 500 being returned by the Composer API layer having a nested 400 error, implying that something that the Composer layer through hlfconnection is passing is invalid.
Any help is greatly appreciated! I can't imagine I'm the first to run across this but I haven't found anything online that's directly related.
Thanks in advance!
Composer version 0.16.6
Docker PS:
f844a2957bd5 dev-peer0.org2.example.com-tutorial-network-0.16.6-95a0f8a4fe6ff659a5943abc80b26a1134e77b74942eef102fa92c8480b680eb "chaincode -peer.add…" 24 hours ago Up 24 hours dev-peer0.org2.example.com-tutorial-network-0.16.6
556c9f3841ce dev-peer0.org1.example.com-tutorial-network-0.16.6-e4f751b9b8b3a307f6bf25ea97ccf3625bd75730a1dcb3f989a9a34bbb73f536 "chaincode -peer.add…" 24 hours ago Up 24 hours dev-peer0.org1.example.com-tutorial-network-0.16.6
831ca5b9a839 dev-peer1.org2.example.com-tutorial-network-0.16.6-a184efa69bdcbcb2e6ec3764e01d56f0c574ca0ad09d4656269d3b7aefbc44b8 "chaincode -peer.add…" 24 hours ago Up 24 hours dev-peer1.org2.example.com-tutorial-network-0.16.6
6faf5b875df9 dev-peer1.org1.example.com-tutorial-network-0.16.6-44b9f2a6ea1ed75f106aa0b5fc8387c95cbde9eee551df9fb36d16709f2db981 "chaincode -peer.add…" 24 hours ago Up 24 hours dev-peer1.org1.example.com-tutorial-network-0.16.6
afbcbe9292fd dev-peer1.org2.example.com-mycc-1.0-26c2ef32838554aac4f7ad6f100aca865e87959c9a126e86d764c8d01f8346ab "chaincode -peer.add…" 26 hours ago Up 26 hours dev-peer1.org2.example.com-mycc-1.0
8444f922486d dev-peer0.org1.example.com-mycc-1.0-384f11f484b9302df90b453200cfb25174305fce8f53f4e94d45ee3b6cab0ce9 "chaincode -peer.add…" 26 hours ago Up 26 hours dev-peer0.org1.example.com-mycc-1.0
753588bacb47 dev-peer0.org2.example.com-mycc-1.0-15b571b3ce849066b7ec74497da3b27e54e0df1345daff3951b94245ce09c42b "chaincode -peer.add…" 26 hours ago Up 26 hours dev-peer0.org2.example.com-mycc-1.0
662b61c00673 hyperledger/fabric-peer "peer node start" 26 hours ago Up 26 hours 0.0.0.0:10051->7051/tcp, 0.0.0.0:10053->7053/tcp peer1.org2.example.com
80a37822a0d6 hyperledger/fabric-peer "peer node start" 26 hours ago Up 26 hours 0.0.0.0:8051->7051/tcp, 0.0.0.0:8053->7053/tcp peer1.org1.example.com
2878eacafb29 hyperledger/fabric-peer "peer node start" 26 hours ago Up 26 hours 0.0.0.0:9051->7051/tcp, 0.0.0.0:9053->7053/tcp peer0.org2.example.com
e8f3259dca2a hyperledger/fabric-peer "peer node start" 26 hours ago Up 26 hours 0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp peer0.org1.example.com
a79c29e762cd hyperledger/fabric-couchdb "tini -- /docker-ent…" 26 hours ago Up 26 hours 4369/tcp, 9100/tcp, 0.0.0.0:6984->5984/tcp couchdb1
34271122957a hyperledger/fabric-couchdb "tini -- /docker-ent…" 26 hours ago Up 26 hours 4369/tcp, 9100/tcp, 0.0.0.0:8984->5984/tcp couchdb3
8b88227ea7a7 hyperledger/fabric-ca "sh -c 'fabric-ca-se…" 26 hours ago Up 26 hours 0.0.0.0:7054->7054/tcp ca_peerOrg1
a75fa6328b02 hyperledger/fabric-ca "sh -c 'fabric-ca-se…" 26 hours ago Up 26 hours 0.0.0.0:8054->7054/tcp ca_peerOrg2
4e21c3c8fa16 hyperledger/fabric-orderer "orderer" 26 hours ago Up 26 hours 0.0.0.0:7050->7050/tcp orderer.example.com
2881999a4c7b hyperledger/fabric-couchdb "tini -- /docker-ent…" 26 hours ago Up 26 hours 4369/tcp, 9100/tcp, 0.0.0.0:7984->5984/tcp couchdb2
8a77a5e86a3a hyperledger/fabric-couchdb "tini -- /docker-ent…" 26 hours ago Up 26 hours 4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp couchdb0
This is probably due to a match of Composer version (16.x) to versions of Fabric (1.1). Composer 0.16.x ONLY works with Fabric v1.0.x (you can check from your logs / docker images what you installed). The release notes detail which versions of composer will work with which versions of fabric. eg
https://github.com/hyperledger/composer/releases
Composer v0.18.2 and above is compatible with Fabric 1.1 GA only
Composer v0.18.0 -> v0.18.1 : compatible with the Fabric 1.1 RC1 driver only
Composer v0.17.3 -> v0.17.6 (old) are compatible with Fabric 1.1 alpha driver only
Composer v0.16.x -> compatible with Fabric v1.0.x only

Unable to issue identity with fabric composer

I successfully deployed a business network to hlfv1 beta and am now trying to issue an identity for a participant but receive the following error:
composer identity issue -p hlfv1 -n 'manumachines-network'
-i Org1PeerAdmin -s DJY27pEnl16d -u dxid1 -a "org.acme.manumachinesnetwork.Designer#designer-X#email.
com"
Error: fabric-ca request register failed with errors [[{"code":400,"message":"Authorization failure"}]
]
Command failed.
Using LoopBack, I know that the participant is on the Blockchain:
[
{
"$class": "org.acme.manumachinesnetwork.Designer",
"email": "designer-X#email.com"
},
{
"$class": "org.acme.manumachinesnetwork.Designer",
"email": "designer-Y#email.com"
},
{
"$class": "org.acme.manumachinesnetwork.Designer",
"email": "designer-Z#email.com"
}
]
I figured it out - in the issue identity cli command you must use the id and password of the CA which is found in the:
fabric-tools/fabric-scripts/hlfv1/composer/crypto-config/docker-compose.yml file which is admin and adminpw.
I was erroneously trying to use the admin identity that I had registered as the prerequisite for deploying the network definition.

Getting deployment error when deploying sample script in Developer composer playground

I'm trying to setup the development environment for composer by following the steps in the tutorial. I was able to generate the .bna file successfully and use it in the online playground. But when I try to deploy the .bna file to the fabric V1.0 running in my local, I get the below error.
ubuntu#ip-172-31-8-83:~/fabric-tools/my-network$ cd dist
ubuntu#ip-172-31-8-83:~/fabric-tools/my-network/dist$ composer network
deploy -a my-network.bna -p hlfv1 -i PeerAdmin -s randomString
Deploying business network from archive: my-network.bna
Business network definition:
Identifier: my-network#0.0.1
Description: The Hello World of Hyperledger Composer samples
events.js:160
throw er; // Unhandled 'error' event
^
Error: event message must be properly signed by an identity from the same organization as the peer: [failed deserializing event creator: [Expected MSP ID Org1MSP, received ]]
at ClientDuplexStream._emitStatusIfDone (/home/ubuntu/.nvm/versions/node/v6.11.0/lib/node_modules/composer-cli/node_modules/grpc/src/node/src/client.js:189:19)
at ClientDuplexStream._receiveStatus (/home/ubuntu/.nvm/versions/node/v6.11.0/lib/node_modules/composer-cli/node_modules/grpc/src/node/src/client.js:169:8)
at /home/ubuntu/.nvm/versions/node/v6.11.0/lib/node_modules/composer-cli/node_modules/grpc/src/node/src/client.js:634:14
My docker images are as follows:
ubuntu#ip-172-31-8-83:~/fabric-tools/my-network/dist$ docker ps -a
CONTAINER ID IMAGE COMMAND
CREATED STATUS PORTS
NAMES
80c9949edf73 hyperledger/fabric-peer:x86_64-1.0.0-beta "peer
node start -..." 19 minutes ago Up 19 minutes 0.0.0.0:7051-
>7051/tcp, 0.0.0.0:7053->7053/tcp peer0.org1.example.com
126f6381cc90 hyperledger/fabric-couchdb:x86_64-1.0.0-beta "tini --
/docker-e..." 19 minutes ago Up 19 minutes 4369/tcp, 9100/tcp,
0.0.0.0:5984->5984/tcp couchdb
924081546fa1 hyperledger/fabric-ca:x86_64-1.0.0-beta "sh -c
'fabric-ca-..." 19 minutes ago Up 19 minutes 0.0.0.0:7054-
>7054/tcp ca.example.com
d13f2c8e8421 hyperledger/fabric-orderer:x86_64-1.0.0-beta "orderer"
19 minutes ago Up 19 minutes 0.0.0.0:7050->7050/tcp
orderer.example.com
Node version is: 4.2.6
npm version is : 3.5.2
Docker version 17.06.0-ce, build 02c1d87
Can someone tell me how to resolve this?
you need to be at the latest Node level - you're currently at 4.2.6 - you need to be at node version 6.x
https://hyperledger.github.io/composer/unstable/installing/development-tools.html
I assume you're using Ubuntu 14.04 or 16.0x LTS ..

Setup Google cloud shell environment for Cloud ML

I am trying to setup a google cloud shell environment for my google cloud project that uses Cloud ML.
I am following the instructions on their setup page itself:
Getting Setup | Google Cloud Machine Learning
I executed this command in my cloud shell:
curl
https://raw.githubusercontent.com/GoogleCloudPlatform/cloudml-samples/master/tools/setup_cloud_shell.sh
| bash
The last part of ouput trace for this was :
echo 'Success! Your environment has the required tools and dependencies.' Success! Your environment has the required tools and
dependencies.
This command:
export PATH=${HOME}/.local/bin:${PATH}
Produces no ouput.
And finally the command to check the environment:
curl
https://raw.githubusercontent.com/GoogleCloudPlatform/cloudml-samples/master/tools/check_environment.py
| python
Produces this output:
vineetkaushik053#cloudshell:~$ curl https://raw.githubusercontent.com/GoogleCloudPlatform/cloudml-samples/master/tools/check_environment.py | python
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3814 100 3814 0 0 17274 0 --:--:-- --:--:-- --:--:-- 17257
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Your active configuration is: [cloudshell-11180]
ERROR: Unable to list Cloud ML models: {
"error": {
"code": 400,
"message": "Field: parent Error: Name should be in the form of 'projects/your-project-id'",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "parent",
"description": "Name should be in the form of 'projects/your-project-id'"
}
]
}
]
}
}
When it should be producing:
"Success! Your environment is configured correctly." when the script finishes successfully.
Please tell me how to resolve this so that I may move to the next part of the setup.
Resolved this.
Need to set the project for the environment. You can use this command:
gcloud config set project your-project-ID

Resources