Skip to content

Commit 13a2097

Browse files
g2flyermbrandenburger
authored andcommitted
(Mostly) Documentation improvements
* document options to run network with couchdb and/or hl explorer * document how to run docker-compose behind proxy and improve docu related to proxies * some minimal extensions of the demo docu and a reference thereof in the top README * a few improvements in network setup script Signed-off-by: michael steiner <[email protected]>
1 parent 1dde82f commit 13a2097

File tree

10 files changed

+136
-44
lines changed

10 files changed

+136
-44
lines changed

README.md

Lines changed: 62 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -110,34 +110,41 @@ your [development environment](https://hyperledger-fabric.readthedocs.io/en/rele
110110

111111
Moreover, we assume that you are familiar with the Intel SGX SDK.
112112

113-
### Intel SGX SDK and SSL
113+
### Intel SGX
114114

115-
Fabric Private Chaincode requires the Intel [SGX SDK](https://github.com/intel/linux-sgx) and
116-
[SGX SSL](https://github.com/intel/intel-sgx-ssl) to build the main components of our framework and to develop and build
117-
your first private chaincode.
118-
119-
Install the Intel SGX software stack for Linux (including the SGX driver, the SGX SDK, and the SGX Platform Software
120-
(PSW)) by following the official [documentation](https://github.com/intel/linux-sgx). Please make sure that you use the
121-
SDK version as denoted above in the list of requirements.
122-
123-
Moreover, if you don't have SGX hardware available you can also install the SGX SDK only and use simulation mode by
124-
setting `SGX_MODE=SIM` in your environment. In this case, also make sure that simulation mode is set when building
125-
and installing [SGX SSL](https://github.com/intel/intel-sgx-ssl#available-make-flags). Note that the simulation mode is
126-
for developing purpose only and does not provide any security guarantees.
115+
To run Fabric Private Chaincode in secure mode, you need an SGX-enabled
116+
hardware as well corresponding OS support. However, even if you don't
117+
have SGX hardware available, you still can run FPC in simulation mode by
118+
setting `SGX_MODE=SIM` in your environment.
127119

128-
Once you have installed the SGX SDK and SSL for SGX SDK please double check that ``SGX_SDK`` and ``SGX_SSL`` variables
129-
are set correctly in your environment.
120+
Note that the simulation mode is for developing purpose only and does
121+
not provide any security guarantees.
130122

131123
Notice: by default the project builds in hardware-mode SGX, ``SGX_MODE=HW`` as defined in `<absolute-project-path>/fabric-private-chaincode/config.mk` and you can
132124
explicitly opt for building in simulation-mode SGX, ``SGX_MODE=SIM``. In order to set non-default values for install
133125
location, or for building in simulation-mode SGX, you can create the file `<absolute-project-path>/fabric-private-chaincode/config.override.mk` and override the default
134126
values by defining the corresponding environment variable.
135127

136-
#### Register with Intel Attestation Service (IAS) if using SGX_MODE=HW
128+
If you run SGX in __simulation mode only__, you can skip below
129+
sections and jump right away to [Setup your Development
130+
Environment](#setup-your-development-environment).
131+
132+
Note that you can always come back here when you want a setup with SGX
133+
hardware-mode later after having tested with simulation mode.
134+
135+
136+
#### Install SGX Operation System Support
137+
138+
Install the Intel SGX software stack for Linux (including the SGX
139+
driver and the SGX Platform Software (PSW)) by following the official
140+
[documentation](https://github.com/intel/linux-sgx).
141+
142+
143+
#### Register with Intel Attestation Service (IAS)
144+
145+
We currently support EPID-based attestation and use the Intel's
146+
Attestation Service to perform attestation with chaincode enclaves.
137147

138-
We use Intel's Attestation Service to perform attestation with chaincode enclaves. If you run SGX in __simulation mode__
139-
only, you can skip this section and come back when you want setup with SGX hardware-mode.
140-
141148
What you need:
142149

143150
* a Service Provider ID (SPID)
@@ -213,7 +220,7 @@ Optional: to do a clean build do the following within the container
213220
<docker-root>:project/src/github.com/hyperledger-labs/fabric-private-chaincode# make build
214221
```
215222
Now you are ready to start development. Go to the [Develop Your First Private Chaincode
216-
](#developing-your-first-private-chaincode) section.
223+
](#your-first-private-chaincode) section.
217224

218225
### Option 2: Setting up your system to do local development
219226

@@ -243,6 +250,26 @@ Make sure that you have the following required dependencies installed:
243250

244251
* [PlantUML](http://plantuml.com/) including Graphviz (for building documentation only)
245252

253+
#### Intel SGX SDK and SSL
254+
255+
Fabric Private Chaincode requires the Intel [SGX SDK](https://github.com/intel/linux-sgx) and
256+
[SGX SSL](https://github.com/intel/intel-sgx-ssl) to build the main components of our framework and to develop and build
257+
your first private chaincode.
258+
259+
Install the Intel SGX software stack for Linux by following the
260+
official [documentation](https://github.com/intel/linux-sgx). Please make sure that you use the
261+
SDK version as denoted above in the list of requirements.
262+
263+
For SGX SSL, just follow the instructions on the [corresponding
264+
github page](https://github.com/intel/intel-sgx-Sal). In case you are
265+
building for simulation mode only and do not have HW support, you
266+
might also want to make sure that [simulation mode is set](https://github.com/intel/intel-sgx-ssl#available-make-flags)
267+
when building and installing it.
268+
269+
Once you have installed the SGX SDK and SSL for SGX SDK please double check that ``SGX_SDK`` and ``SGX_SSL`` variables
270+
are set correctly in your environment.
271+
272+
246273
#### Protocol Buffers
247274

248275
We use *nanopb*, a lightweight implementation of Protocol Buffers, inside the ledger enclave to parse blocks of
@@ -330,14 +357,23 @@ Building the project requires docker. We do not recommend to run `sudo make`
330357
to resolve issues with mis-configured docker environments as this also changes your `$GOPATH`. Please see hints on
331358
[docker](#docker) installation above.
332359

360+
The makefiles do not ensure that docker files are always rebuild to
361+
match the latest version of the code in the repo. If you suspect you
362+
have an issue with outdated docker images, you can run `make clobber
363+
build` which forces a rebuild. It also ensures that all other
364+
downlad, build or test artifacts are scrubbed from your repo and might
365+
help overcoming other problems. Be advised that that the rebuild can
366+
take a fair amount of time.
367+
333368
##### Working from behind a proxy
334369

335370
The current code should work behind a proxy assuming
336371
* you have defined the corresponding environment variables (i.e.,
337-
`http_proxy`, `https_proxy` and, potentially, `no_proxy`) properly
338-
defined
372+
`http_proxy`, `https_proxy` and, potentially, `no_proxy`) properly, and
339373
* docker (daemon & client) is properly set up for proxies as
340-
outlined in the Docker documentation for [clients](https://docs.docker.com/network/proxy/) and the [daemon](https://docs.docker.com/config/daemon/systemd/#httphttps-proxy).
374+
outlined in the Docker documentation for
375+
[clients](https://docs.docker.com/network/proxy/) and the
376+
[daemon](https://docs.docker.com/config/daemon/systemd/#httphttps-proxy).
341377
If you run Ubuntu 18.04, make sure you run docker 18.09 or later. Otherwise you will run into problems with DNS resolution inside the container.
342378

343379
You will also require a recent version of docker-compose. In particular, the docker-compose from ubuntu 18.04
@@ -412,13 +448,15 @@ will create dummy files. In case you switch later to HW mode without
412448
configuring these files correctly for HW mode, this will result in
413449
above error.
414450

415-
## Developing your first private chaincode
451+
## Developing with Fabric Private Chaincode
416452

453+
### Your first private chaincode
417454
Create, build and test your first private chaincode with this [tutorial](examples/README.md).
418455

419456
### A Complete Application
420457
For an end-to-end application demonstrating the potential of FPC, check out our [Clock Auction Demo Application](demo/README.md).
421458

459+
422460
## Documentation
423461

424462
To build documentation, you will have to install `java` and download `plantuml.jar`. Either put `plantuml.jar` into

demo/README.md

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ FPC peer cli hides this name mapping, you will have to manually prefix the
4545
chaincode name in `config.json`, hence the default `ecc_auctioncc`.
4646

4747
Both the frontend and fabric-gateway [expose ports](docker-compose.yml) and are
48-
accessible on the host machine. The frontend can be accessed at `localhost:5000`
49-
and the fabric-gateway can be accessed at `localhost:3000`.
48+
accessible on the host machine. The frontend can be accessed at [localhost:5000](http://localhost:5000)
49+
and the fabric-gateway can be accessed at [localhost:3000](http://localhost:3000).
5050

5151
Below is the script's help text.
5252

@@ -59,7 +59,9 @@ startFPCAuctionNetwork.sh [options]
5959
compliant auction chaincode($FPC_PATH/demo/chaincode/fpc), register auction users, and bring up
6060
both the fabric-gatway & frontend UI. If the fabric-gateway and frontend UI docker images have
6161
not previously been built it will build them, otherwise the script will reuse the images already
62-
existing. The FPC chaincode will not be built unless specified by the flag --build-cc.
62+
existing. The FPC chaincode will not be built unless specified by the flag --build-cc.
63+
By calling the script with both build options, you will be able to run the demo without having
64+
to build the whole FPC project (e.g., by calling `make` in $FPC_PATH).
6365
6466
options:
6567
--build-cc:
@@ -90,6 +92,31 @@ scripts/teardown.sh
9092
in the FPC Network scripts. If you run it with the `--clean-slate` flag the script
9193
will delete all the unused volumes and chaincode images.
9294

95+
96+
### Scripting
97+
98+
To facilitate demonstrations and also to help in testing, you can specify a scenario script defining the
99+
actions of the different parties and execute it using the command [scenario-run.sh](client/scripting/scenario-run.sh).
100+
Below is the script's help text.
101+
```
102+
scenario-run.sh [--help|-h|-?] [--bootstrap|-b] [--dry-run|-d] [--non-interactive|-n] [--skip-delay|-s] [--mock-reset|-r] <script-file>
103+
Run the demo scenario codified in the passed script file.
104+
- If you pass option --bootstrap, it will also first bring up an FPC network
105+
and tear it down at the end; otherwise it assumes you have already
106+
a running setup ...
107+
- option --dry-run/-d will just display all requests but not execute/submit
108+
any of them
109+
- option --non-interactive/-n will case _all_ requests to be submited even
110+
requests from submit_manual. This allows you to easily validate all
111+
json files, even when some steps would be manual in an actual scenario
112+
- option --skip-delay/-s allows you ignore all delays to speed-up demo
113+
- option --mock-reset/-r will try reset the mock-server at the beginning
114+
(obviously, this won't work if you run against the fabric-gateway backend;
115+
to achieve the equivalent for fabric-gateway, use option --bootstrap)
116+
```
117+
118+
An example of a scenario can be found in [demo/scenario](scenario).
119+
93120
## Manually Bring Up The Components
94121

95122
### 1. FPC Network

demo/client/scripting/lib/dsl.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212

1313
CLI="${DEMO_CLIENT_SCRIPTS_DIR}/cli"
1414

15-
15+
if [ ! -x ${CLI} ]; then
16+
# cli does not exist, try to build it
17+
make -C ${DEMO_CLIENT_SCRIPTS_DIR} cli || die "command $LCI did not exist and could not be built"
18+
fi
1619

1720

1821
# Simple "DSL" to script auction scenarios

demo/scripts/startFPCAuctionNetwork.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,18 @@ for var in "$@"; do
5555
shift
5656
done
5757

58-
export DEMO_SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
59-
export FPC_PATH="${FPC_PATH:-${DEMO_SCRIPTS_DIR}/../..}"
60-
export DEMO_ROOT="${DEMO_SCRIPTS_DIR}/.."
58+
export DEMO_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
59+
export DEMO_ROOT="${DEMO_SCRIPT_DIR}/.."
60+
DEMO_DOCKER_COMPOSE=${DEMO_SCRIPT_DIR}/../docker-compose.yml
61+
62+
export FPC_PATH="${FPC_PATH:-${DEMO_SCRIPT_DIR}/../..}"
6163

6264
# SCRIPT_DIR is the docker compose script dir that needs to be defined to source environment variables from the FPC Network
6365
export SCRIPT_DIR=${FPC_PATH}/utils/docker-compose/scripts
6466
. ${SCRIPT_DIR}/lib/common.sh
6567

6668
# Cleanup any previous iterations of the demo
67-
"${SCRIPT_DIR}/teardown.sh"
69+
"${DEMO_SCRIPT_DIR}/teardown.sh"
6870

6971
# Generate the necessary credentials and start the FPC network
7072
"${SCRIPT_DIR}/generate.sh"
@@ -80,15 +82,15 @@ fi
8082
if $BUILD_CLIENT; then
8183
echo ""
8284
echo "Building Fabric Gateway and Frontend UI"
83-
COMPOSE_IGNORE_ORPHANS=true ${DOCKER_COMPOSE_CMD} -f ${DEMO_ROOT}/docker-compose.yml build
85+
COMPOSE_IGNORE_ORPHANS=true ${DOCKER_COMPOSE_CMD} -f ${DEMO_DOCKER_COMPOSE} build
8486
fi
8587

8688
# Start the FPC Network using utils/docker-compose scripts
8789
echo "Starting the FPC Network"
8890
"${SCRIPT_DIR}/start.sh"
8991

9092
# Install and Instantiate Auction Chaincode
91-
"${DEMO_SCRIPTS_DIR}/installCC.sh"
93+
"${DEMO_SCRIPT_DIR}/installCC.sh"
9294

9395
# Register Users
9496
"${DEMO_ROOT}/client/backend/fabric-gateway/registerUsers.sh"
@@ -97,4 +99,4 @@ echo "Starting the FPC Network"
9799
# Since the new containers are going to use the same network as the FPC network, docker-compose
98100
# typically throws a warning as it sees containers using the network. To quiet the warning set
99101
# COMPOSE_IGNORE_ORPHANS to true.
100-
COMPOSE_IGNORE_ORPHANS=true ${DOCKER_COMPOSE_CMD} -f ${DEMO_ROOT}/docker-compose.yml up -d auction_client auction_frontend
102+
COMPOSE_IGNORE_ORPHANS=true ${DOCKER_COMPOSE_CMD} -f ${DEMO_DOCKER_COMPOSE} up -d auction_client auction_frontend

demo/scripts/teardown.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ if $CLEAN_SLATE; then
5151
else
5252
DOWN_OPT=""
5353
fi
54-
COMPOSE_IGNORE_ORPHANS=true docker-compose -f ${DEMO_DOCKER_COMPOSE} kill && COMPOSE_IGNORE_ORPHANS=true docker-compose -f ${DEMO_DOCKER_COMPOSE} down ${DOWN_OPT}
54+
COMPOSE_IGNORE_ORPHANS=true ${DOCKER_COMPOSE_CMD} -f ${DEMO_DOCKER_COMPOSE} kill && COMPOSE_IGNORE_ORPHANS=true docker-compose -f ${DEMO_DOCKER_COMPOSE} down ${DOWN_OPT}
5555

5656
if $CLEAN_SLATE; then
5757
"${SCRIPT_DIR}/teardown.sh" --clean-slate

utils/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ include $(TOP)/build.mk
88
SUB_DIRS = docker fabric docker-compose
99

1010
all build test clean clobber:
11-
$(foreach DIR, $(SUB_DIRS), $(MAKE) -C $(DIR) $@;)
11+
$(foreach DIR, $(SUB_DIRS), $(MAKE) -C $(DIR) $@ || exit ;)

utils/docker-compose/README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,16 @@ is used. Otherwise it will use `core.yaml` and the regular peer image.
3232
scripts/start.sh
3333
```
3434
This will create all necessary installation artifacts and start the
35-
network. For more information in the steps involved, continue
35+
network.
36+
If you set the environment variable `USE_EXPLORER` to `true`, the network will include
37+
and start the [Hyperledger Explorer](https://www.hyperledger.org/projects/explorer) on
38+
[port 8090](http://localhost:8090). This will enable you to inspect the networks,
39+
e.g., processed transactions.
40+
If you set the environment variable `USE_COUCHDB` to `true`, the peer will use couchdb
41+
to store the local version of the ledger and you can inspect the peer's ledger state
42+
on [port 5984](http://localhost:5984) (login as user `admin` with password `adminPassword`).
43+
44+
For more information in the steps involved, continue
3645
reading the following section. Otherwise, you can skip to the
3746
Section on [Chaincode Installation](#deploying-your-fpc-chaincode).
3847

utils/docker-compose/network-config/docker-compose-couchdb.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
version: '2'
88

99
services:
10-
couchdb0:
11-
container_name: couchdb0
10+
couchdb0.org1.example.com:
1211
image: couchdb:2.3
1312
# Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password
1413
# for CouchDB. This will prevent CouchDB from operating in an "Admin Party" mode.
@@ -25,12 +24,12 @@ services:
2524
peer0.org1.example.com:
2625
environment:
2726
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
28-
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb0:5984
27+
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb0.org1.example.com:5984
2928
# The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD
3029
# provide the credentials for ledger to connect to CouchDB. The username and password must
3130
# match the username and password set for the associated CouchDB.
3231
- CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
3332
- CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
3433
depends_on:
35-
- couchdb0
34+
- couchdb0.org1.example.com
3635

utils/docker-compose/scripts/start.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ export SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && p
1414

1515
# test pre-conditions and try to remediate
1616
#
17-
# - existance of FPC peer
1817
if [[ ! $USE_FPC = false ]]; then
18+
# - existance of FPC peer
1919
FPC_PEER_NAME="hyperledger/fabric-peer-fpc"
2020
if [ -z "$(docker images | grep ${FPC_PEER_NAME})" ]; then
2121
echo "FPC peer container image '${FPC_PEER_NAME}' does not exist, try to build it ..."
@@ -24,6 +24,20 @@ if [[ ! $USE_FPC = false ]]; then
2424
make peer || die "can't build peer"
2525
popd
2626
fi
27+
# - existance of boilerplate
28+
BOILERPLATE_NAME="hyperledger/fabric-private-chaincode-boilerplate-ecc"
29+
if [ -z "$(docker images | grep ${BOILERPLATE_NAME})" ]; then
30+
echo "FPC boilerplate container image '${BOILERPLATE_NAME}' does not exist, try to build it ..."
31+
pushd "${FPC_PATH}/" || die "can't go to fpc-sdk and boilerplate build location"
32+
make fpc-sdk || die "can't build fpc sdk"
33+
popd
34+
pushd "${FPC_PATH}/utils/docker" || die "can't go to docker build location"
35+
make || die "can't build docker base images"
36+
popd
37+
pushd "${FPC_PATH}/ecc" || die "can't go to fpc-sdk and boilerplate build location"
38+
make docker-boilerplate-ecc || die "can't build boilerplate"
39+
popd
40+
fi
2741
fi
2842
# - generated crypto-config files
2943
# test that we have generated crypto-config. Otherwise below up

utils/docker/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ clobber:
4646
dev-* \
4747
dev_test-* \
4848
${FPC_PEER_DOCKER_NAMESPACE} \
49+
$(FPC_DOCKER_NAMESPACE)-cc-builder \
4950
$(FPC_DOCKER_NAMESPACE)-dev \
5051
$(FPC_DOCKER_NAMESPACE)-ccenv \
51-
$(FPC_DOCKER_NAMESPACE)-cc-builder \
5252
$(FPC_DOCKER_NAMESPACE)-base \
5353
; do \
5454
IMAGES=$$(${DOCKER} images $${imgs} -q); \

0 commit comments

Comments
 (0)