Here is a brief list of system dependencies currently used for development:
The repository uses submodules so be sure to check them out by doing:
$ git submodule update --init --recursive
The easiest way to build SGX code is to use the provided scripts, which run a Docker
container with all the included tools. This has been tested on MacOS and Ubuntu with SGX_MODE=SIM
.
To start the SGX development container:
$ ./scripts/sgx-enter.sh
Ekiden uses cargo-make
as the build system. The
development Docker container already comes with cargo-make
preinstalled.
To build everything required for running Ekiden, simply run the following in the top-level directory:
$ cargo make
This should install any required dependencies and build all packages. By default SGX code is
built in simulation mode. To change this, do export SGX_MODE=HW
(currently untested) before
running the cargo make
command.
In order to establish authenticated channels with Ekiden contract enclaves, the client needs to know the enclave hash (MRENCLAVE) so it knows that it is talking with the correct contract code.
To obtain the enclave hash, there is a utility that you can run:
$ python scripts/parse_enclave.py target/enclave/token.signed.so
This utility will output a lot of enclave metadata, the important part is:
...
ENCLAVEHASH e38ded31efe3beb062081dc9a7f9af4b785ae8fa2ce61e0bddec2b6aedb02484
...
You will need this hash when running the contract client (see below).
In order to communicate with Intel Attestation Service (IAS), you need to generate a certificate and get an SPID from Intel. For more information on that process, see the following links:
You will need to pass both SPID and the PKCS#12 bundle when starting the compute node.
The easiest way to run Ekiden is through the provided scripts, which set up the Docker containers for you.
To build and run a consensus node:
$ bash scripts/sgx-enter.sh
$ cargo run -p consensus
The consensus node depends on a local instance of Tendermint To start a Tendermint docker container that is linked to the container above:
$ bash ./scripts/tendermint-start.sh
Occasionally, you'll need to clear all persistent data. To clear all data:
$ bash ./scripts/tendermint-clear.sh
Currently, the 3 processes (compute, consensus, tendermint) look for each other on localhost
.
In order to attach secondary shells to an existing container, run
$ bash scripts/sgx-enter.sh
To run a contract on a compute node:
# optionally set the following env vars
export IAS_SPID="<IAS SPID>"
export IAS_PKCS="client.pfx"
scripts/run_contract.sh CONTRACT
To get a list of built contract enclaves:
$ ls ./target/enclave/*.signed.so
The key manager contract is special and must be run in a compute node listening on port 9003
by default. Run it as you would run any other compute node, but specifying the key manager
contract and changing the port:
$ scripts/run_contract.sh ekiden-key-manager -p 9003 --disable-key-manager --consensus-host disabled
To run the token contract client:
$ scripts/run_contract.sh --client token
We welcome anyone to fork and submit a pull request! Please make sure to run rustfmt
before submitting.
$ cargo make format
core
: Core external-facing libraries (aggregatescommon
,enclave
,rpc
,db
, etc.)common
: Common functionality like error handlingenclave
: Enclave loader and identity attestationrpc
: RPC functionality for use in enclavesdb
: Database functionality for use in enclavescompute
: Ekiden compute nodeconsensus
: Ekiden consensus nodecontracts
: Core contracts (key-manager
,token
)tools
: Build toolsscripts
: Bash scripts for development