README.md 5.5 KB
Newer Older
N
Nathan Hourt 已提交
1 2
# Eos

3
Welcome to the EOS.IO source code repository!
N
Nathan Hourt 已提交
4 5 6 7 8 9 10

## Getting Started
The following instructions overview the process of getting the software, building it, and running a simple test network that produces blocks.

### Setting up a build/development environment
This project is written primarily in C++14 and uses CMake as its build system. An up-to-date C++ toolchain (such as Clang or GCC) and the latest version of CMake is recommended. At the time of this writing, Nathan uses clang 4.0.0 and CMake 3.8.0.

D
Daniel Larimer 已提交
11
### Installing Dependencies
N
Nathan Hourt 已提交
12
Eos has the following external dependencies, which must be installed on your system:
13
 - Boost 1.64
N
Nathan Hourt 已提交
14
 - OpenSSL
15
 - LLVM 4.0
N
Nathan Hourt 已提交
16
 - [secp256k1-zkp (Cryptonomex branch)](https://github.com/cryptonomex/secp256k1-zkp.git)
D
Daniel Larimer 已提交
17

D
Daniel Larimer 已提交
18 19
```
git clone https://github.com/cryptonomex/secp256k1-zkp.git
J
Joel Smith 已提交
20
cd secp256k1-zkp
D
Daniel Larimer 已提交
21 22 23 24 25
./autogen.sh
./configure
make
sudo make install
```
D
Daniel Larimer 已提交
26

N
Nathan Hourt 已提交
27 28 29 30 31 32 33 34 35 36
### Getting the code
To download all of the code, download Eos and a recursion or two of submodules. The easiest way to get all of this is to do a recursive clone:

`git clone https://github.com/eosio/eos --recursive`

If a repo is cloned without the `--recursive` flag, the submodules can be retrieved after the fact by running this command from within the repo:

`git submodule update --init --recursive`

### Configuring and building
N
Nathan Hourt 已提交
37
To do an in-source build, simply run `cmake .` from the top level directory. Out-of-source builds are also supported. To override clang's default choice in compiler, add these flags to the CMake command:
N
Nathan Hourt 已提交
38 39 40 41 42 43 44

`-DCMAKE_CXX_COMPILER=/path/to/c++ -DCMAKE_C_COMPILER=/path/to/cc`

For a debug build, add `-DCMAKE_BUILD_TYPE=Debug`. Other common build types include `Release` and `RelWithDebInfo`.

After successfully running cmake, simply run `make` to build everything. To run the test suite after building, run the `chain_test` executable in the `tests` folder.

N
Nathan Hourt 已提交
45
### Creating and launching a single-node testnet
N
Nathan Hourt 已提交
46 47
After successfully building the project, the `eosd` binary should be present in the `programs/eosd` directory. Go ahead and run `eosd` -- it will probably exit with an error, but if not, close it immediately with Ctrl-C. Note that `eosd` will have created a directory named `data-dir` containing the default configuration (`config.ini`) and some other internals. This default data storage path can be overridden by passing `--data-dir /path/to/data` to `eosd`.

N
Nathan Hourt 已提交
48
Edit the `config.ini` file, adding the following settings to the defaults already in place:
N
Nathan Hourt 已提交
49 50

```
N
Nathan Hourt 已提交
51 52 53 54 55
# Load the testnet genesis state, which creates some initial block producers with the default key
genesis-json = /path/to/eos/source/genesis.json
# Enable production on a stale chain, since a single-node test chain is pretty much always stale
enable-stale-production = true
# Enable block production with the testnet producers
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
producer-name = inita
producer-name = initb
producer-name = initc
producer-name = initd
producer-name = inite
producer-name = initf
producer-name = initg
producer-name = inith
producer-name = initi
producer-name = initj
producer-name = initk
producer-name = initl
producer-name = initm
producer-name = initn
producer-name = inito
producer-name = initp
producer-name = initq
producer-name = initr
producer-name = inits
producer-name = initt
producer-name = initu
N
Nathan Hourt 已提交
77 78
# Load the block producer plugin, so we can produce blocks
plugin = eos::producer_plugin
N
Nathan Hourt 已提交
79 80
```

J
Joel Smith 已提交
81
Now it should be possible to run `eosd` and see it begin producing blocks. At present, the P2P code is not implemented, so only single-node configurations are possible. When the P2P networking is implemented, these instructions will be updated to show how to create an example multi-node testnet.
peterwillcn's avatar
peterwillcn 已提交
82 83 84 85 86 87 88 89 90 91 92 93

### Run in docker

So simple and fast operation EOS:
 - [Docker](https://docs.docker.com)
 - [Docker-compose](https://github.com/docker/compose)
 - [Docker-volumes](https://github.com/cpuguy83/docker-volumes)

Build eos images

```
cd eos/Docker
94
cp ../genesis.json .
peterwillcn's avatar
peterwillcn 已提交
95
docker build --rm -t eosio/eos .
peterwillcn's avatar
peterwillcn 已提交
96 97 98 99 100
```

Start docker

```
peterwillcn's avatar
peterwillcn 已提交
101
sudo rm -rf /data/store/eos # options 
peterwillcn's avatar
peterwillcn 已提交
102 103 104 105
sudo mkdir -p /data/store/eos
docker-compose -f docker-compose.yml up
```

peterwillcn's avatar
peterwillcn 已提交
106 107 108 109 110 111 112 113 114 115 116
Run example contracts

```
cd /data/store/eos/contracts/exchange
docker exec docker_eos_1 eosc setcode exchange contracts/exchange/exchange.wast contracts/exchange/exchange.abi

cd /data/store/eos/contracts/currency 
docker exec docker_eos_1 eosc setcode currency contracts/currency/currency.wast contracts/currency/currency.abi

```

peterwillcn's avatar
peterwillcn 已提交
117 118
Done

119 120 121 122 123



### How to Build LLVM and clang for WASM

J
Joel Smith 已提交
124
By default LLVM and clang do not include the WASM build target, so you will have to build it yourself. Note that following these instructions will create a version of LLVM that can only build WASM targets.
125 126

```
127 128 129
mkdir  ~/wasm-compiler
cd ~/wasm-compiler
git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/llvm.git
130
cd llvm/tools
131 132
git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/clang.git
cd ..
133 134 135
mkdir build
cd build
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=.. -DLLVM_TARGETS_TO_BUILD= -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly -DCMAKE_BUILD_TYPE=Release ../
136
make -j4 install
137 138
```

139 140 141 142 143 144 145 146 147 148
### Using the WASM compiler to perform a full build of the project

The WASM_LLVM_CONFIG environment variable is used to find our recently built WASM compiler.
This is needed to compile the example contracts insde eos/contracts folder and their respective tests.

```
git clone https://github.com/eosio/eos --recursive
mkdir -p eos/build && cd eos/build
WASM_LLVM_CONFIG=~/wasm-compiler/llvm/bin/llvm-config cmake ..
make -j4
149
```