How to fix "context finished before block retrieved: context canceled" occurred while instantiating chaincode? - hyperledger-fabric

The instantiation command completes successfully, but when analyzing peer logs, you may notice this:
2019-04-17 17:25:52.581 UTC [gossip.state] commitBlock -> DEBU 48c [canal-contrato] Committed block [1] with 1 transaction(s)
2019-04-17 17:25:52.581 UTC [common.deliver] deliverBlocks -> DEBU 48d [channel: canal-contrato] Delivering block for (0xc00023f9c0) for 192.168.16.1:48230
2019-04-17 17:25:52.581 UTC [fsblkstorage] waitForBlock -> DEBU 48e Going to wait for newer blocks. maxAvailaBlockNumber=[1], waitForBlockNum=[2]
2019-04-17 17:25:52.586 UTC [common.deliver] deliverBlocks -> DEBU 48f Context canceled, aborting wait for next block
2019-04-17 17:25:52.586 UTC [common.deliverevents] func1 -> DEBU 490 Closing Deliver stream
2019-04-17 17:25:52.586 UTC [comm.grpc.server] 1 -> INFO 491 streaming call completed {"grpc.start_time": "2019-04-17T17:25:50.441Z", "grpc.service": "protos.Deliver", "grpc.method": "DeliverFiltered", "grpc.peer_address": "192.168.16.1:48230", "error": "context finished before block retrieved: context canceled", "grpc.code": "Unknown", "grpc.call_duration": "2.144399922s"}
Can anyone orient me what I'm possibly doing wrong and what are the consequences of this error?
Notes:
The orderer logs don't present any type of error
All containers are running correctly
I'm using node version 8.9.0 (with npm 5.5.1)
I have 1 organization with 1 peer, 1 CA and 1 ordered (just to test)
I'm using hyperlegder fabric version 1.4

This is not an error. You are using an SDK that connects to the peer and waits for the instantiate to finish. The block is received by the peer, and when it does - the SDK closes the gRPC stream because it doesn't need it anymore, and the peer logs this to notify you why it closed the stream from the server side.

Related

Hyperledger Fabric ProcessProposal -> Failed to invoke chaincode channel= chaincode=_lifecycle

I am running Hyperledger Fabric and while trying to install the chaincode on peer0.org1, "peer lifecycle chaincode install basic.tar.gz", I run into some errors and can not install it -- Error: chaincode install failed with status: 500 - error in simulation: failed to execute transaction ee4a6ae0672861fa153e7fd5cd797e59b3eeebf1d2950ccd9e13e8231de484a9: error sending: timeout expired while executing transaction.
Below I will share the logs. Can anyone tell me what should I do? I have tried to reinstall it but with no success.
----logs---
2022-08-28 16:10:46.246 UTC 004a INFO [chaincode.externalbuilder.ccaas_builder] waitForExit -> ::Error: chaincode type not supported: node command=detect
2022-08-28 16:14:33.640 UTC 004b WARN [peer.blocksprovider] func1 -> Encountered an error reading from deliver stream: rpc error: code = Unavailable desc = transport is closing channel=mychannel orderer-address=orderer.example.com:7050
2022-08-28 16:14:33.640 UTC 004c WARN [peer.blocksprovider] DeliverBlocks -> Orderer hung up without sending status channel=mychannel orderer-address=orderer.example.com:7050
2022-08-28 16:15:46.750 UTC 004d INFO [endorser] callChaincode -> finished chaincode: _lifecycle duration: 300000ms channel= txID=ee4a6ae0
2022-08-28 16:15:46.778 UTC 004e ERRO [endorser] simulateProposal -> failed to invoke chaincode _lifecycle, error: timeout expired while executing transaction
github.com/hyperledger/fabric/core/chaincode.(*Handler).Execute
runtime.goexit
/usr/local/go/src/runtime/asm_amd64.s:1571 channel= txID=ee4a6ae0
2022-08-28 16:15:46.778 UTC 004f WARN [endorser] ProcessProposal -> Failed to invoke chaincode channel= chaincode=_lifecycle error="error in simulation: failed to execute transaction ee4a6ae0672861fa153e7fd5cd797e59b3eeebf1d2950ccd9e13e8231de484a9: error sending: timeout expired while executing transaction"
2022-08-28 16:15:46.778 UTC 0050 INFO [comm.grpc.server] 1 -> unary call completed grpc.service=protos.Endorser grpc.method=ProcessProposal grpc.peer_address=172.21.0.1:51150 grpc.code=OK grpc.call_duration=5m0.029919322s
2022-08-28 16:16:03.168 UTC 0051 INFO [lifecycle] InstallChaincode -> Successfully installed chaincode with package ID 'basic_1.0:9821071a953f452bda87fe89637d1e377dac825da4649ba998464a3c85d60c50'
2022-08-28 16:20:33.471 UTC 0052 WARN [peer.blocksprovider] func1 -> Encountered an error reading from deliver stream: rpc error: code = Unavailable desc = transport is closing channel=mychannel orderer-address=orderer.example.com:7050
2022-08-28 16:20:33.471 UTC 0053 WARN [peer.blocksprovider] DeliverBlocks -> Orderer hung up without sending status channel=mychannel orderer-address=orderer.example.com:7050

