mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
End validator session stats
This commit is contained in:
parent
0ca022cc72
commit
1b4fb42859
15 changed files with 97 additions and 3 deletions
|
@ -4119,6 +4119,8 @@ bool Collator::process_new_messages(bool enqueue_only) {
|
|||
} else if (res == 3) {
|
||||
LOG(INFO) << "All remaining new messages must be enqueued (BLOCK FULL)";
|
||||
enqueue_only = true;
|
||||
stats_.limits_log += PSTRING() << "NEW_MESSAGES: "
|
||||
<< block_full_comment(*block_limit_status_, block::ParamLimits::cl_normal) << "\n";
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -183,6 +183,7 @@ class ValidatorManager : public ValidatorManagerInterface {
|
|||
|
||||
virtual void log_validator_session_stats(BlockIdExt block_id, validatorsession::ValidatorSessionStats stats) = 0;
|
||||
virtual void log_new_validator_group_stats(validatorsession::NewValidatorGroupStats stats) = 0;
|
||||
virtual void log_end_validator_group_stats(validatorsession::EndValidatorGroupStats stats) = 0;
|
||||
|
||||
virtual void get_block_handle_for_litequery(BlockIdExt block_id, td::Promise<ConstBlockHandle> promise) = 0;
|
||||
virtual void get_block_data_for_litequery(BlockIdExt block_id, td::Promise<td::Ref<BlockData>> promise) = 0;
|
||||
|
|
|
@ -388,6 +388,9 @@ class ValidatorManagerImpl : public ValidatorManager {
|
|||
void log_new_validator_group_stats(validatorsession::NewValidatorGroupStats stats) override {
|
||||
UNREACHABLE();
|
||||
}
|
||||
void log_end_validator_group_stats(validatorsession::EndValidatorGroupStats stats) override {
|
||||
UNREACHABLE();
|
||||
}
|
||||
void get_out_msg_queue_size(BlockIdExt block_id, td::Promise<td::uint64> promise) override {
|
||||
if (queue_size_counter_.empty()) {
|
||||
queue_size_counter_ =
|
||||
|
|
|
@ -450,6 +450,9 @@ class ValidatorManagerImpl : public ValidatorManager {
|
|||
void log_new_validator_group_stats(validatorsession::NewValidatorGroupStats stats) override {
|
||||
UNREACHABLE();
|
||||
}
|
||||
void log_end_validator_group_stats(validatorsession::EndValidatorGroupStats stats) override {
|
||||
UNREACHABLE();
|
||||
}
|
||||
void get_out_msg_queue_size(BlockIdExt block_id, td::Promise<td::uint64> promise) override {
|
||||
if (queue_size_counter_.empty()) {
|
||||
queue_size_counter_ =
|
||||
|
|
|
@ -2902,7 +2902,31 @@ void ValidatorManagerImpl::log_new_validator_group_stats(validatorsession::NewVa
|
|||
file << s << "\n";
|
||||
file.close();
|
||||
|
||||
LOG(INFO) << "Writing new validator group stats for " << stats.shard.to_str();
|
||||
LOG(INFO) << "Writing new validator group stats for " << stats.session_id << " shard=" << stats.shard.to_str()
|
||||
<< " cc_seqno=" << stats.cc_seqno;
|
||||
}
|
||||
|
||||
void ValidatorManagerImpl::log_end_validator_group_stats(validatorsession::EndValidatorGroupStats stats) {
|
||||
std::string fname = opts_->get_session_logs_file();
|
||||
if (fname.empty()) {
|
||||
return;
|
||||
}
|
||||
std::vector<tl_object_ptr<ton_api::validatorSession_endValidatorGroupStats_node>> nodes;
|
||||
for (const auto &node : stats.nodes) {
|
||||
nodes.push_back(create_tl_object<ton_api::validatorSession_endValidatorGroupStats_node>(node.id.bits256_value(),
|
||||
node.catchain_blocks));
|
||||
}
|
||||
auto obj = create_tl_object<ton_api::validatorSession_endValidatorGroupStats>(stats.session_id, stats.timestamp,
|
||||
std::move(nodes));
|
||||
auto s = td::json_encode<std::string>(td::ToJson(*obj.get()), false);
|
||||
s.erase(std::remove_if(s.begin(), s.end(), [](char c) { return c == '\n' || c == '\r'; }), s.end());
|
||||
|
||||
std::ofstream file;
|
||||
file.open(fname, std::ios_base::app);
|
||||
file << s << "\n";
|
||||
file.close();
|
||||
|
||||
LOG(INFO) << "Writing end validator group stats for " << stats.session_id;
|
||||
}
|
||||
|
||||
void ValidatorManagerImpl::get_block_handle_for_litequery(BlockIdExt block_id, td::Promise<ConstBlockHandle> promise) {
|
||||
|
|
|
@ -590,6 +590,7 @@ class ValidatorManagerImpl : public ValidatorManager {
|
|||
|
||||
void log_validator_session_stats(BlockIdExt block_id, validatorsession::ValidatorSessionStats stats) override;
|
||||
void log_new_validator_group_stats(validatorsession::NewValidatorGroupStats stats) override;
|
||||
void log_end_validator_group_stats(validatorsession::EndValidatorGroupStats stats) override;
|
||||
|
||||
void update_options(td::Ref<ValidatorManagerOptions> opts) override;
|
||||
|
||||
|
|
|
@ -418,6 +418,16 @@ void ValidatorGroup::destroy() {
|
|||
td::actor::send_closure(manager, &ValidatorManager::log_validator_session_stats, block_id,
|
||||
std::move(stats));
|
||||
});
|
||||
td::actor::send_closure(session_, &validatorsession::ValidatorSession::get_end_stats,
|
||||
[manager = manager_](td::Result<validatorsession::EndValidatorGroupStats> R) {
|
||||
if (R.is_error()) {
|
||||
LOG(DEBUG) << "Failed to get validator session end stats: " << R.move_as_error();
|
||||
return;
|
||||
}
|
||||
auto stats = R.move_as_ok();
|
||||
td::actor::send_closure(manager, &ValidatorManager::log_end_validator_group_stats,
|
||||
std::move(stats));
|
||||
});
|
||||
auto ses = session_.release();
|
||||
delay_action([ses]() mutable { td::actor::send_closure(ses, &validatorsession::ValidatorSession::destroy); },
|
||||
td::Timestamp::in(10.0));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue