rippled
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Friends | List of all members
xrpl::NegativeUNLVote Class Referencefinal

Manager to create NegativeUNL votes. More...

#include <NegativeUNLVote.h>

Collaboration diagram for xrpl::NegativeUNLVote:
Collaboration graph
[legend]

Classes

struct  Candidates
 UNLModify Tx candidates. More...
 

Public Types

enum  NegativeUNLModify { ToDisable , ToReEnable }
 A flag indicating whether a UNLModify Tx is to disable or to re-enable a validator. More...
 

Public Member Functions

 NegativeUNLVote (NodeID const &myId, beast::Journal j)
 Constructor.
 
 ~NegativeUNLVote ()=default
 
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.
 
void newValidators (LedgerIndex seq, hash_set< NodeID > const &nowTrusted)
 Notify NegativeUNLVote that new validators are added.
 

Static Public Attributes

static constexpr size_t negativeUNLLowWaterMark = FLAG_LEDGER_INTERVAL * 50 / 100
 A validator is considered unreliable if its validations is less than negativeUNLLowWaterMark in the last flag ledger period.
 
static constexpr size_t negativeUNLHighWaterMark = FLAG_LEDGER_INTERVAL * 80 / 100
 An unreliable validator must have more than negativeUNLHighWaterMark validations in the last flag ledger period to be re-enabled.
 
static constexpr size_t negativeUNLMinLocalValsToVote = FLAG_LEDGER_INTERVAL * 90 / 100
 The minimum number of validations of the local node for it to participate in the voting.
 
static constexpr size_t newValidatorDisableSkip = FLAG_LEDGER_INTERVAL * 2
 We don't want to disable new validators immediately after adding them.
 
static constexpr float negativeUNLMaxListed = 0.25
 We only want to put 25% of the UNL on the NegativeUNL.
 

Private Member Functions

void addTx (LedgerIndex seq, PublicKey const &vp, NegativeUNLModify modify, std::shared_ptr< SHAMap > const &initialSet)
 Add a ttUNL_MODIFY Tx to the transaction set.
 
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 ledger period.
 
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 purgeNewValidators (LedgerIndex seq)
 Purge validators that are not new anymore.
 

Private Attributes

NodeID const myId_
 
beast::Journal j_
 
std::mutex mutex_
 
hash_map< NodeID, LedgerIndexnewValidators_
 

Friends

class test::NegativeUNLVoteInternal_test
 
class test::NegativeUNLVoteScoreTable_test
 

Detailed Description

Manager to create NegativeUNL votes.

Definition at line 27 of file NegativeUNLVote.h.

Member Enumeration Documentation

◆ NegativeUNLModify

A flag indicating whether a UNLModify Tx is to disable or to re-enable a validator.

Enumerator
ToDisable 
ToReEnable 

Definition at line 61 of file NegativeUNLVote.h.

Constructor & Destructor Documentation

◆ NegativeUNLVote()

xrpl::NegativeUNLVote::NegativeUNLVote ( NodeID const &  myId,
beast::Journal  j 
)

Constructor.

Parameters
myIdthe NodeID of the local node
jlog

Definition at line 9 of file NegativeUNLVote.cpp.

◆ ~NegativeUNLVote()

xrpl::NegativeUNLVote::~NegativeUNLVote ( )
default

Member Function Documentation

◆ doVoting()

void xrpl::NegativeUNLVote::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.

Parameters
prevLedgerthe parent ledger
unlKeysthe trusted master keys of validators in the UNL
validationsthe validation message container
Note
validations is an in/out parameter. It contains validation messages that will be deleted when no longer needed by other consensus logic. This function asks it to keep the validation messages long enough for this function to use.
Parameters
initialSetthe transactions set for adding ttUNL_MODIFY Tx if any

Definition at line 14 of file NegativeUNLVote.cpp.

◆ newValidators()

void xrpl::NegativeUNLVote::newValidators ( LedgerIndex  seq,
hash_set< NodeID > const &  nowTrusted 
)

Notify NegativeUNLVote that new validators are added.

So that they don't get voted to the NegativeUNL immediately.

Parameters
seqthe current LedgerIndex when adding the new validators
nowTrustedthe new validators

Definition at line 278 of file NegativeUNLVote.cpp.

◆ addTx()

void xrpl::NegativeUNLVote::addTx ( LedgerIndex  seq,
PublicKey const &  vp,
NegativeUNLModify  modify,
std::shared_ptr< SHAMap > const &  initialSet 
)
private

Add a ttUNL_MODIFY Tx to the transaction set.

Parameters
seqthe LedgerIndex when adding the Tx
vpthe master public key of the validator
modifydisabling or re-enabling the validator
initialSetthe transaction set

Definition at line 85 of file NegativeUNLVote.cpp.

◆ choose()

