mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Catchain improvements (#698)
* Fix "sgn" in fift; fix marking infinite loops as noterurn in func * TON-P1-1: Remove unused catchain queries * TON-P1-15: Avoid synchronization with self * TON-P1-3, TON-P1-17: Disallow more than one candidate per src per round (to prevent flood), add checks to process_broadcast * TON-P1-10: Fix fast/slow attempts * TON-P1-14: Add named constants * TON-P1-18, TON-P1-19: Alloc temporary memory in the same way as persistent memory * TON-P1-20: Add comment to choose_blocks_to_approve * TON-P1-16: Avoid creating two catchain blocks on need_new_block * TON-P1-8: Add some validation to validator-engine parameters * TON-P1-6: Don't allow sending the same block many times Many requests for the same block are not unusual (however, there's no need to answer them all) * TON-P1-2: Enable prohibiting dependencies from blamed nodes (2.7.5 in CatChain doc), fix processing blame proofs * Best practices bp-6: Fix incorrect warning bp-7: Remove unused code bp-8: Bring back PerfWarningTimer logging (only when no callback) bp-9: Remove unnecessary condition bp-11: Remove commented-out code bp-13: Divide code in validator-session-state Adherence to Specification: Fix typo
This commit is contained in:
parent
7878578dba
commit
5abfe2337e
27 changed files with 1417 additions and 1303 deletions
|
@ -60,15 +60,15 @@ td::Result<std::unique_ptr<CatChainReceiverSource>> CatChainReceiverSource::crea
|
|||
|
||||
void CatChainReceiverSourceImpl::blame(td::uint32 fork, CatChainBlockHeight height) {
|
||||
blame();
|
||||
if (!blamed_heights_.empty()) {
|
||||
if (blamed_heights_.size() <= fork) {
|
||||
blamed_heights_.resize(fork + 1, 0);
|
||||
}
|
||||
if (blamed_heights_[fork] == 0 || blamed_heights_[fork] > height) {
|
||||
VLOG(CATCHAIN_INFO) << this << ": blamed at " << fork << " " << height;
|
||||
blamed_heights_[fork] = height;
|
||||
}
|
||||
// if (!blamed_heights_.empty()) {
|
||||
if (blamed_heights_.size() <= fork) {
|
||||
blamed_heights_.resize(fork + 1, 0);
|
||||
}
|
||||
if (blamed_heights_[fork] == 0 || blamed_heights_[fork] > height) {
|
||||
VLOG(CATCHAIN_INFO) << this << ": blamed at " << fork << " " << height;
|
||||
blamed_heights_[fork] = height;
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
void CatChainReceiverSourceImpl::blame() {
|
||||
|
@ -144,7 +144,7 @@ void CatChainReceiverSourceImpl::on_new_block(CatChainReceivedBlock *block) {
|
|||
on_found_fork_proof(create_serialize_tl_object<ton_api::catchain_block_data_fork>(block->export_tl_dep(),
|
||||
it->second->export_tl_dep())
|
||||
.as_slice());
|
||||
chain_->add_prepared_event(fork_proof());
|
||||
chain_->on_found_fork_proof(id_, fork_proof());
|
||||
}
|
||||
blame();
|
||||
return;
|
||||
|
@ -162,6 +162,15 @@ void CatChainReceiverSourceImpl::on_found_fork_proof(const td::Slice &proof) {
|
|||
}
|
||||
}
|
||||
|
||||
bool CatChainReceiverSourceImpl::allow_send_block(CatChainBlockHash hash) {
|
||||
td::uint32 count = ++block_requests_count_[hash];
|
||||
if (count > MAX_BLOCK_REQUESTS) {
|
||||
VLOG(CATCHAIN_INFO) << this << ": node requested block " << hash << " " << count << " times";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace catchain
|
||||
|
||||
} // namespace ton
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue