|
| 1 | +<!--- |
| 2 | +Licensed under Creative Commons Attribution 4.0 International License |
| 3 | +https://creativecommons.org/licenses/by/4.0/ |
| 4 | +---> |
| 5 | +# BUILD |
| 6 | + |
| 7 | +In order to build, install, and run Hyperledger Private Data Objects, a number |
| 8 | +of additional components must be installed and configured. The following |
| 9 | +instructions will guide you through the installation and build process for |
| 10 | +Hyperledger Private Data Objects. |
| 11 | + |
| 12 | +## Table of Contents |
| 13 | + |
| 14 | +- [Prerequisites](#prerequisites) |
| 15 | +- [Installing Sawtooth Distributed Ledger](#sawtooth) |
| 16 | +- [Quickstart: Installing PDO Using Scripts](#quickstart) |
| 17 | +- [Building and installing PDO manually](#manual-install) |
| 18 | + - [Setting up a Python Virtual Environment](#virtualenv) |
| 19 | + - [Compiling the Common C++ Libraries](#common) |
| 20 | + - [Compiling the Python shared libraries](#python) |
| 21 | + - [Building the Enclave Service](#eservice) |
| 22 | + - [Building the Provisioning Service](#pservice) |
| 23 | + - [Building the Client](#client) |
| 24 | +- [Using Private Data Objects](#using) |
| 25 | + |
| 26 | +# <a name="prerequisites"></a>Prerequisites |
| 27 | +Follow the instructions [here](PREREQUISITES.md) to install and configure |
| 28 | +components on which PDO depends. |
| 29 | + |
| 30 | +# <a name="sawtooth"></a>Installing Sawtooth Distributed Ledger |
| 31 | +Hyperledger Private Data Objects uses the Hyperledger Sawtooth distributed |
| 32 | +ledger to store data object instances and state, and to guarantee update |
| 33 | +atomicity. |
| 34 | + |
| 35 | +Application logic is implemented in Sawtooth through the use of Transaction |
| 36 | +Processors; transaction processors enable the distributed ledger to handle |
| 37 | +application requests. This repository contains the code required to build |
| 38 | +Transaction Processors that handle PDO requests. |
| 39 | + |
| 40 | +Follow the setup document [here](sawtooth/docs/SETUP.md) to install both |
| 41 | +Sawtooth and the custom Sawtooth Transaction Processors. |
| 42 | + |
| 43 | +Note that the Sawtooth components do not depend on any other components of the |
| 44 | +PDO project, and can be set up on an entirely separate machine from the one |
| 45 | +running Private Data Objects. It is recommended that Sawtooth be run on Ubuntu |
| 46 | +16.04 as it is the only operating system version on which Sawtooth is actively |
| 47 | +supported. |
| 48 | + |
| 49 | +# <a name="quickstart"></a>Quickstart: Installing PDO Using Scripts |
| 50 | +The following section of this document describes manual compilation and |
| 51 | +installation instructions for Private Data Objects components. Following those |
| 52 | +steps is a good way to learn about the components of the project as you become |
| 53 | +an advanced user. |
| 54 | + |
| 55 | +This section describes how to get started with PDO quickly using provided |
| 56 | +scripts to compile and install PDO. |
| 57 | + |
| 58 | +First, make sure environment variables are set as described in the |
| 59 | +[prerequisites](#prerequisites) section. |
| 60 | + |
| 61 | +The quickstart build will set up a python virtual environment to install things |
| 62 | +into. Set `CONTRACTHOME` to point to the target install directory for PDO |
| 63 | +components. You will need this environment variable set in every shell session |
| 64 | +where you interact with PDO. |
| 65 | +``` |
| 66 | +export CONTRACTHOME=`pwd`/__tools__/build/_dev/opt/pdo |
| 67 | +``` |
| 68 | + |
| 69 | +Change to the quickstart build directory: |
| 70 | +``` |
| 71 | +cd __tools__/build |
| 72 | +``` |
| 73 | + |
| 74 | +Edit `opt/pdo/etc/template/eservice.toml` and |
| 75 | +`opt/pdo/etc/template/pservice.toml` to have the correct ledger URL for your |
| 76 | +sawtooth installation. |
| 77 | + |
| 78 | +Build the virtual environment and install PDO components into it: |
| 79 | +``` |
| 80 | +make |
| 81 | +``` |
| 82 | + |
| 83 | +Activate the new virtual environment for the current shell session. You will |
| 84 | +need to do this in each new shell session (in addition to exporting environment |
| 85 | +variables). |
| 86 | +``` |
| 87 | +source _dev/bin/activate |
| 88 | +``` |
| 89 | + |
| 90 | +Run the test suite to check that the installation is working correctly. Replace |
| 91 | +the URL with the URL for the rest-api of your Sawtooth installation. |
| 92 | +``` |
| 93 | +cd .. |
| 94 | +LEDGER_URL=http://127.0.0.1:8008 ./run-tests.sh |
| 95 | +``` |
| 96 | + |
| 97 | +# <a name="manual-install"></a>Building and installing PDO manually |
| 98 | +## <a name="virtualenv"></a>Setting up a Python Virtual Environment |
| 99 | +The directories containing python code (`python`, `eservice`, `pservice`, and |
| 100 | +`client`) all create installable Python modules. You can install these to the |
| 101 | +root system's python if you want; however, the recommended approach is to |
| 102 | +create a new python "virtual environment" where they can be installed without |
| 103 | +affecting the root system. |
| 104 | + |
| 105 | +Create a python virtual environment in the folder `venv` by running: |
| 106 | +``` |
| 107 | +python3 -m venv venv |
| 108 | +``` |
| 109 | + |
| 110 | +Now activate that virtual environment for your current shell session. You will |
| 111 | +need to do this every time you start a new shell session: |
| 112 | +``` |
| 113 | +source venv/bin/activate |
| 114 | +``` |
| 115 | + |
| 116 | +Now that the virtual environment is active, install the python libraries that |
| 117 | +Private Data Objects depends upon. NOTE: On Ubuntu 17.10 (and probably others) |
| 118 | +secp256k1 may not install correctly with pip. If this happens to you, try first |
| 119 | +installing your distribution's libsecp256k1-dev package via something like |
| 120 | +`sudo apt-get install libsecp256k1-dev` and then re-run the pip installation. |
| 121 | +``` |
| 122 | +pip install --upgrade pip |
| 123 | +pip install --upgrade setuptools |
| 124 | +pip install --upgrade toml |
| 125 | +pip install --upgrade requests |
| 126 | +pip install --upgrade colorlog |
| 127 | +pip install --upgrade twisted |
| 128 | +pip install --upgrade pyyaml |
| 129 | +pip install --upgrade google |
| 130 | +pip install --upgrade protobuf |
| 131 | +pip install --upgrade secp256k1 |
| 132 | +pip install --upgrade cryptography |
| 133 | +pip install --upgrade pyparsing |
| 134 | +``` |
| 135 | + |
| 136 | +If you are using this recommended virtual environment setup, you will also need |
| 137 | +to export the environment variable `CONTRACTHOME`. This is used by PDO to find |
| 138 | +configuration files and encryption keys. Set this variable in your current |
| 139 | +shell session with: |
| 140 | +``` |
| 141 | +export CONTRACTHOME=`pwd`/venv/opt/pdo |
| 142 | +``` |
| 143 | + |
| 144 | +## <a name="common"></a>Compiling the Common C++ Libraries |
| 145 | +The `common` directory contains cryptography, encoding, and other miscellaneous |
| 146 | +routines used by many other components. Follow the build instructions |
| 147 | +[here](common/BUILD.md) to compile the common libraries. |
| 148 | + |
| 149 | +## <a name="python"></a>Compiling the Python shared libraries |
| 150 | +The `python` directory contains shared python libraries/imports used by many |
| 151 | +other components. Much of the higher-level user logic of Private Data Objects |
| 152 | +is implemented in Python. The python directory includes a python SWIG wrapper |
| 153 | +of the common libraries, so common must be compiled prior to compiling the |
| 154 | +`python` directory. |
| 155 | + |
| 156 | +Instructions for compiling and installing the python directory are available |
| 157 | +[here](python/BUILD.md). |
| 158 | + |
| 159 | +## <a name="eservice"></a>Building the Enclave Service |
| 160 | +The Enclave Service (eservice for short) consists of two components: |
| 161 | +- A Software Guard Extensions "enclave" which runs the actual contract code |
| 162 | +- A python service wrapper (the eservice) which passes messages to and from the enclave |
| 163 | + |
| 164 | +More information about the eservice is available |
| 165 | +[here](eservice/docs/eservice.md), and instructions for how to build it are |
| 166 | +[here](eservice/docs/BUILD.md). |
| 167 | + |
| 168 | +## <a name="pservice"></a>Building the Provisioning Service |
| 169 | +The Provisioning Service (pservice for short) is a simple key/value store used |
| 170 | +to generate "secrets" which provision specific enclaves for use with specific |
| 171 | +contracts. |
| 172 | + |
| 173 | +Instructions for how to build the provisioning service are available |
| 174 | +[here](pservice/docs/BUILD.md). |
| 175 | + |
| 176 | +## <a name="client"></a>Building the Client |
| 177 | +The client directory contains several utilities for creating and executing |
| 178 | +contracts. |
| 179 | + |
| 180 | +Instructions for how to build the client utilities service are available |
| 181 | +[here](client/docs/BUILD.md). |
| 182 | + |
| 183 | +# <a name="using"></a>Using Private Data Objects |
| 184 | +See the main [USAGE](USAGE.md) document for information on how to test and |
| 185 | +use your Private Data Objects installation. |
0 commit comments