Skip to main content

Liteserver node

info

Before reading this article, please refer to the section on Full node for more information.

When an endpoint is activated in a full node, that node becomes a liteserver. This type of node can handle and respond to requests from the lite-client, facilitating smooth interaction with the TON Blockchain.

Hardware requirements

Running a liteserver mode requires fewer resources than a validator, but it is still recommended that you use a powerful machine:

  • minimum of 16-core CPU
  • minimum of 128 GB RAM
  • at least 1 TB NVMe SSD or provisioned storage with 64,000+ IOPS
  • 1 Gbps network connectivity
  • 16 TB of traffic per month during peak load
  • fixed public IP address

Feel free to use the cloud providers listed in the recommended providers section.

Hetzner and OVH are not allowed to run a validator, but you can use them to run a liteserver:

  • Hetzner: EX101, AX102
  • OVH: RISE-4

Installation of liteserver

If you don't have MyTonCtrl, install it using the -m liteserver flag.

wget https://raw.githubusercontent.com/ton-blockchain/mytonctrl/master/scripts/install.sh
sudo bash ./install.sh -m liteserver
  • -d: The MyTonCtrl command will download a dump of the latest blockchain state, significantly reducing synchronization time.
  • -c <path>: This option allows you to use private liteservers for synchronization. (This option is not required.)
  • -i: Use this flag to ignore minimum requirements. It should only be used if you want to check the compilation process without utilizing a real node.
  • -m: This specifies the mode and can be set to either validator or liteserver.

To use the Testnet, you must provide the -c flag with the value https://ton.org/testnet-global.config.json. The default value for the -c flag is https://ton-blockchain.github.io/global.config.json, which refers to the mainnet configuration.

If you already have MyTonCtrl installed, run:

user@system:~# mytonctrl
MyTonCtrl> enable_mode liteserver

Check the firewall settings

Firstly, check the liteserver port specified in your /var/ton-work/db/config.json file. This port may vary with each new installation of MyTonCtrl and can be found in the port field.

{
...
"liteservers": [
{
"ip": 1605600994,
"port": LITESERVER_PORT
...
}
]
}

If you use a cloud provider, open this port in the firewall settings. For instance, if you are using AWS, you should open the port in the security group.

Here is an example of how to open a port in the firewall of a bare metal server:

Opening a port in the firewall

We will use the ufw utility (see the cheatsheet). However, feel free to use any alternative that you prefer.

  1. If ufw is not already installed, install it:
sudo apt update
sudo apt install ufw
  1. Enable SSH connections:
sudo ufw allow ssh
  1. Ensure that you allow the port indicated in the config.json file:
sudo ufw allow <port>
  1. Enable the firewall:
sudo ufw enable
  1. Check the firewall status:
sudo ufw status

To do this, you can open the port in your server's firewall settings.

Interaction with liteserver (lite-client)

  1. Create a new project directory on your machine and place the config.json file in it. You can obtain this configuration by running the following command:
installer clcf # in mytonctrl

It will create a file at /usr/bin/ton/local.config.json on your machine where MyTonCtrl is installed. Check the MyTonCtrl documentation for more information.

  1. Install libraries.
npm i --save ton-core ton-lite-client
  1. Initialize and request MasterChain information to confirm that the liteserver is running properly.

Update the project type to module in your package.json file.

{
"type": "module"
}

Create a file named index.js and include the following content:

import { LiteSingleEngine } from 'ton-lite-client/dist/engines/single.js'
import { LiteRoundRobinEngine } from 'ton-lite-client/dist/engines/roundRobin.js'
import { Lite } from 'ton-lite-client/dist/.js'
import config from './config.json' assert {type: 'json'};


function intToIP(int ) {
var part1 = int & 255;
var part2 = ((int >> 8) & 255);
var part3 = ((int >> 16) & 255);
var part4 = ((int >> 24) & 255);

return part4 + "." + part3 + "." + part2 + "." + part1;
}

let server = config.liteservers[0];

async function main() {
const engines = [];
engines.push(new LiteSingleEngine({
host: `tcp://${intToIP(server.ip)}:${server.port}`,
publicKey: Buffer.from(server.id.key, 'base64'),
}));

const engine = new LiteRoundRobinEngine(engines);
const = new Lite({ engine });
const master = await .getMasterchainInfo()
console.log('master', master)

}

main()

  1. You can now interact with your own liteserver.

See also