Skip to content

Commit

Permalink
Merge pull request #913 from ton-blockchain/testnet
Browse files Browse the repository at this point in the history
Fix checking ext message broadcasts (#912)
  • Loading branch information
EmelyanenkoK authored Feb 19, 2024
2 parents 73621f6 + c7302bc commit 17c3477
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
13 changes: 11 additions & 2 deletions validator/full-node-shard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ void FullNodeShardImpl::check_broadcast(PublicKeyHash src, td::BufferSlice broad
}

auto q = B.move_as_ok();
if (!processed_ext_msg_broadcasts_.insert(td::sha256_bits256(q->message_->data_)).second) {
auto hash = td::sha256_bits256(q->message_->data_);
if (!processed_ext_msg_broadcasts_.insert(hash).second) {
return promise.set_error(td::Status::Error("duplicate external message broadcast"));
}
if (config_.ext_messages_broadcast_disabled_) {
Expand All @@ -120,6 +121,11 @@ void FullNodeShardImpl::check_broadcast(PublicKeyHash src, td::BufferSlice broad
}
};
}
if (my_ext_msg_broadcasts_.count(hash)) {
// Don't re-check messages that were sent by us
promise.set_result(td::Unit());
return;
}
td::actor::send_closure(validator_manager_, &ValidatorManagerInterface::check_external_message,
std::move(q->message_->data_),
promise.wrap([](td::Ref<ExtMessage>) { return td::Unit(); }));
Expand Down Expand Up @@ -706,9 +712,11 @@ void FullNodeShardImpl::send_external_message(td::BufferSlice data) {
});
return;
}
if (!processed_ext_msg_broadcasts_.insert(td::sha256_bits256(data)).second) {
td::Bits256 hash = td::sha256_bits256(data);
if (processed_ext_msg_broadcasts_.count(hash)) {
return;
}
my_ext_msg_broadcasts_.insert(hash);
auto B = create_serialize_tl_object<ton_api::tonNode_externalMessageBroadcast>(
create_tl_object<ton_api::tonNode_externalMessage>(std::move(data)));
if (B.size() <= overlay::Overlays::max_simple_broadcast_size()) {
Expand Down Expand Up @@ -860,6 +868,7 @@ void FullNodeShardImpl::alarm() {
}
if (cleanup_processed_ext_msg_at_ && cleanup_processed_ext_msg_at_.is_in_past()) {
processed_ext_msg_broadcasts_.clear();
my_ext_msg_broadcasts_.clear();
cleanup_processed_ext_msg_at_ = td::Timestamp::in(60.0);
}
alarm_timestamp().relax(sync_completed_at_);
Expand Down
1 change: 1 addition & 0 deletions validator/full-node-shard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ class FullNodeShardImpl : public FullNodeShard {

FullNodeConfig config_;

std::set<td::Bits256> my_ext_msg_broadcasts_;
std::set<td::Bits256> processed_ext_msg_broadcasts_;
td::Timestamp cleanup_processed_ext_msg_at_;
};
Expand Down

0 comments on commit 17c3477

Please sign in to comment.