/contrib.freeton.validator-docker

TON Blockchain Node inside Docker

Primary LanguageShellGNU General Public License v2.0GPL-2.0

Docker Build Status Docker Image Size (latest by date) Docker Pulls Docker Image Version (latest by date) Docker Image Info Ton Blockchain Commit Ref

Free TON Validator

TON (Telegram Open Network) use the principle «Proof of Stake». This requires the use of masternodes. Third-party developers (validators) are owners of Masternodes.

This image was made especially for launch Free TON Network.

Quick Reference

Quick Start

  1. Docker Host check list:

    • - Empty directory for global configuration, let's say /ton/etc
    • - Empty directory for TON database, let's say /ton/db

    According recommendations you need 1000 GB (prefer SSD) for the database directory.

  2. Fetch latest version of the image

    docker pull cexiolabs/freeton-validator
  3. Start a container

    docker run --name freeton-validator --interactive --tty --network host --mount type=bind,source=/ton/etc,target=/etc/ton --mount type=bind,source=/ton/db,target=/var/ton cexiolabs/freeton-validator

    On first launch the container will enter into setup mode, due your directories /ton/etc and /ton/db are empty. Let answer for a few questions:

    • Choose template of global.config.json (NOTE! devnet is die yet)
    • Enter your public IP address (v4 only right now)
    • Enter ADNL port

    Setup script will create minimal configuration for choosen network and generate id keys.

    See Advanced Usage section to make this job by hand.

    Expected result:

    Directories /etc/ton and /var/ton are empty. Looks like this is a first launch. Entering setup mode...
    
    Please select template of global.config.json. See section 'Global configuration of the TON Blockchain' of the https://test.ton.org/FullNode-HOWTO.txt
    
    		freeton-devnet
    		freeton-mainnet
    		freeton-testnet
    
    Enter template file name [freeton-testnet]: 
    		/usr/local/share/ton/freeton-testnet-global.config.json -> /etc/ton/global.config.json
    
    Enter your external IPv4 address for this TON node [X.X.X.X]: 
    
    Enter ADNL port [30310]: 
    
    Launching validator-engine to generate instance configuration...
    [ 3][t 1][1589413681.457912922][validator-engine.cpp:1160][!validator-engine]   no init block in config. using zero state
    [ 1][t 1][1589413681.465116262][validator-engine.cpp:1445][!validator-engine]   created config file '/var/ton/config.json'
    [ 1][t 1][1589413681.465180159][validator-engine.cpp:1446][!validator-engine]   check it manually before continue
    
    Generating keys for server, liteserver and client(validator-engine-console)...
    
    Starting Validator Engine...
    [ 3][t 1][1589413681.505045414][validator-engine.cpp:1160][!validator-engine]   no init block in config. using zero state
    [ 3][t 1][1589413681.536607504][manager.cpp:1429][!manager]     failed to load blocks from import dir: [PosixError : No such file or directory : 2 : File "/var/ton/import" can't be opened for reading]
    [ 3][t 4][1589413681.584379911][manager-init.cpp:35][!reiniter] init_block_id=[ w=-1 s=9223372036854775808 seq=0 ...
    ...
    
  4. Check status

    NOTE: Validator Engine need some time to start synchronization. Be patient :)

    docker exec --interactive --tty freeton-validator validator-engine-console --address 127.0.0.1:3030 --key /etc/ton/keys/client --pub /etc/ton/keys/server.pub -c "getstats" -c "quit"

    Expected result:

    connecting to [127.0.0.1:3030]
    local key: C4BD31198D39F6214A6505BC00BC6192158256C91F172B44BEFBF0299E74C7E4
    remote key: 2A10CE7EE52139109E186F9588851CCA3FED05F7A574EBD7E7AB49D62DF56863
    conn ready
    unixtime			1589469708
    

What the image includes

/
├── BANNER
└── usr
    └── local
        ├── bin
        │   ├── docker-entrypoint.sh
        │   ├── generate-random-id
        │   ├── validator-engine
        │   └── validator-engine-console
        └── share
            └── ton
                ├── freeton-devnet-global.config.json
                ├── freeton-mainnet-global.config.json
                └── freeton-testnet-global.config.json

Advanced usage

Build own image (performance)

It is possible to improve node perfomance if you build an image for your CPU (instead x86-64) by providing TON_ARCH build argument. See GCC Options and choose correct one value cpu-type. If you hard to determine correct cpu-type just use native.

git clone https://github.com/cexiolabs/contrib.freeton.validator-docker.git freeton-validator-docker
cd freeton-validator-docker
docker build --tag cexiolabs/freeton-validator --build-arg TON_ARCH=native --file docker/alpine/Dockerfile .

Build variables (pass as --build-arg):

Variable Default value Description
TON_ARCH x86-64 See GCC Options for cpu-type
BUILD_THREADS 2 Positive integer
BUILD_TYPE Release Release or RelWithDebInfo. See notes for -DCMAKE_BUILD_TYPE

Use utils

The image includes ton-blockchain/ton utils like generate-random-id. You may use it just pass as arguments, like:

docker run --rm cexiolabs/freeton-validator generate-random-id --mode keys