Skip to content

Latest commit

 

History

History
285 lines (208 loc) · 6.64 KB

installing.md

File metadata and controls

285 lines (208 loc) · 6.64 KB

Installing from Source (without Nix)

Prerequisites

This guide assumes you have the following tools:

In addition, Cardano DB Sync requires the following software (instructions below):

macOS:

Create a working directory for your builds:

mkdir -p ~/src
cd ~/src

Install Dependencies

Install GHC and Cabal

The recommended way to install the Haskell tools is via GHCup. Check this page for installation instructions. Its installation script will guide you through the installation, and warn you about package dependencies.

Once GHCup is installed, open a new terminal (to get an updated environment) and run:

ghcup install ghc 8.10.7
ghcup install cabal 3.10.1.0
ghcup set ghc 8.10.7
ghcup set cabal 3.10.1.0

Check that you will use the GHCup tools (and not any other installation on the system):

which cabal

It should print a path of this shape: /home/<user>/.ghcup/bin/cabal.

Install Sodium

Cardano uses a fork of libsodium which exposes some internal functions and adds some other new functions.

Enter a working directory for your builds:

cd ~/src

Take note of the latest revision from iohk-nix:

REV=$(curl -L https://github.com/input-output-hk/iohk-nix/releases/latest/download/INFO \
  | awk '$1 == "debian.libsodium-vrf.deb" { rev = gensub(/.*-(.*)\.deb/, "\\1", "g", $2); print rev }')

Checkout libsodium:

git clone https://github.com/IntersectMBO/libsodium
cd libsodium
git checkout $REV

Build and install it:

./autogen.sh
./configure
make
make check
sudo make install

Add the following to your ~/.bashrc file and source it (or re-open the terminal):

export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"

On Linux, running the ldconfig command is required to make the dynamic linker aware of the new library.

Installing Secp256k1

Enter the working directory for your builds:

cd ~/src

Take note of the latest revision from iohk-nix:

REV=$(curl -L https://github.com/input-output-hk/iohk-nix/releases/latest/download/INFO \
  | awk '$1 == "debian.libsecp256k1.deb" { rev = gensub(/.*-(.*)\.deb/, "\\1", "g", $2); print rev }')

Checkout libsecp256k1:

git clone https://github.com/bitcoin-core/secp256k1
cd secp256k1
git checkout $REV

Build and install it:

./autogen.sh
./configure --enable-module-schnorrsig --enable-experimental
make
make check
sudo make install

Installing blst

Enter the working directory for your builds:

cd ~/src

Take note of the latest revision from iohk-nix:

REV=$(curl -L https://github.com/input-output-hk/iohk-nix/releases/latest/download/INFO \
  | awk '$1 == "debian.libblst.deb" { rev = gensub(/.*-(.*)\.deb/, "\\1", "g", $2); print rev }')

Checkout blst:

git clone https://github.com/supranational/blst
cd blst
git checkout $REV

Build it:

./build.sh

Install it:

cat > libblst.pc << EOF
prefix=/usr/local
exec_prefix=\${prefix}
libdir=\${exec_prefix}/lib
includedir=\${prefix}/include

Name: libblst
Description: Multilingual BLS12-381 signature library
URL: https://github.com/supranational/blst
Version: 0.3.10
Cflags: -I\${includedir}
Libs: -L\${libdir} -lblst
EOF

sudo cp libblst.pc /usr/local/lib/pkgconfig/
sudo cp bindings/blst_aux.h bindings/blst.h bindings/blst.hpp  /usr/local/include/
sudo cp libblst.a /usr/local/lib
sudo chmod 644 \
  /usr/local/lib/libblst.* \
  /usr/local/include/{blst.*,blst_aux.h}

MACOS:

If you hit the following error on macOS:

+ cc -O2 -fno-builtin -fPIC -Wall -Wextra -Werror -c ./src/server.c
In file included from ./src/server.c:7:
In file included from ./src/keygen.c:7:
In file included from ./src/consts.h:8:
./src/vect.h:402:11: fatal error: 'stdlib.h' file not found
# include <stdlib.h>

check you have x-code command line tools installed or try install them by running:

xcode-select --install

If you are using homebrew you might need to unistall llvm@13 as this clashes with x-code:

brew uninstall llvm@13

Install Cardano DB Sync

Download the Source

Enter the working directory for your builds:

cd ~/src

Find the latest release here: https://github.com/IntersectMBO/cardano-db-sync/releases

Check out the latest release version:

git clone https://github.com/IntersectMBO/cardano-db-sync.git
cd cardano-db-sync
git fetch --all --tags
git checkout tags/<VERSION>

Configure Build Options

Explicitly set the GHC version that we installed earlier. This avoids defaulting to a system version of GHC that might be different than the one you have installed.

echo "with-compiler: ghc-8.10.7" >> cabal.project.local

macOS installs OpenSSL in a different location than expected by default. If you have installed OpenSSL via homebrew then run:

sudo mkdir -p /usr/local/opt/openssl
sudo ln -s /opt/homebrew/opt/openssl@3/lib /usr/local/opt/openssl/lib
sudo ln -s /opt/homebrew/opt/openssl@3/include /usr/local/opt/openssl/include

If you are on an M1 Mac, run:

echo "package HsOpenSSL" >> cabal.project.local
echo "  flags: -homebrew-openssl" >> cabal.project.local
echo "" >> cabal.project.local

Build and Install

Build Cardano DB Sync with cabal:

cabal update
cabal build all

Install it in the ~/.local/bin directory:

mkdir -p ~/.local/bin
cp -p \
  "$(find . -name cardano-db-sync -executable -type f)" \
  ~/.local/bin/

Note: ~/.local/bin should be in the $PATH.

Note, we avoid using cabal install because that method prevents the installed binaries from reporting the git revision with the --version switch.

Check the version that has been installed:

cardano-db-sync --version