Chaincode Deployment Failed - linux

I am new to Hyperledger fabric. When I am trying to install the Chaincode, I am getting the below error :
Error: proposal failed with status: 500 - failed to invoke backing implementation of 'ApproveChaincodeDefinitionForMyOrg': attempted to redefine uncommitted sequence (1) for namespace marbles03 with unchanged content
Please shed a light on this.
Thank you

After doing some Googling, I found Nikhil Gupta's answer on the hyperledger.org site to be helpful.
This message states that you have already approved the chaincode definition as this org. The chaincode definition with sequence 1 has already been defined for that organization, and you cannot define the same sequence again.
Assuming that you are executing the peer lifecycle chaincode approvemyorg command, you have already approved the chaincode definition with sequence 1, and you cannot redefine it for this organization.

Related

asset-transfer-basic blows up with "SendTransaction failed: orderers is nil"

I am trying to run asset-transfer-basic sample program from hyperledger 2.2 (I am using the GO sample programs) My test network is up -- I am able to interact with it by doing "peer chaincode invoke" and exercising different contract methods -- including InitLedger.
However, when trying to run assetTransfer.go program, it blows up when doing:
result, err := contract.SubmitTransaction("InitLedger")
The error message is:
failed to evaluate transaction: Failed to submit: CreateAndSendTransaction failed: SendTransaction failed: orderers is nil
Any clues? THank you
Your length of orderers is zero. You have to set at least one orderer for this process in your fabric-sdk-go code.
This seems to be a bug in the Go SDK. In its current form, the asset-transfer-basic app, the Go flavor, simply does not work.

How to solve "Error: endorsement failure during query. response: status:500 message"?

Background: I modified the /examples/e2e_cli/ from Hyperledger-fabric and get this error message when running the end to end script.sh
Error: endorsement failure during query. response: status:500
message:"make sure the chaincode mycc has been successfully
instantiated and try again: getccdata mychannel/mycc responded with
error: could not find chaincode with name 'mycc'"
The chaincode is correctly instantiated. What could actually be causing this error?
This Jira ticket documents the problem and one thing that causes it... which does not seem directly tied to instantiation.
One cause for this error message is that the ports in the configtx.yaml are wrong or missing.
Missing
Addresses:
- orderer0.od1.example.com
- orderer1.od1.example.com
Correct
Addresses:
- orderer0.od1.example.com:7050
- orderer1.od1.example.com:7050

Hyperledger fabric 1.2 service discovery error

