xrpld
Loading...
Searching...
No Matches
reduce_relay_test.cpp
1#include <test/jtx/Env.h>
2#include <test/jtx/PeerStub.h>
3#include <test/jtx/envconfig.h>
4
5#include <xrpld/app/main/Application.h>
6#include <xrpld/overlay/Message.h>
7#include <xrpld/overlay/Peer.h>
8#include <xrpld/overlay/ReduceRelayCommon.h>
9#include <xrpld/overlay/Slot.h>
10#include <xrpld/overlay/Squelch.h>
11#include <xrpld/overlay/detail/Handshake.h>
12
13#include <xrpl/basics/base_uint.h>
14#include <xrpl/basics/random.h>
15#include <xrpl/beast/net/IPAddress.h>
16#include <xrpl/beast/unit_test/suite.h>
17#include <xrpl/beast/utility/Journal.h>
18#include <xrpl/protocol/KeyType.h>
19#include <xrpl/protocol/PublicKey.h>
20#include <xrpl/protocol/SecretKey.h>
21
22#include <boost/asio/ip/address.hpp>
23
24#include <xrpl.pb.h>
25
26#include <algorithm>
27#include <cassert>
28#include <chrono>
29#include <cstdint>
30#include <functional>
31#include <iostream>
32#include <iterator>
33#include <memory>
34#include <numeric>
35#include <optional>
36#include <random>
37#include <ratio>
38#include <set>
39#include <sstream>
40#include <stdexcept>
41#include <string>
42#include <tuple>
43#include <unordered_map>
44#include <utility>
45#include <vector>
46
47namespace xrpl::test {
48
49using namespace std::chrono;
50
51class Link;
52
58using UnsquelchCB = std::function<void(PublicKey const&, PeerWPtr const&)>;
60
61static constexpr std::uint32_t kMaxPeers = 10;
62static constexpr std::uint32_t kMaxValidators = 10;
63static constexpr std::uint32_t kMaxMessages = 200000;
64
71class PeerPartial : public PeerStub
72{
73public:
75 // Keep the base overload visible; the one below would otherwise hide it.
76 using PeerStub::send;
77
78 virtual void
80 virtual void
81 onMessage(protocol::TMSquelch const& squelch) = 0;
82 void
83 send(protocol::TMSquelch const& squelch)
84 {
86 }
87};
88
93{
94public:
95 using rep = uint64_t;
99 inline static bool const is_steady = false; // NOLINT(readability-identifier-naming)
100
101 static void
102 advance(duration d) noexcept
103 {
104 kNow += d;
105 }
106
107 static void
112
113 static void
114 reset() noexcept
115 {
116 kNow = time_point(seconds(0));
117 }
118
119 static time_point
120 now() noexcept
121 {
122 return kNow;
123 }
124
125 static duration
127 {
128 return duration(milliseconds(randInt(min.count(), max.count())));
129 }
130
131 explicit ManualClock() = default;
132
133private:
134 inline static time_point kNow = time_point(seconds(0));
135};
136
141{
142public:
143 Overlay() = default;
144 virtual ~Overlay() = default;
145
146 virtual void
148 UInt256 const& key,
149 PublicKey const& validator,
150 Peer::ID id,
151 SquelchCB f,
152 protocol::MessageType type = protocol::mtVALIDATION) = 0;
153
154 virtual void deleteIdlePeers(UnsquelchCB) = 0;
155
156 virtual void deletePeer(Peer::ID, UnsquelchCB) = 0;
157};
158
159class Validator;
160
165class Link
166{
168
169public:
171 : validator_(validator), peer_(peer), latency_(std::move(latency))
172 {
173 auto const sp = peer_.lock();
174 assert(sp);
175 }
176 ~Link() = default;
177 void
179 {
180 if (!up_)
181 return;
182 auto const sp = peer_.lock();
183 assert(sp);
184 auto const peer = std::dynamic_pointer_cast<PeerPartial>(sp);
185 peer->onMessage(m, f);
186 }
187 Validator&
189 {
190 return validator_;
191 }
192 void
193 up(bool linkUp)
194 {
195 up_ = linkUp;
196 }
199 {
200 auto const p = peer_.lock();
201 assert(p);
202 return p->id();
203 }
206 {
207 auto p = peer_.lock();
208 assert(p);
209 return p;
210 }
211
212private:
216 bool up_{true};
217};
218
223{
225
226public:
228 {
229 protocol::TMValidation v;
230 v.set_validation("validation");
231 message_ = std::make_shared<Message>(v, protocol::mtVALIDATION, pkey_);
232 }
233 Validator(Validator const&) = default;
234 Validator(Validator&&) = default;
235 Validator&
236 operator=(Validator const&) = default;
237 Validator&
238 operator=(Validator&&) = default;
240 {
241 clear();
242 }
243
244 void
246 {
247 links_.clear();
248 }
249
250 static void
252 {
253 sid = 0;
254 }
255
256 PublicKey const&
258 {
259 return pkey_;
260 }
261
262 operator PublicKey() const
263 {
264 return pkey_;
265 }
266
267 void
269 {
270 links_.emplace(std::make_pair(peer->id(), std::make_shared<Link>(*this, peer)));
271 }
272
273 void
275 {
276 links_.erase(id);
277 }
278
279 void
281 {
282 for (auto const id : peers)
283 {
284 assert(links_.contains(id));
285 f(*links_[id], message_);
286 }
287 }
288
289 void
290 forLinks(LinkIterCB f, bool simulateSlow = false)
291 {
293 std::ranges::transform(links_, std::back_inserter(v), [](auto& kv) { return kv.second; });
295 std::mt19937 g(d());
296 std::shuffle(v.begin(), v.end(), g);
297
298 for (auto const& link : v)
299 {
300 f(*link, message_);
301 }
302 }
303
307 void
309 {
310 forLinks(peers, [&](Link& link, MessageSPtr m) { link.send(m, f); });
311 }
312
316 void
318 {
319 forLinks([&](Link& link, MessageSPtr m) { link.send(m, f); });
320 }
321
324 {
325 return message_;
326 }
327
328 [[nodiscard]] std::uint16_t
329 id() const
330 {
331 return id_;
332 }
333
334 void
336 {
337 auto const it = links_.find(id);
338 assert(it != links_.end());
339 it->second->up(true);
340 }
341
342 void
344 {
345 auto const it = links_.find(id);
346 assert(it != links_.end());
347 it->second->up(false);
348 }
349
350private:
354 inline static std::uint16_t sid = 0;
356};
357
358class PeerSim : public PeerPartial, public std::enable_shared_from_this<PeerSim>
359{
360public:
361 using ID = Peer::ID;
362 PeerSim(Overlay& overlay, beast::Journal journal)
363 : PeerPartial(sid++), overlay_(overlay), squelch_(journal)
364 {
365 }
366
367 ~PeerSim() override = default;
368
369 static void
371 {
372 sid = 0;
373 }
374
378 void
379 onMessage(MessageSPtr const& m, SquelchCB f) override
380 {
381 auto validator = m->getValidatorKey();
382 assert(validator);
383 if (!squelch_.expireSquelch(*validator)) // NOLINT(bugprone-unchecked-optional-access)
384 return;
385
386 overlay_.updateSlotAndSquelch(
387 {}, *validator, id(), f); // NOLINT(bugprone-unchecked-optional-access)
388 }
389
393 void
394 onMessage(protocol::TMSquelch const& squelch) override
395 {
396 auto validator = squelch.validatorpubkey();
397 PublicKey const key(Slice(validator.data(), validator.size()));
398 if (squelch.squelch())
399 {
400 squelch_.addSquelch(key, std::chrono::seconds{squelch.squelchduration()});
401 }
402 else
403 {
404 squelch_.removeSquelch(key);
405 }
406 }
407
408private:
409 inline static ID sid = 0;
412};
413
415{
417
418public:
419 using ID = Peer::ID;
421 OverlaySim(Application& app) : slots_(app, *this, app.config()), registry_(app)
422 {
423 }
424
425 ~OverlaySim() override = default;
426
427 void
429 {
430 peers_.clear();
432 slots_.deleteIdlePeers();
433 }
434
437 {
438 auto res = slots_.inState(validator, state);
439 return res ? *res : 0;
440 }
441
442 void
444 UInt256 const& key,
445 PublicKey const& validator,
446 Peer::ID id,
447 SquelchCB f,
448 protocol::MessageType type = protocol::mtVALIDATION) override
449 {
450 squelch_ = f;
451 slots_.updateSlotAndSquelch(key, validator, id, type);
452 }
453
454 void
455 deletePeer(ID id, UnsquelchCB f) override
456 {
457 unsquelch_ = f;
458 slots_.deletePeer(id, true);
459 }
460
461 void
463 {
464 unsquelch_ = f;
465 slots_.deleteIdlePeers();
466 }
467
469 addPeer(bool useCache = true)
470 {
471 PeerSPtr peer{};
472 Peer::ID id = 0;
473 if (peersCache_.empty() || !useCache)
474 {
475 peer = std::make_shared<PeerSim>(*this, registry_.getJournal("Squelch"));
476 id = peer->id();
477 }
478 else
479 {
480 auto const it = peersCache_.begin();
481 peer = it->second;
482 id = it->first;
483 peersCache_.erase(it);
484 }
485 peers_.emplace(std::make_pair(id, peer));
486 return peer;
487 }
488
489 void
490 deletePeer(Peer::ID id, bool useCache = true)
491 {
492 auto const it = peers_.find(id);
493 assert(it != peers_.end());
494 deletePeer(id, [&](PublicKey const&, PeerWPtr) {});
495 if (useCache)
496 peersCache_.emplace(std::make_pair(id, it->second));
497 peers_.erase(it);
498 }
499
500 void
502 {
503 while (!peers_.empty())
504 deletePeer(peers_.begin()->first);
505 while (!peersCache_.empty())
506 addPeer();
507 }
508
511 {
512 if (peers_.empty())
513 return {};
514
515 std::uint8_t maxId = 0;
516
517 for (auto& [id, _] : peers_)
518 {
519 (void)_;
520 maxId = std::max<unsigned int>(id, maxId);
521 }
522
523 deletePeer(maxId, false);
524
525 return maxId;
526 }
527
528 bool
533
536 {
537 return slots_.getSelected(validator);
538 }
539
540 bool
542 {
543 auto const selected = slots_.getSelected(validator);
544 return selected.contains(peer);
545 }
546
547 ID
549 {
550 auto const selected = slots_.getSelected(validator);
551 assert(!selected.empty());
552 return *selected.begin();
553 }
554
556 ID,
559 {
560 return slots_.getPeers(validator);
561 }
562
565 {
566 return peers_.size();
567 }
568
569private:
570 void
571 squelch(PublicKey const& validator, Peer::ID id, std::uint32_t squelchDuration) const override
572 {
573 if (auto const it = peers_.find(id); it != peers_.end())
574 squelch_(validator, it->second, squelchDuration);
575 }
576 void
577 unsquelch(PublicKey const& validator, Peer::ID id) const override
578 {
579 if (auto const it = peers_.find(id); it != peers_.end())
580 unsquelch_(validator, it->second);
581 }
588};
589
591{
592public:
594 {
595 init();
596 }
597
598 void
600 {
602 for (int p = 0; p < kMaxPeers; p++)
603 {
604 auto const peer = overlay_.addPeer();
605 for (auto& v : validators_)
606 v.addPeer(peer);
607 }
608 }
609
610 ~Network() = default;
611
612 void
614 {
615 validators_.clear();
616 overlay_.clear();
619 init();
620 }
621
624 {
625 auto const peer = overlay_.addPeer();
626 for (auto& v : validators_)
627 v.addPeer(peer);
628 return peer->id();
629 }
630
631 void
633 {
634 auto id = overlay_.deleteLastPeer();
635
636 if (!id)
637 return;
638
639 for (auto& validator : validators_)
640 validator.deletePeer(*id);
641 }
642
643 void
645 {
646 while (overlay_.getNumPeers() > kMaxPeers)
648 }
649
650 Validator&
652 {
653 assert(v < validators_.size());
654 return validators_[v];
655 }
656
659 {
660 return overlay_;
661 }
662
663 void
664 enableLink(std::uint16_t validatorId, Peer::ID peer, bool enable)
665 {
666 auto const it =
667 std::ranges::find_if(validators_, [&](auto& v) { return v.id() == validatorId; });
668 assert(it != validators_.end());
669 if (enable)
670 {
671 it->linkUp(peer);
672 }
673 else
674 {
675 it->linkDown(peer);
676 }
677 }
678
679 void
681 {
682 // Send unsquelch to the Peer on all links. This way when
683 // the Peer "reconnects" it starts sending messages on the link.
684 // We expect that if a Peer disconnects and then reconnects, it's
685 // unsquelched.
686 protocol::TMSquelch squelch;
687 squelch.set_squelch(false);
688 for (auto& v : validators_)
689 {
690 PublicKey const key = v;
691 squelch.clear_validatorpubkey();
692 squelch.set_validatorpubkey(key.data(), key.size());
693 v.forLinks({peer}, [&](Link& l, MessageSPtr) {
695 });
696 }
697 }
698
699 static void
701 {
702 auto size = max - min;
704 std::iota(s.begin(), s.end(), min); // NOLINT(modernize-use-ranges)
706 std::mt19937 g(d());
707 std::shuffle(s.begin(), s.end(), g);
708 for (auto const v : s)
709 f(v);
710 }
711
712 void
714 LinkIterCB link,
715 std::uint16_t nValidators = kMaxValidators,
716 std::uint32_t nMessages = kMaxMessages,
717 bool purge = true,
718 bool resetClock = true)
719 {
720 if (resetClock)
722
723 if (purge)
724 {
725 purgePeers();
726 overlay_.resetPeers();
727 }
728
729 for (int m = 0; m < nMessages; ++m)
730 {
732 forRand(0, nValidators, [&](std::uint32_t v) { validators_[v].forLinks(link); });
733 }
734 }
735
739 bool
741 {
742 return std::ranges::any_of(
743 validators_, [&](auto& v) { return overlay_.isSelected(v, id); });
744 }
745
751 bool
753 {
754 for (auto const& v : validators_)
755 {
756 if (!overlay_.isSelected(v, peer))
757 continue;
758 auto peers = overlay_.getPeers(v);
759 for (auto& [_, v] : peers)
760 {
761 (void)_;
762 if (std::get<reduce_relay::PeerState>(v) == reduce_relay::PeerState::Squelched)
763 return false;
764 }
765 }
766 return true;
767 }
768
769private:
772};
773
775{
777 using ID = Peer::ID;
778
779protected:
780 void
782 {
783 auto peers = network_.overlay().getPeers(network_.validator(validator));
784 std::cout << msg << " "
785 << "num peers " << (int)network_.overlay().getNumPeers() << std::endl;
786 for (auto& [k, v] : peers)
787 std::cout << k << ":" << (int)std::get<reduce_relay::PeerState>(v) << " ";
789 }
790
794 static Peer::ID
796 PublicKey const& validator,
797 PeerWPtr const& peerPtr,
799 {
800 protocol::TMSquelch squelch;
801 bool const res = static_cast<bool>(duration);
802 squelch.set_squelch(res);
803 squelch.set_validatorpubkey(validator.data(), validator.size());
804 if (res)
805 squelch.set_squelchduration(*duration);
806 auto const sp = peerPtr.lock();
807 assert(sp);
809 return sp->id();
810 }
811
812 enum class State { On, Off, WaitReset };
813 enum class EventType { LinkDown = 0, PeerDisconnected = 1 };
814 // Link down or Peer disconnect event
815 // TBD - add new peer event
816 // TBD - add overlapping type of events at any
817 // time in any quantity
830
835 void
837 {
841 };
843
844 network_.reset();
845 network_.propagate([&](Link& link, MessageSPtr m) {
846 auto& validator = link.validator();
847 auto now = ManualClock::now();
848
849 bool squelched = false;
851
852 link.send(
853 m, [&](PublicKey const& key, PeerWPtr const& peerPtr, std::uint32_t duration) {
854 assert(key == validator);
855 auto const p = sendSquelch(key, peerPtr, duration);
856 squelched = true;
857 str << p << " ";
858 });
859
860 if (squelched)
861 {
862 auto const selected = network_.overlay().getSelected(validator);
863 str << " selected: ";
864 for (auto const s : selected)
865 str << s << " ";
866 if (log)
867 {
868 std::cout << (double)reduce_relay::epoch<milliseconds>(now).count() / 1000.
869 << " random, squelched, validator: " << validator.id()
870 << " peers: " << str.str() << std::endl;
871 }
872 auto const countingState = network_.overlay().isCountingState(validator);
873 BEAST_EXPECT(
874 countingState == false &&
875 selected.size() == env_.app().config().vpReduceRelaySquelchMaxSelectedPeers);
876 }
877
878 // Trigger Link Down or Peer Disconnect event
879 // Only one Link Down at a time
880 if (events[EventType::LinkDown].state == State::Off)
881 {
882 auto const update = [&](EventType event) {
883 events[event].cnt++;
884 events[event].validator = validator.id();
885 events[event].key = validator;
886 events[event].peer = link.peerId();
887 events[event].state = State::On;
888 events[event].time = now;
889 if (event == EventType::LinkDown)
890 {
891 network_.enableLink(validator.id(), link.peerId(), false);
892 events[event].isSelected =
893 network_.overlay().isSelected(validator, link.peerId());
894 }
895 else
896 {
897 events[event].isSelected = network_.isSelected(link.peerId());
898 }
899 };
900 auto const r = randInt(0, 1000);
901 if (r == (int)EventType::LinkDown || r == (int)EventType::PeerDisconnected)
902 {
903 update(static_cast<EventType>(r));
904 }
905 }
906
907 if (events[EventType::PeerDisconnected].state == State::On)
908 {
909 auto& event = events[EventType::PeerDisconnected];
910 bool const allCounting = network_.allCounting(event.peer);
911 network_.overlay().deletePeer(
912 event.peer, [&](PublicKey const& v, PeerWPtr const& peerPtr) {
913 if (event.isSelected)
914 sendSquelch(v, peerPtr, {});
915 event.handled = true;
916 });
917 // Should only be unsquelched if the peer is in Selected state
918 // If in Selected state it's possible unsquelching didn't
919 // take place because there is no peers in Squelched state in
920 // any of the slots where the peer is in Selected state
921 // (allCounting is true)
922 bool const handled = (!event.isSelected && !event.handled) ||
923 (event.isSelected && (event.handled || allCounting));
924 BEAST_EXPECT(handled);
925 event.state = State::Off;
926 event.isSelected = false;
927 event.handledCnt += handled;
928 event.handled = false;
929 network_.onDisconnectPeer(event.peer);
930 }
931
932 auto& event = events[EventType::LinkDown];
933 // Check every sec for idled peers. Idled peers are
934 // created by Link Down event.
935 if (now - lastCheck > milliseconds(1000))
936 {
937 lastCheck = now;
938 // Check if Link Down event must be handled by
939 // deleteIdlePeer(): 1) the peer is in Selected state;
940 // 2) the peer has not received any messages for IDLED time;
941 // 3) there are peers in Squelched state in the slot.
942 // 4) peer is in Slot's peers_ (if not then it is deleted
943 // by Slots::deleteIdlePeers())
944 bool mustHandle = false;
945 if (event.state == State::On && BEAST_EXPECT(event.key))
946 {
947 event.isSelected = network_.overlay().isSelected(*event.key, event.peer);
948 auto peers = network_.overlay().getPeers(*event.key);
949 auto const d = reduce_relay::epoch<milliseconds>(now).count() -
950 std::get<3>(peers[event.peer]);
951 mustHandle = event.isSelected &&
953 network_.overlay().inState(*event.key, reduce_relay::PeerState::Squelched) >
954 0 &&
955 peers.contains(event.peer);
956 }
957 network_.overlay().deleteIdlePeers([&](PublicKey const& v, PeerWPtr const& ptr) {
958 event.handled = true;
959 if (mustHandle && v == event.key)
960 {
961 event.state = State::WaitReset;
962 sendSquelch(validator, ptr, {});
963 }
964 });
965 bool const handled = (event.handled && event.state == State::WaitReset) ||
966 (!event.handled && !mustHandle);
967 BEAST_EXPECT(handled);
968 }
969 if (event.state == State::WaitReset ||
970 (event.state == State::On &&
971 (now - event.time > (reduce_relay::kIdled + seconds(2)))))
972 {
973 bool const handled = event.state == State::WaitReset || !event.handled;
974 BEAST_EXPECT(handled);
975 event.state = State::Off;
976 event.isSelected = false;
977 event.handledCnt += handled;
978 event.handled = false;
979 network_.enableLink(event.validator, event.peer, true);
980 }
981 });
982
983 auto const& down = events[EventType::LinkDown];
984 auto const& disconnected = events[EventType::PeerDisconnected];
985 // It's possible the last Down Link event is not handled
986 BEAST_EXPECT(down.handledCnt >= down.cnt - 1);
987 // All Peer Disconnect events must be handled
988 BEAST_EXPECT(disconnected.cnt == disconnected.handledCnt);
989 if (log)
990 {
991 std::cout << "link down count: " << down.cnt << "/" << down.handledCnt
992 << " peer disconnect count: " << disconnected.cnt << "/"
993 << disconnected.handledCnt;
994 }
995 }
996
997 bool
998 checkCounting(PublicKey const& validator, bool isCountingState)
999 {
1000 auto const countingState = network_.overlay().isCountingState(validator);
1001 BEAST_EXPECT(countingState == isCountingState);
1002 return countingState == isCountingState;
1003 }
1004
1005 void
1006 doTest(std::string const& msg, bool log, std::function<void(bool)> f)
1007 {
1008 testcase(msg);
1009 f(log);
1010 }
1011
1018 void
1020 {
1021 doTest("Initial Round", log, [this](bool log) { BEAST_EXPECT(propagateAndSquelch(log)); });
1022 }
1023
1028 void
1030 {
1031 doTest("Peer Unsquelched Too Soon", log, [this](bool log) {
1032 BEAST_EXPECT(propagateNoSquelch(log, 1, false, false, false));
1033 });
1034 }
1035
1040 void
1042 {
1044 doTest("Peer Unsquelched", log, [this](bool log) {
1045 BEAST_EXPECT(propagateNoSquelch(log, 2, true, true, false));
1046 });
1047 }
1048
1052 bool
1053 propagateAndSquelch(bool log, bool purge = true, bool resetClock = true)
1054 {
1055 int n = 0;
1056 network_.propagate(
1057 [&](Link& link, MessageSPtr message) {
1058 std::uint16_t squelched = 0;
1059 link.send(
1060 message,
1061 [&](PublicKey const& key, PeerWPtr const& peerPtr, std::uint32_t duration) {
1062 squelched++;
1063 sendSquelch(key, peerPtr, duration);
1064 });
1065 if (squelched)
1066 {
1067 BEAST_EXPECT(
1068 squelched ==
1069 kMaxPeers - env_.app().config().vpReduceRelaySquelchMaxSelectedPeers);
1070 n++;
1071 }
1072 },
1073 1,
1075 purge,
1076 resetClock);
1077 auto const selected = network_.overlay().getSelected(network_.validator(0));
1078 BEAST_EXPECT(selected.size() == env_.app().config().vpReduceRelaySquelchMaxSelectedPeers);
1079 BEAST_EXPECT(n == 1); // only one selection round
1080 auto const res = checkCounting(network_.validator(0), false);
1081 BEAST_EXPECT(res);
1082 return n == 1 && res;
1083 }
1084
1088 bool
1090 bool log,
1091 std::uint16_t nMessages,
1092 bool countingState,
1093 bool purge = true,
1094 bool resetClock = true)
1095 {
1096 bool squelched = false;
1097 network_.propagate(
1098 [&](Link& link, MessageSPtr message) {
1099 link.send(
1100 message,
1101 [&](PublicKey const& key, PeerWPtr const& peerPtr, std::uint32_t duration) {
1102 squelched = true;
1103 BEAST_EXPECT(false);
1104 });
1105 },
1106 1,
1107 nMessages,
1108 purge,
1109 resetClock);
1110 auto const res = checkCounting(network_.validator(0), countingState);
1111 return !squelched && res;
1112 }
1113
1118 void
1120 {
1121 doTest("New Peer", log, [this](bool log) {
1122 BEAST_EXPECT(propagateAndSquelch(log, true, false));
1123 network_.addPeer();
1124 BEAST_EXPECT(propagateNoSquelch(log, 1, true, false, false));
1125 });
1126 }
1127
1132 void
1134 {
1135 doTest("Selected Peer Disconnects", log, [this](bool log) {
1137 BEAST_EXPECT(propagateAndSquelch(log, true, false));
1138 auto const id = network_.overlay().getSelectedPeer(network_.validator(0));
1139 std::uint16_t unsquelched = 0;
1140 network_.overlay().deletePeer(
1141 id, [&](PublicKey const& key, PeerWPtr const& peer) { unsquelched++; });
1142 BEAST_EXPECT(
1143 unsquelched ==
1144 kMaxPeers - env_.app().config().vpReduceRelaySquelchMaxSelectedPeers);
1145 BEAST_EXPECT(checkCounting(network_.validator(0), true));
1146 });
1147 }
1148
1153 void
1155 {
1156 doTest("Selected Peer Stops Relaying", log, [this](bool log) {
1158 BEAST_EXPECT(propagateAndSquelch(log, true, false));
1160 std::uint16_t unsquelched = 0;
1161 network_.overlay().deleteIdlePeers(
1162 [&](PublicKey const& key, PeerWPtr const& peer) { unsquelched++; });
1163 auto const peers = network_.overlay().getPeers(network_.validator(0));
1164 BEAST_EXPECT(
1165 unsquelched ==
1166 kMaxPeers - env_.app().config().vpReduceRelaySquelchMaxSelectedPeers);
1167 BEAST_EXPECT(checkCounting(network_.validator(0), true));
1168 });
1169 }
1170
1174 void
1176 {
1177 doTest("Squelched Peer Disconnects", log, [this](bool log) {
1179 BEAST_EXPECT(propagateAndSquelch(log, true, false));
1180 auto peers = network_.overlay().getPeers(network_.validator(0));
1181 auto const it = std::ranges::find_if(peers, [&](auto it) {
1182 return std::get<reduce_relay::PeerState>(it.second) ==
1184 });
1185 assert(it != peers.end());
1186 std::uint16_t unsquelched = 0;
1187 network_.overlay().deletePeer(
1188 it->first, [&](PublicKey const& key, PeerWPtr const& peer) { unsquelched++; });
1189 BEAST_EXPECT(unsquelched == 0);
1190 BEAST_EXPECT(checkCounting(network_.validator(0), false));
1191 });
1192 }
1193
1194 void
1196 {
1197 doTest("Test Config - squelch enabled (legacy)", log, [&](bool log) {
1198 Config c;
1199
1200 std::string const toLoad(R"xrpldConfig(
1201[reduce_relay]
1202vp_enable=1
1203)xrpldConfig");
1204
1205 c.loadFromString(toLoad);
1206 BEAST_EXPECT(c.vpReduceRelayBaseSquelchEnable == true);
1207 });
1208
1209 doTest("Test Config - squelch disabled (legacy)", log, [&](bool log) {
1210 Config c;
1211
1212 std::string toLoad(R"xrpldConfig(
1213[reduce_relay]
1214vp_enable=0
1215)xrpldConfig");
1216
1217 c.loadFromString(toLoad);
1218 BEAST_EXPECT(c.vpReduceRelayBaseSquelchEnable == false);
1219
1220 Config c1;
1221
1222 toLoad = R"xrpldConfig(
1223[reduce_relay]
1224)xrpldConfig";
1225
1226 c1.loadFromString(toLoad);
1227 BEAST_EXPECT(c1.vpReduceRelayBaseSquelchEnable == false);
1228 });
1229
1230 doTest("Test Config - squelch enabled", log, [&](bool log) {
1231 Config c;
1232
1233 std::string const toLoad(R"xrpldConfig(
1234[reduce_relay]
1235vp_base_squelch_enable=1
1236)xrpldConfig");
1237
1238 c.loadFromString(toLoad);
1239 BEAST_EXPECT(c.vpReduceRelayBaseSquelchEnable == true);
1240 });
1241
1242 doTest("Test Config - squelch disabled", log, [&](bool log) {
1243 Config c;
1244
1245 std::string const toLoad(R"xrpldConfig(
1246[reduce_relay]
1247vp_base_squelch_enable=0
1248)xrpldConfig");
1249
1250 c.loadFromString(toLoad);
1251 BEAST_EXPECT(c.vpReduceRelayBaseSquelchEnable == false);
1252 });
1253
1254 doTest("Test Config - legacy and new", log, [&](bool log) {
1255 Config c;
1256
1257 std::string const toLoad(R"xrpldConfig(
1258[reduce_relay]
1259vp_base_squelch_enable=0
1260vp_enable=0
1261)xrpldConfig");
1262
1263 std::string error;
1264 auto const expectedError =
1265 "Invalid reduce_relay"
1266 " cannot specify both vp_base_squelch_enable and vp_enable "
1267 "options. "
1268 "vp_enable was deprecated and replaced by "
1269 "vp_base_squelch_enable";
1270
1271 try
1272 {
1273 c.loadFromString(toLoad);
1274 }
1275 catch (std::runtime_error const& e)
1276 {
1277 error = e.what();
1278 }
1279
1280 BEAST_EXPECT(error == expectedError);
1281 });
1282
1283 doTest("Test Config - max selected peers", log, [&](bool log) {
1284 Config c;
1285
1286 std::string toLoad(R"xrpldConfig(
1287[reduce_relay]
1288)xrpldConfig");
1289
1290 c.loadFromString(toLoad);
1291 BEAST_EXPECT(c.vpReduceRelaySquelchMaxSelectedPeers == 5);
1292
1293 Config c1;
1294
1295 toLoad = R"xrpldConfig(
1296[reduce_relay]
1297vp_base_squelch_max_selected_peers=6
1298)xrpldConfig";
1299
1300 c1.loadFromString(toLoad);
1301 BEAST_EXPECT(c1.vpReduceRelaySquelchMaxSelectedPeers == 6);
1302
1304
1305 toLoad = R"xrpldConfig(
1306[reduce_relay]
1307vp_base_squelch_max_selected_peers=2
1308)xrpldConfig";
1309
1310 std::string error;
1311 auto const expectedError =
1312 "Invalid reduce_relay"
1313 " vp_base_squelch_max_selected_peers must be "
1314 "greater than or equal to 3";
1315 try
1316 {
1317 c2.loadFromString(toLoad);
1318 }
1319 catch (std::runtime_error const& e)
1320 {
1321 error = e.what();
1322 }
1323
1324 BEAST_EXPECT(error == expectedError);
1325 });
1326 }
1327
1328 void
1329 testBaseSquelchReady(bool log)
1330 {
1331 doTest("BaseSquelchReady", log, [&](bool log) {
1333 auto const createSlots =
1334 [&](bool baseSquelchEnabled) -> reduce_relay::Slots<ManualClock> {
1335 env_.app().config().vpReduceRelayBaseSquelchEnable = baseSquelchEnabled;
1337 env_.app(), network_.overlay(), env_.app().config());
1338 };
1339 // base squelching must not be ready if squelching is disabled
1340 BEAST_EXPECT(!createSlots(false).baseSquelchReady());
1341
1342 // base squelch must not be ready as not enough time passed from
1343 // bootup
1344 BEAST_EXPECT(!createSlots(true).baseSquelchReady());
1345
1347
1348 // base squelch enabled and bootup time passed
1349 BEAST_EXPECT(createSlots(true).baseSquelchReady());
1350
1351 // even if time passed, base squelching must not be ready if turned
1352 // off in the config
1353 BEAST_EXPECT(!createSlots(false).baseSquelchReady());
1354 });
1355 }
1356
1357 void
1358 testInternalHashRouter(bool log)
1359 {
1360 doTest("Duplicate Message", log, [&](bool log) {
1361 network_.reset();
1362 // update message count for the same peer/validator
1363 std::int16_t const nMessages = 5;
1364 for (int i = 0; i < nMessages; i++)
1365 {
1366 UInt256 const key(i);
1367 network_.overlay().updateSlotAndSquelch(
1368 key, network_.validator(0), 0, [&](PublicKey const&, PeerWPtr, std::uint32_t) {
1369 });
1371 auto peers = network_.overlay().getPeers(network_.validator(0));
1372 // first message changes Slot state to Counting and is not counted,
1373 // hence '-1'.
1374 BEAST_EXPECT(std::get<1>(peers[0]) == (nMessages - 1));
1375 // add duplicate
1376 UInt256 const key(nMessages - 1);
1377 network_.overlay().updateSlotAndSquelch(
1378 key, network_.validator(0), 0, [&](PublicKey const&, PeerWPtr, std::uint32_t) {});
1379 // confirm the same number of messages
1380 peers = network_.overlay().getPeers(network_.validator(0));
1381 BEAST_EXPECT(std::get<1>(peers[0]) == (nMessages - 1));
1382 // advance the clock
1384 network_.overlay().updateSlotAndSquelch(
1385 key, network_.validator(0), 0, [&](PublicKey const&, PeerWPtr, std::uint32_t) {});
1386 peers = network_.overlay().getPeers(network_.validator(0));
1387 // confirm message number increased
1388 BEAST_EXPECT(std::get<1>(peers[0]) == nMessages);
1389 });
1390 }
1391
1392 struct Handler : public reduce_relay::SquelchHandler
1393 {
1394 Handler() = default;
1395 void
1396 squelch(PublicKey const&, Peer::ID, std::uint32_t duration) const override
1397 {
1398 maxDuration = std::max<uint32_t>(duration, maxDuration);
1399 }
1400 void
1401 unsquelch(PublicKey const&, Peer::ID) const override
1402 {
1403 }
1404 mutable int maxDuration{0};
1405 };
1406
1407 void
1408 testRandomSquelch(bool l)
1409 {
1410 doTest("Random Squelch", l, [&](bool l) {
1411 PublicKey validator = std::get<0>(randomKeyPair(KeyType::Ed25519));
1412 Handler handler;
1413
1414 auto const run = [&](int npeers) {
1415 handler.maxDuration = 0;
1416 reduce_relay::Slots<ManualClock> slots(env_.app(), handler, env_.app().config());
1417 // 1st message from a new peer switches the slot
1418 // to counting state and resets the counts of all peers +
1419 // MAX_MESSAGE_THRESHOLD + 1 messages to reach the threshold
1420 // and switch the slot's state to peer selection.
1421 for (int m = 1; m <= reduce_relay::kMaxMessageThreshold + 2; m++)
1422 {
1423 for (int peer = 0; peer < npeers; peer++)
1424 {
1425 // make unique message hash to make the
1426 // slot's internal hash router accept the message
1427 std::uint64_t const mid = (m * 1000) + peer;
1428 UInt256 const message{mid};
1429 slots.updateSlotAndSquelch(
1430 message, validator, peer, protocol::MessageType::mtVALIDATION);
1431 }
1432 }
1433 // make Slot's internal hash router expire all messages
1435 };
1436
1437 using namespace reduce_relay;
1438 // expect max duration less than kMaxUnsquelchExpireDefault with
1439 // less than or equal to 60 peers
1440 run(20);
1441 BEAST_EXPECT(
1442 handler.maxDuration >= kMinUnsquelchExpire.count() &&
1443 handler.maxDuration <= kMaxUnsquelchExpireDefault.count());
1444 run(60);
1445 BEAST_EXPECT(
1446 handler.maxDuration >= kMinUnsquelchExpire.count() &&
1447 handler.maxDuration <= kMaxUnsquelchExpireDefault.count());
1448 // expect max duration greater than kMinUnsquelchExpire and less
1449 // than kMaxUnsquelchExpirePeers with peers greater than 60
1450 // and less than 360
1451 run(350);
1452 // can't make this condition stronger. squelch
1453 // duration is probabilistic and max condition may still fail.
1454 // log when the value is low
1455 BEAST_EXPECT(
1456 handler.maxDuration >= kMinUnsquelchExpire.count() &&
1457 handler.maxDuration <= kMaxUnsquelchExpirePeers.count());
1458 using namespace beast::unit_test::detail;
1459 if (handler.maxDuration <= kMaxUnsquelchExpireDefault.count())
1460 {
1461 log << makeReason("warning: squelch duration is low", __FILE__, __LINE__)
1462 << std::endl
1463 << std::flush;
1464 }
1465 // more than 400 is still less than kMaxUnsquelchExpirePeers
1466 run(400);
1467 BEAST_EXPECT(
1468 handler.maxDuration >= kMinUnsquelchExpire.count() &&
1469 handler.maxDuration <= kMaxUnsquelchExpirePeers.count());
1470 if (handler.maxDuration <= kMaxUnsquelchExpireDefault.count())
1471 {
1472 log << makeReason("warning: squelch duration is low", __FILE__, __LINE__)
1473 << std::endl
1474 << std::flush;
1475 }
1476 });
1477 }
1478
1479 void
1480 testHandshake(bool log)
1481 {
1482 doTest("Handshake", log, [&](bool log) {
1483 auto setEnv = [&](bool enable) {
1484 Config c;
1485 std::stringstream str;
1486 str << "[reduce_relay]\n"
1487 << "vp_enable=" << enable << "\n"
1488 << "[compression]\n"
1489 << "1\n";
1490 c.loadFromString(str.str());
1491 env_.app().config().vpReduceRelayBaseSquelchEnable =
1492 c.vpReduceRelayBaseSquelchEnable;
1493
1494 env_.app().config().compression = c.compression;
1495 };
1496 auto const handshake = [&](int outboundEnable, int inboundEnable) {
1497 beast::ip::Address const addr = boost::asio::ip::make_address("172.1.1.100");
1498
1499 setEnv(outboundEnable);
1500 auto request = xrpl::makeRequest(
1501 true,
1502 env_.app().config().compression,
1503 false,
1504 env_.app().config().txReduceRelayEnable,
1505 env_.app().config().vpReduceRelayBaseSquelchEnable);
1506 HttpRequestType httpRequest;
1507 httpRequest.version(request.version());
1508 httpRequest.base() = request.base();
1509 // feature enabled on the peer's connection only if both sides
1510 // are enabled
1511 auto const peerEnabled = inboundEnable && outboundEnable;
1512 // inbound is enabled if the request's header has the feature
1513 // enabled and the peer's configuration is enabled
1514 auto const inboundEnabled =
1515 peerFeatureEnabled(httpRequest, kFeatureVprr, inboundEnable);
1516 BEAST_EXPECT(!(peerEnabled ^ inboundEnabled));
1517
1518 setEnv(inboundEnable);
1519 auto const httpResp = xrpl::makeResponse(
1520 true, httpRequest, addr, addr, UInt256{1}, 1, {1, 0}, env_.app());
1521 // outbound is enabled if the response's header has the feature
1522 // enabled and the peer's configuration is enabled
1523 auto const outboundEnabled =
1524 peerFeatureEnabled(httpResp, kFeatureVprr, outboundEnable);
1525 BEAST_EXPECT(!(peerEnabled ^ outboundEnabled));
1526 };
1527 handshake(1, 1);
1528 handshake(1, 0);
1529 handshake(0, 1);
1530 handshake(0, 0);
1531 });
1532 }
1533
1534 jtx::Env env_;
1535 Network network_;
1536
1537public:
1538 reduce_relay_test()
1539 : env_(*this, jtx::envconfig([](std::unique_ptr<Config> cfg) {
1540 cfg->vpReduceRelayBaseSquelchEnable = true;
1541 cfg->vpReduceRelaySquelchMaxSelectedPeers = 6;
1542 return cfg;
1543 }))
1544 , network_(env_.app())
1545 {
1546 }
1547
1548 void
1549 run() override
1550 {
1551 bool const log = false;
1552 testConfig(log);
1553 testInitialRound(log);
1554 testPeerUnsquelchedTooSoon(log);
1555 testPeerUnsquelched(log);
1556 testNewPeer(log);
1557 testSquelchedPeerDisconnects(log);
1558 testSelectedPeerDisconnects(log);
1559 testSelectedPeerStopsRelaying(log);
1560 testInternalHashRouter(log);
1561 testRandomSquelch(log);
1562 testHandshake(log);
1563 testBaseSquelchReady(log);
1564 }
1565};
1566
1568{
1569 void
1571 {
1572 doTest("Random Test", log, [&](bool log) { random(log); });
1573 }
1574
1575 void
1576 run() override
1577 {
1578 bool const log = false;
1579 testRandom(log);
1580 }
1581};
1582
1584BEAST_DEFINE_TESTSUITE_MANUAL(reduce_relay_simulate, overlay, xrpl);
1585
1586} // namespace xrpl::test
T any_of(T... args)
T back_inserter(T... args)
T begin(T... args)
A generic endpoint for log messages.
Definition Journal.h:44
A testsuite class.
Definition suite.h:52
LogOs< char > log
Logging output stream.
Definition suite.h:150
TestcaseT testcase
Memberspace for declaring test cases.
Definition suite.h:155
std::size_t vpReduceRelaySquelchMaxSelectedPeers
////////////////// !
void loadFromString(std::string const &fileContents)
Load the config from the contents of the string.
std::uint32_t ID
Uniquely identifies a peer.
A public key.
Definition PublicKey.h:53
std::uint8_t const * data() const noexcept
Definition PublicKey.h:79
static std::size_t size() noexcept
Definition PublicKey.h:85
Service registry for dependency injection.
An immutable linear range of bytes.
Definition Slice.h:28
Slot is associated with a specific validator via validator's public key.
Slots is a container for validator's Slot and handles Slot update when a message is received from a v...
Maintains squelching of relaying messages from validators.
Definition Squelch.h:19
Manually advanced clock.
static void randAdvance(milliseconds min, milliseconds max)
static duration randDuration(milliseconds min, milliseconds max)
static void advance(duration d) noexcept
std::chrono::time_point< ManualClock > time_point
static void reset() noexcept
static time_point now() noexcept
std::chrono::duration< std::uint32_t, period > duration
void onDisconnectPeer(Peer::ID peer)
static void forRand(std::uint32_t min, std::uint32_t max, std::function< void(std::uint32_t)> f)
bool isSelected(Peer::ID id)
Is peer in Selected state in any of the slots.
void propagate(LinkIterCB link, std::uint16_t nValidators=kMaxValidators, std::uint32_t nMessages=kMaxMessages, bool purge=true, bool resetClock=true)
std::vector< Validator > validators_
Network(Application &app)
bool allCounting(Peer::ID peer)
Check if there are peers to unsquelch - peer is in Selected state in any of the slots and there are p...
void enableLink(std::uint16_t validatorId, Peer::ID peer, bool enable)
Validator & validator(std::uint16_t v)
std::set< ID > getSelected(PublicKey const &validator)
std::uint16_t getNumPeers() const
void updateSlotAndSquelch(UInt256 const &key, PublicKey const &validator, Peer::ID id, SquelchCB f, protocol::MessageType type=protocol::mtVALIDATION) override
PeerSPtr addPeer(bool useCache=true)
bool isSelected(PublicKey const &validator, Peer::ID peer)
ID getSelectedPeer(PublicKey const &validator)
std::unordered_map< ID, std::tuple< reduce_relay::PeerState, std::uint16_t, std::uint32_t, std::uint32_t > > getPeers(PublicKey const &validator)
std::optional< Peer::ID > deleteLastPeer()
std::unordered_map< Peer::ID, PeerSPtr > Peers
void deleteIdlePeers(UnsquelchCB f) override
std::uint16_t inState(PublicKey const &validator, reduce_relay::PeerState state)
bool isCountingState(PublicKey const &validator)
~OverlaySim() override=default
void deletePeer(ID id, UnsquelchCB f) override
reduce_relay::Slots< ManualClock > slots_
void deletePeer(Peer::ID id, bool useCache=true)
void unsquelch(PublicKey const &validator, Peer::ID id) const override
Unsquelch handler.
void squelch(PublicKey const &validator, Peer::ID id, std::uint32_t squelchDuration) const override
Squelch handler.
Simulate server's OverlayImpl.
virtual void deleteIdlePeers(UnsquelchCB)=0
virtual void updateSlotAndSquelch(UInt256 const &key, PublicKey const &validator, Peer::ID id, SquelchCB f, protocol::MessageType type=protocol::mtVALIDATION)=0
virtual ~Overlay()=default
virtual void deletePeer(Peer::ID, UnsquelchCB)=0
Simulate two entities - peer directly connected to the server (via squelch in PeerSim) and PeerImp (v...
virtual void onMessage(protocol::TMSquelch const &squelch)=0
virtual void onMessage(MessageSPtr const &m, SquelchCB f)=0
void send(protocol::TMSquelch const &squelch)
~PeerSim() override=default
void onMessage(protocol::TMSquelch const &squelch) override
Remote Peer (Directly connected Peer).
reduce_relay::Squelch< ManualClock > squelch_
void onMessage(MessageSPtr const &m, SquelchCB f) override
Local Peer (PeerImp).
PeerSim(Overlay &overlay, beast::Journal journal)
ID id() const override
Definition PeerStub.h:75
void send(std::shared_ptr< Message > const &) override
Definition PeerStub.h:44
void addPeer(PeerSPtr peer)
Validator & operator=(Validator &&)=default
void send(SquelchCB f)
Send to all peers.
void forLinks(LinkIterCB f, bool simulateSlow=false)
Validator(Validator const &)=default
Validator & operator=(Validator const &)=default
void send(std::vector< Peer::ID > peers, SquelchCB f)
Send to specific peers.
void deletePeer(Peer::ID id)
std::uint16_t id() const
std::unordered_map< Peer::ID, LinkSPtr > Links
Validator(Validator &&)=default
static std::uint16_t sid
PublicKey const & key()
void forLinks(std::vector< Peer::ID > peers, LinkIterCB f)
void printPeers(std::string const &msg, std::uint16_t validator=0)
void doTest(std::string const &msg, bool log, std::function< void(bool)> f)
bool propagateNoSquelch(bool log, std::uint16_t nMessages, bool countingState, bool purge=true, bool resetClock=true)
Send fewer message so that squelch event is not generated.
bool propagateAndSquelch(bool log, bool purge=true, bool resetClock=true)
Propagate enough messages to generate one squelch event.
static Peer::ID sendSquelch(PublicKey const &validator, PeerWPtr const &peerPtr, std::optional< std::uint32_t > duration)
Send squelch (if duration is set) or unsquelch (if duration not set).
void random(bool log)
Randomly brings the link between a validator and a peer down.
void testSquelchedPeerDisconnects(bool log)
Squelched peer disconnects.
void testPeerUnsquelchedTooSoon(bool log)
Receiving message from squelched peer too soon should not change the slot's state to Counting.
reduce_relay::Slot< ManualClock > Slot
void testInitialRound(bool log)
Initial counting round: three peers receive message "faster" then others.
void testSelectedPeerStopsRelaying(bool log)
Selected peer stops relaying.
void testSelectedPeerDisconnects(bool log)
Selected peer disconnects.
bool checkCounting(PublicKey const &validator, bool isCountingState)
void testPeerUnsquelched(bool log)
Receiving message from squelched peer should change the slot's state to Counting.
void testNewPeer(bool log)
Receiving a message from new peer should change the slot's state to Counting.
T end(T... args)
T endl(T... args)
T find_if(T... args)
T flush(T... args)
T iota(T... args)
T lock(T... args)
T log(T... args)
T make_pair(T... args)
T make_shared(T... args)
T max(T... args)
T min(T... args)
boost::asio::ip::address Address
Definition IPAddress.h:20
std::string makeReason(String const &reason, char const *file, int line)
Definition suite.h:24
STL namespace.
static constexpr uint16_t kMaxMessageThreshold
static constexpr auto kWaitOnBootup
static constexpr auto kIdled
std::unique_ptr< Config > envconfig()
creates and initializes a default configuration for jtx::Env
Definition envconfig.h:38
std::unique_ptr< Config > validator(std::unique_ptr< Config >, std::string const &)
adjust configuration with params needed to be a validator
static constexpr std::uint32_t kMaxMessages
std::function< void(Link &, MessageSPtr)> LinkIterCB
BEAST_DEFINE_TESTSUITE(AMMClawback, app, xrpl)
std::shared_ptr< Peer > PeerSPtr
static constexpr std::uint32_t kMaxPeers
BEAST_DEFINE_TESTSUITE_MANUAL(AMMCalc, app, xrpl)
std::shared_ptr< Message > MessageSPtr
static constexpr std::uint32_t kMaxValidators
std::shared_ptr< Link > LinkSPtr
std::weak_ptr< Peer > PeerWPtr
std::function< void(PublicKey const &, PeerWPtr const &)> UnsquelchCB
std::function< void(PublicKey const &, PeerWPtr const &, std::uint32_t)> SquelchCB
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
KeyType
Definition KeyType.h:8
std::pair< PublicKey, SecretKey > randomKeyPair(KeyType type)
Create a key pair using secure random numbers.
T get(Section const &section, std::string const &name, T const &defaultValue=T{})
Retrieve a key/value pair from a section.
HttpResponseType makeResponse(bool crawlPublic, HttpRequestType const &req, beast::ip::Address publicIp, beast::ip::Address remoteIp, UInt256 const &sharedValue, std::optional< std::uint32_t > networkID, ProtocolVersion protocol, Application &app)
Make http response.
auto makeRequest(bool crawlPublic, bool comprEnabled, bool ledgerReplayEnabled, bool txReduceRelayEnabled, bool vpReduceRelayEnabled) -> RequestType
Make outbound http request.
BaseUInt< 256 > UInt256
Definition base_uint.h:581
boost::beast::http::request< boost::beast::http::dynamic_body > HttpRequestType
Definition Handoff.h:12
int run(int argc, char *const *argv)
Definition Main.cpp:354
bool peerFeatureEnabled(Headers const &request, std::string const &feature, std::string value, bool config)
Check if a feature should be enabled for a peer.
Definition Handshake.h:182
constexpr Number squelch(Number const &x, Number const &limit) noexcept
Definition Number.h:911
static constexpr char kFeatureVprr[]
Definition Handshake.h:127
T dynamic_pointer_cast(T... args)
T shuffle(T... args)
T size(T... args)
T str(T... args)
T transform(T... args)
T what(T... args)