Skip to content

Commit 56c0ac3

Browse files
authored
Merge pull request #1727 from ton-blockchain/testnet
Merge developer branch
2 parents 72056a2 + 75a75eb commit 56c0ac3

File tree

157 files changed

+4268
-4227
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+4268
-4227
lines changed

.github/workflows/build-ton-linux-x86-64-appimage.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ jobs:
2121
- name: Install system libraries
2222
run: |
2323
sudo apt update
24-
sudo apt install -y build-essential git cmake ninja-build zlib1g-dev libsecp256k1-dev libmicrohttpd-dev libsodium-dev liblz4-dev ccache
25-
sudo apt remove libgsl-dev
24+
sudo apt install -y build-essential git cmake ninja-build zlib1g-dev libsecp256k1-dev libmicrohttpd-dev libsodium-dev liblz4-dev ccache libgsl-dev libblas-dev
2625
mkdir ~/.ccache 3pp
2726
2827
- name: Install clang-16

.github/workflows/ton-x86-64-windows.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ defaults:
99
jobs:
1010
build:
1111

12-
runs-on: windows-2019
12+
runs-on: windows-2022
1313

1414
steps:
1515
- name: Get Current OS version
@@ -30,15 +30,15 @@ jobs:
3030
uses: actions/cache@v4
3131
with:
3232
path: third_libs
33-
key: ${{ runner.os }}-${{ runner.arch }}-windows-2019-3pp-${{ hashFiles('**/assembly/native/build-windows-2019.bat') }}
33+
key: ${{ runner.os }}-${{ runner.arch }}-windows-2022-3pp-${{ hashFiles('**/assembly/native/build-windows-2022.bat') }}
3434

3535
- name: Build TON
3636
run: |
3737
git submodule sync --recursive
3838
git submodule update
39-
copy assembly\native\build-windows-github-2019.bat .
40-
copy assembly\native\build-windows-2019.bat .
41-
build-windows-github-2019.bat Enterprise
39+
copy assembly\native\build-windows-github-2022.bat .
40+
copy assembly\native\build-windows-2022.bat .
41+
build-windows-github-2022.bat Enterprise
4242
ccache -sp
4343
4444
# - name: Run Tests

CMakeLists.txt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ set(CMAKE_CXX_STANDARD 20)
3333
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
3434
set(CMAKE_CXX_EXTENSIONS FALSE)
3535

36+
set(CMAKE_COLOR_DIAGNOSTICS TRUE)
37+
3638
#BEGIN internal
3739
option(BUILD_SHARED_LIBS "Use \"ON\" to build shared libraries instead of static where it's not specified (not recommended)" OFF)
3840
option(USE_EMSCRIPTEN "Use \"ON\" for config building wasm." OFF)
@@ -56,6 +58,16 @@ option(TON_USE_TSAN "Use \"ON\" to enable ThreadSanitizer." OFF)
5658
option(TON_USE_UBSAN "Use \"ON\" to enable UndefinedBehaviorSanitizer." OFF)
5759
set(TON_ARCH "native" CACHE STRING "Architecture, will be passed to -march=")
5860

61+
option(TON_PRINT_BACKTRACE_ON_CRASH "Attempt to print a backtrace when a fatal signal is caught" ON)
62+
63+
option(TON_USE_LLD "Use LLD for linking" OFF)
64+
65+
if (TON_USE_LLD)
66+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld")
67+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=lld")
68+
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fuse-ld=lld")
69+
endif()
70+
5971
#BEGIN M1 support
6072
EXECUTE_PROCESS( COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE ARCHITECTURE )
6173

@@ -181,7 +193,7 @@ endif()
181193
if (TON_ARCH AND NOT MSVC)
182194
CHECK_CXX_COMPILER_FLAG( "-march=${TON_ARCH}" COMPILER_OPT_ARCH_SUPPORTED )
183195
if (TON_ARCH STREQUAL "apple-m1")
184-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=${TON_ARCH}")
196+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=${TON_ARCH}")
185197
elseif(COMPILER_OPT_ARCH_SUPPORTED)
186198
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=${TON_ARCH}")
187199
elseif(NOT TON_ARCH STREQUAL "native")
@@ -534,7 +546,6 @@ endif()
534546
enable_testing()
535547
set(TEST_OPTIONS "--regression ${CMAKE_CURRENT_SOURCE_DIR}/test/regression-tests.ans --filter -Bench")
536548
separate_arguments(TEST_OPTIONS)
537-
add_test(test-ed25519-crypto crypto/test-ed25519-crypto)
538549
add_test(test-ed25519 test-ed25519)
539550
add_test(test-bigint test-bigint)
540551
add_test(test-vm test-vm ${TEST_OPTIONS})

