mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Merge branch 'testnet' into block-generation
This commit is contained in:
commit
f4fd3ff3be
246 changed files with 7895 additions and 5430 deletions
|
@ -1,4 +1,4 @@
|
|||
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
|
||||
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
|
||||
|
||||
if (NOT OPENSSL_FOUND)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
|
|
|
@ -58,6 +58,7 @@ class ValidatorSessionDescriptionImpl : public ValidatorSessionDescription {
|
|||
};
|
||||
std::array<std::atomic<Cached>, cache_size> cache_;
|
||||
|
||||
public:
|
||||
class MemPool {
|
||||
public:
|
||||
explicit MemPool(size_t chunk_size);
|
||||
|
@ -71,6 +72,8 @@ class ValidatorSessionDescriptionImpl : public ValidatorSessionDescription {
|
|||
std::vector<td::uint8 *> data_;
|
||||
size_t ptr_ = 0;
|
||||
};
|
||||
|
||||
private:
|
||||
MemPool mem_perm_ = MemPool(mem_chunk_size_perm);
|
||||
MemPool mem_temp_ = MemPool(mem_chunk_size_temp);
|
||||
|
||||
|
|
|
@ -74,8 +74,10 @@ struct ValidatorSessionStats {
|
|||
|
||||
struct Producer {
|
||||
PublicKeyHash id = PublicKeyHash::zero();
|
||||
ValidatorSessionCandidateId candidate_id = ValidatorSessionCandidateId::zero();
|
||||
int block_status = status_none;
|
||||
td::uint64 block_timestamp = 0;
|
||||
std::string comment;
|
||||
};
|
||||
struct Round {
|
||||
td::uint64 timestamp = 0;
|
||||
|
@ -85,6 +87,9 @@ struct ValidatorSessionStats {
|
|||
td::uint32 first_round;
|
||||
std::vector<Round> rounds;
|
||||
|
||||
bool success = false;
|
||||
ValidatorSessionId session_id = ValidatorSessionId::zero();
|
||||
CatchainSeqno cc_seqno = 0;
|
||||
td::uint64 timestamp = 0;
|
||||
PublicKeyHash self = PublicKeyHash::zero();
|
||||
PublicKeyHash creator = PublicKeyHash::zero();
|
||||
|
|
|
@ -289,7 +289,7 @@ void ValidatorSessionImpl::process_broadcast(PublicKeyHash src, td::BufferSlice
|
|||
CHECK(!pending_reject_.count(block_id));
|
||||
CHECK(!rejected_.count(block_id));
|
||||
|
||||
stats_set_candidate_status(cur_round_, src, ValidatorSessionStats::status_received);
|
||||
stats_set_candidate_status(cur_round_, src, block_id, ValidatorSessionStats::status_received);
|
||||
auto v = virtual_state_->choose_blocks_to_approve(description(), local_idx());
|
||||
for (auto &b : v) {
|
||||
if (b && SentBlock::get_block_id(b) == block_id) {
|
||||
|
@ -362,7 +362,8 @@ void ValidatorSessionImpl::process_query(PublicKeyHash src, td::BufferSlice data
|
|||
|
||||
void ValidatorSessionImpl::candidate_decision_fail(td::uint32 round, ValidatorSessionCandidateId hash,
|
||||
std::string result, td::uint32 src, td::BufferSlice proof) {
|
||||
stats_set_candidate_status(round, description().get_source_id(src), ValidatorSessionStats::status_rejected);
|
||||
stats_set_candidate_status(round, description().get_source_id(src), hash, ValidatorSessionStats::status_rejected,
|
||||
result);
|
||||
if (round != cur_round_) {
|
||||
return;
|
||||
}
|
||||
|
@ -377,7 +378,8 @@ void ValidatorSessionImpl::candidate_decision_fail(td::uint32 round, ValidatorSe
|
|||
|
||||
void ValidatorSessionImpl::candidate_decision_ok(td::uint32 round, ValidatorSessionCandidateId hash, RootHash root_hash,
|
||||
FileHash file_hash, td::uint32 src, td::uint32 ok_from) {
|
||||
stats_set_candidate_status(round, description().get_source_id(src), ValidatorSessionStats::status_approved);
|
||||
stats_set_candidate_status(round, description().get_source_id(src), hash, ValidatorSessionStats::status_approved,
|
||||
PSTRING() << "ts=" << ok_from);
|
||||
if (round != cur_round_) {
|
||||
return;
|
||||
}
|
||||
|
@ -813,15 +815,13 @@ void ValidatorSessionImpl::on_new_round(td::uint32 round) {
|
|||
if (!have_block) {
|
||||
callback_->on_block_skipped(cur_round_);
|
||||
} else {
|
||||
cur_stats_.success = true;
|
||||
cur_stats_.timestamp = (td::uint64)td::Clocks::system();
|
||||
cur_stats_.total_validators = description().get_total_nodes();
|
||||
cur_stats_.total_weight = description().get_total_weight();
|
||||
cur_stats_.signatures = (td::uint32)export_sigs.size();
|
||||
cur_stats_.signatures_weight = signatures_weight;
|
||||
cur_stats_.approve_signatures = (td::uint32)export_approve_sigs.size();
|
||||
cur_stats_.approve_signatures_weight = approve_signatures_weight;
|
||||
cur_stats_.creator = description().get_source_id(block->get_src_idx());
|
||||
cur_stats_.self = description().get_source_id(local_idx());
|
||||
|
||||
if (it == blocks_.end()) {
|
||||
callback_->on_block_committed(cur_round_, description().get_source_public_key(block->get_src_idx()),
|
||||
|
@ -924,6 +924,12 @@ void ValidatorSessionImpl::destroy() {
|
|||
stop();
|
||||
}
|
||||
|
||||
void ValidatorSessionImpl::get_current_stats(td::Promise<ValidatorSessionStats> promise) {
|
||||
ValidatorSessionStats stats = cur_stats_;
|
||||
stats.timestamp = (td::uint64)td::Clocks::system();
|
||||
promise.set_result(std::move(stats));
|
||||
}
|
||||
|
||||
void ValidatorSessionImpl::start_up() {
|
||||
CHECK(!rldp_.empty());
|
||||
cur_round_ = 0;
|
||||
|
@ -942,6 +948,10 @@ void ValidatorSessionImpl::start_up() {
|
|||
void ValidatorSessionImpl::stats_init() {
|
||||
cur_stats_ = ValidatorSessionStats();
|
||||
cur_stats_.first_round = cur_round_;
|
||||
cur_stats_.session_id = unique_hash_;
|
||||
cur_stats_.total_validators = description().get_total_nodes();
|
||||
cur_stats_.total_weight = description().get_total_weight();
|
||||
cur_stats_.self = description().get_source_id(local_idx());
|
||||
stats_add_round();
|
||||
}
|
||||
|
||||
|
@ -962,20 +972,26 @@ void ValidatorSessionImpl::stats_add_round() {
|
|||
}
|
||||
}
|
||||
|
||||
void ValidatorSessionImpl::stats_set_candidate_status(td::uint32 round, PublicKeyHash src, int status) {
|
||||
void ValidatorSessionImpl::stats_set_candidate_status(td::uint32 round, PublicKeyHash src,
|
||||
ValidatorSessionCandidateId candidate_id, int status,
|
||||
std::string comment) {
|
||||
if (round < cur_stats_.first_round || round - cur_stats_.first_round >= cur_stats_.rounds.size()) {
|
||||
return;
|
||||
}
|
||||
auto& stats_round = cur_stats_.rounds[round - cur_stats_.first_round];
|
||||
auto &stats_round = cur_stats_.rounds[round - cur_stats_.first_round];
|
||||
auto it = std::find_if(stats_round.producers.begin(), stats_round.producers.end(),
|
||||
[&](const ValidatorSessionStats::Producer& p) { return p.id == src; });
|
||||
[&](const ValidatorSessionStats::Producer &p) { return p.id == src; });
|
||||
if (it == stats_round.producers.end()) {
|
||||
return;
|
||||
}
|
||||
it->candidate_id = candidate_id;
|
||||
if (it->block_status == ValidatorSessionStats::status_none) {
|
||||
it->block_timestamp = (td::uint64)td::Clocks::system();
|
||||
}
|
||||
it->block_status = status;
|
||||
if (!comment.empty()) {
|
||||
it->comment = std::move(comment);
|
||||
}
|
||||
}
|
||||
|
||||
void ValidatorSessionImpl::get_session_info(
|
||||
|
|
|
@ -91,6 +91,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_session_info(td::Promise<tl_object_ptr<ton_api::engine_validator_validatorSessionInfo>> promise) = 0;
|
||||
|
||||
|
|
|
@ -160,7 +160,8 @@ class ValidatorSessionImpl : public ValidatorSession {
|
|||
ValidatorSessionStats cur_stats_;
|
||||
void stats_init();
|
||||
void stats_add_round();
|
||||
void stats_set_candidate_status(td::uint32 round, PublicKeyHash src, int status);
|
||||
void stats_set_candidate_status(td::uint32 round, PublicKeyHash src, ValidatorSessionCandidateId candidate_id,
|
||||
int status, std::string comment = "");
|
||||
|
||||
void get_session_info(td::Promise<tl_object_ptr<ton_api::engine_validator_validatorSessionInfo>> promise) override;
|
||||
|
||||
|
@ -175,6 +176,7 @@ class ValidatorSessionImpl : public ValidatorSession {
|
|||
|
||||
void start() override;
|
||||
void destroy() override;
|
||||
void get_current_stats(td::Promise<ValidatorSessionStats> promise) override;
|
||||
|
||||
void process_blocks(std::vector<catchain::CatChainBlock *> blocks);
|
||||
void finished_processing();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue