hyperledger-archives / fabric

THIS IS A READ-ONLY historic repository. Current development is at https://gerrit.hyperledger.org/r/#/admin/projects/fabric . pull requests not accepted
https://gerrit.hyperledger.org/
Apache License 2.0
1.17k stars 1.01k forks source link

Chaincode should be re-deployed after restarting peer node #1655

Open yingfeng opened 8 years ago

yingfeng commented 8 years ago

Description

Chaincode runs as a seperate docker container. After it has been successfully deployed, it could not connect to peer anymore after peer had been restarted, unless the chaincode is re-deployed.

Describe How to Reproduce

docker run --rm -it --name peer1 -e CORE_VM_ENDPOINT=http://172.17.0.1:25 -e CORE_PEER_ID=vp0 -e CORE_PEER_ADDRESSAUTODETECT=true hyperledger-peer peer node start
{
  "jsonrpc": "2.0",
  "method": "deploy",
  "params": {
    "type": 1,
    "chaincodeID":{
        "path":"github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02"
    },
    "ctorMsg": {
        "function":"init",
        "args":["a", "1000", "b", "2000"]
    }
  },
  "id": 1
}
{
  "jsonrpc": "2.0",
  "method": "query",
  "params": {
      "type": 1,
      "chaincodeID":{
          "name":"7b07c59e9b9405c1aef33493b63b9a766d9bb836989ded1730052de650aa8ce5654274d148ceff96a4e5bd43bca26aba099f55c400e4befdc8b2ee4c0a94e30b",
          "path":"github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02"
      },
      "ctorMsg": {
         "function":"query",
         "args":["a"]
      }
  },
  "id": 5
}

When using docker inspect to find the status differences, I've found that {{ .NetworkSettings.Networks.host.EndpointID }} has been set, while after restarting peer node, that field is empty. It's reasonable to enhance the connection management between chaincode and peer, such that the chaincode is not needed to re-deploy whenever peer had been restarted.

corecode commented 8 years ago

@muralisrini