Skip to content

Commit

Permalink
initial code commit
Browse files Browse the repository at this point in the history
Signed-off-by: Varad Ramamoorthy <[email protected]>
  • Loading branch information
varadgit committed Jul 7, 2021
1 parent 9dd3100 commit 0bd6cfd
Show file tree
Hide file tree
Showing 1,058 changed files with 377,464 additions and 7 deletions.
195 changes: 188 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,204 @@
# Fabric Operations Console

# Short Description
Hyperledger Fabric Operations Console code used in the IBM Blockchain Platform Offering.

# Scope of Lab
Hyperledger Fabric Operations Console used in the IBM Blockchain Platform Offering.

The console provides the following high level function:

- Ability to import and manage all Hyperledger Fabric Components from a single web console, no matter where they are located.
- Maintain complete control over identities, channels, and smart contracts.
- Join Peers to Channels and view channel membership as well as individual transactions and channel details.
- Register, view, delete, and re-enroll CA Users.
- View Ordering cluster and node information as well as view and modify consortium and channel membership.
- View and modify channel capabilites and ordering service parameters.
- View and modify channel capabilities and ordering service parameters.
- Install and Instantiate chaincode. Supports both 1.x and 2.x Lifecycle.
- View, Create, Import and Export Organizations and Identities.
- Role Based Access Control in UI to tightly control which Console users can perform which operations.

