bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 16쪽 중 1쪽
The Open Network
based on the work of Dr. Nikolai Durov
July 26, 2021
Abstract
The aim of this text is to provide a rst description of the The Open
Network (TON) and related blockchain, peer-to-peer, distributed stor-
age and service hosting technologies. To reduce the size of this doc-
ument to reasonable proportions, we focus mainly on the unique and
dening features of the TON platform that are important for it to
achieve its stated goals.
Introduction
The The Open Network (TON) is a fast, secure and scalable blockchain and
network project, capable of handling millions of transactions per second if
necessary, and both user-friendly and service provider-friendly. We aim for
it to be able to host all reasonable applications currently proposed and con-
ceived. One might think about TON as a huge distributed supercomputer,
or rather a huge superserver, intended to host and provide a variety of
services.
This text is not intended to be the ultimate reference with respect to
all implementation details. Some particulars are likely to change during the
development and testing phases.
1
Introduction
Contents
1 Brief Description of TON Components 3
2 TON Blockchain 5
2.1 TON Blockchain as a Collection of 2-Blockchains . . . . . . . 5
2.2 Generalities on Blockchains . . . . . . . . . . . . . . . . . . . 15
2.3 Blockchain State, Accounts and Hashmaps . . . . . . . . . . . 19
2.4 Messages Between Shardchains . . . . . . . . . . . . . . . . . 29
2.5 Global Shardchain State. Bag of Cells Philosophy. . . . . . . 38
2.6 Creating and Validating New Blocks . . . . . . . . . . . . . . 44
2.7 Splitting and Merging Shardchains . . . . . . . . . . . . . . . 57
2.8 Classication of Blockchain Projects . . . . . . . . . . . . . . 61
2.9 Comparison to Other Blockchain Projects . . . . . . . . . . . 74
3 TON Networking 80
3.1 Abstract Datagram Network Layer . . . . . . . . . . . . . . . 80
3.2 TON DHT: Kademlia-like Distributed Hash Table . . . . . . . 84
3.3 Overlay Networks and Multicasting Messages . . . . . . . . . 90
4 TON Services and Applications 98
4.1 TON Service Implementation Strategies . . . . . . . . . . . . 98
4.2 Connecting Users and Service Providers . . . . . . . . . . . . . 102
4.3 Accessing TON Services . . . . . . . . . . . . . . . . . . . . . 104
5 TON Payments 111
5.1 Payment Channels . . . . . . . . . . . . . . . . . . . . . . . . 111
5.2 Payment Channel Network, or Lightning Network . . . . . . 118
Conclusion 122
A The TON Coin 125
2
Chapter 1. Brief Description of TON Components
1 Brief Description of TON Components
The The Open Network (TON) is a combination of the following components:
A exible multi-blockchain platform ( TON Blockchain ; cf. Chapter 2 ),
capable of processing millions of transactions per second, with Turing-
complete smart contracts, upgradable formal blockchain specications,
multi-cryptocurrency value transfer, support for micropayment chan-
nels and o-chain payment networks. TON Blockchain presents some
new and unique features, such as the self-healing vertical blockchain
mechanism (cf. 2.1.17 ) and Instant Hypercube Routing (cf. 2.4.20 ),
which enable it to be fast, reliable, scalable and self-consistent at the
same time.
A peer-to-peer network ( TON P2P Network , or just TON Network ; cf.
Chapter 3 ), used for accessing the TON Blockchain, sending transac-
tion candidates, and receiving updates about only those parts of the
blockchain a client is interested in (e.g., those related to the client's
accounts and smart contracts), but also able to support arbitrary dis-
tributed services, blockchain-related or not.
A distributed le storage technology (TON Storage; cf. 4.1.7 ), acces-
sible through TON Network , used by the TON Blockchain to store
archive copies of blocks and status data (snapshots), but also avail-
able for storing arbitrary les for users or other services running on the
platform, with torrent-like access technology.
A network proxy/anonymizer layer (TON Proxy; cf. 4.1.10 and 3.1.6 ),
similar to the I 2P (Invisible Internet Project), used to hide the iden-
tity and IP addresses of TON Network nodes if necessary (e.g., nodes
committing transactions from accounts with large amounts of cryp-
tocurrency, or high-stake blockchain validator nodes who wish to hide
their exact IP address and geographical location as a measure against
DDoS attacks).
A Kademlia-like distributed hash table ( TON DHT ; cf. 3.2 ), used as
a torrent tracker for TON Storage (cf. 3.2.10 ), as an input tunnel
locator for TON Proxy (cf. 3.2.14 ), and as a service locator for TON
Services (cf. 3.2.12 ).
3
Chapter 1. Brief Description of TON Components
A platform for arbitrary services ( TON Services ; cf. Chapter 4 ), re-
siding in and available through TON Network and TON Proxy , with
formalized interfaces (cf. 4.3.14 ) enabling browser-like or smartphone
application interaction. These formal interfaces and persistent service
entry points can be published in the TON Blockchain (cf. 4.3.17 ); ac-
tual nodes providing service at any given moment can be looked up
through the TON DHT starting from information published in the
TON Blockchain (cf. 3.2.12 ). Services may create smart contracts in
the TON Blockchain to oer some guarantees to their clients (cf. 4.1.6 ).
TON DNS (cf. 4.3.1 ), a service for assigning human-readable names
to accounts, smart contracts, services and network nodes.
TON Payments (cf. Chapter 5 ), a platform for micropayments, micro-
payment channels and a micropayment channel network. It can be used
for fast o-chain value transfers, and for paying for services powered
by TON Services .
TON will allow easy integration with third-party messaging and so-
cial networking applications, thus making blockchain technologies and
distributed services nally available and accessible to ordinary users
(cf. 4.3.23 ), rather than just to a handful of early cryptocurrency
adopters.
While the TON Blockchain is the core of the TON project, and the
other components might be considered as playing a supportive role for the
blockchain, they turn out to have useful and interesting functionality by
themselves. Combined, they allow the platform to host more versatile ap-
plications than it would be possible by just using the TON Blockchain
(cf. 2.9.13 and 4.1 ).
4
2.1. TON Blockchain as a Collection of 2-Blockchains
2 TON Blockchain
We start with a description of the The Open Network (TON) Blockchain,
the core component of the project. Our approach here is top-down: we give
a general description of the whole rst, and then provide more detail on each
component.
For simplicity, we speak here about the TON Blockchain, even though
in principle several instances of this blockchain protocol may be running
independently (for example, as a result of hard forks). We consider only one
of them.
2.1 TON Blockchain as a Collection of 2-Blockchains
The TON Blockchain is actually a collection of blockchains (even a collection
of blockchains of blockchains , or 2-blockchains this point will be claried
later in 2.1.17 ), because no single blockchain project is capable of achieving
our goal of processing millions of transactions per second, as opposed to the
now-standard dozens of transactions per second.
2.1.1. List of blockchain types. The blockchains in this collection are:
The unique master blockchain , or masterchain for short, containing
general information about the protocol and the current values of its
parameters, the set of validators and their stakes, the set of currently
active workchains and their shards, and, most importantly, the set of
hashes of the most recent blocks of all workchains and shardchains.
Several (up to 232) working blockchains , or workchains for short, which
are actually the workhorses, containing the value-transfer and smart-
contract transactions. Dierent workchains may have dierent rules,
meaning dierent formats of account addresses, dierent formats of
transactions, dierent virtual machines (VMs) for smart contracts, dif-
ferent basic cryptocurrencies and so on. However, they all must satisfy
certain basic interoperability criteria to make interaction between dif-
ferent workchains possible and relatively simple. In this respect, the
TON Blockchain is heterogeneous (cf. 2.8.8 ), similarly to the EOS
(cf. 2.9.7 ) and PolkaDot (cf. 2.9.8 ) projects.
Each workchain is in turn subdivided into up to 260 shard blockchains ,
or shardchains for short, having the same rules and block format as
5
2.1. TON Blockchain as a Collection of 2-Blockchains
the workchain itself, but responsible only for a subset of accounts, de-
pending on several rst (most signicant) bits of the account address.
In other words, a form of sharding is built into the system (cf. 2.8.12 ).
Because all these shardchains share a common block format and rules,
the TON Blockchain is homogeneous in this respect (cf. 2.8.8 ), simi-
larly to what has been discussed in one of Ethereum scaling proposals. 1
Each block in a shardchain (and in the masterchain) is actually not just
a block, but a small blockchain. Normally, this block blockchain or
vertical blockchain consists of exactly one block, and then we might
think this is just the corresponding block of the shardchain (also called
horizontal blockchain in this situation). However, if it becomes nec-
essary to x incorrect shardchain blocks, a new block is committed into
the vertical blockchain, containing either the replacement for the in-
valid horizontal blockchain block, or a block dierence, containing
only a description of those parts of the previous version of this block
that need to be changed. This is a TON-specic mechanism to replace
detected invalid blocks without making a true fork of all shardchains
involved; it will be explained in more detail in 2.1.17 . For now, we
just remark that each shardchain (and the masterchain) is not a con-
ventional blockchain, but a blockchain of blockchains , or 2D-blockchain ,
or just a 2-blockchain .
2.1.2. Innite Sharding Paradigm. Almost all blockchain sharding pro-
posals are top-down: one rst imagines a single blockchain, and then dis-
cusses how to split it into several interacting shardchains to improve perfor-
mance and achieve scalability.
The TON approach to sharding is bottom-up, explained as follows.
Imagine that sharding has been taken to its extreme, so that exactly one
account or smart contract remains in each shardchain. Then we have a huge
number of account-chains, each describing the state and state transitions
of only one account, and sending value-bearing messages to each other to
transfer value and information.
Of course, it is impractical to have hundreds of millions of blockchains,
with updates (i.e., new blocks) usually appearing quite rarely in each of
them. In order to implement them more eciently, we group these account-
chains into shardchains, so that each block of the shardchain is essentially a
1 https://github.com/ethereum/wiki/wiki/Sharding-FAQ
6
2.1. TON Blockchain as a Collection of 2-Blockchains
collection of blocks of account-chains that have been assigned to this shard.
Thus the account-chains have only a purely virtual or logical existence
inside the shardchains.
We call this perspective the Innite Sharding Paradigm . It explains many
of the design decisions for the TON Blockchain.
2.1.3. Messages. Instant Hypercube Routing. The Innite Sharding
Paradigm instructs us to regard each account (or smart contract) as if it
were in its own shardchain by itself. Then the only way one account might
aect the state of another is by sending a message to it (this is a special
instance of the so-called Actor model, with accounts as Actors; cf. 2.4.2 ).
Therefore, a system of messages between accounts (and shardchains, because
the source and destination accounts are, generally speaking, located in dif-
ferent shardchains) is of paramount importance to a scalable system such as
the TON Blockchain. In fact, a novel feature of the TON Blockchain, called
Instant Hypercube Routing (cf. 2.4.20 ), enables it to deliver and process a
message created in a block of one shardchain into the very next block of the
destination shardchain, regardless of the total number of shardchains in the
system.
2.1.4. Quantity of masterchains, workchains and shardchains. A
TON Blockchain contains exactly one masterchain. However, the system
can potentially accommodate up to 232 workchains, each subdivided into up
to 260 shardchains.
2.1.5. Workchains can be virtual blockchains, not true blockchains.
Because a workchain is usually subdivided into shardchains, the existence of
the workchain is virtual, meaning that it is not a true blockchain in the
sense of the general denition provided in 2.2.1 below, but just a collection
of shardchains. When only one shardchain corresponds to a workchain, this
unique shardchain may be identied with the workchain, which in this case
becomes a true blockchain, at least for some time, thus gaining a super-
cial similarity to customary single-blockchain design. However, the Innite
Sharding Paradigm (cf. 2.1.2 ) tells us that this similarity is indeed super-
cial: it is just a coincidence that the potentially huge number of account-
chains can temporarily be grouped into one blockchain.
2.1.6. Identication of workchains. Each workchain is identied by its
number or workchain identier ( workchain_id : uint 32), which is simply an
7
2.1. TON Blockchain as a Collection of 2-Blockchains
unsigned 32-bit integer. Workchains are created by special transactions in
the masterchain, dening the (previously unused) workchain identier and
the formal description of the workchain, sucient at least for the interaction
of this workchain with other workchains and for supercial verication of this
workchain's blocks.
2.1.7. Creation and activation of new workchains. The creation of a
new workchain may be initiated by essentially any member of the community,
ready to pay the (high) masterchain transaction fees required to publish the
formal specication of a new workchain. However, in order for the new
workchain to become active, a two-thirds consensus of validators is required,
because they will need to upgrade their software to process blocks of the new
workchain, and signal their readiness to work with the new workchain by
special masterchain transactions. The party interested in the activation of
the new workchain might provide some incentive for the validators to support
the new workchain by means of some rewards distributed by a smart contract.
2.1.8. Identication of shardchains. Each shardchain is identied by a
couple (w,s ) = ( workchain_id , shard_prex ), where workchain_id : uint 32
identies the corresponding workchain, and shard_prex : 20...60 is a bit
string of length at most 60, dening the subset of accounts for which this
shardchain is responsible. Namely, all accounts with account_id starting
with shard_prex (i.e., having shard_prex as most signicant bits) will be
assigned to this shardchain.
2.1.9. Identication of account-chains. Recall that account-chains have
only a virtual existence (cf. 2.1.2 ). However, they have a natural identier
namely, (workchain_id , account_id )because any account-chain contains
information about the state and updates of exactly one account (either a
simple account or smart contractthe distinction is unimportant here).
2.1.10. Dynamic splitting and merging of shardchains; cf. 2.7. A
less sophisticated system might use static sharding for example, by using
the top eight bits of the account_id to select one of 256 pre-dened shards.
An important feature of the TON Blockchain is that it implements dy-
namic sharding , meaning that the number of shards is not xed. Instead,
shard (w,s ) can be automatically subdivided into shards (w,s. 0) and (w,s. 1)
if some formal conditions are met (essentially, if the transaction load on the
original shard is high enough for a prolonged period of time). Conversely,
8
2.1. TON Blockchain as a Collection of 2-Blockchains
if the load stays too low for some period of time, the shards (w,s. 0) and
(w,s. 1) can be automatically merged back into shard (w,s ).
Initially, only one shard (w,∅) is created for workchain w. Later, it is
subdivided into more shards, if and when this becomes necessary (cf. 2.7.6
and 2.7.8 ).
2.1.11. Basic workchain or Workchain Zero. While up to 232 workchains
can be dened with their specic rules and transactions, we initially dene
only one, with workchain_id = 0. This workchain, called Workchain Zero or
the basic workchain, is the one used to work with TON smart contracts and
transfer TON coins (cf. Appendix A). Most applications are likely to require
only Workchain Zero. Shardchains of the basic workchain will be called basic
shardchains .
2.1.12. Block generation intervals. We expect a new block to be gener-
ated in each shardchain and the masterchain approximately once every ve
seconds. This will lead to reasonably small transaction conrmation times.
New blocks of all shardchains are generated approximately simultaneously;
a new block of the masterchain is generated approximately one second later,
because it must contain the hashes of the latest blocks of all shardchains.
2.1.13. Using the masterchain to make workchains and shardchains
tightly coupled. Once the hash of a block of a shardchain is incorporated
into a block of the masterchain, that shardchain block and all its ancestors
are considered canonical, meaning that they can be referenced from the sub-
sequent blocks of all shardchains as something xed and immutable. In fact,
each new shardchain block contains a hash of the most recent masterchain
block, and all shardchain blocks referenced from that masterchain block are
considered immutable by the new block.
Essentially, this means that a transaction or a message committed in a
shardchain block may be safely used in the very next blocks of the other
shardchains, without needing to wait for, say, twenty conrmations (i.e.,
twenty blocks generated after the original block in the same blockchain) be-
fore forwarding a message or taking other actions based on a previous trans-
action, as is common in most proposed loosely-coupled systems (cf. 2.8.14 ),
such as EOS. This ability to use transactions and messages in other shard-
chains a mere ve seconds after being committed is one of the reasons we
believe our tightly-coupled system, the rst of its kind, will be able to
deliver unprecedented performance (cf. 2.8.12 and 2.8.14 ).
9
2.1. TON Blockchain as a Collection of 2-Blockchains
2.1.14. Masterchain block hash as a global state. According to 2.1.13 ,
the hash of the last masterchain block completely determines the overall state
of the system from the perspective of an external observer. One does not need
to monitor the state of all shardchains separately.
2.1.15. Generation of new blocks by validators; cf. 2.6. The TON
Blockchain uses a Proof-of-Stake (PoS) approach for generating new blocks in
the shardchains and the masterchain. This means that there is a set of, say,
up to a few hundred validators special nodes that have deposited stakes
(large amounts of TON coins) by a special masterchain transaction to be
eligible for new block generation and validation.
Then a smaller subset of validators is assigned to each shard (w,s ) in a
deterministic pseudorandom way, changing approximately every 1024 blocks.
This subset of validators suggests and reaches consensus on what the next
shardchain block would be, by collecting suitable proposed transactions from
the clients into new valid block candidates. For each block, there is a pseudo-
randomly chosen order on the validators to determine whose block candidate
has the highest priority to be committed at each turn.
Validators and other nodes check the validity of the proposed block candi-
dates; if a validator signs an invalid block candidate, it may 프로젝트로 돌아가기