diff --git a/validator/full-node-shard.cpp b/validator/full-node-shard.cpp index fbdbbfd7a..72d144ff6 100644 --- a/validator/full-node-shard.cpp +++ b/validator/full-node-shard.cpp @@ -712,10 +712,12 @@ void FullNodeShardImpl::send_ihr_message(td::BufferSlice data) { auto B = create_serialize_tl_object( create_tl_object(std::move(data))); if (B.size() <= overlay::Overlays::max_simple_broadcast_size()) { - td::actor::send_closure(overlays_, &overlay::Overlays::send_broadcast_ex, adnl_id_, overlay_id_, local_id_, 0, + td::actor::send_closure(overlays_, &overlay::Overlays::send_broadcast_ex, adnl_id_, overlay_id_, + send_broadcast_as(), 0, std::move(B)); } else { - td::actor::send_closure(overlays_, &overlay::Overlays::send_broadcast_fec_ex, adnl_id_, overlay_id_, local_id_, 0, + td::actor::send_closure(overlays_, &overlay::Overlays::send_broadcast_fec_ex, adnl_id_, overlay_id_, + send_broadcast_as(), 0, std::move(B)); } } @@ -744,10 +746,12 @@ void FullNodeShardImpl::send_external_message(td::BufferSlice data) { auto B = create_serialize_tl_object( create_tl_object(std::move(data))); if (B.size() <= overlay::Overlays::max_simple_broadcast_size()) { - td::actor::send_closure(overlays_, &overlay::Overlays::send_broadcast_ex, adnl_id_, overlay_id_, local_id_, 0, + td::actor::send_closure(overlays_, &overlay::Overlays::send_broadcast_ex, adnl_id_, overlay_id_, + send_broadcast_as(), 0, std::move(B)); } else { - td::actor::send_closure(overlays_, &overlay::Overlays::send_broadcast_fec_ex, adnl_id_, overlay_id_, local_id_, 0, + td::actor::send_closure(overlays_, &overlay::Overlays::send_broadcast_fec_ex, adnl_id_, overlay_id_, + send_broadcast_as(), 0, std::move(B)); } } @@ -761,11 +765,11 @@ void FullNodeShardImpl::send_shard_block_info(BlockIdExt block_id, CatchainSeqno auto B = create_serialize_tl_object( create_tl_object(create_tl_block_id(block_id), cc_seqno, std::move(data))); if (B.size() <= overlay::Overlays::max_simple_broadcast_size()) { - td::actor::send_closure(overlays_, &overlay::Overlays::send_broadcast_ex, adnl_id_, overlay_id_, local_id_, 0, - std::move(B)); + td::actor::send_closure(overlays_, &overlay::Overlays::send_broadcast_ex, adnl_id_, overlay_id_, + send_broadcast_as(), 0, std::move(B)); } else { - td::actor::send_closure(overlays_, &overlay::Overlays::send_broadcast_fec_ex, adnl_id_, overlay_id_, local_id_, - overlay::Overlays::BroadcastFlagAnySender(), std::move(B)); + td::actor::send_closure(overlays_, &overlay::Overlays::send_broadcast_fec_ex, adnl_id_, overlay_id_, + send_broadcast_as(), overlay::Overlays::BroadcastFlagAnySender(), std::move(B)); } } @@ -782,8 +786,8 @@ void FullNodeShardImpl::send_block_candidate(BlockIdExt block_id, CatchainSeqno return; } VLOG(FULL_NODE_DEBUG) << "Sending newBlockCandidate: " << block_id.to_str(); - td::actor::send_closure(overlays_, &overlay::Overlays::send_broadcast_fec_ex, adnl_id_, overlay_id_, local_id_, - overlay::Overlays::BroadcastFlagAnySender(), B.move_as_ok()); + td::actor::send_closure(overlays_, &overlay::Overlays::send_broadcast_fec_ex, adnl_id_, overlay_id_, + send_broadcast_as(), overlay::Overlays::BroadcastFlagAnySender(), B.move_as_ok()); } void FullNodeShardImpl::send_broadcast(BlockBroadcast broadcast) { @@ -797,8 +801,8 @@ void FullNodeShardImpl::send_broadcast(BlockBroadcast broadcast) { VLOG(FULL_NODE_WARNING) << "failed to serialize block broadcast: " << B.move_as_error(); return; } - td::actor::send_closure(overlays_, &overlay::Overlays::send_broadcast_fec_ex, adnl_id_, overlay_id_, local_id_, - overlay::Overlays::BroadcastFlagAnySender(), B.move_as_ok()); + td::actor::send_closure(overlays_, &overlay::Overlays::send_broadcast_fec_ex, adnl_id_, overlay_id_, + send_broadcast_as(), overlay::Overlays::BroadcastFlagAnySender(), B.move_as_ok()); } void FullNodeShardImpl::download_block(BlockIdExt id, td::uint32 priority, td::Timestamp timeout, @@ -898,8 +902,8 @@ void FullNodeShardImpl::alarm() { ping_neighbours_at_ = td::Timestamp::in(td::Random::fast(0.5, 1.0)); } if (update_certificate_at_ && update_certificate_at_.is_in_past()) { - if (!sign_cert_by_.is_zero()) { - sign_new_certificate(sign_cert_by_); + if (!local_validator_key_.is_zero()) { + sign_new_certificate(local_validator_key_); update_certificate_at_ = td::Timestamp::in(30.0); } else { update_certificate_at_ = td::Timestamp::never(); @@ -969,7 +973,7 @@ void FullNodeShardImpl::signed_new_certificate(ton::overlay::Certificate cert) { } void FullNodeShardImpl::sign_overlay_certificate(PublicKeyHash signed_key, td::uint32 expire_at, td::uint32 max_size, td::Promise promise) { - auto sign_by = sign_cert_by_; + auto sign_by = local_validator_key_; if (sign_by.is_zero()) { promise.set_error(td::Status::Error("Node has no key with signing authority")); return; @@ -1005,10 +1009,10 @@ void FullNodeShardImpl::update_validators(std::vector public_key_ return; } bool update_cert = false; - if (!local_hash.is_zero() && local_hash != sign_cert_by_) { + if (!local_hash.is_zero() && local_hash != local_validator_key_) { update_cert = true; } - sign_cert_by_ = local_hash; + local_validator_key_ = local_hash; std::map authorized_keys; for (auto &key : public_key_hashes) { @@ -1019,7 +1023,7 @@ void FullNodeShardImpl::update_validators(std::vector public_key_ td::actor::send_closure(overlays_, &overlay::Overlays::set_privacy_rules, adnl_id_, overlay_id_, rules_); if (update_cert) { - sign_new_certificate(sign_cert_by_); + sign_new_certificate(local_validator_key_); update_certificate_at_ = td::Timestamp::in(30.0); alarm_timestamp().relax(update_certificate_at_); } diff --git a/validator/full-node-shard.hpp b/validator/full-node-shard.hpp index a7cf89ac5..c2786839a 100644 --- a/validator/full-node-shard.hpp +++ b/validator/full-node-shard.hpp @@ -246,7 +246,7 @@ class FullNodeShardImpl : public FullNodeShard { overlay::OverlayIdFull overlay_id_full_; overlay::OverlayIdShort overlay_id_; - PublicKeyHash sign_cert_by_ = PublicKeyHash::zero(); + PublicKeyHash local_validator_key_ = PublicKeyHash::zero(); td::Timestamp update_certificate_at_; td::Timestamp sync_completed_at_; @@ -263,6 +263,10 @@ class FullNodeShardImpl : public FullNodeShard { std::set my_ext_msg_broadcasts_; std::set processed_ext_msg_broadcasts_; td::Timestamp cleanup_processed_ext_msg_at_; + + PublicKeyHash send_broadcast_as() const { + return local_validator_key_.is_zero() ? local_id_ : local_validator_key_; + } }; } // namespace fullnode diff --git a/validator/full-node.cpp b/validator/full-node.cpp index bb6da2c8b..00731d569 100644 --- a/validator/full-node.cpp +++ b/validator/full-node.cpp @@ -40,19 +40,19 @@ void FullNodeImpl::add_permanent_key(PublicKeyHash key, td::Promise pr update_custom_overlay(p.second); } - if (!sign_cert_by_.is_zero()) { + if (!local_validator_key_.is_zero()) { promise.set_value(td::Unit()); return; } for (auto &x : all_validators_) { if (x == key) { - sign_cert_by_ = key; + local_validator_key_ = key; } } for (auto &shard : shards_) { - td::actor::send_closure(shard.second, &FullNodeShard::update_validators, all_validators_, sign_cert_by_); + td::actor::send_closure(shard.second, &FullNodeShard::update_validators, all_validators_, local_validator_key_); } promise.set_value(td::Unit()); } @@ -68,20 +68,20 @@ void FullNodeImpl::del_permanent_key(PublicKeyHash key, td::Promise pr update_custom_overlay(p.second); } - if (sign_cert_by_ != key) { + if (local_validator_key_ != key) { promise.set_value(td::Unit()); return; } - sign_cert_by_ = PublicKeyHash::zero(); + local_validator_key_ = PublicKeyHash::zero(); for (auto &x : all_validators_) { if (local_keys_.count(x)) { - sign_cert_by_ = x; + local_validator_key_ = x; } } for (auto &shard : shards_) { - td::actor::send_closure(shard.second, &FullNodeShard::update_validators, all_validators_, sign_cert_by_); + td::actor::send_closure(shard.second, &FullNodeShard::update_validators, all_validators_, local_validator_key_); } promise.set_value(td::Unit()); } @@ -183,7 +183,8 @@ void FullNodeImpl::add_shard(ShardIdFull shard) { FullNodeShard::create(shard, local_id_, adnl_id_, zero_state_file_hash_, config_, keyring_, adnl_, rldp_, rldp2_, overlays_, validator_manager_, client_, actor_id(this))); if (all_validators_.size() > 0) { - td::actor::send_closure(shards_[shard], &FullNodeShard::update_validators, all_validators_, sign_cert_by_); + td::actor::send_closure(shards_[shard], &FullNodeShard::update_validators, all_validators_, + local_validator_key_); } } else { break; @@ -402,11 +403,11 @@ void FullNodeImpl::got_key_block_config(td::Ref config) { // } all_validators_ = keys; - sign_cert_by_ = l; + local_validator_key_ = l; CHECK(all_validators_.size() > 0); for (auto &shard : shards_) { - td::actor::send_closure(shard.second, &FullNodeShard::update_validators, all_validators_, sign_cert_by_); + td::actor::send_closure(shard.second, &FullNodeShard::update_validators, all_validators_, local_validator_key_); } } diff --git a/validator/full-node.hpp b/validator/full-node.hpp index 584be5ee2..7ccfa464f 100644 --- a/validator/full-node.hpp +++ b/validator/full-node.hpp @@ -119,7 +119,7 @@ class FullNodeImpl : public FullNode { std::string db_root_; - PublicKeyHash sign_cert_by_; + PublicKeyHash local_validator_key_; std::vector all_validators_; std::map current_validators_;