rippled
|
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 (PublicKey const &localSigningKey, std::vector< std::string > const &configKeys, std::vector< std::string > const &publisherKeys) |
Load configured trusted keys. More... | |
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. More... | |
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. More... | |
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. More... | |
std::size_t | quorum () const |
Get quorum value for current trusted key set. More... | |
bool | trusted (PublicKey const &identity) const |
Returns true if public key is trusted. More... | |
bool | listed (PublicKey const &identity) const |
Returns true if public key is included on any lists. More... | |
std::optional< PublicKey > | getTrustedKey (PublicKey const &identity) const |
Returns master public key if public key is trusted. More... | |
std::optional< PublicKey > | getListedKey (PublicKey const &identity) const |
Returns listed master public if public key is included on any lists. More... | |
bool | trustedPublisher (PublicKey const &identity) const |
Returns true if public key is a trusted publisher. More... | |
PublicKey | localPublicKey () const |
Returns local validator public key. More... | |
void | for_each_listed (std::function< void(PublicKey const &, bool)> func) const |
Invokes the callback once for every listed validation public key. More... | |
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. More... | |
std::optional< Json::Value > | getAvailable (boost::beast::string_view const &pubKey, std::optional< std::uint32_t > forceVersion={}) |
Returns the current valid list for the given publisher key, if available, as a Json object. More... | |
std::size_t | count () const |
Return the number of configured validator list sites. More... | |
std::optional< TimeKeeper::time_point > | expires () const |
Return the time when the validator list will expire. More... | |
Json::Value | getJson () const |
Return a JSON representation of the state of the validator list. More... | |
QuorumKeys | getQuorumKeys () const |
Get the quorum and all of the trusted keys. More... | |
hash_set< PublicKey > | getTrustedMasterKeys () const |
get the trusted master public keys More... | |
hash_set< PublicKey > | getNegativeUNL () const |
get the master public keys of Negative UNL validators More... | |
void | setNegativeUNL (hash_set< PublicKey > const &negUnl) |
set the Negative UNL with validators' master public keys More... | |
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. More... | |
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. More... | |
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=maximiumMessageSize) |
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. More... | |
bool | trusted (shared_lock const &, PublicKey const &identity) const |
Returns true if public key is trusted. More... | |
std::optional< PublicKey > | getTrustedKey (shared_lock const &, PublicKey const &identity) const |
Returns master public key if public key is trusted. More... | |
std::optional< TimeKeeper::time_point > | expires (shared_lock const &) const |
Return the time when the validator list will expire. More... | |
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. More... | |
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. More... | |
void | cacheValidatorFile (lock_guard const &lock, PublicKey const &pubKey) const |
Write a JSON UNL to a cache file. More... | |
ListDisposition | verify (lock_guard const &, Json::Value &list, PublicKey &pubKey, std::string const &manifest, std::string const &blob, std::string const &signature) |
Check response for trusted valid published list. More... | |
bool | removePublisherList (lock_guard const &, PublicKey const &publisherKey, PublisherStatus reason) |
Stop trusting publisher's list of keys. More... | |
std::size_t | calculateQuorum (std::size_t unlSize, std::size_t effectiveUnlSize, std::size_t seenSize) |
Return quorum for trusted validator set. More... | |
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. More... | |
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. More... | |
Private Attributes | |
ManifestCache & | validatorManifests_ |
ManifestCache & | publisherManifests_ |
TimeKeeper & | timeKeeper_ |
const boost::filesystem::path | dataPath_ |
const beast::Journal | j_ |
boost::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_ |
hash_set< PublicKey > | trustedSigningKeys_ |
PublicKey | localPubKey_ |
hash_set< PublicKey > | negativeUNL_ |
Static Private Attributes | |
static constexpr std::uint32_t | supportedListVersions [] {1, 2} |
static constexpr std::size_t | maxSupportedBlobs = 5 |
static const std::string | 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 172 of file ValidatorList.h.
|
private |
Definition at line 230 of file ValidatorList.h.
|
private |
Definition at line 231 of file ValidatorList.h.
using ripple::ValidatorList::QuorumKeys = std::pair<std::size_t const, hash_set<PublicKey> > |
Definition at line 652 of file ValidatorList.h.
ripple::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 118 of file ValidatorList.cpp.
|
default |
bool ripple::ValidatorList::load | ( | PublicKey const & | localSigningKey, |
std::vector< std::string > const & | configKeys, | ||
std::vector< std::string > const & | publisherKeys | ||
) |
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 136 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 362 of file ValidatorList.cpp.
|
static |
Definition at line 420 of file ValidatorList.cpp.
|
static |
Definition at line 427 of file ValidatorList.cpp.
|
static |
Definition at line 749 of file ValidatorList.cpp.
|
static |
Definition at line 612 of file ValidatorList.cpp.
ValidatorList::PublisherListStats ripple::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 869 of file ValidatorList.cpp.
ValidatorList::PublisherListStats ripple::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 922 of file ValidatorList.cpp.
std::vector< std::string > ripple::ValidatorList::loadLists | ( | ) |
Definition at line 1206 of file ValidatorList.cpp.
TrustChanges ripple::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 1769 of file ValidatorList.cpp.
std::size_t ripple::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 492 of file ValidatorList.h.
bool ripple::ValidatorList::trusted | ( | PublicKey const & | identity | ) | const |
Returns true
if public key is trusted.
identity | Validation public key |
May be called concurrently
Definition at line 1367 of file ValidatorList.cpp.
bool ripple::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 1349 of file ValidatorList.cpp.
std::optional< PublicKey > ripple::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 1396 of file ValidatorList.cpp.
std::optional< PublicKey > ripple::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 1374 of file ValidatorList.cpp.
bool ripple::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 1404 of file ValidatorList.cpp.
PublicKey ripple::ValidatorList::localPublicKey | ( | ) | const |
Returns local validator public key.
May be called concurrently
Definition at line 1412 of file ValidatorList.cpp.
void ripple::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 1641 of file ValidatorList.cpp.
void ripple::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 1651 of file ValidatorList.cpp.
std::optional< Json::Value > ripple::ValidatorList::getAvailable | ( | boost::beast::string_view const & | 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 1678 of file ValidatorList.cpp.
std::size_t ripple::ValidatorList::count | ( | ) | const |
Return the number of configured validator list sites.
Definition at line 1459 of file ValidatorList.cpp.
std::optional< TimeKeeper::time_point > ripple::ValidatorList::expires | ( | ) | const |
Return the time when the validator list will expire.
Definition at line 1500 of file ValidatorList.cpp.
Json::Value ripple::ValidatorList::getJson | ( | ) | const |
Return a JSON representation of the state of the validator list.
Definition at line 1507 of file ValidatorList.cpp.
QuorumKeys ripple::ValidatorList::getQuorumKeys | ( | ) | const |
Get the quorum and all of the trusted keys.
Definition at line 658 of file ValidatorList.h.
get the trusted master public keys
Definition at line 1933 of file ValidatorList.cpp.
get the master public keys of Negative UNL validators
Definition at line 1940 of file ValidatorList.cpp.
set the Negative UNL with validators' master public keys
negUnl | the public keys |
Definition at line 1947 of file ValidatorList.cpp.
std::vector< std::shared_ptr< STValidation > > ripple::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 1954 of file ValidatorList.cpp.
|
private |
Return the number of configured validator list sites.
Definition at line 1453 of file ValidatorList.cpp.
|
private |
Returns true
if public key is trusted.
identity | Validation public key |
May be called concurrently
Definition at line 1358 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 1385 of file ValidatorList.cpp.
|
private |
Return the time when the validator list will expire.
Definition at line 1466 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 1060 of file ValidatorList.cpp.
|
private |
Definition at line 996 of file ValidatorList.cpp.
|
staticprivate |
Definition at line 776 of file ValidatorList.cpp.
|
staticprivate |
Definition at line 792 of file ValidatorList.cpp.
|
staticprivate |
Definition at line 802 of file ValidatorList.cpp.
|
staticprivate |
Definition at line 677 of file ValidatorList.cpp.
|
private |
Get the filename used for caching UNLs.
Definition at line 250 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 259 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 269 of file ValidatorList.cpp.
|
private |
Write a JSON UNL to a cache file.
Definition at line 331 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 1259 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 1419 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 833 of file ValidatorList.h.
|
private |
Definition at line 224 of file ValidatorList.h.
|
private |
Definition at line 225 of file ValidatorList.h.
|
private |
Definition at line 226 of file ValidatorList.h.
|
private |
Definition at line 227 of file ValidatorList.h.
|
private |
Definition at line 228 of file ValidatorList.h.
|
mutableprivate |
Definition at line 229 of file ValidatorList.h.
|
private |
Definition at line 233 of file ValidatorList.h.
|
private |
Definition at line 234 of file ValidatorList.h.
|
private |
Definition at line 237 of file ValidatorList.h.
|
private |
Definition at line 240 of file ValidatorList.h.
Definition at line 243 of file ValidatorList.h.
Definition at line 248 of file ValidatorList.h.
|
private |
Definition at line 250 of file ValidatorList.h.
Definition at line 253 of file ValidatorList.h.
|
staticconstexprprivate |
Definition at line 256 of file ValidatorList.h.
|
staticconstexprprivate |
Definition at line 259 of file ValidatorList.h.
|
staticprivate |
Definition at line 261 of file ValidatorList.h.