xrpld
Loading...
Searching...
No Matches
xrpl::NegativeUNLVote Class Referencefinal

Manager to create NegativeUNL votes. More...

#include <NegativeUNLVote.h>

Collaboration diagram for xrpl::NegativeUNLVote:

Classes

struct  Candidates
 UNLModify Tx candidates. More...

Public Types

enum class  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 kNegativeUnlLowWaterMark = kFlagLedgerInterval * 50 / 100
 A validator is considered unreliable if its validations is less than negativeUNLLowWaterMark in the last flag ledger period.
static constexpr size_t kNegativeUnlHighWaterMark = kFlagLedgerInterval * 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 kNegativeUnlMinLocalValsToVote = kFlagLedgerInterval * 90 / 100
 The minimum number of validations of the local node for it to participate in the voting.
static constexpr size_t kNewValidatorDisableSkip = kFlagLedgerInterval * 2
 We don't want to disable new validators immediately after adding them.
static constexpr float kNegativeUnlMaxListed = 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.
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 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.

Static Private Member Functions

static NodeID choose (uint256 const &randomPadData, std::vector< NodeID > const &candidates)
 Pick one candidate from a vector of candidates.

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 26 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 60 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 32 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 37 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 310 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 110 of file NegativeUNLVote.cpp.

◆ choose()

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

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 141 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 158 of file NegativeUNLVote.cpp.

◆ findAllCandidates()

NegativeUNLVote::Candidates 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 236 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 324 of file NegativeUNLVote.cpp.

◆ test::NegativeUNLVoteInternal_test

Definition at line 188 of file NegativeUNLVote.h.

◆ test::NegativeUNLVoteScoreTable_test

Definition at line 189 of file NegativeUNLVote.h.

Member Data Documentation

◆ kNegativeUnlLowWaterMark

size_t xrpl::NegativeUNLVote::kNegativeUnlLowWaterMark = kFlagLedgerInterval * 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 35 of file NegativeUNLVote.h.

◆ kNegativeUnlHighWaterMark

size_t xrpl::NegativeUNLVote::kNegativeUnlHighWaterMark = kFlagLedgerInterval * 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 40 of file NegativeUNLVote.h.

◆ kNegativeUnlMinLocalValsToVote

size_t xrpl::NegativeUNLVote::kNegativeUnlMinLocalValsToVote = kFlagLedgerInterval * 90 / 100
staticconstexpr

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

Definition at line 45 of file NegativeUNLVote.h.

◆ kNewValidatorDisableSkip

size_t xrpl::NegativeUNLVote::kNewValidatorDisableSkip = kFlagLedgerInterval * 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 50 of file NegativeUNLVote.h.

◆ kNegativeUnlMaxListed

float xrpl::NegativeUNLVote::kNegativeUnlMaxListed = 0.25
staticconstexpr

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

Definition at line 54 of file NegativeUNLVote.h.

◆ myId_

NodeID const xrpl::NegativeUNLVote::myId_
private

Definition at line 104 of file NegativeUNLVote.h.

◆ j_

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

Definition at line 105 of file NegativeUNLVote.h.

◆ mutex_

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

Definition at line 106 of file NegativeUNLVote.h.

◆ newValidators_

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

Definition at line 107 of file NegativeUNLVote.h.