Skip to content

Feature request: hands-off CCaaS #644

@joaormatos

Description

@joaormatos

I would like the ability to start CCaaS servers manually and have Fablo just generate and install the CCaaS packages containing metadata and connection information.

The motivation is being able to easily start CCaaS instances directly from an IDE with a debugger.

Crude workaround

I managed to get it working manually, for a single peer and chaincode.
I leave the steps I took here as an inspiration for others in the same situation.

First I started Fablo normally, with a regular chaincode definition in the config.
Then I did something like this:

metadata.json:

{
  "path":"",
  "type":"ccaas",
  "label":"mycc"
}

connection.json:

{
  "address": "172.17.0.1:10000",
  "dial_timeout": "10s",
  "tls_required": false
}

Where 172.17.0.1 is the IP address of the host as seen from the peer's container and 10000 is the port I chose to have the chaincode listening on.
I got the address with ip addr show docker0 on the host.

# Create and install package
tar czf code.tar.gz connection.json
tar czf package.tar.gz metadata.json code.tar.gz
cp package.tar.gz fablo-target/fabric-config/chaincode-packages/
docker exec -e CORE_PEER_ADDRESS=peer0.org1.example.com:7041 cli.org1.example.com peer lifecycle chaincode install /var/hyperledger/cli/chaincode-packages/package.tar.gz
# Re-issue the approveformyorg command so that the peer starts using the newly installed package
# No commit is necessary because Fablo already did that and I didn't change any parameters besides --package-id 
pkgid="$(docker exec -e CORE_PEER_ADDRESS=peer0.org1.example.com:7041 cli.org1.example.com peer lifecycle chaincode calculatepackageid /var/hyperledger/cli/chaincode-packages/package.tar.gz)"
docker exec -e CORE_PEER_ADDRESS=peer0.org1.example.com:7041 cli.org1.example.com peer lifecycle chaincode approveformyorg -o orderer0.group1.orderer.example.com:7030 -C my-channel1 -n mychaincode -v 0.0.1 --package-id "$pkgid" --sequence 1

Finally, I started the chaincode in vscode with a launch.json looking something like this:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "My Chaincode for Org1",
      "type": "go",
      "request": "launch",
      "mode": "auto",
      "env": {
        "CORE_PEER_TLS_ENABLED": "false",
        "CORE_CHAINCODE_ID_NAME": "mycc:49009f43ca0943550cea0b6341aa51f39e0931fe1b5b64fba07ea13cac683ff9",
        "CHAINCODE_SERVER_ADDRESS": "172.17.0.1:10000"
      },
      "program": "${workspaceFolder}/chaincodes/mychaincode"
    }
  ]
}

This was a very crude workaround, but for now it's working how I want it to and it's starting to approach a decent development experience.

I can now rapidly iterate on the code, set logpoints, breakpoints, step through the execution, inspect the call stack....
All that good stuff.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions