The mismatch of chaincode verison within fabric peers - hyperledger-fabric

In this situation:
1,Peer X is down
2,Other peer perform upgrade of chaincode with success
3,Peer X is up, it will receive block and tx from the order/other peers, but it lacks of the newest version of chaincode.
4,In my try, if update the chaincode on peer X, it will result to mismatch of the version within peers
How to make all peer have the same verison of chaincode?

You must install the last version of the chaincode in all the endorser peers. Always. The admin of each organization should do that, to be accurate.
Install it in every endorser peer and instantiate/upgrade once.
Be sure that you have the same version in every peer by comparing:
md5sum /var/hyperledger/production/chaincodes/mychaincode.1.0

Related

How to get Id number co chaincode of hyperledger fabric by Hyperledger Fabric SDK for node.js?

After I installed the chaincode, the peer chaincode list return all installed chaincode with the id numbers:
peer chaincode list --installed -C mychannel
Get installed chaincodes on peer:
Name: dev-mychaincode-cc, Version: alpha1, Path: /opt/home/mychaincode-cc, Id: 414955ccc11a2644a7f7caxxxb29ee06
Is there anyway to get this id (414955ccc11a2644a7f7caxxxb29ee06) by Hyperledger Fabric SDK for node.js?
You should be able to call the GetInstalledChaincodes transaction function on the lscc system chaincode, and parse the return value, which is a ChaincodeQueryResponse protocol buffer (protobuf) message.
The protobuf definitions for Fabric are in the fabric-protos repository. There are also published Go, Node (TypeScript/JavaScript) and Java language bindings for all the Fabric protobufs that you can use directly to help unpack protobuf messages:
https://hyperledger.github.io/fabric-protos/
For reference, the lscc chaincode's GetAllChaincodes transaction function implementation is here:
https://github.com/hyperledger/fabric/blob/2b8997153a4d7ea94429b23f9868eb937bce35b5/core/scc/lscc/lscc.go#L613

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

Upgrade of Hyperledger fabric from 1.4.2 to 2.0

I am trying to upgrade our current network setup in fabric 1.4.2 to 2.0. We have a kubernetes setup. I see in the documentation that first we need to upgrade the peer database by using peer node upgrade-dbs and then start the peer. But since this command doesnot exist with peer version 1.4.2 I cannot do it from the running peer pod. when I tried to change the peer image to 2.0 version I get error following error. Error in instantiating ledger provider: unexpected format. db info = [leveldb for channel-IDs at [/var/hyperledger/production/ledgersData/ledgerProvider]], data format = [], expected format = [2.0]
How can I upgrade the peer database and start the peer pod in kubernetes ?
I resolved the issue my manually deleting the couchDB database and then starting the peer with 2.0 image

Convector Framework CLI returns error when installing chaincode

I am very new to the Hyperledger Fabric and Convector Framework and I have followed this tutorial:
https://worldsibu.github.io/convector/modules/getting_started.html
When I try to use the CLI tool and run the command (test is my chaincode name):
npm run cc:start -- test 1
It gives the following errors:
Installing Chaincode test version 1.0 at org1
Error: Error endorsing chaincode: rpc error: code = Unknown desc = access
denied: channel [] creator org [org1MSP]
...
Installing Chaincode test version 1.0 at org2
Error: error getting endorser client for install: endorser client failed to
connect to localhost:7151: failed to create new connection: context deadline
exceeded
I have not changed the configs and MSPs.
What is going wrong and how should I start to resolve the problem? Any guidance is appreciated!
#shole that documentation is now deprecated, you can use http://docs.worldsibu.com/convector for the latest versions.
About your error that usually happens when the environment gets corrupted and keeps cryptographic materials from a previous installation, try re-running npm run env:restart and try again.

adding new peer | 'chaincode with name 'cc' already exists' on composer network start

I am facing issues while while starting chaincode on my newly added peer in hyperledger network. Let me explain you the issue I am facing.
I had up and running hyperledger network where I had installed my bna with version 0.0.1. When I ping my network everything works fine. I have added new peer in network without bringing network down. Now I am trying to install bna on newly added peer. I have added new peer in connection profile for both organizations after adding I have created card and installed on organization where I have added new peer. bna is installed on the peer successfully. Now I am trying to start the network with composer network start. this is the point where I am receiving the following error.
Processing these Network Admins:
userName: user1
userName: user2
× Starting business network definition. This may take a minute...
Error: Error trying to start business network. Error: No valid responses from any peers.
Response from attempted peer comms was an error: Error: chaincode with name 'cc' already exists
Response from attempted peer comms was an error: Error: chaincode with name 'cc' already exists
Response from attempted peer comms was an error: Error: chaincode with name 'cc' already exists
Response from attempted peer comms was an error: Error: chaincode with name 'cc' already exists
Response from attempted peer comms was an error: Error: chaincode with name 'cc' already exists
Command failed
Please help in this matter. How am I suppose to add bna on newly added peer in network. I dont want bring my network down while adding new peer and install bna file.
So long as the bna is the same on the other peers, then you don't need to do anything else. All you need to do is install it onto the peer (the install command will not install it on peers that already have the bna, but will install it on peers that don't have it), and it sounds like you have done the correct approach by updating your connection profile and run the install command using an identity that is in the same MSP as your new Peer.
You do not need to start the business network because it is already started and that is the meaning of the error you are getting.
Now if you submit a transaction it will be sent to all peers in your connection profile. For your new Peer it will bring up the chaincode (ie the business network) automatically so that it can simulate that submission.

Resources