rippled
Loading...
Searching...
No Matches
NegativeUNLVote.h
1#pragma once
2
3#include <xrpl/beast/utility/Journal.h>
4#include <xrpl/ledger/Ledger.h>
5#include <xrpl/protocol/Protocol.h>
6#include <xrpl/protocol/PublicKey.h>
7#include <xrpl/protocol/UintTypes.h>
8
9#include <optional>
10
11namespace xrpl {
12
13template <class Adaptor>
14class Validations;
15class RCLValidationsAdaptor;
16using RCLValidations = Validations<RCLValidationsAdaptor>;
17class SHAMap;
18namespace test {
19class NegativeUNLVoteInternal_test;
20class NegativeUNLVoteScoreTable_test;
21} // namespace test
22
26class NegativeUNLVote final
27{
28public:
35 static constexpr size_t negativeUNLLowWaterMark = FLAG_LEDGER_INTERVAL * 50 / 100;
40 static constexpr size_t negativeUNLHighWaterMark = FLAG_LEDGER_INTERVAL * 80 / 100;
45 static constexpr size_t negativeUNLMinLocalValsToVote = FLAG_LEDGER_INTERVAL * 90 / 100;
50 static constexpr size_t newValidatorDisableSkip = FLAG_LEDGER_INTERVAL * 2;
54 static constexpr float negativeUNLMaxListed = 0.25;
55
61 ToDisable, // UNLModify Tx is to disable a validator
62 ToReEnable // UNLModify Tx is to re-enable a validator
63 };
64
72 ~NegativeUNLVote() = default;
73
86 void
88 std::shared_ptr<Ledger const> const& prevLedger,
89 hash_set<PublicKey> const& unlKeys,
90 RCLValidations& validations,
91 std::shared_ptr<SHAMap> const& initialSet);
92
100 void
101 newValidators(LedgerIndex seq, hash_set<NodeID> const& nowTrusted);
102
103private:
108
117
126 void
127 addTx(
128 LedgerIndex seq,
129 PublicKey const& vp,
130 NegativeUNLModify modify,
131 std::shared_ptr<SHAMap> const& initialSet);
132
142 static NodeID
143 choose(uint256 const& randomPadData, std::vector<NodeID> const& candidates);
144
161 std::shared_ptr<Ledger const> const& prevLedger,
162 hash_set<NodeID> const& unl,
163 RCLValidations& validations);
164
176 hash_set<NodeID> const& unl,
177 hash_set<NodeID> const& negUnl,
178 hash_map<NodeID, std::uint32_t> const& scoreTable);
179
185 void
187
190};
191
192} // 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.
Candidates 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 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_
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 Protocol.h:257
std::vector< NodeID > toDisableCandidates
std::vector< NodeID > toReEnableCandidates