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.


Introduction


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 fift, lite-client, and validator-engine-console. It was created to facilitate the management of wallets, domains, and a validator on the Linux operating system.

Read more


Prerequisites


Start by updating packages and restarting the machine.


sudo apt-get update
sudo apt-get upgrade
sudo reboot

Installation


Download installation script:


wget https://raw.githubusercontent.com/igroman787/mytonctrl/master/scripts/install.sh

Running validator


There are two modes to run the installation script: lite and full. We will use the latter because it will configure and run the validator for us.


sudo bash install.sh -m full

Accessing validator


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:


  1. Mytoncore status becomes green.
  2. Local validator status becomes green.
  3. 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:


  1. Check your local wallets: wl.


    You must see one named validator_wallet_001. The status of the wallet is uninit which means it is not activated yet.


  2. 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 status output.


  3. Activate the validator wallet: aw validator_wallet_001.

Now everything is ready for the validator to work.


Read more


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 status output.


Validation Lifecycle
Image source: https://t.me/TONBaseChat/735.


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.


FAQ


  1. How to uninstall mytonctrl?


    sudo bash /usr/src/mytonctrl/scripts/uninstall.sh

  2. How to restart the validator?


    systemctl restart validator

  3. How to stop the validator?


    systemctl stop validator

  4. Where can I find compiled validator components?


    /usr/bin/ton/


  5. Where can I find files related to the validator's work?


    /var/ton-work/


  6. Where can I find the validator configuration?


    /var/ton-work/db/config.json


  7. Where are the logs of mytoncore?


    /usr/local/bin/mytoncore/


  8. Where are the logs of mytonctrl?


    /usr/local/bin/mytonctrl/


  9. What are the minimal requirements for a validator in the mainnet?


    Currently, 16 cores, 64G RAM, 512G SSD, 1Gbit/s internet connectivity.


    https://ton.org/docs/#/howto/validator?id=validator


  10. What is the maximum number of validators?


    Currently, 1000. You can view current validators at https://tonmon.xyz.


  11. 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.


  12. Where can I find the private key and address of my wallets?


    /usr/local/bin/mytoncore/wallets/


    You can use .addr and .pk files to access your wallet from lite-client.


  13. 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:


    1. Open /etc/systemd/system/validator.service.
    2. Add --archive-ttl 864000 into the ExecStart command.
    3. systemctl daemon-reload
    4. 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***.



Read more


Conclusion


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.

Комментарии (0)