Failed to order the transaction. Error code: SERVICE_UNAVAILABLE using raft consensus protocol

I am facing this error while using Raft consensus protocol in which I have setup 5 orderers(1 in 1st server, 2 each in other 2 servers) namely orderer1 to orderer5.
Everything works fine with the setup and all the orderers are participating in the orderer election process but while I'm trying to invoke a transaction then I'm facing an error like this:
[ERROR] invoke-chaincode - Failed to order the transaction. Error code: SERVICE_UNAVAILABLE
This error comes only when i try to invoke using orderer2 but works well with any other orderer. Please help to resolve the issue.
Here are the logs of orderer2 and its running:
2019-08-13 07:05:59.374 UTC [orderer.consensus.etcdraft] run -> INFO 318 raft.node: 2 elected leader 4 at term 2 channel=invoice node=2
2019-08-13 07:05:59.375 UTC [orderer.consensus.etcdraft] serveRequest -> INFO 319 Raft leader changed: 0 -> 4 channel=invoice node=2
2019-08-13 07:05:59.580 UTC [common.deliver] Handle -> WARN 31a Error reading from xx.xx.xx.xx:56890: rpc error: code = Canceled desc = context canceled
2019-08-13 07:05:59.580 UTC [comm.grpc.server] 1 -> INFO 31b streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Deliver grpc.peer_address=xx.xx.xx.xx:56890 error="rpc error: code = Canceled desc = context canceled" grpc.code=Canceled grpc.call_duration=207.535623ms
2019-08-13 07:13:20.952 UTC [orderer.common.broadcast] ProcessMessage -> WARN 320 [channel: invoice] Rejecting broadcast of normal message from xx.xx.xx.xx:56916 with SERVICE_UNAVAILABLE: rejected by Order: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp 192.168.224.4:8050: connect: connection refused"
2019-08-13 07:13:20.952 UTC [comm.grpc.server] 1 -> INFO 321 streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Broadcast grpc.peer_address=xx.xx.xx.xx:56916 grpc.code=OK grpc.call_duration=35.477429971s
I just ran into this very issue, orderer2 as well. It turns out for me, I had made a typo in the orderer config. In the General.Cluster section, I accidentally renamed the ClientCertificate and ClientPrivateKey fields to ServerCertificate and ServerPrivateKey. I switched them, left the Server* values blank and pointed to my client certs with the others and everything worked.

Chaincode is instantiated but doesn't appear in the list of instantiated codes

I am running Hyperledger Fabric 1.4.0
I have 1 org (Org1), 2 peers (peer0, peer1) and two orderers (ord0, ord1). The peers use couchdb as a storage backend.
I am able to successfully install my chaincode, then instantiate it.
Looking at peer0 logs, the docker image is built and the container started. peer0 also receives and acknowledges the REGISTER request sent by the chaincode binary within the container:
2019-06-24 10:15:57.003 UTC [dockercontroller] createContainer -> DEBU b563 created container {"imageID": "nid1-peer0-mynet-mychain-v1-613158e6e99c2c9e7d567e8b57fe2dfb56444f7fdcbc263dd1f61626a374843d", "containerID": "nid1-peer0-mynet-mychain-v1"}
2019-06-24 10:15:57.160 UTC [dockercontroller] Start -> DEBU b564 Started container nid1-peer0-mynet-mychain-v1
2019-06-24 10:15:57.160 UTC [container] unlockContainer -> DEBU b565 container lock deleted(mychain-v1)
2019-06-24 10:15:57.181 UTC [chaincode] handleMessage -> DEBU b566 [] Fabric side handling ChaincodeMessage of type: REGISTER in state created
2019-06-24 10:15:57.181 UTC [chaincode] HandleRegister -> DEBU b567 Received REGISTER in state created
2019-06-24 10:15:57.182 UTC [chaincode] Register -> DEBU b568 registered handler complete for chaincode mychain:v1
2019-06-24 10:15:57.182 UTC [chaincode] HandleRegister -> DEBU b569 Got REGISTER for chaincodeID = name:"mychain:v1" , sending back REGISTERED
2019-06-24 10:15:57.182 UTC [chaincode] HandleRegister -> DEBU b56a Changed state to established for name:"mychain:v1"
2019-06-24 10:15:57.182 UTC [chaincode] sendReady -> DEBU b56b sending READY for chaincode name:"mychain:v1"
2019-06-24 10:15:57.182 UTC [chaincode] sendReady -> DEBU b56c Changed to state ready for chaincode name:"mychain:v1"
2019-06-24 10:15:57.182 UTC [chaincode] Launch -> DEBU b56d launch complete
2019-06-24 10:15:57.182 UTC [chaincode] Execute -> DEBU b56e Entry
2019-06-24 10:15:57.182 UTC [chaincode] handleMessage -> DEBU b56f [1a98f442] Fabric side handling ChaincodeMessage of type: COMPLETED in state ready
Despite this, the chaincode is not registered in couchdb:
$ peer chaincode list --instantiated -C mychannel
2019-06-24 11:26:29.317 BST [main] InitCmd -> WARN 001 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
2019-06-24 11:26:29.332 BST [main] SetOrdererEnv -> WARN 002 CORE_LOGGING_LEVEL is no longer supported, please use the FABRIC_LOGGING_SPEC environment variable
Get instantiated chaincodes on channel mychannel:
peer0 logs immediately after submitting the list command:
2019-06-24 10:26:30.057 UTC [couchdb] ReadDocRange -> DEBU c02e [mychannel_lscc] HTTP/1.1 200 OK
Transfer-Encoding: chunked
Cache-Control: must-revalidate
Content-Type: application/json
Date: Mon, 24 Jun 2019 10:26:30 GMT
Server: CouchDB/2.1.1 (Erlang OTP/18)
X-Couch-Request-Id: 20d0beb9c3
X-Couchdb-Body-Time: 0
2a
{"total_rows":0,"offset":0,"rows":[
]}
0
If I try to invoke a method on the chaincode, I get this error:
Error: endorsement failure during invoke. response: status:500 message:"make sure the chaincode mychain has been successfully instantiated and try again: chaincode mychain not found"
which just confirms that the chaincode has not been registered within the network.
Update
I realised I had missed an important detail: the peer logs repeatedly report errors connecting to the orderer, e.g.:
2019-06-24 11:30:35.931 UTC [ConnProducer] NewConnection -> ERRO 100e6 Failed connecting to ord0.mynet.example.com , error: context deadline exceeded
which might be the reason why the "chaincode instantiated" message doesn't get propagated...
After much debugging, it turned out the issue was pretty simple: the peers could not communicate with the orderers.
In my particular case the addresses of the orderers were wrong in configtx.yaml. Fixing them resulted in the chaincode instantiation process tu fully succeed.

How fix "rpc error: code = Unknown desc = access denied: channel [mychannel] creator org [Org1MSP]" error in Hyperledger Fabric

Currently I am using Hyperledger Fabric 1.4, and I am trying to modify the basic-network. I am trying to add an org2 with one peer. Whenever I try to invoke the chaincode from the peer on the second organization (Org2) I get the following error:
Error: Error endorsing chaincode: rpc error: code = Unknown desc = access denied: channel [] creator org [Org2MSP]
My current network components are:
org1, with two peers
org2, with one peer
CA1
CA2
Ordere
CLI
and a channel called "mychannel"
I am able to create the channel "mychannel" and join the 3 peers from the two organizations. Also, I am able to install the chaincode on three of the peers from both organizations. And I am instantiating the chaincode on peer0 in Org1
Part of the Ordere logs:
2019-05-13 13:17:42.384 UTC [fsblkstorage] newBlockfileMgr -> INFO 003 Getting block information from block storage
2019-05-13 13:17:42.970 UTC [orderer.commmon.multichannel] Initialize -> INFO 004 Starting system channel 'testchainid' with genesis block hash f1bcfe55588bd24faaa699bc740045455283b63950436a36d5cf473f4b3d8f81 and orderer type solo
2019-05-13 13:17:42.970 UTC [orderer.common.server] Start -> INFO 005 Starting orderer:
Version: 1.4.1
Commit SHA: 87074a7
Go version: go1.11.5
OS/Arch: linux/amd64
2019-05-13 13:17:42.970 UTC [orderer.common.server] Start -> INFO 006 Beginning to serve requests
2019-05-13 13:21:30.921 UTC [comm.grpc.server] 1 -> INFO 007 streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Broadcast grpc.peer_address=172.20.0.6:36544 grpc.code=OK grpc.call_duration=27.428231ms
2019-05-13 13:21:30.927 UTC [fsblkstorage] newBlockfileMgr -> INFO 008 Getting block information from block storage
2019-05-13 13:21:31.038 UTC [orderer.commmon.multichannel] newChain -> INFO 009 Created and starting new chain mychannel
2019-05-13 13:21:31.044 UTC [comm.grpc.server] 1 -> INFO 00a streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Deliver grpc.peer_address=172.20.0.6:36542 grpc.code=OK grpc.call_duration=152.538972ms
2019-05-13 13:22:11.867 UTC [common.deliver] Handle -> WARN 00b Error reading from 172.20.0.6:36578: rpc error: code = Canceled desc = context canceled
2019-05-13 13:22:11.867 UTC [comm.grpc.server] 1 -> INFO 00c streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Deliver grpc.peer_address=172.20.0.6:36578 error="rpc error: code = Canceled desc = context canceled" grpc.code=Canceled grpc.call_duration=5.757971ms
2019-05-13 13:22:22.295 UTC [orderer.common.broadcast] Handle -> WARN 00d Error reading from 172.20.0.8:34272: rpc error: code = Canceled desc = context canceled
2019-05-13 13:22:22.295 UTC [comm.grpc.server] 1 -> INFO 00e streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Broadcast grpc.peer_address=172.20.0.8:34272 error="rpc error: code = Canceled desc = context canceled" grpc.code=Canceled grpc.call_duration=7.238573847s
2019-05-13 13:23:46.748 UTC [orderer.common.broadcast] Handle -> WARN 00f Error reading from 172.20.0.8:34362: rpc error: code = Canceled desc = context canceled
2019-05-13 13:23:46.748 UTC [comm.grpc.server] 1 -> INFO 010 streaming call completed grpc.service=orderer.AtomicBroadcast grpc.method=Broadcast grpc.peer_address=172.20.0.8:34362 error="rpc error: code = Canceled desc = context canceled" grpc.code=Canceled grpc.call_duration=49.20235ms
In summery, I can not invoke the chaincode from the second organization (Org2) because of channel access error.
Note:
I am generating the CA and I have checked the files and it seems to be correct
If anyone can help I would appreciate it.
Thanks in advance
This can be caused by wrong MSPID name for example "orgMSP" is wrong as it starts with lowercase "o"
to solve the problem use correct MSPID
export CORE_PEER_LOCALMSPID="Org1MSP"
It would be easy to answer if you have shared the peer logs.
The error could be because of the Certificates to sign the transaction.Double check your certificate received from CA and also checked the certificates and path used inside the docker container of peer1.

Hyperledger Fabric - Orderer logs show error during broadcast even though the transaction is successful and committed to all peers

Orderer logs show following error(highlighted) during broadcast even though the transaction is successful and committed to all peers:
2018-12-19 13:43:42.724 UTC [policies] Evaluate -> DEBU 997 == Done Evaluating *policies.implicitMetaPolicy Policy /Channel/Writers
2018-12-19 13:43:42.724 UTC [orderer/common/broadcast] Handle -> DEBU 998 [channel: mychannel] Broadcast has successfully enqueued message of type ENDORSER_TRANSACTION from 172.19.0.7:40978
2018-12-19 13:43:42.724 UTC [orderer/common/blockcutter] Ordered -> DEBU 999 Enqueuing message into batch
2018-12-19 13:43:42.724 UTC [orderer/consensus/solo] main -> DEBU 99a Just began 2s batch timer
2018-12-19 13:43:42.730 UTC [grpc] infof -> DEBU 99b transport: loopyWriter.run returning. connection error: desc = "transport is closing"
2018-12-19 13:43:42.730 UTC [orderer/common/broadcast] Handle -> WARN
99c Error reading from 172.19.0.7:40978: rpc error: code = Canceled
desc = context canceled
2018-12-19 13:43:42.731 UTC [orderer/common/server] func1 -> DEBU 99d Closing Broadcast stream
2018-12-19 13:43:44.724 UTC [orderer/consensus/solo] main -> DEBU 99e Batch timer expired, creating block
2018-12-19 13:43:44.724 UTC [msp] GetDefaultSigningIdentity -> DEBU 99f Obtaining default signing identity
Fabric Config: All configs and setup same as specified in Build you First Network tutorial at https://hyperledger-fabric.readthedocs.io/en/release-1.3/build_network.html
Query
What is meant by this error? What does orderer read from cli(IP of cli: 172.19.0.7:40978) during broadcast?

Resources