|
rippled
|
#include <ValidatorList.h>

Classes | |
| struct | MessageWithHash |
| 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... | |
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 () |
| 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 | for_each_listed (std::function< void(PublicKey const &, bool)> func) const |
| Invokes the callback once for every listed validation public key. | |
| void | for_each_available (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::TMValidatorList const &body) |
| 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::size_t messageVersion, 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=maximumMessageSize) |
Private Types | |
| using | lock_guard = std::lock_guard< 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, lock_guard const &) |
| Apply published list of public keys. | |
| void | updatePublisherList (PublicKey const &pubKey, PublisherList const ¤t, std::vector< PublicKey > const &oldList, lock_guard const &) |
| boost::filesystem::path | getCacheFileName (lock_guard const &, PublicKey const &pubKey) const |
| Get the filename used for caching UNLs. | |
| void | cacheValidatorFile (lock_guard const &lock, PublicKey const &pubKey) const |
| Write a JSON UNL to a cache file. | |
| std::pair< ListDisposition, std::optional< PublicKey > > | verify (lock_guard const &, Json::Value &list, Manifest manifest, std::string const &blob, std::string const &signature) |
| Check response for trusted valid published list. | |
| bool | removePublisherList (lock_guard 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. | |
Private Attributes | |
| ManifestCache & | validatorManifests_ |
| ManifestCache & | publisherManifests_ |
| TimeKeeper & | timeKeeper_ |
| boost::filesystem::path const | dataPath_ |
| beast::Journal const | j_ |
| std::shared_mutex | mutex_ |
| std::atomic< std::size_t > | quorum_ |
| std::optional< std::size_t > | minimumQuorum_ |
| hash_map< PublicKey, PublisherListCollection > | publisherLists_ |
| hash_map< PublicKey, std::size_t > | keyListings_ |
| hash_set< PublicKey > | trustedMasterKeys_ |
| std::size_t | listThreshold_ |
| hash_set< PublicKey > | trustedSigningKeys_ |
| std::optional< PublicKey > | localPubKey_ |
| PublisherList | localPublisherList |
| hash_set< PublicKey > | negativeUNL_ |
Static Private Attributes | |
| static constexpr std::uint32_t | supportedListVersions [] {1, 2} |
| static constexpr std::size_t | maxSupportedBlobs = 5 |
| static std::string const | filePrefix_ = "cache." |
Friends | |
| template<class Hasher > | |
| void | hash_append (Hasher &h, PublisherListCollection pl) |
Rippled 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 rippled 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 Ripple timestamp (seconds since January 1st, 2000 (00:00 UTC)) for when the list becomes valid. "validUntil" contains the Ripple 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 152 of file ValidatorList.h.
|
private |
Definition at line 210 of file ValidatorList.h.
|
private |
Definition at line 211 of file ValidatorList.h.
| using xrpl::ValidatorList::QuorumKeys = std::pair<std::size_t const, hash_set<PublicKey> > |
Definition at line 637 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 98 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
false if an entry is invalid or unparsable Definition at line 117 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 357 of file ValidatorList.cpp.
|
static |
Definition at line 414 of file ValidatorList.cpp.
|
static |
Definition at line 421 of file ValidatorList.cpp.
|
static |
Definition at line 728 of file ValidatorList.cpp.
|
static |
Definition at line 612 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 |
ListDisposition::accepted, plus some of the publisher information, if list was successfully appliedMay be called concurrently
Definition at line 834 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 |
ListDisposition::accepted, plus some of the publisher information, if list was successfully appliedMay be called concurrently
Definition at line 883 of file ValidatorList.cpp.
| std::vector< std::string > xrpl::ValidatorList::loadLists | ( | ) |
Definition at line 1161 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 1734 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 479 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 1312 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 1296 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 |
std::nullopt if key is not trustedMay be called concurrently
Definition at line 1339 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 |
std::nullopt if key is not listedMay be called concurrently
Definition at line 1319 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 1347 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 1355 of file ValidatorList.cpp.
| void xrpl::ValidatorList::for_each_listed | ( | 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 1589 of file ValidatorList.cpp.
| void xrpl::ValidatorList::for_each_available | ( | 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:
PublicKey of the blob signer (matches the value from [validator_list_keys])May be called concurrently
Definition at line 1598 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 1624 of file ValidatorList.cpp.
| std::size_t xrpl::ValidatorList::count | ( | ) | const |
Return the number of configured validator list sites.
Definition at line 1401 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 1457 of file ValidatorList.cpp.
| Json::Value xrpl::ValidatorList::getJson | ( | ) | const |
Return a JSON representation of the state of the validator list.
Definition at line 1464 of file ValidatorList.cpp.
| QuorumKeys xrpl::ValidatorList::getQuorumKeys | ( | ) | const |
Get the quorum and all of the trusted keys.
Definition at line 643 of file ValidatorList.h.
get the trusted master public keys
Definition at line 1906 of file ValidatorList.cpp.
| std::size_t xrpl::ValidatorList::getListThreshold | ( | ) | const |
get the validator list threshold
Definition at line 1913 of file ValidatorList.cpp.
get the master public keys of Negative UNL validators
Definition at line 1920 of file ValidatorList.cpp.
set the Negative UNL with validators' master public keys
| negUnl | the public keys |
Definition at line 1927 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 1934 of file ValidatorList.cpp.
|
private |
Return the number of configured validator list sites.
Definition at line 1395 of file ValidatorList.cpp.
|
private |
Returns true if public key is trusted.
| identity | Validation public key |
May be called concurrently
Definition at line 1305 of file ValidatorList.cpp.
|
private |
Returns master public key if public key is trusted.
| identity | Validation public key |
std::nullopt if key is not trustedMay be called concurrently
Definition at line 1330 of file ValidatorList.cpp.
|
private |
Return the time when the validator list will expire.
Definition at line 1408 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 |
ListDisposition::accepted, plus some of the publisher information, if list was successfully appliedMay be called concurrently
Definition at line 1005 of file ValidatorList.cpp.
|
private |
Definition at line 947 of file ValidatorList.cpp.
|
staticprivate |
Definition at line 746 of file ValidatorList.cpp.
|
staticprivate |
Definition at line 761 of file ValidatorList.cpp.
|
staticprivate |
Definition at line 770 of file ValidatorList.cpp.
|
staticprivate |
Definition at line 666 of file ValidatorList.cpp.
|
private |
Get the filename used for caching UNLs.
Definition at line 254 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 261 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 271 of file ValidatorList.cpp.
|
private |
Write a JSON UNL to a cache file.
Definition at line 330 of file ValidatorList.cpp.
|
private |
Check response for trusted valid published list.
ListDisposition::accepted if list can be appliedCalling public member function is expected to lock mutex
Definition at line 1216 of file ValidatorList.cpp.
|
private |
Stop trusting publisher's list of keys.
| publisherKey | Publisher public key |
false if key was not trustedCalling public member function is expected to lock mutex
Definition at line 1362 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 1649 of file ValidatorList.cpp.
|
friend |
Definition at line 821 of file ValidatorList.h.
|
private |
Definition at line 204 of file ValidatorList.h.
|
private |
Definition at line 205 of file ValidatorList.h.
|
private |
Definition at line 206 of file ValidatorList.h.
|
private |
Definition at line 207 of file ValidatorList.h.
|
private |
Definition at line 208 of file ValidatorList.h.
|
mutableprivate |
Definition at line 209 of file ValidatorList.h.
|
private |
Definition at line 213 of file ValidatorList.h.
|
private |
Definition at line 214 of file ValidatorList.h.
|
private |
Definition at line 217 of file ValidatorList.h.
|
private |
Definition at line 220 of file ValidatorList.h.
Definition at line 223 of file ValidatorList.h.
|
private |
Definition at line 226 of file ValidatorList.h.
Definition at line 231 of file ValidatorList.h.
|
private |
Definition at line 233 of file ValidatorList.h.
|
private |
Definition at line 243 of file ValidatorList.h.
Definition at line 246 of file ValidatorList.h.
|
staticconstexprprivate |
Definition at line 249 of file ValidatorList.h.
|
staticconstexprprivate |
Definition at line 252 of file ValidatorList.h.
|
staticprivate |
Definition at line 254 of file ValidatorList.h.