rippled
Loading...
Searching...
No Matches
NegativeUNLVote.h
1#ifndef XRPL_APP_MISC_NEGATIVEUNLVOTE_H_INCLUDED
2#define XRPL_APP_MISC_NEGATIVEUNLVOTE_H_INCLUDED
3
4#include <xrpld/app/ledger/Ledger.h>
5
6#include <xrpl/beast/utility/Journal.h>
7#include <xrpl/protocol/Protocol.h>
8#include <xrpl/protocol/PublicKey.h>
9#include <xrpl/protocol/UintTypes.h>
10
11#include <optional>
12
13namespace ripple {
14
15template <class Adaptor>
16class Validations;
17class RCLValidationsAdaptor;
18using RCLValidations = Validations<RCLValidationsAdaptor>;
19class SHAMap;
20namespace test {
21class NegativeUNLVoteInternal_test;
22class NegativeUNLVoteScoreTable_test;
23} // namespace test
24
28class NegativeUNLVote final
29{
30public:
37 static constexpr size_t negativeUNLLowWaterMark =
38 FLAG_LEDGER_INTERVAL * 50 / 100;
43 static constexpr size_t negativeUNLHighWaterMark =
44 FLAG_LEDGER_INTERVAL * 80 / 100;
49 static constexpr size_t negativeUNLMinLocalValsToVote =
50 FLAG_LEDGER_INTERVAL * 90 / 100;
55 static constexpr size_t newValidatorDisableSkip = FLAG_LEDGER_INTERVAL * 2;
59 static constexpr float negativeUNLMaxListed = 0.25;
60
66 ToDisable, // UNLModify Tx is to disable a validator
67 ToReEnable // UNLModify Tx is to re-enable a validator
68 };
69
77 ~NegativeUNLVote() = default;
78
91 void
93 std::shared_ptr<Ledger const> const& prevLedger,
94 hash_set<PublicKey> const& unlKeys,
95 RCLValidations& validations,
96 std::shared_ptr<SHAMap> const& initialSet);
97
105 void
106 newValidators(LedgerIndex seq, hash_set<NodeID> const& nowTrusted);
107
108private:
113
122
131 void
132 addTx(
133 LedgerIndex seq,
134 PublicKey const& vp,
135 NegativeUNLModify modify,
136 std::shared_ptr<SHAMap> const& initialSet);
137
147 NodeID
148 choose(uint256 const& randomPadData, std::vector<NodeID> const& candidates);
149
166 std::shared_ptr<Ledger const> const& prevLedger,
167 hash_set<NodeID> const& unl,
168 RCLValidations& validations);
169
179 Candidates const
181 hash_set<NodeID> const& unl,
182 hash_set<NodeID> const& negUnl,
183 hash_map<NodeID, std::uint32_t> const& scoreTable);
184
190 void
192
195};
196
197} // namespace ripple
198
199#endif
A generic endpoint for log messages.
Definition Journal.h:41
Manager to create NegativeUNL votes.
static constexpr size_t negativeUNLHighWaterMark
An unreliable validator must have more than negativeUNLHighWaterMark validations in the last flag led...
NodeID choose(uint256 const &randomPadData, std::vector< NodeID > const &candidates)
Pick one candidate from a vector of candidates.
std::optional< hash_map< NodeID, std::uint32_t > > buildScoreTable(std::shared_ptr< Ledger const > const &prevLedger, hash_set< NodeID > const &unl, RCLValidations &validations)
Build a reliability measurement score table of validators' validation messages in the last flag ledge...
NegativeUNLModify
A flag indicating whether a UNLModify Tx is to disable or to re-enable a validator.
void purgeNewValidators(LedgerIndex seq)
Purge validators that are not new anymore.
Candidates const findAllCandidates(hash_set< NodeID > const &unl, hash_set< NodeID > const &negUnl, hash_map< NodeID, std::uint32_t > const &scoreTable)
Process the score table and find all disabling and re-enabling candidates.
static constexpr size_t newValidatorDisableSkip
We don't want to disable new validators immediately after adding them.
static constexpr size_t negativeUNLLowWaterMark
A validator is considered unreliable if its validations is less than negativeUNLLowWaterMark in the l...
void doVoting(std::shared_ptr< Ledger const > const &prevLedger, hash_set< PublicKey > const &unlKeys, RCLValidations &validations, std::shared_ptr< SHAMap > const &initialSet)
Cast our local vote on the NegativeUNL candidates.
hash_map< NodeID, LedgerIndex > newValidators_
void newValidators(LedgerIndex seq, hash_set< NodeID > const &nowTrusted)
Notify NegativeUNLVote that new validators are added.
static constexpr float negativeUNLMaxListed
We only want to put 25% of the UNL on the NegativeUNL.
void addTx(LedgerIndex seq, PublicKey const &vp, NegativeUNLModify modify, std::shared_ptr< SHAMap > const &initialSet)
Add a ttUNL_MODIFY Tx to the transaction set.
static constexpr size_t negativeUNLMinLocalValsToVote
The minimum number of validations of the local node for it to participate in the voting.
A public key.
Definition PublicKey.h:43
Test the private member functions of NegativeUNLVote.
Rest the build score table function of NegativeUNLVote.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
std::uint32_t constexpr FLAG_LEDGER_INTERVAL
Definition Ledger.h:407
Validations< RCLValidationsAdaptor > RCLValidations
Alias for RCL-specific instantiation of generic Validations.
std::vector< NodeID > toReEnableCandidates
std::vector< NodeID > toDisableCandidates