Skip to content

Instantly share code, notes, and snippets.

@therandomsecurityguy
Last active May 7, 2021 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save therandomsecurityguy/d7416548971411ff56339b392aa3163f to your computer and use it in GitHub Desktop.
Save therandomsecurityguy/d7416548971411ff56339b392aa3163f to your computer and use it in GitHub Desktop.
Upgrading Cardano nodes

Running Cardano relays and block nodes is a fun project, but upgrading nodes can be a bit of a pain. I compiled some simple steps I used to upgrade from Cardano node 1.26.1 to 1.26.2.

  1. Update/upgrade and install cabal requirements
sudo apt update -y
sudo apt upgrade -y

sudo apt install build-essential curl libffi-dev libffi7 libgmp-dev libgmp10 libncurses-dev libncurses5 libtinfo5 -y
  1. Install ghcup

ghcup is the Haskell toolchain installer, which makes it easy to update ghc:

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

When asked if you want to install the haskell-language-server, select NO. When asked if you want to add ghcup to your .bashrcfile, select YES

Then make the ghcup command available:

source $HOME/.bashrc

  1. Upgrade cabal and ghc versions
ghcup upgrade
ghcup install cabal 3.4.0.0
ghcup set cabal 3.4.0.0
ghcup install ghc 8.10.4
ghcup set ghc 8.10.4
cabal update
cabal --version
ghc --version
  1. Download 1.26.2
git clone https://github.com/input-output-hk/cardano-node.git
cd cardano-node
git fetch --all --recurse-submodules --tags
git checkout tags/1.26.2
  1. Configure build options
# Sets cabal to use ghc 8.10.4
cabal configure -O0 -w ghc-8.10.4

# Sets Ouroboros Praos Libsodium function flags in your local build options
echo -e "package cardano-crypto-praos\n flags: -external-libsodium-vrf" > cabal.project.local

# Allows policy overwrites
sed -i $HOME/.cabal/config -e "s/overwrite-policy:/overwrite-policy: always/g"

# Removes any existing build files
rm -rf $HOME/git/cardano-node/dist-newstyle/build/x86_64-linux/ghc-8.10.4

  1. Build

Grab a drink and a bite to eat as this will take a while

cabal build cardano-cli cardano-node

  1. Stop the node and replace the binaries

sudo systemctl stop cardano-node

Find where you're current binaries are

whereis cardano-node

Install new binaries and CLI commands (~/.local/bin is my binary path)

cabal install --installdir ~/.local/bin cardano-cli cardano-node

If the above command fails, you can manually copy of the executables, replacing the place holder with the target version (1.26.2 in this case):

cp -p dist-newstyle/build/x86_64-linux/ghc-8.10.2/cardano-node-<TAGGED VERSION>/x/cardano-node/build/cardano-node/cardano-node ~/.local/bin/

cp -p dist-newstyle/build/x86_64-linux/ghc-8.10.2/cardano-cli-<TAGGED VERSION>/x/cardano-cli/build/cardano-cli/cardano-cli ~/.local/bin/
  1. Validate new versions
cardano-node version
cardano-cli version
  1. Update the node build number and mainnet-config.json
cd $NODE_HOME

export NODE_BUILD_NUM=$(curl https://hydra.iohk.io/job/Cardano/iohk-nix/cardano-deployment/latest-finished/download/1/index.html | grep -e "build" | sed 's/.*build\/\([0-9]*\)\/download.*/\1/g')

sed -i $HOME/.bashrc \
    -e "s/export NODE_BUILD_NUM=[0-9]\+/export NODE_BUILD_NUM=${NODE_BUILD_NUM}/g"
source $HOME/.bashrc

wget -N https://hydra.iohk.io/build/${NODE_BUILD_NUM}/download/1/mainnet-config.json
sed -i mainnet-config.json \
    -e "s/TraceBlockFetchDecisions\": false/TraceBlockFetchDecisions\": true/g"

  1. Start your node

sudo systemctl start cardano-node

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