'Chaincode fingerprint does not match' when querying from other peer

前端 未结 4 531
攒了一身酷
攒了一身酷 2021-01-24 01:52

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:

相关标签:
4条回答
  • 2021-01-24 02:04

    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
    
    0 讨论(0)
  • 2021-01-24 02:10

    When you install a chaincode the basic flow works as following:

    1. It's being packed into archive file considering all dependencies including transitive
    2. Copied inside docker container with golang environment and got compiled there
    3. Next peer builds up new chaincode container and moves compiled binary if I'm not mistaken into /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.

    0 讨论(0)
  • 2021-01-24 02:13

    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.

    0 讨论(0)
  • 2021-01-24 02:13

    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.

    0 讨论(0)
提交回复
热议问题