Skip to content

Commit c5a1234

Browse files
committed
Merge remote-tracking branch 'origin/testnet' into testnet
2 parents 7a465f4 + ce58805 commit c5a1234

Some content is hidden

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

53 files changed

+1148
-261
lines changed

Changelog.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
## 2024.12 Update
2+
3+
1. FunC 0.4.6: Fix in try/catch handling, fixing pure flag for functions stored in variables
4+
2. Merging parts of Accelerator: support of specific shard monitoring, archive/liteserver slice format, support for partial liteservers, proxy liteserver, on-demand neighbour queue loading
5+
3. Fix of asynchronous cell loading
6+
4. Various improvements: caching certificates checks, better block overloading detection, `_malloc` in emulator
7+
5. Introduction of telemetry in overlays
8+
6. Use non-null local-id for tonlib-LS interaction - mitigates MitM attack.
9+
7. Adding `SECP256K1_XONLY_PUBKEY_TWEAK_ADD`, `SETCONTCTRMANY` instructions to TVM (activated by `Config8.version >= 9`)
10+
8. Private keys export via validator-engine-console - required for better backups
11+
9. Fix proof checking in tonlib, `hash` in `raw.Message` in tonlib_api
12+
13+
Besides the work of the core team, this update is based on the efforts of OtterSec and LayerZero (FunC), tg:@throwunless (FunC), Aviv Frenkel and Dima Kogan from Fordefi (LS MitM), @hacker-volodya (Tonlib), OKX team (async cell loading), @krigga (emulator)
14+
115
## 2024.10 Update
216

317
1. Parallel write to celldb: substantial improvement of sync and GC speed, especially with slow disks.

