mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Improve block broadcasts processing; add special overlay for blocks for validators (#885)
* Improve block broadcast processing
* ValidatorManagerImpl::written_handle
* Retry sending broadcasts in ValidatorGroup
* Fix setting channel_ready in AdnlPeerPair
* Add special overlay for validators for block broadcasting (#842)
* Private overlay for broadcasting blocks
---------
Co-authored-by: SpyCheese <mikle98@yandex.ru>
(cherry picked from commit a52045bd91
)
---------
Co-authored-by: SpyCheese <mikle98@yandex.ru>
This commit is contained in:
parent
a11ffb1637
commit
59927ba534
16 changed files with 410 additions and 30 deletions
|
@ -50,6 +50,7 @@ void FullNodeImpl::add_permanent_key(PublicKeyHash key, td::Promise<td::Unit> pr
|
|||
for (auto &shard : shards_) {
|
||||
td::actor::send_closure(shard.second, &FullNodeShard::update_validators, all_validators_, sign_cert_by_);
|
||||
}
|
||||
create_private_block_overlay(key);
|
||||
promise.set_value(td::Unit());
|
||||
}
|
||||
|
||||
|
@ -74,6 +75,7 @@ void FullNodeImpl::del_permanent_key(PublicKeyHash key, td::Promise<td::Unit> pr
|
|||
for (auto &shard : shards_) {
|
||||
td::actor::send_closure(shard.second, &FullNodeShard::update_validators, all_validators_, sign_cert_by_);
|
||||
}
|
||||
private_block_overlays_.erase(key);
|
||||
promise.set_value(td::Unit());
|
||||
}
|
||||
|
||||
|
@ -179,6 +181,10 @@ void FullNodeImpl::send_shard_block_info(BlockIdExt block_id, CatchainSeqno cc_s
|
|||
VLOG(FULL_NODE_WARNING) << "dropping OUT shard block info message to unknown shard";
|
||||
return;
|
||||
}
|
||||
if (!private_block_overlays_.empty()) {
|
||||
td::actor::send_closure(private_block_overlays_.begin()->second, &FullNodePrivateOverlay::send_shard_block_info,
|
||||
block_id, cc_seqno, data.clone());
|
||||
}
|
||||
td::actor::send_closure(shard, &FullNodeShard::send_shard_block_info, block_id, cc_seqno, std::move(data));
|
||||
}
|
||||
|
||||
|
@ -188,6 +194,10 @@ void FullNodeImpl::send_broadcast(BlockBroadcast broadcast) {
|
|||
VLOG(FULL_NODE_WARNING) << "dropping OUT broadcast to unknown shard";
|
||||
return;
|
||||
}
|
||||
if (!private_block_overlays_.empty()) {
|
||||
td::actor::send_closure(private_block_overlays_.begin()->second, &FullNodePrivateOverlay::send_broadcast,
|
||||
broadcast.clone());
|
||||
}
|
||||
td::actor::send_closure(shard, &FullNodeShard::send_broadcast, std::move(broadcast));
|
||||
}
|
||||
|
||||
|
@ -289,6 +299,7 @@ void FullNodeImpl::got_key_block_proof(td::Ref<ProofLink> proof) {
|
|||
|
||||
PublicKeyHash l = PublicKeyHash::zero();
|
||||
std::vector<PublicKeyHash> keys;
|
||||
std::map<PublicKeyHash, adnl::AdnlNodeIdShort> current_validators;
|
||||
for (td::int32 i = -1; i <= 1; i++) {
|
||||
auto r = config->get_total_validator_set(i < 0 ? i : 1 - i);
|
||||
if (r.not_null()) {
|
||||
|
@ -299,10 +310,18 @@ void FullNodeImpl::got_key_block_proof(td::Ref<ProofLink> proof) {
|
|||
if (local_keys_.count(key)) {
|
||||
l = key;
|
||||
}
|
||||
if (i == 1) {
|
||||
current_validators[key] = adnl::AdnlNodeIdShort{el.addr.is_zero() ? key.bits256_value() : el.addr};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (current_validators != current_validators_) {
|
||||
current_validators_ = std::move(current_validators);
|
||||
update_private_block_overlays();
|
||||
}
|
||||
|
||||
if (keys == all_validators_) {
|
||||
return;
|
||||
}
|
||||
|
@ -321,6 +340,7 @@ void FullNodeImpl::got_zero_block_state(td::Ref<ShardState> state) {
|
|||
|
||||
PublicKeyHash l = PublicKeyHash::zero();
|
||||
std::vector<PublicKeyHash> keys;
|
||||
std::map<PublicKeyHash, adnl::AdnlNodeIdShort> current_validators;
|
||||
for (td::int32 i = -1; i <= 1; i++) {
|
||||
auto r = m->get_total_validator_set(i < 0 ? i : 1 - i);
|
||||
if (r.not_null()) {
|
||||
|
@ -331,10 +351,18 @@ void FullNodeImpl::got_zero_block_state(td::Ref<ShardState> state) {
|
|||
if (local_keys_.count(key)) {
|
||||
l = key;
|
||||
}
|
||||
if (i == 1) {
|
||||
current_validators[key] = adnl::AdnlNodeIdShort{el.addr.is_zero() ? key.bits256_value() : el.addr};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (current_validators != current_validators_) {
|
||||
current_validators_ = std::move(current_validators);
|
||||
update_private_block_overlays();
|
||||
}
|
||||
|
||||
if (keys == all_validators_) {
|
||||
return;
|
||||
}
|
||||
|
@ -456,6 +484,29 @@ void FullNodeImpl::start_up() {
|
|||
std::make_unique<Callback>(actor_id(this)), std::move(P));
|
||||
}
|
||||
|
||||
void FullNodeImpl::update_private_block_overlays() {
|
||||
private_block_overlays_.clear();
|
||||
if (local_keys_.empty()) {
|
||||
return;
|
||||
}
|
||||
for (const auto &key : local_keys_) {
|
||||
create_private_block_overlay(key);
|
||||
}
|
||||
}
|
||||
|
||||
void FullNodeImpl::create_private_block_overlay(PublicKeyHash key) {
|
||||
CHECK(local_keys_.count(key));
|
||||
if (current_validators_.count(key)) {
|
||||
std::vector<adnl::AdnlNodeIdShort> nodes;
|
||||
for (const auto &p : current_validators_) {
|
||||
nodes.push_back(p.second);
|
||||
}
|
||||
private_block_overlays_[key] = td::actor::create_actor<FullNodePrivateOverlay>(
|
||||
"BlocksPrivateOverlay", current_validators_[key], std::move(nodes), zero_state_file_hash_, config_, keyring_,
|
||||
adnl_, rldp_, rldp2_, overlays_, validator_manager_);
|
||||
}
|
||||
}
|
||||
|
||||
FullNodeImpl::FullNodeImpl(PublicKeyHash local_id, adnl::AdnlNodeIdShort adnl_id, FileHash zero_state_file_hash,
|
||||
FullNodeConfig config, td::actor::ActorId<keyring::Keyring> keyring,
|
||||
td::actor::ActorId<adnl::Adnl> adnl, td::actor::ActorId<rldp::Rldp> rldp,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue