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

Experimental flags for speeding up broadcasts

This commit is contained in:
SpyCheese 2025-02-20 17:32:24 +03:00
parent 04f2bc1360
commit 8a08bf67a2
19 changed files with 131 additions and 46 deletions

View file

@ -526,10 +526,12 @@ void CatChainReceiverImpl::start_up() {
for (td::uint32 i = 0; i < get_sources_cnt(); i++) { for (td::uint32 i = 0; i < get_sources_cnt(); i++) {
root_keys.emplace(get_source(i)->get_hash(), OVERLAY_MAX_ALLOWED_PACKET_SIZE); root_keys.emplace(get_source(i)->get_hash(), OVERLAY_MAX_ALLOWED_PACKET_SIZE);
} }
td::actor::send_closure(overlay_manager_, &overlay::Overlays::create_private_overlay, overlay::OverlayOptions overlay_options;
overlay_options.broadcast_speed_multiplier_ = opts_.broadcast_speed_multiplier;
td::actor::send_closure(overlay_manager_, &overlay::Overlays::create_private_overlay_ex,
get_source(local_idx_)->get_adnl_id(), overlay_full_id_.clone(), std::move(ids), get_source(local_idx_)->get_adnl_id(), overlay_full_id_.clone(), std::move(ids),
make_callback(), overlay::OverlayPrivacyRules{0, 0, std::move(root_keys)}, make_callback(), overlay::OverlayPrivacyRules{0, 0, std::move(root_keys)},
R"({ "type": "catchain" })"); R"({ "type": "catchain" })", std::move(overlay_options));
CHECK(root_block_); CHECK(root_block_);

View file

@ -32,7 +32,7 @@ void OverlayOutboundFecBroadcast::alarm() {
fec_type_.size(), flags_, std::move(X.data), X.id, fec_type_, date_); fec_type_.size(), flags_, std::move(X.data), X.id, fec_type_, date_);
} }
alarm_timestamp() = td::Timestamp::in(0.010); alarm_timestamp() = td::Timestamp::in(delay_);
if (seqno_ >= to_send_) { if (seqno_ >= to_send_) {
stop(); stop();
@ -46,8 +46,9 @@ void OverlayOutboundFecBroadcast::start_up() {
OverlayOutboundFecBroadcast::OverlayOutboundFecBroadcast(td::BufferSlice data, td::uint32 flags, OverlayOutboundFecBroadcast::OverlayOutboundFecBroadcast(td::BufferSlice data, td::uint32 flags,
td::actor::ActorId<OverlayImpl> overlay, td::actor::ActorId<OverlayImpl> overlay,
PublicKeyHash local_id) PublicKeyHash local_id, double speed_multiplier)
: flags_(flags) { : flags_(flags) {
delay_ /= speed_multiplier;
CHECK(data.size() <= (1 << 27)); CHECK(data.size() <= (1 << 27));
local_id_ = local_id; local_id_ = local_id;
overlay_ = std::move(overlay); overlay_ = std::move(overlay);
@ -63,9 +64,10 @@ OverlayOutboundFecBroadcast::OverlayOutboundFecBroadcast(td::BufferSlice data, t
} }
td::actor::ActorId<OverlayOutboundFecBroadcast> OverlayOutboundFecBroadcast::create( td::actor::ActorId<OverlayOutboundFecBroadcast> OverlayOutboundFecBroadcast::create(
td::BufferSlice data, td::uint32 flags, td::actor::ActorId<OverlayImpl> overlay, PublicKeyHash local_id) { td::BufferSlice data, td::uint32 flags, td::actor::ActorId<OverlayImpl> overlay, PublicKeyHash local_id,
return td::actor::create_actor<OverlayOutboundFecBroadcast>(td::actor::ActorOptions().with_name("bcast"), double speed_multiplier) {
std::move(data), flags, overlay, local_id) return td::actor::create_actor<OverlayOutboundFecBroadcast>(
td::actor::ActorOptions().with_name("bcast"), std::move(data), flags, overlay, local_id, speed_multiplier)
.release(); .release();
} }

View file

@ -37,6 +37,7 @@ class OverlayOutboundFecBroadcast : public td::actor::Actor {
PublicKeyHash local_id_; PublicKeyHash local_id_;
Overlay::BroadcastDataHash data_hash_; Overlay::BroadcastDataHash data_hash_;
td::uint32 flags_ = 0; td::uint32 flags_ = 0;
double delay_ = 0.010;
td::int32 date_; td::int32 date_;
std::unique_ptr<td::fec::Encoder> encoder_; std::unique_ptr<td::fec::Encoder> encoder_;
td::actor::ActorId<OverlayImpl> overlay_; td::actor::ActorId<OverlayImpl> overlay_;
@ -45,9 +46,9 @@ class OverlayOutboundFecBroadcast : public td::actor::Actor {
public: public:
static td::actor::ActorId<OverlayOutboundFecBroadcast> create(td::BufferSlice data, td::uint32 flags, static td::actor::ActorId<OverlayOutboundFecBroadcast> create(td::BufferSlice data, td::uint32 flags,
td::actor::ActorId<OverlayImpl> overlay, td::actor::ActorId<OverlayImpl> overlay,
PublicKeyHash local_id); PublicKeyHash local_id, double speed_multiplier = 1.0);
OverlayOutboundFecBroadcast(td::BufferSlice data, td::uint32 flags, td::actor::ActorId<OverlayImpl> overlay, OverlayOutboundFecBroadcast(td::BufferSlice data, td::uint32 flags, td::actor::ActorId<OverlayImpl> overlay,
PublicKeyHash local_id); PublicKeyHash local_id, double speed_multiplier = 1.0);
void alarm() override; void alarm() override;
void start_up() override; void start_up() override;

View file

@ -63,7 +63,7 @@ td::actor::ActorOwn<Overlay> Overlay::create_private(
return td::actor::create_actor<OverlayImpl>( return td::actor::create_actor<OverlayImpl>(
overlay_actor_name(overlay_id), keyring, adnl, manager, dht_node, local_id, std::move(overlay_id), overlay_actor_name(overlay_id), keyring, adnl, manager, dht_node, local_id, std::move(overlay_id),
OverlayType::FixedMemberList, std::move(nodes), std::vector<PublicKeyHash>(), OverlayMemberCertificate{}, OverlayType::FixedMemberList, std::move(nodes), std::vector<PublicKeyHash>(), OverlayMemberCertificate{},
std::move(callback), std::move(rules), std::move(scope)); std::move(callback), std::move(rules), std::move(scope), std::move(opts));
} }
td::actor::ActorOwn<Overlay> Overlay::create_semiprivate( td::actor::ActorOwn<Overlay> Overlay::create_semiprivate(
@ -99,6 +99,7 @@ OverlayImpl::OverlayImpl(td::actor::ActorId<keyring::Keyring> keyring, td::actor
overlay_id_ = id_full_.compute_short_id(); overlay_id_ = id_full_.compute_short_id();
frequent_dht_lookup_ = opts_.frequent_dht_lookup_; frequent_dht_lookup_ = opts_.frequent_dht_lookup_;
peer_list_.local_member_flags_ = opts_.local_overlay_member_flags_; peer_list_.local_member_flags_ = opts_.local_overlay_member_flags_;
opts_.broadcast_speed_multiplier_ = std::max(opts_.broadcast_speed_multiplier_, 1e-9);
VLOG(OVERLAY_INFO) << this << ": creating"; VLOG(OVERLAY_INFO) << this << ": creating";
@ -490,7 +491,8 @@ void OverlayImpl::send_broadcast_fec(PublicKeyHash send_as, td::uint32 flags, td
VLOG(OVERLAY_WARNING) << "broadcast source certificate is invalid"; VLOG(OVERLAY_WARNING) << "broadcast source certificate is invalid";
return; return;
} }
OverlayOutboundFecBroadcast::create(std::move(data), flags, actor_id(this), send_as); OverlayOutboundFecBroadcast::create(std::move(data), flags, actor_id(this), send_as,
opts_.broadcast_speed_multiplier_);
} }
void OverlayImpl::print(td::StringBuilder &sb) { void OverlayImpl::print(td::StringBuilder &sb) {

View file

@ -269,6 +269,7 @@ struct OverlayOptions {
td::uint32 nodes_to_send_ = 4; td::uint32 nodes_to_send_ = 4;
td::uint32 propagate_broadcast_to_ = 5; td::uint32 propagate_broadcast_to_ = 5;
td::uint32 default_permanent_members_flags_ = 0; td::uint32 default_permanent_members_flags_ = 0;
double broadcast_speed_multiplier_ = 1.0;
}; };
class Overlays : public td::actor::Actor { class Overlays : public td::actor::Actor {

View file

@ -493,6 +493,7 @@ struct CatChainOptions {
td::uint64 max_block_height_coeff = 0; td::uint64 max_block_height_coeff = 0;
bool debug_disable_db = false; bool debug_disable_db = false;
double broadcast_speed_multiplier = 1.0;
}; };
struct ValidatorSessionConfig { struct ValidatorSessionConfig {

View file

@ -1504,6 +1504,7 @@ td::Status ValidatorEngine::load_global_config() {
} }
validator_options_.write().set_hardforks(std::move(h)); validator_options_.write().set_hardforks(std::move(h));
validator_options_.write().set_fast_state_serializer_enabled(fast_state_serializer_enabled_); validator_options_.write().set_fast_state_serializer_enabled(fast_state_serializer_enabled_);
validator_options_.write().set_catchain_broadcast_speed_multiplier(broadcast_speed_multiplier_catchain_);
return td::Status::OK(); return td::Status::OK();
} }
@ -2004,9 +2005,13 @@ void ValidatorEngine::start_full_node() {
R.ensure(); R.ensure();
td::actor::send_closure(SelfId, &ValidatorEngine::started_full_node); td::actor::send_closure(SelfId, &ValidatorEngine::started_full_node);
}); });
ton::validator::fullnode::FullNodeOptions full_node_options{
.config_ = config_.full_node_config,
.public_broadcast_speed_multiplier_ = broadcast_speed_multiplier_public_,
.private_broadcast_speed_multiplier_ = broadcast_speed_multiplier_private_};
full_node_ = ton::validator::fullnode::FullNode::create( full_node_ = ton::validator::fullnode::FullNode::create(
short_id, ton::adnl::AdnlNodeIdShort{config_.full_node}, validator_options_->zero_block_id().file_hash, short_id, ton::adnl::AdnlNodeIdShort{config_.full_node}, validator_options_->zero_block_id().file_hash,
config_.full_node_config, keyring_.get(), adnl_.get(), rldp_.get(), rldp2_.get(), full_node_options, keyring_.get(), adnl_.get(), rldp_.get(), rldp2_.get(),
default_dht_node_.is_zero() ? td::actor::ActorId<ton::dht::Dht>{} : dht_nodes_[default_dht_node_].get(), default_dht_node_.is_zero() ? td::actor::ActorId<ton::dht::Dht>{} : dht_nodes_[default_dht_node_].get(),
overlay_manager_.get(), validator_manager_.get(), full_node_client_.get(), db_root_, std::move(P)); overlay_manager_.get(), validator_manager_.get(), full_node_client_.get(), db_root_, std::move(P));
for (auto &v : config_.validators) { for (auto &v : config_.validators) {
@ -4562,6 +4567,42 @@ int main(int argc, char *argv[]) {
"disable persistent state serializer (similar to set-state-serializer-enabled 0 in validator console)", [&]() { "disable persistent state serializer (similar to set-state-serializer-enabled 0 in validator console)", [&]() {
acts.push_back([&x]() { td::actor::send_closure(x, &ValidatorEngine::set_state_serializer_disabled_flag); }); acts.push_back([&x]() { td::actor::send_closure(x, &ValidatorEngine::set_state_serializer_disabled_flag); });
}); });
p.add_checked_option(
'\0', "broadcast-speed-catchain",
"multiplier for broadcast speed in catchain overlays (experimental, default is 1.0, which is ~300 KB/s)",
[&](td::Slice s) -> td::Status {
auto v = td::to_double(s);
if (v <= 0.0) {
return td::Status::Error("broadcast-speed-catchain should be positive");
}
acts.push_back(
[&x, v]() { td::actor::send_closure(x, &ValidatorEngine::set_broadcast_speed_multiplier_catchain, v); });
return td::Status::OK();
});
p.add_checked_option(
'\0', "broadcast-speed-public",
"multiplier for broadcast speed in public shard overlays (experimental, default is 1.0, which is ~300 KB/s)",
[&](td::Slice s) -> td::Status {
auto v = td::to_double(s);
if (v <= 0.0) {
return td::Status::Error("broadcast-speed-public should be positive");
}
acts.push_back(
[&x, v]() { td::actor::send_closure(x, &ValidatorEngine::set_broadcast_speed_multiplier_public, v); });
return td::Status::OK();
});
p.add_checked_option(
'\0', "broadcast-speed-private",
"multiplier for broadcast speed in private block overlays (experimental, default is 1.0, which is ~300 KB/s)",
[&](td::Slice s) -> td::Status {
auto v = td::to_double(s);
if (v <= 0.0) {
return td::Status::Error("broadcast-speed-private should be positive");
}
acts.push_back(
[&x, v]() { td::actor::send_closure(x, &ValidatorEngine::set_broadcast_speed_multiplier_private, v); });
return td::Status::OK();
});
auto S = p.run(argc, argv); auto S = p.run(argc, argv);
if (S.is_error()) { if (S.is_error()) {
LOG(ERROR) << "failed to parse options: " << S.move_as_error(); LOG(ERROR) << "failed to parse options: " << S.move_as_error();

View file

@ -229,6 +229,9 @@ class ValidatorEngine : public td::actor::Actor {
bool not_all_shards_ = false; bool not_all_shards_ = false;
std::vector<ton::ShardIdFull> add_shard_cmds_; std::vector<ton::ShardIdFull> add_shard_cmds_;
bool state_serializer_disabled_flag_ = false; bool state_serializer_disabled_flag_ = false;
double broadcast_speed_multiplier_catchain_ = 1.0;
double broadcast_speed_multiplier_public_ = 1.0;
double broadcast_speed_multiplier_private_ = 1.0;
std::set<ton::CatchainSeqno> unsafe_catchains_; std::set<ton::CatchainSeqno> unsafe_catchains_;
std::map<ton::BlockSeqno, std::pair<ton::CatchainSeqno, td::uint32>> unsafe_catchain_rotations_; std::map<ton::BlockSeqno, std::pair<ton::CatchainSeqno, td::uint32>> unsafe_catchain_rotations_;
@ -329,6 +332,15 @@ class ValidatorEngine : public td::actor::Actor {
void set_state_serializer_disabled_flag() { void set_state_serializer_disabled_flag() {
state_serializer_disabled_flag_ = true; state_serializer_disabled_flag_ = true;
} }
void set_broadcast_speed_multiplier_catchain(double value) {
broadcast_speed_multiplier_catchain_ = value;
}
void set_broadcast_speed_multiplier_public(double value) {
broadcast_speed_multiplier_public_ = value;
}
void set_broadcast_speed_multiplier_private(double value) {
broadcast_speed_multiplier_private_ = value;
}
void start_up() override; void start_up() override;
ValidatorEngine() { ValidatorEngine() {

View file

@ -264,8 +264,11 @@ void FullNodePrivateBlockOverlay::init() {
overlay::OverlayPrivacyRules rules{overlay::Overlays::max_fec_broadcast_size(), overlay::OverlayPrivacyRules rules{overlay::Overlays::max_fec_broadcast_size(),
overlay::CertificateFlags::AllowFec | overlay::CertificateFlags::Trusted, overlay::CertificateFlags::AllowFec | overlay::CertificateFlags::Trusted,
{}}; {}};
td::actor::send_closure(overlays_, &overlay::Overlays::create_private_overlay, local_id_, overlay_id_full_.clone(), overlay::OverlayOptions overlay_options;
nodes_, std::make_unique<Callback>(actor_id(this)), rules, R"({ "type": "private-blocks" })"); overlay_options.broadcast_speed_multiplier_ = opts_.private_broadcast_speed_multiplier_;
td::actor::send_closure(overlays_, &overlay::Overlays::create_private_overlay_ex, local_id_, overlay_id_full_.clone(),
nodes_, std::make_unique<Callback>(actor_id(this)), rules, R"({ "type": "private-blocks" })",
overlay_options);
td::actor::send_closure(rldp_, &rldp::Rldp::add_id, local_id_); td::actor::send_closure(rldp_, &rldp::Rldp::add_id, local_id_);
td::actor::send_closure(rldp2_, &rldp2::Rldp::add_id, local_id_); td::actor::send_closure(rldp2_, &rldp2::Rldp::add_id, local_id_);
@ -366,7 +369,7 @@ void FullNodeCustomOverlay::receive_broadcast(PublicKeyHash src, td::BufferSlice
} }
void FullNodeCustomOverlay::send_external_message(td::BufferSlice data) { void FullNodeCustomOverlay::send_external_message(td::BufferSlice data) {
if (!inited_ || config_.ext_messages_broadcast_disabled_) { if (!inited_ || opts_.config_.ext_messages_broadcast_disabled_) {
return; return;
} }
VLOG(FULL_NODE_DEBUG) << "Sending external message to custom overlay \"" << name_ << "\""; VLOG(FULL_NODE_DEBUG) << "Sending external message to custom overlay \"" << name_ << "\"";
@ -472,10 +475,13 @@ void FullNodeCustomOverlay::init() {
authorized_keys[sender.pubkey_hash()] = overlay::Overlays::max_fec_broadcast_size(); authorized_keys[sender.pubkey_hash()] = overlay::Overlays::max_fec_broadcast_size();
} }
overlay::OverlayPrivacyRules rules{overlay::Overlays::max_fec_broadcast_size(), 0, std::move(authorized_keys)}; overlay::OverlayPrivacyRules rules{overlay::Overlays::max_fec_broadcast_size(), 0, std::move(authorized_keys)};
overlay::OverlayOptions overlay_options;
overlay_options.broadcast_speed_multiplier_ = opts_.private_broadcast_speed_multiplier_;
td::actor::send_closure( td::actor::send_closure(
overlays_, &overlay::Overlays::create_private_overlay, local_id_, overlay_id_full_.clone(), nodes_, overlays_, &overlay::Overlays::create_private_overlay_ex, local_id_, overlay_id_full_.clone(), nodes_,
std::make_unique<Callback>(actor_id(this)), rules, std::make_unique<Callback>(actor_id(this)), rules,
PSTRING() << R"({ "type": "custom-overlay", "name": ")" << td::format::Escaped{name_} << R"(" })"); PSTRING() << R"({ "type": "custom-overlay", "name": ")" << td::format::Escaped{name_} << R"(" })",
overlay_options);
td::actor::send_closure(rldp_, &rldp::Rldp::add_id, local_id_); td::actor::send_closure(rldp_, &rldp::Rldp::add_id, local_id_);
td::actor::send_closure(rldp2_, &rldp2::Rldp::add_id, local_id_); td::actor::send_closure(rldp2_, &rldp2::Rldp::add_id, local_id_);

View file

@ -50,14 +50,14 @@ class FullNodePrivateBlockOverlay : public td::actor::Actor {
void collect_validator_telemetry(std::string filename); void collect_validator_telemetry(std::string filename);
void set_config(FullNodeConfig config) { void set_config(FullNodeConfig config) {
config_ = std::move(config); opts_.config_ = std::move(config);
} }
void start_up() override; void start_up() override;
void tear_down() override; void tear_down() override;
FullNodePrivateBlockOverlay(adnl::AdnlNodeIdShort local_id, std::vector<adnl::AdnlNodeIdShort> nodes, FullNodePrivateBlockOverlay(adnl::AdnlNodeIdShort local_id, std::vector<adnl::AdnlNodeIdShort> nodes,
FileHash zero_state_file_hash, FullNodeConfig config, FileHash zero_state_file_hash, FullNodeOptions opts,
td::actor::ActorId<keyring::Keyring> keyring, td::actor::ActorId<adnl::Adnl> adnl, 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<rldp::Rldp> rldp, td::actor::ActorId<rldp2::Rldp> rldp2,
td::actor::ActorId<overlay::Overlays> overlays, td::actor::ActorId<overlay::Overlays> overlays,
@ -66,7 +66,7 @@ class FullNodePrivateBlockOverlay : public td::actor::Actor {
: local_id_(local_id) : local_id_(local_id)
, nodes_(std::move(nodes)) , nodes_(std::move(nodes))
, zero_state_file_hash_(zero_state_file_hash) , zero_state_file_hash_(zero_state_file_hash)
, config_(config) , opts_(opts)
, keyring_(keyring) , keyring_(keyring)
, adnl_(adnl) , adnl_(adnl)
, rldp_(rldp) , rldp_(rldp)
@ -80,7 +80,7 @@ class FullNodePrivateBlockOverlay : public td::actor::Actor {
adnl::AdnlNodeIdShort local_id_; adnl::AdnlNodeIdShort local_id_;
std::vector<adnl::AdnlNodeIdShort> nodes_; std::vector<adnl::AdnlNodeIdShort> nodes_;
FileHash zero_state_file_hash_; FileHash zero_state_file_hash_;
FullNodeConfig config_; FullNodeOptions opts_;
bool enable_compression_ = true; bool enable_compression_ = true;
td::actor::ActorId<keyring::Keyring> keyring_; td::actor::ActorId<keyring::Keyring> keyring_;
@ -126,14 +126,14 @@ class FullNodeCustomOverlay : public td::actor::Actor {
td::BufferSlice data); td::BufferSlice data);
void set_config(FullNodeConfig config) { void set_config(FullNodeConfig config) {
config_ = std::move(config); opts_.config_ = std::move(config);
} }
void start_up() override; void start_up() override;
void tear_down() override; void tear_down() override;
FullNodeCustomOverlay(adnl::AdnlNodeIdShort local_id, CustomOverlayParams params, FileHash zero_state_file_hash, FullNodeCustomOverlay(adnl::AdnlNodeIdShort local_id, CustomOverlayParams params, FileHash zero_state_file_hash,
FullNodeConfig config, td::actor::ActorId<keyring::Keyring> keyring, FullNodeOptions opts, td::actor::ActorId<keyring::Keyring> keyring,
td::actor::ActorId<adnl::Adnl> adnl, td::actor::ActorId<rldp::Rldp> rldp, td::actor::ActorId<adnl::Adnl> adnl, td::actor::ActorId<rldp::Rldp> rldp,
td::actor::ActorId<rldp2::Rldp> rldp2, td::actor::ActorId<overlay::Overlays> overlays, td::actor::ActorId<rldp2::Rldp> rldp2, td::actor::ActorId<overlay::Overlays> overlays,
td::actor::ActorId<ValidatorManagerInterface> validator_manager, td::actor::ActorId<ValidatorManagerInterface> validator_manager,
@ -144,7 +144,7 @@ class FullNodeCustomOverlay : public td::actor::Actor {
, msg_senders_(std::move(params.msg_senders_)) , msg_senders_(std::move(params.msg_senders_))
, block_senders_(std::move(params.block_senders_)) , block_senders_(std::move(params.block_senders_))
, zero_state_file_hash_(zero_state_file_hash) , zero_state_file_hash_(zero_state_file_hash)
, config_(config) , opts_(opts)
, keyring_(keyring) , keyring_(keyring)
, adnl_(adnl) , adnl_(adnl)
, rldp_(rldp) , rldp_(rldp)
@ -161,7 +161,7 @@ class FullNodeCustomOverlay : public td::actor::Actor {
std::map<adnl::AdnlNodeIdShort, int> msg_senders_; std::map<adnl::AdnlNodeIdShort, int> msg_senders_;
std::set<adnl::AdnlNodeIdShort> block_senders_; std::set<adnl::AdnlNodeIdShort> block_senders_;
FileHash zero_state_file_hash_; FileHash zero_state_file_hash_;
FullNodeConfig config_; FullNodeOptions opts_;
td::actor::ActorId<keyring::Keyring> keyring_; td::actor::ActorId<keyring::Keyring> keyring_;
td::actor::ActorId<adnl::Adnl> adnl_; td::actor::ActorId<adnl::Adnl> adnl_;

View file

@ -105,6 +105,7 @@ void FullNodeShardImpl::create_overlay() {
}; };
overlay::OverlayOptions opts; overlay::OverlayOptions opts;
opts.announce_self_ = active_; opts.announce_self_ = active_;
opts.broadcast_speed_multiplier_ = opts_.public_broadcast_speed_multiplier_;
td::actor::send_closure(overlays_, &overlay::Overlays::create_public_overlay_ex, adnl_id_, overlay_id_full_.clone(), td::actor::send_closure(overlays_, &overlay::Overlays::create_public_overlay_ex, adnl_id_, overlay_id_full_.clone(),
std::make_unique<Callback>(actor_id(this)), rules_, std::make_unique<Callback>(actor_id(this)), rules_,
PSTRING() << "{ \"type\": \"shard\", \"shard_id\": " << get_shard() PSTRING() << "{ \"type\": \"shard\", \"shard_id\": " << get_shard()
@ -132,7 +133,7 @@ void FullNodeShardImpl::check_broadcast(PublicKeyHash src, td::BufferSlice broad
if (!processed_ext_msg_broadcasts_.insert(hash).second) { if (!processed_ext_msg_broadcasts_.insert(hash).second) {
return promise.set_error(td::Status::Error("duplicate external message broadcast")); return promise.set_error(td::Status::Error("duplicate external message broadcast"));
} }
if (config_.ext_messages_broadcast_disabled_) { if (opts_.config_.ext_messages_broadcast_disabled_) {
promise.set_error(td::Status::Error("rebroadcasting external messages is disabled")); promise.set_error(td::Status::Error("rebroadcasting external messages is disabled"));
promise = [manager = validator_manager_, message = q->message_->data_.clone()](td::Result<td::Unit> R) mutable { promise = [manager = validator_manager_, message = q->message_->data_.clone()](td::Result<td::Unit> R) mutable {
if (R.is_ok()) { if (R.is_ok()) {
@ -850,7 +851,7 @@ void FullNodeShardImpl::send_ihr_message(td::BufferSlice data) {
} }
void FullNodeShardImpl::send_external_message(td::BufferSlice data) { void FullNodeShardImpl::send_external_message(td::BufferSlice data) {
if (config_.ext_messages_broadcast_disabled_) { if (opts_.config_.ext_messages_broadcast_disabled_) {
return; return;
} }
if (!client_.empty()) { if (!client_.empty()) {
@ -1367,7 +1368,7 @@ void FullNodeShardImpl::get_stats_extra(td::Promise<std::string> promise) {
} }
FullNodeShardImpl::FullNodeShardImpl(ShardIdFull shard, PublicKeyHash local_id, adnl::AdnlNodeIdShort adnl_id, FullNodeShardImpl::FullNodeShardImpl(ShardIdFull shard, PublicKeyHash local_id, adnl::AdnlNodeIdShort adnl_id,
FileHash zero_state_file_hash, FullNodeConfig config, FileHash zero_state_file_hash, FullNodeOptions opts,
td::actor::ActorId<keyring::Keyring> keyring, td::actor::ActorId<adnl::Adnl> adnl, 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<rldp::Rldp> rldp, td::actor::ActorId<rldp2::Rldp> rldp2,
td::actor::ActorId<overlay::Overlays> overlays, td::actor::ActorId<overlay::Overlays> overlays,
@ -1387,17 +1388,17 @@ FullNodeShardImpl::FullNodeShardImpl(ShardIdFull shard, PublicKeyHash local_id,
, client_(client) , client_(client)
, full_node_(full_node) , full_node_(full_node)
, active_(active) , active_(active)
, config_(config) { , opts_(opts) {
} }
td::actor::ActorOwn<FullNodeShard> FullNodeShard::create( td::actor::ActorOwn<FullNodeShard> FullNodeShard::create(
ShardIdFull shard, PublicKeyHash local_id, adnl::AdnlNodeIdShort adnl_id, FileHash zero_state_file_hash, ShardIdFull shard, 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, FullNodeOptions opts, 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<rldp::Rldp> rldp, td::actor::ActorId<rldp2::Rldp> rldp2,
td::actor::ActorId<overlay::Overlays> overlays, td::actor::ActorId<ValidatorManagerInterface> validator_manager, td::actor::ActorId<overlay::Overlays> overlays, td::actor::ActorId<ValidatorManagerInterface> validator_manager,
td::actor::ActorId<adnl::AdnlExtClient> client, td::actor::ActorId<FullNode> full_node, bool active) { td::actor::ActorId<adnl::AdnlExtClient> client, td::actor::ActorId<FullNode> full_node, bool active) {
return td::actor::create_actor<FullNodeShardImpl>(PSTRING() << "tonnode" << shard.to_str(), shard, local_id, adnl_id, return td::actor::create_actor<FullNodeShardImpl>(PSTRING() << "tonnode" << shard.to_str(), shard, local_id, adnl_id,
zero_state_file_hash, config, keyring, adnl, rldp, rldp2, overlays, zero_state_file_hash, opts, keyring, adnl, rldp, rldp2, overlays,
validator_manager, client, full_node, active); validator_manager, client, full_node, active);
} }

View file

@ -76,7 +76,7 @@ class FullNodeShard : public td::actor::Actor {
static td::actor::ActorOwn<FullNodeShard> create( static td::actor::ActorOwn<FullNodeShard> create(
ShardIdFull shard, PublicKeyHash local_id, adnl::AdnlNodeIdShort adnl_id, FileHash zero_state_file_hash, ShardIdFull shard, 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, FullNodeOptions opts, 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<rldp::Rldp> rldp, td::actor::ActorId<rldp2::Rldp> rldp2,
td::actor::ActorId<overlay::Overlays> overlays, td::actor::ActorId<ValidatorManagerInterface> validator_manager, td::actor::ActorId<overlay::Overlays> overlays, td::actor::ActorId<ValidatorManagerInterface> validator_manager,
td::actor::ActorId<adnl::AdnlExtClient> client, td::actor::ActorId<FullNode> full_node, bool active); td::actor::ActorId<adnl::AdnlExtClient> client, td::actor::ActorId<FullNode> full_node, bool active);

View file

@ -86,7 +86,7 @@ class FullNodeShardImpl : public FullNodeShard {
void set_active(bool active) override; void set_active(bool active) override;
void set_config(FullNodeConfig config) override { void set_config(FullNodeConfig config) override {
config_ = config; opts_.config_ = config;
} }
void try_get_next_block(td::Timestamp timestamp, td::Promise<ReceivedBlock> promise); void try_get_next_block(td::Timestamp timestamp, td::Promise<ReceivedBlock> promise);
@ -222,7 +222,7 @@ class FullNodeShardImpl : public FullNodeShard {
} }
FullNodeShardImpl(ShardIdFull shard, PublicKeyHash local_id, adnl::AdnlNodeIdShort adnl_id, FullNodeShardImpl(ShardIdFull shard, PublicKeyHash local_id, adnl::AdnlNodeIdShort adnl_id,
FileHash zero_state_file_hash, FullNodeConfig config, td::actor::ActorId<keyring::Keyring> keyring, FileHash zero_state_file_hash, FullNodeOptions opts, td::actor::ActorId<keyring::Keyring> keyring,
td::actor::ActorId<adnl::Adnl> adnl, td::actor::ActorId<rldp::Rldp> rldp, td::actor::ActorId<adnl::Adnl> adnl, td::actor::ActorId<rldp::Rldp> rldp,
td::actor::ActorId<rldp2::Rldp> rldp2, td::actor::ActorId<overlay::Overlays> overlays, td::actor::ActorId<rldp2::Rldp> rldp2, td::actor::ActorId<overlay::Overlays> overlays,
td::actor::ActorId<ValidatorManagerInterface> validator_manager, td::actor::ActorId<ValidatorManagerInterface> validator_manager,
@ -269,7 +269,7 @@ class FullNodeShardImpl : public FullNodeShard {
bool active_; bool active_;
FullNodeConfig config_; FullNodeOptions opts_;
std::set<td::Bits256> my_ext_msg_broadcasts_; std::set<td::Bits256> my_ext_msg_broadcasts_;
std::set<td::Bits256> processed_ext_msg_broadcasts_; std::set<td::Bits256> processed_ext_msg_broadcasts_;

View file

@ -139,7 +139,7 @@ void FullNodeImpl::update_adnl_id(adnl::AdnlNodeIdShort adnl_id, td::Promise<td:
} }
void FullNodeImpl::set_config(FullNodeConfig config) { void FullNodeImpl::set_config(FullNodeConfig config) {
config_ = config; opts_.config_ = config;
for (auto& s : shards_) { for (auto& s : shards_) {
if (!s.second.actor.empty()) { if (!s.second.actor.empty()) {
td::actor::send_closure(s.second.actor, &FullNodeShard::set_config, config); td::actor::send_closure(s.second.actor, &FullNodeShard::set_config, config);
@ -256,7 +256,7 @@ void FullNodeImpl::on_new_masterchain_block(td::Ref<MasterchainState> state, std
void FullNodeImpl::update_shard_actor(ShardIdFull shard, bool active) { void FullNodeImpl::update_shard_actor(ShardIdFull shard, bool active) {
ShardInfo &info = shards_[shard]; ShardInfo &info = shards_[shard];
if (info.actor.empty()) { if (info.actor.empty()) {
info.actor = FullNodeShard::create(shard, local_id_, adnl_id_, zero_state_file_hash_, config_, keyring_, adnl_, rldp_, info.actor = FullNodeShard::create(shard, local_id_, adnl_id_, zero_state_file_hash_, opts_, keyring_, adnl_, rldp_,
rldp2_, overlays_, validator_manager_, client_, actor_id(this), active); rldp2_, overlays_, validator_manager_, client_, actor_id(this), active);
if (!all_validators_.empty()) { if (!all_validators_.empty()) {
td::actor::send_closure(info.actor, &FullNodeShard::update_validators, all_validators_, sign_cert_by_); td::actor::send_closure(info.actor, &FullNodeShard::update_validators, all_validators_, sign_cert_by_);
@ -717,7 +717,7 @@ void FullNodeImpl::create_private_block_overlay(PublicKeyHash key) {
nodes.push_back(p.second); nodes.push_back(p.second);
} }
private_block_overlays_[key] = td::actor::create_actor<FullNodePrivateBlockOverlay>( private_block_overlays_[key] = td::actor::create_actor<FullNodePrivateBlockOverlay>(
"BlocksPrivateOverlay", current_validators_[key], std::move(nodes), zero_state_file_hash_, config_, keyring_, "BlocksPrivateOverlay", current_validators_[key], std::move(nodes), zero_state_file_hash_, opts_, keyring_,
adnl_, rldp_, rldp2_, overlays_, validator_manager_, actor_id(this)); adnl_, rldp_, rldp2_, overlays_, validator_manager_, actor_id(this));
update_validator_telemetry_collector(); update_validator_telemetry_collector();
} }
@ -735,7 +735,7 @@ void FullNodeImpl::update_custom_overlay(CustomOverlayInfo &overlay) {
old_actors.erase(it); old_actors.erase(it);
} else { } else {
overlay.actors_[local_id] = td::actor::create_actor<FullNodeCustomOverlay>( overlay.actors_[local_id] = td::actor::create_actor<FullNodeCustomOverlay>(
"CustomOverlay", local_id, params, zero_state_file_hash_, config_, keyring_, adnl_, rldp_, rldp2_, "CustomOverlay", local_id, params, zero_state_file_hash_, opts_, keyring_, adnl_, rldp_, rldp2_,
overlays_, validator_manager_, actor_id(this)); overlays_, validator_manager_, actor_id(this));
} }
} }
@ -794,7 +794,7 @@ void FullNodeImpl::send_block_candidate_broadcast_to_custom_overlays(const Block
} }
FullNodeImpl::FullNodeImpl(PublicKeyHash local_id, adnl::AdnlNodeIdShort adnl_id, FileHash zero_state_file_hash, FullNodeImpl::FullNodeImpl(PublicKeyHash local_id, adnl::AdnlNodeIdShort adnl_id, FileHash zero_state_file_hash,
FullNodeConfig config, td::actor::ActorId<keyring::Keyring> keyring, FullNodeOptions opts, td::actor::ActorId<keyring::Keyring> keyring,
td::actor::ActorId<adnl::Adnl> adnl, td::actor::ActorId<rldp::Rldp> rldp, td::actor::ActorId<adnl::Adnl> adnl, td::actor::ActorId<rldp::Rldp> rldp,
td::actor::ActorId<rldp2::Rldp> rldp2, td::actor::ActorId<dht::Dht> dht, td::actor::ActorId<rldp2::Rldp> rldp2, td::actor::ActorId<dht::Dht> dht,
td::actor::ActorId<overlay::Overlays> overlays, td::actor::ActorId<overlay::Overlays> overlays,
@ -814,16 +814,16 @@ FullNodeImpl::FullNodeImpl(PublicKeyHash local_id, adnl::AdnlNodeIdShort adnl_id
, client_(client) , client_(client)
, db_root_(db_root) , db_root_(db_root)
, started_promise_(std::move(started_promise)) , started_promise_(std::move(started_promise))
, config_(config) { , opts_(opts) {
} }
td::actor::ActorOwn<FullNode> FullNode::create( td::actor::ActorOwn<FullNode> FullNode::create(
ton::PublicKeyHash local_id, adnl::AdnlNodeIdShort adnl_id, FileHash zero_state_file_hash, FullNodeConfig config, ton::PublicKeyHash local_id, adnl::AdnlNodeIdShort adnl_id, FileHash zero_state_file_hash, FullNodeOptions opts,
td::actor::ActorId<keyring::Keyring> keyring, td::actor::ActorId<adnl::Adnl> adnl, 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<dht::Dht> dht, td::actor::ActorId<rldp::Rldp> rldp, td::actor::ActorId<rldp2::Rldp> rldp2, td::actor::ActorId<dht::Dht> dht,
td::actor::ActorId<overlay::Overlays> overlays, td::actor::ActorId<ValidatorManagerInterface> validator_manager, td::actor::ActorId<overlay::Overlays> overlays, td::actor::ActorId<ValidatorManagerInterface> validator_manager,
td::actor::ActorId<adnl::AdnlExtClient> client, std::string db_root, td::Promise<td::Unit> started_promise) { td::actor::ActorId<adnl::AdnlExtClient> client, std::string db_root, td::Promise<td::Unit> started_promise) {
return td::actor::create_actor<FullNodeImpl>("fullnode", local_id, adnl_id, zero_state_file_hash, config, keyring, return td::actor::create_actor<FullNodeImpl>("fullnode", local_id, adnl_id, zero_state_file_hash, opts, keyring,
adnl, rldp, rldp2, dht, overlays, validator_manager, client, db_root, adnl, rldp, rldp2, dht, overlays, validator_manager, client, db_root,
std::move(started_promise)); std::move(started_promise));
} }

View file

@ -55,6 +55,12 @@ struct FullNodeConfig {
bool ext_messages_broadcast_disabled_ = false; bool ext_messages_broadcast_disabled_ = false;
}; };
struct FullNodeOptions {
FullNodeConfig config_;
double public_broadcast_speed_multiplier_ = 1.0;
double private_broadcast_speed_multiplier_ = 1.0;
};
struct CustomOverlayParams { struct CustomOverlayParams {
std::string name_; std::string name_;
std::vector<adnl::AdnlNodeIdShort> nodes_; std::vector<adnl::AdnlNodeIdShort> nodes_;
@ -107,7 +113,7 @@ class FullNode : public td::actor::Actor {
enum { broadcast_mode_public = 1, broadcast_mode_private_block = 2, broadcast_mode_custom = 4 }; enum { broadcast_mode_public = 1, broadcast_mode_private_block = 2, broadcast_mode_custom = 4 };
static td::actor::ActorOwn<FullNode> create( static td::actor::ActorOwn<FullNode> create(
ton::PublicKeyHash local_id, adnl::AdnlNodeIdShort adnl_id, FileHash zero_state_file_hash, FullNodeConfig config, ton::PublicKeyHash local_id, adnl::AdnlNodeIdShort adnl_id, FileHash zero_state_file_hash, FullNodeOptions opts,
td::actor::ActorId<keyring::Keyring> keyring, td::actor::ActorId<adnl::Adnl> adnl, 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<dht::Dht> dht, td::actor::ActorId<rldp::Rldp> rldp, td::actor::ActorId<rldp2::Rldp> rldp2, td::actor::ActorId<dht::Dht> dht,
td::actor::ActorId<overlay::Overlays> overlays, td::actor::ActorId<ValidatorManagerInterface> validator_manager, td::actor::ActorId<overlay::Overlays> overlays, td::actor::ActorId<ValidatorManagerInterface> validator_manager,

View file

@ -98,7 +98,7 @@ class FullNodeImpl : public FullNode {
void start_up() override; void start_up() override;
FullNodeImpl(PublicKeyHash local_id, adnl::AdnlNodeIdShort adnl_id, FileHash zero_state_file_hash, 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, FullNodeOptions opts, 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<rldp::Rldp> rldp, td::actor::ActorId<rldp2::Rldp> rldp2,
td::actor::ActorId<dht::Dht> dht, td::actor::ActorId<overlay::Overlays> overlays, td::actor::ActorId<dht::Dht> dht, td::actor::ActorId<overlay::Overlays> overlays,
td::actor::ActorId<ValidatorManagerInterface> validator_manager, td::actor::ActorId<ValidatorManagerInterface> validator_manager,
@ -141,7 +141,7 @@ class FullNodeImpl : public FullNode {
std::set<PublicKeyHash> local_keys_; std::set<PublicKeyHash> local_keys_;
td::Promise<td::Unit> started_promise_; td::Promise<td::Unit> started_promise_;
FullNodeConfig config_; FullNodeOptions opts_;
std::map<PublicKeyHash, td::actor::ActorOwn<FullNodePrivateBlockOverlay>> private_block_overlays_; std::map<PublicKeyHash, td::actor::ActorOwn<FullNodePrivateBlockOverlay>> private_block_overlays_;
bool broadcast_block_candidates_in_public_overlay_ = false; bool broadcast_block_candidates_in_public_overlay_ = false;

View file

@ -373,6 +373,7 @@ void ValidatorGroup::create_session() {
} }
CHECK(found); CHECK(found);
config_.catchain_opts.broadcast_speed_multiplier = opts_->get_catchain_broadcast_speed_multiplier();
if (!config_.new_catchain_ids) { if (!config_.new_catchain_ids) {
session_ = validatorsession::ValidatorSession::create(session_id_, config_, local_id_, std::move(vec), session_ = validatorsession::ValidatorSession::create(session_id_, config_, local_id_, std::move(vec),
make_validator_session_callback(), keyring_, adnl_, rldp_, make_validator_session_callback(), keyring_, adnl_, rldp_,

View file

@ -154,6 +154,9 @@ struct ValidatorManagerOptionsImpl : public ValidatorManagerOptions {
bool get_fast_state_serializer_enabled() const override { bool get_fast_state_serializer_enabled() const override {
return fast_state_serializer_enabled_; return fast_state_serializer_enabled_;
} }
double get_catchain_broadcast_speed_multiplier() const override {
return catchain_broadcast_speed_multipliers_;
}
void set_zero_block_id(BlockIdExt block_id) override { void set_zero_block_id(BlockIdExt block_id) override {
zero_block_id_ = block_id; zero_block_id_ = block_id;
@ -249,6 +252,9 @@ struct ValidatorManagerOptionsImpl : public ValidatorManagerOptions {
void set_fast_state_serializer_enabled(bool value) override { void set_fast_state_serializer_enabled(bool value) override {
fast_state_serializer_enabled_ = value; fast_state_serializer_enabled_ = value;
} }
void set_catchain_broadcast_speed_multiplier(double value) override {
catchain_broadcast_speed_multipliers_ = value;
}
ValidatorManagerOptionsImpl *make_copy() const override { ValidatorManagerOptionsImpl *make_copy() const override {
return new ValidatorManagerOptionsImpl(*this); return new ValidatorManagerOptionsImpl(*this);
@ -302,6 +308,7 @@ struct ValidatorManagerOptionsImpl : public ValidatorManagerOptions {
bool state_serializer_enabled_ = true; bool state_serializer_enabled_ = true;
td::Ref<CollatorOptions> collator_options_{true}; td::Ref<CollatorOptions> collator_options_{true};
bool fast_state_serializer_enabled_ = false; bool fast_state_serializer_enabled_ = false;
double catchain_broadcast_speed_multipliers_;
}; };
} // namespace validator } // namespace validator

View file

@ -116,6 +116,7 @@ struct ValidatorManagerOptions : public td::CntObject {
virtual bool get_state_serializer_enabled() const = 0; virtual bool get_state_serializer_enabled() const = 0;
virtual td::Ref<CollatorOptions> get_collator_options() const = 0; virtual td::Ref<CollatorOptions> get_collator_options() const = 0;
virtual bool get_fast_state_serializer_enabled() const = 0; virtual bool get_fast_state_serializer_enabled() const = 0;
virtual double get_catchain_broadcast_speed_multiplier() const = 0;
virtual void set_zero_block_id(BlockIdExt block_id) = 0; virtual void set_zero_block_id(BlockIdExt block_id) = 0;
virtual void set_init_block_id(BlockIdExt block_id) = 0; virtual void set_init_block_id(BlockIdExt block_id) = 0;
@ -148,6 +149,7 @@ struct ValidatorManagerOptions : public td::CntObject {
virtual void set_state_serializer_enabled(bool value) = 0; virtual void set_state_serializer_enabled(bool value) = 0;
virtual void set_collator_options(td::Ref<CollatorOptions> value) = 0; virtual void set_collator_options(td::Ref<CollatorOptions> value) = 0;
virtual void set_fast_state_serializer_enabled(bool value) = 0; virtual void set_fast_state_serializer_enabled(bool value) = 0;
virtual void set_catchain_broadcast_speed_multiplier(double value) = 0;
static td::Ref<ValidatorManagerOptions> create( static td::Ref<ValidatorManagerOptions> create(
BlockIdExt zero_block_id, BlockIdExt init_block_id, BlockIdExt zero_block_id, BlockIdExt init_block_id,