Install Cardano node Linux
Testnet hardware | |
---|---|
CPU | x86/x64 two+ cores |
RAM | 4GB |
HDD | 30GB+ |
Mainnet hardware | |
CPU | x86/x64 two+ cores |
RAM | 16GB |
HDD | 100GB+ |
Dependencies and packages | |
Git | Free and open source distributed version control system originally developed by Linus Torvalds https://git-scm.com/ |
GCC | The GNU Compiler Collection includes front ends for C, C++ https://gcc.gnu.org/ |
GMP | A free library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating-point numbers https://gmplib.org/ |
ncurses | A programming library providing an API for writing text-based user interfaces (TUI) in a terminal-independent manner https://invisible-island.net/ncurses |
systemd | A suite of basic building blocks for a Linux system https://www.freedesktop.org/wiki/Software/systemd/ |
zlib | free, general-purpose library for lossless data-compression https://zlib.net/ |
Cabal 3.6.2.0 | The system for building and packaging Haskell libraries and programs https://www.haskell.org/cabal |
GHC 8.10.7 | a state-of-the-art compiler and interactive environment for Haskell https://www.haskell.org/ghc |
The page describes the installation process of cardano-node and cardano-cli on a Linux-based operating system from the source code.
cardano-node and cardano-cli are two essential components of Cardano blockchain, cardano-node is essentially a container that implements several components such as networking, consensus, and storage. Full block-producing nodes have a responsibility to validate transactions, execute smart contracts, and produce blocks. Cardano CLI is the utility direct socket connection to cardano-node installed and by that gives full access to Cardano blockchain.
Both of the components installed and running will let:
- keys generation, transaction construction, certificate creation
- sending, receiving, querying transactions
- transaction metadata submission
- native tokens creation
- minting NFTs
- stake pool operation
- smart contracts execution
Step 1 - System Packages
Every host Linux system requires additional package dependencies to work properly: Git, GCC, GMP, ncurses, systemd, Zlib. The set of additional package dependencies is common to every Linux distribution and can be installed in a variety of ways depending on the package manager installed or the approach used.
For installation on Ubuntu, Debian:
sudo apt-get update -y && sudo apt-get upgrade -y
sudo apt-get install automake build-essential pkg-config libffi-dev libgmp-dev libssl-dev libtinfo-dev libsystemd-dev zlib1g-dev make g++ tmux git jq wget libncursesw5 libtool autoconf
For installation on Redhat, Fedora, Centos:
sudo yum update -y
sudo yum install git gcc gcc-c++ tmux gmp-devel make tar xz wget zlib-devel libtool autoconf jq -y
sudo yum install systemd-devel ncurses-devel ncurses-compat-libs -y
Step 2 - GHC and Cabal
GHC - is the most commonly used Haskell compiler. Cabal - is a system for building and packaging Haskell libraries and programs.
GHC(Glasgow Haskell Compiler) and Cabal(Common Architecture for Building Applications and Libraries) are packages needed for the compilation and building of the sources and managed by GHCup - general purpose installer for Haskell language.
Install GHCup with:
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
Running GHCup installer will require necessary input from the command line.
Do you want ghcup to automatically add the required PATH variable to "/home/ubuntu/.bashrc"? - (P or enter)
Do you want to install haskell-language-server (HLS)? - (N or enter)
Do you want to install stack? - (N or enter)
Press ENTER to proceed or ctrl-c to abort. (enter)
At the end of the installation, GHCup will automatically detect the shell used and add new environment variables at the bottom after which the shell sessions should be restarted. Alternatively the shell can be reloaded with the command source $HOME/.bashrc
, or source $HOME/.zshrc
in case if zsh is used.
Ensure GHC and Cabal were installed on the host Linux system with the command:
ghcup --version
Expected output:
The GHCup Haskell installer, version v0.1.17.8
IOHK suggests using GHC 8.10.7 and Cabal 3.6.2.0, which could be picked up by telling GHCup to install and switch to the required versions:
ghcup install ghc 8.10.7
ghcup install cabal 3.6.2.0
ghcup set ghc 8.10.7
ghcup set cabal 3.6.2.0
Ensure the correct version of GHC and Cabal versions are installed with the command:
ghc --version
cabal --version
Expected output:
The Glorious Glasgow Haskell Compilation System, version 8.10.7
cabal-install version 3.6.2.0
compiled using version 3.6.2.0 of the Cabal library
Step 3 - Sources compilation
Compilation of cardano-node requires compilation and two dependency libraries: Secp256k1 and secp256k1.
- libsodium - a modern, portable, easy-to-use crypto library
- libsecp256k1 - optimized C library for ECDSA signatures and secret/public key operations on curve secp256k1
A good practice to keep source codes and builds in the $HOME/cardano-src directory, to make one command:
mkdir -p $HOME/cardano-src
cd $HOME/cardano-src
Download, compile, and install libsodium:
git clone https://github.com/input-output-hk/libsodium
cd libsodium
git checkout 66f017f1
./autogen.sh
./configure
make
sudo make install
Update the shell by adding two environment variables, so the compiler can be aware that libsodium is installed on your Linux host.
Type nano $HOME/.zshrc
(or nano $HOME/.bashrc
) and add to the bottom:
export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
Restart or reload the shell afterwards with the command: source $HOME/.bashrc
, or source $HOME/.zshrc
in case of Zsh.
Download, compile, and install libsecp256k1:
cd $HOME/cardano-src
git clone https://github.com/bitcoin-core/secp256k1
cd secp256k1
git checkout ac83be33
./autogen.sh
./configure --enable-module-schnorrsig --enable-experimental
make
make check
sudo make install
Download, compile, and install cardano-node(cardano-cli is included):
cd $HOME/cardano-src
git clone https://github.com/input-output-hk/cardano-node.git
cd cardano-node
git fetch --all --recurse-submodules --tags
git checkout $(curl -s https://api.github.com/repos/input-output-hk/cardano-node/releases/latest | jq -r .tag_name)
Step 4 - Building binaries
For correct building GHC is required to be configured to the version recommended by IOHK by running:
cabal configure --with-compiler=ghc-8.10.7
And one more step for Linux hosts on ARM platforms which require additional configuration for LLVM:
sudo apt install llvm-9
sudo apt install clang-9 libnuma-dev
sudo ln -s /usr/bin/llvm-config-9 /usr/bin/llvm-config
sudo ln -s /usr/bin/opt-9 /usr/bin/opt
sudo ln -s /usr/bin/llc-9 /usr/bin/llc
sudo ln -s /usr/bin/clang-9 /usr/bin/clang
Build Haskell-based cardano-node to produce executable binaries:
cabal build cardano-node cardano-cli
Install cardano-node and cardano-cli commands to the $HOME/.local/bin
directory with:
mkdir -p $HOME/.local/bin
cp -p "$(./scripts/bin-path.sh cardano-node)" $HOME/.local/bin/
cp -p "$(./scripts/bin-path.sh cardano-cli)" $HOME/.local/bin/
Update $HOME/.bashrc
by adding export PATH="$HOME/.local/bin/:$PATH"
to the end and restart shell or reload source $HOME/.bashrc
profile, use source $HOME/.zshrc
in case of Zsh.
See the version installed by typing:
cardano-cli --version
cardano-node --version
Successful installation should display the versions installed:
cardano-cli 1.35.1 - darwin-aarch64 - ghc-8.10
git rev c23d5d319cd3276575c6ac32458516232e8d2c48
cardano-node 1.35.1 - darwin-aarch64 - ghc-8.10
git rev c23d5d319cd3276575c6ac32458516232e8d2c48
Cardano node and cli are now configured and ready for usage.