mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Improve validator session stats (#1117)
* Improve validator session stats * Collator stats: block limits, number of processed external messages * Collator and validator work time * Last key block seqno * Approvers and signers * End validator session stats
This commit is contained in:
parent
b70090dae3
commit
dc26c3be67
21 changed files with 373 additions and 27 deletions
|
@ -77,6 +77,8 @@ struct ValidatorSessionStats {
|
|||
ValidatorSessionCandidateId candidate_id = ValidatorSessionCandidateId::zero();
|
||||
int block_status = status_none;
|
||||
double block_timestamp = -1.0;
|
||||
td::Bits256 root_hash = td::Bits256::zero();
|
||||
td::Bits256 file_hash = td::Bits256::zero();
|
||||
std::string comment;
|
||||
|
||||
bool is_accepted = false;
|
||||
|
@ -159,11 +161,23 @@ struct NewValidatorGroupStats {
|
|||
ValidatorSessionId session_id = ValidatorSessionId::zero();
|
||||
ShardIdFull shard{masterchainId};
|
||||
CatchainSeqno cc_seqno = 0;
|
||||
BlockSeqno last_key_block_seqno = 0;
|
||||
double timestamp = -1.0;
|
||||
td::uint32 self_idx = 0;
|
||||
std::vector<Node> nodes;
|
||||
};
|
||||
|
||||
struct EndValidatorGroupStats {
|
||||
struct Node {
|
||||
PublicKeyHash id = PublicKeyHash::zero();
|
||||
td::uint32 catchain_blocks = 0;
|
||||
};
|
||||
|
||||
ValidatorSessionId session_id = ValidatorSessionId::zero();
|
||||
double timestamp = -1.0;
|
||||
std::vector<Node> nodes;
|
||||
};
|
||||
|
||||
} // namespace validatorsession
|
||||
|
||||
} // namespace ton
|
||||
|
|
|
@ -270,6 +270,8 @@ void ValidatorSessionImpl::process_broadcast(PublicKeyHash src, td::BufferSlice
|
|||
}
|
||||
stat->deserialize_time = deserialize_time;
|
||||
stat->serialized_size = data.size();
|
||||
stat->root_hash = candidate->root_hash_;
|
||||
stat->file_hash = file_hash;
|
||||
}
|
||||
|
||||
if ((td::int32)block_round < (td::int32)cur_round_ - MAX_PAST_ROUND_BLOCK ||
|
||||
|
@ -468,6 +470,8 @@ void ValidatorSessionImpl::generated_block(td::uint32 round, ValidatorSessionCan
|
|||
stat->collated_at = td::Clocks::system();
|
||||
stat->block_timestamp = td::Clocks::system();
|
||||
stat->collation_cached = collation_cached;
|
||||
stat->root_hash = root_hash;
|
||||
stat->file_hash = file_hash;
|
||||
}
|
||||
if (round != cur_round_) {
|
||||
return;
|
||||
|
@ -602,6 +606,8 @@ void ValidatorSessionImpl::try_approve_block(const SentBlock *block) {
|
|||
if (stat->block_timestamp <= 0.0) {
|
||||
stat->block_timestamp = td::Clocks::system();
|
||||
}
|
||||
stat->root_hash = B->root_hash_;
|
||||
stat->file_hash = td::sha256_bits256(B->data_);
|
||||
}
|
||||
|
||||
auto P = td::PromiseCreator::lambda([round = cur_round_, hash = block_id, root_hash = block->get_root_hash(),
|
||||
|
@ -997,6 +1003,29 @@ void ValidatorSessionImpl::get_current_stats(td::Promise<ValidatorSessionStats>
|
|||
promise.set_result(cur_stats_);
|
||||
}
|
||||
|
||||
void ValidatorSessionImpl::get_end_stats(td::Promise<EndValidatorGroupStats> promise) {
|
||||
if (!started_) {
|
||||
promise.set_error(td::Status::Error(ErrorCode::notready, "not started"));
|
||||
return;
|
||||
}
|
||||
EndValidatorGroupStats stats;
|
||||
stats.session_id = unique_hash_;
|
||||
stats.timestamp = td::Clocks::system();
|
||||
stats.nodes.resize(description().get_total_nodes());
|
||||
for (size_t i = 0; i < stats.nodes.size(); ++i) {
|
||||
stats.nodes[i].id = description().get_source_id(i);
|
||||
}
|
||||
td::actor::send_closure(catchain_, &catchain::CatChain::get_source_heights,
|
||||
[promise = std::move(promise),
|
||||
stats = std::move(stats)](td::Result<std::vector<catchain::CatChainBlockHeight>> R) mutable {
|
||||
TRY_RESULT_PROMISE(promise, heights, std::move(R));
|
||||
for (size_t i = 0; i < std::min(heights.size(), stats.nodes.size()); ++i) {
|
||||
stats.nodes[i].catchain_blocks = heights[i];
|
||||
}
|
||||
promise.set_result(std::move(stats));
|
||||
});
|
||||
}
|
||||
|
||||
void ValidatorSessionImpl::get_validator_group_info_for_litequery(
|
||||
td::uint32 cur_round,
|
||||
td::Promise<std::vector<tl_object_ptr<lite_api::liteServer_nonfinal_candidateInfo>>> promise) {
|
||||
|
|
|
@ -105,6 +105,7 @@ class ValidatorSession : public td::actor::Actor {
|
|||
virtual void start() = 0;
|
||||
virtual void destroy() = 0;
|
||||
virtual void get_current_stats(td::Promise<ValidatorSessionStats> promise) = 0;
|
||||
virtual void get_end_stats(td::Promise<EndValidatorGroupStats> promise) = 0;
|
||||
virtual void get_validator_group_info_for_litequery(
|
||||
td::uint32 cur_round,
|
||||
td::Promise<std::vector<tl_object_ptr<lite_api::liteServer_nonfinal_candidateInfo>>> promise) = 0;
|
||||
|
|
|
@ -187,6 +187,7 @@ class ValidatorSessionImpl : public ValidatorSession {
|
|||
void start() override;
|
||||
void destroy() override;
|
||||
void get_current_stats(td::Promise<ValidatorSessionStats> promise) override;
|
||||
void get_end_stats(td::Promise<EndValidatorGroupStats> promise) override;
|
||||
void get_validator_group_info_for_litequery(
|
||||
td::uint32 cur_round,
|
||||
td::Promise<std::vector<tl_object_ptr<lite_api::liteServer_nonfinal_candidateInfo>>> promise) override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue