Nitro database snapshots
Nitro stores the chain state and data in a database in the local filesystem. When starting Nitro for the first time, it will initialize an empty database by default and start processing transactions from Genesis. It takes a long time for the node to sync from Genesis, so starting from a database snapshot is advisable instead. Moreover, for the Arb1 chain, you must start from a snapshot because Nitro cannot process transactions from the Classic Arbitrum node.
Supply the snapshot URL to Nitro
There are multiple ways to supply Nitro with the database snapshot. The most straightforward way is to provide the configuration, so Nitro downloads the snapshot by itself. It is also possible to download the database manually and supply it to Nitro.
Downloading the latest snapshot
Nitro has a CLI configuration for downloading the latest snapshot from a remote server. Set the flag --init.latest to either archive, pruned, or genesis, and Nitro will download the preferred snapshot. You may also change the --init.latest-base flag to set the base URL when searching for the latest snapshot.
How it works
When searching for the latest snapshot, Nitro uses the chain name provided in --chain.name. Make sure to set it correctly; otherwise, Nitro might be unable to find the snapshot. Nitro will look for a remote file in <latest-base>/<chain-name>/latest-<kind>.txt, where <kind> is the option supplied to --init.latest. This file should contain either the path or the full URL to the snapshot; if it only contains the path, Nitro will use the <latest-base> as the base URL.
After finding the latest snapshot URL, Nitro will download the archive and temporarily store it in the directory specified in --init.download-path. Nitro looks for a SHA256 checksum on the remote server and verifies the checksum of the snapshot after finishing the download. (It is possible to disable this feature by setting --init.validate-checksum to false.)
The snapshot can be a single archive file or a series of parts. Nitro first tries to download the snapshot as a single archive. In this case, Nitro will look for a checksum file in <archive-url>.sha256. If the remote server returns not found (404 status code), Nitro will proceed to download the snapshot in parts. When downloading in parts, Nitro will look for a manifest file in <archive-url>.manifest.txt containing each part's name and checksum. In this case, Nitro will download each part in the manifest file and concatenate them into a single archive.
Finally, Nitro decompresses and extracts the snapshot archive, placing it in the database directory. Nitro will delete the archive after extracting it, so if you need to set up multiple nodes with the same snapshot, consider downloading it manually, as explained below.
Downloading the snapshot from a URL
Instead of letting Nitro search for the latest snapshot, you can provide a specific URL to download by setting the flag --init.url with the snapshot URL. If the URL points to a remote server, it should start with the https:// protocol definition. Given the URL, Nitro will download the snapshot as described in the "Downloading the Latest Snapshot" section.
Nitro also supports importing files from the local file system. In this case, you should provide the file path to --init.url starting with the prefix file:// followed by the file path. Beware that when running Nitro inside a Docker container, you must mount a volume containing the provided snapshot using the docker flag -v (see Docker documentation). Otherwise, the Nitro container running inside Docker won’t be able to find the snapshot in your local filesystem.
Downloading the snapshot manually
It is possible to download the snapshot manually and supply the archive instead of having Nitro download it.
The first step is downloading the snapshot. The command below illustrates how to do that on the command line using wget. The -c flag tells the wget to continue the download from where it left off, which is helpful because snapshots can be huge files, and the download can fail mid-way. The -P flag tells wget to place the snapshot on the temporary dir.
wget -c -P /tmp "$SNAPSHOT_URL"
After downloading the snapshot, make sure to verify whether the checksum matches the one provided by the remote server. To fetch the checksum, you may run the command below.
wget -q -O - "$SNAPSHOT_URL".sha256
Once you know the expected snapshot checksum, run the command below to compute the checksum of the downloaded snapshot. Then, compare both and see if they are the same. If they are not the same, consider redownloading the snapshot. You must provide a valid snapshot to Nitro; otherwise, it won’t work properly.
sha256sum $PATH_TO_SNAPSHOT
Finally, you can provide a path to the downloaded snapshot archive to Nitro using the --init.url flag, as described in the "Download the Snapshot from a URL" section.