Skip to content

Instantly share code, notes, and snippets.

@ariady-putra
Last active October 26, 2024 11:01
Show Gist options
  • Save ariady-putra/42aab0513e179b4a6c82b0271ef9b721 to your computer and use it in GitHub Desktop.
Save ariady-putra/42aab0513e179b4a6c82b0271ef9b721 to your computer and use it in GitHub Desktop.

Build cardano-node and cardano-cli on Ubuntu

Install Prerequisites

sudo apt-get update -y

sudo apt-get install automake build-essential curl pkg-config libffi-dev libgmp-dev libssl-dev libtinfo-dev libsystemd-dev zlib1g-dev make g++ tmux git jq wget libncursesw5 libtool autoconf -y

Install GHC and Cabal

curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh

Logout and login to run further commands

ghcup --version

Install specific version of GHC (8.10.7)

ghcup install ghc 8.10.7
ghcup set ghc 8.10.7

Downloading and Compiling

mkdir -p ~/cardano-src

cd ~/cardano-src
git clone https://github.com/input-output-hk/libsodium

cd libsodium
git checkout 66f017f1

./autogen.sh
./configure

make
sudo make install

Logout and login to run further commands

cd ~/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 clean
make check
sudo make install

https://groups.google.com/g/protobuf/c/PiMeN10AtOQ

sudo ldconfig /usr/local/lib

Add the following to /etc/ environment so that the compiler can be aware that libsodium and secp256k1 are installed on your system, and set Cardano node socket path for database sync later:

LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
# where :$LD_LIBRARY_PATH refers to the existing LD_LIBRARY_PATH values separated by : (colon)

PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
# where :$PKG_CONFIG_PATH refers to the existing PKG_CONFIG_PATH values separated by : (colon)

CARDANO_NODE_SOCKET_PATH="/media/ariady/VIRUS DETECTED/cardano-testnet/testnet.socket"

Logout and login to run further commands

cd ~/cardano-src
git clone https://github.com/input-output-hk/cardano-node.git

cd cardano-node
git fetch --all --recurse-submodules --tags

Checkout the latest version:

git checkout $(curl -s https://api.github.com/repos/input-output-hk/cardano-node/releases/latest | jq -r .tag_name)

or specify a specific version manually:

git checkout tags/1.35.2

Modify ~/cardano-src/cardano-node/ cabal.project

# Remove `cardano-client-demo` from `packages`
# Set all `tests` to `False`

Compile the cardano-node

cd ~/cardano-src/cardano-node
cabal configure --with-compiler=ghc-8.10.7

Append the following to ~/cardano-src/cardano-node/ cabal.project.local

package cardano-crypto-praos
flags: -external-libsodium-vrf

Build and install cardano-node and cardano-cli

cd ~/cardano-src/cardano-node
cabal build cardano-node cardano-cli

mkdir -p ~/.local/bin

cp -p "$(~/cardano-src/cardano-node/scripts/bin-path.sh cardano-node)" ~/.local/bin/
cp -p "$(~/cardano-src/cardano-node/scripts/bin-path.sh cardano-cli)" ~/.local/bin/

We need to add this line to /etc/ environment so that the shell/terminal can recognize that cardano-node and cardano-cli as global commands:

PATH="~/.local/bin/:$PATH"
# where :$PATH refers to the existing PATH values separated by : (colon)

Check the version that has been installed

cardano-cli --version
cardano-node --version

SELAMAT ANDA SUDAH BUILD LOCAL CARDANO NODE !!!

Run Cardano Node After Vasil HardFork

Di dalam folder ~/cardano-src/cardano-node/configuration/cardano sudah ada cardano-node configuration files, tapi jka belum ada kita bisa men-download-nya dengan commands di bawah ini:

Mainnet / Production, NetworkMagic: 764824073

curl -O -J https://hydra.iohk.io/build/7370192/download/1/mainnet-config.json
curl -O -J https://hydra.iohk.io/build/7370192/download/1/mainnet-byron-genesis.json
curl -O -J https://hydra.iohk.io/build/7370192/download/1/mainnet-shelley-genesis.json
curl -O -J https://hydra.iohk.io/build/7370192/download/1/mainnet-alonzo-genesis.json
curl -O -J https://hydra.iohk.io/build/7370192/download/1/mainnet-topology.json

Testnet / Sandbox, NetworkMagic: 1097911063

curl -O -J https://hydra.iohk.io/build/7654130/download/1/testnet-topology.json
curl -O -J https://hydra.iohk.io/build/7654130/download/1/testnet-shelley-genesis.json
curl -O -J https://hydra.iohk.io/build/7654130/download/1/testnet-config.json
curl -O -J https://hydra.iohk.io/build/7654130/download/1/testnet-byron-genesis.json
curl -O -J https://hydra.iohk.io/build/7654130/download/1/testnet-alonzo-genesis.json

Untuk run cardano-node kita bisa menggunakan script berikut dijalankan dari terminal:

cardano-node run \
   --topology ~/cardano-src/cardano-node/configuration/cardano/mainnet-topology.json \
   --database-path /media/ariady/VIRUS\ DETECTED/cardano-mainnet-db \
   --socket-path /media/ariady/VIRUS\ DETECTED/cardano-mainnet-db/mainnet.socket \
   --host-addr 0.0.0.0 \
   --port 41506 \
   --config ~/cardano-src/cardano-node/configuration/cardano/mainnet-config.json

Contoh menjalankan cardano-node untuk connect ke testnet:

cardano-node run \
   --topology ~/cardano-src/cardano-node/configuration/cardano/testnet-topology.json \
   --database-path /media/ariady/VIRUS\ DETECTED/cardano-testnet \
   --socket-path /media/ariady/VIRUS\ DETECTED/cardano-testnet/testnet.socket \
   --host-addr 0.0.0.0 \
   --port 60514 \
   --config ~/cardano-src/cardano-node/configuration/cardano/testnet-config.json

Jika cardano-node sudah berjalan, maka harus synced 100% dengan slot yg ada di Cardano Explorer, atau bisa di-cek dengan menjalankan command query tip melalui cardano-cli:

cardano-cli query tip --testnet-magic 1097911063

Hasilnya adalah sbb:

{
    "block": 1716443,
    "epoch": 79,
    "era": "Shelley",
    "hash": "1964b7bf15f4170e20cf68164c785a0e2a29e6e316dc17acd3edc0bb42e93aa9",
    "slot": 4003485,
    "syncProgress": "36.45"
}

Jika sudah synced 100% maka value di "syncProgress" akan: "100"

SELAMAT NODE ANDA SUDAH SYNCED 100% DENGAN CARDANO NETWORK !!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment