|
xrpld
|
#include <ValidatorList.h>

Classes | |
| struct | PublisherList |
| struct | PublisherListCollection |
| struct | PublisherListStats |
| Describes the result of processing a Validator List (UNL), including some of the information from the list which can be used by the caller to know which list publisher is involved. More... | |
| struct | MessageWithHash |
Public Types | |
| using | QuorumKeys = std::pair<std::size_t const, hash_set<PublicKey>> |
Public Member Functions | |
| ValidatorList (ManifestCache &validatorManifests, ManifestCache &publisherManifests, TimeKeeper &timeKeeper, std::string const &databasePath, beast::Journal j, std::optional< std::size_t > minimumQuorum=std::nullopt) | |
| ~ValidatorList ()=default | |
| bool | load (std::optional< PublicKey > const &localSigningKey, std::vector< std::string > const &configKeys, std::vector< std::string > const &publisherKeys, std::optional< std::size_t > listThreshold={}) |
| Load configured trusted keys. | |
| PublisherListStats | applyListsAndBroadcast (std::string const &manifest, std::uint32_t version, std::vector< ValidatorBlobInfo > const &blobs, std::string siteUri, uint256 const &hash, Overlay &overlay, HashRouter &hashRouter, NetworkOPs &networkOPs) |
| Apply multiple published lists of public keys, then broadcast it to all peers that have not seen it or sent it. | |
| PublisherListStats | applyLists (std::string const &manifest, std::uint32_t version, std::vector< ValidatorBlobInfo > const &blobs, std::string siteUri, std::optional< uint256 > const &hash={}) |
| Apply multiple published lists of public keys. | |
| std::vector< std::string > | loadLists () |
| Attempt to read previously stored list files. | |
| TrustChanges | updateTrusted (hash_set< NodeID > const &seenValidators, NetClock::time_point closeTime, NetworkOPs &ops, Overlay &overlay, HashRouter &hashRouter) |
| Update trusted nodes. | |
| std::size_t | quorum () const |
| Get quorum value for current trusted key set. | |
| bool | trusted (PublicKey const &identity) const |
| Returns true if public key is trusted. | |
| bool | listed (PublicKey const &identity) const |
| Returns true if public key is included on any lists. | |
| std::optional< PublicKey > | getTrustedKey (PublicKey const &identity) const |
| Returns master public key if public key is trusted. | |
| std::optional< PublicKey > | getListedKey (PublicKey const &identity) const |
| Returns listed master public if public key is included on any lists. | |
| bool | trustedPublisher (PublicKey const &identity) const |
| Returns true if public key is a trusted publisher. | |
| std::optional< PublicKey > | localPublicKey () const |
| This function returns the local validator public key or a std::nullopt. | |
| void | forEachListed (std::function< void(PublicKey const &, bool)> func) const |
| Invokes the callback once for every listed validation public key. | |
| void | forEachAvailable (std::function< void(std::string const &manifest, std::uint32_t version, std::map< std::size_t, ValidatorBlobInfo > const &blobInfos, PublicKey const &pubKey, std::size_t maxSequence, uint256 const &hash)> func) const |
| Invokes the callback once for every available publisher list's raw data members. | |
| std::optional< json::Value > | getAvailable (std::string_view pubKey, std::optional< std::uint32_t > forceVersion={}) |
| Returns the current valid list for the given publisher key, if available, as a Json object. | |
| std::size_t | count () const |
| Return the number of configured validator list sites. | |
| std::optional< TimeKeeper::time_point > | expires () const |
| Return the time when the validator list will expire. | |
| json::Value | getJson () const |
| Return a JSON representation of the state of the validator list. | |
| QuorumKeys | getQuorumKeys () const |
| Get the quorum and all of the trusted keys. | |
| hash_set< PublicKey > | getTrustedMasterKeys () const |
| get the trusted master public keys | |
| std::size_t | getListThreshold () const |
| get the validator list threshold | |
| hash_set< PublicKey > | getNegativeUNL () const |
| get the master public keys of Negative UNL validators | |
| void | setNegativeUNL (hash_set< PublicKey > const &negUnl) |
| set the Negative UNL with validators' master public keys | |
| std::vector< std::shared_ptr< STValidation > > | negativeUNLFilter (std::vector< std::shared_ptr< STValidation > > &&validations) const |
| Remove validations that are from validators on the negative UNL. | |
Static Public Member Functions | |
| static std::vector< ValidatorBlobInfo > | parseBlobs (std::uint32_t version, json::Value const &body) |
| Pull the blob/signature/manifest information out of the appropriate Json body fields depending on the version. | |
| static std::vector< ValidatorBlobInfo > | parseBlobs (protocol::TMValidatorListCollection const &body) |
| static void | sendValidatorList (Peer &peer, std::uint64_t peerSequence, PublicKey const &publisherKey, std::size_t maxSequence, std::uint32_t rawVersion, std::string const &rawManifest, std::map< std::size_t, ValidatorBlobInfo > const &blobInfos, HashRouter &hashRouter, beast::Journal j) |
| static std::pair< std::size_t, std::size_t > | buildValidatorListMessages (std::uint64_t peerSequence, std::size_t maxSequence, std::uint32_t rawVersion, std::string const &rawManifest, std::map< std::size_t, ValidatorBlobInfo > const &blobInfos, std::vector< MessageWithHash > &messages, std::size_t maxSize=kMaximumMessageSize) |
Private Types | |
| using | scoped_lock = std::scoped_lock<decltype(mutex_)> |
| using | shared_lock = std::shared_lock<decltype(mutex_)> |
Private Member Functions | |
| std::size_t | count (shared_lock const &) const |
| Return the number of configured validator list sites. | |
| bool | trusted (shared_lock const &, PublicKey const &identity) const |
| Returns true if public key is trusted. | |
| std::optional< PublicKey > | getTrustedKey (shared_lock const &, PublicKey const &identity) const |
| Returns master public key if public key is trusted. | |
| std::optional< TimeKeeper::time_point > | expires (shared_lock const &) const |
| Return the time when the validator list will expire. | |
| PublisherListStats | applyList (std::string const &globalManifest, std::optional< std::string > const &localManifest, std::string const &blob, std::string const &signature, std::uint32_t version, std::string siteUri, std::optional< uint256 > const &hash, scoped_lock const &) |
| Apply published list of public keys. | |
| void | updatePublisherList (PublicKey const &pubKey, PublisherList const ¤t, std::vector< PublicKey > const &oldList, scoped_lock const &) |
| std::filesystem::path | getCacheFileName (scoped_lock const &, PublicKey const &pubKey) const |
| Get the filename used for caching UNLs. | |
| void | cacheValidatorFile (scoped_lock const &lock, PublicKey const &pubKey) const |
| Write a JSON UNL to a cache file. | |
| std::pair< ListDisposition, std::optional< PublicKey > > | verify (scoped_lock const &, json::Value &list, Manifest manifest, std::string const &blob, std::string const &signature) |
| Check response for trusted valid published list. | |
| bool | removePublisherList (scoped_lock const &, PublicKey const &publisherKey, PublisherStatus reason) |
| Stop trusting publisher's list of keys. | |
| std::size_t | calculateQuorum (std::size_t unlSize, std::size_t effectiveUnlSize, std::size_t seenSize) |
| Return quorum for trusted validator set. | |
Static Private Member Functions | |
| static void | buildBlobInfos (std::map< std::size_t, ValidatorBlobInfo > &blobInfos, PublisherListCollection const &lists) |
| static std::map< std::size_t, ValidatorBlobInfo > | buildBlobInfos (PublisherListCollection const &lists) |
| static void | broadcastBlobs (PublicKey const &publisherKey, PublisherListCollection const &lists, std::size_t maxSequence, uint256 const &hash, Overlay &overlay, HashRouter &hashRouter, beast::Journal j) |
| static void | sendValidatorList (Peer &peer, std::uint64_t peerSequence, PublicKey const &publisherKey, std::size_t maxSequence, std::uint32_t rawVersion, std::string const &rawManifest, std::map< std::size_t, ValidatorBlobInfo > const &blobInfos, std::vector< MessageWithHash > &messages, HashRouter &hashRouter, beast::Journal j) |
| static json::Value | buildFileData (std::string const &pubKey, PublisherListCollection const &pubCollection, beast::Journal j) |
| Build a Json representation of the collection, suitable for writing to a cache file, or serving to a /vl/ query. | |
| static json::Value | buildFileData (std::string const &pubKey, PublisherListCollection const &pubCollection, std::optional< std::uint32_t > forceVersion, beast::Journal j) |
| Build a Json representation of the collection, suitable for writing to a cache file, or serving to a /vl/ query. | |
Static Private Attributes | |
| static constexpr std::uint32_t | kSupportedListVersions [] {1, 2} |
| static constexpr std::size_t | kMaxSupportedBlobs = 5 |
| static std::string const | kFilePrefix = "cache." |
Friends | |
| template<class Hasher> | |
| void | hash_append (Hasher &h, PublisherListCollection pl) |
Xrpld accepts ledger proposals and validations from trusted validator nodes. A ledger is considered fully-validated once the number of received trusted validations for a ledger meets or exceeds a quorum value.
This class manages the set of validation public keys the local xrpld node trusts. The list of trusted keys is populated using the keys listed in the configuration file as well as lists signed by trusted publishers. The trusted publisher public keys are specified in the config.
New lists are expected to include the following data:
"blob": Base64-encoded JSON string containing a "sequence", "validFrom", "validUntil", and "validators" field. "validFrom" contains the XRPL timestamp (seconds since January 1st, 2000 (00:00 UTC)) for when the list becomes valid. "validUntil" contains the XRPL timestamp for when the list expires. "validators" contains an array of objects with a "validation_public_key" and optional "manifest" field. "validation_public_key" should be the hex-encoded master public key. "manifest" should be the base64-encoded validator manifest."manifest": Base64-encoded serialization of a manifest containing the publisher's master and signing public keys."signature": Hex-encoded signature of the blob using the publisher's signing key."version": 1Individual validator lists are stored separately by publisher. The number of lists on which a validator's public key appears is also tracked.
The list of trusted validation public keys is reset at the start of each consensus round to take into account the latest known lists as well as the set of validators from whom validations are being received. Listed validation public keys are shuffled and then sorted by the number of lists they appear on. (The shuffling makes the order/rank of validators with the same number of listings non-deterministic.) A quorum value is calculated for the new trusted validator list. If there is only one list, all listed keys are trusted. Otherwise, the trusted list size is set to 125% of the quorum.
Definition at line 186 of file ValidatorList.h.
|
private |
Definition at line 244 of file ValidatorList.h.
|
private |
Definition at line 245 of file ValidatorList.h.
| using xrpl::ValidatorList::QuorumKeys = std::pair<std::size_t const, hash_set<PublicKey>> |
Definition at line 692 of file ValidatorList.h.
| xrpl::ValidatorList::ValidatorList | ( | ManifestCache & | validatorManifests, |
| ManifestCache & | publisherManifests, | ||
| TimeKeeper & | timeKeeper, | ||
| std::string const & | databasePath, | ||
| beast::Journal | j, | ||
| std::optional< std::size_t > | minimumQuorum = std::nullopt ) |
Definition at line 133 of file ValidatorList.cpp.
|
default |
| bool xrpl::ValidatorList::load | ( | std::optional< PublicKey > const & | localSigningKey, |
| std::vector< std::string > const & | configKeys, | ||
| std::vector< std::string > const & | publisherKeys, | ||
| std::optional< std::size_t > | listThreshold = {} ) |
Load configured trusted keys.
| localSigningKey | This node's validation public key |
| configKeys | List of trusted keys from config. Each entry consists of a base58 encoded validation public key, optionally followed by a comment. |
| publisherKeys | List of trusted publisher public keys. Each entry contains a base58 encoded account public key. |
May be called concurrently
Definition at line 152 of file ValidatorList.cpp.
|
static |
Pull the blob/signature/manifest information out of the appropriate Json body fields depending on the version.
Definition at line 396 of file ValidatorList.cpp.
|
static |
Definition at line 454 of file ValidatorList.cpp.
|
static |
Definition at line 696 of file ValidatorList.cpp.
|
staticnodiscard |
Definition at line 607 of file ValidatorList.cpp.
| ValidatorList::PublisherListStats xrpl::ValidatorList::applyListsAndBroadcast | ( | std::string const & | manifest, |
| std::uint32_t | version, | ||
| std::vector< ValidatorBlobInfo > const & | blobs, | ||
| std::string | siteUri, | ||
| uint256 const & | hash, | ||
| Overlay & | overlay, | ||
| HashRouter & | hashRouter, | ||
| NetworkOPs & | networkOPs ) |
Apply multiple published lists of public keys, then broadcast it to all peers that have not seen it or sent it.
| manifest | base64-encoded publisher key manifest |
| version | Version of published list format |
| blobs | Vector of BlobInfos representing one or more encoded validator lists and signatures (and optional manifests) |
| siteUri | Uri of the site from which the list was validated |
| hash | Hash of the data parameters |
| overlay | Overlay object which will handle sending the message |
| hashRouter | HashRouter object which will determine which peers not to send to |
| networkOPs | NetworkOPs object which will be informed if there is a valid VL |
May be called concurrently
Definition at line 806 of file ValidatorList.cpp.
| ValidatorList::PublisherListStats xrpl::ValidatorList::applyLists | ( | std::string const & | manifest, |
| std::uint32_t | version, | ||
| std::vector< ValidatorBlobInfo > const & | blobs, | ||
| std::string | siteUri, | ||
| std::optional< uint256 > const & | hash = {} ) |
Apply multiple published lists of public keys.
| manifest | base64-encoded publisher key manifest |
| version | Version of published list format |
| blobs | Vector of BlobInfos representing one or more encoded validator lists and signatures (and optional manifests) |
| siteUri | Uri of the site from which the list was validated |
| hash | Optional hash of the data parameters |
May be called concurrently
Definition at line 867 of file ValidatorList.cpp.
| std::vector< std::string > xrpl::ValidatorList::loadLists | ( | ) |
Attempt to read previously stored list files.
Expected to only be called when loading from URL fails.
May be called concurrently
Definition at line 1188 of file ValidatorList.cpp.
| TrustChanges xrpl::ValidatorList::updateTrusted | ( | hash_set< NodeID > const & | seenValidators, |
| NetClock::time_point | closeTime, | ||
| NetworkOPs & | ops, | ||
| Overlay & | overlay, | ||
| HashRouter & | hashRouter ) |
Update trusted nodes.
Reset the trusted nodes based on latest manifests, received validations, and lists.
| seenValidators | Set of NodeIDs of validators that have signed recently received validations |
May be called concurrently
Definition at line 1800 of file ValidatorList.cpp.
| std::size_t xrpl::ValidatorList::quorum | ( | ) | const |
Get quorum value for current trusted key set.
The quorum is the minimum number of validations needed for a ledger to be fully validated. It can change when the set of trusted validation keys is updated (at the start of each consensus round) and primarily depends on the number of trusted keys.
May be called concurrently
Definition at line 520 of file ValidatorList.h.
| bool xrpl::ValidatorList::trusted | ( | PublicKey const & | identity | ) | const |
Returns true if public key is trusted.
| identity | Validation public key |
May be called concurrently
Definition at line 1353 of file ValidatorList.cpp.
| bool xrpl::ValidatorList::listed | ( | PublicKey const & | identity | ) | const |
Returns true if public key is included on any lists.
| identity | Validation public key |
May be called concurrently
Definition at line 1337 of file ValidatorList.cpp.
| std::optional< PublicKey > xrpl::ValidatorList::getTrustedKey | ( | PublicKey const & | identity | ) | const |
Returns master public key if public key is trusted.
| identity | Validation public key |
May be called concurrently
Definition at line 1380 of file ValidatorList.cpp.
| std::optional< PublicKey > xrpl::ValidatorList::getListedKey | ( | PublicKey const & | identity | ) | const |
Returns listed master public if public key is included on any lists.
| identity | Validation public key |
May be called concurrently
Definition at line 1360 of file ValidatorList.cpp.
| bool xrpl::ValidatorList::trustedPublisher | ( | PublicKey const & | identity | ) | const |
Returns true if public key is a trusted publisher.
| identity | Publisher public key |
May be called concurrently
Definition at line 1388 of file ValidatorList.cpp.
| std::optional< PublicKey > xrpl::ValidatorList::localPublicKey | ( | ) | const |
This function returns the local validator public key or a std::nullopt.
May be called concurrently
Definition at line 1396 of file ValidatorList.cpp.
| void xrpl::ValidatorList::forEachListed | ( | std::function< void(PublicKey const &, bool)> | func | ) | const |
Invokes the callback once for every listed validation public key.
The arguments passed into the lambda are:
May be called concurrently
Definition at line 1643 of file ValidatorList.cpp.
| void xrpl::ValidatorList::forEachAvailable | ( | std::function< void(std::string const &manifest, std::uint32_t version, std::map< std::size_t, ValidatorBlobInfo > const &blobInfos, PublicKey const &pubKey, std::size_t maxSequence, uint256 const &hash)> | func | ) | const |
Invokes the callback once for every available publisher list's raw data members.
The arguments passed into the lambda are:
May be called concurrently
Definition at line 1652 of file ValidatorList.cpp.
| std::optional< json::Value > xrpl::ValidatorList::getAvailable | ( | std::string_view | pubKey, |
| std::optional< std::uint32_t > | forceVersion = {} ) |
Returns the current valid list for the given publisher key, if available, as a Json object.
Definition at line 1681 of file ValidatorList.cpp.
| std::size_t xrpl::ValidatorList::count | ( | ) | const |
Return the number of configured validator list sites.
Definition at line 1446 of file ValidatorList.cpp.
| std::optional< TimeKeeper::time_point > xrpl::ValidatorList::expires | ( | ) | const |
Return the time when the validator list will expire.
Definition at line 1506 of file ValidatorList.cpp.
| json::Value xrpl::ValidatorList::getJson | ( | ) | const |
Return a JSON representation of the state of the validator list.
Definition at line 1513 of file ValidatorList.cpp.
| QuorumKeys xrpl::ValidatorList::getQuorumKeys | ( | ) | const |
Get the quorum and all of the trusted keys.
Definition at line 699 of file ValidatorList.h.
get the trusted master public keys
Definition at line 1982 of file ValidatorList.cpp.
| std::size_t xrpl::ValidatorList::getListThreshold | ( | ) | const |
get the validator list threshold
Definition at line 1989 of file ValidatorList.cpp.
get the master public keys of Negative UNL validators
Definition at line 1996 of file ValidatorList.cpp.
set the Negative UNL with validators' master public keys
| negUnl | the public keys |
Definition at line 2003 of file ValidatorList.cpp.
| std::vector< std::shared_ptr< STValidation > > xrpl::ValidatorList::negativeUNLFilter | ( | std::vector< std::shared_ptr< STValidation > > && | validations | ) | const |
Remove validations that are from validators on the negative UNL.
| validations | the validations to filter |
Definition at line 2010 of file ValidatorList.cpp.
|
private |
Return the number of configured validator list sites.
Definition at line 1440 of file ValidatorList.cpp.
|
private |
Returns true if public key is trusted.
| identity | Validation public key |
May be called concurrently
Definition at line 1346 of file ValidatorList.cpp.
|
private |
Returns master public key if public key is trusted.
| identity | Validation public key |
May be called concurrently
Definition at line 1371 of file ValidatorList.cpp.
|
private |
Return the time when the validator list will expire.
Definition at line 1453 of file ValidatorList.cpp.
|
private |
Apply published list of public keys.
| manifest | base64-encoded publisher key manifest |
| blob | base64-encoded json containing published validator list |
| signature | Signature of the decoded blob |
| version | Version of published list format |
| siteUri | Uri of the site from which the list was validated |
| hash | Optional hash of the data parameters. Defaults to uninitialized |
May be called concurrently
Definition at line 1012 of file ValidatorList.cpp.
|
private |
Definition at line 944 of file ValidatorList.cpp.
|
staticprivate |
Definition at line 723 of file ValidatorList.cpp.
|
staticprivate |
Definition at line 742 of file ValidatorList.cpp.
|
staticprivate |
Definition at line 751 of file ValidatorList.cpp.
|
staticprivate |
Definition at line 645 of file ValidatorList.cpp.
|
private |
Get the filename used for caching UNLs.
Definition at line 290 of file ValidatorList.cpp.
|
staticprivate |
Build a Json representation of the collection, suitable for writing to a cache file, or serving to a /vl/ query.
Definition at line 297 of file ValidatorList.cpp.
|
staticprivate |
Build a Json representation of the collection, suitable for writing to a cache file, or serving to a /vl/ query.
Definition at line 307 of file ValidatorList.cpp.
|
private |
Write a JSON UNL to a cache file.
Definition at line 367 of file ValidatorList.cpp.
|
private |
Check response for trusted valid published list.
Calling public member function is expected to lock mutex
Definition at line 1242 of file ValidatorList.cpp.
|
private |
Stop trusting publisher's list of keys.
| publisherKey | Publisher public key |
Calling public member function is expected to lock mutex
Definition at line 1403 of file ValidatorList.cpp.
|
private |
Return quorum for trusted validator set.
| unlSize | Number of trusted validator keys |
| effectiveUnlSize | Number of trusted validator keys that are not in the NegativeUNL |
| seenSize | Number of trusted validators that have signed recently received validations |
Definition at line 1708 of file ValidatorList.cpp.
|
friend |
Definition at line 891 of file ValidatorList.h.
|
private |
Definition at line 238 of file ValidatorList.h.
|
private |
Definition at line 239 of file ValidatorList.h.
|
private |
Definition at line 240 of file ValidatorList.h.
|
private |
Definition at line 241 of file ValidatorList.h.
|
private |
Definition at line 242 of file ValidatorList.h.
|
mutableprivate |
Definition at line 243 of file ValidatorList.h.
|
private |
Definition at line 247 of file ValidatorList.h.
|
private |
Definition at line 248 of file ValidatorList.h.
|
private |
Definition at line 251 of file ValidatorList.h.
|
private |
Definition at line 254 of file ValidatorList.h.
Definition at line 257 of file ValidatorList.h.
|
private |
Definition at line 260 of file ValidatorList.h.
Definition at line 265 of file ValidatorList.h.
|
private |
Definition at line 267 of file ValidatorList.h.
|
private |
Definition at line 277 of file ValidatorList.h.
Definition at line 280 of file ValidatorList.h.
|
staticconstexprprivate |
Definition at line 283 of file ValidatorList.h.
|
staticconstexprprivate |
Definition at line 286 of file ValidatorList.h.
|
staticprivate |
Definition at line 288 of file ValidatorList.h.