diff --git a/src/test/overlay/base_squelch_test.cpp b/src/test/overlay/base_squelch_test.cpp index a13efb39d5..b9a330e14c 100644 --- a/src/test/overlay/base_squelch_test.cpp +++ b/src/test/overlay/base_squelch_test.cpp @@ -1700,7 +1700,7 @@ public: void run() override { - bool log = false; + bool log = true; testConfig(log); testInitialRound(log); testPeerUnsquelchedTooSoon(log); diff --git a/src/xrpld/overlay/ReduceRelayCommon.h b/src/xrpld/overlay/ReduceRelayCommon.h index efcb0f9690..6e7b24ca87 100644 --- a/src/xrpld/overlay/ReduceRelayCommon.h +++ b/src/xrpld/overlay/ReduceRelayCommon.h @@ -40,7 +40,7 @@ static constexpr auto MAX_UNSQUELCH_EXPIRE_DEFAULT = std::chrono::seconds{600}; static constexpr auto SQUELCH_PER_PEER = std::chrono::seconds(10); static constexpr auto MAX_UNSQUELCH_EXPIRE_PEERS = std::chrono::seconds{3600}; // No message received threshold before identifying a peer as idled -static constexpr auto IDLED = std::chrono::seconds{8}; +static constexpr auto IDLED = std::chrono::seconds{5}; // Message count threshold to start selecting peers as the source // of messages from the validator. We add peers who reach // MIN_MESSAGE_THRESHOLD to considered pool once MAX_SELECTED_PEERS diff --git a/src/xrpld/overlay/Slot.h b/src/xrpld/overlay/Slot.h index 3c2bc49e6a..503c507abf 100644 --- a/src/xrpld/overlay/Slot.h +++ b/src/xrpld/overlay/Slot.h @@ -35,6 +35,8 @@ #include #include +#include +#include #include #include #include @@ -259,6 +261,7 @@ class Slot final time_point expire; // squelch expiration time time_point lastMessage; // time last message received std::size_t timesSelected; // number of times the peer was selected + std::size_t timesCloseToThreshold; }; std::unordered_map peers_; // peer's data @@ -330,7 +333,8 @@ Slot::update( .count = 0, .expire = now, .lastMessage = now, - .timesSelected = 0})); + .timesSelected = 0, + .timesCloseToThreshold = 0})); initCounting(); return; } @@ -354,6 +358,9 @@ Slot::update( << duration_cast(now - peer.lastMessage).count() << " pool " << considered_.size() << " threshold " << reachedThreshold_; + if (now - peer.lastMessage - IDLED <= milliseconds{500}) + ++peer.timesCloseToThreshold; + peer.lastMessage = now; // report if we received a message from a squelched peer @@ -379,6 +386,16 @@ Slot::update( if (reachedThreshold_ == maxSelectedPeers_) { + for (auto const& [id, info] : peers_) + { + if (info.state == PeerState::Selected && + info.count < MIN_MESSAGE_THRESHOLD) + { + JLOG(journal_.debug()) + << "update: previously selected peer " << id + << " failed to reach a threshold with: " << info.count; + } + } // Randomly select maxSelectedPeers_ peers from considered. // Exclude peers that have been idling > IDLED - // it's possible that deleteIdlePeer() has not been called yet. @@ -440,6 +457,11 @@ Slot::update( else if (v.state != PeerState::Squelched) { + if (v.state == PeerState::Selected) + { + JLOG(journal_.debug()) + << "squelching previously selected peer"; + } if (journal_.trace()) str << k << " "; v.state = PeerState::Squelched; @@ -540,6 +562,7 @@ Slot::onWrite(beast::PropertyStream::Map& stream) const item["lastMessage"] = duration_cast(now - info.lastMessage).count(); item["timesSelected"] = info.timesSelected; + item["timesCloseToThreshold"] = info.timesCloseToThreshold; item["state"] = to_string(info.state); } }