Skip to content

Commit

Permalink
2.0.0-rcX-debugrelay-6: log whether duplicate messages are being
Browse files Browse the repository at this point in the history
relayed and whether peers' send queue is being modified correctly.
  • Loading branch information
mtrippled committed Feb 7, 2024
1 parent f06e259 commit 81760bc
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/ripple/app/main/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,8 @@ class ApplicationImp : public Application, public BasicApp

, hashRouter_(std::make_unique<HashRouter>(
stopwatch(),
HashRouter::getDefaultHoldTime()))
HashRouter::getDefaultHoldTime(),
logs_->journal("HashRouter")))

, mValidations(
ValidationParms(),
Expand Down
18 changes: 16 additions & 2 deletions src/ripple/app/misc/HashRouter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
//==============================================================================

#include <ripple/app/misc/HashRouter.h>
#include <ripple/basics/Log.h>
#include <sstream>

namespace ripple {

Expand Down Expand Up @@ -122,10 +124,22 @@ HashRouter::shouldRelay(uint256 const& key)

auto& s = emplace(key).first;

std::stringstream ss;
ss << "shouldRelay " << key;
std::optional<std::set<PeerShortID>> ret;
if (!s.shouldRelay(suppressionMap_.clock().now(), holdTime_))
return {};
{
ss << " not recently relayed.";
}
else
{
ss << " recently relayed.";
ret = s.releasePeerSet();
}

return s.releasePeerSet();
ss << " relaying: " << (ret.has_value() ? "true" : "false");
JLOG(j_.debug()) << ss.str();
return ret;
}

} // namespace ripple
6 changes: 5 additions & 1 deletion src/ripple/app/misc/HashRouter.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <ripple/basics/base_uint.h>
#include <ripple/basics/chrono.h>
#include <ripple/beast/container/aged_unordered_map.h>
#include <ripple/beast/utility/Journal.h>

#include <optional>

Expand Down Expand Up @@ -143,8 +144,10 @@ class HashRouter
return 300s;
}

HashRouter(Stopwatch& clock, std::chrono::seconds entryHoldTimeInSeconds)
HashRouter(Stopwatch& clock, std::chrono::seconds entryHoldTimeInSeconds,
beast::Journal j)
: suppressionMap_(clock), holdTime_(entryHoldTimeInSeconds)
, j_(j)
{
}

Expand Down Expand Up @@ -221,6 +224,7 @@ class HashRouter
suppressionMap_;

std::chrono::seconds const holdTime_;
beast::Journal j_;
};

} // namespace ripple
Expand Down
2 changes: 2 additions & 0 deletions src/ripple/overlay/impl/OverlayImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1246,8 +1246,10 @@ OverlayImpl::relay(
std::make_shared<Message>(m, protocol::mtPROPOSE_LEDGER, validator);
for_each([&](std::shared_ptr<PeerImp>&& p) {
if (toSkip->find(p->id()) == toSkip->end())
{
JLOG(journal_.debug()) << "debugrelay send() 9";
p->send(sm);
}
});
return *toSkip;
}
Expand Down
10 changes: 9 additions & 1 deletion src/ripple/overlay/impl/PeerImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,16 @@ PeerImp::send(std::shared_ptr<Message> const& m)
send_queue_.push(m);

if (sendq_size != 0)
{
JLOG(journal_.debug()) << "send not sending type: "
<< protocolMessageName(m->getType(&m->getBuffer(Compressed::Off)[0]))
<< ". Prior to push, q size was " << sendq_size << ". now it's "
<< send_queue_.size();
return;
}

JLOG(journal_.debug()) << "sending message type " << protocolMessageName(m->getType(&m->getBuffer(Compressed::Off)[0]));
JLOG(journal_.debug()) << "sending message type " << protocolMessageName(m->getType(&m->getBuffer(Compressed::Off)[0]))
<< ". just pushed q size " << send_queue_.size();
boost::asio::async_write(
stream_,
boost::asio::buffer(
Expand Down Expand Up @@ -978,6 +985,7 @@ PeerImp::onWriteMessage(error_code ec, std::size_t bytes_transferred)

assert(!send_queue_.empty());
send_queue_.pop();
JLOG(journal_.debug()) << "onWriteMessage just popped q size " << send_queue_.size();
if (!send_queue_.empty())
{
// Timeout on writes only
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/protocol/impl/BuildInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace BuildInfo {
// and follow the format described at http://semver.org/
//------------------------------------------------------------------------------
// clang-format off
char const* const versionString = "2.0.0-rcX-debugrelay-5"
char const* const versionString = "2.0.0-rcX-debugrelay-6"
// clang-format on

#if defined(DEBUG) || defined(SANITIZER)
Expand Down
13 changes: 7 additions & 6 deletions src/test/app/HashRouter_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <ripple/app/misc/HashRouter.h>
#include <ripple/basics/chrono.h>
#include <ripple/beast/unit_test.h>
#include <test/unit_test/SuiteJournal.h>

namespace ripple {
namespace test {
Expand All @@ -31,7 +32,7 @@ class HashRouter_test : public beast::unit_test::suite
{
using namespace std::chrono_literals;
TestStopwatch stopwatch;
HashRouter router(stopwatch, 2s);
HashRouter router(stopwatch, 2s, test::SuiteJournal("TestHashRouter", *this));

uint256 const key1(1);
uint256 const key2(2);
Expand Down Expand Up @@ -68,7 +69,7 @@ class HashRouter_test : public beast::unit_test::suite
{
using namespace std::chrono_literals;
TestStopwatch stopwatch;
HashRouter router(stopwatch, 2s);
HashRouter router(stopwatch, 2s, test::SuiteJournal("TestHashRouter", *this));

uint256 const key1(1);
uint256 const key2(2);
Expand Down Expand Up @@ -146,7 +147,7 @@ class HashRouter_test : public beast::unit_test::suite
// Normal HashRouter
using namespace std::chrono_literals;
TestStopwatch stopwatch;
HashRouter router(stopwatch, 2s);
HashRouter router(stopwatch, 2s, test::SuiteJournal("TestHashRouter", *this));

uint256 const key1(1);
uint256 const key2(2);
Expand Down Expand Up @@ -174,7 +175,7 @@ class HashRouter_test : public beast::unit_test::suite
{
using namespace std::chrono_literals;
TestStopwatch stopwatch;
HashRouter router(stopwatch, 2s);
HashRouter router(stopwatch, 2s, test::SuiteJournal("TestHashRouter", *this));

uint256 const key1(1);
BEAST_EXPECT(router.setFlags(key1, 10));
Expand All @@ -187,7 +188,7 @@ class HashRouter_test : public beast::unit_test::suite
{
using namespace std::chrono_literals;
TestStopwatch stopwatch;
HashRouter router(stopwatch, 1s);
HashRouter router(stopwatch, 1s, test::SuiteJournal("TestHashRouter", *this));

uint256 const key1(1);

Expand Down Expand Up @@ -230,7 +231,7 @@ class HashRouter_test : public beast::unit_test::suite
{
using namespace std::chrono_literals;
TestStopwatch stopwatch;
HashRouter router(stopwatch, 5s);
HashRouter router(stopwatch, 5s, test::SuiteJournal("TestHashRouter", *this));
uint256 const key(1);
HashRouter::PeerShortID peer = 1;
int flags;
Expand Down

0 comments on commit 81760bc

Please sign in to comment.