mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Fix block limit classification (#1337)
Block size estimation can decrease, so it was possible that soft limit was reached, but the block is not considered overloaded
This commit is contained in:
parent
413da6cd20
commit
52b010ff34
2 changed files with 12 additions and 5 deletions
|
@ -180,6 +180,7 @@ class Collator final : public td::actor::Actor {
|
||||||
td::RefInt256 masterchain_create_fee_, basechain_create_fee_;
|
td::RefInt256 masterchain_create_fee_, basechain_create_fee_;
|
||||||
std::unique_ptr<block::BlockLimits> block_limits_;
|
std::unique_ptr<block::BlockLimits> block_limits_;
|
||||||
std::unique_ptr<block::BlockLimitStatus> block_limit_status_;
|
std::unique_ptr<block::BlockLimitStatus> block_limit_status_;
|
||||||
|
int block_limit_class_ = 0;
|
||||||
ton::LogicalTime min_new_msg_lt{std::numeric_limits<td::uint64>::max()};
|
ton::LogicalTime min_new_msg_lt{std::numeric_limits<td::uint64>::max()};
|
||||||
block::CurrencyCollection total_balance_, old_total_balance_, total_validator_fees_;
|
block::CurrencyCollection total_balance_, old_total_balance_, total_validator_fees_;
|
||||||
block::CurrencyCollection global_balance_, old_global_balance_, import_created_{0};
|
block::CurrencyCollection global_balance_, old_global_balance_, import_created_{0};
|
||||||
|
|
|
@ -2333,6 +2333,7 @@ bool Collator::out_msg_queue_cleanup() {
|
||||||
register_out_msg_queue_op();
|
register_out_msg_queue_op();
|
||||||
if (!block_limit_status_->fits(block::ParamLimits::cl_normal)) {
|
if (!block_limit_status_->fits(block::ParamLimits::cl_normal)) {
|
||||||
block_full_ = true;
|
block_full_ = true;
|
||||||
|
block_limit_class_ = std::max(block_limit_class_, block_limit_status_->classify());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return !delivered;
|
return !delivered;
|
||||||
|
@ -2402,6 +2403,7 @@ bool Collator::out_msg_queue_cleanup() {
|
||||||
register_out_msg_queue_op();
|
register_out_msg_queue_op();
|
||||||
if (!block_limit_status_->fits(block::ParamLimits::cl_normal)) {
|
if (!block_limit_status_->fits(block::ParamLimits::cl_normal)) {
|
||||||
block_full_ = true;
|
block_full_ = true;
|
||||||
|
block_limit_class_ = std::max(block_limit_class_, block_limit_status_->classify());
|
||||||
}
|
}
|
||||||
queue.next();
|
queue.next();
|
||||||
++i;
|
++i;
|
||||||
|
@ -3205,6 +3207,7 @@ int Collator::process_one_new_message(block::NewOutMsg msg, bool enqueue_only, R
|
||||||
// 7. check whether the block is full now
|
// 7. check whether the block is full now
|
||||||
if (!block_limit_status_->fits(block::ParamLimits::cl_normal)) {
|
if (!block_limit_status_->fits(block::ParamLimits::cl_normal)) {
|
||||||
block_full_ = true;
|
block_full_ = true;
|
||||||
|
block_limit_class_ = std::max(block_limit_class_, block_limit_status_->classify());
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
if (soft_timeout_.is_in_past(td::Timestamp::now())) {
|
if (soft_timeout_.is_in_past(td::Timestamp::now())) {
|
||||||
|
@ -3568,6 +3571,7 @@ bool Collator::process_inbound_internal_messages() {
|
||||||
block_full_ = !block_limit_status_->fits(block::ParamLimits::cl_normal);
|
block_full_ = !block_limit_status_->fits(block::ParamLimits::cl_normal);
|
||||||
if (block_full_) {
|
if (block_full_) {
|
||||||
LOG(INFO) << "BLOCK FULL, stop processing inbound internal messages";
|
LOG(INFO) << "BLOCK FULL, stop processing inbound internal messages";
|
||||||
|
block_limit_class_ = std::max(block_limit_class_, block_limit_status_->classify());
|
||||||
stats_.limits_log += PSTRING() << "INBOUND_INT_MESSAGES: "
|
stats_.limits_log += PSTRING() << "INBOUND_INT_MESSAGES: "
|
||||||
<< block_full_comment(*block_limit_status_, block::ParamLimits::cl_normal) << "\n";
|
<< block_full_comment(*block_limit_status_, block::ParamLimits::cl_normal) << "\n";
|
||||||
break;
|
break;
|
||||||
|
@ -3659,6 +3663,7 @@ bool Collator::process_inbound_external_messages() {
|
||||||
}
|
}
|
||||||
if (r > 0) {
|
if (r > 0) {
|
||||||
full = !block_limit_status_->fits(block::ParamLimits::cl_soft);
|
full = !block_limit_status_->fits(block::ParamLimits::cl_soft);
|
||||||
|
block_limit_class_ = std::max(block_limit_class_, block_limit_status_->classify());
|
||||||
}
|
}
|
||||||
auto it = ext_msg_map.find(hash);
|
auto it = ext_msg_map.find(hash);
|
||||||
CHECK(it != ext_msg_map.end());
|
CHECK(it != ext_msg_map.end());
|
||||||
|
@ -3761,6 +3766,7 @@ bool Collator::process_dispatch_queue() {
|
||||||
block_full_ = !block_limit_status_->fits(block::ParamLimits::cl_normal);
|
block_full_ = !block_limit_status_->fits(block::ParamLimits::cl_normal);
|
||||||
if (block_full_) {
|
if (block_full_) {
|
||||||
LOG(INFO) << "BLOCK FULL, stop processing dispatch queue";
|
LOG(INFO) << "BLOCK FULL, stop processing dispatch queue";
|
||||||
|
block_limit_class_ = std::max(block_limit_class_, block_limit_status_->classify());
|
||||||
stats_.limits_log += PSTRING() << "DISPATCH_QUEUE_STAGE_" << iter << ": "
|
stats_.limits_log += PSTRING() << "DISPATCH_QUEUE_STAGE_" << iter << ": "
|
||||||
<< block_full_comment(*block_limit_status_, block::ParamLimits::cl_normal)
|
<< block_full_comment(*block_limit_status_, block::ParamLimits::cl_normal)
|
||||||
<< "\n";
|
<< "\n";
|
||||||
|
@ -4787,11 +4793,11 @@ bool Collator::check_block_overload() {
|
||||||
LOG(INFO) << "block load statistics: gas=" << block_limit_status_->gas_used
|
LOG(INFO) << "block load statistics: gas=" << block_limit_status_->gas_used
|
||||||
<< " lt_delta=" << block_limit_status_->cur_lt - block_limit_status_->limits.start_lt
|
<< " lt_delta=" << block_limit_status_->cur_lt - block_limit_status_->limits.start_lt
|
||||||
<< " size_estimate=" << block_size_estimate_;
|
<< " size_estimate=" << block_size_estimate_;
|
||||||
auto cl = block_limit_status_->classify();
|
block_limit_class_ = std::max(block_limit_class_, block_limit_status_->classify());
|
||||||
if (cl >= block::ParamLimits::cl_soft || dispatch_queue_total_limit_reached_) {
|
if (block_limit_class_ >= block::ParamLimits::cl_soft || dispatch_queue_total_limit_reached_) {
|
||||||
std::string message = "block is overloaded ";
|
std::string message = "block is overloaded ";
|
||||||
if (cl >= block::ParamLimits::cl_soft) {
|
if (block_limit_class_ >= block::ParamLimits::cl_soft) {
|
||||||
message += PSTRING() << "(category " << cl << ")";
|
message += PSTRING() << "(category " << block_limit_class_ << ")";
|
||||||
} else {
|
} else {
|
||||||
message += "(long dispatch queue processing)";
|
message += "(long dispatch queue processing)";
|
||||||
}
|
}
|
||||||
|
@ -4802,7 +4808,7 @@ bool Collator::check_block_overload() {
|
||||||
overload_history_ |= 1;
|
overload_history_ |= 1;
|
||||||
LOG(INFO) << message;
|
LOG(INFO) << message;
|
||||||
}
|
}
|
||||||
} else if (cl <= block::ParamLimits::cl_underload) {
|
} else if (block_limit_class_ <= block::ParamLimits::cl_underload) {
|
||||||
if (out_msg_queue_size_ > MERGE_MAX_QUEUE_SIZE) {
|
if (out_msg_queue_size_ > MERGE_MAX_QUEUE_SIZE) {
|
||||||
LOG(INFO)
|
LOG(INFO)
|
||||||
<< "block is underloaded, but don't set underload history because out_msg_queue size is too big to merge ("
|
<< "block is underloaded, but don't set underload history because out_msg_queue size is too big to merge ("
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue