Hyperledger Fabric: CouchDB doesn't show the worldstate of a channel - couchdb

The HLF Version I use is 2.2
I set up my own network consisting of 3 Orgs, 1 Orderer and 2 Channels. The network is set up and I can call Chaincode Functions responding with 200. So far, so good. The problem is I don't see the worldstate in CouchDB. I think it's related due to the fact the chaincode is not instantiated properly or at all
When I call:
peer chaincode list --instantiated -C examplechannel
It doesn't return anything. But if I try to set the flag --isInit on the first Invoke.
peer chaincode invoke -o localhost:7050 -C examplechannel -n example --peerAddresses localhost:9051 --isInit -c '{"function":"instantiate","Args":[]}'
The response is:
chaincode 'example' does not require initialization but called as init
When I try to instantiate the Chaincode by:
peer chaincode instantiate -o localhost:7050 -C examplechannel -n example -v 1 -c '{"function":"instantiate","Args":[]}'
I get the response:
Error: could not assemble transaction, err proposal response was not successful, error code 500, msg Channel 'examplechannel' has been migrated to the new lifecycle, LSCC is now read-only
Any suggestions?

There is difference in the chaincode installation from Fabric version 2.0 when compare to previous version. Please refer below documentation for more details regarding new chaincode lifecycle
https://hyperledger-fabric.readthedocs.io/en/release-2.2/deploy_chaincode.html

Related

Endoresement Failure during query

while running the secured-asset transfer in hyperledger fabric I am getting this error and the query command is not passing
Command:-
peer chaincode query -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C mychannel -n secured -c '{"function":"GetAssetPrivateProperties","Args":["asset1"]}'
Error:-
Error: endorsement failure during query. response: status:500 message:"asset private details does not exist in client org's collection: asset1"
Can anyone help me with it ??
This error is thrown from the chaincode. Make sure you have added the data to the private data collection with the key 'asset1' before querying it. Also, orderer endpoints are not required for query command.
peer chaincode query -C mychannel -n basic -c '{"function":"GetAssetPrivateProperties","Args":["asset1"]}'
The source code from the hyperledger /fabric-samples seems is not compatible with the command provided in the hyperledger fabric document.
Change the code in the repository of
fabric-samples/asset-transfer-secured-agreement/chaincode-go/asset_transfer.go
Add argument asset_id string to this function head.
CreateAsset(ctx contractapi.TransactionContextInterface,asset_id string, publicDescription string)
In this function body
comment this line assetID := hex.EncodeToString(hash.Sum(nil))
and reset the assetID := asset_id
hope helpful

Peer chaincode install failed due to chaincode definition sequence mismatch

Recently I have ran into a situation where I accidentally delete the /var/hyperledger/production folder. After rejoining the channel and finished syncing from other peers, I got this error
+ peer lifecycle chaincode approveformyorg -o orderer0-orderer.orderer20:7050 --tls true --cafile /shared/crypto-config/orderer.orderer20/orderers/orderer0-orderer.orderer20/msp/tlsintermediatecerts/ica-orderer-orderer20-7054.pem --channelID htqachannel --name ht_cc --version b21734e0c25e509e3ff4b3dc96b78ca83047aa9e --package-id ht_cc_b21734e0c25e509e3ff4b3dc96b78ca83047aa9e:76c6642ba927c690ad5a402d22f3ec28c581ef76cea8828b9af583a5021bea23 --sequence 1 --waitForEvent
+ res=1
+ set +x
Error: proposal failed with status: 500 - failed to invoke backing implementation of 'ApproveChaincodeDefinitionForMyOrg': currently defined sequence 109 is larger than requested sequence 1
Are there anyway to make the chaincode definition sequence on this peer to match the current defined sequence ?
You have to increment the chaincode sequence number when upgrading chaincode definition. From the error it seems your current definition is having a sequence number 109. So you have to provide 110 as sequence instead of 1.

Error: endorsement failure during invoke. response: status:500 message:

I followed Hyperledger fabric official tutorial to deploy my first blockchain project. However, I met the problem that I have installed my chaincode named "basic" on channel "mychannel"
peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C mychannel -n basic --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" -c '{"function":"InitLedger","Args":[]}'
and the feedback is
Error: endorsement failure during invoke. response: status:500 message:"make sure the `chaincode basic has been successfully defined on channel mychannel and try again: chaincode definition for 'basic' exists, but chaincode is not installed"
but the last step I used the coomand
peer lifecycle chaincode querycommitted --channelID mychannel --name basic --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem"
and the feedback is
Committed chaincode definition for chaincode 'basic' on channel 'mychannel':
Version: 1.0, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc, Approvals: [Org1MSP: true, Org2MSP: true]
I think that means I was successful committed "basic" to the channel.
But I cannot invoking the chaincode by following tutorial's steps.
What should I do to fix the problem?
I use ubuntu 20.04. on Windows OS.
I use Mobaxterm to open WSL-Ubuntu-20.04.
Tutorial is enter link description here I met this problem is the first step at “Invoking the chaincode”
the step
If the contracts were commited, you should have 2 extra docker containers on your container list. Do a docker ps command to see if contract containers exist for 7051 and 9051. If the containers do not exist for the contracts, then you do not have a working contract.
Try stopping and starting your network by running the following in the docker folder - grasping at straws here
docker-compose -f docker-compose-couch.yaml -f docker-compose-ca.yaml -f docker-compose-test-net.yaml stop
docker-compose -f docker-compose-couch.yaml -f docker-compose-ca.yaml -f docker-compose-test-net.yaml start
If there is at least one contract container available, try a docker logs command to see if any useful output is available e.g.
docker logs [container Id value here]
Step through the contract loading procedure again, but remember to increase the sequence number and version number. You could set up some environment variables as follows
export CC_PACKAGE_VERSION=1
export CC_PACKAGE_SEQUENCE=1
and then use them on the command line as follows
--version $CC_PACKAGE_VERSION --sequence $CC_PACKAGE_SEQUENCE
By doing it that way, you can install the same contract as many times as it takes to get it working, or for amendments that might come later on.
Sometimes you will have to retrace your installation steps because it is so easy to get things wrong when working by hand. Have a look at the deployCC.sh script as well. But I would recommend that you persevere in getting things working by hand first and then use automation later on.
The output that you provided seems to indicate that everything should be correct, so I can't see what the problem is without seeing the full history from start to finish.
Check the packageId and use localhost instead of peer0.example.com

Error: endorsement failure during invoke. response: status:500 message:"error in simulation:

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
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.
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.
Check your chaincode, their is some typo in your code.
check --> repair --> run following script -->
./startFabric.sh javascript
The name of the invoked chaincode does not match the name of the committed one.
Check it.

Hyperledger Fabric Java SDK Error while instantiate java chaincode

Error: could not assemble transaction, err proposal response was not successful, error code 500, msg timeout expired while starting chaincode
Error while instantiating java chaincode
Command :
peer chaincode instantiate -o orderer.example.com:7050 --tls --cafile
/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
-C mychannel -n test -l java -v 1.0 -c '{"Args":["init","a", "100", "b","200"]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')"
Initially it was working fine but once the line of code increase instantiation gets slow down and now it is giving this error while instantiation
unfortunatelly, java chaincode always shows the same error. I had the same issue, please, check that you have the main function in the code. If you can share the code here, that would be awesome.
There can be multiple reasons for this, like if you are in a proxy, include your settings in a gradle.properties file. another can be, check your chaincode for errors if it was working fine then it should now, increase in no. of line doesn't affect instantiation. If you are not in a proxy and still facing the error try to include your chaincode in the question.

Resources