From 7cd552ac0e378280ac02b72e4d5aa567d243d04e Mon Sep 17 00:00:00 2001 From: Nicko Guyer Date: Wed, 2 Nov 2022 16:34:29 -0400 Subject: [PATCH 1/3] Create new guide for fabric test-network Signed-off-by: Nicko Guyer --- docs/_i18n/en.yml | 4 +- docs/tutorials/chains/fabric_remote.md | 256 --------------- docs/tutorials/chains/fabric_test_network.md | 316 +++++++++++++++++++ smart_contracts/fabric/firefly-go/go.mod | 26 ++ 4 files changed, 345 insertions(+), 257 deletions(-) delete mode 100644 docs/tutorials/chains/fabric_remote.md create mode 100644 docs/tutorials/chains/fabric_test_network.md diff --git a/docs/_i18n/en.yml b/docs/_i18n/en.yml index 9c50bf28c2..b741389d3f 100644 --- a/docs/_i18n/en.yml +++ b/docs/_i18n/en.yml @@ -51,4 +51,6 @@ pages: tutorials: Tutorials understanding_firefly: Understanding FireFly usage_patterns: Usage Patterns - web3_gateway_features: Web3 Gateway Features \ No newline at end of file + web3_gateway_features: Web3 Gateway Features + basic_auth: Enable Basic Auth + fabric_test_network: Fabric Test Network diff --git a/docs/tutorials/chains/fabric_remote.md b/docs/tutorials/chains/fabric_remote.md deleted file mode 100644 index f54fe08439..0000000000 --- a/docs/tutorials/chains/fabric_remote.md +++ /dev/null @@ -1,256 +0,0 @@ ---- -layout: i18n_page -title: pages.remote_fabric_network -parent: pages.chains -grand_parent: pages.tutorials -nav_order: 7 ---- - -# Work with remote Hyperledger Fabric Network -{: .no_toc } - -The FireFly CLI makes it quick and easy to create an entire FireFly development environment on your local machine, including a new blockchain from scratch. However, sometimes a developer may want to connect their local FireFly development environment to a Fabric network that already exists on their machine or elsewhere. This guide describes the steps to connect FireFly to an external Hyperledger Fabric blockchain network (not created by the FireFly CLI), including interacting with a custom chaincode in order to submit transactions and query for state. - -> **NOTE:** This guide assumes that you are already running a Hyperledger Fabric blockchain network and have a chaicode deployed in that network that you want to connect to with FireFly. - -## Table of contents -{: .no_toc .text-delta } - -1. TOC -{:toc} - ---- - -## Creating a FireFly stack with Fabric provider - -In the ff init command, pass fabric in the `-b` flag to select fabric as the blockchain provider. You can also pass an additional `--prompt-names` flag to give actual names for your organizations in the firefly setup. - -``` -ff init -b fabric --prompt-names -``` - -Choose a stack name. For this guide, I will choose the name `my-remote-fabric`, but you can pick whatever you want. - -``` -stack name: my-remote-fabric -``` - -For this guide, we will be creating only one supernode for one of the organizations in our fabric network and using that organizational identity to interact with the chaincode. You can create multiple supernodes for different organizations in your fabric network by passing here the number of members in your stack. - -``` -number of members: 1 -``` - -Next, you will be prompted to enter a name for your organization and node. If you selected more than 1 member for your stack in the previous step, it will prompt you to give name for each member. For this guide, I will choose the name `my-org` and `my-org-node`, but you can pick whatever you want. - -``` -name for org 0: my-org -name for node 0: my-org-node -``` - -At the end of it, you will be greeted with something like : - -``` -Stack 'my-remote-fabric' created! -To start your new stack run: - -ff start my-remote-fabric -``` - -Next, you need to edit your stack configuration before you run it. - -## Configuring the stack to connect to your remote Fabric network - -Now that you have created a stack, let's open it up in your favourite code editor to configure it further. By default, the path where it gets created in your system is `$HOME/.firefly/stacks/my-remote-fabric.` - -### Add msp folder representing your fabric identity - -In `$HOME/.firefly/stacks/my-remote-fabric`, you need to add a msp folder. This msp folder essentially describes the fabric organizational identity which will be interacting with your chaincode. Inside the msp folder, you must have all the certificates and the private key to be used by firefly to query/invoke your chaincode. - -You should be having this msp folder for an organizational identity from when you would have set up your fabric network. For more details, please refer to [Hyperledger Fabric Documentation for MSP](https://hyperledger-fabric.readthedocs.io/en/latest/msp.html). - -Now, you need to mount this msp directory as a docker volume in your fabconnect service. - -> **NOTE:** All docker-compose.yml related changes should be done in docker-compose.override.yml. - -For this, simply copy the fabconnect_0 service as it is from your docker-compose.yml and paste it in your docker-compose.override.yml. Next, in your docker-compose.override.yml, in the volumes section of the fabconnect_0 service, you need to add a new docker volume mapping your host's msp directory to your fabconnect_0 docker container's /etc/firefly/msp directory. - -It will look something like : - -``` --/Users//.firefly/stacks/my-remote-fabric/msp:/etc/firefly/msp -``` - -Your docker-compose.override.yml file after editing should look something like : - -``` -# Add custom config overrides here -# See https://docs.docker.com/compose/extends -version: "2.1" -services: - fabconnect_0: - container_name: my-remote-fabric_fabconnect_0 - image: ghcr.io/hyperledger/firefly-fabconnect@sha256:0dff97610990414d8ceb24859ced7712fa18b71b1d22b6a6f46fd51266413a22 - command: -f /fabconnect/fabconnect.yaml - volumes: - - fabconnect_receipts_0:/fabconnect/receipts - - fabconnect_events_0:/fabconnect/events - - /Users//.firefly/stacks/my-remote-fabric/runtime/blockchain/fabconnect.yaml:/fabconnect/fabconnect.yaml - - /Users//.firefly/stacks/my-remote-fabric/runtime/blockchain/ccp.yaml:/fabconnect/ccp.yaml - - /Users//.firefly/stacks/my-remote-fabric/msp:/etc/firefly/msp - - firefly_fabric:/etc/firefly - ports: - - 5102:3000 - depends_on: - fabric_ca: - condition: service_started - fabric_orderer: - condition: service_started - fabric_peer: - condition: service_started - healthcheck: - test: - - CMD - - wget - - -O - - '-' - - http://localhost:3000/status - logging: - driver: json-file - options: - max-file: "1" - max-size: 10m -``` - -> **NOTE:** If you had multiple members in your stack, with each member representing a different fabric organizational entity, then you would need to add separate msp folders for all of them in a similar manner - -### Edit your fabric connection profile (ccp.yml) - -In `$HOME/.firefly/stacks/my-remote-fabric/init/blockchain`, you will find a ccp.yml file which is mounted as a volume in our fabconnect service. This file is also commonly referred to as fabric connection profile. - -This ccp.yml file is written to connect to the default localhost containerized fabric network that is created by firefly CLI when you run your stack. You probably don't want to connect to that network since you are viewing this guide. So what you need to do is : - -* You need to edit this ccp.yml file and give your fabric network and client details here instead. -* For the `credentialStore/cryptoStore` path or the `cryptoconfig` path in your ccp.yml, you need to provide the path of your msp folder in your fabconnect docker container : `/etc/firefly/msp` -* For the `certificates/key` paths in your ccp.yml, you need to provide the paths of corresponding key/certificates in your msp folder in your fabconnect docker container :`/etc/firefly/msp/` - -Your ccp.yml file after editing should look something like : - -``` -certificateAuthorities: - my-fabric-network-ca: - tlsCACerts: - path: /etc/firefly/msp/tlscacerts/tls-ca-cert.pem - url: https://my-fabric-network-ca.my-domain.com:443 - registrar: - enrollId: my-enroll-id - enrollSecret: my-enroll-secret -channels: - my-channel: - orderers: - - my-orderer-node - peers: - my-peer-node: - chaincodeQuery: true - endorsingPeer: true - eventSource: true - ledgerQuery: true -client: - BCCSP: - security: - default: - provider: SW - enabled: true - hashAlgorithm: SHA2 - level: 256 - softVerify: true - credentialStore: - cryptoStore: - path: /etc/firefly/msp - path: /etc/firefly/msp - cryptoconfig: - path: /etc/firefly/msp - logging: - level: info - organization: my-org - tlsCerts: - client: - cert: - path: /etc/firefly/msp/signcerts/cert.pem - key: - path: /etc/firefly/msp/keystore/key.pem -orderers: - my-orderer-node: - tlsCACerts: - path: /etc/firefly/msp/tlscacerts/tls-ca-cert.pem - url: grpcs://my-orderer-node.my-domain.com:7050 -organizations: - my-org: - certificateAuthorities: - - my-fabric-network-ca - cryptoPath: /etc/firefly/msp - mspid: my-org-mspid - peers: - - my-peer-node -peers: - my-peer-node: - tlsCACerts: - path: /etc/firefly/msp/tlscacerts/tls-ca-cert.pem - url: grpcs://my-peer-node.my-domain.com:7051 -version: 1.1.0% - -``` - -> **NOTE:** If you had multiple members in your stack, with each member representing a different fabric organizational entity, then you would need to add separate ccp.yml files for all of them in a similar manner. - -## Setting up Batchpin chaincode and running your stack - -### Deploying batchpin chaincode to fabric network - -For Firefly to succeesfully integrate and interact with your remote fabric network, you need to also deploy a Firefly batchpin chaincode in your network setup. This chaincode can be found in the [FireFly git repo](https://github.com/hyperledger/firefly/tree/main/smart_contracts/fabric/firefly-go). - -Once you have successfully packaged, installed, approved and commited this chaincode in your remote fabric network, carefully note down the chaincode name you gave and the channel name where this chaincode is deployed for future reference. - -> **NOTE:** You can deploy the batchpin chaincode to the same channel where your application chaincode lives or to a separate channel as well. - -### Update batchpin chaincode details in firefly core config - -In `$HOME/.firefly/stacks/my-remote-fabric/init/config`, you will find a firefly_core_0.yml file which is used by firefly core service in our firefly network setup. - -In this file, under the fabconnect section of blockchain-fabric section, you need to change the chaincode value to your batchpin chaincode name, and the channel value to the channel name where your batchpin chaincode was deployed in the previous step. - -### Starting your FireFly stack - -To start your stack now, simply run: - -``` -ff start my-remote-fabric -``` - -This may take a minute or two and in the background the FireFly CLI will do the following for you: - -- Download Docker images for all the components of the Supernode -- Set up configuration between all the components -- Deploy FireFly's `BatchPin` smart contract to our remote fabric network -- Register an identity for each member and node in our remote fabric network -- It will probably also initialize a new blockchain and blockchain node running inside a container and also deploy an `ERC-1155` token smart contract to that local fabric network. This behaviour can be ignored. - -After your stack finishes starting it will print out the links to each member's UI and the Sandbox for that node. For this guide, it's just one member. - -``` -Web UI for member '0': http://127.0.0.1:5000/ui -Sandbox UI for member '0': http://127.0.0.1:5108 - -To see logs for your stack run: - -ff logs my-remote-fabric - -``` - -## Integrate your FireFly stack with your Fabric chaincode - -Once your stack is up and running, you can define and broadcast FireFly Interface Document for your remote fabric chaincode. You can refer to [Broadcast the Contract Interface(Fabric)](../custom_contracts/fabric.html#broadcast-the-contract-interface) guide for this. - -You can also now create an HTTP API for your fabric chaincode which will help you easily query/invoke all your chaincode methods with your organizational context that you set up in fabconnect. You can refer to [Create an HTTP API for the contract(Fabric)](../custom_contracts/fabric.html#create-an-http-api-for-the-contract) guide for this. - -To view the OpenAPI spec for your contract, or to submit transactions, query for states and listen for events, you can further refer to [Work with Hyperledger Fabric chaincodes](../custom_contracts/fabric.html#work-with-hyperledger-fabric-chaincodes) guide. diff --git a/docs/tutorials/chains/fabric_test_network.md b/docs/tutorials/chains/fabric_test_network.md new file mode 100644 index 0000000000..9853fcf6cd --- /dev/null +++ b/docs/tutorials/chains/fabric_test_network.md @@ -0,0 +1,316 @@ +--- +layout: i18n_page +title: pages.fabric_test_network +parent: pages.chains +grand_parent: pages.tutorials +nav_order: 7 +--- + +# Work with Fabric Test Network +{: .no_toc } + +## Table of contents +{: .no_toc .text-delta } + +1. TOC +{:toc} + +--- + +This guide will walk you through the steps to create a local FireFly development environment and connect it to the Fabric Test Network from the [Fabric Samples repo](https://github.com/hyperledger/fabric-samples) + +## Previous steps: Install the FireFly CLI +If you haven't set up the FireFly CLI already, please go back to the Getting Started guide and read the section on how to [Install the FireFly CLI](../../gettingstarted/firefly_cli.md). + +[← ① Install the FireFly CLI](../../gettingstarted/firefly_cli.md){: .btn .btn-purple .mb-5} + +## Start Fabric Test Network with Fabric CA + +For details about the Fabric Test Network and how to set it up, please see the [Fabric Samples repo](https://github.com/hyperledger/fabric-samples/tree/main/test-network). The one important detail is that you need to start up the Test Network with a Fabric CA. This is because Fabconnect will use the Fabric CA to create an identity for its FireFly node to use. To start up the network with the CA, and create a new channel called `mychannel` run: + +``` +./network.sh up createChannel -ca +``` + +> **NOTE**: If you already have the Test Network running, you will need to bring it down first, by running: `./network.sh down` + +## Deploy FireFly Chaincode + +Next we will need to package and deploy the FireFly chaincode to `mychannel` in our new network. For more details on packaging and deploying chaincode, please see the [Fabric chaincode lifecycle documentation](https://hyperledger-fabric.readthedocs.io/en/latest/chaincode_lifecycle.html). If you already have the [FireFly repo](https://github.com/hyperledger/firefly) cloned in the same directory as your `fabric-samples` repo, you can run the following script from your `test-network` directory: + +> **NOTE**: This script is provided as a convenience only, and you are not required to use it. You are welcome to package and deploy the chaincode to your test-network any way you would like. + +```bash +#!/bin/bash + +# This file should be run from the test-network directory in the fabric-samples repo +# It also assumes that you have the firefly repo checked out at the same level as the fabric-samples directory +# It also assumes that the test-network is up and running and a channel named 'mychannel' has already been created + +cd ../../firefly/smart_contracts/fabric/firefly-go +GO111MODULE=on go mod vendor +cd ../../../../fabric-samples/test-network + +export PATH=${PWD}/../bin:$PATH +export FABRIC_CFG_PATH=$PWD/../config/ + +peer lifecycle chaincode package firefly.tar.gz --path ../../firefly/smart_contracts/fabric/firefly-go --lang golang --label firefly_1.0 + +export CORE_PEER_TLS_ENABLED=true +export CORE_PEER_LOCALMSPID="Org1MSP" +export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt +export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp +export CORE_PEER_ADDRESS=localhost:7051 + +peer lifecycle chaincode install firefly.tar.gz + +export CORE_PEER_LOCALMSPID="Org2MSP" +export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt +export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp +export CORE_PEER_ADDRESS=localhost:9051 + +peer lifecycle chaincode install firefly.tar.gz + +export CC_PACKAGE_ID=$(peer lifecycle chaincode queryinstalled --output json | jq --raw-output ".installed_chaincodes[0].package_id") + +peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --channelID mychannel --name firefly --version 1.0 --package-id $CC_PACKAGE_ID --sequence 1 --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" + +export CORE_PEER_LOCALMSPID="Org1MSP" +export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp +export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt +export CORE_PEER_ADDRESS=localhost:7051 + +peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --channelID mychannel --name firefly --version 1.0 --package-id $CC_PACKAGE_ID --sequence 1 --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" + +peer lifecycle chaincode commit -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --channelID mychannel --name firefly --version 1.0 --sequence 1 --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" --peerAddresses localhost:7051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" +``` + +## Create `ccp.yml` documents + +Each FireFly Supernode (specifically the Fabconnect instance in each) will need to know how to connect to the Fabric network. Fabconnect will use a [Fabric Connection Profile](https://hyperledger-fabric.readthedocs.io/en/release-2.2/developapps/connectionprofile.html) which describes the network and tells it where the certs and keys are that it needs. Below is a `ccp.yml` for each organization. You will need to fill in one line by replacing the string `FILL_IN_KEY_NAME_HERE`, because the file name of the private key for each user is randomly generated. + +### Organization 1 connection profile + +Create a new file at `~/org1_ccp.yml` with the contents below. Replace the string `FILL_IN_KEY_NAME_HERE` with the filename in your `/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/keystore/` directory. + +```yml +certificateAuthorities: + org1.example.com: + tlsCACerts: + path: /etc/firefly/organizations/peerOrganizations/org1.example.com/msp/tlscacerts/ca.crt + url: https://ca_org1:7054 + grpcOptions: + ssl-target-name-override: org1.example.com + registrar: + enrollId: admin + enrollSecret: adminpw +channels: + mychannel: + orderers: + - fabric_orderer + peers: + fabric_peer: + chaincodeQuery: true + endorsingPeer: true + eventSource: true + ledgerQuery: true +client: + BCCSP: + security: + default: + provider: SW + enabled: true + hashAlgorithm: SHA2 + level: 256 + softVerify: true + credentialStore: + cryptoStore: + path: /etc/firefly/organizations/peerOrganizations/org1.example.com/msp + path: /etc/firefly/organizations/peerOrganizations/org1.example.com/msp + cryptoconfig: + path: /etc/firefly/organizations/peerOrganizations/org1.example.com/msp + logging: + level: info + organization: org1.example.com + tlsCerts: + client: + cert: + path: /etc/firefly/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/cert.pem + key: + path: /etc/firefly/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/FILL_IN_KEY_NAME_HERE +orderers: + fabric_orderer: + tlsCACerts: + path: /etc/firefly/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/tlscacerts/tls-localhost-9054-ca-orderer.pem + url: grpcs://orderer.example.com:7050 +organizations: + org1.example.com: + certificateAuthorities: + - org1.example.com + cryptoPath: /tmp/msp + mspid: Org1MSP + peers: + - fabric_peer +peers: + fabric_peer: + tlsCACerts: + path: /etc/firefly/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/tlscacerts/tls-localhost-7054-ca-org1.pem + url: grpcs://peer0.org1.example.com:7051 +version: 1.1.0% +``` + +### Organization 2 connection profile + +Create a new file at `~/org2_ccp.yml` with the contents below. Replace the string `FILL_IN_KEY_NAME_HERE` with the filename in your `/fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp/keystore/` directory. + +```yml +certificateAuthorities: + org2.example.com: + tlsCACerts: + path: /etc/firefly/organizations/peerOrganizations/org2.example.com/msp/tlscacerts/ca.crt + url: https://ca_org2:8054 + grpcOptions: + ssl-target-name-override: org2.example.com + registrar: + enrollId: admin + enrollSecret: adminpw +channels: + mychannel: + orderers: + - fabric_orderer + peers: + fabric_peer: + chaincodeQuery: true + endorsingPeer: true + eventSource: true + ledgerQuery: true +client: + BCCSP: + security: + default: + provider: SW + enabled: true + hashAlgorithm: SHA2 + level: 256 + softVerify: true + credentialStore: + cryptoStore: + path: /etc/firefly/organizations/peerOrganizations/org2.example.com/msp + path: /etc/firefly/organizations/peerOrganizations/org2.example.com/msp + cryptoconfig: + path: /etc/firefly/organizations/peerOrganizations/org2.example.com/msp + logging: + level: info + organization: org2.example.com + tlsCerts: + client: + cert: + path: /etc/firefly/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/signcerts/cert.pem + key: + path: /etc/firefly/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/keystore/FILL_IN_KEY_NAME_HERE +orderers: + fabric_orderer: + tlsCACerts: + path: /etc/firefly/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/tlscacerts/tls-localhost-9054-ca-orderer.pem + url: grpcs://orderer.example.com:7050 +organizations: + org2.example.com: + certificateAuthorities: + - org2.example.com + cryptoPath: /tmp/msp + mspid: Org2MSP + peers: + - fabric_peer +peers: + fabric_peer: + tlsCACerts: + path: /etc/firefly/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/tlscacerts/tls-localhost-8054-ca-org2.pem + url: grpcs://peer0.org2.example.com:9051 +version: 1.1.0% +``` + +## Create the FireFly stack + +Now we can create a FireFly stack and pass in these files as command line flags: + +``` +ff init fabric dev \ + --ccp "${HOME}/org1_ccp.yml" \ + --msp "organizations" \ + --ccp "${HOME}/org2_ccp.yml" \ + --msp "organizations" \ + --channel mychannel \ + --chaincode firefly +``` + +## Edit `docker-compose.override.yml` + +The last step before starting up FireFly is to make sure that our FireFly containers have networking access to the Fabric containers. Because these are in two different Docker Compose networks by default, normally the containers would not be able to connect directly. We can fix this by instructing Docker to also attach our FireFly containers to the Fabric test network Docker Compose network. The easiest way to do that is to edit `~/.firefly/stacks/dev/docker-compose.override.yml` and set its contents to the following: + +```yml +# Add custom config overrides here +# See https://docs.docker.com/compose/extends +version: "2.1" +networks: + default: + name: fabric_test + external: true +``` + +## Start FireFly stack + +Now we can start up FireFly! + +``` +ff start dev +``` + +After everything starts up, you should have two FireFly nodes that are each mapped to an Organization in your Fabric network. You can that they each use separate signing keys for their Org on messages that each FireFly node sends. + +## Connecting to a remote Fabric Network + +This same guide can be adapted to connect to a remote Fabric network running somewhere else. They key takeaways are: + +- You need the FireFly chaincode deployed on channel in your Fabric network +- You need to pass the channel and chaincode name when you run `ff init` +- You need to provide a connection profile and the correct certs, keys, etc. for each node when you run `ff init` +- Your FireFly containers will need to have network access to your Fabric network + + +## Troubleshooting + +There are quite a few moving parts in this guide and if steps are missed or done out of order it can cause problems. Below are some of the common situations that you might run into while following this guide, and solutions for each. + +You may see a message something along the lines of: + +``` +ERROR: for firefly_core_0 Container "bc04521372aa" is unhealthy. +Encountered errors while bringing up the project. +``` + +In this case, we need to look at the container logs to get more detail about what happened. To do this, we can run `ff start` and tell it not to clean up the stack after the failure, to let you inspect what went wrong. To do that, you can run: + +``` +ff start dev --verbose --no-rollback +``` + +Then we could run `docker logs ` to see the logs for that container. + +### No such host + +``` +Error: http://127.0.0.1:5102/identities [500] {"error":"enroll failed: enroll failed: POST failure of request: POST https://ca_org1:7054/enroll\n{\"hosts\":null,\"certificate_request\":\"-----BEGIN CERTIFICATE REQUEST-----\\nMIH0MIGcAgEAMBAxDjAMBgNVBAMTBWFkbWluMFkwEwYHKoZIzj0CAQYIKoZIzj0D\\nAQcDQgAE7qJZ5nGt/kxU9IvrEb7EmgNIgn9xXoQUJLl1+U9nXdWB9cnxcmoitnvy\\nYN63kbBuUh0z21vOmO8GLD3QxaRaD6AqMCgGCSqGSIb3DQEJDjEbMBkwFwYDVR0R\\nBBAwDoIMMGQ4NGJhZWIwZGY0MAoGCCqGSM49BAMCA0cAMEQCIBcWb127dVxm/80K\\nB2LtenAY/Jtb2FbZczolrXNCKq+LAiAcGEJ6Mx8LVaPzuSP4uGpEoty6+bEErc5r\\nHVER+0aXiQ==\\n-----END CERTIFICATE REQUEST-----\\n\",\"profile\":\"\",\"crl_override\":\"\",\"label\":\"\",\"NotBefore\":\"0001-01-01T00:00:00Z\",\"NotAfter\":\"0001-01-01T00:00:00Z\",\"ReturnPrecert\":false,\"CAName\":\"\"}: Post \"https://ca_org1:7054/enroll\": dial tcp: lookup ca_org1 on 127.0.0.11:53: no such host"} +``` + +If you see something in your logs that looks like the above, there could be a couple issues: + +1. The hostname for one of your Fabric containers could be wrong in the `ccp.yml`. Check the `ccp.yml` for that member and make sure the hostnames are correct. +1. The FireFly container doesn't have networking connectivity to the Fabric containers. Check the `docker-compose.override.yml` file to make sure you added the `fabric_test` network as instructed above. + +### No such file or directory + +``` +User credentials store creation failed. Failed to load identity configurations: failed to create identity config from backends: failed to load client TLSConfig : failed to load client key: failed to load pem bytes from path /etc/firefly/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/keystore/cfc50311e2204f232cfdfaf4eba7731279f2366ec291ca1c1781e2bf7bc75529_sk: open /etc/firefly/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/keystore/cfc50311e2204f232cfdfaf4eba7731279f2366ec291ca1c1781e2bf7bc75529_sk: no such file or directory +``` + +If you see something in your logs that looks like the above, it's likely that your private key file name is not correct in your `ccp.yml` file for that particular member. Check your `ccp.yml` and make sure all the files listed there exist in your `organizations` directory. \ No newline at end of file diff --git a/smart_contracts/fabric/firefly-go/go.mod b/smart_contracts/fabric/firefly-go/go.mod index c02aeea325..05f3196833 100644 --- a/smart_contracts/fabric/firefly-go/go.mod +++ b/smart_contracts/fabric/firefly-go/go.mod @@ -10,3 +10,29 @@ require ( github.com/stretchr/testify v1.5.1 google.golang.org/protobuf v1.23.0 ) + +require ( + github.com/PuerkitoBio/purell v1.1.1 // indirect + github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/go-openapi/jsonpointer v0.19.3 // indirect + github.com/go-openapi/jsonreference v0.19.2 // indirect + github.com/go-openapi/spec v0.19.4 // indirect + github.com/go-openapi/swag v0.19.5 // indirect + github.com/gobuffalo/envy v1.7.0 // indirect + github.com/gobuffalo/packd v0.3.0 // indirect + github.com/gobuffalo/packr v1.30.1 // indirect + github.com/joho/godotenv v1.3.0 // indirect + github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/rogpeppe/go-internal v1.3.0 // indirect + github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect + github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect + github.com/xeipuuv/gojsonschema v1.2.0 // indirect + golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 // indirect + golang.org/x/sys v0.0.0-20190710143415-6ec70d6a5542 // indirect + golang.org/x/text v0.3.2 // indirect + google.golang.org/genproto v0.0.0-20180831171423-11092d34479b // indirect + google.golang.org/grpc v1.23.0 // indirect + gopkg.in/yaml.v2 v2.2.8 // indirect +) From e66bc8082bef01ca80e52deb48d1287d1c668ecb Mon Sep 17 00:00:00 2001 From: Nicko Guyer Date: Thu, 3 Nov 2022 11:30:18 -0400 Subject: [PATCH 2/3] Add note on ff init command in new fabric tutorial Signed-off-by: Nicko Guyer --- docs/tutorials/chains/fabric_test_network.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/tutorials/chains/fabric_test_network.md b/docs/tutorials/chains/fabric_test_network.md index 9853fcf6cd..48e44944df 100644 --- a/docs/tutorials/chains/fabric_test_network.md +++ b/docs/tutorials/chains/fabric_test_network.md @@ -231,7 +231,9 @@ version: 1.1.0% ## Create the FireFly stack -Now we can create a FireFly stack and pass in these files as command line flags: +Now we can create a FireFly stack and pass in these files as command line flags. + +> **NOTE**: The following command should be run in the `test-network` directory as it includes a relative path to the `organizations` directory containing each org's MSP. ``` ff init fabric dev \ From 9bbec3b7a008bc66a93c2b3a20c38229b19472e4 Mon Sep 17 00:00:00 2001 From: Nicko Guyer Date: Fri, 4 Nov 2022 10:58:46 -0400 Subject: [PATCH 3/3] Add clarification to new fabric test network tutorial Signed-off-by: Nicko Guyer --- docs/_i18n/en.yml | 2 +- docs/tutorials/chains/fabric_test_network.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/_i18n/en.yml b/docs/_i18n/en.yml index b741389d3f..fb9865e5d1 100644 --- a/docs/_i18n/en.yml +++ b/docs/_i18n/en.yml @@ -53,4 +53,4 @@ pages: usage_patterns: Usage Patterns web3_gateway_features: Web3 Gateway Features basic_auth: Enable Basic Auth - fabric_test_network: Fabric Test Network + fabric_test_network: Fabric-Samples Test Network diff --git a/docs/tutorials/chains/fabric_test_network.md b/docs/tutorials/chains/fabric_test_network.md index 48e44944df..21201716f3 100644 --- a/docs/tutorials/chains/fabric_test_network.md +++ b/docs/tutorials/chains/fabric_test_network.md @@ -6,7 +6,7 @@ grand_parent: pages.tutorials nav_order: 7 --- -# Work with Fabric Test Network +# Work with Fabric-Samples Test Network {: .no_toc } ## Table of contents