1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

optimistic out-msg-queue broadcast

This commit is contained in:
birydrad 2024-11-26 14:01:20 +04:00
parent 6df6f182bf
commit bf572f9599
24 changed files with 623 additions and 126 deletions

View file

@ -41,6 +41,7 @@ class OutMsgQueueImporter : public td::actor::Actor {
void new_masterchain_block_notification(td::Ref<MasterchainState> state, std::set<ShardIdFull> collating_shards);
void get_neighbor_msg_queue_proofs(ShardIdFull dst_shard, std::vector<BlockIdExt> blocks, td::Timestamp timeout,
td::Promise<std::map<BlockIdExt, td::Ref<OutMsgQueueProof>>> promise);
void add_out_msg_queue_proof(ShardIdFull dst_shard, td::Ref<OutMsgQueueProof> proof);
void update_options(td::Ref<ValidatorManagerOptions> opts) {
opts_ = std::move(opts);
@ -62,13 +63,28 @@ class OutMsgQueueImporter : public td::actor::Actor {
td::Timestamp timeout = td::Timestamp::never();
td::Timer timer;
size_t pending = 0;
size_t from_small_cache = 0;
size_t from_broadcast = 0;
size_t from_query = 0;
size_t from_local = 0;
};
std::map<std::pair<ShardIdFull, std::vector<BlockIdExt>>, std::shared_ptr<CacheEntry>> cache_;
// This cache has smaller granularity, proof is stored for each block separately
struct SmallCacheEntry {
td::Ref<OutMsgQueueProof> result;
std::vector<std::shared_ptr<CacheEntry>> pending_entries;
td::Timestamp timeout = td::Timestamp::never();
};
std::map<std::pair<ShardIdFull, BlockIdExt>, SmallCacheEntry> small_cache_;
void get_proof_local(std::shared_ptr<CacheEntry> entry, BlockIdExt block);
void get_proof_import(std::shared_ptr<CacheEntry> entry, std::vector<BlockIdExt> blocks,
block::ImportedMsgQueueLimits limits);
void got_proof(std::shared_ptr<CacheEntry> entry, std::vector<td::Ref<OutMsgQueueProof>> proofs);
enum class ProofSource {
SmallCache, Broadcast, Query, Local
};
void got_proof(std::shared_ptr<CacheEntry> entry, std::vector<td::Ref<OutMsgQueueProof>> proofs, ProofSource proof_source);
void finish_query(std::shared_ptr<CacheEntry> entry);
bool check_timeout(std::shared_ptr<CacheEntry> entry);