mirror of
https://github.com/ton-blockchain/ton
synced 2025-02-12 11:12:16 +00:00
Account for unprocessed messages in estimate_block_size; check consensus_config limits in collator (#692)
Co-authored-by: SpyCheese <mikle98@yandex.ru>
This commit is contained in:
parent
a78adf3062
commit
1696ebfa20
3 changed files with 17 additions and 2 deletions
|
@ -715,7 +715,7 @@ td::uint64 BlockLimitStatus::estimate_block_size(const vm::NewCellStorageStat::S
|
|||
sum += *extra;
|
||||
}
|
||||
return 2000 + (sum.bits >> 3) + sum.cells * 12 + sum.internal_refs * 3 + sum.external_refs * 40 + accounts * 200 +
|
||||
transactions * 200 + (extra ? 200 : 0);
|
||||
transactions * 200 + (extra ? 200 : 0) + extra_out_msgs * 300;
|
||||
}
|
||||
|
||||
int BlockLimitStatus::classify() const {
|
||||
|
|
|
@ -261,7 +261,7 @@ struct BlockLimitStatus {
|
|||
ton::LogicalTime cur_lt;
|
||||
td::uint64 gas_used{};
|
||||
vm::NewCellStorageStat st_stat;
|
||||
unsigned accounts{}, transactions{};
|
||||
unsigned accounts{}, transactions{}, extra_out_msgs{};
|
||||
BlockLimitStatus(const BlockLimits& limits_, ton::LogicalTime lt = 0)
|
||||
: limits(limits_), cur_lt(std::max(limits_.start_lt, lt)) {
|
||||
}
|
||||
|
@ -270,6 +270,7 @@ struct BlockLimitStatus {
|
|||
st_stat.set_zero();
|
||||
transactions = accounts = 0;
|
||||
gas_used = 0;
|
||||
extra_out_msgs = 0;
|
||||
}
|
||||
td::uint64 estimate_block_size(const vm::NewCellStorageStat::Stat* extra = nullptr) const;
|
||||
int classify() const;
|
||||
|
|
|
@ -2961,6 +2961,7 @@ bool Collator::process_new_messages(bool enqueue_only) {
|
|||
while (!new_msgs.empty()) {
|
||||
block::NewOutMsg msg = new_msgs.top();
|
||||
new_msgs.pop();
|
||||
block_limit_status_->extra_out_msgs--;
|
||||
if (block_full_ && !enqueue_only) {
|
||||
LOG(INFO) << "BLOCK FULL, enqueue all remaining new messages";
|
||||
enqueue_only = true;
|
||||
|
@ -2982,6 +2983,7 @@ void Collator::register_new_msg(block::NewOutMsg new_msg) {
|
|||
min_new_msg_lt = new_msg.lt;
|
||||
}
|
||||
new_msgs.push(std::move(new_msg));
|
||||
block_limit_status_->extra_out_msgs++;
|
||||
}
|
||||
|
||||
void Collator::register_new_msgs(block::transaction::Transaction& trans) {
|
||||
|
@ -3972,6 +3974,18 @@ bool Collator::create_block_candidate() {
|
|||
ton::BlockIdExt{ton::BlockId{shard_, new_block_seqno}, new_block->get_hash().bits(),
|
||||
block::compute_file_hash(blk_slice.as_slice())},
|
||||
block::compute_file_hash(cdata_slice.as_slice()), blk_slice.clone(), cdata_slice.clone());
|
||||
// 3.1 check block and collated data size
|
||||
auto consensus_config = config_->get_consensus_config();
|
||||
if (block_candidate->data.size() > consensus_config.max_block_size) {
|
||||
return fatal_error(PSTRING() << "block size (" << block_candidate->data.size()
|
||||
<< ") exceeds the limit in consensus config (" << consensus_config.max_block_size
|
||||
<< ")");
|
||||
}
|
||||
if (block_candidate->collated_data.size() > consensus_config.max_collated_data_size) {
|
||||
return fatal_error(PSTRING() << "collated data size (" << block_candidate->collated_data.size()
|
||||
<< ") exceeds the limit in consensus config ("
|
||||
<< consensus_config.max_collated_data_size << ")");
|
||||
}
|
||||
// 4. save block candidate
|
||||
LOG(INFO) << "saving new BlockCandidate";
|
||||
td::actor::send_closure_later(manager, &ValidatorManager::set_block_candidate, block_candidate->id,
|
||||
|
|
Loading…
Reference in a new issue