2

I'm using hyperledger fabric 2.0. I have two orgs. ORGA and ORGB. I'm using "test-network" of fabric-samples repository as my network. I have edited javascript version of fabcar chaincode by changing the variable names in the init functions and other functions of fabcar.js chaincode. I have installed my edited chaincode on the peers of two orgs. I have also successfully approved chaincode on 2 orgs. Successfully committed chaincode definition to the channel. But when I'm trying to invoke chaincode using command with function initLedger I'm getting error:

Command:

peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls true --cafile ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n deed --peerAddresses localhost:7051 --tlsRootCertFiles ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses localhost:9051 --tlsRootCertFiles ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt --isInit -c '{"function":"initLedger","Args":[]}' 

I'm getting an error shown below:

Error: endorsement failure during invoke. response: status:500 message:"error in simulation: failed to execute transaction 5b14718ab2408cd29dafc9daf33e193534c7a1262afebd0ca5eae3b0116aeca0: could not launch chaincode deed_1:48b197c4e734f589019d61ba1615ad9fc2b0007f478ab92a8b34714bc3c404e0: chaincode registration failed: container exited with 1"

help me. Regards, Satish

Hnampk
  • 517
  • 6
  • 17
  • 1
    Endorsement fails if the smart contract method does not return the same result on both the peers in my understading. Check your docker container logs. – Siva May 01 '20 at 16:03
  • 1
    Actually there is a syntax error in my chaincode file, which I found after running logspout tool. The error is now rectified and my contract is running fine. Thanks for suggestion! – Satish Chandra Medi May 02 '20 at 12:38

4 Answers4

1

Fabric provides monitordocker.sh along with its commercial-paper sample in the Fabric sample (https://hyperledger-fabric.readthedocs.io/en/latest/deploy_chaincode.html#setup-logspout-optional)

Run the below line in a separate PUTTY window to keep monitoring the logs across all containers in docker. Note that "fabric_test" is the name of the network that needs to be monitored.

./monitordocker.sh fabric_test

Now run the fabric command that results in error and you should see details on the log in the other PUTTY window.

Karthik
  • 931
  • 2
  • 9
  • 14
0

The error is telling you that the container hosting the chaincode has exited after the chaincode process terminated with an exit code of 1. If you've configured the peer to stream the chaincode container logs (vm.docker.attachStdout=true / CORE_VM_DOCKER_ATTACHSTDOUT=true), you can look at the peer logs to see any errors produced by the chaincode.

southwick
  • 24
  • 1
  • I have ran logspout tool for logs the error is: orderer.example.com|2020-04-30 03:44:44.662 UTC [orderer.common.broadcast] Handle -> WARN 061 Error reading from 172.18.0.1:38564: rpc error: code = Canceled desc = context canceled – Satish Chandra Medi Apr 30 '20 at 03:50
  • hi southwick, I have found out an syntax error of missing a single quote for a variable in my chaincode.... Thanks for suggesting me using logs because I have found out error using logspout tool... – Satish Chandra Medi Apr 30 '20 at 07:09
0

Check your chaincode, their is some typo in your code. check --> repair --> run following script -->

./startFabric.sh javascript

Mohit Rakhade
  • 351
  • 4
  • 8
0

The name of the invoked chaincode does not match the name of the committed one. Check it.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 19 '22 at 20:36