Changelog.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## 2025.06 Update
2+
3+
1. ADNL and candidate broadcast optimization
4+
2. [TVM version v11](./doc/GlobalVersions.md): new opcodes, and `c7` entry to improve developer experience. It also activates storage stats and `ihr_fee` nullification.
5+
3. Fixed `start_lt` of tick transactions [see details on 01.06.2025 incident](https://telegra.ph/Report-on-June-1-2025-Operation-Incident-06-02).
6+
4. Introduction of persistent state sharding, as well as making serialization of large BOCs more deterministic
7+
5. Emulator improvements: in get methods, set config from provided `c7`; allow retrieval of logs from emulator runs for get methods
8+
6. Optimized package import for archive nodes
9+
10+
Besides the work of the core team, this update is based on the efforts of the RSquad team (deterministic large BOC serialization); AArayz, wy666444, Robinlzw, Lucian-code233 from TonBit (early discovery of the TVM 11 bug); @Skydev0h (uninitialized `BLOCKLT` in get methods); and @yma-het from TONWhales (emulator improvements).
11+
12+
113
## 2025.04 Update
214

315
1. Introduced substantial improvements of CellDB performance: celldb-v2, bloom filters.
@@ -8,7 +20,7 @@
820
6. [Added normalized hash](https://github.com/ton-blockchain/TEPs/pull/467)
921
7. Fix SDBEGINS(Q) in Asm.fif
1022

11-
Besides the work of the core team, this update is based on the efforts of @Stanislav-Povolotsky (tonlib fixes), @ice-charon (tonlib fixes), RSquad team (due payments improvements in v10), Arayz @ TonBit (improvements in RUNVM), @Skydev0h and @pyAndr3w (Asm.fif).
23+
Besides the work of the core team, this update is based on the efforts of @Stanislav-Povolotsky (tonlib fixes); @ice-charon (tonlib fixes); RSquad team (due payments improvements in v10); Arayz, Robinlzw, @wy666444 @Lucian-code233 from TonBit (improvements in RUNVM); @Skydev0h and @pyAndr3w (Asm.fif).
1224

1325
## 2025.03 Update
1426
1. New extracurrency behavior introduced, check [GlobalVersions.md](./doc/GlobalVersions.md#version-10)

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ RUN mkdir build && \
2929
cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DPORTABLE=1 -DTON_ARCH= -DTON_USE_JEMALLOC=ON .. && \
3030
ninja storage-daemon storage-daemon-cli tonlibjson fift func validator-engine validator-engine-console \
3131
generate-random-id dht-server lite-client tolk rldp-http-proxy dht-server proxy-liteserver create-state \
32-
blockchain-explorer emulator tonlibjson http-proxy adnl-proxy
32+
blockchain-explorer emulator tonlibjson http-proxy adnl-proxy dht-ping-servers dht-resolve
3333

3434
FROM ubuntu:22.04
3535
ARG DEBIAN_FRONTEND=noninteractive
@@ -50,6 +50,8 @@ COPY --from=builder /ton/build/blockchain-explorer/blockchain-explorer /usr/loca
5050
COPY --from=builder /ton/build/crypto/create-state /usr/local/bin/
5151
COPY --from=builder /ton/build/utils/proxy-liteserver /usr/local/bin/
5252
COPY --from=builder /ton/build/dht-server/dht-server /usr/local/bin/
53+
COPY --from=builder /ton/build/dht/dht-ping-servers /usr/local/bin/
54+
COPY --from=builder /ton/build/dht/dht-resolve /usr/local/bin/
5355
COPY --from=builder /ton/build/rldp-http-proxy/rldp-http-proxy /usr/local/bin/
5456
COPY --from=builder /ton/build/http/http-proxy /usr/local/bin/
5557
COPY --from=builder /ton/build/adnl/adnl-proxy /usr/local/bin/

adnl/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ set(ADNL_HEADERS
2323
adnl-peer.h
2424
adnl-peer.hpp
2525
adnl-query.h
26-
adnl-static-nodes.h
27-
adnl-static-nodes.hpp
2826
adnl-proxy-types.h
2927
adnl-proxy-types.hpp
3028
adnl.h
@@ -46,7 +44,6 @@ set(ADNL_SOURCE
4644
adnl-peer.cpp
4745
adnl-query.cpp
4846
adnl-channel.cpp
49-
adnl-static-nodes.cpp
5047
adnl-proxy-types.cpp
5148
utils.cpp
5249
${ADNL_HEADERS}

adnl/adnl-peer-table.cpp

Lines changed: 116 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,42 @@ void AdnlPeerTableImpl::receive_packet(td::IPAddress addr, AdnlCategoryMask cat_
8484
<< " (len=" << (data.size() + 32) << ")";
8585
}
8686

87+
void AdnlPeerTableImpl::update_id(AdnlPeerTableImpl::PeerInfo &peer_info, AdnlNodeIdFull &&peer_id) {
88+
if (peer_info.peer_id.empty()) {
89+
peer_info.peer_id = std::move(peer_id);
90+
for (auto &e: peer_info.peers) {
91+
td::actor::send_closure(e.second, &AdnlPeerPair::update_peer_id, peer_info.peer_id);
92+
}
93+
}
94+
}
95+
96+
td::actor::ActorOwn<AdnlPeerPair> &AdnlPeerTableImpl::get_peer_pair(
97+
AdnlNodeIdShort peer_id, AdnlPeerTableImpl::PeerInfo &peer_info,
98+
AdnlNodeIdShort local_id, AdnlPeerTableImpl::LocalIdInfo &local_id_info) {
99+
auto it = peer_info.peers.find(local_id);
100+
if (it == peer_info.peers.end()) {
101+
it = peer_info.peers.emplace(local_id,
102+
AdnlPeerPair::create(network_manager_, actor_id(this),
103+
local_id_info.mode, local_id_info.local_id.get(),
104+
dht_node_, local_id, peer_id))
105+
.first;
106+
if (!peer_info.peer_id.empty()) {
107+
td::actor::send_closure(it->second, &AdnlPeerPair::update_peer_id, peer_info.peer_id);
108+
}
109+
}
110+
return it->second;
111+
}
112+
87113
void AdnlPeerTableImpl::receive_decrypted_packet(AdnlNodeIdShort dst, AdnlPacket packet, td::uint64 serialized_size) {
88114
packet.run_basic_checks().ensure();
89115

90116
if (!packet.inited_from_short()) {
91117
VLOG(ADNL_INFO) << this << ": dropping IN message [?->" << dst << "]: destination not set";
92118
return;
93119
}
120+
AdnlNodeIdShort src = packet.from_short();
94121

95-
auto it = peers_.find(packet.from_short());
122+
auto it = peers_.find(src);
96123
if (it == peers_.end()) {
97124
if (!packet.inited_from()) {
98125
VLOG(ADNL_NOTICE) << this << ": dropping IN message [" << packet.from_short() << "->" << dst
@@ -105,11 +132,7 @@ void AdnlPeerTableImpl::receive_decrypted_packet(AdnlNodeIdShort dst, AdnlPacket
105132
return;
106133
}
107134

108-
it = peers_
109-
.emplace(packet.from_short(),
110-
AdnlPeer::create(network_manager_, actor_id(this), dht_node_, packet.from_short()))
111-
.first;
112-
CHECK(it != peers_.end());
135+
it = peers_.try_emplace(src).first;
113136
}
114137

115138
auto it2 = local_ids_.find(dst);
@@ -118,8 +141,13 @@ void AdnlPeerTableImpl::receive_decrypted_packet(AdnlNodeIdShort dst, AdnlPacket
118141
<< "]: unknown dst (but how did we decrypt message?)";
119142
return;
120143
}
121-
td::actor::send_closure(it->second, &AdnlPeer::receive_packet, dst, it2->second.mode, it2->second.local_id.get(),
122-
std::move(packet), serialized_size);
144+
145+
if (packet.inited_from()) {
146+
update_id(it->second, packet.from());
147+
}
148+
149+
td::actor::send_closure(get_peer_pair(src, it->second, dst, it2->second),
150+
&AdnlPeerPair::receive_packet, std::move(packet), serialized_size);
123151
}
124152

125153
void AdnlPeerTableImpl::add_peer(AdnlNodeIdShort local_id, AdnlNodeIdFull id, AdnlAddressList addr_list) {
@@ -129,40 +157,36 @@ void AdnlPeerTableImpl::add_peer(AdnlNodeIdShort local_id, AdnlNodeIdFull id, Ad
129157
auto it2 = local_ids_.find(local_id);
130158
CHECK(it2 != local_ids_.end());
131159

132-
auto it = peers_.find(id_short);
133-
if (it == peers_.end()) {
134-
it = peers_.emplace(id_short, AdnlPeer::create(network_manager_, actor_id(this), dht_node_, id_short)).first;
135-
CHECK(it != peers_.end());
136-
}
137-
td::actor::send_closure(it->second, &AdnlPeer::update_id, std::move(id));
160+
auto &peer_info = peers_[id_short];
161+
update_id(peer_info, std::move(id));
138162
if (!addr_list.empty()) {
139-
td::actor::send_closure(it->second, &AdnlPeer::update_addr_list, local_id, it2->second.mode,
140-
it2->second.local_id.get(), std::move(addr_list));
163+
td::actor::send_closure(get_peer_pair(id_short, peer_info, local_id, it2->second),
164+
&AdnlPeerPair::update_addr_list, std::move(addr_list));
141165
}
142166
}
143167

144168
void AdnlPeerTableImpl::add_static_nodes_from_config(AdnlNodesList nodes) {
145-
for (auto &it : nodes.nodes()) {
146-
add_static_node(it);
169+
for (auto &node : nodes.nodes()) {
170+
auto id_short = node.compute_short_id();
171+
VLOG(ADNL_INFO) << "[staticnodes] adding static node " << id_short;
172+
static_nodes_.emplace(id_short, std::move(node));
147173
}
148174
}
149175

150176
void AdnlPeerTableImpl::send_message_in(AdnlNodeIdShort src, AdnlNodeIdShort dst, AdnlMessage message,
151177
td::uint32 flags) {
152-
auto it = peers_.find(dst);
153-
154-
if (it == peers_.end()) {
155-
it = peers_.emplace(dst, AdnlPeer::create(network_manager_, actor_id(this), dht_node_, dst)).first;
156-
}
178+
auto &peer_info = peers_[dst];
157179

158180
auto it2 = local_ids_.find(src);
159181
if (it2 == local_ids_.end()) {
160182
LOG(ERROR) << this << ": dropping OUT message [" << src << "->" << dst << "]: unknown src";
161183
return;
162184
}
163185

164-
td::actor::send_closure(it->second, &AdnlPeer::send_one_message, src, it2->second.mode, it2->second.local_id.get(),
165-
OutboundAdnlMessage{std::move(message), flags});
186+
std::vector<OutboundAdnlMessage> messages;
187+
messages.push_back(OutboundAdnlMessage{std::move(message), flags});
188+
td::actor::send_closure(get_peer_pair(dst, peer_info, src, it2->second),
189+
&AdnlPeerPair::send_messages, std::move(messages));
166190
}
167191

168192
void AdnlPeerTableImpl::answer_query(AdnlNodeIdShort src, AdnlNodeIdShort dst, AdnlQueryId query_id,
@@ -182,20 +206,16 @@ void AdnlPeerTableImpl::send_query(AdnlNodeIdShort src, AdnlNodeIdShort dst, std
182206
VLOG(ADNL_WARNING) << "DUMP: " << td::buffer_to_hex(data.as_slice().truncate(128));
183207
return;
184208
}
185-
auto it = peers_.find(dst);
186-
187-
if (it == peers_.end()) {
188-
it = peers_.emplace(dst, AdnlPeer::create(network_manager_, actor_id(this), dht_node_, dst)).first;
189-
}
209+
auto &peer_info = peers_[dst];
190210

191211
auto it2 = local_ids_.find(src);
192212
if (it2 == local_ids_.end()) {
193213
LOG(ERROR) << this << ": dropping OUT message [" << src << "->" << dst << "]: unknown src";
194214
return;
195215
}
196216

197-
td::actor::send_closure(it->second, &AdnlPeer::send_query, src, it2->second.mode, it2->second.local_id.get(), name,
198-
std::move(promise), timeout, std::move(data), 0);
217+
td::actor::send_closure(get_peer_pair(dst, peer_info, src, it2->second),
218+
&AdnlPeerPair::send_query, name, std::move(promise), timeout, std::move(data), 0);
199219
}
200220

201221
void AdnlPeerTableImpl::add_id_ex(AdnlNodeIdFull id, AdnlAddressList addr_list, td::uint8 cat, td::uint32 mode) {
@@ -247,8 +267,10 @@ void AdnlPeerTableImpl::unsubscribe(AdnlNodeIdShort dst, std::string prefix) {
247267
void AdnlPeerTableImpl::register_dht_node(td::actor::ActorId<dht::Dht> dht_node) {
248268
dht_node_ = dht_node;
249269

250-
for (auto &peer : peers_) {
251-
td::actor::send_closure(peer.second, &AdnlPeer::update_dht_node, dht_node_);
270+
for (auto &e : peers_) {
271+
for (auto &e2 : e.second.peers) {
272+
td::actor::send_closure(e2.second, &AdnlPeerPair::update_dht_node, dht_node_);
273+
}
252274
}
253275
for (auto &local_id : local_ids_) {
254276
td::actor::send_closure(local_id.second.local_id, &AdnlLocalId::update_dht_node, dht_node_);
@@ -332,8 +354,6 @@ void AdnlPeerTableImpl::get_addr_list_from_db(AdnlNodeIdShort local_id, AdnlNode
332354

333355
AdnlPeerTableImpl::AdnlPeerTableImpl(std::string db_root, td::actor::ActorId<keyring::Keyring> keyring) {
334356
keyring_ = keyring;
335-
static_nodes_manager_ = AdnlStaticNodesManager::create();
336-
337357
if (!db_root.empty()) {
338358
db_ = AdnlDb::create(db_root + "/adnl");
339359
}
@@ -382,7 +402,64 @@ void AdnlPeerTableImpl::get_conn_ip_str(AdnlNodeIdShort l_id, AdnlNodeIdShort p_
382402
promise.set_value("undefined");
383403
return;
384404
}
385-
td::actor::send_closure(it->second, &AdnlPeer::get_conn_ip_str, l_id, std::move(promise));
405+
auto it2 = it->second.peers.find(l_id);
406+
if (it2 == it->second.peers.end()) {
407+
promise.set_value("undefined");
408+
return;
409+
}
410+
td::actor::send_closure(it2->second, &AdnlPeerPair::get_conn_ip_str, std::move(promise));
411+
}
412+
413+
void AdnlPeerTableImpl::get_stats_peer(AdnlNodeIdShort peer_id, AdnlPeerTableImpl::PeerInfo &peer_info, bool all,
414+
td::Promise<std::vector<tl_object_ptr<ton_api::adnl_stats_peerPair>>> promise) {
415+
class Cb : public td::actor::Actor {
416+
public:
417+
explicit Cb(td::Promise<std::vector<tl_object_ptr<ton_api::adnl_stats_peerPair>>> promise)
418+
: promise_(std::move(promise)) {
419+
}
420+
421+
void got_peer_pair_stats(tl_object_ptr<ton_api::adnl_stats_peerPair> peer_pair) {
422+
if (peer_pair) {
423+
result_.push_back(std::move(peer_pair));
424+
}
425+
dec_pending();
426+
}
427+
428+
void inc_pending() {
429+
++pending_;
430+
}
431+
432+
void dec_pending() {
433+
CHECK(pending_ > 0);
434+
--pending_;
435+
if (pending_ == 0) {
436+
promise_.set_result(std::move(result_));
437+
stop();
438+
}
439+
}
440+
441+
private:
442+
td::Promise<std::vector<tl_object_ptr<ton_api::adnl_stats_peerPair>>> promise_;
443+
size_t pending_ = 1;
444+
std::vector<tl_object_ptr<ton_api::adnl_stats_peerPair>> result_;
445+
};
446+
auto callback = td::actor::create_actor<Cb>("adnlpeerstats", std::move(promise)).release();
447+
448+
for (auto &[local_id, peer_pair] : peer_info.peers) {
449+
td::actor::send_closure(callback, &Cb::inc_pending);
450+
td::actor::send_closure(peer_pair, &AdnlPeerPair::get_stats, all,
451+
[local_id = local_id, peer_id = peer_id,
452+
callback](td::Result<tl_object_ptr<ton_api::adnl_stats_peerPair>> R) {
453+
if (R.is_error()) {
454+
VLOG(ADNL_NOTICE) << "failed to get stats for peer pair " << peer_id << "->" << local_id
455+
<< " : " << R.move_as_error();
456+
td::actor::send_closure(callback, &Cb::dec_pending);
457+
} else {
458+
td::actor::send_closure(callback, &Cb::got_peer_pair_stats, R.move_as_ok());
459+
}
460+
});
461+
}
462+
td::actor::send_closure(callback, &Cb::dec_pending);
386463
}
387464

388465
void AdnlPeerTableImpl::get_stats(bool all, td::Promise<tl_object_ptr<ton_api::adnl_stats>> promise) {
@@ -453,8 +530,8 @@ void AdnlPeerTableImpl::get_stats(bool all, td::Promise<tl_object_ptr<ton_api::a
453530
}
454531
for (auto &[id, peer] : peers_) {
455532
td::actor::send_closure(callback, &Cb::inc_pending);
456-
td::actor::send_closure(
457-
peer, &AdnlPeer::get_stats, all,
533+
get_stats_peer(
534+
id, peer, all,
458535
[id = id, callback](td::Result<std::vector<tl_object_ptr<ton_api::adnl_stats_peerPair>>> R) {
459536
if (R.is_error()) {
460537
VLOG(ADNL_NOTICE) << "failed to get stats for peer " << id << " : " << R.move_as_error();

0 commit comments

Comments
 (0)