跳到主要内容

Archive Node

信息

Read about Full Node before this article

Overview

An Archive Node is a type of Full Node that stores extended historical data of a blockchain. If you are creating a blockchain explorer or a similar application that requires access to historical data, using an Archive Node as an indexer is recommended.

OS requirements

We highly recommend install mytonctrl using the supported operating systems:

  • Ubuntu 20.04
  • Ubuntu 22.04
  • Debian 11

Hardware requirements

  • 16 x Cores CPU
  • 128GB ECC Memory
  • 9TB SSD OR Provisioned 64+k IOPS storage
  • 1 Gbit/s network connectivity
  • 16 TB/month traffic on peak load
  • a public IP address (fixed IP address)
Data Compression

It requires 9TB for the uncompressed data. 6TB is based on using a ZFS volume with compression enabled. The data volume increases by approximately 0.5TB and 0.25TB each month, with the latest update in November 2024.

Installation

Install ZFS and Prepare Volume

Dumps come in form of ZFS Snapshots compressed using plzip, you need to install zfs on your host and restore the dump, see Oracle Documentation for more details.

Usually, it's a good idea to create a separate ZFS pool for your node on a dedicated SSD drive, this will allow you to easily manage storage space and backup your node.

  1. Install zfs
sudo apt install zfsutils-linux
  1. Create pool on your dedicated 4TB <disk> and name it data
sudo zpool create data <disk>
  1. Before restoring we highly recommend to enable compression on parent ZFS filesystem, this will save you a lot of space. To enable compression for the data volume enter using root account:
sudo zfs set compression=lz4 data

Install MyTonCtrl

Please, use a Running Full Node to install and run mytonctrl.

Run an Archive Node

Prepare the node

  1. Before performing a restore, you must stop the validator using root account:
sudo -s
systemctl stop validator.service
  1. Make a backup of ton-work config files (we will need the /var/ton-work/db/config.json, /var/ton-work/keys, and /var/ton-work/db/keyring).
mv /var/ton-work /var/ton-work.bak

Download the dump

  1. Request user and password credentials to gain access for downloading dumps in the @TONBaseChatEn Telegram chat.
  2. Here is an example command to download & restore the mainnet dump from the ton.org server:
wget --user <usr> --password <pwd> -c https://archival-dump.ton.org/dumps/latest.zfs.lz | pv | plzip -d -n <cores> | zfs recv data/ton-work

To install testnet dump use:

wget --user <usr> --password <pwd> -c https://archival-dump.ton.org/dumps/latest_testnet.zfs.lz | pv | plzip -d -n <cores> | zfs recv data/ton-work

The size of the dump is approximately 4TB, so it may take several days (up to 4 days) to download and restore. The dump size can increase as the network grows.

Prepare and run the command:

  1. Install the tools if necessary (pv, plzip)
  2. Replace <usr> and <pwd> with your credentials
  3. Tell plzip to use as many cores as your machine allows to speed up extraction (-n)

Mount the dump

  1. Mount zfs:
zfs set mountpoint=/var/ton-work data/ton-work && zfs mount data/ton-work
  1. Restore db/config.json, keys and db/keyring from backup to /var/ton-work
cp /var/ton-work.bak/db/config.json /var/ton-work/db/config.json
cp -r /var/ton-work.bak/keys /var/ton-work/keys
cp -r /var/ton-work.bak/db/keyring /var/ton-work/db/keyring
  1. Make sure that permissions for /var/ton-work and /var/ton-work/keys dirs promoted correctly:
  • The owner for the /var/ton-work/db dir should be validator user:
chown -R validator:validator /var/ton-work/db
  • The owner for the /var/ton-work/keys dir should be ubuntu user:
chown -R ubuntu:ubuntu /var/ton-work/keys

Update Configuration

Update node configuration for the archive node.

  1. Open the node config file /etc/systemd/system/validator.service
nano /etc/systemd/system/validator.service
  1. Add storage settings for the node in the ExecStart line:
--state-ttl 315360000 --archive-ttl 315360000 --block-ttl 315360000
信息

Please be patient once you start the node and observe the logs. Dumps come without DHT caches, so it will take some time for your node to find other nodes and sync with them. Depending on the age of the snapshot and your internet connection speed, it might take your node anywhere from a few hours to several days to catch up with the network. On a minimum setup, this process can take up to 5 days. This is normal.

警告

If the node sync process has already taken 5 days, but the node is still out of sync, you should check the troubleshooting section.

Start the node

  1. Start the validator by running the command:
systemctl start validator.service
  1. Open mytonctrl from local user and check the node status using the status.

Node maintenance

Node database requires cleansing from time to time (we advise once a week), to do so please perform following steps as root:

  1. Stop validator process (Never skip this!)
sudo -s
systemctl stop validator.service
  1. Remove old logs
find /var/ton-work -name 'LOG.old*' -exec rm {} +
  1. Remove temp files
rm -r /var/ton-work/db/files/packages/temp.archive.*
  1. Start validator process
systemctl start validator.service

Troubleshooting and backups

If for some reason something does not work / breaks you can always roll back to @archstate snapshot on your ZFS filesystem, this is the original state from dump.

  1. Stop validator process (Never skip this!)
sudo -s
systemctl stop validator.service
  1. Check the snapshot name
zfs list -t snapshot
  1. Rollback to the snapshot
zfs rollback data/ton-work@dumpstate

If your Node works well then you can remove this snapshot to save storage space, but we do recommend to regularly snapshot your filesystem for rollback purposes because validator node has been known to corrupt data as well as config.json in some cases. zfsnap is a nice tool to automate snapshot rotation.

Need help?

Have question or need help? Please ask in the TON dev chat to get help from the community. MyTonCtrl developers also hang out there.

Tips & Tricks

Force archive node not to store blocks

To force node not to store archive blocks use the value 86400. Check set_node_argument section for more.

installer set_node_argument --archive-ttl 86400

Support

Contact technical support with @mytonctrl_help.

See Also