create-hardfork/create-hardfork.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,10 @@ class HardforkCreator : public td::actor::Actor {
272272
void download_archive(ton::BlockSeqno masterchain_seqno, ton::ShardIdFull shard_prefix, std::string tmp_dir,
273273
td::Timestamp timeout, td::Promise<std::string> promise) override {
274274
}
275+
void download_out_msg_queue_proof(
276+
ton::ShardIdFull dst_shard, std::vector<ton::BlockIdExt> blocks, block::ImportedMsgQueueLimits limits,
277+
td::Timestamp timeout, td::Promise<std::vector<td::Ref<ton::validator::OutMsgQueueProof>>> promise) override {
278+
}
275279

276280
void new_key_block(ton::validator::BlockHandle handle) override {
277281
}

crypto/block/block.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,12 @@ bool EnqueuedMsgDescr::check_key(td::ConstBitPtr key) const {
660660
hash_ == key + 96;
661661
}
662662

663+
bool ImportedMsgQueueLimits::deserialize(vm::CellSlice& cs) {
664+
return cs.fetch_ulong(8) == 0xd3 // imported_msg_queue_limits#d3
665+
&& cs.fetch_uint_to(32, max_bytes) // max_bytes:#
666+
&& cs.fetch_uint_to(32, max_msgs); // max_msgs:#
667+
}
668+
663669
bool ParamLimits::deserialize(vm::CellSlice& cs) {
664670
return cs.fetch_ulong(8) == 0xc3 // param_limits#c3
665671
&& cs.fetch_uint_to(32, limits_[0]) // underload:uint32

crypto/block/block.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,16 @@ static inline std::ostream& operator<<(std::ostream& os, const MsgProcessedUptoC
216216
return proc_coll.print(os);
217217
}
218218

219+
struct ImportedMsgQueueLimits {
220+
// Default values
221+
td::uint32 max_bytes = 1 << 16;
222+
td::uint32 max_msgs = 30;
223+
bool deserialize(vm::CellSlice& cs);
224+
ImportedMsgQueueLimits operator*(td::uint32 x) const {
225+
return {max_bytes * x, max_msgs * x};
226+
}
227+
};
228+
219229
struct ParamLimits {
220230
enum { limits_cnt = 4 };
221231
enum { cl_underload = 0, cl_normal = 1, cl_soft = 2, cl_medium = 3, cl_hard = 4 };

crypto/common/bitstring.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -554,11 +554,7 @@ class BitArray {
554554
set_same(0);
555555
}
556556
void set_zero_s() {
557-
volatile uint8* p = data();
558-
auto x = m;
559-
while (x--) {
560-
*p++ = 0;
561-
}
557+
as_slice().fill_zero_secure();
562558
}
563559
void set_ones() {
564560
set_same(1);

crypto/vm/db/DynamicBagOfCellsDb.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,16 @@ class DynamicBagOfCellsDbImpl : public DynamicBagOfCellsDb, private ExtCellCreat
111111
}
112112
void load_cell_async(td::Slice hash, std::shared_ptr<AsyncExecutor> executor,
113113
td::Promise<Ref<DataCell>> promise) override {
114+
auto promise_ptr = std::make_shared<td::Promise<Ref<DataCell>>>(std::move(promise));
114115
auto info = hash_table_.get_if_exists(hash);
115116
if (info && info->sync_with_db) {
116-
TRY_RESULT_PROMISE(promise, loaded_cell, info->cell->load_cell());
117-
promise.set_result(loaded_cell.data_cell);
117+
executor->execute_async([promise = std::move(promise_ptr), cell = info->cell]() mutable {
118+
TRY_RESULT_PROMISE((*promise), loaded_cell, cell->load_cell());
119+
promise->set_result(loaded_cell.data_cell);
120+
});
118121
return;
119122
}
120123
SimpleExtCellCreator ext_cell_creator(cell_db_reader_);
121-
auto promise_ptr = std::make_shared<td::Promise<Ref<DataCell>>>(std::move(promise));
122124
executor->execute_async(
123125
[executor, loader = *loader_, hash = CellHash::from_slice(hash), db = this,
124126
ext_cell_creator = std::move(ext_cell_creator), promise = std::move(promise_ptr)]() mutable {

emulator/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ endif()
4747
if (USE_EMSCRIPTEN)
4848
add_executable(emulator-emscripten ${EMULATOR_EMSCRIPTEN_SOURCE})
4949
target_link_libraries(emulator-emscripten PUBLIC emulator)
50-
target_link_options(emulator-emscripten PRIVATE -sEXPORTED_RUNTIME_METHODS=_malloc,free,UTF8ToString,stringToUTF8,allocate,ALLOC_NORMAL,lengthBytesUTF8)
51-
target_link_options(emulator-emscripten PRIVATE -sEXPORTED_FUNCTIONS=_emulate,_free,_run_get_method,_create_emulator,_destroy_emulator,_emulate_with_emulator,_version)
50+
target_link_options(emulator-emscripten PRIVATE -sEXPORTED_RUNTIME_METHODS=UTF8ToString,stringToUTF8,allocate,ALLOC_NORMAL,lengthBytesUTF8)
51+
target_link_options(emulator-emscripten PRIVATE -sEXPORTED_FUNCTIONS=_emulate,_free,_malloc,_run_get_method,_create_emulator,_destroy_emulator,_emulate_with_emulator,_version)
5252
target_link_options(emulator-emscripten PRIVATE -sEXPORT_NAME=EmulatorModule)
5353
target_link_options(emulator-emscripten PRIVATE -sERROR_ON_UNDEFINED_SYMBOLS=0)
5454
target_link_options(emulator-emscripten PRIVATE -Oz)

keyring/keyring.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace ton {
2828
namespace keyring {
2929

3030
KeyringImpl::PrivateKeyDescr::PrivateKeyDescr(PrivateKey private_key, bool is_temp)
31-
: public_key(private_key.compute_public_key()), is_temp(is_temp) {
31+
: public_key(private_key.compute_public_key()), private_key(private_key), is_temp(is_temp) {
3232
auto D = private_key.create_decryptor_async();
3333
D.ensure();
3434
decryptor_sign = D.move_as_ok();
@@ -190,6 +190,16 @@ void KeyringImpl::decrypt_message(PublicKeyHash key_hash, td::BufferSlice data,
190190
}
191191
}
192192

193+
void KeyringImpl::export_all_private_keys(td::Promise<std::vector<PrivateKey>> promise) {
194+
std::vector<PrivateKey> keys;
195+
for (auto& [_, descr] : map_) {
196+
if (!descr->is_temp && descr->private_key.exportable()) {
197+
keys.push_back(descr->private_key);
198+
}
199+
}
200+
promise.set_value(std::move(keys));
201+
}
202+
193203
td::actor::ActorOwn<Keyring> Keyring::create(std::string db_root) {
194204
return td::actor::create_actor<KeyringImpl>("keyring", db_root);
195205
}

keyring/keyring.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class Keyring : public td::actor::Actor {
4444

4545
virtual void decrypt_message(PublicKeyHash key_hash, td::BufferSlice data, td::Promise<td::BufferSlice> promise) = 0;
4646

47+
virtual void export_all_private_keys(td::Promise<std::vector<PrivateKey>> promise) = 0;
48+
4749
static td::actor::ActorOwn<Keyring> create(std::string db_root);
4850
};
4951

keyring/keyring.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class KeyringImpl : public Keyring {
3333
td::actor::ActorOwn<DecryptorAsync> decryptor_sign;
3434
td::actor::ActorOwn<DecryptorAsync> decryptor_decrypt;
3535
PublicKey public_key;
36+
PrivateKey private_key;
3637
bool is_temp;
3738
PrivateKeyDescr(PrivateKey private_key, bool is_temp);
3839
};
@@ -56,6 +57,8 @@ class KeyringImpl : public Keyring {
5657

5758
void decrypt_message(PublicKeyHash key_hash, td::BufferSlice data, td::Promise<td::BufferSlice> promise) override;
5859

60+
void export_all_private_keys(td::Promise<std::vector<PrivateKey>> promise) override;
61+
5962
KeyringImpl(std::string db_root) : db_root_(db_root) {
6063
}
6164

0 commit comments

Comments
 (0)