rippled
Classes | Public Types | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Friends | List of all members
ripple::NegativeUNLVote Class Referencefinal

Manager to create NegativeUNL votes. More...

Collaboration diagram for ripple::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. More...
 
 ~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. More...
 
void newValidators (LedgerIndex seq, hash_set< NodeID > const &nowTrusted)
 Notify NegativeUNLVote that new validators are added. More...
 

Static Public Attributes

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

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. More...
 
NodeID choose (uint256 const &randomPadData, std::vector< NodeID > const &candidates)
 Pick one candidate from a vector of candidates. More...
 
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. More...
 
const 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. More...
 
void purgeNewValidators (LedgerIndex seq)
 Purge validators that are not new anymore. More...
 

Private Attributes

const NodeID 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 46 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 83 of file NegativeUNLVote.h.

Constructor & Destructor Documentation

◆ NegativeUNLVote()

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

Constructor.

Parameters
myIdthe NodeID of the local node
jlog

Definition at line 27 of file NegativeUNLVote.cpp.

◆ ~NegativeUNLVote()

ripple::NegativeUNLVote::~NegativeUNLVote ( )
default

Member Function Documentation

◆ doVoting()

void ripple::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 33 of file NegativeUNLVote.cpp.

◆ newValidators()

void ripple::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 317 of file NegativeUNLVote.cpp.

◆ addTx()

void ripple::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 107 of file NegativeUNLVote.cpp.

◆ choose()

NodeID ripple::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 139 of file NegativeUNLVote.cpp.

◆ buildScoreTable()

std::optional< hash_map< NodeID, std::uint32_t > > ripple::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 158 of file NegativeUNLVote.cpp.

◆ findAllCandidates()

const NegativeUNLVote::Candidates ripple::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 242 of file NegativeUNLVote.cpp.

◆ purgeNewValidators()

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

Purge validators that are not new anymore.

Parameters
seqthe current LedgerIndex

Definition at line 334 of file NegativeUNLVote.cpp.

Friends And Related Function Documentation

◆ test::NegativeUNLVoteInternal_test

Definition at line 211 of file NegativeUNLVote.h.

◆ test::NegativeUNLVoteScoreTable_test

Definition at line 212 of file NegativeUNLVote.h.

Member Data Documentation

◆ negativeUNLLowWaterMark

constexpr size_t ripple::NegativeUNLVote::negativeUNLLowWaterMark
staticconstexpr
Initial value:
=

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 55 of file NegativeUNLVote.h.

◆ negativeUNLHighWaterMark

constexpr size_t ripple::NegativeUNLVote::negativeUNLHighWaterMark
staticconstexpr
Initial value:
=

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

Definition at line 61 of file NegativeUNLVote.h.

◆ negativeUNLMinLocalValsToVote

constexpr size_t ripple::NegativeUNLVote::negativeUNLMinLocalValsToVote
staticconstexpr
Initial value:
=

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

Definition at line 67 of file NegativeUNLVote.h.

◆ newValidatorDisableSkip

constexpr size_t ripple::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 73 of file NegativeUNLVote.h.

◆ negativeUNLMaxListed

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

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

Definition at line 77 of file NegativeUNLVote.h.

◆ myId_

const NodeID ripple::NegativeUNLVote::myId_
private

Definition at line 127 of file NegativeUNLVote.h.

◆ j_

beast::Journal ripple::NegativeUNLVote::j_
private

Definition at line 128 of file NegativeUNLVote.h.

◆ mutex_

std::mutex ripple::NegativeUNLVote::mutex_
mutableprivate

Definition at line 129 of file NegativeUNLVote.h.

◆ newValidators_

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

Definition at line 130 of file NegativeUNLVote.h.

ripple::FLAG_LEDGER_INTERVAL
constexpr std::uint32_t FLAG_LEDGER_INTERVAL
Definition: Ledger.h:426