1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

Merge branch 'testnet' into accelerator

This commit is contained in:
SpyCheese 2025-02-21 12:19:27 +03:00
commit bf884b5611
55 changed files with 866 additions and 326 deletions

View file

@ -54,16 +54,6 @@ static constexpr int HIGH_PRIORITY_EXTERNAL = 10; // don't skip high priority e
static constexpr int MAX_ATTEMPTS = 5;
#define DBG(__n) dbg(__n)&&
#define DSTART int __dcnt = 0;
#define DEB DBG(++__dcnt)
static inline bool dbg(int c) TD_UNUSED;
static inline bool dbg(int c) {
std::cerr << '[' << (char)('0' + c / 10) << (char)('0' + c % 10) << ']';
return true;
}
/**
* Constructs a Collator object.
*
@ -381,6 +371,9 @@ bool Collator::fatal_error(td::Status error) {
} else {
LOG(INFO) << "collation failed in " << perf_timer_.elapsed() << " s " << error;
LOG(INFO) << perf_log_;
finalize_stats();
stats_.status = error.clone();
td::actor::send_closure(manager, &ValidatorManager::log_collate_query_stats, std::move(stats_));
main_promise(std::move(error));
}
busy_ = false;
@ -812,8 +805,6 @@ bool Collator::unpack_last_mc_state() {
<< " (upgrade validator software?)";
}
// TODO: extract start_lt and end_lt from prev_mc_block as well
// std::cerr << " block::gen::ShardState::print_ref(mc_state_root) = ";
// block::gen::t_ShardState.print_ref(std::cerr, mc_state_root, 2);
return true;
}
@ -1000,8 +991,10 @@ void Collator::got_neighbor_msg_queue(unsigned i, Ref<OutMsgQueueProof> res) {
// unpack ProcessedUpto
LOG(DEBUG) << "unpacking ProcessedUpto of neighbor " << descr.blk_.to_str();
if (verbosity >= 2) {
block::gen::t_ProcessedInfo.print(std::cerr, qinfo.proc_info);
qinfo.proc_info->print_rec(std::cerr);
FLOG(INFO) {
block::gen::t_ProcessedInfo.print(sb, qinfo.proc_info);
qinfo.proc_info->print_rec(sb);
};
}
descr.processed_upto = block::MsgProcessedUptoCollection::unpack(descr.shard(), qinfo.proc_info);
if (!descr.processed_upto) {
@ -1879,13 +1872,12 @@ bool Collator::import_new_shard_top_blocks() {
if (tb_act) {
shard_conf_adjusted_ = true;
}
if (tb_act) {
LOG(INFO) << "updated shard block configuration: " << tb_act << " new top shard blocks";
if (verbosity >= 3) {
LOG(INFO) << "updated shard block configuration to ";
if (tb_act && verbosity >= 0) { // DEBUG
FLOG(INFO) {
sb << "updated shard block configuration to ";
auto csr = shard_conf_->get_root_csr();
block::gen::t_ShardHashes.print(std::cerr, csr.write());
}
block::gen::t_ShardHashes.print(sb, csr);
};
}
block::gen::ShardFeeCreated::Record fc;
if (!(tlb::csr_unpack(fees_import_dict_->get_root_extra(),
@ -2422,10 +2414,12 @@ bool Collator::dequeue_message(Ref<vm::Cell> msg_envelope, ton::LogicalTime deli
bool Collator::out_msg_queue_cleanup() {
LOG(INFO) << "cleaning outbound queue from messages already imported by neighbors";
if (verbosity >= 2) {
auto rt = out_msg_queue_->get_root();
std::cerr << "old out_msg_queue is ";
block::gen::t_OutMsgQueue.print(std::cerr, *rt);
rt->print_rec(std::cerr);
FLOG(INFO) {
auto rt = out_msg_queue_->get_root();
sb << "old out_msg_queue is ";
block::gen::t_OutMsgQueue.print(sb, rt);
rt->print_rec(sb);
};
}
if (after_merge_) {
@ -2587,10 +2581,12 @@ bool Collator::out_msg_queue_cleanup() {
<< out_msg_queue_size_;
}
if (verbosity >= 2) {
auto rt = out_msg_queue_->get_root();
std::cerr << "new out_msg_queue is ";
block::gen::t_OutMsgQueue.print(std::cerr, *rt);
rt->print_rec(std::cerr);
FLOG(INFO) {
auto rt = out_msg_queue_->get_root();
sb << "new out_msg_queue is ";
block::gen::t_OutMsgQueue.print(sb, rt);
rt->print_rec(sb);
};
}
return register_out_msg_queue_op(true);
}
@ -2689,19 +2685,27 @@ bool Collator::combine_account_transactions() {
auto cell = cb.finalize();
auto csr = vm::load_cell_slice_ref(cell);
if (verbosity > 2) {
std::cerr << "new AccountBlock for " << z.first.to_hex() << ": ";
block::gen::t_AccountBlock.print_ref(std::cerr, cell);
csr->print_rec(std::cerr);
FLOG(INFO) {
sb << "new AccountBlock for " << z.first.to_hex() << ": ";
block::gen::t_AccountBlock.print_ref(sb, cell);
csr->print_rec(sb);
};
}
if (!block::gen::t_AccountBlock.validate_ref(100000, cell)) {
block::gen::t_AccountBlock.print_ref(std::cerr, cell);
csr->print_rec(std::cerr);
FLOG(WARNING) {
sb << "AccountBlock failed to pass automatic validation tests: ";
block::gen::t_AccountBlock.print_ref(sb, cell);
csr->print_rec(sb);
};
return fatal_error(std::string{"new AccountBlock for "} + z.first.to_hex() +
" failed to pass automatic validation tests");
}
if (!block::tlb::t_AccountBlock.validate_ref(100000, cell)) {
block::gen::t_AccountBlock.print_ref(std::cerr, cell);
csr->print_rec(std::cerr);
FLOG(WARNING) {
sb << "AccountBlock failed to pass handwritten validation tests: ";
block::gen::t_AccountBlock.print_ref(sb, cell);
csr->print_rec(sb);
};
return fatal_error(std::string{"new AccountBlock for "} + z.first.to_hex() +
" failed to pass handwritten validation tests");
}
@ -2726,8 +2730,10 @@ bool Collator::combine_account_transactions() {
} else if (acc.status == block::Account::acc_nonexist) {
// account deleted
if (verbosity > 2) {
std::cerr << "deleting account " << acc.addr.to_hex() << " with empty new value ";
block::gen::t_Account.print_ref(std::cerr, acc.total_state);
FLOG(INFO) {
sb << "deleting account " << acc.addr.to_hex() << " with empty new value ";
block::gen::t_Account.print_ref(sb, acc.total_state);
};
}
if (account_dict->lookup_delete(acc.addr).is_null()) {
return fatal_error(std::string{"cannot delete account "} + acc.addr.to_hex() + " from ShardAccounts");
@ -2735,8 +2741,10 @@ bool Collator::combine_account_transactions() {
} else {
// existing account modified
if (verbosity > 4) {
std::cerr << "modifying account " << acc.addr.to_hex() << " to ";
block::gen::t_Account.print_ref(std::cerr, acc.total_state);
FLOG(INFO) {
sb << "modifying account " << acc.addr.to_hex() << " to ";
block::gen::t_Account.print_ref(sb, acc.total_state);
};
}
if (!(cb.store_ref_bool(acc.total_state) // account_descr$_ account:^Account
&& cb.store_bits_bool(acc.last_trans_hash_) // last_trans_hash:bits256
@ -2759,9 +2767,11 @@ bool Collator::combine_account_transactions() {
return fatal_error("cannot serialize ShardAccountBlocks");
}
if (verbosity > 2) {
std::cerr << "new ShardAccountBlocks: ";
block::gen::t_ShardAccountBlocks.print_ref(std::cerr, shard_account_blocks_);
vm::load_cell_slice(shard_account_blocks_).print_rec(std::cerr);
FLOG(INFO) {
sb << "new ShardAccountBlocks: ";
block::gen::t_ShardAccountBlocks.print_ref(sb, shard_account_blocks_);
vm::load_cell_slice(shard_account_blocks_).print_rec(sb);
};
}
if (!block::gen::t_ShardAccountBlocks.validate_ref(100000, shard_account_blocks_)) {
return fatal_error("new ShardAccountBlocks failed to pass automatic validity tests");
@ -2771,9 +2781,11 @@ bool Collator::combine_account_transactions() {
}
auto shard_accounts = account_dict->get_root();
if (verbosity > 2) {
std::cerr << "new ShardAccounts: ";
block::gen::t_ShardAccounts.print(std::cerr, *shard_accounts);
shard_accounts->print_rec(std::cerr);
FLOG(INFO) {
sb << "new ShardAccounts: ";
block::gen::t_ShardAccounts.print(sb, shard_accounts);
shard_accounts->print_rec(sb);
};
}
if (verify >= 2) {
LOG(INFO) << "verifying new ShardAccounts";
@ -2824,7 +2836,9 @@ bool Collator::create_special_transaction(block::CurrencyCollection amount, Ref<
addr.to_hex());
}
if (verbosity >= 4) {
block::gen::t_Message_Any.print_ref(std::cerr, msg);
FLOG(INFO) {
block::gen::t_Message_Any.print_ref(sb, msg);
};
}
CHECK(block::gen::t_Message_Any.validate_ref(msg));
CHECK(block::tlb::t_Message.validate_ref(msg));
@ -3328,8 +3342,10 @@ int Collator::process_one_new_message(block::NewOutMsg msg, bool enqueue_only, R
Ref<vm::Cell> msg_env;
CHECK(block::tlb::pack_cell(msg_env, msg_env_rec));
if (verbosity > 2) {
std::cerr << "new (processed outbound) message envelope: ";
block::gen::t_MsgEnvelope.print_ref(std::cerr, msg_env);
FLOG(INFO) {
sb << "new (processed outbound) message envelope: ";
block::gen::t_MsgEnvelope.print_ref(sb, msg_env);
};
}
// 3. create InMsg, referring to this MsgEnvelope and this Transaction
vm::CellBuilder cb;
@ -3451,16 +3467,20 @@ bool Collator::enqueue_transit_message(Ref<vm::Cell> msg, Ref<vm::Cell> old_msg_
Ref<vm::Cell> out_msg = cb.finalize();
// 4.1. insert OutMsg into OutMsgDescr
if (verbosity > 2) {
std::cerr << "OutMsg for a transit message: ";
block::gen::t_OutMsg.print_ref(std::cerr, out_msg);
FLOG(INFO) {
sb << "OutMsg for a transit message: ";
block::gen::t_OutMsg.print_ref(sb, out_msg);
};
}
if (!insert_out_msg(out_msg)) {
return fatal_error("cannot insert a new OutMsg into OutMsgDescr");
}
// 4.2. insert InMsg into InMsgDescr
if (verbosity > 2) {
std::cerr << "InMsg for a transit message: ";
block::gen::t_InMsg.print_ref(std::cerr, in_msg);
FLOG(INFO) {
sb << "InMsg for a transit message: ";
block::gen::t_InMsg.print_ref(sb, in_msg);
};
}
if (!insert_in_msg(in_msg)) {
return fatal_error("cannot insert a new InMsg into InMsgDescr");
@ -3519,7 +3539,10 @@ bool Collator::precheck_inbound_message(Ref<vm::CellSlice> enq_msg, ton::Logical
if (enq_msg.is_null() || enq_msg->size_ext() != 0x10040 ||
(enqueued_lt = enq_msg->prefetch_ulong(64)) < /* 0 */ 1 * lt) { // DEBUG
if (enq_msg.not_null()) {
block::gen::t_EnqueuedMsg.print(std::cerr, *enq_msg);
FLOG(WARNING) {
sb << "inbound internal message is not a valid EnqueuedMsg: ";
block::gen::t_EnqueuedMsg.print(sb, enq_msg);
};
}
LOG(ERROR) << "inbound internal message is not a valid EnqueuedMsg (created lt " << lt << ", enqueued "
<< enqueued_lt << ")";
@ -3780,14 +3803,18 @@ bool Collator::process_inbound_internal_messages() {
LOG(DEBUG) << "processing inbound message with (lt,hash)=(" << kv->lt << "," << kv->key.to_hex()
<< ") from neighbor #" << kv->source;
if (verbosity > 2) {
std::cerr << "inbound message: lt=" << kv->lt << " from=" << kv->source << " key=" << kv->key.to_hex() << " msg=";
block::gen::t_EnqueuedMsg.print(std::cerr, *(kv->msg));
FLOG(INFO) {
sb << "inbound message: lt=" << kv->lt << " from=" << kv->source << " key=" << kv->key.to_hex() << " msg=";
block::gen::t_EnqueuedMsg.print(sb, kv->msg);
};
}
if (!process_inbound_message(kv->msg, kv->lt, kv->key.cbits(), neighbors_.at(kv->source))) {
if (verbosity > 1) {
std::cerr << "invalid inbound message: lt=" << kv->lt << " from=" << kv->source << " key=" << kv->key.to_hex()
<< " msg=";
block::gen::t_EnqueuedMsg.print(std::cerr, *(kv->msg));
FLOG(INFO) {
sb << "invalid inbound message: lt=" << kv->lt << " from=" << kv->source << " key=" << kv->key.to_hex()
<< " msg=";
block::gen::t_EnqueuedMsg.print(sb, kv->msg);
};
}
return fatal_error("error processing inbound internal message");
}
@ -4074,7 +4101,10 @@ bool Collator::process_deferred_message(Ref<vm::CellSlice> enq_msg, StdSmcAddres
LogicalTime enqueued_lt = 0;
if (enq_msg.is_null() || enq_msg->size_ext() != 0x10040 || (enqueued_lt = enq_msg->prefetch_ulong(64)) != lt) {
if (enq_msg.not_null()) {
block::gen::t_EnqueuedMsg.print(std::cerr, *enq_msg);
FLOG(WARNING) {
sb << "internal message in DispatchQueue is not a valid EnqueuedMsg: ";
block::gen::t_EnqueuedMsg.print(sb, enq_msg);
};
}
LOG(ERROR) << "internal message in DispatchQueue is not a valid EnqueuedMsg (created lt " << lt << ", enqueued "
<< enqueued_lt << ")";
@ -4176,8 +4206,10 @@ bool Collator::process_deferred_message(Ref<vm::CellSlice> enq_msg, StdSmcAddres
*/
bool Collator::insert_in_msg(Ref<vm::Cell> in_msg) {
if (verbosity > 2) {
std::cerr << "InMsg being inserted into InMsgDescr: ";
block::gen::t_InMsg.print_ref(std::cerr, in_msg);
FLOG(INFO) {
sb << "InMsg being inserted into InMsgDescr: ";
block::gen::t_InMsg.print_ref(sb, in_msg);
};
}
auto cs = load_cell_slice(in_msg);
if (!cs.size_refs()) {
@ -4218,8 +4250,10 @@ bool Collator::insert_in_msg(Ref<vm::Cell> in_msg) {
*/
bool Collator::insert_out_msg(Ref<vm::Cell> out_msg) {
if (verbosity > 2) {
std::cerr << "OutMsg being inserted into OutMsgDescr: ";
block::gen::t_OutMsg.print_ref(std::cerr, out_msg);
FLOG(INFO) {
sb << "OutMsg being inserted into OutMsgDescr: ";
block::gen::t_OutMsg.print_ref(sb, out_msg);
};
}
auto cs = load_cell_slice(out_msg);
if (!cs.size_refs()) {
@ -4315,8 +4349,10 @@ bool Collator::enqueue_message(block::NewOutMsg msg, td::RefInt256 fwd_fees_rema
}
// 4. insert OutMsg into OutMsgDescr
if (verbosity > 2) {
std::cerr << "OutMsg for a newly-generated message: ";
block::gen::t_OutMsg.print_ref(std::cerr, out_msg);
FLOG(INFO) {
sb << "OutMsg for a newly-generated message: ";
block::gen::t_OutMsg.print_ref(sb, out_msg);
};
}
if (!insert_out_msg(out_msg)) {
return fatal_error("cannot insert a new OutMsg into OutMsgDescr");
@ -4609,9 +4645,12 @@ bool Collator::create_mc_state_extra() {
bool ignore_cfg_changes = false;
Ref<vm::Cell> cfg0;
if (!block::valid_config_data(cfg_smc_config, config_addr, true, true, old_mparams_)) {
block::gen::t_Hashmap_32_Ref_Cell.print_ref(std::cerr, cfg_smc_config);
LOG(ERROR) << "configuration smart contract "s + config_addr.to_hex() +
" contains an invalid configuration in its data, IGNORING CHANGES";
FLOG(WARNING) {
sb << "ignored configuration: ";
block::gen::t_Hashmap_32_Ref_Cell.print_ref(sb, cfg_smc_config);
};
ignore_cfg_changes = true;
} else {
cfg0 = cfg_dict.lookup_ref(td::BitArray<32>{(long long)0});
@ -4649,34 +4688,26 @@ bool Collator::create_mc_state_extra() {
return fatal_error(wset_res.move_as_error());
}
bool update_shard_cc = is_key_block_ || (now_ / ccvc.shard_cc_lifetime > prev_now_ / ccvc.shard_cc_lifetime);
// temp debug
if (verbosity >= 3 * 1) {
auto csr = shard_conf_->get_root_csr();
LOG(INFO) << "new shard configuration before post-processing is";
std::ostringstream os;
csr->print_rec(os);
block::gen::t_ShardHashes.print(os, csr.write());
LOG(INFO) << os.str();
}
// end (temp debug)
if (!update_shard_config(wset_res.move_as_ok(), ccvc, update_shard_cc)) {
auto csr = shard_conf_->get_root_csr();
if (csr.is_null()) {
LOG(WARNING) << "new shard configuration is null (!)";
} else {
LOG(WARNING) << "invalid new shard configuration is";
std::ostringstream os;
csr->print_rec(os);
block::gen::t_ShardHashes.print(os, csr.write());
LOG(WARNING) << os.str();
FLOG(WARNING) {
csr->print_rec(sb);
block::gen::t_ShardHashes.print(sb, csr);
};
}
return fatal_error("cannot post-process shard configuration");
}
// 3. save new shard_hashes
state_extra.shard_hashes = shard_conf_->get_root_csr();
if (verbosity >= 3) {
std::cerr << "updated shard configuration to ";
block::gen::t_ShardHashes.print(std::cerr, *state_extra.shard_hashes);
FLOG(INFO) {
sb << "updated shard configuration to ";
block::gen::t_ShardHashes.print(sb, state_extra.shard_hashes);
};
}
if (!block::gen::t_ShardHashes.validate_upto(10000, *state_extra.shard_hashes)) {
return fatal_error("new ShardHashes is invalid");
@ -4777,13 +4808,18 @@ bool Collator::create_mc_state_extra() {
if (verify >= 2) {
LOG(INFO) << "verifying new BlockCreateStats";
if (!block::gen::t_BlockCreateStats.validate_csr(100000, cs)) {
cs->print_rec(std::cerr);
block::gen::t_BlockCreateStats.print(std::cerr, *cs);
FLOG(WARNING) {
sb << "BlockCreateStats in the new masterchain state failed to pass automated validity checks: ";
cs->print_rec(sb);
block::gen::t_BlockCreateStats.print(sb, cs);
};
return fatal_error("BlockCreateStats in the new masterchain state failed to pass automated validity checks");
}
}
if (verbosity >= 4 * 1) {
block::gen::t_BlockCreateStats.print(std::cerr, *cs);
FLOG(INFO) {
block::gen::t_BlockCreateStats.print(sb, cs);
};
}
} else {
state_extra.r1.block_create_stats.clear();
@ -4818,7 +4854,6 @@ bool Collator::update_block_creator_count(td::ConstBitPtr key, unsigned shard_in
if (!block::unpack_CreatorStats(std::move(cs), mc_cnt, shard_cnt)) {
return fatal_error("cannot unpack CreatorStats for "s + key.to_hex(256) + " from previous masterchain state");
}
// std::cerr << mc_cnt.to_str() << " " << shard_cnt.to_str() << std::endl;
if (mc_incr && !mc_cnt.increase_by(mc_incr, now_)) {
return fatal_error(PSTRING() << "cannot increase masterchain block counter in CreatorStats for " << key.to_hex(256)
<< " by " << mc_incr << " (old value is " << mc_cnt.to_str() << ")");
@ -5190,9 +5225,11 @@ bool Collator::update_public_libraries() {
}
}
if (libraries_changed_ && verbosity >= 2) {
std::cerr << "New public libraries: ";
block::gen::t_HashmapE_256_LibDescr.print(std::cerr, shard_libraries_->get_root());
shard_libraries_->get_root()->print_rec(std::cerr);
FLOG(INFO) {
sb << "New public libraries: ";
block::gen::t_HashmapE_256_LibDescr.print(sb, shard_libraries_->get_root());
shard_libraries_->get_root()->print_rec(sb);
};
}
return true;
}
@ -5315,9 +5352,11 @@ bool Collator::create_shard_state() {
}
LOG(DEBUG) << "min_ref_mc_seqno is " << min_ref_mc_seqno_;
if (verbosity > 2) {
std::cerr << "new ShardState: ";
block::gen::t_ShardState.print_ref(std::cerr, state_root);
vm::load_cell_slice(state_root).print_rec(std::cerr);
FLOG(INFO) {
sb << "new ShardState: ";
block::gen::t_ShardState.print_ref(sb, state_root);
vm::load_cell_slice(state_root).print_rec(sb);
};
}
if (verify >= 2) {
LOG(INFO) << "verifying new ShardState";
@ -5330,9 +5369,11 @@ bool Collator::create_shard_state() {
return fatal_error("cannot create Merkle update for ShardState");
}
if (verbosity > 2) {
std::cerr << "Merkle Update for ShardState: ";
vm::CellSlice cs{vm::NoVm{}, state_update};
cs.print_rec(std::cerr);
FLOG(INFO) {
sb << "Merkle Update for ShardState: ";
vm::CellSlice cs{vm::NoVm{}, state_update};
cs.print_rec(sb);
};
}
LOG(INFO) << "updating block profile statistics";
block_limit_status_->add_proof(state_root);
@ -5377,10 +5418,12 @@ bool Collator::update_processed_upto() {
*/
bool Collator::compute_out_msg_queue_info(Ref<vm::Cell>& out_msg_queue_info) {
if (verbosity >= 2) {
auto rt = out_msg_queue_->get_root();
std::cerr << "resulting out_msg_queue is ";
block::gen::t_OutMsgQueue.print(std::cerr, *rt);
rt->print_rec(std::cerr);
FLOG(INFO) {
auto rt = out_msg_queue_->get_root();
sb << "resulting out_msg_queue is ";
block::gen::t_OutMsgQueue.print(sb, rt);
rt->print_rec(sb);
};
}
vm::CellBuilder cb;
// out_msg_queue_extra#0 dispatch_queue:DispatchQueue out_queue_size:(Maybe uint48) = OutMsgQueueExtra;
@ -5430,8 +5473,10 @@ bool Collator::compute_total_balance() {
}
vm::CellSlice cs{*(in_msg_dict->get_root_extra())};
if (verbosity > 2) {
block::gen::t_ImportFees.print(std::cerr, vm::CellSlice{*(in_msg_dict->get_root_extra())});
cs.print_rec(std::cerr);
FLOG(INFO) {
block::gen::t_ImportFees.print(sb, in_msg_dict->get_root_extra());
cs.print_rec(sb);
};
}
auto new_import_fees = block::tlb::t_Grams.as_integer_skip(cs);
if (new_import_fees.is_null()) {
@ -5659,9 +5704,11 @@ bool Collator::create_block() {
return fatal_error("cannot create new Block");
}
if (verbosity >= 3 * 1) {
std::cerr << "new Block: ";
block::gen::t_Block.print_ref(std::cerr, new_block);
vm::load_cell_slice(new_block).print_rec(std::cerr);
FLOG(INFO) {
sb << "new Block: ";
block::gen::t_Block.print_ref(sb, new_block);
vm::load_cell_slice(new_block).print_rec(sb);
};
}
if (verify >= 1) {
LOG(INFO) << "verifying new Block";
@ -5699,9 +5746,11 @@ Ref<vm::Cell> Collator::collate_shard_block_descr_set() {
return {};
}
if (verbosity >= 4 * 1) {
std::cerr << "serialized TopBlockDescrSet for collated data is: ";
block::gen::t_TopBlockDescrSet.print_ref(std::cerr, cell);
vm::load_cell_slice(cell).print_rec(std::cerr);
FLOG(INFO) {
sb << "serialized TopBlockDescrSet for collated data is: ";
block::gen::t_TopBlockDescrSet.print_ref(sb, cell);
vm::load_cell_slice(cell).print_rec(sb);
};
}
return cell;
}
@ -5965,35 +6014,6 @@ bool Collator::create_block_candidate() {
td::actor::send_closure_later(manager, &ValidatorManager::complete_external_messages, std::move(delay_ext_msgs_),
std::move(bad_ext_msgs_));
}
double work_time = work_timer_.elapsed();
double cpu_work_time = cpu_work_timer_.elapsed();
LOG(WARNING) << "Collate query work time = " << work_time << "s, cpu time = " << cpu_work_time << "s";
stats_.block_id = block_candidate->id;
stats_.collated_data_hash = block_candidate->collated_file_hash;
stats_.cc_seqno = validator_set_->get_catchain_seqno();
stats_.collated_at = td::Clocks::system();
stats_.actual_bytes = block_candidate->data.size();
stats_.actual_collated_data_bytes = block_candidate->collated_data.size();
stats_.attempt = attempt_idx_;
stats_.is_validator = !(mode_ & CollateMode::from_collator_node);
stats_.self = stats_.is_validator ? PublicKey(pubkeys::Ed25519(created_by_)).compute_short_id()
: collator_node_id_.pubkey_hash();
stats_.estimated_bytes = block_limit_status_->estimate_block_size();
stats_.gas = block_limit_status_->gas_used;
stats_.lt_delta = block_limit_status_->cur_lt - block_limit_status_->limits.start_lt;
stats_.estimated_collated_data_bytes = block_limit_status_->collated_data_stat.estimate_proof_size();
stats_.cat_bytes = block_limit_status_->limits.classify_size(stats_.estimated_bytes);
stats_.cat_gas = block_limit_status_->limits.classify_gas(stats_.gas);
stats_.cat_lt_delta = block_limit_status_->limits.classify_lt(block_limit_status_->cur_lt);
stats_.cat_collated_data_bytes =
block_limit_status_->limits.classify_collated_data_size(stats_.estimated_collated_data_bytes);
stats_.total_time = perf_timer_.elapsed();
stats_.work_time = work_time;
stats_.cpu_work_time = cpu_work_time;
stats_.time_stats = (PSTRING() << perf_log_);
td::actor::send_closure(manager, &ValidatorManager::log_collate_query_stats, std::move(stats_));
return true;
}
@ -6013,6 +6033,9 @@ void Collator::return_block_candidate(td::Result<td::Unit> saved) {
LOG(WARNING) << "sending new BlockCandidate to Promise";
LOG(WARNING) << "collation took " << perf_timer_.elapsed() << " s";
LOG(WARNING) << perf_log_;
finalize_stats();
stats_.status = td::Status::OK();
td::actor::send_closure(manager, &ValidatorManager::log_collate_query_stats, std::move(stats_));
main_promise(block_candidate->clone());
busy_ = false;
stop();
@ -6078,8 +6101,10 @@ td::Result<bool> Collator::register_external_message_cell(Ref<vm::Cell> ext_msg,
return td::Status::Error("inbound external message has destination address not in this shard");
}
if (verbosity > 2) {
std::cerr << "registered external message: ";
block::gen::t_Message_Any.print_ref(std::cerr, ext_msg);
FLOG(INFO) {
sb << "registered external message: ";
block::gen::t_Message_Any.print_ref(sb, ext_msg);
};
}
ext_msg_map.emplace(hash, 1);
ext_msg_list_.push_back({std::move(ext_msg), ext_hash, priority});
@ -6139,6 +6164,39 @@ td::uint32 Collator::get_skip_externals_queue_size() {
return SKIP_EXTERNALS_QUEUE_SIZE;
}
void Collator::finalize_stats() {
double work_time = work_timer_.elapsed();
double cpu_work_time = cpu_work_timer_.elapsed();
LOG(WARNING) << "Collate query work time = " << work_time << "s, cpu time = " << cpu_work_time << "s";
if (block_candidate) {
stats_.block_id = block_candidate->id;
stats_.collated_data_hash = block_candidate->collated_file_hash;
stats_.actual_bytes = block_candidate->data.size();
stats_.actual_collated_data_bytes = block_candidate->collated_data.size();
} else {
stats_.block_id.id = new_id;
}
stats_.cc_seqno = validator_set_->get_catchain_seqno();
stats_.collated_at = td::Clocks::system();
stats_.attempt = attempt_idx_;
stats_.is_validator = !(mode_ & CollateMode::from_collator_node);
stats_.self = stats_.is_validator ? PublicKey(pubkeys::Ed25519(created_by_)).compute_short_id()
: collator_node_id_.pubkey_hash();
stats_.estimated_bytes = block_limit_status_->estimate_block_size();
stats_.gas = block_limit_status_->gas_used;
stats_.lt_delta = block_limit_status_->cur_lt - block_limit_status_->limits.start_lt;
stats_.estimated_collated_data_bytes = block_limit_status_->collated_data_stat.estimate_proof_size();
stats_.cat_bytes = block_limit_status_->limits.classify_size(stats_.estimated_bytes);
stats_.cat_gas = block_limit_status_->limits.classify_gas(stats_.gas);
stats_.cat_lt_delta = block_limit_status_->limits.classify_lt(block_limit_status_->cur_lt);
stats_.cat_collated_data_bytes =
block_limit_status_->limits.classify_collated_data_size(stats_.estimated_collated_data_bytes);
stats_.total_time = perf_timer_.elapsed();
stats_.work_time = work_time;
stats_.cpu_work_time = cpu_work_time;
stats_.time_stats = (PSTRING() << perf_log_);
}
} // namespace validator
} // namespace ton