mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Remove unused priority_broadcast_receivers
This commit is contained in:
parent
747b24aa18
commit
e575d27302
17 changed files with 16 additions and 124 deletions
|
@ -782,7 +782,7 @@ misbehaviour_punishment_config_v1#01
|
|||
_ MisbehaviourPunishmentConfig = ConfigParam 40;
|
||||
|
||||
// collator_nodes: each collator is (workchain:int32 shard:uint64 adnl_id:uint256)
|
||||
collator_info#0 full_node_id:(Maybe uint256) = CollatorInfo;
|
||||
collator_info#00 = CollatorInfo;
|
||||
colator_config#a0 full_collated_data:Bool collator_nodes:(HashmapE 352 CollatorInfo) = CollatorConfig;
|
||||
_ CollatorConfig = ConfigParam 41;
|
||||
|
||||
|
|
|
@ -2333,12 +2333,7 @@ CollatorConfig Config::get_collator_config(bool need_collator_nodes) const {
|
|||
td::uint64 shard = key.get_uint(64);
|
||||
key.advance(64);
|
||||
td::Bits256 adnl_id(key);
|
||||
td::Bits256 full_node_id = td::Bits256::zero();
|
||||
gen::CollatorInfo::Record info;
|
||||
if (tlb::csr_unpack(std::move(value), info) && info.full_node_id->size() == 257) {
|
||||
full_node_id = td::Bits256(info.full_node_id->data_bits() + 1);
|
||||
}
|
||||
collator_config.collator_nodes.push_back({ton::ShardIdFull(workchain, shard), adnl_id, full_node_id});
|
||||
collator_config.collator_nodes.push_back({ton::ShardIdFull(workchain, shard), adnl_id});
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -529,7 +529,6 @@ struct BurningConfig {
|
|||
struct CollatorNodeDescr {
|
||||
ton::ShardIdFull shard;
|
||||
ton::NodeIdShort adnl_id;
|
||||
ton::NodeIdShort full_node_id;
|
||||
};
|
||||
|
||||
struct CollatorConfig {
|
||||
|
|
|
@ -68,11 +68,7 @@ td::Status BroadcastSimple::run_checks() {
|
|||
|
||||
td::Status BroadcastSimple::distribute() {
|
||||
auto B = serialize();
|
||||
auto nodes = overlay_->get_neighbours(5);
|
||||
if (is_ours_) {
|
||||
auto priority_nodes = overlay_->get_priority_broadcast_receivers(3);
|
||||
nodes.insert(nodes.end(), priority_nodes.begin(), priority_nodes.end());
|
||||
}
|
||||
auto nodes = overlay_->get_neighbours(3);
|
||||
|
||||
auto manager = overlay_->overlay_manager();
|
||||
for (auto &n : nodes) {
|
||||
|
@ -144,7 +140,7 @@ td::Status BroadcastSimple::create_new(td::actor::ActorId<OverlayImpl> overlay,
|
|||
auto date = static_cast<td::uint32>(td::Clocks::system());
|
||||
|
||||
auto B = std::make_unique<BroadcastSimple>(broadcast_hash, PublicKey{}, nullptr, flags, std::move(data), date,
|
||||
td::BufferSlice{}, false, nullptr, adnl::AdnlNodeIdShort::zero(), true);
|
||||
td::BufferSlice{}, false, nullptr, adnl::AdnlNodeIdShort::zero());
|
||||
|
||||
auto to_sign = B->to_sign();
|
||||
auto P = td::PromiseCreator::lambda(
|
||||
|
|
|
@ -46,7 +46,6 @@ class BroadcastSimple : public td::ListNode {
|
|||
td::uint32 date_;
|
||||
td::BufferSlice signature_;
|
||||
bool is_valid_{false};
|
||||
bool is_ours_{false};
|
||||
|
||||
OverlayImpl *overlay_;
|
||||
|
||||
|
@ -64,7 +63,7 @@ class BroadcastSimple : public td::ListNode {
|
|||
public:
|
||||
BroadcastSimple(Overlay::BroadcastHash broadcast_hash, PublicKey source, std::shared_ptr<Certificate> cert,
|
||||
td::uint32 flags, td::BufferSlice data, td::uint32 date, td::BufferSlice signature, bool is_valid,
|
||||
OverlayImpl *overlay, adnl::AdnlNodeIdShort src_peer_id, bool is_ours = false)
|
||||
OverlayImpl *overlay, adnl::AdnlNodeIdShort src_peer_id)
|
||||
: broadcast_hash_(broadcast_hash)
|
||||
, source_(std::move(source))
|
||||
, cert_(std::move(cert))
|
||||
|
@ -73,7 +72,6 @@ class BroadcastSimple : public td::ListNode {
|
|||
, date_(date)
|
||||
, signature_(std::move(signature))
|
||||
, is_valid_(is_valid)
|
||||
, is_ours_(is_ours)
|
||||
, overlay_(overlay)
|
||||
, src_peer_id_(src_peer_id) {
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ namespace overlay {
|
|||
|
||||
td::Result<std::unique_ptr<BroadcastFec>> BroadcastFec::create(Overlay::BroadcastHash hash, PublicKey src,
|
||||
Overlay::BroadcastDataHash data_hash, td::uint32 flags,
|
||||
td::uint32 date, fec::FecType fec_type, bool is_ours) {
|
||||
auto F = std::make_unique<BroadcastFec>(hash, std::move(src), data_hash, flags, date, std::move(fec_type), is_ours);
|
||||
td::uint32 date, fec::FecType fec_type) {
|
||||
auto F = std::make_unique<BroadcastFec>(hash, std::move(src), data_hash, flags, date, std::move(fec_type));
|
||||
TRY_STATUS(F->run_checks());
|
||||
TRY_STATUS(F->init_fec_type());
|
||||
return std::move(F);
|
||||
|
@ -94,12 +94,12 @@ void BroadcastFec::broadcast_checked(td::Result<td::Unit> R) {
|
|||
overlay_->deliver_broadcast(get_source().compute_short_id(), data_.clone());
|
||||
auto manager = overlay_->overlay_manager();
|
||||
while (!parts_.empty()) {
|
||||
distribute_part(parts_.begin()->first);
|
||||
distribute_part(parts_.begin()->first);
|
||||
}
|
||||
}
|
||||
|
||||
// Do we need status here??
|
||||
td::Status BroadcastFec::distribute_part(td::uint32 seqno) {
|
||||
td::Status BroadcastFec::distribute_part(td::uint32 seqno) {
|
||||
auto i = parts_.find(seqno);
|
||||
if (i == parts_.end()) {
|
||||
// should not get here
|
||||
|
@ -111,12 +111,8 @@ td::Status BroadcastFec::distribute_part(td::uint32 seqno) {
|
|||
td::BufferSlice data = std::move(tls.second);
|
||||
|
||||
auto nodes = overlay_->get_neighbours(5);
|
||||
if (is_ours_) {
|
||||
auto priority_nodes = overlay_->get_priority_broadcast_receivers(3);
|
||||
nodes.insert(nodes.end(), priority_nodes.begin(), priority_nodes.end());
|
||||
}
|
||||
|
||||
auto manager = overlay_->overlay_manager();
|
||||
|
||||
for (auto &n : nodes) {
|
||||
if (neighbour_completed(n)) {
|
||||
continue;
|
||||
|
@ -144,8 +140,7 @@ td::Status OverlayFecBroadcastPart::apply() {
|
|||
if (is_short_) {
|
||||
return td::Status::Error(ErrorCode::protoviolation, "short broadcast part for incomplete broadcast");
|
||||
}
|
||||
TRY_RESULT(
|
||||
B, BroadcastFec::create(broadcast_hash_, source_, broadcast_data_hash_, flags_, date_, fec_type_, is_ours_));
|
||||
TRY_RESULT(B, BroadcastFec::create(broadcast_hash_, source_, broadcast_data_hash_, flags_, date_, fec_type_));
|
||||
bcast_ = B.get();
|
||||
overlay_->register_fec_broadcast(std::move(B));
|
||||
}
|
||||
|
@ -309,8 +304,7 @@ td::Status OverlayFecBroadcastPart::create_new(OverlayImpl *overlay, td::actor::
|
|||
|
||||
auto B = std::make_unique<OverlayFecBroadcastPart>(
|
||||
broadcast_hash, part_hash, PublicKey{}, overlay->get_certificate(local_id), data_hash, size, flags,
|
||||
part_data_hash, std::move(part), seqno, std::move(fec_type), date, td::BufferSlice{}, false, nullptr, overlay,
|
||||
adnl::AdnlNodeIdShort::zero(), true);
|
||||
part_data_hash, std::move(part), seqno, std::move(fec_type), date, td::BufferSlice{}, false, nullptr, overlay, adnl::AdnlNodeIdShort::zero());
|
||||
auto to_sign = B->to_sign();
|
||||
|
||||
auto P = td::PromiseCreator::lambda(
|
||||
|
|
|
@ -131,19 +131,18 @@ class BroadcastFec : public td::ListNode {
|
|||
td::Status run_checks();
|
||||
|
||||
BroadcastFec(Overlay::BroadcastHash hash, PublicKey src, Overlay::BroadcastDataHash data_hash, td::uint32 flags,
|
||||
td::uint32 date, fec::FecType fec_type, bool is_ours = false)
|
||||
td::uint32 date, fec::FecType fec_type)
|
||||
: hash_(hash)
|
||||
, data_hash_(data_hash)
|
||||
, flags_(flags)
|
||||
, date_(date)
|
||||
, src_(std::move(src))
|
||||
, fec_type_(std::move(fec_type))
|
||||
, is_ours_(is_ours) {
|
||||
, fec_type_(std::move(fec_type)) {
|
||||
}
|
||||
|
||||
static td::Result<std::unique_ptr<BroadcastFec>> create(Overlay::BroadcastHash hash, PublicKey src,
|
||||
Overlay::BroadcastDataHash data_hash, td::uint32 flags,
|
||||
td::uint32 date, fec::FecType fec_type, bool is_ours);
|
||||
td::uint32 date, fec::FecType fec_type);
|
||||
|
||||
bool neighbour_received(adnl::AdnlNodeIdShort id) const {
|
||||
return received_neighbours_.find(id) != received_neighbours_.end();
|
||||
|
@ -226,7 +225,6 @@ class BroadcastFec : public td::ListNode {
|
|||
OverlayImpl *overlay_;
|
||||
adnl::AdnlNodeIdShort src_peer_id_ = adnl::AdnlNodeIdShort::zero();
|
||||
td::BufferSlice data_;
|
||||
bool is_ours_ = false;
|
||||
};
|
||||
|
||||
class OverlayFecBroadcastPart : public td::ListNode {
|
||||
|
@ -248,7 +246,6 @@ class OverlayFecBroadcastPart : public td::ListNode {
|
|||
|
||||
bool is_short_;
|
||||
bool untrusted_{false};
|
||||
bool is_ours_;
|
||||
|
||||
BroadcastFec *bcast_;
|
||||
OverlayImpl *overlay_;
|
||||
|
@ -268,8 +265,7 @@ class OverlayFecBroadcastPart : public td::ListNode {
|
|||
std::shared_ptr<Certificate> cert, Overlay::BroadcastDataHash data_hash, td::uint32 data_size,
|
||||
td::uint32 flags, Overlay::BroadcastDataHash part_data_hash, td::BufferSlice data,
|
||||
td::uint32 seqno, fec::FecType fec_type, td::uint32 date, td::BufferSlice signature,
|
||||
bool is_short, BroadcastFec *bcast, OverlayImpl *overlay, adnl::AdnlNodeIdShort src_peer_id,
|
||||
bool is_ours = false)
|
||||
bool is_short, BroadcastFec *bcast, OverlayImpl *overlay, adnl::AdnlNodeIdShort src_peer_id)
|
||||
: broadcast_hash_(broadcast_hash)
|
||||
, part_hash_(part_hash)
|
||||
, source_(std::move(source))
|
||||
|
@ -284,7 +280,6 @@ class OverlayFecBroadcastPart : public td::ListNode {
|
|||
, date_(date)
|
||||
, signature_(std::move(signature))
|
||||
, is_short_(is_short)
|
||||
, is_ours_(is_ours)
|
||||
, bcast_(bcast)
|
||||
, overlay_(overlay)
|
||||
, src_peer_id_(src_peer_id) {
|
||||
|
|
|
@ -350,19 +350,6 @@ void OverlayManager::get_stats(td::Promise<tl_object_ptr<ton_api::engine_validat
|
|||
td::actor::send_closure(act, &Cb::decr_pending);
|
||||
}
|
||||
|
||||
void OverlayManager::set_priority_broadcast_receivers(adnl::AdnlNodeIdShort local_id, OverlayIdShort overlay,
|
||||
std::vector<adnl::AdnlNodeIdShort> nodes) {
|
||||
auto it = overlays_.find(local_id);
|
||||
if (it == overlays_.end()) {
|
||||
return;
|
||||
}
|
||||
auto it2 = it->second.find(overlay);
|
||||
if (it2 == it->second.end()) {
|
||||
return;
|
||||
}
|
||||
td::actor::send_closure(it2->second, &Overlay::set_priority_broadcast_receivers, std::move(nodes));
|
||||
}
|
||||
|
||||
void OverlayManager::forget_peer(adnl::AdnlNodeIdShort local_id, OverlayIdShort overlay,
|
||||
adnl::AdnlNodeIdShort peer_id) {
|
||||
auto it = overlays_.find(local_id);
|
||||
|
|
|
@ -96,8 +96,6 @@ class OverlayManager : public Overlays {
|
|||
td::actor::ActorOwn<Overlay> overlay);
|
||||
void get_stats(td::Promise<tl_object_ptr<ton_api::engine_validator_overlaysStats>> promise) override;
|
||||
|
||||
void set_priority_broadcast_receivers(adnl::AdnlNodeIdShort local_id, OverlayIdShort overlay,
|
||||
std::vector<adnl::AdnlNodeIdShort> nodes) override;
|
||||
void forget_peer(adnl::AdnlNodeIdShort local_id, OverlayIdShort overlay, adnl::AdnlNodeIdShort peer_id) override;
|
||||
|
||||
struct PrintId {};
|
||||
|
|
|
@ -69,7 +69,6 @@ class Overlay : public td::actor::Actor {
|
|||
virtual void update_peer_ip_str(adnl::AdnlNodeIdShort peer_id, td::string ip_str) = 0;
|
||||
//virtual void receive_broadcast(td::BufferSlice data) = 0;
|
||||
//virtual void subscribe(std::unique_ptr<Overlays::Callback> callback) = 0;
|
||||
virtual void set_priority_broadcast_receivers(std::vector<adnl::AdnlNodeIdShort> nodes) = 0;
|
||||
virtual void forget_peer(adnl::AdnlNodeIdShort peer_id) = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -216,18 +216,6 @@ class OverlayImpl : public Overlay {
|
|||
return vec;
|
||||
}
|
||||
}
|
||||
std::vector<adnl::AdnlNodeIdShort> get_priority_broadcast_receivers(td::uint32 max_size = 0) const {
|
||||
if (max_size == 0 || max_size >= priority_broadcast_receivers_.size()) {
|
||||
return priority_broadcast_receivers_;
|
||||
} else {
|
||||
std::vector<adnl::AdnlNodeIdShort> vec;
|
||||
for (td::uint32 i = 0; i < max_size; i++) {
|
||||
vec.push_back(priority_broadcast_receivers_[td::Random::fast(
|
||||
0, static_cast<td::int32>(priority_broadcast_receivers_.size()) - 1)]);
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
}
|
||||
td::actor::ActorId<OverlayManager> overlay_manager() const {
|
||||
return manager_;
|
||||
}
|
||||
|
@ -281,10 +269,6 @@ class OverlayImpl : public Overlay {
|
|||
}
|
||||
}
|
||||
|
||||
void set_priority_broadcast_receivers(std::vector<adnl::AdnlNodeIdShort> nodes) override {
|
||||
priority_broadcast_receivers_ = std::move(nodes);
|
||||
}
|
||||
|
||||
void forget_peer(adnl::AdnlNodeIdShort peer_id) override {
|
||||
del_peer(peer_id);
|
||||
}
|
||||
|
@ -364,7 +348,6 @@ class OverlayImpl : public Overlay {
|
|||
std::queue<BroadcastHash> bcast_lru_;
|
||||
|
||||
std::map<BroadcastHash, td::actor::ActorOwn<OverlayOutboundFecBroadcast>> out_fec_bcasts_;
|
||||
std::vector<adnl::AdnlNodeIdShort> priority_broadcast_receivers_;
|
||||
|
||||
void bcast_gc();
|
||||
|
||||
|
|
|
@ -250,8 +250,6 @@ class Overlays : public td::actor::Actor {
|
|||
td::Promise<std::vector<adnl::AdnlNodeIdShort>> promise) = 0;
|
||||
virtual void get_stats(td::Promise<tl_object_ptr<ton_api::engine_validator_overlaysStats>> promise) = 0;
|
||||
|
||||
virtual void set_priority_broadcast_receivers(adnl::AdnlNodeIdShort local_id, OverlayIdShort overlay,
|
||||
std::vector<adnl::AdnlNodeIdShort> nodes) = 0;
|
||||
virtual void forget_peer(adnl::AdnlNodeIdShort local_id, OverlayIdShort overlay, adnl::AdnlNodeIdShort peer_id) = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -124,10 +124,6 @@ void FullNodeShardImpl::create_overlay() {
|
|||
if (cert_) {
|
||||
td::actor::send_closure(overlays_, &overlay::Overlays::update_certificate, adnl_id_, overlay_id_, local_id_, cert_);
|
||||
}
|
||||
if (!collator_nodes_.empty()) {
|
||||
td::actor::send_closure(overlays_, &overlay::Overlays::set_priority_broadcast_receivers, adnl_id_, overlay_id_,
|
||||
collator_nodes_);
|
||||
}
|
||||
}
|
||||
|
||||
void FullNodeShardImpl::check_broadcast(PublicKeyHash src, td::BufferSlice broadcast, td::Promise<td::Unit> promise) {
|
||||
|
@ -1141,15 +1137,6 @@ void FullNodeShardImpl::update_validators(std::vector<PublicKeyHash> public_key_
|
|||
}
|
||||
}
|
||||
|
||||
void FullNodeShardImpl::update_collators(std::vector<adnl::AdnlNodeIdShort> nodes) {
|
||||
if (!client_.empty()) {
|
||||
return;
|
||||
}
|
||||
collator_nodes_ = std::move(nodes);
|
||||
td::actor::send_closure(overlays_, &overlay::Overlays::set_priority_broadcast_receivers, adnl_id_, overlay_id_,
|
||||
collator_nodes_);
|
||||
}
|
||||
|
||||
void FullNodeShardImpl::reload_neighbours() {
|
||||
auto P = td::PromiseCreator::lambda([SelfId = actor_id(this)](td::Result<std::vector<adnl::AdnlNodeIdShort>> R) {
|
||||
if (R.is_error()) {
|
||||
|
|
|
@ -77,7 +77,6 @@ class FullNodeShard : public td::actor::Actor {
|
|||
virtual void set_handle(BlockHandle handle, td::Promise<td::Unit> promise) = 0;
|
||||
|
||||
virtual void update_validators(std::vector<PublicKeyHash> public_key_hashes, PublicKeyHash local_hash) = 0;
|
||||
virtual void update_collators(std::vector<adnl::AdnlNodeIdShort> nodes) = 0;
|
||||
|
||||
static td::actor::ActorOwn<FullNodeShard> create(
|
||||
ShardIdFull shard, PublicKeyHash local_id, adnl::AdnlNodeIdShort adnl_id, FileHash zero_state_file_hash,
|
||||
|
|
|
@ -199,7 +199,6 @@ class FullNodeShardImpl : public FullNodeShard {
|
|||
void alarm() override;
|
||||
|
||||
void update_validators(std::vector<PublicKeyHash> public_key_hashes, PublicKeyHash local_hash) override;
|
||||
void update_collators(std::vector<adnl::AdnlNodeIdShort> nodes) override;
|
||||
|
||||
void sign_overlay_certificate(PublicKeyHash signed_key, td::uint32 expiry_at, td::uint32 max_size, td::Promise<td::BufferSlice> promise) override;
|
||||
void import_overlay_certificate(PublicKeyHash signed_key, std::shared_ptr<ton::overlay::Certificate> cert, td::Promise<td::Unit> promise) override;
|
||||
|
@ -278,7 +277,6 @@ class FullNodeShardImpl : public FullNodeShard {
|
|||
adnl::AdnlNodeIdShort last_pinged_neighbour_ = adnl::AdnlNodeIdShort::zero();
|
||||
|
||||
FullNodeShardMode mode_;
|
||||
std::vector<adnl::AdnlNodeIdShort> collator_nodes_;
|
||||
|
||||
FullNodeConfig config_;
|
||||
|
||||
|
|
|
@ -218,33 +218,6 @@ void FullNodeImpl::update_shard_configuration(td::Ref<MasterchainState> state, s
|
|||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
if (!collators_inited_ || state->is_key_state()) {
|
||||
update_collators(state);
|
||||
}
|
||||
}
|
||||
|
||||
void FullNodeImpl::update_collators(td::Ref<MasterchainState> state) {
|
||||
collators_inited_ = true;
|
||||
collator_config_ = state->get_collator_config(true);
|
||||
for (auto& s : shards_) {
|
||||
update_shard_collators(s.first, s.second);
|
||||
}
|
||||
}
|
||||
|
||||
void FullNodeImpl::update_shard_collators(ShardIdFull shard, ShardInfo& info) {
|
||||
if (info.actor.empty()) {
|
||||
return;
|
||||
}
|
||||
std::vector<adnl::AdnlNodeIdShort> nodes;
|
||||
for (const block::CollatorNodeDescr& desc : collator_config_.collator_nodes) {
|
||||
if (!desc.full_node_id.is_zero() && shard_intersects(shard, desc.shard)) {
|
||||
nodes.emplace_back(desc.full_node_id);
|
||||
}
|
||||
}
|
||||
std::sort(nodes.begin(), nodes.end());
|
||||
nodes.erase(std::unique(nodes.begin(), nodes.end()), nodes.end());
|
||||
td::actor::send_closure(info.actor, &FullNodeShard::update_collators, std::move(nodes));
|
||||
}
|
||||
|
||||
void FullNodeImpl::add_shard_actor(ShardIdFull shard, FullNodeShardMode mode) {
|
||||
|
@ -259,9 +232,6 @@ void FullNodeImpl::add_shard_actor(ShardIdFull shard, FullNodeShardMode mode) {
|
|||
if (all_validators_.size() > 0) {
|
||||
td::actor::send_closure(info.actor, &FullNodeShard::update_validators, all_validators_, sign_cert_by_);
|
||||
}
|
||||
if (collators_inited_) {
|
||||
update_shard_collators(shard, info);
|
||||
}
|
||||
}
|
||||
|
||||
void FullNodeImpl::sync_completed() {
|
||||
|
|
|
@ -102,8 +102,6 @@ class FullNodeImpl : public FullNode {
|
|||
};
|
||||
|
||||
void add_shard_actor(ShardIdFull shard, FullNodeShardMode mode);
|
||||
void update_collators(td::Ref<MasterchainState> state);
|
||||
void update_shard_collators(ShardIdFull shard, ShardInfo& info);
|
||||
|
||||
PublicKeyHash local_id_;
|
||||
adnl::AdnlNodeIdShort adnl_id_;
|
||||
|
@ -131,8 +129,6 @@ class FullNodeImpl : public FullNode {
|
|||
std::set<PublicKeyHash> local_keys_;
|
||||
|
||||
td::Promise<td::Unit> started_promise_;
|
||||
bool collators_inited_ = false;
|
||||
block::CollatorConfig collator_config_;
|
||||
FullNodeConfig config_;
|
||||
|
||||
std::map<PublicKeyHash, td::actor::ActorOwn<FullNodePrivateOverlay>> private_block_overlays_;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue