Skip to content

Commit 91b5fd5

Browse files
committed
Merge branch 'staging' into redirect-script
2 parents 964f453 + 4dab143 commit 91b5fd5

File tree

19 files changed

+274
-202
lines changed

19 files changed

+274
-202
lines changed

docs/develop/network/overlay.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Overlay subnetworks
22

3+
Implementation:
4+
* https://github.com/ton-blockchain/ton/tree/master/overlay
5+
6+
## Overview
7+
38
The architecture of TON is built in such a way that a lot of chains can exist simultaneously and independently in it - they can be both private or public.
49
Nodes have the ability to choose which shards and chains they store and process.
510
At the same time, the communication protocol remains unchanged due to its universality. Protocols such as DHT, RLDP and Overlays allow this to be achieved.
@@ -11,6 +16,21 @@ All chains in TON, including the masterchain, communicate using their own overla
1116
To join it, you need to find the nodes that are already in it, and start exchanging data with them.
1217
For the public overlays you can find nodes using DHT.
1318

19+
## ADNL vs Overlay networks
20+
21+
In contrast to ADNL, the TON overlay networks usually do not support
22+
sending datagrams to other arbitrary nodes. Instead, some “semi-permanent
23+
links” are established between certain nodes (called “neighbors” with respect to
24+
the overlay network under consideration) and messages are usually forwarded
25+
along these links (i.e. from a node to one of its neighbors).
26+
27+
Each overlay subnetwork has a 256-bit network identifier usually equal
28+
to a SHA256 of the description of the overlay network—a TL-serialized object.
29+
30+
Overlay subnetworks can be public or private.
31+
32+
Overlay subnetworks work according to a special [gossip](https://en.wikipedia.org/wiki/Gossip_protocol) protocol.
33+
1434
## Interaction with overlay nodes
1535

1636
We have already analyzed an example with finding overlay nodes in an article about DHT,
@@ -70,4 +90,4 @@ Thus, we can receive information directly from the nodes.
7090

7191
## References
7292

73-
_Here a [link to the original article](https://github.com/xssnick/ton-deep-doc/blob/master/Overlay-Network.md) by [Oleg Baranov](https://github.com/xssnick)._
93+
_Here a [link to the original article](https://github.com/xssnick/ton-deep-doc/blob/master/Overlay-Network.md) by [Oleg Baranov](https://github.com/xssnick)._

docs/develop/network/rldp.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# RLDP
22

3+
Implementation:
4+
* https://github.com/ton-blockchain/ton/tree/master/rldp
5+
* https://github.com/ton-blockchain/ton/tree/master/rldp2
6+
* https://github.com/ton-blockchain/ton/tree/master/rldp-http-proxy
7+
8+
## Overview
9+
310
RLDP - Reliable Large Datagram Protocol - is a protocol that runs on top of ADNL UDP, which is used to transfer large data blocks and
411
includes Forward Error Correction (FEC) algorithms as a replacement of acknowledgment packets on the other side.
512
This makes it possible to transfer data between network components more efficiently, but with more traffic consumption.
@@ -179,4 +186,4 @@ If `last` = true, then we have reached the end, we can put all the pieces togeth
179186

180187
## References
181188

182-
_Here a [link to the original article](https://github.com/xssnick/ton-deep-doc/blob/master/RLDP.md) by [Oleg Baranov](https://github.com/xssnick)._
189+
_Here a [link to the original article](https://github.com/xssnick/ton-deep-doc/blob/master/RLDP.md) by [Oleg Baranov](https://github.com/xssnick)._

docs/develop/smart-contracts/tutorials/wallet.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2105,7 +2105,7 @@ When working with many messages in a short period, there is a need for special w
21052105

21062106
:::note
21072107
We will work [with a slightly modified version of Wrapper](https://github.com/aSpite/highload-wallet-contract-v3/blob/main/wrappers/HighloadWalletV3.ts) for the contract, as it protects against some non-obvious mistakes.
2108-
:::note
2108+
:::
21092109

21102110

21112111
### Storage Structure

docs/learn/networking/overlay-subnetworks.md

Lines changed: 0 additions & 33 deletions
This file was deleted.

docs/learn/networking/overview.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,9 @@ The TON Project uses its own peer-to-peer network protocols.
1919
blockchain itself, thus providing more possibilities and flexibility for creating
2020
new services in the TON Ecosystem.
2121

22+
## See Also
23+
24+
* [ADNL Protocol](/learn/networking/adnl)
25+
* [Overlay Subnetworks](/learn/networking/overlay-subnetworks)
26+
* [RLDP Protocol](/learn/networking/rldp)
27+
* [TON DHT Service](/learn/networking/ton-dht)

docs/learn/networking/rldp.md

Lines changed: 0 additions & 17 deletions
This file was deleted.

docs/learn/overviews/addresses.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Smart Contract Addresses
1+
# Smart Contract Addresses Documentation
22

33
This section will describe the specifics of smart contract addresses on TON Blockchain. It will also explain how actors are synonymous with smart contracts on TON.
44

docs/participate/wallets/apps.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Player from '@site/src/components/player'
22

3-
# Wallet Apps (for Devs)
3+
# Wallet Apps
44

55
## Overview
66

docs/participate/wallets/contracts.md

Lines changed: 2 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -101,64 +101,9 @@ Sometimes the functionality of basic wallets isn't enough. That's why there are
101101

102102
Let's have a look at them.
103103

104-
### Highload Wallet v3
104+
### Highload Wallets
105105

106-
This wallet is made for who need to send transactions at very high rates. For example, crypto exchanges.
107-
108-
- [Source code](https://github.com/ton-blockchain/highload-wallet-contract-v3)
109-
110-
Any given external message (transfer request) to a highload v3 contains:
111-
- a signature (512 bits) in the top level cell - the other parameters are in the ref of that cell
112-
- subwallet ID (32 bits)
113-
- message to send as a ref (the serialized internal message that will be sent)
114-
- send mode for the message (8 bits)
115-
- composite query ID - 13 bits of "shift" and 10 bits of "bit number", however the 10 bits of bit number can only go up to 1022, not 1023, and also the last such usable query ID (8388605) is reserved for emergencies and should not be normally used
116-
- created at, or message timestamp
117-
- timeout
118-
119-
Timeout is stored in highload as a parameter and is checked against the timeout in all requests - so the timeout for all requests is equal. The message should be not older than timeout at the time of arrival to the highload wallet, or in code it is required that `created_at > now() - timeout`. Query IDs are stored for the purposes of replay protection for at least timeout and possibly up to 2 * timeout, however one should not expect them to be stored for longer than timeout. Subwallet ID is checked against the one stored in the wallet. Inner ref's hash is checked along with the signature against the public key of the wallet.
120-
121-
Highload v3 can only send 1 message from any given external message, however it can send that message to itself with a special op code, allowing one to set any action cell on that internal message invocation, effectively making it possible to send up to 254 messages per 1 external message (possibly more if another message is sent to highload wallet again among these 254).
122-
123-
Highload v3 will always store the query ID (replay protection) once all the checks pass, however a message may not be sent due to some conditions, including but not limited to:
124-
- **containing state init** (such messages, if required, may be sent using the special op code to set the action cell after an internal message from highload wallet to itself)
125-
- not enough balance
126-
- invalid message structure (that includes external out messages - only internal messages may be sent straight from the external message)
127-
128-
Highload v3 will never execute multiple externals containing the same `query_id` **and** `created_at` - by the time it forgets any given `query_id`, the `created_at` condition will prevent such a message from executing. This effectively makes `query_id` **and** `created_at` together the "primary key" of a transfer request for highload v3.
129-
130-
When iterating (incrementing) query ID, it is cheaper (in terms of TON spent on fees) to iterate through bit number first, and then the shift, like when incrementing a regular number. After you've reached the last query ID (remember about the emergency query ID - see above), you can reset query ID to 0, but if highload's timeout period has not passed yet, then the replay protection dictionary will be full and you will have to wait for the timeout period to pass.
131-
132-
133-
### Highload wallet v2
134-
135-
:::danger
136-
Legacy contract, it is suggest to use High-load wallet v3.
137-
:::
138-
139-
This wallet is made for those who need to send hundreds of transactions in a short period of time. For example, crypto exchanges.
140-
141-
It allows you to send up to `254` transactions in one smart contract call. It also uses a slightly different approach to solve replay attacks instead of seqno, so you can call this wallet several times at once to send even thousands of transactions in a second.
142-
143-
:::caution Limitations
144-
Note, when dealing with highload-wallet the following limits need to be checked and taken into account.
145-
:::
146-
147-
1. **Storage size limit.** Currently, size of contract storage should be less than 65535 cells. If size of
148-
old_queries will grow above this limit, exception in ActionPhase will be thrown and transaction will fail.
149-
Failed transaction may be replayed.
150-
2. **Gas limit.** Currently, gas limit is 1'000'000 GAS units, that means that there is a limit of how much
151-
old queries may be cleaned in one tx. If number of expired queries will be higher, contract will stuck.
152-
153-
That means that it is not recommended to set too high expiration date:
154-
number of queries during expiration time span should not exceed 1000.
155-
156-
Also, number of expired queries cleaned in one transaction should be below 100.
157-
158-
159-
160-
Wallet source code:
161-
* [ton/crypto/smartcont/highload-wallet-v2-code.fc](https://github.com/ton-blockchain/ton/blob/master/crypto/smartcont/highload-wallet-v2-code.fc)
106+
When working with many messages in a short period, there is a need for special wallet called Highload Wallet. Read [the article](/participate/wallets/highload) for more information.
162107

163108
### Lockup wallet
164109

docs/participate/wallets/highload.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Highload Wallet
2+
3+
When working with many messages in a short period, there is a need for special wallet called Highload Wallet. Highload Wallet V2 was the main wallet on TON for a long time, but you had to be very careful with it. Otherwise, you could [lock all funds](https://t.me/tonstatus/88).
4+
5+
[With the advent of Highload Wallet V3](https://github.com/ton-blockchain/Highload-wallet-contract-v3), this problem has been solved at the contract architecture level and consumes less gas. This chapter will cover the basics of Highload Wallet V3 and important nuances to remember.
6+
7+
## Highload Wallet v3
8+
9+
This wallet is made for who need to send transactions at very high rates. For example, crypto exchanges.
10+
11+
- [Source code](https://github.com/ton-blockchain/Highload-wallet-contract-v3)
12+
13+
Any given external message (transfer request) to a Highload v3 contains:
14+
- a signature (512 bits) in the top level cell - the other parameters are in the ref of that cell
15+
- subwallet ID (32 bits)
16+
- message to send as a ref (the serialized internal message that will be sent)
17+
- send mode for the message (8 bits)
18+
- composite query ID - 13 bits of "shift" and 10 bits of "bit number", however the 10 bits of bit number can only go up to 1022, not 1023, and also the last such usable query ID (8388605) is reserved for emergencies and should not be normally used
19+
- created at, or message timestamp
20+
- timeout
21+
22+
Timeout is stored in Highload as a parameter and is checked against the timeout in all requests - so the timeout for all requests is equal. The message should be not older than timeout at the time of arrival to the Highload wallet, or in code it is required that `created_at > now() - timeout`. Query IDs are stored for the purposes of replay protection for at least timeout and possibly up to 2 * timeout, however one should not expect them to be stored for longer than timeout. Subwallet ID is checked against the one stored in the wallet. Inner ref's hash is checked along with the signature against the public key of the wallet.
23+
24+
Highload v3 can only send 1 message from any given external message, however it can send that message to itself with a special op code, allowing one to set any action cell on that internal message invocation, effectively making it possible to send up to 254 messages per 1 external message (possibly more if another message is sent to Highload wallet again among these 254).
25+
26+
Highload v3 will always store the query ID (replay protection) once all the checks pass, however a message may not be sent due to some conditions, including but not limited to:
27+
- **containing state init** (such messages, if required, may be sent using the special op code to set the action cell after an internal message from Highload wallet to itself)
28+
- not enough balance
29+
- invalid message structure (that includes external out messages - only internal messages may be sent straight from the external message)
30+
31+
Highload v3 will never execute multiple externals containing the same `query_id` **and** `created_at` - by the time it forgets any given `query_id`, the `created_at` condition will prevent such a message from executing. This effectively makes `query_id` **and** `created_at` together the "primary key" of a transfer request for Highload v3.
32+
33+
When iterating (incrementing) query ID, it is cheaper (in terms of TON spent on fees) to iterate through bit number first, and then the shift, like when incrementing a regular number. After you've reached the last query ID (remember about the emergency query ID - see above), you can reset query ID to 0, but if Highload's timeout period has not passed yet, then the replay protection dictionary will be full and you will have to wait for the timeout period to pass.
34+
35+
36+
## Highload wallet v2
37+
38+
:::danger
39+
Legacy contract, it is suggest to use Highload wallet v3.
40+
:::
41+
42+
This wallet is made for those who need to send hundreds of transactions in a short period of time. For example, crypto exchanges.
43+
44+
It allows you to send up to `254` transactions in one smart contract call. It also uses a slightly different approach to solve replay attacks instead of seqno, so you can call this wallet several times at once to send even thousands of transactions in a second.
45+
46+
:::caution Limitations
47+
Note, when dealing with Highload wallet the following limits need to be checked and taken into account.
48+
:::
49+
50+
1. **Storage size limit.** Currently, size of contract storage should be less than 65535 cells. If size of
51+
old_queries will grow above this limit, exception in ActionPhase will be thrown and transaction will fail.
52+
Failed transaction may be replayed.
53+
2. **Gas limit.** Currently, gas limit is 1'000'000 GAS units, that means that there is a limit of how much
54+
old queries may be cleaned in one tx. If number of expired queries will be higher, contract will stuck.
55+
56+
That means that it is not recommended to set too high expiration date:
57+
number of queries during expiration time span should not exceed 1000.
58+
59+
Also, number of expired queries cleaned in one transaction should be below 100.
60+
61+
62+
63+
Wallet source code:
64+
* [ton/crypto/smartcont/Highload-wallet-v2-code.fc](https://github.com/ton-blockchain/ton/blob/master/crypto/smartcont/Highload-wallet-v2-code.fc)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Overview: Sharding and Split Merge in the TON Blockchain
2+
3+
[//]: # (TODO, this is from gpt)
4+
5+
The TON Blockchain employs advanced sharding mechanisms to enhance scalability and performance, allowing it to efficiently process a massive number of transactions.
6+
The core concept is splitting the blockchain into smaller, independent pieces called **shards**. These shards can handle transactions in parallel, ensuring high throughput even as the network grows.
7+
8+
In TON, sharding is highly dynamic. Unlike other blockchains, which have a fixed number of shards, TON can create new shards on demand.
9+
As the transaction load increases, shards split, and as the load decreases, they merge.
10+
This flexibility ensures that the system can adapt to varying workloads while maintaining efficiency.
11+
12+
The **Masterchain** plays a crucial role, maintaining the network configuration and the final state of all **workchains** and **shardchains**.
13+
While the masterchain is responsible for overall coordination, **workchains** operate under their specific rules, each of which can be split further into shardchains.
14+
Currently, only one workchain (the **Basechain**) operates on TON.
15+
16+
At the heart of TON's efficiency is the **Infinity Sharding Paradigm**, which treats each account as part of its own "accountchain."
17+
These accountchains are then aggregated into shardchain blocks, facilitating efficient transaction processing.
18+
19+
In addition to the dynamic creation of shards, TON uses **Split Merge** functionality, which allows the network to efficiently respond to changing transaction loads. This system enhances scalability and interaction within the blockchain network, exemplifying TON's approach to resolving common blockchain challenges with a focus on efficiency and global consistency.
20+
21+
22+
## See Also
23+
24+
* [Shards Dive In](/develop/blockchain/shards)
25+
* [# Infinity Sharding Paradigm](/develop/blockchain/sharding-lifecycle)

0 commit comments

Comments
 (0)