Building from source

When building from source, you have three options:

  1. Build using Nix, a package manager that keeps your system configuration intact and maintains a minimal set of dependencies

  2. Build with Nix inside a Docker image (doesn’t require you to install nix)

  3. Build using Cargo and the usual Rust build process

Getting the repository

All those three methods require you to download Aleph’s code repository:

git clone https://github.com/Cardinal-Cryptography/aleph-node.git
cd aleph-node

Nix

  1. Install Nix:

sh <(curl -L https://nixos.org/nix/install) --daemon
  1. Checkout the appropriate tag. It’s recommended that you use the latest tag you find here:

git checkout r-13.0
  1. Use nix to build the node binary:

nix-shell --pure --run 'cargo build --release --locked --package aleph-node' shell.nix

The binary will be stored as target/release/aleph-node

Docker

In order to build a binary for aleph-node using docker we first need to install docker itself, i.e. in case of the Ubuntu Linux distribution, by executing sudo apt install docker.io (please consult your distribution's manual describing docker installation procedure). Build procedure can be invoked by running:

sudo docker build -t aleph-node/build -f nix/Dockerfile.build .
sudo docker run -ti --volume=$(pwd):/node/build aleph-node/build

Binary will be stored in $(pwd)/aleph-node

Cargo

This way is not recommended as it can potentially interfere with your system’s configuration but we provide it for the sake of this guide’s completeness.

First of all, you will need some system-level dependencies. These are build dependencies we use in our Linux images for aleph-node:

bash
binutils
clang
git
glibc
llvm
nss-cacert
openssl
pkg-config
protobuf
rust-nightly

Version of the rust toolchain is specified by the rust-toolchain file within the aleph-node repository. You can use rustup to install a specific version of rust, including its custom compilation targets. Using rustup, it should set a proper toolchain automatically while you call rustup show within project's root directory.

Example build procedure using Ubuntu 20.04 LTS and bash shell:

sudo apt update
sudo apt install build-essential curl git clang libclang-dev pkg-config libssl-dev protobuf-compiler
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"
git clone https://github.com/Cardinal-Cryptography/aleph-node.git
cd aleph-node
rustup show
rustup target add x86_64-unknown-linux-gnu wasm32-unknown-unknown
cargo build --release

The binary will be located in the target/release directory in the aleph-node repository. It is named aleph-node.

Of course, if you want to build a specific release, you can checkout an appropriate tag after cloning the repository, similarly to the Nix guide above. For example:

git checkout r-13.0

The best way to find the tag is to go to the page for the specific release and copy the tag, e.g. here is the page for release 11.4 https://github.com/Cardinal-Cryptography/aleph-node/releases/tag/r-11.4

Last updated