Trust Levels

For trustless communication with Liteservers there are "Proofs" in TON. The trust_level argument in LiteClient constructor defines how do you trust the Liteserver you communicate with.

  1. trust_level = 2

You should use this value when you fully trust the Liteserver, i.e. it's yours. Then the lib won't check any proofs it recieves, and the speed of processing requests will be twice as fast.

  1. trust_level = 1

You should use this value when you do not trust the Liteserver, but you don't want to wait for the client to synchronize (it takes about 1 minute on the first run) and lose out on speed. Then the lib will check all proofs it recieves but won't synchronize and store keyblocks and check block hashes.

Here is the doc page where proofs verifying explained in detailes. For example, ton-kotlin by default check only such proofs.

  1. trust_level = 0

You should use this value when you do not trust the Liteserver, but you want to fully trust any data you recieve from it. Then, first time you run client the lib will prove block link from init_block to last masterchain block and prove hash of every block it receives from ls. Also it will check all data it receive (like it does with trust_level = 1). After first time run it will create directory .blockstore and store there last key block and last mc block it trusts. For the next runs it will take just seconds to synchronize from last block it stored if the block's persistent state has not been expired. Otherwise it will start sync from the init_block again. By default it stores key blocks with ttl at least 3 weeks, so if you run the client at least once in 3 weeks it won't synchronize blocks from the init one again.

Last updated