mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Rename private ext msg overlays to custom overlays, change interface a bit (#952)
Co-authored-by: SpyCheese <mikle98@yandex.ru>
This commit is contained in:
parent
0434eadc1f
commit
f7907bdd58
11 changed files with 121 additions and 125 deletions
|
@ -400,7 +400,7 @@ tonNode.newShardBlockBroadcast block:tonNode.newShardBlock = tonNode.Broadcast;
|
|||
tonNode.shardPublicOverlayId workchain:int shard:long zero_state_file_hash:int256 = tonNode.ShardPublicOverlayId;
|
||||
|
||||
tonNode.privateBlockOverlayId zero_state_file_hash:int256 nodes:(vector int256) = tonNode.PrivateBlockOverlayId;
|
||||
tonNode.privateExtMsgsOverlayId zero_state_file_hash:int256 name:string nodes:(vector int256) = tonNode.PrivateExtMsgsOverlayId;
|
||||
tonNode.customOverlayId zero_state_file_hash:int256 name:string nodes:(vector int256) = tonNode.CustomOverlayId;
|
||||
|
||||
tonNode.keyBlocks blocks:(vector tonNode.blockIdExt) incomplete:Bool error:Bool = tonNode.KeyBlocks;
|
||||
|
||||
|
@ -595,9 +595,9 @@ engine.validator.config out_port:int addrs:(vector engine.Addr) adnl:(vector eng
|
|||
liteservers:(vector engine.liteServer) control:(vector engine.controlInterface)
|
||||
gc:engine.gc = engine.validator.Config;
|
||||
|
||||
engine.validator.privateExtMsgOverlayNode adnl_id:int256 sender:Bool sender_priority:int = engine.validator.PrivateExtMsgOverlayNode;
|
||||
engine.validator.privateExtMsgOverlay name:string nodes:(vector engine.validator.privateExtMsgOverlayNode) = engine.validator.PrivateExtMsgOverlay;
|
||||
engine.validator.privateExtMsgOverlaysConfig overlays:(vector engine.validator.privateExtMsgOverlay) = engine.validator.PrivateExtMsgOverlaysConfig;
|
||||
engine.validator.customOverlayNode adnl_id:int256 msg_sender:Bool msg_sender_priority:int = engine.validator.CustomOverlayNode;
|
||||
engine.validator.customOverlay name:string nodes:(vector engine.validator.customOverlayNode) = engine.validator.CustomOverlay;
|
||||
engine.validator.customOverlaysConfig overlays:(vector engine.validator.customOverlay) = engine.validator.CustomOverlaysConfig;
|
||||
|
||||
---functions---
|
||||
---types---
|
||||
|
@ -702,9 +702,9 @@ engine.validator.getPerfTimerStats name:string = engine.validator.PerfTimerStats
|
|||
engine.validator.getShardOutQueueSize flags:# block_id:tonNode.blockId dest_wc:flags.0?int dest_shard:flags.0?long = engine.validator.ShardOutQueueSize;
|
||||
engine.validator.setExtMessagesBroadcastDisabled disabled:Bool = engine.validator.Success;
|
||||
|
||||
engine.validator.addPrivateExtMsgOverlay overlay:engine.validator.privateExtMsgOverlay = engine.validator.Success;
|
||||
engine.validator.delPrivateExtMsgOverlay name:string = engine.validator.Success;
|
||||
engine.validator.showPrivateExtMsgOverlays = engine.validator.PrivateExtMsgOverlaysConfig;
|
||||
engine.validator.addCustomOverlay overlay:engine.validator.customOverlay = engine.validator.Success;
|
||||
engine.validator.delCustomOverlay name:string = engine.validator.Success;
|
||||
engine.validator.showCustomOverlays = engine.validator.CustomOverlaysConfig;
|
||||
|
||||
---types---
|
||||
|
||||
|
|
Binary file not shown.
|
@ -1110,69 +1110,69 @@ td::Status SetExtMessagesBroadcastDisabledQuery::receive(td::BufferSlice data) {
|
|||
return td::Status::OK();
|
||||
}
|
||||
|
||||
td::Status AddPrivateExtMsgOverlayQuery::run() {
|
||||
td::Status AddCustomOverlayQuery::run() {
|
||||
TRY_RESULT_ASSIGN(file_name_, tokenizer_.get_token<std::string>());
|
||||
TRY_STATUS(tokenizer_.check_endl());
|
||||
return td::Status::OK();
|
||||
}
|
||||
|
||||
td::Status AddPrivateExtMsgOverlayQuery::send() {
|
||||
td::Status AddCustomOverlayQuery::send() {
|
||||
TRY_RESULT(data, td::read_file(file_name_));
|
||||
TRY_RESULT(json, td::json_decode(data.as_slice()));
|
||||
auto overlay = ton::create_tl_object<ton::ton_api::engine_validator_privateExtMsgOverlay>();
|
||||
auto overlay = ton::create_tl_object<ton::ton_api::engine_validator_customOverlay>();
|
||||
TRY_STATUS(ton::ton_api::from_json(*overlay, json.get_object()));
|
||||
auto b = ton::create_serialize_tl_object<ton::ton_api::engine_validator_addPrivateExtMsgOverlay>(std::move(overlay));
|
||||
auto b = ton::create_serialize_tl_object<ton::ton_api::engine_validator_addCustomOverlay>(std::move(overlay));
|
||||
td::actor::send_closure(console_, &ValidatorEngineConsole::envelope_send_query, std::move(b), create_promise());
|
||||
return td::Status::OK();
|
||||
}
|
||||
|
||||
td::Status AddPrivateExtMsgOverlayQuery::receive(td::BufferSlice data) {
|
||||
td::Status AddCustomOverlayQuery::receive(td::BufferSlice data) {
|
||||
TRY_RESULT_PREFIX(f, ton::fetch_tl_object<ton::ton_api::engine_validator_success>(data.as_slice(), true),
|
||||
"received incorrect answer: ");
|
||||
td::TerminalIO::out() << "success\n";
|
||||
return td::Status::OK();
|
||||
}
|
||||
|
||||
td::Status DelPrivateExtMsgOverlayQuery::run() {
|
||||
td::Status DelCustomOverlayQuery::run() {
|
||||
TRY_RESULT_ASSIGN(name_, tokenizer_.get_token<std::string>());
|
||||
TRY_STATUS(tokenizer_.check_endl());
|
||||
return td::Status::OK();
|
||||
}
|
||||
|
||||
td::Status DelPrivateExtMsgOverlayQuery::send() {
|
||||
auto b = ton::create_serialize_tl_object<ton::ton_api::engine_validator_delPrivateExtMsgOverlay>(name_);
|
||||
td::Status DelCustomOverlayQuery::send() {
|
||||
auto b = ton::create_serialize_tl_object<ton::ton_api::engine_validator_delCustomOverlay>(name_);
|
||||
td::actor::send_closure(console_, &ValidatorEngineConsole::envelope_send_query, std::move(b), create_promise());
|
||||
return td::Status::OK();
|
||||
}
|
||||
|
||||
td::Status DelPrivateExtMsgOverlayQuery::receive(td::BufferSlice data) {
|
||||
td::Status DelCustomOverlayQuery::receive(td::BufferSlice data) {
|
||||
TRY_RESULT_PREFIX(f, ton::fetch_tl_object<ton::ton_api::engine_validator_success>(data.as_slice(), true),
|
||||
"received incorrect answer: ");
|
||||
td::TerminalIO::out() << "success\n";
|
||||
return td::Status::OK();
|
||||
}
|
||||
|
||||
td::Status ShowPrivateExtMsgOverlaysQuery::run() {
|
||||
td::Status ShowCustomOverlaysQuery::run() {
|
||||
TRY_STATUS(tokenizer_.check_endl());
|
||||
return td::Status::OK();
|
||||
}
|
||||
|
||||
td::Status ShowPrivateExtMsgOverlaysQuery::send() {
|
||||
auto b = ton::create_serialize_tl_object<ton::ton_api::engine_validator_showPrivateExtMsgOverlays>();
|
||||
td::Status ShowCustomOverlaysQuery::send() {
|
||||
auto b = ton::create_serialize_tl_object<ton::ton_api::engine_validator_showCustomOverlays>();
|
||||
td::actor::send_closure(console_, &ValidatorEngineConsole::envelope_send_query, std::move(b), create_promise());
|
||||
return td::Status::OK();
|
||||
}
|
||||
|
||||
td::Status ShowPrivateExtMsgOverlaysQuery::receive(td::BufferSlice data) {
|
||||
TRY_RESULT_PREFIX(
|
||||
f, ton::fetch_tl_object<ton::ton_api::engine_validator_privateExtMsgOverlaysConfig>(data.as_slice(), true),
|
||||
"received incorrect answer: ");
|
||||
td::TerminalIO::out() << f->overlays_.size() << " private overlays:\n\n";
|
||||
td::Status ShowCustomOverlaysQuery::receive(td::BufferSlice data) {
|
||||
TRY_RESULT_PREFIX(f, ton::fetch_tl_object<ton::ton_api::engine_validator_customOverlaysConfig>(data.as_slice(), true),
|
||||
"received incorrect answer: ");
|
||||
td::TerminalIO::out() << f->overlays_.size() << " custom overlays:\n\n";
|
||||
for (const auto &overlay : f->overlays_) {
|
||||
td::TerminalIO::out() << "Overlay \"" << overlay->name_ << "\": " << overlay->nodes_.size() << " nodes\n";
|
||||
for (const auto &node : overlay->nodes_) {
|
||||
td::TerminalIO::out() << " " << node->adnl_id_
|
||||
<< (node->sender_ ? (PSTRING() << " (sender, p=" << node->sender_priority_ << ")") : "")
|
||||
<< (node->msg_sender_ ? (PSTRING() << " (sender, p=" << node->msg_sender_priority_ << ")")
|
||||
: "")
|
||||
<< "\n";
|
||||
}
|
||||
td::TerminalIO::out() << "\n";
|
||||
|
|
|
@ -1145,20 +1145,19 @@ class SetExtMessagesBroadcastDisabledQuery : public Query {
|
|||
bool value;
|
||||
};
|
||||
|
||||
class AddPrivateExtMsgOverlayQuery : public Query {
|
||||
class AddCustomOverlayQuery : public Query {
|
||||
public:
|
||||
AddPrivateExtMsgOverlayQuery(td::actor::ActorId<ValidatorEngineConsole> console, Tokenizer tokenizer)
|
||||
AddCustomOverlayQuery(td::actor::ActorId<ValidatorEngineConsole> console, Tokenizer tokenizer)
|
||||
: Query(console, std::move(tokenizer)) {
|
||||
}
|
||||
td::Status run() override;
|
||||
td::Status send() override;
|
||||
td::Status receive(td::BufferSlice data) override;
|
||||
static std::string get_name() {
|
||||
return "addprivateextmsgoverlay";
|
||||
return "addcustomoverlay";
|
||||
}
|
||||
static std::string get_help() {
|
||||
return "addprivateextmsgoverlay <filename>\tadd private overlay for external messages with config from file "
|
||||
"<filename>";
|
||||
return "addcustomoverlay <filename>\tadd custom overlay with config from file <filename>";
|
||||
}
|
||||
std::string name() const override {
|
||||
return get_name();
|
||||
|
@ -1168,19 +1167,19 @@ class AddPrivateExtMsgOverlayQuery : public Query {
|
|||
std::string file_name_;
|
||||
};
|
||||
|
||||
class DelPrivateExtMsgOverlayQuery : public Query {
|
||||
class DelCustomOverlayQuery : public Query {
|
||||
public:
|
||||
DelPrivateExtMsgOverlayQuery(td::actor::ActorId<ValidatorEngineConsole> console, Tokenizer tokenizer)
|
||||
DelCustomOverlayQuery(td::actor::ActorId<ValidatorEngineConsole> console, Tokenizer tokenizer)
|
||||
: Query(console, std::move(tokenizer)) {
|
||||
}
|
||||
td::Status run() override;
|
||||
td::Status send() override;
|
||||
td::Status receive(td::BufferSlice data) override;
|
||||
static std::string get_name() {
|
||||
return "delprivateextmsgoverlay";
|
||||
return "delcustomoverlay";
|
||||
}
|
||||
static std::string get_help() {
|
||||
return "delprivateextmsgoverlay <name>\tdelete private overlay for external messages with name <name>";
|
||||
return "delcustomoverlay <name>\tdelete custom overlay with name <name>";
|
||||
}
|
||||
std::string name() const override {
|
||||
return get_name();
|
||||
|
@ -1190,19 +1189,19 @@ class DelPrivateExtMsgOverlayQuery : public Query {
|
|||
std::string name_;
|
||||
};
|
||||
|
||||
class ShowPrivateExtMsgOverlaysQuery : public Query {
|
||||
class ShowCustomOverlaysQuery : public Query {
|
||||
public:
|
||||
ShowPrivateExtMsgOverlaysQuery(td::actor::ActorId<ValidatorEngineConsole> console, Tokenizer tokenizer)
|
||||
ShowCustomOverlaysQuery(td::actor::ActorId<ValidatorEngineConsole> console, Tokenizer tokenizer)
|
||||
: Query(console, std::move(tokenizer)) {
|
||||
}
|
||||
td::Status run() override;
|
||||
td::Status send() override;
|
||||
td::Status receive(td::BufferSlice data) override;
|
||||
static std::string get_name() {
|
||||
return "showprivateextmsgoverlays";
|
||||
return "showcustomoverlays";
|
||||
}
|
||||
static std::string get_help() {
|
||||
return "showprivateextmsgoverlays\tshow all private overlay for external messages";
|
||||
return "showcustomoverlays\tshow all custom overlays";
|
||||
}
|
||||
std::string name() const override {
|
||||
return get_name();
|
||||
|
|
|
@ -143,9 +143,9 @@ void ValidatorEngineConsole::run() {
|
|||
add_query_runner(std::make_unique<QueryRunnerImpl<GetPerfTimerStatsJsonQuery>>());
|
||||
add_query_runner(std::make_unique<QueryRunnerImpl<GetShardOutQueueSizeQuery>>());
|
||||
add_query_runner(std::make_unique<QueryRunnerImpl<SetExtMessagesBroadcastDisabledQuery>>());
|
||||
add_query_runner(std::make_unique<QueryRunnerImpl<AddPrivateExtMsgOverlayQuery>>());
|
||||
add_query_runner(std::make_unique<QueryRunnerImpl<DelPrivateExtMsgOverlayQuery>>());
|
||||
add_query_runner(std::make_unique<QueryRunnerImpl<ShowPrivateExtMsgOverlaysQuery>>());
|
||||
add_query_runner(std::make_unique<QueryRunnerImpl<AddCustomOverlayQuery>>());
|
||||
add_query_runner(std::make_unique<QueryRunnerImpl<DelCustomOverlayQuery>>());
|
||||
add_query_runner(std::make_unique<QueryRunnerImpl<ShowCustomOverlaysQuery>>());
|
||||
}
|
||||
|
||||
bool ValidatorEngineConsole::envelope_send_query(td::BufferSlice query, td::Promise<td::BufferSlice> promise) {
|
||||
|
|
|
@ -1843,7 +1843,7 @@ void ValidatorEngine::start_full_node() {
|
|||
config_.full_node_config, 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(),
|
||||
overlay_manager_.get(), validator_manager_.get(), full_node_client_.get(), db_root_);
|
||||
load_private_ext_msg_overlays_config();
|
||||
load_custom_overlays_config();
|
||||
}
|
||||
|
||||
for (auto &v : config_.validators) {
|
||||
|
@ -2336,33 +2336,33 @@ void ValidatorEngine::try_del_proxy(td::uint32 ip, td::int32 port, std::vector<A
|
|||
write_config(std::move(promise));
|
||||
}
|
||||
|
||||
void ValidatorEngine::load_private_ext_msg_overlays_config() {
|
||||
private_ext_msg_overlays_config_ =
|
||||
ton::create_tl_object<ton::ton_api::engine_validator_privateExtMsgOverlaysConfig>();
|
||||
auto data_R = td::read_file(private_ext_msg_overlays_config_file());
|
||||
void ValidatorEngine::load_custom_overlays_config() {
|
||||
custom_overlays_config_ =
|
||||
ton::create_tl_object<ton::ton_api::engine_validator_customOverlaysConfig>();
|
||||
auto data_R = td::read_file(custom_overlays_config_file());
|
||||
if (data_R.is_error()) {
|
||||
return;
|
||||
}
|
||||
auto data = data_R.move_as_ok();
|
||||
auto json_R = td::json_decode(data.as_slice());
|
||||
if (json_R.is_error()) {
|
||||
LOG(ERROR) << "Failed to parse private ext msg overlays config: " << json_R.move_as_error();
|
||||
LOG(ERROR) << "Failed to parse custom overlays config: " << json_R.move_as_error();
|
||||
return;
|
||||
}
|
||||
auto json = json_R.move_as_ok();
|
||||
auto S = ton::ton_api::from_json(*private_ext_msg_overlays_config_, json.get_object());
|
||||
auto S = ton::ton_api::from_json(*custom_overlays_config_, json.get_object());
|
||||
if (S.is_error()) {
|
||||
LOG(ERROR) << "Failed to parse private ext msg overlays config: " << S;
|
||||
LOG(ERROR) << "Failed to parse custom overlays config: " << S;
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto &overlay : private_ext_msg_overlays_config_->overlays_) {
|
||||
for (auto &overlay : custom_overlays_config_->overlays_) {
|
||||
std::vector<ton::adnl::AdnlNodeIdShort> nodes;
|
||||
std::map<ton::adnl::AdnlNodeIdShort, int> senders;
|
||||
for (const auto &node : overlay->nodes_) {
|
||||
nodes.emplace_back(node->adnl_id_);
|
||||
if (node->sender_) {
|
||||
senders[ton::adnl::AdnlNodeIdShort{node->adnl_id_}] = node->sender_priority_;
|
||||
if (node->msg_sender_) {
|
||||
senders[ton::adnl::AdnlNodeIdShort{node->adnl_id_}] = node->msg_sender_priority_;
|
||||
}
|
||||
}
|
||||
td::actor::send_closure(full_node_, &ton::validator::fullnode::FullNode::add_ext_msg_overlay, std::move(nodes),
|
||||
|
@ -2370,25 +2370,25 @@ void ValidatorEngine::load_private_ext_msg_overlays_config() {
|
|||
}
|
||||
}
|
||||
|
||||
td::Status ValidatorEngine::write_private_ext_msg_overlays_config() {
|
||||
auto s = td::json_encode<std::string>(td::ToJson(*private_ext_msg_overlays_config_), true);
|
||||
TRY_STATUS_PREFIX(td::write_file(private_ext_msg_overlays_config_file(), s), "failed to write config: ");
|
||||
td::Status ValidatorEngine::write_custom_overlays_config() {
|
||||
auto s = td::json_encode<std::string>(td::ToJson(*custom_overlays_config_), true);
|
||||
TRY_STATUS_PREFIX(td::write_file(custom_overlays_config_file(), s), "failed to write config: ");
|
||||
return td::Status::OK();
|
||||
}
|
||||
|
||||
void ValidatorEngine::add_private_ext_msg_overlay_to_config(
|
||||
ton::tl_object_ptr<ton::ton_api::engine_validator_privateExtMsgOverlay> overlay, td::Promise<td::Unit> promise) {
|
||||
private_ext_msg_overlays_config_->overlays_.push_back(std::move(overlay));
|
||||
TRY_STATUS_PROMISE(promise, write_private_ext_msg_overlays_config());
|
||||
void ValidatorEngine::add_custom_overlay_to_config(
|
||||
ton::tl_object_ptr<ton::ton_api::engine_validator_customOverlay> overlay, td::Promise<td::Unit> promise) {
|
||||
custom_overlays_config_->overlays_.push_back(std::move(overlay));
|
||||
TRY_STATUS_PROMISE(promise, write_custom_overlays_config());
|
||||
promise.set_result(td::Unit());
|
||||
}
|
||||
|
||||
void ValidatorEngine::del_private_ext_msg_overlay_from_config(std::string name, td::Promise<td::Unit> promise) {
|
||||
auto &overlays = private_ext_msg_overlays_config_->overlays_;
|
||||
void ValidatorEngine::del_custom_overlay_from_config(std::string name, td::Promise<td::Unit> promise) {
|
||||
auto &overlays = custom_overlays_config_->overlays_;
|
||||
for (size_t i = 0; i < overlays.size(); ++i) {
|
||||
if (overlays[i]->name_ == name) {
|
||||
overlays.erase(overlays.begin() + i);
|
||||
TRY_STATUS_PROMISE(promise, write_private_ext_msg_overlays_config());
|
||||
TRY_STATUS_PROMISE(promise, write_custom_overlays_config());
|
||||
promise.set_result(td::Unit());
|
||||
return;
|
||||
}
|
||||
|
@ -3550,7 +3550,7 @@ void ValidatorEngine::run_control_query(ton::ton_api::engine_validator_setExtMes
|
|||
});
|
||||
}
|
||||
|
||||
void ValidatorEngine::run_control_query(ton::ton_api::engine_validator_addPrivateExtMsgOverlay &query,
|
||||
void ValidatorEngine::run_control_query(ton::ton_api::engine_validator_addCustomOverlay &query,
|
||||
td::BufferSlice data, ton::PublicKeyHash src, td::uint32 perm,
|
||||
td::Promise<td::BufferSlice> promise) {
|
||||
if (!(perm & ValidatorEnginePermissions::vep_modify)) {
|
||||
|
@ -3567,8 +3567,8 @@ void ValidatorEngine::run_control_query(ton::ton_api::engine_validator_addPrivat
|
|||
std::map<ton::adnl::AdnlNodeIdShort, int> senders;
|
||||
for (const auto &node : overlay->nodes_) {
|
||||
nodes.emplace_back(node->adnl_id_);
|
||||
if (node->sender_) {
|
||||
senders[ton::adnl::AdnlNodeIdShort{node->adnl_id_}] = node->sender_priority_;
|
||||
if (node->msg_sender_) {
|
||||
senders[ton::adnl::AdnlNodeIdShort{node->adnl_id_}] = node->msg_sender_priority_;
|
||||
}
|
||||
}
|
||||
std::string name = overlay->name_;
|
||||
|
@ -3582,7 +3582,7 @@ void ValidatorEngine::run_control_query(ton::ton_api::engine_validator_addPrivat
|
|||
return;
|
||||
}
|
||||
td::actor::send_closure(
|
||||
SelfId, &ValidatorEngine::add_private_ext_msg_overlay_to_config, std::move(overlay),
|
||||
SelfId, &ValidatorEngine::add_custom_overlay_to_config, std::move(overlay),
|
||||
[promise = std::move(promise)](td::Result<td::Unit> R) mutable {
|
||||
if (R.is_error()) {
|
||||
promise.set_value(create_control_query_error(R.move_as_error()));
|
||||
|
@ -3593,7 +3593,7 @@ void ValidatorEngine::run_control_query(ton::ton_api::engine_validator_addPrivat
|
|||
});
|
||||
}
|
||||
|
||||
void ValidatorEngine::run_control_query(ton::ton_api::engine_validator_delPrivateExtMsgOverlay &query,
|
||||
void ValidatorEngine::run_control_query(ton::ton_api::engine_validator_delCustomOverlay &query,
|
||||
td::BufferSlice data, ton::PublicKeyHash src, td::uint32 perm,
|
||||
td::Promise<td::BufferSlice> promise) {
|
||||
if (!(perm & ValidatorEnginePermissions::vep_modify)) {
|
||||
|
@ -3612,7 +3612,7 @@ void ValidatorEngine::run_control_query(ton::ton_api::engine_validator_delPrivat
|
|||
return;
|
||||
}
|
||||
td::actor::send_closure(
|
||||
SelfId, &ValidatorEngine::del_private_ext_msg_overlay_from_config, std::move(name),
|
||||
SelfId, &ValidatorEngine::del_custom_overlay_from_config, std::move(name),
|
||||
[promise = std::move(promise)](td::Result<td::Unit> R) mutable {
|
||||
if (R.is_error()) {
|
||||
promise.set_value(create_control_query_error(R.move_as_error()));
|
||||
|
@ -3623,7 +3623,7 @@ void ValidatorEngine::run_control_query(ton::ton_api::engine_validator_delPrivat
|
|||
});
|
||||
}
|
||||
|
||||
void ValidatorEngine::run_control_query(ton::ton_api::engine_validator_showPrivateExtMsgOverlays &query,
|
||||
void ValidatorEngine::run_control_query(ton::ton_api::engine_validator_showCustomOverlays &query,
|
||||
td::BufferSlice data, ton::PublicKeyHash src, td::uint32 perm,
|
||||
td::Promise<td::BufferSlice> promise) {
|
||||
if (!(perm & ValidatorEnginePermissions::vep_default)) {
|
||||
|
@ -3635,8 +3635,8 @@ void ValidatorEngine::run_control_query(ton::ton_api::engine_validator_showPriva
|
|||
return;
|
||||
}
|
||||
|
||||
promise.set_value(ton::serialize_tl_object<ton::ton_api::engine_validator_privateExtMsgOverlaysConfig>(
|
||||
private_ext_msg_overlays_config_, true));
|
||||
promise.set_value(ton::serialize_tl_object<ton::ton_api::engine_validator_customOverlaysConfig>(
|
||||
custom_overlays_config_, true));
|
||||
}
|
||||
|
||||
void ValidatorEngine::process_control_query(td::uint16 port, ton::adnl::AdnlNodeIdShort src,
|
||||
|
|
|
@ -167,7 +167,7 @@ class ValidatorEngine : public td::actor::Actor {
|
|||
std::shared_ptr<ton::dht::DhtGlobalConfig> dht_config_;
|
||||
td::Ref<ton::validator::ValidatorManagerOptions> validator_options_;
|
||||
Config config_;
|
||||
ton::tl_object_ptr<ton::ton_api::engine_validator_privateExtMsgOverlaysConfig> private_ext_msg_overlays_config_;
|
||||
ton::tl_object_ptr<ton::ton_api::engine_validator_customOverlaysConfig> custom_overlays_config_;
|
||||
|
||||
std::set<ton::PublicKeyHash> running_gc_;
|
||||
|
||||
|
@ -363,15 +363,15 @@ class ValidatorEngine : public td::actor::Actor {
|
|||
void try_del_proxy(td::uint32 ip, td::int32 port, std::vector<AdnlCategory> cats, std::vector<AdnlCategory> prio_cats,
|
||||
td::Promise<td::Unit> promise);
|
||||
|
||||
std::string private_ext_msg_overlays_config_file() const {
|
||||
return db_root_ + "/private-ext-msg-overlays.json";
|
||||
std::string custom_overlays_config_file() const {
|
||||
return db_root_ + "/custom-overlays.json";
|
||||
}
|
||||
|
||||
void load_private_ext_msg_overlays_config();
|
||||
td::Status write_private_ext_msg_overlays_config();
|
||||
void add_private_ext_msg_overlay_to_config(
|
||||
ton::tl_object_ptr<ton::ton_api::engine_validator_privateExtMsgOverlay> overlay, td::Promise<td::Unit> promise);
|
||||
void del_private_ext_msg_overlay_from_config(std::string name, td::Promise<td::Unit> promise);
|
||||
void load_custom_overlays_config();
|
||||
td::Status write_custom_overlays_config();
|
||||
void add_custom_overlay_to_config(
|
||||
ton::tl_object_ptr<ton::ton_api::engine_validator_customOverlay> overlay, td::Promise<td::Unit> promise);
|
||||
void del_custom_overlay_from_config(std::string name, td::Promise<td::Unit> promise);
|
||||
|
||||
void check_key(ton::PublicKeyHash id, td::Promise<td::Unit> promise);
|
||||
|
||||
|
@ -451,11 +451,11 @@ class ValidatorEngine : public td::actor::Actor {
|
|||
ton::PublicKeyHash src, td::uint32 perm, td::Promise<td::BufferSlice> promise);
|
||||
void run_control_query(ton::ton_api::engine_validator_setExtMessagesBroadcastDisabled &query, td::BufferSlice data,
|
||||
ton::PublicKeyHash src, td::uint32 perm, td::Promise<td::BufferSlice> promise);
|
||||
void run_control_query(ton::ton_api::engine_validator_addPrivateExtMsgOverlay &query, td::BufferSlice data,
|
||||
void run_control_query(ton::ton_api::engine_validator_addCustomOverlay &query, td::BufferSlice data,
|
||||
ton::PublicKeyHash src, td::uint32 perm, td::Promise<td::BufferSlice> promise);
|
||||
void run_control_query(ton::ton_api::engine_validator_delPrivateExtMsgOverlay &query, td::BufferSlice data,
|
||||
void run_control_query(ton::ton_api::engine_validator_delCustomOverlay &query, td::BufferSlice data,
|
||||
ton::PublicKeyHash src, td::uint32 perm, td::Promise<td::BufferSlice> promise);
|
||||
void run_control_query(ton::ton_api::engine_validator_showPrivateExtMsgOverlays &query, td::BufferSlice data,
|
||||
void run_control_query(ton::ton_api::engine_validator_showCustomOverlays &query, td::BufferSlice data,
|
||||
ton::PublicKeyHash src, td::uint32 perm, td::Promise<td::BufferSlice> promise);
|
||||
template <class T>
|
||||
void run_control_query(T &query, td::BufferSlice data, ton::PublicKeyHash src, td::uint32 perm,
|
||||
|
|
|
@ -169,8 +169,7 @@ void FullNodePrivateBlockOverlay::tear_down() {
|
|||
}
|
||||
}
|
||||
|
||||
void FullNodePrivateExtMsgOverlay::process_broadcast(PublicKeyHash src,
|
||||
ton_api::tonNode_externalMessageBroadcast &query) {
|
||||
void FullNodeCustomOverlay::process_broadcast(PublicKeyHash src, ton_api::tonNode_externalMessageBroadcast &query) {
|
||||
auto it = senders_.find(adnl::AdnlNodeIdShort{src});
|
||||
if (it == senders_.end()) {
|
||||
return;
|
||||
|
@ -181,7 +180,7 @@ void FullNodePrivateExtMsgOverlay::process_broadcast(PublicKeyHash src,
|
|||
std::move(query.message_->data_), it->second);
|
||||
}
|
||||
|
||||
void FullNodePrivateExtMsgOverlay::receive_broadcast(PublicKeyHash src, td::BufferSlice broadcast) {
|
||||
void FullNodeCustomOverlay::receive_broadcast(PublicKeyHash src, td::BufferSlice broadcast) {
|
||||
auto B = fetch_tl_object<ton_api::tonNode_Broadcast>(std::move(broadcast), true);
|
||||
if (B.is_error()) {
|
||||
return;
|
||||
|
@ -189,7 +188,7 @@ void FullNodePrivateExtMsgOverlay::receive_broadcast(PublicKeyHash src, td::Buff
|
|||
ton_api::downcast_call(*B.move_as_ok(), [src, Self = this](auto &obj) { Self->process_broadcast(src, obj); });
|
||||
}
|
||||
|
||||
void FullNodePrivateExtMsgOverlay::send_external_message(td::BufferSlice data) {
|
||||
void FullNodeCustomOverlay::send_external_message(td::BufferSlice data) {
|
||||
if (config_.ext_messages_broadcast_disabled_) {
|
||||
return;
|
||||
}
|
||||
|
@ -205,15 +204,14 @@ void FullNodePrivateExtMsgOverlay::send_external_message(td::BufferSlice data) {
|
|||
}
|
||||
}
|
||||
|
||||
void FullNodePrivateExtMsgOverlay::start_up() {
|
||||
void FullNodeCustomOverlay::start_up() {
|
||||
std::sort(nodes_.begin(), nodes_.end());
|
||||
nodes_.erase(std::unique(nodes_.begin(), nodes_.end()), nodes_.end());
|
||||
std::vector<td::Bits256> nodes;
|
||||
for (const adnl::AdnlNodeIdShort &id : nodes_) {
|
||||
nodes.push_back(id.bits256_value());
|
||||
}
|
||||
auto X =
|
||||
create_hash_tl_object<ton_api::tonNode_privateExtMsgsOverlayId>(zero_state_file_hash_, name_, std::move(nodes));
|
||||
auto X = create_hash_tl_object<ton_api::tonNode_customOverlayId>(zero_state_file_hash_, name_, std::move(nodes));
|
||||
td::BufferSlice b{32};
|
||||
b.as_slice().copy_from(as_slice(X));
|
||||
overlay_id_full_ = overlay::OverlayIdFull{std::move(b)};
|
||||
|
@ -221,21 +219,21 @@ void FullNodePrivateExtMsgOverlay::start_up() {
|
|||
try_init();
|
||||
}
|
||||
|
||||
void FullNodePrivateExtMsgOverlay::try_init() {
|
||||
void FullNodeCustomOverlay::try_init() {
|
||||
// Sometimes adnl id is added to validator engine later (or not at all)
|
||||
td::actor::send_closure(
|
||||
adnl_, &adnl::Adnl::check_id_exists, local_id_, [SelfId = actor_id(this)](td::Result<bool> R) {
|
||||
if (R.is_ok() && R.ok()) {
|
||||
td::actor::send_closure(SelfId, &FullNodePrivateExtMsgOverlay::init);
|
||||
td::actor::send_closure(SelfId, &FullNodeCustomOverlay::init);
|
||||
} else {
|
||||
delay_action([SelfId]() { td::actor::send_closure(SelfId, &FullNodePrivateExtMsgOverlay::try_init); },
|
||||
delay_action([SelfId]() { td::actor::send_closure(SelfId, &FullNodeCustomOverlay::try_init); },
|
||||
td::Timestamp::in(30.0));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void FullNodePrivateExtMsgOverlay::init() {
|
||||
LOG(FULL_NODE_WARNING) << "Creating private ext msg overlay \"" << name_ << "\" for adnl id " << local_id_ << " : "
|
||||
void FullNodeCustomOverlay::init() {
|
||||
LOG(FULL_NODE_WARNING) << "Creating custom overlay \"" << name_ << "\" for adnl id " << local_id_ << " : "
|
||||
<< nodes_.size() << " nodes, overlay_id=" << overlay_id_;
|
||||
class Callback : public overlay::Overlays::Callback {
|
||||
public:
|
||||
|
@ -245,16 +243,16 @@ void FullNodePrivateExtMsgOverlay::init() {
|
|||
td::Promise<td::BufferSlice> promise) override {
|
||||
}
|
||||
void receive_broadcast(PublicKeyHash src, overlay::OverlayIdShort overlay_id, td::BufferSlice data) override {
|
||||
td::actor::send_closure(node_, &FullNodePrivateExtMsgOverlay::receive_broadcast, src, std::move(data));
|
||||
td::actor::send_closure(node_, &FullNodeCustomOverlay::receive_broadcast, src, std::move(data));
|
||||
}
|
||||
void check_broadcast(PublicKeyHash src, overlay::OverlayIdShort overlay_id, td::BufferSlice data,
|
||||
td::Promise<td::Unit> promise) override {
|
||||
}
|
||||
Callback(td::actor::ActorId<FullNodePrivateExtMsgOverlay> node) : node_(node) {
|
||||
Callback(td::actor::ActorId<FullNodeCustomOverlay> node) : node_(node) {
|
||||
}
|
||||
|
||||
private:
|
||||
td::actor::ActorId<FullNodePrivateExtMsgOverlay> node_;
|
||||
td::actor::ActorId<FullNodeCustomOverlay> node_;
|
||||
};
|
||||
|
||||
std::map<PublicKeyHash, td::uint32> authorized_keys;
|
||||
|
@ -265,14 +263,14 @@ void FullNodePrivateExtMsgOverlay::init() {
|
|||
td::actor::send_closure(
|
||||
overlays_, &overlay::Overlays::create_private_overlay, local_id_, overlay_id_full_.clone(), nodes_,
|
||||
std::make_unique<Callback>(actor_id(this)), rules,
|
||||
PSTRING() << R"({ "type": "private-ext-msg", "name": ")" << td::format::Escaped{name_} << R"(" })");
|
||||
PSTRING() << R"({ "type": "custom-overlay", "name": ")" << td::format::Escaped{name_} << R"(" })");
|
||||
|
||||
td::actor::send_closure(rldp_, &rldp::Rldp::add_id, local_id_);
|
||||
td::actor::send_closure(rldp2_, &rldp2::Rldp::add_id, local_id_);
|
||||
}
|
||||
|
||||
void FullNodePrivateExtMsgOverlay::tear_down() {
|
||||
LOG(FULL_NODE_WARNING) << "Destroying private ext msg overlay \"" << name_ << "\" for adnl id " << local_id_;
|
||||
void FullNodeCustomOverlay::tear_down() {
|
||||
LOG(FULL_NODE_WARNING) << "Destroying custom overlay \"" << name_ << "\" for adnl id " << local_id_;
|
||||
td::actor::send_closure(overlays_, &ton::overlay::Overlays::delete_overlay, local_id_, overlay_id_);
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ class FullNodePrivateBlockOverlay : public td::actor::Actor {
|
|||
void init();
|
||||
};
|
||||
|
||||
class FullNodePrivateExtMsgOverlay : public td::actor::Actor {
|
||||
class FullNodeCustomOverlay : public td::actor::Actor {
|
||||
public:
|
||||
void process_broadcast(PublicKeyHash src, ton_api::tonNode_externalMessageBroadcast &query);
|
||||
template <class T>
|
||||
|
@ -106,13 +106,12 @@ class FullNodePrivateExtMsgOverlay : public td::actor::Actor {
|
|||
void start_up() override;
|
||||
void tear_down() override;
|
||||
|
||||
FullNodePrivateExtMsgOverlay(adnl::AdnlNodeIdShort local_id, std::vector<adnl::AdnlNodeIdShort> nodes,
|
||||
std::map<adnl::AdnlNodeIdShort, int> senders, std::string name,
|
||||
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,
|
||||
td::actor::ActorId<ValidatorManagerInterface> validator_manager)
|
||||
FullNodeCustomOverlay(adnl::AdnlNodeIdShort local_id, std::vector<adnl::AdnlNodeIdShort> nodes,
|
||||
std::map<adnl::AdnlNodeIdShort, int> senders, std::string name, 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,
|
||||
td::actor::ActorId<ValidatorManagerInterface> validator_manager)
|
||||
: local_id_(local_id)
|
||||
, nodes_(std::move(nodes))
|
||||
, senders_(std::move(senders))
|
||||
|
|
|
@ -36,7 +36,7 @@ void FullNodeImpl::add_permanent_key(PublicKeyHash key, td::Promise<td::Unit> pr
|
|||
|
||||
local_keys_.insert(key);
|
||||
create_private_block_overlay(key);
|
||||
for (auto &p : private_ext_msg_overlays_) {
|
||||
for (auto &p : private_custom_overlays_) {
|
||||
update_ext_msg_overlay(p.first, p.second);
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ void FullNodeImpl::del_permanent_key(PublicKeyHash key, td::Promise<td::Unit> pr
|
|||
}
|
||||
local_keys_.erase(key);
|
||||
private_block_overlays_.erase(key);
|
||||
for (auto &p : private_ext_msg_overlays_) {
|
||||
for (auto &p : private_custom_overlays_) {
|
||||
update_ext_msg_overlay(p.first, p.second);
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ void FullNodeImpl::update_adnl_id(adnl::AdnlNodeIdShort adnl_id, td::Promise<td:
|
|||
}
|
||||
local_id_ = adnl_id_.pubkey_hash();
|
||||
|
||||
for (auto &p : private_ext_msg_overlays_) {
|
||||
for (auto &p : private_custom_overlays_) {
|
||||
update_ext_msg_overlay(p.first, p.second);
|
||||
}
|
||||
}
|
||||
|
@ -132,9 +132,9 @@ void FullNodeImpl::set_config(FullNodeConfig config) {
|
|||
for (auto& overlay : private_block_overlays_) {
|
||||
td::actor::send_closure(overlay.second, &FullNodePrivateBlockOverlay::set_config, config);
|
||||
}
|
||||
for (auto& overlay : private_ext_msg_overlays_) {
|
||||
for (auto& overlay : private_custom_overlays_) {
|
||||
for (auto &actor : overlay.second.actors_) {
|
||||
td::actor::send_closure(actor.second, &FullNodePrivateExtMsgOverlay::set_config, config);
|
||||
td::actor::send_closure(actor.second, &FullNodeCustomOverlay::set_config, config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -146,13 +146,13 @@ void FullNodeImpl::add_ext_msg_overlay(std::vector<adnl::AdnlNodeIdShort> nodes,
|
|||
promise.set_error(td::Status::Error("list of nodes is empty"));
|
||||
return;
|
||||
}
|
||||
if (private_ext_msg_overlays_.count(name)) {
|
||||
if (private_custom_overlays_.count(name)) {
|
||||
promise.set_error(td::Status::Error(PSTRING() << "duplicate overlay name \"" << name << "\""));
|
||||
return;
|
||||
}
|
||||
VLOG(FULL_NODE_WARNING) << "Adding private overlay for external messages \"" << name << "\", " << nodes.size()
|
||||
<< " nodes";
|
||||
auto &p = private_ext_msg_overlays_[name];
|
||||
auto &p = private_custom_overlays_[name];
|
||||
p.nodes_ = nodes;
|
||||
p.senders_ = senders;
|
||||
update_ext_msg_overlay(name, p);
|
||||
|
@ -160,12 +160,12 @@ void FullNodeImpl::add_ext_msg_overlay(std::vector<adnl::AdnlNodeIdShort> nodes,
|
|||
}
|
||||
|
||||
void FullNodeImpl::del_ext_msg_overlay(std::string name, td::Promise<td::Unit> promise) {
|
||||
auto it = private_ext_msg_overlays_.find(name);
|
||||
if (it == private_ext_msg_overlays_.end()) {
|
||||
auto it = private_custom_overlays_.find(name);
|
||||
if (it == private_custom_overlays_.end()) {
|
||||
promise.set_error(td::Status::Error(PSTRING() << "no such overlay \"" << name << "\""));
|
||||
return;
|
||||
}
|
||||
private_ext_msg_overlays_.erase(it);
|
||||
private_custom_overlays_.erase(it);
|
||||
promise.set_result(td::Unit());
|
||||
}
|
||||
|
||||
|
@ -221,11 +221,11 @@ void FullNodeImpl::send_ext_message(AccountIdPrefixFull dst, td::BufferSlice dat
|
|||
VLOG(FULL_NODE_WARNING) << "dropping OUT ext message to unknown shard";
|
||||
return;
|
||||
}
|
||||
for (auto &private_overlay : private_ext_msg_overlays_) {
|
||||
for (auto &private_overlay : private_custom_overlays_) {
|
||||
for (auto &actor : private_overlay.second.actors_) {
|
||||
auto local_id = actor.first;
|
||||
if (private_overlay.second.senders_.count(local_id)) {
|
||||
td::actor::send_closure(actor.second, &FullNodePrivateExtMsgOverlay::send_external_message, data.clone());
|
||||
td::actor::send_closure(actor.second, &FullNodeCustomOverlay::send_external_message, data.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -488,7 +488,7 @@ void FullNodeImpl::start_up() {
|
|||
}
|
||||
|
||||
void FullNodeImpl::update_private_overlays() {
|
||||
for (auto &p : private_ext_msg_overlays_) {
|
||||
for (auto &p : private_custom_overlays_) {
|
||||
update_ext_msg_overlay(p.first, p.second);
|
||||
}
|
||||
|
||||
|
@ -534,8 +534,8 @@ void FullNodeImpl::update_ext_msg_overlay(const std::string &name, ExtMsgOverlay
|
|||
overlay.actors_[local_id] = std::move(it->second);
|
||||
old_actors.erase(it);
|
||||
} else {
|
||||
overlay.actors_[local_id] = td::actor::create_actor<FullNodePrivateExtMsgOverlay>(
|
||||
"ExtMsgPrivateOverlay", local_id, overlay.nodes_, overlay.senders_, name, zero_state_file_hash_, config_,
|
||||
overlay.actors_[local_id] = td::actor::create_actor<FullNodeCustomOverlay>(
|
||||
"CustomOverlay", local_id, overlay.nodes_, overlay.senders_, name, zero_state_file_hash_, config_,
|
||||
keyring_, adnl_, rldp_, rldp2_, overlays_, validator_manager_);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,10 +126,10 @@ class FullNodeImpl : public FullNode {
|
|||
struct ExtMsgOverlayInfo {
|
||||
std::vector<adnl::AdnlNodeIdShort> nodes_;
|
||||
std::map<adnl::AdnlNodeIdShort, int> senders_;
|
||||
std::map<adnl::AdnlNodeIdShort, td::actor::ActorOwn<FullNodePrivateExtMsgOverlay>>
|
||||
std::map<adnl::AdnlNodeIdShort, td::actor::ActorOwn<FullNodeCustomOverlay>>
|
||||
actors_; // our local id -> actor
|
||||
};
|
||||
std::map<std::string, ExtMsgOverlayInfo> private_ext_msg_overlays_;
|
||||
std::map<std::string, ExtMsgOverlayInfo> private_custom_overlays_;
|
||||
|
||||
void update_private_overlays();
|
||||
void set_private_block_overlays_enable_compression(bool value);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue