Quickly bootstrap Cardano Node
added: September 20, 2023
LINKS:
Today, there are several methods available to quickly configure and launch your Cardano node. In this brief post, I'd like to write about the precompiled node + chain snapshot setup, which is both quick and straightforward. However, if you plan to operate a Stake Pool, it's highly advisable to ensure maximum security by verifying and building your node from the official repository and manually syncing it. Let's cook! 👨🍳
This tutorial is based on a fantastic post by APEX Stake Pool!
download necessary files
Download the most recent, precompiled stable node version; at the time of writing this tutorial, that version is 8.1.2 Additionally, you can check preview version for the very latest developments and features. Be ready to encounter issues.
To speed up the synchronization proces we can download the mainet snapshot. This is a big file so make sure you have enough space to download and unpack it. The archive alone is ~80GB.
You can also run Cardano PreProd which it's only ~3GB
These configuration files are necessary because they provide the settings and data required for your Cardano node to function correctly and stay synchronized with the Cardano blockchain. They ensure that your node operates in accordance with the network's rules and protocols, and they enable you to participate in the Cardano network effectively, whether you are running a stake pool or simply using a Cardano node for other purposes.
Notice that we don't need all of files provided to run our relay node. We need:
node config - configuration settings for your Cardano node
node topology - specifies how your Cardano node connects to other nodes in the network
byron genesis - Byron-specific parameters
shelley genesis - Shelley-specific parameters
alonzo genesis - Alonzo-specific parameters
conway genesis - Conway-specific parameters
setting up
My folder will be located in users/mcj/cardano-node-mainnet and it will look like this:
cardano-node-mainnet
├── bin
├── config
└── db
bin - our node startup file will be located here
config - configuration files for the node
db - blockchain database
Inside the archive cointaining pre-compilled cardano node you will find many binary files and a folder named configuration. Copy the binaries to usr/local/bin (Linux or macOS). When you place the Cardano node binaries in provided directory, you essentially integrate them into the system's PATH. This integration enables you to execute these binaries from any terminal location without having to specify their full path.
Inside bin folder, create a startNode.sh file using a text editor of your choice. Copy and paste the script below, and be sure to update the DIRECTORY variable with your own path.
#!/bin/bash
DIRECTORY=/Users/mcj/cardano-node-mainnet
PORT=6000
HOSTADDR=0.0.0.0
TOPOLOGY=${DIRECTORY}/config/topology.json
DB_PATH=${DIRECTORY}/db
SOCKET_PATH=${DIRECTORY}/db/node.socket
CONFIG=${DIRECTORY}/config/config.json
cardano-node +RTS -N -RTS run \
--topology ${TOPOLOGY} \
--database-path ${DB_PATH} \
--socket-path ${SOCKET_PATH} \
--host-addr ${HOSTADDR} \
--port ${PORT} \
--config ${CONFIG}
If you haven't already, move configuration files we downloaded into cardano-node-mainnet/config
To use the snapshot we just downloaded, we need to decompress and unpack the file into our main folder, cardano-node-mainnet. You can achieve this with a single command:
lz4 -dc /users/mcj/downloads/mainnet-db-103468146.tar.lz4 | tar -xv -C /users/mcj/cardano-node-mainnet/
where /users/mcj/downloads/mainnet-db-103468146.tar.lz4 is the path of the file we downloaded and /users/mcj/cardano-node-mainnet/ is the destination to unpack.
Now all of the files are ready. Let's try to run the node!
running the node
startNode.sh - just drag and drop this file into the terminal and press enter. The node should start syncing. Becuase we downloaded the snapshot, the syncign time should be short.
INTERACTING WITH CARDANO NODE VIA CLI
Our node is now syncing! But how do we determine how much has been synchronized, and how can we check the current tip? It's actually quite simple. Open a new Terminal window - remember to leave the node running - and try to obtain the current tip with command:
cardano-cli query tip --mainnet
It may not work immediately, but don't worry! You just need to connect to the node socket using this command (remember to update the path):
export CARDANO_NODE_SOCKET_PATH=/Users/mcj/cardano-node-mainnet/db/node.socket
Now, when you attempt to query the tip, you should see the current EPOCH, block, and more.
what about mithril?
Mithril is quite similar to a snapshot we just downloaded, but with a significant difference: you don't need to trust the snapshot provider, as it's certified by Stake Pool operators. Currently, Mithril is in Beta. However, as soon as it becomes available, I will create a new tutorial on how to use it. This will enable you to bootstrap a Cardano node in just a few hours, depending on your connection speed.
final notes
While there are a few steps involved, this process teaches you some crucial aspects of the node setup process. We skipped the node build, which has quite a few steps & can be time consuming. Additionally, we didn't wait for synchronization. Without the snapshot, this process could take an entire day or even longer, as it depends not only on your connection speed but also on your CPU. I hope you found this informative!