NodeID xrpl::NegativeUNLVote::choose ( uint256 const &  randomPadData,
std::vector< NodeID > const &  candidates 
)
private

Pick one candidate from a vector of candidates.

Parameters
randomPadDatathe data used for picking a candidate.
Note
Nodes must use the same randomPadData for picking the same candidate. The hash of the parent ledger is used.
Parameters
candidatesthe vector of candidates
Returns
the picked candidate

Definition at line 113 of file NegativeUNLVote.cpp.

◆ buildScoreTable()

std::optional< hash_map< NodeID, std::uint32_t > > xrpl::NegativeUNLVote::buildScoreTable ( std::shared_ptr< Ledger const > const &  prevLedger,
hash_set< NodeID > const &  unl,
RCLValidations validations 
)
private

Build a reliability measurement score table of validators' validation messages in the last flag ledger period.

Parameters
prevLedgerthe parent ledger
unlthe trusted master keys
validationsthe validation container
Note
validations is an in/out parameter. It contains validation messages that will be deleted when no longer needed by other consensus logic. This function asks it to keep the validation messages long enough for this function to use.
Returns
the built scoreTable or empty optional if table could not be built

Definition at line 130 of file NegativeUNLVote.cpp.

◆ findAllCandidates()

NegativeUNLVote::Candidates const xrpl::NegativeUNLVote::findAllCandidates ( hash_set< NodeID > const &  unl,
hash_set< NodeID > const &  negUnl,
hash_map< NodeID, std::uint32_t > const &  scoreTable 
)
private

Process the score table and find all disabling and re-enabling candidates.

Parameters
unlthe trusted master keys
negUnlthe NegativeUNL
scoreTablethe score table
Returns
the candidates to disable and the candidates to re-enable

Definition at line 207 of file NegativeUNLVote.cpp.

◆ purgeNewValidators()

void xrpl::NegativeUNLVote::purgeNewValidators ( LedgerIndex  seq)
private

Purge validators that are not new anymore.

Parameters
seqthe current LedgerIndex

Definition at line 292 of file NegativeUNLVote.cpp.

Friends And Related Symbol Documentation

◆ test::NegativeUNLVoteInternal_test

Definition at line 185 of file NegativeUNLVote.h.

◆ test::NegativeUNLVoteScoreTable_test

Definition at line 186 of file NegativeUNLVote.h.

Member Data Documentation

◆ negativeUNLLowWaterMark

constexpr size_t xrpl::NegativeUNLVote::negativeUNLLowWaterMark = FLAG_LEDGER_INTERVAL * 50 / 100
staticconstexpr

A validator is considered unreliable if its validations is less than negativeUNLLowWaterMark in the last flag ledger period.

An unreliable validator is a candidate to be disabled by the NegativeUNL protocol.

Definition at line 36 of file NegativeUNLVote.h.

◆ negativeUNLHighWaterMark

constexpr size_t xrpl::NegativeUNLVote::negativeUNLHighWaterMark = FLAG_LEDGER_INTERVAL * 80 / 100
staticconstexpr

An unreliable validator must have more than negativeUNLHighWaterMark validations in the last flag ledger period to be re-enabled.

Definition at line 41 of file NegativeUNLVote.h.

◆ negativeUNLMinLocalValsToVote

constexpr size_t xrpl::NegativeUNLVote::negativeUNLMinLocalValsToVote = FLAG_LEDGER_INTERVAL * 90 / 100
staticconstexpr

The minimum number of validations of the local node for it to participate in the voting.

Definition at line 46 of file NegativeUNLVote.h.

◆ newValidatorDisableSkip

constexpr size_t xrpl::NegativeUNLVote::newValidatorDisableSkip = FLAG_LEDGER_INTERVAL * 2
staticconstexpr

We don't want to disable new validators immediately after adding them.

So we skip voting for disabling them for 2 flag ledgers.

Definition at line 51 of file NegativeUNLVote.h.

◆ negativeUNLMaxListed

constexpr float xrpl::NegativeUNLVote::negativeUNLMaxListed = 0.25
staticconstexpr

We only want to put 25% of the UNL on the NegativeUNL.

Definition at line 55 of file NegativeUNLVote.h.

◆ myId_

NodeID const xrpl::NegativeUNLVote::myId_
private

Definition at line 105 of file NegativeUNLVote.h.

◆ j_

beast::Journal xrpl::NegativeUNLVote::j_
private

Definition at line 106 of file NegativeUNLVote.h.

◆ mutex_

std::mutex xrpl::NegativeUNLVote::mutex_
mutableprivate

Definition at line 107 of file NegativeUNLVote.h.

◆ newValidators_

hash_map<NodeID, LedgerIndex> xrpl::NegativeUNLVote::newValidators_
private

Definition at line 108 of file NegativeUNLVote.h.