Relay nodes do not have any keys, so they cannot produce blocks. Instead, relays act as proxies between the core network nodes and the internet, establishing a security perimeter around the core, block-producing network nodes. Since external nodes cannot communicate with block-producing nodes directly, relay nodes ensure that the integrity of the core nodes and the blockchain remains intact, even if one or more relays become compromised.
a different computer/laptop/server/VM (not located on the same machine as your block-producing node)
We call the current relay node NEW and the previous block producing or relay node EXISTING.
NEW_RELAY_NODE_IP
can be discovered automatically with help from ifconfig.me
NEW_RELAY_NODE_IP=$(curl http://ifconfig.me/ip)NEW_RELAY_NODE_PORT=3001EXISTING_NODE_IP=<IP OF MY EXISTING BLOCK PRODUCING OR RELAY NODE>EXISTING_NODE_PORT=<PORT OF MY EXISTING BLOCK PRODUCING OR RELAY NODE>
printf "NEW_RELAY_NODE_IP: $NEW_RELAY_NODE_IP \n\NEW_RELAY_NODE_PORT: $NEW_RELAY_NODE_PORT \n\EXISTING_NODE_IP: $EXISTING_NODE_IP \n\EXISTING_NODE_PORT: $EXISTING_NODE_PORT \n"
echo export NODE_HOME=$HOME/cardano-my-node >> ~/.bashrcecho export NODE_CONFIG=mainnet >> ~/.bashrcecho export NODE_URL=cardano-mainnet >> ~/.bashrcecho 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') >> ~/.bashrcecho export NETWORK_IDENTIFIER=\"--mainnet\" >> ~/.bashrcecho export CARDANO_NODE_SOCKET_PATH="$NODE_HOME/db/socket" >> ~/.bashrcsource ~/.bashrc
Install dependencies and compile source code.
cat > installRelayNode.sh << HEREsudo apt-get update -ysudo apt-get upgrade -ysudo apt-get install git make tmux rsync htop curl 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 -ymkdir ~/gitcd ~/gitgit clone https://github.com/input-output-hk/libsodiumcd libsodiumgit checkout 66f017f1./autogen.sh./configuremakesudo make installcdwget https://downloads.haskell.org/~cabal/cabal-install-3.2.0.0/cabal-install-3.2.0.0-x86_64-unknown-linux.tar.xztar -xf cabal-install-3.2.0.0-x86_64-unknown-linux.tar.xzrm cabal-install-3.2.0.0-x86_64-unknown-linux.tar.xz cabal.sigmkdir -p ~/.local/binmv cabal ~/.local/bin/wget https://downloads.haskell.org/~ghc/8.6.5/ghc-8.6.5-x86_64-deb9-linux.tar.xztar -xf ghc-8.6.5-x86_64-deb9-linux.tar.xzrm ghc-8.6.5-x86_64-deb9-linux.tar.xzcd ghc-8.6.5./configuresudo make installcabal updatecabal -Vghc -Vcd ~/gitgit clone https://github.com/input-output-hk/cardano-node.gitcd cardano-nodegit fetch --allgit checkout tags/1.18.0sed -i $HOME/.cabal/config -e "s/overwrite-policy:/overwrite-policy: always/g"rm -rf $HOME/git/cardano-node/dist-newstyle/build/x86_64-linux/ghc-8.6.5HEREchmod +x installRelayNode.shsudo -u $(whoami) ./installRelayNode.sh
Build binaries and fetch the node .json files.
cd ~/git/cardano-nodeecho -e "package cardano-crypto-praos\n flags: -external-libsodium-vrf" > cabal.project.localcabal build cardano-cli cardano-nodemkdir $NODE_HOMEcd $NODE_HOMEwget -N https://hydra.iohk.io/build/${NODE_BUILD_NUM}/download/1/${NODE_CONFIG}-byron-genesis.jsonwget -N https://hydra.iohk.io/build/${NODE_BUILD_NUM}/download/1/${NODE_CONFIG}-topology.jsonwget -N https://hydra.iohk.io/build/${NODE_BUILD_NUM}/download/1/${NODE_CONFIG}-shelley-genesis.jsonwget -N https://hydra.iohk.io/build/${NODE_BUILD_NUM}/download/1/${NODE_CONFIG}-config.jsonsed -i ${NODE_CONFIG}-config.json \-e "s/SimpleView/LiveView/g" \-e "s/TraceBlockFetchDecisions\": false/TraceBlockFetchDecisions\": true/g"cd $NODE_HOMEmkdir relaynode1cp *.json relaynode1
Copy binaries and verify the correct version is installed.
sudo cp $(find ~/git/cardano-node/dist-newstyle/build -type f -name "cardano-cli") /usr/local/bin/cardano-clisudo cp $(find ~/git/cardano-node/dist-newstyle/build -type f -name "cardano-node") /usr/local/bin/cardano-nodecardano-node versioncardano-cli version
Create topology and start/stop scripts.
cat > $NODE_HOME/relaynode1/${NODE_CONFIG}-topology.json << EOF{"Producers": [{"addr": "$EXISTING_NODE_IP","port": $EXISTING_NODE_PORT,"valency": 1},{"addr": "relays-new.${NODE_URL}.iohk.io","port": 3001,"valency": 2}]}EOFcat > $NODE_HOME/relaynode1/startRelayNode1.sh << EOFDIRECTORY=\$NODE_HOME/relaynode1PORT=3001HOSTADDR=0.0.0.0TOPOLOGY=\${DIRECTORY}/${NODE_CONFIG}-topology.jsonDB_PATH=\${DIRECTORY}/dbSOCKET_PATH=\${DIRECTORY}/db/socketCONFIG=\${DIRECTORY}/${NODE_CONFIG}-config.jsoncardano-node run --topology \${TOPOLOGY} --database-path \${DB_PATH} --socket-path \${SOCKET_PATH} --host-addr \${HOSTADDR} --port \${PORT} --config \${CONFIG}EOFcat > $NODE_HOME/startRelay.sh << EOF#!/bin/bashSESSION=$(whoami)tmux has-session -t \$SESSION 2>/dev/nullif [ \$? != 0 ]; then# tmux attach-session -t \$SESSIONtmux new-session -s \$SESSION -n window -dtmux split-window -htmux select-pane -t \$SESSION:window.0tmux send-keys -t \$SESSION:window.0 $NODE_HOME/relaynode1/startRelayNode1.sh Entertmux send-keys -t \$SESSION:window.1 htop Enterecho Relaynode started. \"tmux a\" to view.fiEOFcat > $NODE_HOME/stopRelay.sh << EOF#!/bin/bashSESSION=$(whoami)tmux has-session -t \$SESSION 2>/dev/nullif [ \$? != 0 ]; thenecho Relaynode not running.elseecho Stopped Relaynode.tmux kill-session -t \$SESSIONfiEOFcd $NODE_HOMEchmod +x relaynode1/startRelayNode1.shchmod +x startRelay.shchmod +x stopRelay.sh
cat $NODE_HOME/relaynode1/${NODE_CONFIG}-topology.json
Use pooltool.io and the get_buddies script to manage your NEW relay node's topology.
Alternatively, if you have multiple relay nodes you would like to connect to, add their configurations to your topology.json file.
Example snippet below:
{"addr": "3.3.3.3","port": 3002,"valency": 1},
Specific to your networking setup or cloud provider settings, ensure your relay node's ports are open and reachable. Use https://canyouseeme.org/ to verify.
Finally, add your new NEW relay node IP/port information to your EXISTING node's topology file.
Same process as step 5 but for your EXISTING node.
On NEW relay node,
cd $NODE_HOME./startRelay.sh
On EXISTING relay / block producing node,
cd $NODE_HOME./stopStakePool.sh./startStakePool.sh
## or if you are using systemdsudo systemctl stop cardano-stakepoolsudo systemctl start cardano-stakepool
On one of your node's tmux screen, press P
to view the peer list. You should see the connection to other node's IP.
✨ Congrats on the new relay node.
Reminder, relay nodes should NOT contain any operational certifications
, vrf
, skey
or cold
keys.