20#include <xrpld/app/misc/HashRouter.h>
21#include <xrpld/app/misc/NetworkOPs.h>
22#include <xrpld/app/misc/ValidatorList.h>
23#include <xrpld/overlay/Overlay.h>
24#include <xrpl/basics/FileUtilities.h>
25#include <xrpl/basics/Slice.h>
26#include <xrpl/basics/StringUtilities.h>
27#include <xrpl/basics/base64.h>
28#include <xrpl/json/json_reader.h>
29#include <xrpl/protocol/PublicKey.h>
30#include <xrpl/protocol/STValidation.h>
31#include <xrpl/protocol/digest.h>
32#include <xrpl/protocol/jss.h>
33#include <xrpl/protocol/messages.h>
34#include <boost/regex.hpp>
52 return "same_sequence";
56 return "known_sequence";
58 return "unsupported_version";
79 : publisherKey(key), status(stat), sequence(seq)
88 : dispositions.begin()->first;
95 : dispositions.rbegin()->first;
104 dispositions[disp] +=
count;
112 : message(message_), hash(hash_), numVLs(num_)
130 ,
quorum_(minimumQuorum.value_or(1))
141 static boost::regex
const re(
156 <<
"Loading configured trusted validator list publisher keys";
159 for (
auto key : publisherKeys)
161 JLOG(
j_.
trace()) <<
"Processing '" << key <<
"'";
167 JLOG(
j_.
error()) <<
"Invalid validator list publisher key: " << key;
177 <<
"Configured validator list publisher key is revoked: "
185 <<
"Duplicate validator list publisher key: " << key;
202 JLOG(
j_.
debug()) <<
"Loading configured validator keys";
205 for (
auto const& n : configKeys)
207 JLOG(
j_.
trace()) <<
"Processing '" << n <<
"'";
211 if (!boost::regex_match(n,
match, re))
213 JLOG(
j_.
error()) <<
"Malformed entry: '" << n <<
"'";
222 JLOG(
j_.
error()) <<
"Invalid node identity: " <<
match[1];
233 JLOG(
j_.
warn()) <<
"Duplicate node identity: " <<
match[1];
251boost::filesystem::path
281 "ripple::ValidatorList::buildFileData : valid publisher list input");
282 auto const effectiveVersion =
283 forceVersion ? *forceVersion : pubCollection.
rawVersion;
286 value[jss::version] = effectiveVersion;
287 value[jss::public_key] = pubKey;
289 switch (effectiveVersion)
293 value[jss::blob] =
current.rawBlob;
294 value[jss::signature] =
current.rawSignature;
299 value[jss::manifest] = *
current.rawManifest;
305 auto add = [&blobs, &outerManifest = pubCollection.
rawManifest](
308 blob[jss::blob] = pubList.rawBlob;
309 blob[jss::signature] = pubList.rawSignature;
310 if (pubList.rawManifest &&
311 *pubList.rawManifest != outerManifest)
312 blob[jss::manifest] = *pubList.rawManifest;
322 value[jss::blobs_v2] = std::move(blobs);
327 <<
"Invalid VL version provided: " << effectiveVersion;
344 boost::system::error_code ec;
352 value[jss::refresh_interval] = 24 * 60;
359 JLOG(
j_.
error()) <<
"Problem writing " << filename <<
" " << ec.value()
360 <<
": " << ec.message();
383 "ripple::ValidatorList::parseBlobs : single element result");
392 if (!body.
isMember(jss::blobs_v2) ||
393 !body[jss::blobs_v2].
isArray() ||
398 auto const& blobs = body[jss::blobs_v2];
400 for (
auto const& blobInfo : blobs)
402 if (!blobInfo.isObject() ||
403 !blobInfo.isMember(jss::signature) ||
404 !blobInfo[jss::signature].isString() ||
405 !blobInfo.isMember(jss::blob) ||
406 !blobInfo[jss::blob].isString())
409 info.
blob = blobInfo[jss::blob].asString();
410 info.
signature = blobInfo[jss::signature].asString();
411 if (blobInfo.isMember(jss::manifest))
413 if (!blobInfo[jss::manifest].isString())
415 info.
manifest = blobInfo[jss::manifest].asString();
419 result.
size() == blobs.size(),
420 "ripple::ValidatorList::parseBlobs(version, Jason::Value) : "
421 "result size matches");
431 return {{body.blob(), body.signature(), {}}};
441 result.
reserve(body.blobs_size());
442 for (
auto const& blob : body.blobs())
445 info.
blob = blob.blob();
447 if (blob.has_manifest())
453 result.
size() == body.blobs_size(),
454 "ripple::ValidatorList::parseBlobs(TMValidatorList) : result size "
462 protocol::TMValidatorListCollection
const& largeMsg,
470 protocol::TMValidatorListCollection
const& largeMsg,
475 if (begin == 0 && end == 0)
476 end = largeMsg.blobs_size();
477 XRPL_ASSERT(begin < end,
"ripple::splitMessage : valid inputs");
481 auto mid = (begin + end) / 2;
491 protocol::TMValidatorListCollection
const& largeMsg,
498 if (end - begin == 1)
500 protocol::TMValidatorList smallMsg;
501 smallMsg.set_version(1);
502 smallMsg.set_manifest(largeMsg.manifest());
504 auto const& blob = largeMsg.blobs(begin);
505 smallMsg.set_blob(blob.blob());
506 smallMsg.set_signature(blob.signature());
508 if (blob.has_manifest())
509 smallMsg.set_manifest(blob.manifest());
513 "ripple::splitMessageParts : maximum message size");
516 std::make_shared<Message>(smallMsg, protocol::mtVALIDATORLIST),
519 return messages.
back().numVLs;
525 smallMsg->set_version(largeMsg.version());
526 smallMsg->set_manifest(largeMsg.manifest());
530 *smallMsg->add_blobs() = largeMsg.blobs(i);
537 return splitMessage(messages, largeMsg, maxSize, begin, end);
542 std::make_shared<Message>(
543 *smallMsg, protocol::mtVALIDATORLISTCOLLECTION),
545 smallMsg->blobs_size());
546 return messages.
back().numVLs;
563 "ripple::buildValidatorListMessage(ValidatorBlobInfo) : empty messages "
565 protocol::TMValidatorList msg;
568 auto const version = 1;
570 msg.set_blob(currentBlob.
blob);
571 msg.set_signature(currentBlob.
signature);
573 msg.set_version(version);
577 "ripple::buildValidatorListMessage(ValidatorBlobInfo) : maximum "
580 std::make_shared<Message>(msg, protocol::mtVALIDATORLIST),
599 "ripple::buildValidatorListMessage(std::map<std::size_t, "
600 "ValidatorBlobInfo>) : empty messages input");
601 protocol::TMValidatorListCollection msg;
602 auto const version = rawVersion < 2 ? 2 : rawVersion;
603 msg.set_version(version);
604 msg.set_manifest(rawManifest);
606 for (
auto const& [sequence, blobInfo] : blobInfos)
608 if (sequence <= peerSequence)
610 protocol::ValidatorBlobInfo& blob = *msg.add_blobs();
611 blob.set_blob(blobInfo.blob);
612 blob.set_signature(blobInfo.signature);
613 if (blobInfo.manifest)
614 blob.set_manifest(*blobInfo.manifest);
617 msg.blobs_size() > 0,
618 "ripple::buildValidatorListMessage(std::map<std::size_t, "
619 "ValidatorBlobInfo>) : minimum message blobs");
628 std::make_shared<Message>(msg, protocol::mtVALIDATORLISTCOLLECTION),
631 return messages.
back().numVLs;
650 "ripple::ValidatorList::buildValidatorListMessages : empty messages "
652 auto const& [currentSeq, currentBlob] = *blobInfos.
begin();
658 return total + m.numVLs;
660 if (messageVersion == 2 && peerSequence < maxSequence)
663 if (messages.
empty())
672 if (messages.
empty())
679 return {maxSequence, numVLs};
681 else if (messageVersion == 1 && peerSequence < currentSeq)
684 if (messages.
empty())
689 currentBlob.manifest ? *currentBlob.manifest : rawManifest,
692 if (messages.
empty())
699 return {currentSeq, numVLs};
736 "ripple::ValidatorList::sendValidatorList : non-empty messages "
742 for (
auto const& message : messages)
746 peer.
send(message.message);
754 sent || messages.size() == 1,
755 "ripple::ValidatorList::sendValidatorList : sent or one message");
758 if (messageVersion > 1)
760 <<
"Sent " << messages.size()
761 <<
" validator list collection(s) containing " << numVLs
762 <<
" validator list(s) for " <<
strHex(publisherKey)
763 <<
" with sequence range " << peerSequence <<
", "
764 << newPeerSequence <<
" to "
771 "ripple::ValidatorList::sendValidatorList : one validator "
774 <<
"Sent validator list for " <<
strHex(publisherKey)
775 <<
" with sequence " << newPeerSequence <<
" to "
818 blobInfos[
current.sequence] = {
820 for (
auto const& [sequence, vl] : remaining)
822 blobInfos[sequence] = {vl.rawBlob, vl.rawSignature, vl.rawManifest};
870 "ripple::ValidatorList::broadcastBlobs : valid sequence");
875 if (toSkip->count(peer->id()) == 0)
877 auto const peerSequence =
878 peer->publisherListSequence(publisherKey).value_or(0);
879 if (peerSequence < maxSequence)
881 if (blobInfos.
empty())
883 auto const v2 = peer->supportsFeature(
893 v2 ? messages2[peerSequence] : messages1,
918 auto const disposition = result.bestDisposition();
945 result.publisherKey &&
951 *result.publisherKey,
953 *pubCollection.maxSequence,
980 for (
auto const& blobInfo : blobs)
996 stats.mergeDispositions(result);
997 result = std::move(stats);
1009 auto& remaining = pubCollection.remaining;
1010 auto const&
current = pubCollection.current;
1011 for (
auto iter = remaining.begin(); iter != remaining.end();)
1015 next == remaining.end() || next->first > iter->first,
1016 "ripple::ValidatorList::applyLists : next is valid");
1017 if (iter->first <=
current.sequence ||
1018 (next != remaining.end() &&
1019 next->second.validFrom <= iter->second.validFrom))
1021 iter = remaining.erase(iter);
1031 pubCollection.fullHash =
sha512Half(pubCollection);
1033 result.
sequence = *pubCollection.maxSequence;
1049 auto iNew = publisherList.
begin();
1050 auto iOld = oldList.
begin();
1051 while (iNew != publisherList.
end() || iOld != oldList.
end())
1053 if (iOld == oldList.
end() ||
1054 (iNew != publisherList.
end() && *iNew < *iOld))
1061 iNew == publisherList.
end() ||
1062 (iOld != oldList.
end() && *iOld < *iNew))
1078 if (publisherList.
empty())
1080 JLOG(
j_.
warn()) <<
"No validator keys included in valid list";
1083 for (
auto const& valManifest : manifests)
1090 <<
" contained untrusted validator manifest";
1098 <<
" contained invalid validator manifest";
1114 using namespace std::string_literals;
1117 auto const&
manifest = localManifest ? *localManifest : globalManifest;
1118 auto [result, pubKeyOpt] =
verify(lock, list,
manifest, blob, signature);
1122 JLOG(
j_.
info()) <<
"ValidatorList::applyList unable to retrieve the "
1123 "master public key from the verify function\n";
1129 JLOG(
j_.
info()) <<
"ValidatorList::applyList Invalid Public Key type"
1130 " retrieved from the verify function\n ";
1140 if (pubCollection.maxSequence &&
1149 pubCollection.status,
1150 *pubCollection.maxSequence};
1158 auto const sequence = list[jss::sequence].
asUInt();
1167 pubCollection.rawManifest = globalManifest;
1168 if (!pubCollection.maxSequence || sequence > *pubCollection.maxSequence)
1169 pubCollection.maxSequence = sequence;
1171 Json::Value const& newList = list[jss::validators];
1173 if (
accepted && pubCollection.remaining.count(sequence) != 0)
1180 auto& publisher = pubCollection.current;
1182 oldList = std::move(pubCollection.current.list);
1184 publisher = std::move(pubCollection.remaining[sequence]);
1186 pubCollection.remaining.erase(sequence);
1189 publisher.sequence == sequence,
1190 "ripple::ValidatorList::applyList : publisher sequence match");
1194 auto& publisher =
accepted ? pubCollection.current
1195 : pubCollection.remaining[sequence];
1196 publisher.sequence = sequence;
1198 list.
isMember(jss::effective) ? list[jss::effective].
asUInt() : 0}};
1201 publisher.siteUri = std::move(siteUri);
1202 publisher.rawBlob = blob;
1203 publisher.rawSignature = signature;
1204 publisher.rawManifest = localManifest;
1206 publisher.hash = *hash;
1212 oldList = std::move(publisherList);
1214 publisherList.
clear();
1216 for (
auto const& val : newList)
1218 if (val.isObject() && val.isMember(jss::validation_public_key) &&
1219 val[jss::validation_public_key].isString())
1222 strUnHex(val[jss::validation_public_key].asString());
1227 <<
"Invalid node identity: "
1228 << val[jss::validation_public_key].asString();
1236 if (val.isMember(jss::manifest) &&
1237 val[jss::manifest].isString())
1238 manifests.
push_back(val[jss::manifest].asString());
1247 pubCollection.rawVersion =
std::max(pubCollection.rawVersion, version);
1248 if (!pubCollection.remaining.empty())
1252 pubCollection.rawVersion =
std::max(pubCollection.rawVersion, 2u);
1256 result, pubKey, pubCollection.status, *pubCollection.maxSequence};
1269 using namespace std::string_literals;
1270 using namespace boost::filesystem;
1271 using namespace boost::system::errc;
1279 boost::system::error_code ec;
1286 auto const fullPath{
canonical(filename, ec)};
1290 auto size = file_size(fullPath, ec);
1303 return fullPath.root_path() ==
"/"s ?
"file://" :
"file:///";
1335 auto const revoked = m->revoked();
1351 auto const sig =
strUnHex(signature);
1357 if (!r.
parse(data, list))
1360 if (list.
isMember(jss::sequence) && list[jss::sequence].
isInt() &&
1361 list.
isMember(jss::expiration) && list[jss::expiration].
isInt() &&
1362 (!list.
isMember(jss::effective) || list[jss::effective].
isInt()) &&
1365 auto const sequence = list[jss::sequence].
asUInt();
1367 list.
isMember(jss::effective) ? list[jss::effective].
asUInt() : 0}};
1372 if (validUntil <= validFrom)
1374 else if (sequence < listCollection.current.sequence)
1376 else if (sequence == listCollection.current.sequence)
1378 else if (validUntil <= now)
1380 else if (validFrom > now)
1391 return !listCollection.maxSequence ||
1392 sequence > *listCollection.maxSequence ||
1393 (listCollection.remaining.count(sequence) == 0 &&
1394 validFrom < listCollection.remaining
1395 .at(*listCollection.maxSequence)
1430 return trusted(read_lock, identity);
1441 return std::nullopt;
1452 return std::nullopt;
1487 "ripple::ValidatorList::removePublisherList : valid reason input");
1492 JLOG(
j_.
debug()) <<
"Removing validator list for publisher "
1495 for (
auto const& val : iList->second.current.list)
1501 if (iVal->second <= 1)
1507 iList->second.current.list.clear();
1508 iList->second.status = reason;
1523 return count(read_lock);
1533 auto const&
current = collection.current;
1536 return std::nullopt;
1542 auto chainedExpiration =
current.validUntil;
1543 for (
auto const& [sequence, check] : collection.remaining)
1546 if (check.validFrom <= chainedExpiration)
1547 chainedExpiration = check.validUntil;
1553 if (!res || chainedExpiration < *res)
1555 res = chainedExpiration;
1563 auto const&
current = collection;
1564 auto chainedExpiration =
current.validUntil;
1567 if (!res || chainedExpiration < *res)
1569 res = chainedExpiration;
1596 if (
auto when =
expires(read_lock))
1598 if (*when == TimeKeeper::time_point::max())
1600 x[jss::expiration] =
"never";
1601 x[jss::status] =
"active";
1608 x[jss::status] =
"active";
1610 x[jss::status] =
"expired";
1615 x[jss::status] =
"unknown";
1616 x[jss::expiration] =
"unknown";
1633 curr[jss::pubkey_publisher] =
strHex(publicKey);
1634 curr[jss::available] =
1639 target[jss::uri] = publisherList.
siteUri;
1649 for (
auto const& key : publisherList.
list)
1655 auto const&
current = pubCollection.current;
1659 curr[jss::version] = pubCollection.rawVersion;
1664 for (
auto const& [sequence, future] : pubCollection.remaining)
1666 using namespace std::chrono_literals;
1670 appendList(future, r);
1674 "ripple::ValidatorList::getJson : minimum valid from");
1676 if (remaining.
size())
1677 curr[jss::remaining] = std::move(remaining);
1683 for (
auto const& k : trustedMasterKeys_)
1690 validatorManifests_.for_each_manifest([&jSigningKeys,
1692 auto it = keyListings_.find(
manifest.masterKey);
1693 if (it != keyListings_.end() &&
manifest.signingKey)
1701 if (!negativeUNL_.empty())
1704 for (
auto const& k : negativeUNL_)
1714ValidatorList::for_each_listed(
1719 for (
auto const& v : keyListings_)
1720 func(v.first, trusted(read_lock, v.first));
1724ValidatorList::for_each_available(
1731 uint256 const& hash)> func)
const
1735 for (
auto const& [key, plCollection] : publisherLists_)
1737 if (plCollection.status != PublisherStatus::available)
1740 plCollection.maxSequence != 0,
1741 "ripple::ValidatorList::for_each_available : nonzero maxSequence");
1743 plCollection.rawManifest,
1744 plCollection.rawVersion,
1745 buildBlobInfos(plCollection),
1747 plCollection.maxSequence.value_or(0),
1748 plCollection.fullHash);
1753ValidatorList::getAvailable(
1763 JLOG(j_.
info()) <<
"Invalid requested validator list publisher key: "
1770 auto const iter = publisherLists_.find(
id);
1772 if (iter == publisherLists_.end() ||
1773 iter->second.status != PublisherStatus::available)
1777 buildFileData(
std::string{pubKey}, iter->second, forceVersion, j_);
1783ValidatorList::calculateQuorum(
1789 if (minimumQuorum_ > 0)
1791 JLOG(j_.
warn()) <<
"Using potentially unsafe quorum of "
1793 <<
" as specified on the command line";
1794 return *minimumQuorum_;
1799 for (
auto const& list : publisherLists_)
1801 if (list.second.status != PublisherStatus::available)
1844ValidatorList::updateTrusted(
1851 using namespace std::chrono_literals;
1852 if (timeKeeper_.now() > closeTime + 30s)
1853 closeTime = timeKeeper_.now();
1862 for (
auto& [pubKey, collection] : publisherLists_)
1865 auto& remaining = collection.remaining;
1866 auto const firstIter = remaining.begin();
1867 auto iter = firstIter;
1868 if (iter != remaining.end() && iter->second.validFrom <= closeTime)
1871 for (
auto next =
std::next(iter); next != remaining.end() &&
1872 next->second.validFrom <= closeTime;
1877 "ripple::ValidatorList::updateTrusted : sequential "
1881 iter != remaining.end(),
1882 "ripple::ValidatorList::updateTrusted : non-end of "
1886 auto sequence = iter->first;
1887 auto& candidate = iter->second;
1888 auto&
current = collection.current;
1890 candidate.validFrom <= closeTime,
1891 "ripple::ValidatorList::updateTrusted : maximum time");
1893 auto const oldList =
current.list;
1894 current = std::move(candidate);
1895 if (collection.status != PublisherStatus::available)
1896 collection.status = PublisherStatus::available;
1899 "ripple::ValidatorList::updateTrusted : sequence match");
1903 if (
current.validUntil <= closeTime)
1906 updatePublisherList(pubKey,
current, oldList, lock);
1923 remaining.erase(firstIter,
std::next(iter));
1929 if (collection.status == PublisherStatus::available &&
1930 collection.current.validUntil <= closeTime)
1932 removePublisherList(lock, pubKey, PublisherStatus::expired);
1935 if (collection.status != PublisherStatus::available)
1943 auto it = trustedMasterKeys_.cbegin();
1944 while (it != trustedMasterKeys_.cend())
1946 if (!keyListings_.count(*it) || validatorManifests_.revoked(*it))
1949 it = trustedMasterKeys_.erase(it);
1957 for (
auto const& val : keyListings_)
1959 if (!validatorManifests_.revoked(val.first) &&
1960 trustedMasterKeys_.emplace(val.first).second)
1966 if (!trustChanges.
added.empty() || !trustChanges.
removed.empty())
1968 trustedSigningKeys_.clear();
1972 for (
auto const& k : trustedMasterKeys_)
1975 validatorManifests_.getSigningKey(k);
1978 "ripple::ValidatorList::updateTrusted : found signing key");
1979 trustedSigningKeys_.insert(*signingKey);
1984 << trustedMasterKeys_.size() <<
" of " << keyListings_.size()
1985 <<
" listed validators eligible for inclusion in the trusted set";
1987 auto const unlSize = trustedMasterKeys_.size();
1988 auto effectiveUnlSize = unlSize;
1989 auto seenSize = seenValidators.
size();
1990 if (!negativeUNL_.empty())
1992 for (
auto const& k : trustedMasterKeys_)
1994 if (negativeUNL_.count(k))
1998 for (
auto const& k : negativeUNL_)
2002 for (
auto const& nid : seenValidators)
2004 if (negUnlNodeIDs.
count(nid))
2008 quorum_ = calculateQuorum(unlSize, effectiveUnlSize, seenSize);
2010 JLOG(j_.
debug()) <<
"Using quorum of " << quorum_ <<
" for new set of "
2011 << unlSize <<
" trusted validators ("
2012 << trustChanges.
added.size() <<
" added, "
2013 << trustChanges.
removed.size() <<
" removed)";
2015 if (unlSize < quorum_)
2017 JLOG(j_.
warn()) <<
"New quorum of " << quorum_
2018 <<
" exceeds the number of trusted validators ("
2022 if ((publisherLists_.size() || localPublisherList.list.size()) &&
2029 return trustChanges;
2033ValidatorList::getTrustedMasterKeys()
const
2036 return trustedMasterKeys_;
2040ValidatorList::getNegativeUNL()
const
2043 return negativeUNL_;
2050 negativeUNL_ = negUnl;
2054ValidatorList::negativeUNLFilter(
2058 auto ret = std::move(validations);
2061 if (!negativeUNL_.empty())
2067 [&](
auto const& v) ->
bool {
2068 if (auto const masterKey =
2069 getTrustedKey(read_lock, v->getSignerPublic());
2072 return negativeUNL_.count(*masterKey);
Unserialize a JSON document into a Value.
bool parse(std::string const &document, Value &root)
Read a Value from a JSON document.
UInt size() const
Number of values in array or object.
std::string toStyledString() const
Value & append(const Value &value)
Append value to array at the end.
std::string asString() const
Returns the unquoted string value.
bool isMember(const char *key) const
Return true if the object has a member named key.
std::string to_string() const
Returns a string representing the endpoint.
A generic endpoint for log messages.
Stream trace() const
Severity stream access functions.
typename Clock::time_point time_point
typename Clock::duration duration
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.
std::optional< PublicKey > getSigningKey(PublicKey const &pk) const
Returns master key's current signing key.
bool revoked(PublicKey const &pk) const
Returns true if master key has been revoked in a manifest.
ManifestDisposition applyManifest(Manifest m)
Add manifest to cache.
PublicKey getMasterKey(PublicKey const &pk) const
Returns ephemeral signing key's master public key.
static std::size_t totalSize(::google::protobuf::Message const &message)
Provides server functionality for clients.
virtual void setUNLBlocked()=0
virtual void clearUNLBlocked()=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 bool supportsFeature(ProtocolFeature f) const =0
virtual beast::IP::Endpoint getRemoteAddress() const =0
virtual void send(std::shared_ptr< Message > const &m)=0
virtual void setPublisherListSequence(PublicKey const &, std::size_t const)=0
virtual id_t id() const =0
std::size_t size() const noexcept
An immutable linear range of bytes.
Manages various times used by the server.
time_point now() const override
Returns the current time, using the server's clock.
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.
bool load(std::optional< PublicKey > const &localSigningKey, std::vector< std::string > const &configKeys, std::vector< std::string > const &publisherKeys)
Load configured trusted keys.
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 void broadcastBlobs(PublicKey const &publisherKey, PublisherListCollection const &lists, std::size_t maxSequence, uint256 const &hash, Overlay &overlay, HashRouter &hashRouter, beast::Journal j)
boost::filesystem::path getCacheFileName(lock_guard const &, PublicKey const &pubKey) const
Get the filename used for caching UNLs.
std::vector< std::string > loadLists()
PublisherList localPublisherList
std::optional< PublicKey > localPublicKey() const
This function returns the local validator public key or a std::nullopt.
ManifestCache & validatorManifests_
std::atomic< std::size_t > quorum_
void updatePublisherList(PublicKey const &pubKey, PublisherList const ¤t, std::vector< PublicKey > const &oldList, lock_guard const &)
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)
hash_map< PublicKey, std::size_t > keyListings_
bool listed(PublicKey const &identity) const
Returns true if public key is included on any lists.
void cacheValidatorFile(lock_guard const &lock, PublicKey const &pubKey) const
Write a JSON UNL to a cache file.
hash_set< PublicKey > trustedMasterKeys_
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.
Json::Value getJson() const
Return a JSON representation of the state of the validator list.
std::optional< TimeKeeper::time_point > expires() const
Return the time when the validator list will expire.
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 trustedPublisher(PublicKey const &identity) const
Returns true if public key is a trusted publisher.
std::optional< PublicKey > getListedKey(PublicKey const &identity) const
Returns listed master public if public key is included on any lists.
boost::filesystem::path const dataPath_
boost::shared_mutex mutex_
bool removePublisherList(lock_guard const &, PublicKey const &publisherKey, PublisherStatus reason)
Stop trusting publisher's list of keys.
bool trusted(PublicKey const &identity) const
Returns true if public key is trusted.
static constexpr std::size_t maxSupportedBlobs
ValidatorList(ManifestCache &validatorManifests, ManifestCache &publisherManifests, TimeKeeper &timeKeeper, std::string const &databasePath, beast::Journal j, std::optional< std::size_t > minimumQuorum=std::nullopt)
std::pair< ListDisposition, std::optional< PublicKey > > verify(lock_guard const &, Json::Value &list, std::string const &manifest, std::string const &blob, std::string const &signature)
Check response for trusted valid published list.
std::optional< PublicKey > localPubKey_
std::optional< std::size_t > minimumQuorum_
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...
hash_map< PublicKey, PublisherListCollection > publisherLists_
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.
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)
static const std::string filePrefix_
ManifestCache & publisherManifests_
static constexpr std::uint32_t supportedListVersions[]
T emplace_back(T... args)
@ arrayValue
array value (ordered list)
@ objectValue
object value (collection of name/value pairs).
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
std::optional< Manifest > deserializeManifest(Slice s, beast::Journal journal)
Constructs Manifest from serialized string.
std::optional< Blob > strUnHex(std::size_t strSize, Iterator begin, Iterator end)
bool verify(PublicKey const &publicKey, Slice const &m, Slice const &sig, bool mustBeFullyCanonical=true) noexcept
Verify a signature on a message.
@ ValidatorListPropagation
@ ValidatorList2Propagation
std::string base64_decode(std::string_view data)
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::size_t splitMessageParts(std::vector< ValidatorList::MessageWithHash > &messages, protocol::TMValidatorListCollection const &largeMsg, std::size_t maxSize, std::size_t begin, std::size_t end)
@ current
This was a new validation and was added.
@ unsupported_version
List version is not supported.
@ stale
Trusted publisher key, but seq is too old.
@ untrusted
List signed by untrusted publisher key.
@ same_sequence
Same sequence as current list.
@ pending
List will be valid in the future.
@ known_sequence
Future sequence already seen.
@ expired
List is expired, but has the largest non-pending sequence seen so far.
@ invalid
Invalid format or signature.
std::error_code make_error_code(ripple::TokenCodecErrc e)
std::optional< KeyType > publicKeyType(Slice const &slice)
Returns the type of public key.
std::string strHex(FwdIt begin, FwdIt end)
@ accepted
Manifest is valid.
@ invalid
Timely, but invalid signature.
std::enable_if_t< std::is_same< T, char >::value||std::is_same< T, unsigned char >::value, Slice > makeSlice(std::array< T, N > const &a)
NodeID calcNodeID(PublicKey const &)
Calculate the 160-bit node ID from a node public key.
std::optional< Blob > strViewUnHex(std::string_view strSrc)
std::string to_string(base_uint< Bits, Tag > const &a)
constexpr std::size_t maximiumMessageSize
void writeFileContents(boost::system::error_code &ec, boost::filesystem::path const &destPath, std::string const &contents)
sha512_half_hasher::result_type sha512Half(Args const &... args)
Returns the SHA512-Half of a series of objects.
std::size_t buildValidatorListMessage(std::vector< ValidatorList::MessageWithHash > &messages, std::uint32_t rawVersion, std::string const &rawManifest, ValidatorBlobInfo const ¤tBlob, std::size_t maxSize)
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::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)
ListDisposition bestDisposition() const
PublisherListStats()=default
ListDisposition worstDisposition() const
std::map< ListDisposition, std::size_t > dispositions
std::optional< PublicKey > publisherKey
std::vector< PublicKey > list
TimeKeeper::time_point validUntil
TimeKeeper::time_point validFrom