Hyperledger Fabric chaincode instantiation returns timeout expired - node.js

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.

Related

Why can't I commit transactions with Caliper to Hyperledger Fabric?

I've got Caliper configured as a subtree of my custom Fabric blockchain. I have it configured correctly in order to connect the network and am running a small set of tests at the moment. The arguments I'm providing are absolutely correct in terms of the custom chaincode being run, but whenever I try to create a transaction via Caliper I get the error:
Failed to perform submit transaction [CreateAsset] using arguments [<ARGS>], with error: TypeError: Cannot read property 'status' of undefined
Anybody encountered this before with Caliper V0.4.2? It's interfacing with a Fabric 2.3.3 instance on local machine via Kubernetes, with the latest SDK bound.
The error occurs on line 237 of transactions.js inside the node_module fabric-network, where there is a strict property comparison on a commit object.
Also it's worth noting that the querying part of my test rounds is yielding expected results... none of those assets get created due to the error thrown, and when querying for a given asset an error like so occurs:
Failed to perform query transaction [ReadAsset] using arguments [<ID>], with error: Error: error in simulation: transaction returned with failure: Error: The asset <ID> does not exist
The closest thing I've been able to find is this ~2 year old issue which isn't exactly what I'm facing but it's the same sort of error at least... any help or pointers would be greatly appreciated because I'm struggling to glean useful information. (Link: https://github.com/hyperledger/caliper/issues/727)
The issue was due to the host names being converted to localhost when you want to work anything except a network running locally via docker. You need to launch caliper with the following extra option
--caliper-fabric-gateway-localhost false

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.

Question about Hyperledger Fabric Python SDK

I got a question when running the Jupyter Notebook Tutorial file which provides in Hyperledger Fabric Python SDK. The error occurs when I try to run the code which could install an example chaincode which can be found at test/fixtures/chaincode on the peers of org1.
It shows error: the loop is not defined. But when I add the code before loop = asyncio.get_event_loop(). It also shows error: RuntimeError: This event loop is already running.
How can I solve this problem?
Looks like the python sdk tutorial you're referring to is: https://github.com/hyperledger/fabric-sdk-py/blob/master/Tutorial.ipynb
and this references contract: https://github.com/hyperledger/fabric-sdk-py/blob/master/test/fixtures/chaincode/src/github.com/example_cc/example_cc.go
The first loops is this one:
Run the below code snippet to install an example chaincode which can be found at test/fixtures/chaincode on the peers of org1.
In [ ]:
# This installs the example chaincode on the peers
# Make the client know there is a channel in the network
cli.new_channel('businesschannel')
#The GOPTAH settings is required for only running the example chaincode in the SDK
import os
gopath_bak = os.environ.get('GOPATH', '')
gopath = os.path.normpath(os.path.join(
os.path.dirname(os.path.realpath('__file__')),
'test/fixtures/chaincode'
))
# The response should be true if succeed
responses = loop.run_until_complete(cli.chaincode_install( <<<<<<<<< Here
requestor=org1_admin,
peers=['peer0.org1.example.com',
'peer1.org1.example.com'],
cc_path='github.com/example_cc',
cc_name='example_cc',
cc_version='v1.0'
))
If you can confirm some of this with a comment response or include it in your post above it might help get an answer. I've just read the question and tried searching for the bits of info your referring to... without explicit examples of what you're talking about, you're going to find it hard to get a response though.

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.

Data size limit. Error: Received message larger than max

I am running a node script which connects to the business network and adds assets to the network.
I get the below error.
Error: Error trying invoke business network. Error: No valid responses from any peers.
Response from attempted peer comms was an error: Error: Received message larger than max (5153800 vs. 4194304)
at _initializeChannel.then.then.then.then.catch (/home/sneha/node-app-v1/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:916:34)
at <anonymous>
I followed this solved issue: https://jira.hyperledger.org/browse/FAB-3301
and changed remote.js file in respective node modules [ composer-playground,composer-client,composer-admin,composer-common etc.. ]
Even after the changes, I can't add the asset through the node script. It throws the same error.
If I add the asset through composer playground it successfully adds the asset but then I can't access the network [ in composer playground ] it throws this error
Error: No connection found with ID 2db7d182-8856-44d5-a9d8-5f7178726423
How can I solve both errors?
How can I set the limit to infinite?
I am using:
Node version: v8.9.4
Composer version: v0.16.5
To change grpc message limits requires you to create/update your connection profile. See https://hyperledger.github.io/composer/reference/connectionprofile
for information about connection profiles.
A no connection profile with id found usually implies you have restarted playground, but not restarted your interaction with playground. Would suggest closing the playground tab and creating new tab to use playground in.

Resources