Peer chaincode install failed due to chaincode definition sequence mismatch - hyperledger-fabric

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.

Related

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

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

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

Hyperledger Fabric: Peer Node Rollback

I am following Hyperledger V 1.4 documsation to roll back the channel mychannel to block number 150 using this following command:
peer node rollback -c mychannel -b 150
If I run this inside CLI container it's showing:
Validating the rollback parameters: ledgerID [mychannel], block number
[0]
Error: ledgerID [mychannel] does not exist.
If i run inside peer0 it is giving an error
Error: as another peer node command is executing, wait for that
command to complete its execution or terminate it before retrying:
lock is already acquired on file
/var/hyperledger/production/ledgersData/fileLock
I have tried different possible ways by stop and pausing the nodes but failed, can anyone please guide the right way to perform this task.
Thanks in Advance
peer node rollback -c mychannel -b 150
Note: The above-said command should be executed from the peer node, not from the CLI
Error: as another peer node command is executing, wait for that command to complete its execution or terminate it before retrying: lock is already acquired on file /var/hyperledger/production/ledgersData/fileLock
Please make sure that peer is offline when you are performing tasks such as
peer node reset
peer node rollback
Please note that rollback doest mean it delete the blocks permanently, after the rollback operation performed peer will receive blocks from the orderer or other peers
I have found the solution as follow:
First network was up and running, I have added following command in docker compose file for required peer lets say peer0.org1.example.com,
command: peer node rollback -c mychannel -b 1 && peer node start
After saving the changes run following command
docker-compose -f docker-compose-cli.yaml up -d peer0.org1.example.com
Now remove rollback part from above command, I can see logs show that it has been rollback successfully.
docker logs peer0.org1.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.

Error while installing chaincode in fabric 2.0

when I try to approve chaincode definition for my organization using peer lifecycle chaincode approveformyorg I got this error
Error: proposal failed with status: 500 - failed to invoke backing implementation of 'ApproveChaincodeDefinitionForMyOrg': could not
serialize chaincode parameters to state: could not deserialize
metadata for namespace namespaces/hei-authorization-contract#1: could
not query metadata for namespace
namespaces/hei-authorization-contract#1: GET_STATE failed: transaction
ID: 85c9a7441cda90c5860c0d64b45e3d0fb3aaf963ccb2b3c0420e517c60880a5a:
private data matching public hash version is not available. Public
hash version = {BlockNum: 9, TxNum: 0}, Private data version =
can someone please explain the cause of this error
I am using the following commands to install chaincode
peer lifecycle chaincode package contracts.tar.gz --path /opt/gopath/src/github.com/chaincode/Contracts/ --lang node --label contracts_0.0.1
peer lifecycle chaincode install contracts.tar.gz
peer lifecycle chaincode queryinstalled >&log.txt
export PACKAGE_ID=$(sed -n "/contracts_0.0.1/{s/^Package ID: //; s/, Label:.*$//; p;}" log.txt)
echo PackageID is ${PACKAGE_ID}
peer lifecycle chaincode approveformyorg -o orderer1.regulator.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/regulator.com/orderers/orderer1.regulator.com/msp/tlscacerts/tlsca.regulator.com-cert.pem --channelID dvchannel --name contracts --version 1 --init-required --package-id ${PACKAGE_ID} --sequence 1
peer lifecycle chaincode querycommitted --channelID dvchannel --name contracts

Resources