mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Fix loading key block config in FullNodeImpl (#1013)
Co-authored-by: SpyCheese <mikle98@yandex.ru>
This commit is contained in:
parent
3d7e85bafd
commit
0301e9fbb7
3 changed files with 32 additions and 38 deletions
|
@ -47,15 +47,11 @@ class FullNodePrivateBlockOverlay : public td::actor::Actor {
|
|||
config_ = std::move(config);
|
||||
}
|
||||
|
||||
void set_enable_compression(bool value) {
|
||||
enable_compression_ = value;
|
||||
}
|
||||
|
||||
void start_up() override;
|
||||
void tear_down() override;
|
||||
|
||||
FullNodePrivateBlockOverlay(adnl::AdnlNodeIdShort local_id, std::vector<adnl::AdnlNodeIdShort> nodes,
|
||||
FileHash zero_state_file_hash, FullNodeConfig config, bool enable_compression,
|
||||
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, td::actor::ActorId<rldp2::Rldp> rldp2,
|
||||
td::actor::ActorId<overlay::Overlays> overlays,
|
||||
|
@ -65,7 +61,6 @@ class FullNodePrivateBlockOverlay : public td::actor::Actor {
|
|||
, nodes_(std::move(nodes))
|
||||
, zero_state_file_hash_(zero_state_file_hash)
|
||||
, config_(config)
|
||||
, enable_compression_(enable_compression)
|
||||
, keyring_(keyring)
|
||||
, adnl_(adnl)
|
||||
, rldp_(rldp)
|
||||
|
@ -80,7 +75,7 @@ class FullNodePrivateBlockOverlay : public td::actor::Actor {
|
|||
std::vector<adnl::AdnlNodeIdShort> nodes_;
|
||||
FileHash zero_state_file_hash_;
|
||||
FullNodeConfig config_;
|
||||
bool enable_compression_;
|
||||
bool enable_compression_ = true;
|
||||
|
||||
td::actor::ActorId<keyring::Keyring> keyring_;
|
||||
td::actor::ActorId<adnl::Adnl> adnl_;
|
||||
|
|
|
@ -369,14 +369,12 @@ td::actor::ActorId<FullNodeShard> FullNodeImpl::get_shard(AccountIdPrefixFull ds
|
|||
return get_shard(shard_prefix(dst, 60));
|
||||
}
|
||||
|
||||
void FullNodeImpl::got_key_block_state(td::Ref<ShardState> state) {
|
||||
auto m = td::Ref<MasterchainState>{std::move(state)};
|
||||
|
||||
void FullNodeImpl::got_key_block_config(td::Ref<ConfigHolder> config) {
|
||||
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);
|
||||
auto r = config->get_total_validator_set(i < 0 ? i : 1 - i);
|
||||
if (r.not_null()) {
|
||||
auto vec = r->export_vector();
|
||||
for (auto &el : vec) {
|
||||
|
@ -392,8 +390,6 @@ void FullNodeImpl::got_key_block_state(td::Ref<ShardState> state) {
|
|||
}
|
||||
}
|
||||
|
||||
set_private_block_overlays_enable_compression(m->get_consensus_config().proto_version >= 3);
|
||||
|
||||
if (current_validators != current_validators_) {
|
||||
current_validators_ = std::move(current_validators);
|
||||
update_private_overlays();
|
||||
|
@ -413,15 +409,31 @@ void FullNodeImpl::got_key_block_state(td::Ref<ShardState> state) {
|
|||
}
|
||||
|
||||
void FullNodeImpl::new_key_block(BlockHandle handle) {
|
||||
auto P = td::PromiseCreator::lambda([SelfId = actor_id(this)](td::Result<td::Ref<ShardState>> R) {
|
||||
if (R.is_error()) {
|
||||
VLOG(FULL_NODE_WARNING) << "failed to get key block state: " << R.move_as_error();
|
||||
} else {
|
||||
td::actor::send_closure(SelfId, &FullNodeImpl::got_key_block_state, R.move_as_ok());
|
||||
}
|
||||
});
|
||||
td::actor::send_closure(validator_manager_, &ValidatorManagerInterface::get_shard_state_from_db, handle,
|
||||
std::move(P));
|
||||
if (handle->id().seqno() == 0) {
|
||||
auto P = td::PromiseCreator::lambda([SelfId = actor_id(this)](td::Result<td::Ref<ShardState>> R) {
|
||||
if (R.is_error()) {
|
||||
VLOG(FULL_NODE_WARNING) << "failed to get zero state: " << R.move_as_error();
|
||||
} else {
|
||||
auto s = td::Ref<MasterchainState>{R.move_as_ok()};
|
||||
CHECK(s.not_null());
|
||||
td::actor::send_closure(SelfId, &FullNodeImpl::got_key_block_config, s->get_config_holder().move_as_ok());
|
||||
}
|
||||
});
|
||||
td::actor::send_closure(validator_manager_, &ValidatorManagerInterface::get_shard_state_from_db, handle,
|
||||
std::move(P));
|
||||
} else {
|
||||
CHECK(handle->is_key_block());
|
||||
auto P = td::PromiseCreator::lambda([SelfId = actor_id(this)](td::Result<td::Ref<ProofLink>> R) {
|
||||
if (R.is_error()) {
|
||||
VLOG(FULL_NODE_WARNING) << "failed to get key block proof: " << R.move_as_error();
|
||||
} else {
|
||||
td::actor::send_closure(SelfId, &FullNodeImpl::got_key_block_config,
|
||||
R.ok()->get_key_block_config().move_as_ok());
|
||||
}
|
||||
});
|
||||
td::actor::send_closure(validator_manager_, &ValidatorManagerInterface::get_block_proof_link_from_db, handle,
|
||||
std::move(P));
|
||||
}
|
||||
}
|
||||
|
||||
void FullNodeImpl::process_block_broadcast(BlockBroadcast broadcast) {
|
||||
|
@ -549,16 +561,6 @@ void FullNodeImpl::update_private_overlays() {
|
|||
}
|
||||
}
|
||||
|
||||
void FullNodeImpl::set_private_block_overlays_enable_compression(bool value) {
|
||||
if (private_block_overlays_enable_compression_ == value) {
|
||||
return;
|
||||
}
|
||||
private_block_overlays_enable_compression_ = true;
|
||||
for (auto &p : private_block_overlays_) {
|
||||
td::actor::send_closure(p.second, &FullNodePrivateBlockOverlay::set_enable_compression, value);
|
||||
}
|
||||
}
|
||||
|
||||
void FullNodeImpl::create_private_block_overlay(PublicKeyHash key) {
|
||||
CHECK(local_keys_.count(key));
|
||||
if (current_validators_.count(key)) {
|
||||
|
@ -567,9 +569,8 @@ void FullNodeImpl::create_private_block_overlay(PublicKeyHash key) {
|
|||
nodes.push_back(p.second);
|
||||
}
|
||||
private_block_overlays_[key] = td::actor::create_actor<FullNodePrivateBlockOverlay>(
|
||||
"BlocksPrivateOverlay", current_validators_[key], std::move(nodes), zero_state_file_hash_, config_,
|
||||
private_block_overlays_enable_compression_, keyring_, adnl_, rldp_, rldp2_, overlays_, validator_manager_,
|
||||
actor_id(this));
|
||||
"BlocksPrivateOverlay", current_validators_[key], std::move(nodes), zero_state_file_hash_, config_, keyring_,
|
||||
adnl_, rldp_, rldp2_, overlays_, validator_manager_, actor_id(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ class FullNodeImpl : public FullNode {
|
|||
void download_archive(BlockSeqno masterchain_seqno, std::string tmp_dir, td::Timestamp timeout,
|
||||
td::Promise<std::string> promise);
|
||||
|
||||
void got_key_block_state(td::Ref<ShardState> state);
|
||||
void got_key_block_config(td::Ref<ConfigHolder> config);
|
||||
void new_key_block(BlockHandle handle);
|
||||
|
||||
void process_block_broadcast(BlockBroadcast broadcast) override;
|
||||
|
@ -127,7 +127,6 @@ class FullNodeImpl : public FullNode {
|
|||
FullNodeConfig config_;
|
||||
|
||||
std::map<PublicKeyHash, td::actor::ActorOwn<FullNodePrivateBlockOverlay>> private_block_overlays_;
|
||||
bool private_block_overlays_enable_compression_ = false;
|
||||
bool broadcast_block_candidates_in_public_overlay_ = false;
|
||||
|
||||
struct CustomOverlayInfo {
|
||||
|
@ -139,7 +138,6 @@ class FullNodeImpl : public FullNode {
|
|||
std::queue<BlockIdExt> custom_overlays_sent_broadcasts_lru_;
|
||||
|
||||
void update_private_overlays();
|
||||
void set_private_block_overlays_enable_compression(bool value);
|
||||
void create_private_block_overlay(PublicKeyHash key);
|
||||
void update_custom_overlay(CustomOverlayInfo& overlay);
|
||||
void send_block_broadcast_to_custom_overlays(const BlockBroadcast& broadcast);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue