mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Reduce duplicate peer traffic for ledger data (#5126)
- Drop duplicate outgoing TMGetLedger messages per peer
- Allow a retry after 30s in case of peer or network congestion.
- Addresses RIPD-1870
- (Changes levelization. That is not desirable, and will need to be fixed.)
- Drop duplicate incoming TMGetLedger messages per peer
- Allow a retry after 15s in case of peer or network congestion.
- The requestCookie is ignored when computing the hash, thus increasing
the chances of detecting duplicate messages.
- With duplicate messages, keep track of the different requestCookies
(or lack of cookie). When work is finally done for a given request,
send the response to all the peers that are waiting on the request,
sending one message per peer, including all the cookies and
a "directResponse" flag indicating the data is intended for the
sender, too.
- Addresses RIPD-1871
- Drop duplicate incoming TMLedgerData messages
- Addresses RIPD-1869
- Improve logging related to ledger acquisition
- Class "CanProcess" to keep track of processing of distinct items
---------
Co-authored-by: Valentin Balaschenko <13349202+vlntb@users.noreply.github.com>
This commit is contained in:
@@ -242,6 +242,33 @@ class HashRouter_test : public beast::unit_test::suite
|
||||
BEAST_EXPECT(router.shouldProcess(key, peer, flags, 1s));
|
||||
}
|
||||
|
||||
void
|
||||
testProcessPeer()
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
TestStopwatch stopwatch;
|
||||
HashRouter router(stopwatch, 5s);
|
||||
uint256 const key(1);
|
||||
HashRouter::PeerShortID peer1 = 1;
|
||||
HashRouter::PeerShortID peer2 = 2;
|
||||
auto const timeout = 2s;
|
||||
|
||||
BEAST_EXPECT(router.shouldProcessForPeer(key, peer1, timeout));
|
||||
BEAST_EXPECT(!router.shouldProcessForPeer(key, peer1, timeout));
|
||||
++stopwatch;
|
||||
BEAST_EXPECT(!router.shouldProcessForPeer(key, peer1, timeout));
|
||||
BEAST_EXPECT(router.shouldProcessForPeer(key, peer2, timeout));
|
||||
BEAST_EXPECT(!router.shouldProcessForPeer(key, peer2, timeout));
|
||||
++stopwatch;
|
||||
BEAST_EXPECT(router.shouldProcessForPeer(key, peer1, timeout));
|
||||
BEAST_EXPECT(!router.shouldProcessForPeer(key, peer2, timeout));
|
||||
++stopwatch;
|
||||
BEAST_EXPECT(router.shouldProcessForPeer(key, peer2, timeout));
|
||||
++stopwatch;
|
||||
BEAST_EXPECT(router.shouldProcessForPeer(key, peer1, timeout));
|
||||
BEAST_EXPECT(!router.shouldProcessForPeer(key, peer2, timeout));
|
||||
}
|
||||
|
||||
public:
|
||||
void
|
||||
run() override
|
||||
@@ -252,6 +279,7 @@ public:
|
||||
testSetFlags();
|
||||
testRelay();
|
||||
testProcess();
|
||||
testProcessPeer();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -322,6 +322,11 @@ public:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
std::set<std::optional<uint64_t>>
|
||||
releaseRequestCookies(uint256 const& requestHash) override
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
bool ledgerReplayEnabled_;
|
||||
PublicKey nodePublicKey_;
|
||||
|
||||
@@ -151,6 +151,7 @@ struct base_uint_test : beast::unit_test::suite
|
||||
uset.insert(u);
|
||||
BEAST_EXPECT(raw.size() == u.size());
|
||||
BEAST_EXPECT(to_string(u) == "0102030405060708090A0B0C");
|
||||
BEAST_EXPECT(to_short_string(u) == "01020304...");
|
||||
BEAST_EXPECT(*u.data() == 1);
|
||||
BEAST_EXPECT(u.signum() == 1);
|
||||
BEAST_EXPECT(!!u);
|
||||
@@ -173,6 +174,7 @@ struct base_uint_test : beast::unit_test::suite
|
||||
test96 v{~u};
|
||||
uset.insert(v);
|
||||
BEAST_EXPECT(to_string(v) == "FEFDFCFBFAF9F8F7F6F5F4F3");
|
||||
BEAST_EXPECT(to_short_string(v) == "FEFDFCFB...");
|
||||
BEAST_EXPECT(*v.data() == 0xfe);
|
||||
BEAST_EXPECT(v.signum() == 1);
|
||||
BEAST_EXPECT(!!v);
|
||||
@@ -193,6 +195,7 @@ struct base_uint_test : beast::unit_test::suite
|
||||
test96 z{beast::zero};
|
||||
uset.insert(z);
|
||||
BEAST_EXPECT(to_string(z) == "000000000000000000000000");
|
||||
BEAST_EXPECT(to_short_string(z) == "00000000...");
|
||||
BEAST_EXPECT(*z.data() == 0);
|
||||
BEAST_EXPECT(*z.begin() == 0);
|
||||
BEAST_EXPECT(*std::prev(z.end(), 1) == 0);
|
||||
@@ -213,6 +216,7 @@ struct base_uint_test : beast::unit_test::suite
|
||||
BEAST_EXPECT(n == z);
|
||||
n--;
|
||||
BEAST_EXPECT(to_string(n) == "FFFFFFFFFFFFFFFFFFFFFFFF");
|
||||
BEAST_EXPECT(to_short_string(n) == "FFFFFFFF...");
|
||||
n = beast::zero;
|
||||
BEAST_EXPECT(n == z);
|
||||
|
||||
@@ -223,6 +227,7 @@ struct base_uint_test : beast::unit_test::suite
|
||||
test96 x{zm1 ^ zp1};
|
||||
uset.insert(x);
|
||||
BEAST_EXPECTS(to_string(x) == "FFFFFFFFFFFFFFFFFFFFFFFE", to_string(x));
|
||||
BEAST_EXPECTS(to_short_string(x) == "FFFFFFFF...", to_short_string(x));
|
||||
|
||||
BEAST_EXPECT(uset.size() == 4);
|
||||
|
||||
|
||||
@@ -87,8 +87,8 @@ public:
|
||||
negotiateProtocolVersion("XRPL/2.2") == make_protocol(2, 2));
|
||||
BEAST_EXPECT(
|
||||
negotiateProtocolVersion(
|
||||
"RTXP/1.2, XRPL/2.2, XRPL/2.3, XRPL/999.999") ==
|
||||
make_protocol(2, 2));
|
||||
"RTXP/1.2, XRPL/2.2, XRPL/2.3, XRPL/2.4, XRPL/999.999") ==
|
||||
make_protocol(2, 3));
|
||||
BEAST_EXPECT(
|
||||
negotiateProtocolVersion("XRPL/999.999, WebSocket/1.0") ==
|
||||
std::nullopt);
|
||||
|
||||
@@ -182,6 +182,11 @@ public:
|
||||
removeTxQueue(const uint256&) override
|
||||
{
|
||||
}
|
||||
std::set<std::optional<uint64_t>>
|
||||
releaseRequestCookies(uint256 const& requestHash) override
|
||||
{
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
/** Manually advanced clock. */
|
||||
|
||||
Reference in New Issue
Block a user