DOWNLOAD CARDANO SNAPSHOT WITH MITHRIL CLIENT
added: September 25, 2023
LINKS:
Recently, I published a tutorial on how to QUICKLY BOOTSTRAP A CARDANO NODE. To bootstrap the node, we used a snapshot of the Cardano blockchain from a relatively safe source. However, what Mithril does is provide confidence that the data is genuine, as it has been certified by Stake Pool Operators via the Mithril protocol. Let's build the client and download the snapshot in this manner. Let's get cooking! 👨🍳
download snapshot without client
Firstly, I'd like to mention that you don't have to use the Mithril Client to download the snapshot. We'll do it because it's a good exercise. However, before we proceed, let me tell you that you can navigate to the Mithril Explorer and get the direct link to dl the snapshot.
That's it! You now have the latest snapshot of the Cardano blockchain. How cool is that?!
compiling mithril client
Installing Rust Toolchain is very simple. All you have to do is to copy/paste this command into the terminal (macOS, or another Unix-like OS):
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
To forge out Mithril binaries 🔥🔨, we need to get the source files from GitHub:
git clone https://github.com/input-output-hk/mithril.git
After downloading the GitHub repository with the source files, a new folder named mithril has been created. Since we want to build the client, we need to navigate to mithril/mithril-client and then build the binaries in order to use it to download the snapshot.
cd mithril/mithril-client
Once you're in the correct folder, it's time to finally build:
make build
to double check your Mithril node, check its version:
./mithril-client -V
download mainnet snapshot
Let's try to list the available snapshots that we can download for the mainnet:
./mithril-client --run-mode mainnet snapshot list
We get and error: configuration property "aggregator_endpoint" not found - Why?
If you navigate to mithril/mithril-client/config you will see two files: dev.json and preview.json Inside the preview.json is the configuration that contains:
network - specifies which Cardano network the client will connect to
aggregator_endpoint - the URL address of the aggregator endpoint
genesis_verification_key - the key used to verify the authenticity of the genesis block
Because Mithril is currently in Beta, it comes with a config for the preview network, not the mainnet. So, if we run command to list snapshot and 'preview' instead of 'mainnet', we should get the list of snapshots for the preview network.
Let's create the config file for the mainnet and try to get the list of snapshots again. Simply create a new file named mainnet.json and use the configuration provided on the mithril website.
{
"network": "mainnet",
"aggregator_endpoint": "https://aggregator.release-mainnet.api.mithril.network/aggregator",
"genesis_verification_key": "5b3139312c36362c3134302c3138352c3133382c31312c3233372c3230372c3235302c3134342c32372c322c3138382c33302c31322c38312c3135352c3230342c31302c3137392c37352c32332c3133382c3139362c3231372c352c31342c32302c35372c37392c33392c3137365d"
}
Now we can list the mainnet snapshots!
We are now ready to download the latest snapshot!
./mithril-client --run-mode mainnet snapshot download latest
using the snapshot
The snapshot will download to the mithril/mithril-client/db folder. Once it finishes, you can copy and paste it into your node folder and then run the node. The node will validate it and then sync the remaining data. QUICKLY BOOTSTRAP A CARDANO NODE provides all the information you need to run the relay node using the snapshot.
final notes
While you can download the snapshot directly from the website, using the Mithril Client is a fun exercise. It allows you to become familiar with a few more aspects involved in it, without delving into too much complexity. I hope you enjoyed this one!