Online has a lot of information on the BTC of the source analysis, as the EOS main network on the line will take time, and the online information about EOS less, the bold attempt to do a series of text, learn the EOS source, but also to improve their ability to read the code and new knowledge of the ability to understand. To read appreciation of the source code first run up to see what is probably like this, so the heart has a bottom, also more practical. This article is the first article in the series, Ubuntu under the EOS code compiled, is based on the official website documentation Guide to complete.
Official Documents Link: Https://github.com/EOSIO/eos
According to the official documentation, the EOS code only supports compiling on the Ubuntu16.04 version or later (the recommended use of Ubuntu16.10), which is implemented on Ubuntu16.04. Before compiling the EOS code, we first get the tools and libraries that the EOS code needs to compile and run, and the way to do this is to enter the following instructions in the terminal:
sudo apt-get update
Wget-o-Https://apt.llvm.org/llvm-snapshot.gpg.key
sudo apt-get install clang-4.0 lldb-4.0 libclang-4.0-dev cmake make
Libbz2-dev Libssl-dev Libgmp3-dev
Autotools-dev build-essential
Libbz2-dev Libicu-dev Python-dev
autoconf Libtool git
The LLVM is a framework compiler (compiler) frame system, written in C + + to optimize the compilation time (compile-time), Link time (link-time), run time (run-time), and idle time of programs written in any program language ( Idle-time), and Clang is exactly the compiler we have to complete the EOS code compilation. The EOS code relies heavily on the boost library, so we need to get the boost library and compile it, install it, and add the information about the boost library to the environment variable, which can be achieved by following these instructions:
CD ~
Wget-c ' https://sourceforge.net/projects/boost/files/boost/1.66.0/boost_1_66_0.tar.bz2/download '-o boost_1.66.0. tar.bz2
Tar xjf boost_1.66.0.tar.bz2
CD boost_1_66_0/
echo "Export boost_root= $HOME/boost_1_66_0" >> ~/.bash_profile
SOURCE ~/.bash_profile
./bootstrap.sh "--prefix= $BOOST _root"
./B2 Install
SOURCE ~/.bash_profile
If you feel that the download is slow, you can also go to boost website download the corresponding version (linux64 bit) and then follow the steps above to extract, add environment variables, compile, install.
Next we need to get and install SECP256K1-ZKP, we can think of it as a decrypted library, the specific acquisition, compilation, installation can be achieved in the following ways:
CD ~
git clone https://github.com/cryptonomex/secp256k1-zkp.git
CD SECP256K1-ZKP
./autogen.sh
./configure
Make
sudo make install
At the same time, we need to wasm the compiler, because WASM is not configured in LLVM and clang, so we need to compile it manually
mkdir ~/wasm-compiler
CD ~/wasm-compiler
git clone--depth 1--single-branch--branch release_40 https://github.com/llvm-mirror/llvm.git
CD Llvm/tools
git clone--depth 1--single-branch--branch release_40 https://github.com/llvm-mirror/clang.git
Cd..
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. /
Make-j4 Install
With the tools and dependencies needed to compile the EOS code, we can compile and run an EOS node on the basis of ensuring that the above steps are completed. Before compiling, we first need to download the EOS source from Git, because the EOS code branch More, we can add-recursive to get complete code, the following instructions:
git clone Https://github.com/eosio/eos--recursive
After we get the code, we can compile the EOS
CD ~
git clone Https://github.com/eosio/eos--recursive
Mkdir-p ~/eos/build && CD ~/eos/build
Cmake-dbinaryen_bin=~/binaryen/bin-dwasm_root=~/wasm-compiler/llvm-dopenssl_root_dir=/usr/local/opt/openssl- Dopenssl_libraries=/usr/local/opt/openssl/lib..
make-j$ (Nproc)
After the compilation is complete we can see the following folder in the path ~/eos/build/programs:
Eosiod inside is the server-side block chain component related files.
Eosioc inside is a block chain of command line interface related files
Eosio-launcher inside is the application related file of network node.
Eosiowd inside is the EOS wallet related documents.
Now we CD to the Eosiod path, you can execute the Eosiod, in the process of execution may produce an error, if there is no error, you can use CTRL + C to stop eosiod operation, at this time we can see a eosiod folder named Data-dir folder, It contains related configuration information for eosiod. Open Config.ini to add the following:
# Load The Testnet Genesis State, which creates some initial blocks 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 are pretty much always stale
Enable-stale-production = True
# Enable block production with the testnet producers
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
# Load The block producer plugin and so can produce blocks
Plugin = Eosio::p roducer_plugin
# Wallet Plugin
Plugin = Eosio::wallet_api_plugin
# as-as-as-API and HTTP plugins
Plugin = Eosio::chain_api_plugin
Plugin = Eosio::http_plugin
Run again./eosiod, Goose, there's been a mistake again.
Originally prompted US genesis.json file path is not correct, then we can use locate Genesis to find our local Genesis.json in the path, and add the path to the EOS of the compiled configuration file, the following figure:
Run Eosiod again, and there is an error in the following image:
Originally is prompts us to use the enable-stale-production in the configuration file two times or more than two times, we reopen config.ini to be able to comment out one enable-stale-production.
Now let's run it again./eosiod, finally, the moment to witness the miracle:
When you see the diagram above, your first EOS node is already running, and it's really twists.