Building Astar Nodes by Reducing Synchronization with Snapshot!

tksarah
The Astar Bulletin | TAB
4 min readJul 9, 2023

--

You can easily build an Astar Archive Node using the following documentation. However, it takes a significant amount of time until it reaches the latest block state. Depending on the environment, it took me about one month when I used Raspberry Pi. There is a method to reduce synchronization time by using Snapshot. This report will cover that approach

1, Downloading the Snapshot

The Snapshot (which is essentially just a tar ball) can be downloaded from the Stakecraft website. Here, you will find not only the Astar Snapshot but also other Snapshots available. Archive files updated approximately by date and time are available for download.

For example, if it is July 1, 2023, you would download the tar ball archive file named “astar_2023–07–01.tar” for that specific date.

Here’s how you can download it:

# wget {download link}

Since the file is several hundred gigabytes in size and quite large, downloading it may take time depending on your internet connection. Therefore, it is advisable to use a tool that supports resumable downloads for this purpose.

2, Preparing the Directory

“First, set up the Astar Archive Node and start it once. After confirming that the initial synchronization has started, stop the node.”

# sudo systemctl start astar.service

# sudo systemctl stop astar.service

This process will create the necessary directory structure under ‘/var/lib/astar’.

Next, while the Astar service (astar-collator) is stopped, you will recreate the DB directory, effectively deleting the previously initialized data.

# sudo rm -rf /var/lib/astar/chains/astar/db 
# sudo mkdir -p /var/lib/astar/chains/astar/db/full

3, Extracting the Snapshot

Extract the downloaded Snapshot file (tar ball).

# sudo tar xf {snapshot file} -C /var/lib/astar/chains/astar/db/full

This process may take some time, depending on your environment.

4, Updating Ownership and Group

You need to change the ownership and group of all the newly created directories and extracted files to ‘astar’. Note that unless they are set to ‘astar’ (specifically the user running astar-collator), the node will not start.

# sudo chown -R astar.astar /var/lib/astar/chains/astar/db

5, Starting the Astar Service

Finally, start the Astar service, and you’re done!

# sudo systemctl start astar.service

Afterwards, please use the command ‘journalctl -f -u astar.service -n 100’ to check for any errors and ensure that the synchronization has started successfully.

That’s all!

Points of attention

Regarding the Download of the Snapshot

The Snapshot file, as of the time of writing this article, is approximately 350GB in size. Based on the download speed of your internet connection, you can roughly estimate the time it will take to complete the download. However, please note that it will indeed take a significant amount of time. For example, at a rough speed of 10MB/s, it could take around 10 hours.

Regarding the Drive

When it comes to extracting the Snapshot, the time taken for the extraction process will largely depend on the data drive you are using (whether it’s a hard disk drive or an SSD). Especially if the source Snapshot file and the destination directory are on the same hard disk drive, you should expect the extraction process to take several hours.

To shorten the extraction time, you have a couple of options. One is to use separate drives for the source and destination, or alternatively, using an SSD can also significantly reduce the extraction time.

Snapshot File and File System Status

If the download and extraction process fails, attempting to start the Astar service may result in errors, preventing it from starting properly. The service restarts may occur repeatedly, and you may encounter the following error messages:

Jul 09 04:13:58 hogenode astar-collator[1829]: Error: Service(Client(Backend("Invalid argument: Column families not opened: col12, col11, col10, col9, col8, col7, col6, col5, col4, col3, col2, col1, col0")))
Jul 09 04:13:58 hogenode systemd[1]: astar.service: Main process exited, code=exited, status=1/FAILURE
Jul 09 04:13:58 hogenode systemd[1]: astar.service: Failed with result 'exit-code'.
Jul 09 04:14:08 hogenode systemd[1]: astar.service: Scheduled restart job, restart counter is at 8.
Jul 09 04:14:08 hogenode systemd[1]: Stopped Astar Archive node.
Jul 09 04:14:08 hogenode systemd[1]: Started Astar Archive node.
Jul 09 04:14:08 hogenode astar-collator[1884]: 2023-07-09 04:14:08 Astar Collator

In such cases, the potential causes could be a corrupted or incomplete Snapshot, as well as inconsistencies in the extracted file system.

Please try obtaining a new Snapshot and, if necessary, rebuilding the file system to resolve the issues.

References

※Please note that the procedure on this site performs the download of the snapshot and the extraction of the archive in a stream. However, considering the large size of the files and for future troubleshooting purposes, I personally recommend performing these tasks separately.

--

--

Astar Network Official Ambassador@Tokyo / web3 Technacal Marketing / IT Infra TechLead / Tech Instructor / School Teacher