|
| 1 | +# Setup your Development Environment (Option 2) |
| 2 | + |
| 3 | +In this document we explain how to setup your FPC development environment by installing all required software components on your machine. We refer to this setup as `Option 2`. An alternative setup with docker you can find in [Option 1](setup-option1.md). |
| 4 | + |
| 5 | + |
| 6 | +## Requirements |
| 7 | + |
| 8 | +Make sure that you have the following required dependencies installed: |
| 9 | +* Linux (OS) (we recommend Ubuntu 22.04, see [list](https://github.com/intel/linux-sgx#prerequisites) supported OS) |
| 10 | + |
| 11 | +* CMake v3.5.1 or higher |
| 12 | + |
| 13 | +* [Go](https://golang.org/) 1.21.x or higher |
| 14 | + |
| 15 | +* Docker 18.09 (or higher) and docker-compose 1.25.x (or higher) |
| 16 | + Note that version from Ubuntu 18.04 is not recent enough! To upgrade, install a recent version following the instructions from [docker.com](https://docs.docker.com/compose/install/), e.g., for version 1.25.4 execute |
| 17 | + ```bash |
| 18 | + sudo curl -L "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose |
| 19 | + sudo chmod +x /usr/local/bin/docker-compose |
| 20 | + ``` |
| 21 | + |
| 22 | + To install docker-componse 1.25.4 from [docker.com](https://docs.docker.com/compose/install/), execute |
| 23 | + ```bash |
| 24 | + sudo curl -L "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose |
| 25 | + sudo chmod +x /usr/local/bin/docker-compose |
| 26 | + ``` |
| 27 | + |
| 28 | +* yq v4.x |
| 29 | + You can install `yq` via `go get`. |
| 30 | + ```bash |
| 31 | + go get github.com/mikefarah/yq/v4 |
| 32 | + ``` |
| 33 | + |
| 34 | +* Protocol Buffers |
| 35 | + - Protocol Buffers 3.0.x needed for the Intel SGX SDK |
| 36 | + - Protocol Buffers 3.11.x or higher and [Nanopb](http://github.com/nanopb/nanopb) 0.4.7 |
| 37 | + |
| 38 | +* SGX PSW & SDK v2.22 for [Linux](https://01.org/intel-software-guard-extensions/downloads) |
| 39 | + (alternatively, you could also install it from the [source](https://github.com/intel/linux-sgx) |
| 40 | + |
| 41 | +* Credentials for Intel Attestation Service, read [here](../README.md#intel-attestation-service-ias) (for hardware-mode SGX) |
| 42 | + |
| 43 | +* [Intel Software Guard Extensions SSL](https://github.com/intel/intel-sgx-ssl) |
| 44 | + (we recommend using tag `3.0_Rev2` OpenSSL `3.0.12`) |
| 45 | + |
| 46 | +* Hyperledger [Fabric](https://github.com/hyperledger/fabric/tree/v2.5.9) v2.5.9 |
| 47 | + |
| 48 | +* Clang-format 6.x or higher |
| 49 | + |
| 50 | +* jq |
| 51 | + |
| 52 | +* hex (for Ubuntu, found in package basez) |
| 53 | + |
| 54 | +* A recent version of [PlantUML](http://plantuml.com/), including Graphviz, for building documentation. See [Documentation](../README.md#building-documentation) for our recommendations on installing. The version available in common package repositories may be out of date. |
| 55 | + |
| 56 | +## Intel SGX SDK and SSL |
| 57 | + |
| 58 | +Fabric Private Chaincode requires the Intel [SGX SDK](https://github.com/intel/linux-sgx) and |
| 59 | +[SGX SSL](https://github.com/intel/intel-sgx-ssl) to build the main components of our framework and to develop and build |
| 60 | +your first private chaincode. |
| 61 | + |
| 62 | +Install the Intel SGX software stack for Linux by following the |
| 63 | +official [documentation](https://github.com/intel/linux-sgx). Please make sure that you use the |
| 64 | +SDK version as denoted above in the list of requirements. |
| 65 | + |
| 66 | +For SGX SSL, just follow the instructions on the [corresponding |
| 67 | +github page](https://github.com/intel/intel-sgx-ssl). In case you are |
| 68 | +building for simulation mode only and do not have HW support, you |
| 69 | +might also want to make sure that [simulation mode is set](https://github.com/intel/intel-sgx-ssl#available-make-flags) |
| 70 | +when building and installing it. |
| 71 | + |
| 72 | +Once you have installed the SGX SDK and SSL for SGX SDK please double check that `SGX_SDK` and `SGX_SSL` variables |
| 73 | +are set correctly in your environment. |
| 74 | + |
| 75 | + |
| 76 | +## Protocol Buffers |
| 77 | + |
| 78 | +We use *nanopb*, a lightweight implementation of Protocol Buffers, inside the enclaves to parse blocks of |
| 79 | +transactions. Install nanopb by following the instruction below. For this you need a working Google Protocol Buffers |
| 80 | +compiler with python bindings (e.g. via `apt-get install protobuf-compiler python3-protobuf libprotobuf-dev`). |
| 81 | +For more detailed information consult the official nanopb documentation http://github.com/nanopb/nanopb. |
| 82 | +```bash |
| 83 | +export NANOPB_PATH=/path-to/install/nanopb/ |
| 84 | +git clone https://github.com/nanopb/nanopb.git $NANOPB_PATH |
| 85 | +cd $NANOPB_PATH |
| 86 | +git checkout nanopb-0.4.7 |
| 87 | +cd generator/proto && make |
| 88 | +``` |
| 89 | + |
| 90 | +Make sure that you set `$NANOPB_PATH` as it is needed to build Fabric Private Chaincode. |
| 91 | + |
| 92 | +Moreover, in order to build Fabric protobufs we also require a newer Protobuf compiler than what is provided as standard Ubuntu package and is used to build the |
| 93 | +Intel SGX SDK. For this reason you will have to download and install another version and use it together with Nanopb. Do not install the new protobuf, though, such that it is not found in your standard PATH but instead define the `PROTOC_CMD`, either as environment variable or via `config.override.mk` to point to the new `protoc` binary |
| 94 | +```bash |
| 95 | +wget https://github.com/protocolbuffers/protobuf/releases/download/v22.3/protoc-22.3-linux-x86_64.zip |
| 96 | +unzip protoc-22.3-linux-x86_64.zip -d /usr/local/proto3 |
| 97 | +export PROTOC_CMD=/usr/local/proto3/bin/protoc |
| 98 | +``` |
| 99 | + |
| 100 | +## Hyperledger Fabric |
| 101 | + |
| 102 | +Our project fetches the latest supported Fabric binaries during the build process automatically. |
| 103 | +However, if you want to use your own Fabric binaries, please checkout Fabric 2.5.9 release using the following commands: |
| 104 | +```bash |
| 105 | +export FABRIC_PATH=$GOPATH/src/github.com/hyperledger/fabric |
| 106 | +git clone https://github.com/hyperledger/fabric.git $FABRIC_PATH |
| 107 | +cd $FABRIC_PATH; git checkout tags/v2.5.9 |
| 108 | +``` |
| 109 | + |
| 110 | +Note that Fabric Private Chaincode may not work with the Fabric `main` branch. |
| 111 | +Therefore, make sure you use the Fabric `v2.5.9` tag. |
| 112 | +Make sure the source of Fabric is in your `$GOPATH`. |
0 commit comments