@@ -919,6 +919,7 @@ void Collator::got_neighbor_msg_queues(td::Result<std::map<BlockIdExt, Ref<OutMs
919919 LOG (INFO) << " neighbor output queues fetched, took " << duration << " s" ;
920920 auto res = R.move_as_ok ();
921921 unsigned i = 0 ;
922+ stats_.neighbors .resize (neighbors_.size ());
922923 for (block::McShardDescr& descr : neighbors_) {
923924 LOG (DEBUG) << " neighbor #" << i << " : " << descr.blk_ .to_str ();
924925 auto it = res.find (descr.blk_ );
@@ -937,6 +938,13 @@ void Collator::got_neighbor_msg_queue(unsigned i, Ref<OutMsgQueueProof> res) {
937938 if (res->block_state_proof_ .not_null () && !block_id.is_masterchain ()) {
938939 block_state_proofs_.emplace (block_id.root_hash , res->block_state_proof_ );
939940 }
941+
942+ auto &neighbor_stats = stats_.neighbors .at (i);
943+ neighbor_stats.shard = block_id.shard_full ();
944+ neighbor_stats.is_trivial = shard_intersects (block_id.shard_full (), shard_);
945+ neighbor_stats.is_local = res->is_local_ ;
946+ neighbor_stats.msg_limit = res->msg_count_ ;
947+
940948 Ref<vm::Cell> state_root;
941949 if (block_id.is_masterchain ()) {
942950 state_root = res->state_root_ ;
@@ -1000,18 +1008,16 @@ void Collator::got_neighbor_msg_queue(unsigned i, Ref<OutMsgQueueProof> res) {
10001008 return ;
10011009 }
10021010 outq_descr.clear ();
1003- do {
1004- // require masterchain blocks referred to in ProcessedUpto
1005- // TODO: perform this only if there are messages for this shard in our output queue
1006- // .. (have to check the above condition and perform a `break` here) ..
1007- // ..
1008- for (const auto & entry : descr.processed_upto ->list ) {
1009- Ref<MasterchainStateQ> state;
1010- if (!request_aux_mc_state (entry.mc_seqno , state)) {
1011- return ;
1012- }
1011+ // require masterchain blocks referred to in ProcessedUpto
1012+ // TODO: perform this only if there are messages for this shard in our output queue
1013+ // .. (have to check the above condition and perform a `break` here) ..
1014+ // ..
1015+ for (const auto & entry : descr.processed_upto ->list ) {
1016+ Ref<MasterchainStateQ> state;
1017+ if (!request_aux_mc_state (entry.mc_seqno , state)) {
1018+ return ;
10131019 }
1014- } while ( false );
1020+ }
10151021}
10161022
10171023/* *
@@ -1940,7 +1946,7 @@ bool Collator::try_collate() {
19401946 last_proc_int_msg_.second .set_zero ();
19411947 first_unproc_int_msg_.first = ~0ULL ;
19421948 first_unproc_int_msg_.second .set_ones ();
1943- old_out_msg_queue_size_ = out_msg_queue_size_;
1949+ stats_. old_out_msg_queue_size = old_out_msg_queue_size_ = out_msg_queue_size_;
19441950 if (is_masterchain ()) {
19451951 LOG (DEBUG) << " getting the list of special smart contracts" ;
19461952 auto res = config_->get_special_smartcontracts ();
@@ -2407,6 +2413,9 @@ bool Collator::dequeue_message(Ref<vm::Cell> msg_envelope, ton::LogicalTime deli
24072413 * @returns True if the cleanup operation was successful, false otherwise.
24082414 */
24092415bool Collator::out_msg_queue_cleanup () {
2416+ SCOPE_EXIT {
2417+ stats_.load_fraction_queue_cleanup = block_limit_status_->load_fraction (block::ParamLimits::cl_normal);
2418+ };
24102419 LOG (INFO) << " cleaning outbound queue from messages already imported by neighbors" ;
24112420 if (verbosity >= 2 ) {
24122421 FLOG (INFO) {
@@ -2492,6 +2501,7 @@ bool Collator::out_msg_queue_cleanup() {
24922501 }
24932502 return true ;
24942503 });
2504+ stats_.msg_queue_cleaned = deleted;
24952505 LOG (WARNING) << " deleted " << deleted << " messages from out_msg_queue after merge, remaining queue size is "
24962506 << out_msg_queue_size_;
24972507 if (!ok) {
@@ -2572,6 +2582,7 @@ bool Collator::out_msg_queue_cleanup() {
25722582 std::swap (queue_parts[i], queue_parts.back ());
25732583 queue_parts.pop_back ();
25742584 }
2585+ stats_.msg_queue_cleaned = deleted;
25752586 LOG (WARNING) << " deleted " << deleted << " messages from out_msg_queue, remaining queue size is "
25762587 << out_msg_queue_size_;
25772588 }
@@ -3712,12 +3723,13 @@ bool Collator::precheck_inbound_message(Ref<vm::CellSlice> enq_msg, ton::Logical
37123723 * @param enq_msg The inbound message serialized using EnqueuedMsg TLB-scheme.
37133724 * @param lt The logical time of the message.
37143725 * @param key The 32+64+256-bit key of the message.
3715- * @param src_nb The description of the source neighbor shard.
3726+ * @param src_nb_idx The index of the source neighbor shard.
37163727 *
37173728 * @returns True if the message was processed successfully, false otherwise.
37183729 */
37193730bool Collator::process_inbound_message (Ref<vm::CellSlice> enq_msg, ton::LogicalTime lt, td::ConstBitPtr key,
3720- const block::McShardDescr& src_nb) {
3731+ int src_nb_idx) {
3732+ const auto & src_nb = neighbors_.at (src_nb_idx);
37213733 ton::LogicalTime enqueued_lt = enq_msg->prefetch_ulong (64 );
37223734 auto msg_env = enq_msg->prefetch_ref ();
37233735 // 1. unpack MsgEnvelope
@@ -3815,6 +3827,8 @@ bool Collator::process_inbound_message(Ref<vm::CellSlice> enq_msg, ton::LogicalT
38153827 << " enqueued_lt=" << enq_msg_descr.enqueued_lt_ << " has been already processed by us before, skipping" ;
38163828 // should we dequeue the message if it is ours (after a merge?)
38173829 // (it should have been dequeued by out_msg_queue_cleanup() before)
3830+ auto &neighbor_stats = stats_.neighbors .at (src_nb_idx);
3831+ ++neighbor_stats.skipped_msgs ;
38183832 return true ;
38193833 }
38203834 // 6.1. check whether we have already processed this message by IHR
@@ -3901,12 +3915,17 @@ static std::string block_full_comment(const block::BlockLimitStatus& block_limit
39013915 * @returns True if the processing was successful, false otherwise.
39023916 */
39033917bool Collator::process_inbound_internal_messages () {
3918+ SCOPE_EXIT {
3919+ stats_.load_fraction_internals = block_limit_status_->load_fraction (block::ParamLimits::cl_normal);
3920+ };
39043921 while (!nb_out_msgs_->is_eof ()) {
39053922 block_full_ = !block_limit_status_->fits (block::ParamLimits::cl_normal);
39063923 auto kv = nb_out_msgs_->extract_cur ();
39073924 CHECK (kv && kv->msg .not_null ());
3925+ auto &neighbor_stats = stats_.neighbors .at (kv->source );
39083926 if (kv->limit_exceeded ) {
39093927 LOG (INFO) << " limit for imported messages is reached, stop processing inbound internal messages" ;
3928+ neighbor_stats.limit_reached = true ;
39103929 block::EnqueuedMsgDescr enq;
39113930 enq.unpack (kv->msg .write ()); // Visit cells to include it in proof
39123931 break ;
@@ -3941,13 +3960,14 @@ bool Collator::process_inbound_internal_messages() {
39413960 }
39423961 LOG (DEBUG) << " processing inbound message with (lt,hash)=(" << kv->lt << " ," << kv->key .to_hex ()
39433962 << " ) from neighbor #" << kv->source ;
3963+ ++neighbor_stats.processed_msgs ;
39443964 if (verbosity > 2 ) {
39453965 FLOG (INFO) {
39463966 sb << " inbound message: lt=" << kv->lt << " from=" << kv->source << " key=" << kv->key .to_hex () << " msg=" ;
39473967 block::gen::t_EnqueuedMsg.print (sb, kv->msg );
39483968 };
39493969 }
3950- if (!process_inbound_message (kv->msg , kv->lt , kv->key .cbits (), neighbors_. at ( kv->source ) )) {
3970+ if (!process_inbound_message (kv->msg , kv->lt , kv->key .cbits (), kv->source )) {
39513971 if (verbosity > 1 ) {
39523972 FLOG (INFO) {
39533973 sb << " invalid inbound message: lt=" << kv->lt << " from=" << kv->source << " key=" << kv->key .to_hex ()
@@ -3970,6 +3990,9 @@ bool Collator::process_inbound_internal_messages() {
39703990 * @returns True if the processing was successful, false otherwise.
39713991 */
39723992bool Collator::process_inbound_external_messages () {
3993+ SCOPE_EXIT {
3994+ stats_.load_fraction_externals = block_limit_status_->load_fraction (block::ParamLimits::cl_soft);
3995+ };
39733996 if (skip_extmsg_) {
39743997 LOG (INFO) << " skipping processing of inbound external messages" ;
39753998 return true ;
@@ -4089,6 +4112,9 @@ int Collator::process_external_message(Ref<vm::Cell> msg) {
40894112 * @returns True if the processing was successful, false otherwise.
40904113 */
40914114bool Collator::process_dispatch_queue () {
4115+ SCOPE_EXIT {
4116+ stats_.load_fraction_dispatch = block_limit_status_->load_fraction (block::ParamLimits::cl_normal);
4117+ };
40924118 if (out_msg_queue_size_ > defer_out_queue_size_limit_ && old_out_msg_queue_size_ > hard_defer_out_queue_size_limit_) {
40934119 return true ;
40944120 }
@@ -4548,6 +4574,9 @@ bool Collator::enqueue_message(block::NewOutMsg msg, td::RefInt256 fwd_fees_rema
45484574 * @returns True if all new messages were processed successfully, false otherwise.
45494575 */
45504576bool Collator::process_new_messages (bool enqueue_only) {
4577+ SCOPE_EXIT {
4578+ stats_.load_fraction_new_msgs = block_limit_status_->load_fraction (block::ParamLimits::cl_normal);
4579+ };
45514580 while (!new_msgs.empty ()) {
45524581 block::NewOutMsg msg = new_msgs.top ();
45534582 new_msgs.pop ();
@@ -6380,6 +6409,7 @@ void Collator::finalize_stats() {
63806409 return 0 ;
63816410 });
63826411 }
6412+ stats_.new_out_msg_queue_size = out_msg_queue_size_;
63836413}
63846414
63856415/* *
0 commit comments