mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Improve handling outbound message queues (#825)
* Improve handling outbound message queues * Cleanup queue faster * Calculate queue sizes in background * Force or limit split/merge depending on queue size * Increase validate_ref limit for transaction * Add all changes of public libraries to block size estimation * Don't crash on timeout in GC * Don't import external messages when queue is too big --------- Co-authored-by: SpyCheese <mikle98@yandex.ru>
This commit is contained in:
parent
3a595ce849
commit
5e6b67ae96
16 changed files with 727 additions and 111 deletions
|
@ -2536,6 +2536,31 @@ static td::uint32 get_public_libraries_count(const td::Ref<vm::Cell>& libraries)
|
|||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the number of changes of public libraries in the dictionary.
|
||||
*
|
||||
* @param old_libraries The dictionary of account libraries before the transaction.
|
||||
* @param new_libraries The dictionary of account libraries after the transaction.
|
||||
*
|
||||
* @returns The number of changed public libraries.
|
||||
*/
|
||||
static td::uint32 get_public_libraries_diff_count(const td::Ref<vm::Cell>& old_libraries,
|
||||
const td::Ref<vm::Cell>& new_libraries) {
|
||||
td::uint32 count = 0;
|
||||
vm::Dictionary dict1{old_libraries, 256};
|
||||
vm::Dictionary dict2{new_libraries, 256};
|
||||
dict1.scan_diff(dict2, [&](td::ConstBitPtr key, int n, Ref<vm::CellSlice> val1, Ref<vm::CellSlice> val2) -> bool {
|
||||
CHECK(n == 256);
|
||||
bool is_public1 = val1.not_null() && block::is_public_library(key, val1);
|
||||
bool is_public2 = val2.not_null() && block::is_public_library(key, val2);
|
||||
if (is_public1 != is_public2) {
|
||||
++count;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the new account state fits in the limits.
|
||||
* This function is not called for special accounts.
|
||||
|
@ -2979,14 +3004,14 @@ bool Transaction::serialize() {
|
|||
vm::load_cell_slice(root).print_rec(std::cerr);
|
||||
}
|
||||
|
||||
if (!block::gen::t_Transaction.validate_ref(root)) {
|
||||
if (!block::gen::t_Transaction.validate_ref(4096, root)) {
|
||||
LOG(ERROR) << "newly-generated transaction failed to pass automated validation:";
|
||||
vm::load_cell_slice(root).print_rec(std::cerr);
|
||||
block::gen::t_Transaction.print_ref(std::cerr, root);
|
||||
root.clear();
|
||||
return false;
|
||||
}
|
||||
if (!block::tlb::t_Transaction.validate_ref(root)) {
|
||||
if (!block::tlb::t_Transaction.validate_ref(4096, root)) {
|
||||
LOG(ERROR) << "newly-generated transaction failed to pass hand-written validation:";
|
||||
vm::load_cell_slice(root).print_rec(std::cerr);
|
||||
block::gen::t_Transaction.print_ref(std::cerr, root);
|
||||
|
@ -3187,8 +3212,12 @@ bool Transaction::update_limits(block::BlockLimitStatus& blimst, bool with_size)
|
|||
blimst.add_account(is_first))) {
|
||||
return false;
|
||||
}
|
||||
if (account.is_masterchain() && (was_frozen || was_deleted)) {
|
||||
blimst.extra_library_diff += get_public_libraries_count(account.orig_library);
|
||||
if (account.is_masterchain()) {
|
||||
if (was_frozen || was_deleted) {
|
||||
blimst.public_library_diff += get_public_libraries_count(account.orig_library);
|
||||
} else {
|
||||
blimst.public_library_diff += get_public_libraries_diff_count(account.orig_library, new_library);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue