mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Dynamic catchain delays, state serialization improvements (#1140)
* Validator improvements * Fix cancelling state serialization * Disable state serializer on all mainnet validators * Flag --catchain-max-block-delay-slow * Set default catchain-max-block-delay to 0.4, delay-slow to 1.0 --------- Co-authored-by: SpyCheese <mikle98@yandex.ru>
This commit is contained in:
parent
97c57c3386
commit
e08111159f
15 changed files with 85 additions and 28 deletions
|
@ -813,13 +813,25 @@ void ValidatorSessionImpl::request_new_block(bool now) {
|
|||
} else {
|
||||
double lambda = 10.0 / description().get_total_nodes();
|
||||
double x = -1 / lambda * log(td::Random::fast(1, 999) * 0.001);
|
||||
if (x > catchain_max_block_delay_) { // default = 0.5
|
||||
x = catchain_max_block_delay_;
|
||||
}
|
||||
x = std::min(x, get_current_max_block_delay()); // default = 0.4
|
||||
td::actor::send_closure(catchain_, &catchain::CatChain::need_new_block, td::Timestamp::in(x));
|
||||
}
|
||||
}
|
||||
|
||||
double ValidatorSessionImpl::get_current_max_block_delay() const {
|
||||
td::uint32 att = real_state_->cur_attempt_in_round(*description_);
|
||||
td::uint32 att1 = description_->opts().max_round_attempts;
|
||||
if (att <= att1) {
|
||||
return catchain_max_block_delay_;
|
||||
}
|
||||
td::uint32 att2 = att1 + 4;
|
||||
if (att >= att2) {
|
||||
return catchain_max_block_delay_slow_;
|
||||
}
|
||||
return catchain_max_block_delay_ +
|
||||
(catchain_max_block_delay_slow_ - catchain_max_block_delay_) * (double)(att - att1) / (double)(att2 - att1);
|
||||
}
|
||||
|
||||
void ValidatorSessionImpl::on_new_round(td::uint32 round) {
|
||||
if (round != 0) {
|
||||
CHECK(cur_round_ < round);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue