3#include <xrpl/basics/UnorderedContainers.h>
4#include <xrpl/basics/base_uint.h>
5#include <xrpl/beast/utility/Journal.h>
6#include <xrpl/ledger/Ledger.h>
7#include <xrpl/protocol/Protocol.h>
8#include <xrpl/protocol/PublicKey.h>
9#include <xrpl/protocol/UintTypes.h>
20template <
class Adaptor>
A generic endpoint for log messages.
static constexpr size_t kNegativeUnlHighWaterMark
An unreliable validator must have more than negativeUNLHighWaterMark validations in the last flag led...
static constexpr size_t kNegativeUnlMinLocalValsToVote
The minimum number of validations of the local node for it to participate in the voting.
std::optional< HashMap< NodeID, std::uint32_t > > buildScoreTable(std::shared_ptr< Ledger const > const &prevLedger, HashSet< NodeID > const &unl, RCLValidations &validations)
Build a reliability measurement score table of validators' validation messages in the last flag ledge...
~NegativeUNLVote()=default
static constexpr size_t kNewValidatorDisableSkip
We don't want to disable new validators immediately after adding them.
NegativeUNLVote(NodeID const &myId, beast::Journal j)
Constructor.
void purgeNewValidators(LedgerIndex seq)
Purge validators that are not new anymore.
NegativeUNLModify
A flag indicating whether a UNLModify Tx is to disable or to re-enable a validator.
static constexpr float kNegativeUnlMaxListed
We only want to put 25% of the UNL on the NegativeUNL.
Candidates findAllCandidates(HashSet< NodeID > const &unl, HashSet< NodeID > const &negUnl, HashMap< NodeID, std::uint32_t > const &scoreTable)
Process the score table and find all disabling and re-enabling candidates.
HashMap< NodeID, LedgerIndex > newValidators_
void doVoting(std::shared_ptr< Ledger const > const &prevLedger, HashSet< PublicKey > const &unlKeys, RCLValidations &validations, std::shared_ptr< SHAMap > const &initialSet)
Cast our local vote on the NegativeUNL candidates.
static constexpr size_t kNegativeUnlLowWaterMark
A validator is considered unreliable if its validations is less than negativeUNLLowWaterMark in the l...
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 NodeID choose(UInt256 const &randomPadData, std::vector< NodeID > const &candidates)
Pick one candidate from a vector of candidates.
void newValidators(LedgerIndex seq, HashSet< NodeID > const &nowTrusted)
Notify NegativeUNLVote that new validators are added.
Generic validations adaptor class for RCL.
Maintains current and recent ledger validations.
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.
std::uint32_t LedgerIndex
A ledger index.
Validations< RCLValidationsAdaptor > RCLValidations
Alias for RCL-specific instantiation of generic Validations.
std::unordered_set< Value, Hash, Pred, Allocator > HashSet
std::unordered_map< Key, Value, Hash, Pred, Allocator > HashMap
BaseUInt< 160, detail::NodeIDTag > NodeID
NodeID is a 160-bit hash representing one node.
constexpr std::uint32_t kFlagLedgerInterval
std::vector< NodeID > toDisableCandidates
std::vector< NodeID > toReEnableCandidates