The The Open Network (TON) is a fast, secure and scalable blockchain and network project, capable of handling millions of transactions per second.
It was originally introduced by Telegram and called Telegram Open Network. Unfortunately, in May 2020, they announced the closure of the project due to the US court decision. Right after that, three different organizations announced their intentions to continue work on the blockchain: TON Labs, NewTON (TON Foundation), and the Chinese TON community.
In early August, the Telegram team transferred the original repository on GitHub, as well as the ton.org domain, to the open developer community of the TON Foundation.
You can read more about it here.
In this tutorial, you will learn how to set up & run a TON validator using mytonctrl on Ubuntu. Note that, it is only dedicated to validators on the NewTON (TON Foundation) blockchain.
mytonctrl is a console program. It is a wrapper over
validator-engine-console. It was created to facilitate the management of wallets, domains, and a validator on the Linux operating system.
Start by updating packages and restarting the machine.
sudo apt-get update sudo apt-get upgrade sudo reboot
Download installation script:
There are two modes to run the installation script:
full. We will use the latter because it will configure and run the validator for us.
sudo bash install.sh -m full
After the installation script finishes, you can access the validator by typing
mytonctrl. To read about available commands in mytonctrl type
help. For our needs, you will need to check
status. Your validator will be ready when:
- Mytoncore status becomes green.
- Local validator status becomes green.
- Local validator out of sync value becomes less than 10-20. This would mean that validator is synchronized. Note that it might take some time.
Once your validator is ready:
Check your local wallets:
You must see one named validator_wallet_001. The status of the wallet is uninit which means it is not activated yet.
Send some coins to the validator wallet.
Make sure to type the wallet address correctly. Send a small amount first just to verify. Note that our validator wallet must have at least the amount of the minimum stake plus one coin. You can check what is the minimum stake in the
Activate the validator wallet:
Now everything is ready for the validator to work.
How does a validator work
After completing the steps above your validator is ready to work. Below is a validation lifecycle scheme. You can find each part’s actual duration and start, end timestamps in the
Image source: Telegram: Contact @TONBaseChat.
First, mytoncore will split the validator’s wallet balance into two parts. Once elections start it will put one part as a stake to participate in it. If your validator was elected, then it will participate in the next validation session. Note that the next validation session will not start right after the elections.
During the validation session, you will see in the
status that your validator’s index is greater than -1. You can also check its efficiency. Also, new elections will start during this session. That is why your validator used only half of the wallet’s balance to participate in the previous elections. Now it will use the remaining half and do the same.
You won’t be able to get your stake and possible bonus after the validation session ends. That amount will be on hold and retrieved only when new elections start. So it means that you will be able to get back your stake only at the second election.
Let’s take an example. Let’s assume that elections last 7h. The validation duration is 18h. The stake hold period is 9h. And elections start right in the middle of the validation session (after 9h since the session start). This means that starting from the second election you will get your stake and possible bonus every 18h: 7h + 2h + 9h.
- 7h — elections duration.
- 2h — duration between the end of elections and the beginning of the next validation session.
- 9h — duration between the start of the validation session and the beginning of the next elections.
Note that you can manually configure your stake, e.g.
set stake 300000. This will configure your stake to be always 300000 toncoins. If you have a little more than 300000 toncoins, then you will get your stake and bonuses back every 36h by the example above. That is because after putting your first stake you will not have enough toncoins for the next elections.
- How to uninstall mytonctrl?
sudo bash /usr/src/mytonctrl/scripts/uninstall.sh
- How to restart the validator?
systemctl restart validator
- How to stop the validator?
systemctl stop validator
Where can I find compiled validator components?
Where can I find files related to the validator’s work?
Where can I find the validator configuration?
Where are the logs of mytoncore?
Where are the logs of mytonctrl?
What are the minimal requirements for a validator in the mainnet?
Currently, 16 cores, 64G RAM, 512G SSD, 1Gbit/s internet connectivity.
The Open Network Docs
What is the maximum number of validators?
Currently, 1000. You can view current validators at https://tonmon.xyz.
How to send toncoins from mytonctrl?
The TON network has error protection. For example, if we send coins to a non-existent wallet, they return with a transaction fee deducted.
The same happens if the wallet is not activated since there is no such wallet for the network yet.
To send coins to an activated wallet use:
mg <wallet_name> <dest_wallet_addr> <amount>
To send coins to a wallet that is not activated, you need to set a special no_bouncable flag:
mg <wallet_name> <dest_wallet_addr> <amount> -n
In native wallets, this flag is set by default and if you send coins to a non-existent wallet, coins will not be returned. Make sure that the dest_wallet_addr is correct, otherwise, you will lose your coins.
Where can I find the private key and address of my wallets?
You can use .addr and .pk files to access your wallet from lite-client.
How to limit the disk space of DB?
You can limit the archive duration, e.g. you can set to store archive files only from the last 10 days:
--archive-ttl 864000into the
systemctl restart validator
But remember that the size of the DB is determined by two factors: time (TTL) and the number of blocks created during this time. So if the number of blocks is big enough, then the size of the DB will increase accordingly.
You can also manually delete older archive files from /var/ton-work/db/archive. They are named arch0***.
These instructions do not cover all of the aspects of the TON validator. If you have any questions feel free to ask them in The Open Network Chat.
Article carried from：How to setup TON (The Open Network) validator / Хабр