1#include <xrpld/app/misc/ValidatorList.h>
3#include <xrpld/core/TimeKeeper.h>
4#include <xrpld/overlay/Message.h>
5#include <xrpld/overlay/Overlay.h>
6#include <xrpld/overlay/Peer.h>
8#include <xrpl/basics/Blob.h>
9#include <xrpl/basics/FileUtilities.h>
10#include <xrpl/basics/Log.h>
11#include <xrpl/basics/Slice.h>
12#include <xrpl/basics/StringUtilities.h>
13#include <xrpl/basics/base64.h>
14#include <xrpl/basics/base_uint.h>
15#include <xrpl/basics/chrono.h>
16#include <xrpl/basics/strHex.h>
17#include <xrpl/beast/utility/Journal.h>
18#include <xrpl/beast/utility/instrumentation.h>
19#include <xrpl/core/HashRouter.h>
20#include <xrpl/json/json_forwards.h>
21#include <xrpl/json/json_reader.h>
22#include <xrpl/json/json_value.h>
23#include <xrpl/protocol/PublicKey.h>
24#include <xrpl/protocol/STValidation.h>
25#include <xrpl/protocol/UintTypes.h>
26#include <xrpl/protocol/digest.h>
27#include <xrpl/protocol/jss.h>
28#include <xrpl/protocol/tokens.h>
29#include <xrpl/server/Manifest.h>
30#include <xrpl/server/NetworkOPs.h>
32#include <boost/regex/v5/regex.hpp>
33#include <boost/regex/v5/regex_match.hpp>
70 return "same_sequence";
74 return "known_sequence";
76 return "unsupported_version";
145 ,
quorum_(minimumQuorum.value_or(1))
158 static boost::regex
const kRE(
172 JLOG(
j_.debug()) <<
"Loading configured trusted validator list publisher keys";
175 for (
auto const& key : publisherKeys)
177 JLOG(
j_.trace()) <<
"Processing '" << key <<
"'";
183 JLOG(
j_.error()) <<
"Invalid validator list publisher key: " << key;
192 JLOG(
j_.warn()) <<
"Configured validator list publisher key is revoked: " << key;
198 JLOG(
j_.warn()) <<
"Duplicate validator list publisher key: " << key;
212 "xrpl::ValidatorList::load : list threshold inside range");
213 JLOG(
j_.debug()) <<
"Validator list threshold set in configuration to " <<
listThreshold_;
220 JLOG(
j_.debug()) <<
"Validator list threshold computed as " <<
listThreshold_;
223 JLOG(
j_.debug()) <<
"Loaded " <<
count <<
" keys";
236 JLOG(
j_.debug()) <<
"Added own master key "
241 JLOG(
j_.debug()) <<
"Loading configured validator keys";
244 for (
auto const& n : configKeys)
246 JLOG(
j_.trace()) <<
"Processing '" << n <<
"'";
250 if (!boost::regex_match(n, match, kRE))
252 JLOG(
j_.error()) <<
"Malformed entry: '" << n <<
"'";
260 JLOG(
j_.error()) <<
"Invalid node identity: " << match[1];
271 JLOG(
j_.warn()) <<
"Duplicate node identity: " << match[1];
284 JLOG(
j_.debug()) <<
"Loaded " <<
count <<
" entries";
317 "xrpl::ValidatorList::buildFileData : valid publisher list input");
318 auto const effectiveVersion = forceVersion ? *forceVersion : pubCollection.
rawVersion;
321 value[jss::version] = effectiveVersion;
322 value[jss::public_key] = pubKey;
324 switch (effectiveVersion)
327 auto const& current = pubCollection.
current;
328 value[jss::blob] = current.
rawBlob;
329 value[jss::signature] = current.rawSignature;
332 if (current.rawManifest && *current.rawManifest != pubCollection.
rawManifest)
333 value[jss::manifest] = *current.rawManifest;
342 blob[jss::blob] = pubList.rawBlob;
343 blob[jss::signature] = pubList.rawSignature;
344 if (pubList.rawManifest && *pubList.rawManifest != outerManifest)
345 blob[jss::manifest] = *pubList.rawManifest;
349 for (
auto const& [_, pending] : pubCollection.
remaining)
355 value[jss::blobs_v2] = std::move(blobs);
359 JLOG(j.
trace()) <<
"Invalid VL version provided: " << effectiveVersion;
382 value[jss::refresh_interval] = 24 * 60;
389 JLOG(
j_.error()) <<
"Problem writing " << filename <<
" " << ec.
value() <<
": "
411 result.
size() == 1,
"xrpl::ValidatorList::parseBlobs : single element result");
425 auto const& blobs = body[jss::blobs_v2];
427 for (
auto const& blobInfo : blobs)
429 if (!blobInfo.isObject() || !blobInfo.isMember(jss::signature) ||
430 !blobInfo[jss::signature].isString() || !blobInfo.isMember(jss::blob) ||
431 !blobInfo[jss::blob].isString())
434 info.
blob = blobInfo[jss::blob].asString();
435 info.
signature = blobInfo[jss::signature].asString();
436 if (blobInfo.isMember(jss::manifest))
438 if (!blobInfo[jss::manifest].isString())
440 info.
manifest = blobInfo[jss::manifest].asString();
444 result.
size() == blobs.size(),
445 "xrpl::ValidatorList::parseBlobs(version, Jason::Value) : "
446 "result size matches");
459 result.
reserve(body.blobs_size());
460 for (
auto const& blob : body.blobs())
463 info.
blob = blob.blob();
465 if (blob.has_manifest())
471 result.
size() == body.blobs_size(),
472 "xrpl::ValidatorList::parseBlobs(TMValidatorListCollection) : result size "
480 protocol::TMValidatorListCollection
const& largeMsg,
488 protocol::TMValidatorListCollection
const& largeMsg,
493 if (begin == 0 && end == 0)
494 end = largeMsg.blobs_size();
495 XRPL_ASSERT(begin < end,
"xrpl::splitMessage : valid inputs");
499 auto mid = (begin + end) / 2;
509 protocol::TMValidatorListCollection
const& largeMsg,
519 smallMsg->set_version(largeMsg.version());
520 smallMsg->set_manifest(largeMsg.manifest());
524 *smallMsg->add_blobs() = largeMsg.blobs(i);
531 if (size > maxSize && end - begin > 1)
535 return splitMessage(messages, largeMsg, maxSize, begin, end);
545 UNREACHABLE(
"xrpl::splitMessageParts : maximum message size exceeded");
553 smallMsg->blobs_size());
554 return messages.
back().numVLs;
570 "xrpl::buildValidatorListMessage(std::map<std::size_t, "
571 "ValidatorBlobInfo>) : empty messages input");
572 protocol::TMValidatorListCollection msg;
573 auto const version = rawVersion < 2 ? 2 : rawVersion;
574 msg.set_version(version);
575 msg.set_manifest(rawManifest);
577 for (
auto const& [sequence, blobInfo] : blobInfos)
579 if (sequence <= peerSequence)
581 protocol::ValidatorBlobInfo& blob = *msg.add_blobs();
582 blob.set_blob(blobInfo.blob);
583 blob.set_signature(blobInfo.signature);
584 if (blobInfo.manifest)
585 blob.set_manifest(*blobInfo.manifest);
588 msg.blobs_size() > 0,
589 "xrpl::buildValidatorListMessage(std::map<std::size_t, "
590 "ValidatorBlobInfo>) : minimum message blobs");
601 return messages.
back().numVLs;
618 "xrpl::ValidatorList::buildValidatorListMessages : empty messages "
622 return total + m.numVLs;
624 if (peerSequence < maxSequence)
626 if (messages.
empty())
629 messages, peerSequence, rawVersion, rawManifest, blobInfos, maxSize);
630 if (messages.
empty())
638 return {maxSequence, numVLs};
658 peerSequence, maxSequence, rawVersion, rawManifest, blobInfos, messages);
659 if (newPeerSequence != 0u)
663 "xrpl::ValidatorList::sendValidatorList : non-empty messages "
669 for (
auto const& message : messages)
673 peer.
send(message.message);
681 sent || messages.size() == 1,
682 "xrpl::ValidatorList::sendValidatorList : sent or one message");
685 JLOG(j.
debug()) <<
"Sent " << messages.size()
686 <<
" validator list collection(s) containing " << numVLs
687 <<
" validator list(s) for " <<
strHex(publisherKey)
688 <<
" with sequence range " << peerSequence <<
", " << newPeerSequence
727 auto const& current = lists.
current;
729 blobInfos[current.sequence] = {
730 .blob = current.rawBlob,
731 .signature = current.rawSignature,
732 .manifest = current.rawManifest};
733 for (
auto const& [sequence, vl] : remaining)
735 blobInfos[sequence] = {
736 .blob = vl.rawBlob, .signature = vl.rawSignature, .manifest = vl.rawManifest};
774 "xrpl::ValidatorList::broadcastBlobs : valid sequence");
779 if (!toSkip->contains(peer->id()))
781 auto const peerSequence = peer->publisherListSequence(publisherKey).value_or(0);
782 if (peerSequence < maxSequence)
784 if (blobInfos.
empty())
794 messages2[peerSequence],
816 auto const result =
applyLists(manifest, version, blobs, std::move(siteUri), hash);
817 auto const disposition = result.bestDisposition();
853 *result.publisherKey,
855 *pubCollection.maxSequence,
881 for (
auto const& blobInfo : blobs)
897 stats.mergeDispositions(result);
898 result = std::move(stats);
913 auto& remaining = pubCollection.remaining;
914 auto const& current = pubCollection.current;
915 for (
auto iter = remaining.begin(); iter != remaining.end();)
919 next == remaining.end() || next->first > iter->first,
920 "xrpl::ValidatorList::applyLists : next is valid");
921 if (iter->first <= current.sequence ||
922 (next != remaining.end() && next->second.validFrom <= iter->second.validFrom))
924 iter = remaining.erase(iter);
934 pubCollection.fullHash =
sha512Half(pubCollection);
936 result.
sequence = *pubCollection.maxSequence;
953 auto iNew = publisherList.
begin();
954 auto iOld = oldList.
begin();
955 while (iNew != publisherList.
end() || iOld != oldList.
end())
957 if (iOld == oldList.
end() || (iNew != publisherList.
end() && *iNew < *iOld))
965 else if (iNew == publisherList.
end() || (iOld != oldList.
end() && *iOld < *iNew))
985 if (publisherList.
empty())
987 JLOG(
j_.warn()) <<
"No validator keys included in valid list";
990 for (
auto const& valManifest : manifests)
996 JLOG(
j_.warn()) <<
"List for " <<
strHex(pubKey)
997 <<
" contained untrusted validator manifest";
1005 JLOG(
j_.warn()) <<
"List for " <<
strHex(pubKey)
1006 <<
" contained invalid validator manifest";
1022 using namespace std::string_literals;
1025 auto const& manifest = localManifest ? *localManifest : globalManifest;
1032 JLOG(
j_.warn()) <<
"UNL manifest exceeds maximum size";
1038 JLOG(
j_.warn()) <<
"UNL manifest cannot be deserialized";
1042 auto [result, pubKeyOpt] =
verify(lock, list, std::move(*m), blob, signature);
1046 JLOG(
j_.warn()) <<
"UNL manifest is signed with an unrecognized master public key";
1057 UNREACHABLE(
"xrpl::ValidatorList::applyList : invalid public key type");
1068 if (pubCollection.maxSequence &&
1075 result, pubKey, pubCollection.status, *pubCollection.maxSequence};
1083 auto const sequence = list[jss::sequence].
asUInt();
1084 auto const accepted =
1092 pubCollection.rawManifest = globalManifest;
1093 if (!pubCollection.maxSequence || sequence > *pubCollection.maxSequence)
1094 pubCollection.maxSequence = sequence;
1096 json::Value const& newList = list[jss::validators];
1098 if (accepted && pubCollection.remaining.contains(sequence))
1105 auto& publisher = pubCollection.current;
1107 oldList = std::move(pubCollection.current.list);
1109 publisher = std::move(pubCollection.remaining[sequence]);
1111 pubCollection.remaining.erase(sequence);
1114 publisher.sequence == sequence,
1115 "xrpl::ValidatorList::applyList : publisher sequence match");
1119 auto& publisher = accepted ? pubCollection.current : pubCollection.remaining[sequence];
1120 publisher.sequence = sequence;
1122 list.
isMember(jss::effective) ? list[jss::effective].
asUInt() : 0}};
1123 publisher.validUntil =
1125 publisher.siteUri = std::move(siteUri);
1126 publisher.rawBlob = blob;
1127 publisher.rawSignature = signature;
1128 publisher.rawManifest = localManifest;
1130 publisher.hash = *hash;
1136 oldList = std::move(publisherList);
1138 publisherList.
clear();
1140 for (
auto const& val : newList)
1142 if (val.isObject() && val.isMember(jss::validation_public_key) &&
1143 val[jss::validation_public_key].isString())
1146 strUnHex(val[jss::validation_public_key].asString());
1151 <<
"Invalid node identity: " << val[jss::validation_public_key].asString();
1158 if (val.isMember(jss::manifest) && val[jss::manifest].isString())
1159 manifests.
push_back(val[jss::manifest].asString());
1168 pubCollection.rawVersion =
std::max(pubCollection.rawVersion, version);
1169 if (!pubCollection.remaining.empty())
1173 pubCollection.rawVersion =
std::max(pubCollection.rawVersion, 2u);
1177 result, pubKey, pubCollection.status, *pubCollection.maxSequence};
1190 using namespace std::string_literals;
1206 auto const fullPath{
canonical(filename, ec)};
1211 if (!ec && (
size == 0u))
1223 return fullPath.root_path() ==
"/"s ?
"file://" :
"file:///";
1253 auto const revoked = manifest.
revoked();
1272 auto const sig =
strUnHex(signature);
1281 if (
list.isMember(jss::sequence) &&
list[jss::sequence].isInt() &&
1282 list.isMember(jss::expiration) &&
list[jss::expiration].isInt() &&
1283 (!
list.isMember(jss::effective) ||
list[jss::effective].isInt()) &&
1284 list.isMember(jss::validators) &&
list[jss::validators].isArray())
1286 auto const sequence =
list[jss::sequence].asUInt();
1288 list.isMember(jss::effective) ?
list[jss::effective].asUInt() : 0}};
1289 auto const validUntil =
1293 if (validUntil <= validFrom)
1297 if (sequence < listCollection.current.sequence)
1301 if (sequence == listCollection.current.sequence)
1305 if (validUntil <= now)
1309 if (validFrom > now)
1321 return !listCollection.maxSequence || sequence > *listCollection.maxSequence ||
1322 (!listCollection.remaining.contains(sequence) &&
1323 validFrom < listCollection.remaining.at(*listCollection.maxSequence).validFrom)
1367 return std::nullopt;
1376 return std::nullopt;
1410 "xrpl::ValidatorList::removePublisherList : valid reason input");
1415 JLOG(
j_.debug()) <<
"Removing validator list for publisher " <<
strHex(publisherKey);
1417 for (
auto const& val : iList->second.current.list)
1423 if (iVal->second <= 1)
1433 iList->second.current.list.clear();
1434 iList->second.status = reason;
1449 return count(readLock);
1459 auto const& current = collection.current;
1462 return std::nullopt;
1468 auto chainedExpiration = current.validUntil;
1469 for (
auto const& [sequence, check] : collection.remaining)
1472 if (check.validFrom <= chainedExpiration)
1474 chainedExpiration = check.validUntil;
1483 if (!res || chainedExpiration < *res)
1485 res = chainedExpiration;
1493 auto const& current = collection;
1497 if (!res || chainedExpiration < *res)
1499 res = chainedExpiration;
1526 if (
auto when =
expires(readLock))
1528 if (*when == TimeKeeper::time_point::max())
1530 x[jss::expiration] =
"never";
1531 x[jss::status] =
"active";
1539 x[jss::status] =
"active";
1543 x[jss::status] =
"expired";
1549 x[jss::status] =
"unknown";
1550 x[jss::expiration] =
"unknown";
1567 curr[jss::pubkey_publisher] =
strHex(publicKey);
1571 target[jss::uri] = publisherList.
siteUri;
1580 for (
auto const& key : publisherList.
list)
1586 auto const& current = pubCollection.current;
1587 appendList(current, curr);
1590 curr[jss::version] = pubCollection.rawVersion;
1595 for (
auto const& [sequence,
future] : pubCollection.remaining)
1597 using namespace std::chrono_literals;
1605 "xrpl::ValidatorList::getJson : minimum valid from");
1607 if (remaining.
size() != 0u)
1608 curr[jss::remaining] = std::move(remaining);
1648 func(v.first,
trusted(readLock, v.first));
1668 plCollection.maxSequence.value_or(0) != 0,
1669 "xrpl::ValidatorList::for_each_available : nonzero maxSequence");
1671 plCollection.rawManifest,
1672 plCollection.rawVersion,
1675 plCollection.maxSequence.value_or(0),
1676 plCollection.fullHash);
1687 auto const keyBlob =
strUnHex(pubKey);
1691 JLOG(
j_.warn()) <<
"Invalid requested validator list publisher key: " << pubKey;
1717 JLOG(
j_.warn()) <<
"Using potentially unsafe quorum of " << *
minimumQuorum_
1718 <<
" as specified on the command line";
1752 auto const errorThreshold =
std::min(
1756 errorThreshold > 0,
"xrpl::ValidatorList::calculateQuorum : nonzero error threshold");
1757 if (unavailable >= errorThreshold)
1807 using namespace std::chrono_literals;
1821 auto& remaining = collection.remaining;
1822 auto const firstIter = remaining.begin();
1823 auto iter = firstIter;
1824 if (iter != remaining.end() && iter->second.validFrom <= closeTime)
1828 next != remaining.end() &&
next->second.validFrom <= closeTime;
1833 "xrpl::ValidatorList::updateTrusted : sequential "
1837 iter != remaining.end(),
1838 "xrpl::ValidatorList::updateTrusted : non-end of "
1842 auto sequence = iter->first;
1843 auto& candidate = iter->second;
1844 auto& current = collection.current;
1846 candidate.validFrom <= closeTime,
1847 "xrpl::ValidatorList::updateTrusted : maximum time");
1849 auto const oldList = current.list;
1850 current = std::move(candidate);
1854 current.sequence == sequence,
1855 "xrpl::ValidatorList::updateTrusted : sequence match");
1859 if (current.validUntil <= closeTime)
1860 current.list.clear();
1869 broadcastBlobs(pubKey, collection, sequence, current.hash, overlay, hashRouter,
j_);
1872 remaining.erase(firstIter,
std::next(iter));
1879 collection.current.validUntil <= closeTime)
1907 "xrpl::ValidatorList::updateTrusted : count meets threshold");
1921 if (!trustChanges.
added.empty() || !trustChanges.
removed.empty())
1930 XRPL_ASSERT(signingKey,
"xrpl::ValidatorList::updateTrusted : found signing key");
1937 <<
" listed validators eligible for inclusion in the trusted set";
1940 auto effectiveUnlSize = unlSize;
1941 auto seenSize = seenValidators.
size();
1954 for (
auto const& nid : seenValidators)
1962 JLOG(
j_.debug()) <<
"Using quorum of " <<
quorum_ <<
" for new set of " << unlSize
1963 <<
" trusted validators (" << trustChanges.
added.size() <<
" added, "
1964 << trustChanges.
removed.size() <<
" removed)";
1968 JLOG(
j_.warn()) <<
"New quorum of " <<
quorum_
1969 <<
" exceeds the number of trusted validators (" << unlSize <<
")";
1978 return trustChanges;
2013 auto ret = std::move(validations);
2021 [&](
auto const& v) ->
bool {
2022 if (
auto const masterKey =
getTrustedKey(readLock, v->getSignerPublic());
NetClock::duration duration
NetClock::time_point time_point
A generic endpoint for log messages.
Stream trace() const
Severity stream access functions.
Unserialize a JSON document into a Value.
bool parse(std::string const &document, Value &root)
Read a Value from a JSON document.
Value & append(Value const &value)
Append value to array at the end.
UInt size() const
Number of values in array or object.
std::string asString() const
Returns the unquoted string value.
bool isMember(char const *key) const
Return true if the object has a member named key.
Routing table for objects identified by hash.
std::optional< std::set< PeerShortID > > shouldRelay(uint256 const &key)
Determines whether the hashed item should be relayed.
bool addSuppressionPeer(uint256 const &key, PeerShortID peer)
Remembers manifests with the highest sequence number.
static std::size_t totalSize(::google::protobuf::Message const &message)
std::chrono::time_point< NetClock > time_point
Provides server functionality for clients.
virtual void clearUNLBlocked()=0
virtual void setUNLBlocked()=0
Manages the set of connected peers.
virtual PeerSequence getActivePeers() const =0
Returns a sequence representing the current list of peers.
Represents a peer connection in the overlay.
virtual std::string const & fingerprint() const =0
virtual void setPublisherListSequence(PublicKey const &, std::size_t const)=0
virtual void send(std::shared_ptr< Message > const &m)=0
virtual id_t id() const =0
An immutable linear range of bytes.
Manages various times used by the server.
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)
std::scoped_lock< decltype(mutex_)> scoped_lock
std::filesystem::path getCacheFileName(scoped_lock const &, PublicKey const &pubKey) const
Get the filename used for caching UNLs.
static constexpr std::size_t kMaxSupportedBlobs
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.
std::shared_lock< decltype(mutex_)> shared_lock
hash_set< PublicKey > trustedMasterKeys_
static std::string const kFilePrefix
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 forEachListed(std::function< void(PublicKey const &, bool)> func) const
Invokes the callback once for every listed validation public key.
bool trustedPublisher(PublicKey const &identity) const
Returns true if public key is a trusted publisher.
bool removePublisherList(scoped_lock const &, PublicKey const &publisherKey, PublisherStatus reason)
Stop trusting publisher's list of keys.
hash_set< PublicKey > trustedSigningKeys_
std::size_t calculateQuorum(std::size_t unlSize, std::size_t effectiveUnlSize, std::size_t seenSize)
Return quorum for trusted validator set.
ValidatorList(ManifestCache &validatorManifests, ManifestCache &publisherManifests, TimeKeeper &timeKeeper, std::string const &databasePath, beast::Journal j, std::optional< std::size_t > minimumQuorum=std::nullopt)
std::vector< std::string > loadLists()
Attempt to read previously stored list files.
hash_set< PublicKey > getTrustedMasterKeys() const
get the trusted master public keys
std::optional< PublicKey > localPubKey_
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...
std::atomic< std::size_t > quorum_
json::Value getJson() const
Return a JSON representation of the state of the validator list.
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.
void cacheValidatorFile(scoped_lock const &lock, PublicKey const &pubKey) const
Write a JSON UNL to a cache file.
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.
PublisherList localPublisherList_
TrustChanges updateTrusted(hash_set< NodeID > const &seenValidators, NetClock::time_point closeTime, NetworkOPs &ops, Overlay &overlay, HashRouter &hashRouter)
Update trusted nodes.
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.
void updatePublisherList(PublicKey const &pubKey, PublisherList const ¤t, std::vector< PublicKey > const &oldList, scoped_lock const &)
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::optional< PublicKey > localPublicKey() const
This function returns the local validator public key or a std::nullopt.
std::optional< PublicKey > getListedKey(PublicKey const &identity) const
Returns listed master public if public key is included on any lists.
hash_set< PublicKey > getNegativeUNL() const
get the master public keys of Negative UNL validators
std::optional< std::size_t > minimumQuorum_
ManifestCache & publisherManifests_
hash_map< PublicKey, std::size_t > keyListings_
std::size_t getListThreshold() const
get the validator list threshold
std::optional< TimeKeeper::time_point > expires() const
Return the time when the validator list will expire.
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,...
static void buildBlobInfos(std::map< std::size_t, ValidatorBlobInfo > &blobInfos, PublisherListCollection const &lists)
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)
ManifestCache & validatorManifests_
hash_set< PublicKey > negativeUNL_
std::size_t listThreshold_
void setNegativeUNL(hash_set< PublicKey > const &negUnl)
set the Negative UNL with validators' master public keys
static void broadcastBlobs(PublicKey const &publisherKey, PublisherListCollection const &lists, std::size_t maxSequence, uint256 const &hash, Overlay &overlay, HashRouter &hashRouter, beast::Journal j)
std::size_t count() const
Return the number of configured validator list sites.
std::optional< PublicKey > getTrustedKey(PublicKey const &identity) const
Returns master public key if public key is trusted.
std::filesystem::path const dataPath_
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 constexpr std::uint32_t kSupportedListVersions[]
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 o...
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.
hash_map< PublicKey, PublisherListCollection > publisherLists_
T emplace_back(T... args)
@ Array
array value (ordered list)
@ Object
object value (collection of name/value pairs).
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
constexpr std::size_t kMaximumMessageSize
std::string base64Decode(std::string_view data)
std::error_code make_error_code(xrpl::TokenCodecErrc e)
sha512_half_hasher::result_type sha512Half(Args const &... args)
Returns the SHA512-Half of a series of objects.
std::optional< AccountID > parseBase58(std::string const &s)
Parse AccountID from checked, base58 string.
std::string strHex(FwdIt begin, FwdIt end)
@ UnsupportedVersion
List version is not supported.
@ Expired
List is expired, but has the largest non-pending sequence seen so far.
@ SameSequence
Same sequence as current list.
@ KnownSequence
Future sequence already seen.
@ Pending
List will be valid in the future.
@ Invalid
Invalid format or signature.
@ Untrusted
List signed by untrusted publisher key.
@ Stale
Trusted publisher key, but seq is too old.
bool verify(PublicKey const &publicKey, Slice const &m, Slice const &sig) noexcept
Verify a signature on a message.
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
std::size_t splitMessage(std::vector< ValidatorList::MessageWithHash > &messages, protocol::TMValidatorListCollection const &largeMsg, std::size_t maxSize, std::size_t begin=0, std::size_t end=0)
std::unordered_set< Value, Hash, Pred, Allocator > hash_set
constexpr std::size_t kMaxManifestBase64
Largest a valid manifest can be, in base64 characters.
std::size_t buildValidatorListMessage(std::vector< ValidatorList::MessageWithHash > &messages, std::uint64_t peerSequence, std::uint32_t rawVersion, std::string const &rawManifest, std::map< std::size_t, ValidatorBlobInfo > const &blobInfos, std::size_t maxSize)
std::string to_string(BaseUInt< Bits, Tag > const &a)
std::size_t splitMessageParts(std::vector< ValidatorList::MessageWithHash > &messages, protocol::TMValidatorListCollection const &largeMsg, std::size_t maxSize, std::size_t begin, std::size_t end)
std::optional< KeyType > publicKeyType(Slice const &slice)
Returns the type of public key.
std::optional< Manifest > deserializeManifest(Slice s, beast::Journal journal)
Constructs Manifest from serialized string.
@ Uncapped
Bypasses the cap (listed/trusted or config manifests).
Slice makeSlice(std::array< T, N > const &a)
std::optional< Blob > strUnHex(std::size_t strSize, Iterator begin, Iterator end)
NodeID calcNodeID(PublicKey const &)
Calculate the 160-bit node ID from a node public key.
void writeFileContents(std::error_code &ec, std::filesystem::path const &destPath, std::string const &contents)
@ Accepted
Manifest is valid.
@ Invalid
Timely, but invalid signature.
static bool revoked(std::uint32_t sequence)
Returns true if manifest revokes master key.
PublicKey masterKey
The master key associated with this manifest.
std::optional< PublicKey > signingKey
The ephemeral key associated with this manifest.
Changes in trusted nodes after updating validator list.
hash_set< NodeID > removed
Used to represent the information stored in the blobs_v2 Json array.
std::optional< std::string > manifest
MessageWithHash()=default
std::shared_ptr< Message > message
std::map< std::size_t, PublisherList > remaining
Describes the result of processing a Validator List (UNL), including some of the information from the...
void mergeDispositions(PublisherListStats const &src)
PublisherListStats()=default
std::optional< PublicKey > publisherKey
ListDisposition worstDisposition() const
std::map< ListDisposition, std::size_t > dispositions
ListDisposition bestDisposition() const
std::vector< PublicKey > list
TimeKeeper::time_point validFrom
TimeKeeper::time_point validUntil
std::vector< std::string > manifests