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
.
- 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
- 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 .bashrc
file, select YES
Then make the ghcup
command available:
source $HOME/.bashrc
- 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
- 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
- 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
- Build
Grab a drink and a bite to eat as this will take a while
cabal build cardano-cli cardano-node
- 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/
- Validate new versions
cardano-node version
cardano-cli version
- 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"
- Start your node
sudo systemctl start cardano-node