1
0
Fork 0
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:
SpyCheese 2023-05-10 12:57:57 +03:00 committed by GitHub
parent 7878578dba
commit 5abfe2337e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 1417 additions and 1303 deletions

View file

@ -74,6 +74,8 @@ class ValidatorSessionImpl : public ValidatorSession {
td::BufferSlice signature_;
std::map<ValidatorSessionCandidateId, tl_object_ptr<ton_api::validatorSession_candidate>> blocks_;
// src_round_candidate_[src_id][round] -> candidate id
std::vector<std::map<td::uint32, ValidatorSessionCandidateId>> src_round_candidate_;
catchain::CatChainSessionId unique_hash_;
@ -110,7 +112,8 @@ class ValidatorSessionImpl : public ValidatorSession {
td::actor::send_closure(id_, &ValidatorSessionImpl::preprocess_block, block);
}
void process_broadcast(const PublicKeyHash &src, td::BufferSlice data) override {
td::actor::send_closure(id_, &ValidatorSessionImpl::process_broadcast, src, std::move(data));
td::actor::send_closure(id_, &ValidatorSessionImpl::process_broadcast, src, std::move(data),
td::optional<ValidatorSessionCandidateId>(), true);
}
void process_message(const PublicKeyHash &src, td::BufferSlice data) override {
td::actor::send_closure(id_, &ValidatorSessionImpl::process_message, src, std::move(data));
@ -174,7 +177,9 @@ class ValidatorSessionImpl : public ValidatorSession {
void process_blocks(std::vector<catchain::CatChainBlock *> blocks);
void finished_processing();
void preprocess_block(catchain::CatChainBlock *block);
void process_broadcast(PublicKeyHash src, td::BufferSlice data);
bool ensure_candidate_unique(td::uint32 src_idx, td::uint32 round, ValidatorSessionCandidateId block_id);
void process_broadcast(PublicKeyHash src, td::BufferSlice data, td::optional<ValidatorSessionCandidateId> expected_id,
bool is_overlay_broadcast);
void process_message(PublicKeyHash src, td::BufferSlice data);
void process_query(PublicKeyHash src, td::BufferSlice data, td::Promise<td::BufferSlice> promise);
@ -206,6 +211,8 @@ class ValidatorSessionImpl : public ValidatorSession {
static const size_t MAX_REJECT_REASON_SIZE = 1024;
static const td::int32 MAX_FUTURE_ROUND_BLOCK = 100;
static const td::int32 MAX_PAST_ROUND_BLOCK = 20;
constexpr static const double REQUEST_BROADCAST_P2P_DELAY = 2.0;
static const td::uint32 MAX_CANDIDATE_EXTRA_SIZE = 1024;
};
} // namespace validatorsession