fix(overlay): isolate relay duplicate tracking per Slots instance

This commit is contained in:
Nicholas Dudfield
2026-09-18 10:55:11 +07:00
parent 14c93a5215
commit 06a7d2c6ae
2 changed files with 36 additions and 1 deletions

View File

@@ -1410,6 +1410,40 @@ vp_squelched=1
mutable int maxDuration_;
};
void
testIndependentHashRouters()
{
testcase("Duplicate-message tracking belongs to each Slots instance");
Handler handler;
reduce_relay::Slots<ManualClock> first(env_.app().logs(), handler);
reduce_relay::Slots<ManualClock> second(env_.app().logs(), handler);
auto const validator = network_.validator(0);
constexpr Peer::id_t peer = 42;
for (std::uint64_t n = 1; n <= 2; ++n)
{
uint256 const message{0x5A710000ULL + n};
first.updateSlotAndSquelch(
message, validator, peer, protocol::MessageType::mtVALIDATION);
second.updateSlotAndSquelch(
message, validator, peer, protocol::MessageType::mtVALIDATION);
}
for (auto* slots : {&first, &second})
{
auto const peers = slots->getPeers(validator);
if (BEAST_EXPECT(peers.size() == 1 && peers.contains(peer)))
BEAST_EXPECT(std::get<1>(peers.at(peer)) == 1);
// A duplicate is still suppressed within its own instance.
slots->updateSlotAndSquelch(
uint256{0x5A710002ULL},
validator,
peer,
protocol::MessageType::mtVALIDATION);
BEAST_EXPECT(slots->getPeers(validator) == peers);
}
}
void
testRandomSquelch(bool l)
{
@@ -1575,6 +1609,7 @@ public:
testSelectedPeerDisconnects(log);
testSelectedPeerStopsRelaying(log);
testInternalHashRouter(log);
testIndependentHashRouters();
testRandomSquelch(log);
testHandshake(log);
}

View File

@@ -658,7 +658,7 @@ private:
// to discard duplicate message from the same peer. A message
// is aged after IDLED seconds. A message received IDLED seconds
// after it was relayed is ignored by PeerImp.
inline static messages peersWithMessage_{
messages peersWithMessage_{
beast::get_abstract_clock<clock_type>()};
};