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

User has no way to determine if Chaincode Deployment failed #2187

Open juliancarrivick-ibm opened 8 years ago

juliancarrivick-ibm commented 8 years ago

Description

When Chaincode deployment fails the only way of determining this is by looking at the logs. It would be nice if there was a way for a user to query a chaincode's state and see if it has deployed successfully and if not, the reason why.

Describe How to Reproduce

Bring up a Validating Peer:

docker run -d --name vp0 -p 5000:5000 -e CORE_VM_ENDPOINT=http://172.17.0.1:2375 -e CORE_PEER_ID=vp0 -e CORE_PEER_ADDRESSAUTODETECT=true -e CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN=noops hyperledger/fabric-peer peer node start

Attempt to deploy a chaincode with the incorrect parameters: HTTP POST: http://localhost:5000/chaincode

{
  "jsonrpc": "2.0",
  "method": "deploy",
  "params": {
    "type": 1,
    "chaincodeID": {
      "path": "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02"
    },
    "ctorMsg": {
      "function": "init",
      "args": [
        "test", "100", "params", "10", "extra", "params"
      ]
    }
  },
  "id": 0
}

You will see that the response indicates a success:

{
  "jsonrpc": "2.0",
  "result": {
    "status": "OK",
    "message": "51c2793ead88cb2a785180261cfff676e7ee6c12882cecced73ed4c30e9eabc858de3e653672e48428145825e171b3f6dfe31e03e3a2f5e1368fdec0edfefaf3"
  },
  "id": 0
}

But there are errors in the logs:

05:30:28.387 [rest] ProcessChaincode -> INFO 01d REST successfully deploy chaincode: {"jsonrpc":"2.0","result":{"status":"OK","message":"51c2793ead88cb2a785180261cfff676e7ee6c12882cecced73ed4c30e9eabc858de3e653672e48428145825e171b3f6dfe31e03e3a2f5e1368fdec0edfefaf3"},"id":0}
05:30:29.836 [chaincode] processStream -> ERRO 01e Got error: Incorrect number of arguments. Expecting 4
05:30:29.836 [chaincode] Launch -> ERRO 01f sending init failed(Error initializing container 51c2793ead88cb2a785180261cfff676e7ee6c12882cecced73ed4c30e9eabc858de3e653672e48428145825e171b3f6dfe31e03e3a2f5e1368fdec0edfefaf3: Incorrect number of arguments. Expecting 4)
05:30:29.877 [chaincode] processStream -> ERRO 020 Error handling chaincode support stream: connection error: desc = "transport is closing"

A user can still invoke transactions successfully: HTTP POST: localhost:5000/chaincode

{
  "jsonrpc": "2.0",
  "method": "invoke",
  "params": {
    "type": 1,
    "chaincodeID": {
      "name": "51c2793ead88cb2a785180261cfff676e7ee6c12882cecced73ed4c30e9eabc858de3e653672e48428145825e171b3f6dfe31e03e3a2f5e1368fdec0edfefaf3"
    },
    "ctorMsg": {
      "function": "invoke",
      "args": [
        "test", "params", "5"
      ]
    }
  },
  "id": 0
}

Response:

{
  "jsonrpc": "2.0",
  "result": {
    "status": "OK",
    "message": "141eab1f-2903-4efa-8467-0c0a1504c9c6"
  },
  "id": 0
}

But queries fail: HTTP POST: localhost:5000/chaincode

{
  "jsonrpc": "2.0",
  "method": "query",
  "params": {
    "type": 1,
    "chaincodeID": {
      "name": "51c2793ead88cb2a785180261cfff676e7ee6c12882cecced73ed4c30e9eabc858de3e653672e48428145825e171b3f6dfe31e03e3a2f5e1368fdec0edfefaf3"
    },
    "ctorMsg": {
      "function": "query",
      "args": [
        "test"
      ]
    }
  },
  "id": 0
}

Response:

{
  "jsonrpc": "2.0",
  "error": {
    "code": -32003,
    "message": "Query failure",
    "data": "Error when querying chaincode: Error:Failed to launch chaincode spec(Could not get deployment transaction for 51c2793ead88cb2a785180261cfff676e7ee6c12882cecced73ed4c30e9eabc858de3e653672e48428145825e171b3f6dfe31e03e3a2f5e1368fdec0edfefaf3 - LedgerError - ResourceNotFound: ledger: resource not found)"
  },
  "id": 0
}
bcbrock commented 8 years ago

@juliancarrivick-ibm Great minds... See for example #2068