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 const 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,
734 for (
auto const& [sequence, vl] : remaining)
736 blobInfos[sequence] = {
738 .signature = vl.rawSignature,
739 .manifest = vl.rawManifest,
778 "xrpl::ValidatorList::broadcastBlobs : valid sequence");
783 if (!toSkip->contains(peer->id()))
785 auto const peerSequence = peer->publisherListSequence(publisherKey).value_or(0);
786 if (peerSequence < maxSequence)
788 if (blobInfos.
empty())
798 messages2[peerSequence],
820 auto const result =
applyLists(manifest, version, blobs, std::move(siteUri), hash);
821 auto const disposition = result.bestDisposition();
857 *result.publisherKey,
859 *pubCollection.maxSequence,
885 for (
auto const& blobInfo : blobs)
901 stats.mergeDispositions(result);
902 result = std::move(stats);
917 auto& remaining = pubCollection.remaining;
918 auto const& current = pubCollection.current;
919 for (
auto iter = remaining.begin(); iter != remaining.end();)
923 next == remaining.end() || next->first > iter->first,
924 "xrpl::ValidatorList::applyLists : next is valid");
925 if (iter->first <= current.sequence ||
926 (next != remaining.end() && next->second.validFrom <= iter->second.validFrom))
928 iter = remaining.erase(iter);
938 pubCollection.fullHash =
sha512Half(pubCollection);
940 result.
sequence = *pubCollection.maxSequence;
957 auto iNew = publisherList.
begin();
958 auto iOld = oldList.
begin();
959 while (iNew != publisherList.
end() || iOld != oldList.
end())
961 if (iOld == oldList.
end() || (iNew != publisherList.
end() && *iNew < *iOld))
969 else if (iNew == publisherList.
end() || (iOld != oldList.
end() && *iOld < *iNew))
989 if (publisherList.
empty())
991 JLOG(
j_.warn()) <<
"No validator keys included in valid list";
994 for (
auto const& valManifest : manifests)
1000 JLOG(
j_.warn()) <<
"List for " <<
strHex(pubKey)
1001 <<
" contained untrusted validator manifest";
1009 JLOG(
j_.warn()) <<
"List for " <<
strHex(pubKey)
1010 <<
" contained invalid validator manifest";
1026 using namespace std::string_literals;
1029 auto const& manifest = localManifest ? *localManifest : globalManifest;
1036 JLOG(
j_.warn()) <<
"UNL manifest exceeds maximum size";
1042 JLOG(
j_.warn()) <<
"UNL manifest cannot be deserialized";
1046 auto [result, pubKeyOpt] =
verify(lock, list, std::move(*m), blob, signature);
1050 JLOG(
j_.warn()) <<
"UNL manifest is signed with an unrecognized master public key";
1061 UNREACHABLE(
"xrpl::ValidatorList::applyList : invalid public key type");
1072 if (pubCollection.maxSequence &&
1079 result, pubKey, pubCollection.status, *pubCollection.maxSequence};
1087 auto const sequence = list[jss::sequence].
asUInt();
1088 auto const accepted =
1096 pubCollection.rawManifest = globalManifest;
1097 if (!pubCollection.maxSequence || sequence > *pubCollection.maxSequence)
1098 pubCollection.maxSequence = sequence;
1100 json::Value const& newList = list[jss::validators];
1102 if (accepted && pubCollection.remaining.contains(sequence))
1109 auto& publisher = pubCollection.current;
1111 oldList = std::move(pubCollection.current.list);
1113 publisher = std::move(pubCollection.remaining[sequence]);
1115 pubCollection.remaining.erase(sequence);
1118 publisher.sequence == sequence,
1119 "xrpl::ValidatorList::applyList : publisher sequence match");
1123 auto& publisher = accepted ? pubCollection.current : pubCollection.remaining[sequence];
1124 publisher.sequence = sequence;
1126 list.
isMember(jss::effective) ? list[jss::effective].
asUInt() : 0}};
1127 publisher.validUntil =
1129 publisher.siteUri = std::move(siteUri);
1130 publisher.rawBlob = blob;
1131 publisher.rawSignature = signature;
1132 publisher.rawManifest = localManifest;
1134 publisher.hash = *hash;
1140 oldList = std::move(publisherList);
1142 publisherList.
clear();
1144 for (
auto const& val : newList)
1146 if (val.isObject() && val.isMember(jss::validation_public_key) &&
1147 val[jss::validation_public_key].isString())
1150 strUnHex(val[jss::validation_public_key].asString());
1155 <<
"Invalid node identity: " << val[jss::validation_public_key].asString();
1162 if (val.isMember(jss::manifest) && val[jss::manifest].isString())
1163 manifests.
push_back(val[jss::manifest].asString());
1172 pubCollection.rawVersion =
std::max(pubCollection.rawVersion, version);
1173 if (!pubCollection.remaining.empty())
1177 pubCollection.rawVersion =
std::max(pubCollection.rawVersion, 2u);
1181 result, pubKey, pubCollection.status, *pubCollection.maxSequence};
1194 using namespace std::string_literals;
1210 auto const fullPath{
canonical(filename, ec)};
1215 if (!ec && (
size == 0u))
1227 return fullPath.root_path() ==
"/"s ?
"file://" :
"file:///";
1257 auto const revoked = manifest.
revoked();
1276 auto const sig =
strUnHex(signature);
1285 if (
list.isMember(jss::sequence) &&
list[jss::sequence].isInt() &&
1286 list.isMember(jss::expiration) &&
list[jss::expiration].isInt() &&
1287 (!
list.isMember(jss::effective) ||
list[jss::effective].isInt()) &&
1288 list.isMember(jss::validators) &&
list[jss::validators].isArray())
1290 auto const sequence =
list[jss::sequence].asUInt();
1292 list.isMember(jss::effective) ?
list[jss::effective].asUInt() : 0}};
1293 auto const validUntil =
1297 if (validUntil <= validFrom)
1301 if (sequence < listCollection.current.sequence)
1305 if (sequence == listCollection.current.sequence)
1309 if (validUntil <= now)
1313 if (validFrom > now)
1325 return !listCollection.maxSequence || sequence > *listCollection.maxSequence ||
1326 (!listCollection.remaining.contains(sequence) &&
1327 validFrom < listCollection.remaining.at(*listCollection.maxSequence).validFrom)
1371 return std::nullopt;
1380 return std::nullopt;
1414 "xrpl::ValidatorList::removePublisherList : valid reason input");
1419 JLOG(
j_.debug()) <<
"Removing validator list for publisher " <<
strHex(publisherKey);
1421 for (
auto const& val : iList->second.current.list)
1427 if (iVal->second <= 1)
1437 iList->second.current.list.clear();
1438 iList->second.status = reason;
1453 return count(readLock);
1463 auto const& current = collection.current;
1466 return std::nullopt;
1472 auto chainedExpiration = current.validUntil;
1473 for (
auto const& [sequence, check] : collection.remaining)
1476 if (check.validFrom <= chainedExpiration)
1478 chainedExpiration = check.validUntil;
1487 if (!res || chainedExpiration < *res)
1489 res = chainedExpiration;
1497 auto const& current = collection;
1498 auto const chainedExpiration = current.
validUntil;
1501 if (!res || chainedExpiration < *res)
1503 res = chainedExpiration;
1530 if (
auto when =
expires(readLock))
1532 if (*when == TimeKeeper::time_point::max())
1534 x[jss::expiration] =
"never";
1535 x[jss::status] =
"active";
1543 x[jss::status] =
"active";
1547 x[jss::status] =
"expired";
1553 x[jss::status] =
"unknown";
1554 x[jss::expiration] =
"unknown";
1571 curr[jss::pubkey_publisher] =
strHex(publicKey);
1575 target[jss::uri] = publisherList.
siteUri;
1584 for (
auto const& key : publisherList.
list)
1590 auto const& current = pubCollection.current;
1591 appendList(current, curr);
1594 curr[jss::version] = pubCollection.rawVersion;
1599 for (
auto const& [sequence,
future] : pubCollection.remaining)
1601 using namespace std::chrono_literals;
1609 "xrpl::ValidatorList::getJson : minimum valid from");
1611 if (remaining.
size() != 0u)
1612 curr[jss::remaining] = std::move(remaining);
1652 func(v.first,
trusted(readLock, v.first));
1672 plCollection.maxSequence.value_or(0) != 0,
1673 "xrpl::ValidatorList::for_each_available : nonzero maxSequence");
1675 plCollection.rawManifest,
1676 plCollection.rawVersion,
1679 plCollection.maxSequence.value_or(0),
1680 plCollection.fullHash);
1691 auto const keyBlob =
strUnHex(pubKey);
1695 JLOG(
j_.warn()) <<
"Invalid requested validator list publisher key: " << pubKey;
1721 JLOG(
j_.warn()) <<
"Using potentially unsafe quorum of " << *
minimumQuorum_
1722 <<
" as specified on the command line";
1756 auto const errorThreshold =
std::min(
1760 errorThreshold > 0,
"xrpl::ValidatorList::calculateQuorum : nonzero error threshold");
1761 if (unavailable >= errorThreshold)
1811 using namespace std::chrono_literals;
1825 auto& remaining = collection.remaining;
1826 auto const firstIter = remaining.begin();
1827 auto iter = firstIter;
1828 if (iter != remaining.end() && iter->second.validFrom <= closeTime)
1832 next != remaining.end() &&
next->second.validFrom <= closeTime;
1837 "xrpl::ValidatorList::updateTrusted : sequential "
1841 iter != remaining.end(),
1842 "xrpl::ValidatorList::updateTrusted : non-end of "
1846 auto const sequence = iter->first;
1847 auto& candidate = iter->second;
1848 auto& current = collection.current;
1850 candidate.validFrom <= closeTime,
1851 "xrpl::ValidatorList::updateTrusted : maximum time");
1853 auto const oldList = current.list;
1854 current = std::move(candidate);
1858 current.sequence == sequence,
1859 "xrpl::ValidatorList::updateTrusted : sequence match");
1863 if (current.validUntil <= closeTime)
1864 current.list.clear();
1873 broadcastBlobs(pubKey, collection, sequence, current.hash, overlay, hashRouter,
j_);
1876 remaining.erase(firstIter,
std::next(iter));
1883 collection.current.validUntil <= closeTime)
1911 "xrpl::ValidatorList::updateTrusted : count meets threshold");
1925 if (!trustChanges.
added.empty() || !trustChanges.
removed.empty())
1934 XRPL_ASSERT(signingKey,
"xrpl::ValidatorList::updateTrusted : found signing key");
1941 <<
" listed validators eligible for inclusion in the trusted set";
1944 auto effectiveUnlSize = unlSize;
1945 auto seenSize = seenValidators.
size();
1958 for (
auto const& nid : seenValidators)
1966 JLOG(
j_.debug()) <<
"Using quorum of " <<
quorum_ <<
" for new set of " << unlSize
1967 <<
" trusted validators (" << trustChanges.
added.size() <<
" added, "
1968 << trustChanges.
removed.size() <<
" removed)";
1972 JLOG(
j_.warn()) <<
"New quorum of " <<
quorum_
1973 <<
" exceeds the number of trusted validators (" << unlSize <<
")";
1982 return trustChanges;
2017 auto ret = std::move(validations);
2025 [&](
auto const& v) ->
bool {
2026 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.
bool addSuppressionPeer(UInt256 const &key, PeerShortID peer)
std::optional< std::set< PeerShortID > > shouldRelay(UInt256 const &key)
Determines whether the hashed item should be relayed.
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
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)
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, ScopedLock const &)
Apply published list of public keys.
HashSet< PublicKey > negativeUNL_
static constexpr std::size_t kMaxSupportedBlobs
void updatePublisherList(PublicKey const &pubKey, PublisherList const ¤t, std::vector< PublicKey > const &oldList, ScopedLock const &)
static std::string const kFilePrefix
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.
static void broadcastBlobs(PublicKey const &publisherKey, PublisherListCollection const &lists, std::size_t maxSequence, UInt256 const &hash, Overlay &overlay, HashRouter &hashRouter, beast::Journal j)
bool trustedPublisher(PublicKey const &identity) const
Returns true if public key is a trusted publisher.
HashMap< PublicKey, std::size_t > keyListings_
std::size_t calculateQuorum(std::size_t unlSize, std::size_t effectiveUnlSize, std::size_t seenSize)
Return quorum for trusted validator set.
std::shared_lock< decltype(mutex_)> SharedLock
std::filesystem::path getCacheFileName(ScopedLock const &, PublicKey const &pubKey) const
Get the filename used for caching UNLs.
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.
TrustChanges updateTrusted(HashSet< NodeID > const &seenValidators, NetClock::time_point closeTime, NetworkOPs &ops, Overlay &overlay, HashRouter &hashRouter)
Update trusted nodes.
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.
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< 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.
HashSet< PublicKey > trustedMasterKeys_
PublisherList localPublisherList_
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.
std::pair< ListDisposition, std::optional< PublicKey > > verify(ScopedLock const &, json::Value &list, Manifest manifest, std::string const &blob, std::string const &signature)
Check response for trusted valid published list.
std::optional< PublicKey > localPublicKey() const
This function returns the local validator public key or a std::nullopt.
void setNegativeUNL(HashSet< PublicKey > const &negUnl)
set the Negative UNL with validators' master public keys
std::optional< PublicKey > getListedKey(PublicKey const &identity) const
Returns listed master public if public key is included on any lists.
void cacheValidatorFile(ScopedLock const &lock, PublicKey const &pubKey) const
Write a JSON UNL to a cache file.
std::optional< std::size_t > minimumQuorum_
ManifestCache & publisherManifests_
HashSet< PublicKey > getTrustedMasterKeys() const
get the trusted master public keys
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,...
HashMap< PublicKey, PublisherListCollection > publisherLists_
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_
bool removePublisherList(ScopedLock const &, PublicKey const &publisherKey, PublisherStatus reason)
Stop trusting publisher's list of 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 o...
std::size_t listThreshold_
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.
HashSet< PublicKey > getNegativeUNL() const
get the master public keys of Negative UNL validators
static constexpr std::uint32_t kSupportedListVersions[]
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::scoped_lock< decltype(mutex_)> ScopedLock
HashSet< PublicKey > trustedSigningKeys_
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)
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)
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.
std::unordered_set< Value, Hash, Pred, Allocator > HashSet
void writeFileContents(std::error_code &ec, std::filesystem::path const &destPath, std::string const &contents)
Sha512HalfHasher::result_type sha512Half(Args const &... args)
Returns the SHA512-Half of a series of objects.
@ 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.
HashSet< 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