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
- 8TB 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)
Note: 4TB assumes usage of zfs volume with compression enabled
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.
- Install zfs
sudo apt install zfsutils-linux
- Create pool on your dedicated 4TB
<disk>
and name itdata
sudo zpool create data <disk>
- 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
- Before performing a restore, you must stop the validator using root account:
sudo -s
systemctl stop validator.service
- 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
- Request
user
andpassword
credentials to gain access for downloading dumps in the @TONBaseChatEn Telegram chat. - 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
Size of the dump is ~1.5TB, so it will take some time to download and restore it.
Prepare and run the command:
- Install the tools if necessary (
pv
,plzip
) - Replace
<usr>
and<pwd>
with your credentials - Tell
plzip
to use as many cores as your machine allows to speed up extraction (-n
)
Mount the dump
- Mount zfs:
zfs set mountpoint=/var/ton-work data/ton-work && zfs mount data/ton-work
- Restore
db/config.json
,keys
anddb/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
- 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 bevalidator
user:
chown -R validator:validator /var/ton-work/db
- The owner for the
/var/ton-work/keys
dir should beubuntu
user:
chown -R ubuntu:ubuntu /var/ton-work/keys
Update Configuration
Update node configuration for the archive node.
- Open the node config file
/etc/systemd/system/validator.service
nano /etc/systemd/system/validator.service
- 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 your node some time to find other nodes and then sync with them. Depending on the age of the snapshot, your node might take from a few hours to several days to catch up with the network. This is normal.
Start the node
- Start the validator by running the command:
systemctl start validator.service
- Open
mytonctrl
from local user and check the node status using thestatus
.
Node maintenance
Node database requires cleansing from time to time (we advise once a week), to do so please perform following steps as root:
- Stop validator process (Never skip this!)
sudo -s
systemctl stop validator.service
- Remove old logs
find /var/ton-work -name 'LOG.old*' -exec rm {} +
- Remove temp files
rm -r /var/ton-work/db/files/packages/temp.archive.*
- 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.
- Stop validator process (Never skip this!)
sudo -s
systemctl stop validator.service
- Check the snapshot name
zfs list -t snapshot
- 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.
Have question or need help? Please ask in the TON dev chat to get help from the community. MyTonCtrl developers also hang out there.