The console relies on [GRPC web](https://grpc.io/docs/platforms/web/) to allow GRPC based communication with Orderers and Peers via Node.js. Management of Certificate Authorities is done via REST API and does not require a GRPC Web Instance.

For more Information see the [documentation for the current IBM production offerings](https://cloud.ibm.com/docs/blockchain-sw-252?topic=blockchain-sw-252-ibp-console-govern) which are driven by the code in this Lab proposal.

# Running Fabric Operations Console

You can use the following steps to provision a network using Fabric test-network, add grpc-web proxy on that of that and import components into Console so that you can manage the test network.
## Prerequisites
* jq
* docker
* docker-compose

## Setup
Clone console

`git clone https://github.com/IBM-Blockchain/console`

`cd console`

## Bring up a Fabric 2.2.3 network
You can find more information on the test network setup from here
https://hyperledger-fabric.readthedocs.io/en/latest/test_network.html

`./scripts/setupNetwork.sh up`

## Build grpc proxy image
Ensure that the `docker` has enough resources to be able to build the images. We recommend 2 CPUs and 4 GB RAM available to build.

`./scripts/buildImages.sh`

If you do not have enough memory allocated to docker, the following command will fail with out of memory error similar to the below.

```#16 109.5 The build failed because the process exited too early. This probably means the system ran out of memory or someone called `kill -9` on the process.```

## Bring up console
`./scripts/setupConsole.sh up`

## Create zip file
Run the following command to create a zip of the console JSONs to match the network setup above

`./scripts/createAssets.sh`

## Console setup
* Open browser to URL http://localhost:3000/
* Login with admin/password
* Change password

### Import components into console
* Switch to "Settings" page 
* Click "Import"
* Select zip file ./workarea/console_assets.zip

### Create Identities
* Switch to Nodes page and perform the following steps
#### org1ca
* Select CA "org1ca-local"
* Associate Identity
* Enter admin/adminpw for enroll id and secret
* Select the overflow menu (3 dots) against "org1admin"
* Select "Enroll identity"
* Enter "org1adminpw" for Enroll secret
* Next
* Enter identity display name as "Org1MSP Admin"
* Click "Add Identity to wallet"

#### org2ca
* Select CA "org2ca-local"
* Associate Identity
* Enter admin/adminpw for enroll id and secret
* Select the overflow menu (3 dots) against "org2admin"
* Select "Enroll identity"
* Enter "org2adminpw" for Enroll secret
* Next
* Enter identity display name as "Org2MSP Admin"
* Click "Add Identity to wallet"

#### ordererca
* Select CA "ordererca-local"
* Associate Identity
* Enter admin/adminpw for enroll id and secret
* Select the overflow menu (3 dots) against "ordererAdmin"
* Select "Enroll identity"
* Enter "ordererAdminpw" for Enroll secret
* Next
* Enter identity display name as "OrdererMSP Admin"
* Click "Add Identity to wallet"

### Associate Identity
* Switch to Nodes page and perform the following steps
* Select peer "org1_peer1 - local"
* Associate Identity
* Select "Org1MSP Admin"

* Select peer "org2_peer1 - local"
* Associate Identity
* Select "Org2MSP Admin"

* Select orderer "orderer_local"
* Associate Identity
* Select "OrdererMSP Admin"

## Enjoy!
You should be able to manage channels, Using 2.0 lifecycle to install, approve, commit smart contracts following the guide

## Bring down network

`./scripts/setupConsole.sh down`

`./scripts/setupNetwork.sh down`


## couchdb credentials (for console)
* URL - http://127.0.0.1:5985/_utils/
* Login - admin/password

# Developing Fabric Operations Console
This repository is managed using [Lerna](https://github.com/lerna/lerna).

It contains the following applications:

- **packages/apollo**: Frontend React.js for the console
- **packages/athena**: Backend server for the console
- **packages/stitch**:


To run commands in this repository, install lerna:
```sh
npm install -g lerna
```

For more information, see the documentation at: https://lerna.js.org/

## Install

```sh
lerna bootstrap
```

_Note: You can use `lerna clean && lerna bootstrap` to delete existing `node_modules` before lerna runs `npm install`._

## Usage


<!-- ### Running
```sh
lerna ...
``` -->

### Developing Athena

Builds Apollo and starts the file watcher for Athena.

Before running, ensure that you have the necessary local env files in the `packages/athena/env` directory. See the [athena readme](https://github.com/IBM-Blockchain/console/tree/main/packages/athena#acquiring-a-deployer-backend) for all the details on what these files should contain.

```sh
lerna run dev:athena
```

### Developing Apollo

Starts Apollo and Athena in dev mode. Apollo proxies its backend requests to Athena.

```sh
lerna run dev:apollo
```

_Note: even though this command is for running Apollo in dev mode, Athena still needs a production build of Apollo to start. If this command fails, it's likely because there is no Apollo build present._

## Run tests

```sh
lerna run test
```

## Building the Docker image

There is a Makefile in the `common/deploy_scripts` directory. It contains commands to `build`, `tag` and `push` the console image.

Example usage (from the root directory):

```bash
./docker/build_image.sh
```

## Notes:
* When making a Git commit, a pre-commit Git hook will call `lerna run lint`.
* When pushing to Git, a pre-push Git hook that calls `detect-secrets-hook` will be run. To install this utility you'll need Python 3.x and `pip`. Once installed, run the following command from the root directory:
```bash
npm run install-detect-secrets
```
11 changes: 11 additions & 0 deletions cSpell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"dictionaryDefinitions": [
{
"name": "blockchainTerms",
"path": "./dictionary_blockchain.txt"
}
],
"dictionaries": [
"blockchainTerms"
]
}
21 changes: 21 additions & 0 deletions common/deploy_scripts/edit_package.json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//------------------------------------------------------------
// edit_package.json.js - remove dev dependencies from package.json to prevent npm audit from failing on dev modules
//------------------------------------------------------------
const fs = require('fs');
const package_json = JSON.parse(fs.readFileSync('./package.json'));
fs.writeFileSync('./package.orig.json', JSON.stringify(package_json, null, '\t'));
delete package_json.devDependencies;
fs.writeFileSync('./package.json', JSON.stringify(package_json, null, '\t'));
38 changes: 38 additions & 0 deletions common/deploy_scripts/test_run_athena.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
# ------------------------------------------------------------------------
# This script attempt to start athena with some placeholder settings just to make sure it runs
# ------------------------------------------------------------------------

# export these values so the subshell running athena will be able to see them
export HOST_URL="${HOST_URL:=http://localhost:3000}"
export DB_SYSTEM="${DB_SYSTEM:=athena_system}"
export DB_CONNECTION_STRING="${DB_CONNECTION_STRING:=http://localhost:5984}"

echo "HOST_URL=$HOST_URL"
echo "DB_SYSTEM=$DB_SYSTEM"
echo "DB_CONNECTION_STRING=$DB_CONNECTION_STRING"

echo "Start Athena as a background process"
node ../../packages/athena/app.js &
NODE_PID=$!

i=0
while [[ "$status" != "204" && "$i" -lt "5" ]]; do #loop a few times
echo "Sleep $((i*2+4))s before checking Athena $([[ $i -gt 0 ]] && echo "again $i" || echo "$i")"
sleep $((i*2+4))s
((i+=1))
status=$(curl -LI $HOST_URL -o /dev/null -w '%{http_code}\n' -s || true)
echo "Curl response status: $status"
done

echo "Killing background athena process: $NODE_PID"
ps -f
kill -9 $NODE_PID || true

echo "Stop Travis"
if [ "$status" == 204 ]; then
echo "athena responded w/204"
else
echo "athena did not respond w/204. ${status}"
exit 1
fi
11 changes: 11 additions & 0 deletions common/templates/Certificate_Authorities/ordererca-local_ca.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"display_name": "ordererca - local",
"api_url": "https://ca_orderer:9054",
"operations_url": "http://ca_orderer:19054",
"ca_url": "https://ca_orderer:9054",
"type": "fabric-ca",
"ca_name": "ca-orderer",
"tlsca_name": "ca-orderer",
"tls_cert": "<TLS_CERT>",
"name": "ordererca - local"
}
11 changes: 11 additions & 0 deletions common/templates/Certificate_Authorities/org1ca-local_ca.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"display_name": "org1ca - local",
"api_url": "https://ca_org1:7054",
"operations_url": "http://ca_org1:17054",
"ca_url": "https://ca_org1:7054",
"name": "org1ca - local",
"type": "fabric-ca",
"ca_name": "ca-org1",
"tlsca_name": "ca-org1",
"tls_cert": "<TLS_CERT>"
}
11 changes: 11 additions & 0 deletions common/templates/Certificate_Authorities/org2ca-local_ca.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"display_name": "org2ca - local",
"api_url": "https://ca_org2:8054",
"operations_url": "http://ca_org2:18054",
"name": "org2ca - local",
"ca_url": "https://ca_org2:8054",
"type": "fabric-ca",
"ca_name": "ca-org2",
"tlsca_name": "ca-org2",
"tls_cert": "<TLS_CERT>"
}
30 changes: 30 additions & 0 deletions common/templates/Ordering_Services/orderer-local_orderer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"display_name": "ordering node - local",
"grpcwp_url": "https://proxy.orderer.example.com:7445",
"api_url": "grpcs://orderer.example.com:7050",
"operations_url": "http://orderer.example.com:17050",
"type": "fabric-orderer",
"msp_id": "OrdererMSP",
"system_channel_id": "system-channel",
"cluster_id": "kcfhqzuxci",
"cluster_name": "orderer_local",
"name": "ordering node - local",
"msp": {
"component": {
"tls_cert": "<CERT>"
},
"ca": {
"root_certs": [
"<CERT>"
]
},
"tlsca": {
"root_certs": [
"<CERT>"
]
}
},
"pem": "<CERT>",
"tls_cert": "<CERT>",
"tls_ca_root_cert": "<CERT>"
}
33 changes: 33 additions & 0 deletions common/templates/Organizations/orderermsp_msp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"display_name": "Orderer MSP",
"msp_id": "OrdererMSP",
"type": "msp",
"admins": [],
"root_certs": [
"<CERT>"
],
"tls_root_certs": [
"<CERT>"
],
"fabric_node_ous": {
"admin_ou_identifier": {
"certificate": "<CERT>",
"organizational_unit_identifier": "admin"
},
"client_ou_identifier": {
"certificate": "<CERT>",
"organizational_unit_identifier": "client"
},
"enable": true,
"orderer_ou_identifier": {
"certificate": "<CERT>",
"organizational_unit_identifier": "orderer"
},
"peer_ou_identifier": {
"certificate": "<CERT>",
"organizational_unit_identifier": "peer"
}
},
"host_url": "http://localhost:3002",
"name": "Orderer MSP"
}
Loading

0 comments on commit 0bd6cfd

Please sign in to comment.