I use Hyperledger Fabric 1.2 to build a blockchain cluster, which contains 3 peers and 3 orderers. I can successfully deploy and invoke the chaincode via both CLI and Java SDK. Everything works fine. However, when I notice the service discovery function and try to use it, I met two problems. First, after I build the discover tool and try to use it to get some discovered information, I can't access the peer and get the message as follow
"failed connecting to discovery service: failed to create new
connection: context deadline exceeded"
The config command is
discover --configFile conf.yaml --userKey ./crypto-config/peerOrganizations/org1.forchain.com/peers/peer0.org1.forchain.com/msp/keystore/7458b29b1fb6a89768585430dbf0e522a40ff4aefe600fc1e4fafe62c3c972e4_sk --userCert ./crypto-config/peerOrganizations/org1.forchain.com/peers/peer0.org1.forchain.com/msp/signcerts/peer0.org1.forchain.com-cert.pem --MSP Org1MSP saveConfig
The query command is
discover --configFile conf.yaml peers --channel lajiao --server localhost:6051
I guess it may be caused by the TLS config so I canceled the TLS and tried again. This time I successfully access the peer and get some messages, but I met another problem. When I use 'discover peers xxx ' command, I always get null result, in fact there are two peers in that channel. When I use 'discover endorsers xxx' command, I always get the following error message
'failed constructing descriptor for chaincodes:'
In the meantime, the peer log outputs the following message:
'Principal set computation failed: chaincode isn't installed on
sufficient organizations required by the endorsement policy 2018-08-01
10:21:50.860 UTC [discovery] chaincodeQuery -> ERRO 1441 Failed
constructing descriptor for chaincode chaincodes:
,: chaincode isn't installed on sufficient organizations required by
the endorsement policy'
I can assure that the chaincode is successfully installed in all peers. And I didn't use the endorsement policy when I instantiated the chaincode. I think it is not the policy problem because I still can invoke the chaincode and propose a transaction.
I also tried to use the Java SDK and found that I can get the orderer nodes info but I can't get the other peer nodes or chaincode info. The log always output: "Discover of chaincode names was empty.". But the chaincode is definitely instantiated and can be invoke via SDK. I refered to the test code in "org.hyperledger.fabric.sdkintegration.ServiceDiscoveryIT" and some key Java code is as follow:
channel.addPeer(peer, createPeerOptions().setPeerRoles(EnumSet.of(Peer.PeerRole.SERVICE_DISCOVERY,Peer.PeerRole.LEDGER_QUERY, Peer.PeerRole.EVENT_SOURCE,Peer.PeerRole.CHAINCODE_QUERY)));
channel.initialize();
System.out.println("================ orderer ===============");
for (Orderer orderer : channel.getOrderers()) {
System.out.println(orderer.getName());
}
System.out.println("================ peer ===============");
for (Peer p: channel.getPeers()) {
System.out.println(p.getName());
}
System.out.println("================ chaincode ===============");
for (String s: channel.getDiscoveredChaincodeNames()) {
System.out.println(s);
}
So, how can I use the 'discover' command under TLS configuration and how can I get the discovered information?
For the config command - you need to pass a TLS root CA, via --peerTLSCA. Please look at the examples in the documentation and act accordingly.
Now - for the second problem, I think that the peers might not know each other in the channel.
Make sure you have anchor peers defined in the channel and that both peers have external endpoints configured.
Feel free to bug me (yacovm) on chat.hyperledger.org if you're struggling for too long and can't solve the problem.
You must add an anchor peer from each organization in the channel, this solved the problem for me. Anchor peers are required for the service discovery since the service discovery uses gossip protocol- thanks #yacovm
I stumbled a similar error (regarding to service discovery) as below.
Go Fabric Client logs:
Failed to get endorsing peers: error getting channel response for channel [myc]:
Discovery status Code: (11) UNKNOWN. Description: error received from Discovery Server:
failed constructing descriptor for chaincodes:<name:"mycc">
Peer logs:
Failed constructing descriptor for chaincode chaincodes:<name:"mycc" > ,:
cannot satisfy any principal combination
It's fixed when I provide CORE_PEER_GOSSIP_EXTERNALENDPOINT environment attribute with a correct value on peer's configuration (in docker yaml file in my case).
As I understood since this attribute is missing, discovery services running on peers failed to communicate with each other to have a conclusion of what current network looks like.

Hyperledger Fabric chaincode instantiation returns timeout expired

I've been working around with Fabric for a a few months now, and I've been trying to run a somewhat complex virtual machine, the Ethereum Virtual Machine within a chaincode. It is written in JavaScript so I worked with the nodeJS chaincode version.
I packed the the VM with my chaincode in a directory that i install and instantiate onto the peer. The install completes and exits with no errors, however the instantiation after hanging for a few minutes returns me an error:
Error: Error endorsing chaincode: rpc error: code = Unknown desc = timeout expired while starting chaincode mychaincode:1.0(networkid:dev,peerid:peer0.org1.example.com,tx:....
It should run for quite a few minutes at least as the added packages are ~15MB, according to the example nodejs chaincode runs for a minute at least.
The example nodejs chaincode (chaincode_example02) runs perfectly on both BYFN network from the tutorial and on a basic-network that I've started. My environment was set up according to the documentation (v1.1.0) from the fabric-samples repository (v1.1.0). Even if I only add one package to the example chaincode with the require method, it hangs, than return error.
I've been searching for a flag or config where I can set the timeout value for chaincode instantiation, but with no luck. Where could I increase the timeout value?
Which log should I provide in order to step forward in searching for the soution?
Thanks is advance,
Balint
You can modify the chaincode.startuptimeout config by adding a CORE_CHAINCODE_STARTUPTIMEOUT environment variable to the base/peer-base.yaml docker compose file specifying something other than the default.

The current identity has not been registered:

I have successfully issued, imported and pinged a card on Hyperledger composer 0.16.0. However, when I try to execute transactions with the created identity, I get the following errors
"Error trying invoke business network. Error: No valid responses from any peers.\nResponse from attempted peer comms was an error: Error: chaincode error (status: 500, message: Error: The current identity has not been registered: roger)\n"
I am not sure whether I should now 'bind' the identity to a participant as demonstrated here. I did try this but there is a required certificate file --certificateFile which I am not sure where to find. Preliminary checks on .composer folder in my home directory indicate that I have a xxxx-pub and xxxx-priv file on the card details in client-data subdirectory. Would this xxxx-pub act as the required certificate?
Anyway, that was just my attempt at finding the solution but I would really appreciate if anyone could help me resolve the The current identity has not been registered: roger error.
Ok. I tried with the xxxx-pub file and it worked. So use -e /path/to/file/xxxx-pub in the composer identity bind command.

Resources