Skip to content

Commit

Permalink
Drop only accepted duplicate ext messages, don't cache errors (#902)
Browse files Browse the repository at this point in the history
Co-authored-by: SpyCheese <[email protected]>
  • Loading branch information
EmelyanenkoK and SpyCheese authored Feb 12, 2024
1 parent f344aa4 commit 4d39772
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions validator/impl/liteserver-cache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ class LiteServerCacheImpl : public LiteServerCache {
}
}

void drop_send_message_from_cache(td::Bits256 key) override {
send_message_cache_.erase(key);
}

private:
struct CacheEntry : public td::ListNode {
explicit CacheEntry(td::Bits256 key, td::BufferSlice value) : key_(key), value_(std::move(value)) {
Expand Down
11 changes: 7 additions & 4 deletions validator/impl/liteserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,10 +531,13 @@ void LiteQuery::perform_sendMessage(td::BufferSlice data) {
auto copy = data.clone();
td::actor::send_closure_later(
manager_, &ValidatorManager::check_external_message, std::move(copy),
[Self = actor_id(this), data = std::move(data), manager = manager_](td::Result<td::Ref<ExtMessage>> res) mutable {
if(res.is_error()) {
td::actor::send_closure(Self, &LiteQuery::abort_query,
res.move_as_error_prefix("cannot apply external message to current state : "s));
[Self = actor_id(this), data = std::move(data), manager = manager_, cache = cache_,
cache_key = cache_key_](td::Result<td::Ref<ExtMessage>> res) mutable {
if (res.is_error()) {
// Don't cache errors
td::actor::send_closure(cache, &LiteServerCache::drop_send_message_from_cache, cache_key);
td::actor::send_closure(Self, &LiteQuery::abort_query,
res.move_as_error_prefix("cannot apply external message to current state : "s));
} else {
LOG(INFO) << "sending an external message to validator manager";
td::actor::send_closure_later(manager, &ValidatorManager::send_external_message, res.move_as_ok());
Expand Down
1 change: 1 addition & 0 deletions validator/interfaces/liteserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class LiteServerCache : public td::actor::Actor {
virtual void update(td::Bits256 key, td::BufferSlice value) = 0;

virtual void process_send_message(td::Bits256 key, td::Promise<td::Unit> promise) = 0;
virtual void drop_send_message_from_cache(td::Bits256 key) = 0;
};

} // namespace ton::validator

0 comments on commit 4d39772

Please sign in to comment.