Reputation: 11
I set up a network on several servers. On one of the servers, the compiled chaincode is consistently different from the chaincode on other servers, resulting in the message:
Error: Error endorsing query: rpc error: code = Unknown desc = Error executing chaincode: Could not get deployment transaction from LSCC for mycc:1.0 - Get ChaincodeDeploymentSpec for mycc/torchplatformchannel from LSCC error: chaincode fingerprint mismatch data mismatch - <nil>
I don't know how chaincode is compiled exactly, but when I run a number of peers on my own laptop, with the same configuration, the hash always matches. I use the normal command to install the chaincode on the peer from the cli (fabric-tools) container (peer chaincode install -n mycc -v 1.0 -p chaincode_example02
). The host machines are similar:
root@fabric:~# uname -a
Linux fabric 4.4.0-81-generic #104-Ubuntu SMP Wed Jun 14 08:17:06 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Other server:
Linux fabric2 4.4.0-75-generic #96-Ubuntu SMP Thu Apr 20 09:56:33 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Docker versions are the same:
root@fabric:~# docker version
Client:
Version: 17.06.0-ce
API version: 1.30
Go version: go1.8.3
Git commit: 02c1d87
Built: Fri Jun 23 21:23:31 2017
OS/Arch: linux/amd64
Server:
Version: 17.06.0-ce
API version: 1.30 (minimum version 1.12)
Go version: go1.8.3
Git commit: 02c1d87
Built: Fri Jun 23 21:19:04 2017
OS/Arch: linux/amd64
Experimental: false
Images are the same:
root@fabric:~# docker images
hyperledger/fabric-tools x86_64-1.0.0-beta ae6b0f53cb70 3 weeks ago 1.32GB
hyperledger/fabric-peer x86_64-1.0.0-beta e01c2b645f11 3 weeks ago 182MB
hyperledger/fabric-ca x86_64-1.0.0-beta e549e8c53c2e 3 weeks ago 238MB
But the chaincode actually IS different:
root@286f0cd4bc82:/var/hyperledger/production/chaincodes# md5sum mycc.1.0
a96076f0cadf7c0e5c8da50ee5195078 mycc.1.0
root@286f0cd4bc82:/var/hyperledger/production/chaincodes# ls -la mycc.1.0
-rw-r--r-- 1 root root 2441 Jul 4 12:55 mycc.1.0
And on the other side:
root@6089fc35a6d9:/var/hyperledger/production/chaincodes# md5sum mycc.1.0
918307de80ef18de378c63e4138ccdf5 mycc.1.0
root@6089fc35a6d9:/var/hyperledger/production/chaincodes# ls -la mycc.1.0
-rw-r--r-- 1 root root 2448 Jul 4 12:53 mycc.1.0
What could be the reason for a chaincode not having the same hash on a different peer?
Upvotes: 1
Views: 2588
Reputation: 116
You need to have the exact copy of chaincode in all of your peers.
Try :
docker exec cli peer chaincode list --installed
(Note that the cli container name may be different in yours)
and check the Id in both the servers. If they do not match that means you have a different chaincode file.
Just try copying the whole chaincode folder to another machine at the same location.
Upvotes: 0
Reputation: 134
I faced the same issue and the reason for it is I had an extra file in one of the two servers. First, let's understand how a Chaincode fingerprint is calculated. It is the combination of srcPath(whole content of chaincode folder ), ID and version. All servers should have the same chaincode i.e even an extra file will change the hash of chaincode.
Upvotes: 0
Reputation: 46
If you pick a machine from which to do the install but pointing to different peers where the chaincode is to be installed, like
CORE_PEER_ADDRESS=<peer1>:7051 peer chaincode install ....
and
CORE_PEER_ADDRESS=<peer2>:7051 peer chaincode install ....
Then you should end up with the same install on both peer1 and peer2.
Alternately, as Artem points above you can package the CC once into "mycc.pak"
peer chaincode package -n mycc -p <path to mycc> -v 0 mycc.pak
and can install it on multiple peers with a slightly different install command
peer chaincode install mycc.pak
Upvotes: 1
Reputation: 41222
When you install a chaincode the basic flow works as following:
/usr/bin/local/chaincode
Now, you problem is that most likely $GOPATH
in your computers differes and therefore installing same chaincode on different machines brings different dependencies ending up with different finger results.
What you need to do is to have your chaincode packed at one place and distribute the package to have it installed.
peer chaincode package -n name -v 1.0 -p path_to_your_chaincode
This will produce packed file which you will be able to use later. You can find more details here.
Upvotes: 1