How to Import a Pre-synced Kusama Database

When first booting up a Kusama node, it may take a while for it go get in sync with the latest block. Depending on how long the chain has been alive, your hard drive speed, your bandwidth, and some other factors, it can take days.

To save time, you can import a database that's already fully synced. First, you need to be aware of the two types of database supported by any Substrate based chain, including Kusama.

  • RocksDB is the industry standard, and used in most blockchains. It's one of the fastest databases out there, is extremely lightweight, and has good compression. This is currently the default.
  • ParityDB is a new database, custom built for blockchain data. It performs better in this niche than any other database out there, but at the cost of storage - it takes up much more disk space.

Either is fine, though ParityDB is preferred as it's likely to become the default soon.

Obtaining a copy

There are several ways to obtain a copy of a pre-synced database (like getting in touch with a validator who is bound to have one), but one of the easiest and most convenient is downloading it from IPFS. Read our primer on IPFS if this is not familiar.

The following links will download the archive database:

If you'd like to speed up the download, feel free to peer to the node with ID QmQjFNk17aKzK1LnD6zk98iPkjeUBoWpb8Ru5AyBcZNCsH.

Importing the Database

We assume you have a working Kusama node on your machine. If you are on Linux-based systems or the WSL (Windows Subsystem for Linux), you can download a pre-built Kusama node (Linux binary) from the release page. While it is possible to compile and run a node on native Windows and Mac OS, it is not recommended for long-term stability, as those operating systems are not built for long continuous operation.

The node needs to be run in archive mode, so the option --pruning=archive needs to be appended unless you're running a validator in which case it's the default. 

Here's an example command to run the node provided you're in the folder which contains the binary:

polkadot --name "My node" --pruning=archive --chain=kusama

 As stated earlier, this will default to RocksDB. To use ParityDB, use:

polkadot --name "My node" --pruning=archive --db=paritydb --chain=kusama

The database folder will be created in ~/.local/share/polkadot/chains/ksmcc3 by default. If you used RocksDB, there will be the folder db. If you used paritydb, there will be the folder paritydb.

You will need the 7zip program to unzip this. First, rename the downloaded file from Qm.... to archive.7z. Now simply uncompress the previously downloaded archive in place of the appropriate folder (make sure the node is not running before doing this). The output of the decompressing will be the folder (db or paritydb) so you can just uncompress into the ksmcc3 folder directly. This is probably easiest to do through a user interface, but if you want a command:

7z x archive.7z -o~/.local/share/polkadot/chains/ksmcc3

 Now relaunch your node with the desired db option, and it will continue syncing from where this archive left off.

Remember to subscribe to our newsletter to be kept up to date on new posts and to be kept in the loop about Web 3.0 developments.

Related posts