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:
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
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.
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.
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.