rippled
Loading...
Searching...
No Matches
ReduceRelayCommon.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright 2020 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_OVERLAY_REDUCERELAYCOMMON_H_INCLUDED
21#define RIPPLE_OVERLAY_REDUCERELAYCOMMON_H_INCLUDED
22
23#include <chrono>
24
25namespace ripple {
26
27// Blog post explaining the rationale behind reduction of flooding gossip
28// protocol:
29// https://xrpl.org/blog/2021/message-routing-optimizations-pt-1-proposal-validation-relaying.html
30
31namespace reduce_relay {
32
33// Peer's squelch is limited in time to
34// rand{MIN_UNSQUELCH_EXPIRE, max_squelch},
35// where max_squelch is
36// min(max(MAX_UNSQUELCH_EXPIRE_DEFAULT, SQUELCH_PER_PEER * number_of_peers),
37// MAX_UNSQUELCH_EXPIRE_PEERS)
38static constexpr auto MIN_UNSQUELCH_EXPIRE = std::chrono::seconds{300};
40static constexpr auto SQUELCH_PER_PEER = std::chrono::seconds(10);
42// No message received threshold before identifying a peer as idled
43static constexpr auto IDLED = std::chrono::seconds{8};
44// Message count threshold to start selecting peers as the source
45// of messages from the validator. We add peers who reach
46// MIN_MESSAGE_THRESHOLD to considered pool once MAX_SELECTED_PEERS
47// reach MAX_MESSAGE_THRESHOLD.
48static constexpr uint16_t MIN_MESSAGE_THRESHOLD = 19;
49static constexpr uint16_t MAX_MESSAGE_THRESHOLD = 20;
50// Max selected peers to choose as the source of messages from validator
51static constexpr uint16_t MAX_SELECTED_PEERS = 5;
52// Wait before reduce-relay feature is enabled on boot up to let
53// the server establish peer connections
54static constexpr auto WAIT_ON_BOOTUP = std::chrono::minutes{10};
55// Maximum size of the aggregated transaction hashes per peer.
56// Once we get to high tps throughput, this cap will prevent
57// TMTransactions from exceeding the current protocol message
58// size limit of 64MB.
59static constexpr std::size_t MAX_TX_QUEUE_SIZE = 10000;
60
61} // namespace reduce_relay
62
63} // namespace ripple
64
65#endif // RIPPLED_REDUCERELAYCOMMON_H_INCLUDED
static constexpr auto SQUELCH_PER_PEER
static constexpr std::size_t MAX_TX_QUEUE_SIZE
static constexpr uint16_t MAX_SELECTED_PEERS
static constexpr auto MIN_UNSQUELCH_EXPIRE
static constexpr auto IDLED
static constexpr uint16_t MAX_MESSAGE_THRESHOLD
static constexpr auto WAIT_ON_BOOTUP
static constexpr auto MAX_UNSQUELCH_EXPIRE_DEFAULT
static constexpr uint16_t MIN_MESSAGE_THRESHOLD
static constexpr auto MAX_UNSQUELCH_EXPIRE_PEERS
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25