rippled
Loading...
Searching...
No Matches
NegativeUNLVote.h
1#pragma once
2
3#include <xrpld/app/ledger/Ledger.h>
4
5#include <xrpl/beast/utility/Journal.h>
6#include <xrpl/protocol/Protocol.h>
7#include <xrpl/protocol/PublicKey.h>
8#include <xrpl/protocol/UintTypes.h>
9
10#include <optional>
11
12namespace xrpl {
13
14template <class Adaptor>
15class Validations;
16class RCLValidationsAdaptor;
17using RCLValidations = Validations<RCLValidationsAdaptor>;
18class SHAMap;
19namespace test {
20class NegativeUNLVoteInternal_test;
21class NegativeUNLVoteScoreTable_test;
22} // namespace test
23
27class NegativeUNLVote final
28{
29public:
36 static constexpr size_t negativeUNLLowWaterMark = FLAG_LEDGER_INTERVAL * 50 / 100;
41 static constexpr size_t negativeUNLHighWaterMark = FLAG_LEDGER_INTERVAL * 80 / 100;
46 static constexpr size_t negativeUNLMinLocalValsToVote = FLAG_LEDGER_INTERVAL * 90 / 100;
51 static constexpr size_t newValidatorDisableSkip = FLAG_LEDGER_INTERVAL * 2;
55 static constexpr float negativeUNLMaxListed = 0.25;
56
62 ToDisable, // UNLModify Tx is to disable a validator
63 ToReEnable // UNLModify Tx is to re-enable a validator
64 };
65
73 ~NegativeUNLVote() = default;
74
87 void
89 std::shared_ptr<Ledger const> const& prevLedger,
90 hash_set<PublicKey> const& unlKeys,
91 RCLValidations& validations,
92 std::shared_ptr<SHAMap> const& initialSet);
93
101 void
102 newValidators(LedgerIndex seq, hash_set<NodeID> const& nowTrusted);
103
104private:
109
118
127 void
128 addTx(LedgerIndex seq, PublicKey const& vp, NegativeUNLModify modify, std::shared_ptr<SHAMap> const& initialSet);
129
139 NodeID
140 choose(uint256 const& randomPadData, std::vector<NodeID> const& candidates);
141
158 std::shared_ptr<Ledger const> const& prevLedger,
159 hash_set<NodeID> const& unl,
160 RCLValidations& validations);
161
171 Candidates const
173 hash_set<NodeID> const& unl,
174 hash_set<NodeID> const& negUnl,
175 hash_map<NodeID, std::uint32_t> const& scoreTable);
176
182 void
184
187};
188
189} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:40
Manager to create NegativeUNL votes.
static constexpr size_t negativeUNLHighWaterMark
An unreliable validator must have more than negativeUNLHighWaterMark validations in the last flag led...
void newValidators(LedgerIndex seq, hash_set< NodeID > const &nowTrusted)
Notify NegativeUNLVote that new validators are added.
static constexpr size_t negativeUNLMinLocalValsToVote
The minimum number of validations of the local node for it to participate in the voting.
NodeID choose(uint256 const &randomPadData, std::vector< NodeID > const &candidates)
Pick one candidate from a vector of candidates.
static constexpr float negativeUNLMaxListed
We only want to put 25% of the UNL on the NegativeUNL.
~NegativeUNLVote()=default
void purgeNewValidators(LedgerIndex seq)
Purge validators that are not new anymore.
static constexpr size_t negativeUNLLowWaterMark
A validator is considered unreliable if its validations is less than negativeUNLLowWaterMark in the l...
NegativeUNLModify
A flag indicating whether a UNLModify Tx is to disable or to re-enable a validator.
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...
static constexpr size_t newValidatorDisableSkip
We don't want to disable new validators immediately after adding them.
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_
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.
void addTx(LedgerIndex seq, PublicKey const &vp, NegativeUNLModify modify, std::shared_ptr< SHAMap > const &initialSet)
Add a ttUNL_MODIFY Tx to the transaction set.
A public key.
Definition PublicKey.h:42
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:5
Validations< RCLValidationsAdaptor > RCLValidations
Alias for RCL-specific instantiation of generic Validations.
std::uint32_t constexpr FLAG_LEDGER_INTERVAL
Definition Ledger.h:394
std::vector< NodeID > toDisableCandidates
std::vector< NodeID > toReEnableCandidates