xrpld
Loading...
Searching...
No Matches
ValidatorList.cpp
1#include <xrpld/app/misc/ValidatorList.h>
2
3#include <xrpld/core/TimeKeeper.h>
4#include <xrpld/overlay/Message.h>
5#include <xrpld/overlay/Overlay.h>
6#include <xrpld/overlay/Peer.h>
7
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>
31
32#include <boost/regex/v5/regex.hpp>
33#include <boost/regex/v5/regex_match.hpp>
34
35#include <xrpl.pb.h>
36
37#include <algorithm>
38#include <chrono>
39#include <cmath>
40#include <cstddef>
41#include <cstdint>
42#include <filesystem>
43#include <functional>
44#include <iterator>
45#include <limits>
46#include <map>
47#include <memory>
48#include <mutex>
49#include <numeric>
50#include <optional>
51#include <shared_mutex>
52#include <string>
53#include <string_view>
54#include <system_error>
55#include <utility>
56#include <vector>
57
58namespace xrpl {
59
60std::string
62{
63 switch (disposition)
64 {
66 return "accepted";
68 return "expired";
70 return "same_sequence";
72 return "pending";
74 return "known_sequence";
76 return "unsupported_version";
78 return "untrusted";
80 return "stale";
82 return "invalid";
83 }
84 return "unknown";
85}
86
91
101
107
113
114void
116{
117 for (auto const& [disp, count] : src.dispositions)
118 {
119 dispositions[disp] += count;
120 }
121}
122
130
132
134 ManifestCache& validatorManifests,
135 ManifestCache& publisherManifests,
136 TimeKeeper& timeKeeper,
137 std::string const& databasePath,
139 std::optional<std::size_t> minimumQuorum)
140 : validatorManifests_(validatorManifests)
141 , publisherManifests_(publisherManifests)
142 , timeKeeper_(timeKeeper)
143 , dataPath_(databasePath)
144 , j_(j)
145 , quorum_(minimumQuorum.value_or(1)) // Genesis ledger quorum
146 , minimumQuorum_(minimumQuorum)
147
148{
149}
150
151bool
153 std::optional<PublicKey> const& localSigningKey,
154 std::vector<std::string> const& configKeys,
155 std::vector<std::string> const& publisherKeys,
156 std::optional<std::size_t> listThreshold)
157{
158 static boost::regex const kRE(
159 "[[:space:]]*" // skip leading whitespace
160 "([[:alnum:]]+)" // node identity
161 "(?:" // begin optional comment block
162 "[[:space:]]+" // (skip all leading whitespace)
163 "(?:" // begin optional comment
164 "(.*[^[:space:]]+)" // the comment
165 "[[:space:]]*" // (skip all trailing whitespace)
166 ")?" // end optional comment
167 ")?" // end optional comment block
168 );
169
170 std::scoped_lock const lock{mutex_};
171
172 JLOG(j_.debug()) << "Loading configured trusted validator list publisher keys";
173
174 std::size_t count = 0;
175 for (auto const& key : publisherKeys)
176 {
177 JLOG(j_.trace()) << "Processing '" << key << "'";
178
179 auto const ret = strUnHex(key);
180
181 if (!ret || !publicKeyType(makeSlice(*ret)))
182 {
183 JLOG(j_.error()) << "Invalid validator list publisher key: " << key;
184 return false;
185 }
186
187 auto const id = PublicKey(makeSlice(*ret));
188 auto status = PublisherStatus::Unavailable;
189
190 if (publisherManifests_.revoked(id))
191 {
192 JLOG(j_.warn()) << "Configured validator list publisher key is revoked: " << key;
194 }
195
196 if (publisherLists_.contains(id))
197 {
198 JLOG(j_.warn()) << "Duplicate validator list publisher key: " << key;
199 continue;
200 }
201
202 publisherLists_[id].status = status;
203 ++count;
204 }
205
206 if (listThreshold)
207 {
208 listThreshold_ = *listThreshold;
209 // This should be enforced by Config class
210 XRPL_ASSERT(
212 "xrpl::ValidatorList::load : list threshold inside range");
213 JLOG(j_.debug()) << "Validator list threshold set in configuration to " << listThreshold_;
214 }
215 else
216 {
217 // Want truncated result when dividing an odd integer
218 listThreshold_ = (publisherLists_.size() < 3) ? 1 //
219 : (publisherLists_.size() / 2) + 1;
220 JLOG(j_.debug()) << "Validator list threshold computed as " << listThreshold_;
221 }
222
223 JLOG(j_.debug()) << "Loaded " << count << " keys";
224
225 if (localSigningKey)
226 localPubKey_ = validatorManifests_.getMasterKey(*localSigningKey);
227
228 // Treat local validator key as though it was listed in the config
229 if (localPubKey_)
230 {
231 // The local validator must meet listThreshold_ so the validator does
232 // not ignore itself.
233 auto const [_, inserted] = keyListings_.insert({*localPubKey_, listThreshold_});
234 if (inserted)
235 {
236 JLOG(j_.debug()) << "Added own master key "
238 }
239 }
240
241 JLOG(j_.debug()) << "Loading configured validator keys";
242
243 count = 0;
244 for (auto const& n : configKeys)
245 {
246 JLOG(j_.trace()) << "Processing '" << n << "'";
247
248 boost::smatch match;
249
250 if (!boost::regex_match(n, match, kRE))
251 {
252 JLOG(j_.error()) << "Malformed entry: '" << n << "'";
253 return false;
254 }
255
256 auto const id = parseBase58<PublicKey>(TokenType::NodePublic, match[1].str());
257
258 if (!id)
259 {
260 JLOG(j_.error()) << "Invalid node identity: " << match[1];
261 return false;
262 }
263
264 // Skip local key which was already added
265 if (*id == localPubKey_ || *id == localSigningKey)
266 continue;
267
268 auto const ret = keyListings_.insert({*id, listThreshold_});
269 if (!ret.second)
270 {
271 JLOG(j_.warn()) << "Duplicate node identity: " << match[1];
272 continue;
273 }
274 localPublisherList_.list.emplace_back(*id);
275 ++count;
276 }
277
278 // Config listed keys never expire
279 // set the expiration time for the newly created publisher list
280 // exactly once
281 if (count > 0)
282 localPublisherList_.validUntil = TimeKeeper::time_point::max();
283
284 JLOG(j_.debug()) << "Loaded " << count << " entries";
285
286 return true;
287}
288
291{
292 return dataPath_ / (kFilePrefix + strHex(pubKey));
293}
294
295// static
298 std::string const& pubKey,
299 ValidatorList::PublisherListCollection const& pubCollection,
301{
302 return buildFileData(pubKey, pubCollection, {}, j);
303}
304
305// static
308 std::string const& pubKey,
309 ValidatorList::PublisherListCollection const& pubCollection,
310 std::optional<std::uint32_t> forceVersion,
312{
314
315 XRPL_ASSERT(
316 pubCollection.rawVersion == 2 || pubCollection.remaining.empty(),
317 "xrpl::ValidatorList::buildFileData : valid publisher list input");
318 auto const effectiveVersion = forceVersion ? *forceVersion : pubCollection.rawVersion;
319
320 value[jss::manifest] = pubCollection.rawManifest;
321 value[jss::version] = effectiveVersion;
322 value[jss::public_key] = pubKey;
323
324 switch (effectiveVersion)
325 {
326 case 1: {
327 auto const& current = pubCollection.current;
328 value[jss::blob] = current.rawBlob;
329 value[jss::signature] = current.rawSignature;
330 // This is only possible if "downgrading" a v2 UNL to v1, for
331 // example for the /vl/ endpoint.
332 if (current.rawManifest && *current.rawManifest != pubCollection.rawManifest)
333 value[jss::manifest] = *current.rawManifest;
334 break;
335 }
336 case 2: {
338
339 auto const add =
340 [&blobs, &outerManifest = pubCollection.rawManifest](PublisherList const& pubList) {
341 auto& blob = blobs.append(json::ValueType::Object);
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;
346 };
347
348 add(pubCollection.current);
349 for (auto const& [_, pending] : pubCollection.remaining)
350 {
351 (void)_;
352 add(pending);
353 }
354
355 value[jss::blobs_v2] = std::move(blobs);
356 break;
357 }
358 default:
359 JLOG(j.trace()) << "Invalid VL version provided: " << effectiveVersion;
360 value = json::ValueType::Null;
361 }
362
363 return value;
364}
365
366void
368 const
369{
370 if (dataPath_.empty())
371 return;
372
373 std::filesystem::path const filename = getCacheFileName(lock, pubKey);
374
376
377 json::Value value = buildFileData(strHex(pubKey), publisherLists_.at(pubKey), j_);
378 // xrpld should be the only process writing to this file, so
379 // if it ever needs to be read, it is not expected to change externally, so
380 // delay the refresh as long as possible: 24 hours. (See also
381 // `ValidatorSite::missingSite()`)
382 value[jss::refresh_interval] = 24 * 60;
383
384 writeFileContents(ec, filename, value.toStyledString());
385
386 if (ec)
387 {
388 // Log and ignore any file I/O exceptions
389 JLOG(j_.error()) << "Problem writing " << filename << " " << ec.value() << ": "
390 << ec.message();
391 }
392}
393
394// static
397{
399 switch (version)
400 {
401 case 1: {
402 if (!body.isMember(jss::blob) || !body[jss::blob].isString() ||
403 !body.isMember(jss::signature) || !body[jss::signature].isString() ||
404 // If the v2 field is present, the VL is malformed
405 body.isMember(jss::blobs_v2))
406 return {};
407 ValidatorBlobInfo& info = result.emplace_back();
408 info.blob = body[jss::blob].asString();
409 info.signature = body[jss::signature].asString();
410 XRPL_ASSERT(
411 result.size() == 1, "xrpl::ValidatorList::parseBlobs : single element result");
412 return result;
413 }
414 // Treat unknown versions as if they're the latest version. This
415 // will likely break a bunch of unit tests each time we introduce a
416 // new version, so don't do it casually. Note that the version is
417 // validated elsewhere.
418 case 2:
419 default: {
420 if (!body.isMember(jss::blobs_v2) || !body[jss::blobs_v2].isArray() ||
421 body[jss::blobs_v2].size() > kMaxSupportedBlobs ||
422 // If any of the v1 fields are present, the VL is malformed
423 body.isMember(jss::blob) || body.isMember(jss::signature))
424 return {};
425 auto const& blobs = body[jss::blobs_v2];
426 result.reserve(blobs.size());
427 for (auto const& blobInfo : blobs)
428 {
429 if (!blobInfo.isObject() || !blobInfo.isMember(jss::signature) ||
430 !blobInfo[jss::signature].isString() || !blobInfo.isMember(jss::blob) ||
431 !blobInfo[jss::blob].isString())
432 return {};
433 ValidatorBlobInfo& info = result.emplace_back();
434 info.blob = blobInfo[jss::blob].asString();
435 info.signature = blobInfo[jss::signature].asString();
436 if (blobInfo.isMember(jss::manifest))
437 {
438 if (!blobInfo[jss::manifest].isString())
439 return {};
440 info.manifest = blobInfo[jss::manifest].asString();
441 }
442 }
443 XRPL_ASSERT(
444 result.size() == blobs.size(),
445 "xrpl::ValidatorList::parseBlobs(version, Jason::Value) : "
446 "result size matches");
447 return result;
448 }
449 }
450}
451
452// static
454ValidatorList::parseBlobs(protocol::TMValidatorListCollection const& body)
455{
456 if (body.blobs_size() > kMaxSupportedBlobs)
457 return {};
459 result.reserve(body.blobs_size());
460 for (auto const& blob : body.blobs())
461 {
462 ValidatorBlobInfo& info = result.emplace_back();
463 info.blob = blob.blob();
464 info.signature = blob.signature();
465 if (blob.has_manifest())
466 {
467 info.manifest = blob.manifest();
468 }
469 }
470 XRPL_ASSERT(
471 result.size() == body.blobs_size(),
472 "xrpl::ValidatorList::parseBlobs(TMValidatorListCollection) : result size "
473 "match");
474 return result;
475}
476
480 protocol::TMValidatorListCollection const& largeMsg,
481 std::size_t maxSize,
482 std::size_t begin,
483 std::size_t end);
484
488 protocol::TMValidatorListCollection const& largeMsg,
489 std::size_t maxSize,
490 std::size_t begin = 0,
491 std::size_t end = 0)
492{
493 if (begin == 0 && end == 0)
494 end = largeMsg.blobs_size();
495 XRPL_ASSERT(begin < end, "xrpl::splitMessage : valid inputs");
496 if (end <= begin)
497 return 0;
498
499 auto const mid = (begin + end) / 2;
500 // The parts function will do range checking
501 // Use two separate calls to ensure deterministic order
502 auto const result = splitMessageParts(messages, largeMsg, maxSize, begin, mid);
503 return result + splitMessageParts(messages, largeMsg, maxSize, mid, end);
504}
505
509 protocol::TMValidatorListCollection const& largeMsg,
510 std::size_t maxSize,
511 std::size_t begin,
512 std::size_t end)
513{
514 if (end <= begin)
515 return 0;
516
518 smallMsg.emplace();
519 smallMsg->set_version(largeMsg.version());
520 smallMsg->set_manifest(largeMsg.manifest());
521
522 for (std::size_t i = begin; i < end; ++i)
523 {
524 *smallMsg->add_blobs() = largeMsg.blobs(i);
525 }
526
527 auto const size = Message::totalSize(*smallMsg);
528
529 // Split until each message fits, but a single blob can't be split any
530 // further, so stop recursing at that point regardless of maxSize.
531 if (size > maxSize && end - begin > 1)
532 {
533 // free up the message space
534 smallMsg.reset();
535 return splitMessage(messages, largeMsg, maxSize, begin, end);
536 }
537
538 // An unsplittable blob is still bounded by the protocol limit: peers drop
539 // messages exceeding it on receipt, so don't waste the bandwidth. maxSize
540 // only ever tightens this (it defaults to kMaximumMessageSize), so a blob
541 // reaching here can exceed maxSize but never the protocol limit.
542 if (size > kMaximumMessageSize)
543 {
544 // LCOV_EXCL_START
545 UNREACHABLE("xrpl::splitMessageParts : maximum message size exceeded");
546 return 0;
547 // LCOV_EXCL_STOP
548 }
549
550 messages.emplace_back(
551 std::make_shared<Message>(*smallMsg, protocol::mtVALIDATOR_LIST_COLLECTION),
552 sha512Half(*smallMsg),
553 smallMsg->blobs_size());
554 return messages.back().numVLs;
555}
556
557// Build a v2 protocol message using all the VLs with sequence larger than the
558// peer's
562 std::uint64_t peerSequence,
563 std::uint32_t rawVersion,
564 std::string const& rawManifest,
566 std::size_t maxSize)
567{
568 XRPL_ASSERT(
569 messages.empty(),
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);
576
577 for (auto const& [sequence, blobInfo] : blobInfos)
578 {
579 if (sequence <= peerSequence)
580 continue;
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);
586 }
587 XRPL_ASSERT(
588 msg.blobs_size() > 0,
589 "xrpl::buildValidatorListMessage(std::map<std::size_t, "
590 "ValidatorBlobInfo>) : minimum message blobs");
591 if (Message::totalSize(msg) > maxSize)
592 {
593 // split into smaller messages
594 return splitMessage(messages, msg, maxSize);
595 }
596
597 messages.emplace_back(
598 std::make_shared<Message>(msg, protocol::mtVALIDATOR_LIST_COLLECTION),
599 sha512Half(msg),
600 msg.blobs_size());
601 return messages.back().numVLs;
602}
603
604[[nodiscard]]
605// static
608 std::uint64_t peerSequence,
609 std::size_t maxSequence,
610 std::uint32_t rawVersion,
611 std::string const& rawManifest,
614 std::size_t maxSize /*= kMaximumMessageSize*/)
615{
616 XRPL_ASSERT(
617 !blobInfos.empty(),
618 "xrpl::ValidatorList::buildValidatorListMessages : empty messages "
619 "input");
620 auto numVLs = std::accumulate(
621 messages.begin(), messages.end(), 0, [](std::size_t total, MessageWithHash const& m) {
622 return total + m.numVLs;
623 });
624 if (peerSequence < maxSequence)
625 {
626 if (messages.empty())
627 {
629 messages, peerSequence, rawVersion, rawManifest, blobInfos, maxSize);
630 if (messages.empty())
631 {
632 // No message was generated. Create an empty placeholder so we
633 // don't repeat the work later.
634 messages.emplace_back();
635 }
636 }
637
638 return {maxSequence, numVLs};
639 }
640 return {0, 0};
641}
642
643// static
644void
646 Peer& peer,
647 std::uint64_t peerSequence,
648 PublicKey const& publisherKey,
649 std::size_t maxSequence,
650 std::uint32_t rawVersion,
651 std::string const& rawManifest,
654 HashRouter& hashRouter,
656{
657 auto const [newPeerSequence, numVLs] = buildValidatorListMessages(
658 peerSequence, maxSequence, rawVersion, rawManifest, blobInfos, messages);
659 if (newPeerSequence != 0u)
660 {
661 XRPL_ASSERT(
662 !messages.empty(),
663 "xrpl::ValidatorList::sendValidatorList : non-empty messages "
664 "input");
665 // Don't send it next time.
666 peer.setPublisherListSequence(publisherKey, newPeerSequence);
667
668 bool sent = false;
669 for (auto const& message : messages)
670 {
671 if (message.message)
672 {
673 peer.send(message.message);
674 hashRouter.addSuppressionPeer(message.hash, peer.id());
675 sent = true;
676 }
677 }
678 // The only way sent wil be false is if the messages was too big, and
679 // thus there will only be one entry without a message
680 XRPL_ASSERT(
681 sent || messages.size() == 1,
682 "xrpl::ValidatorList::sendValidatorList : sent or one message");
683 if (sent)
684 {
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
689 << " to " << peer.fingerprint();
690 }
691 }
692}
693
694// static
695void
697 Peer& peer,
698 std::uint64_t peerSequence,
699 PublicKey const& publisherKey,
700 std::size_t maxSequence,
701 std::uint32_t rawVersion,
702 std::string const& rawManifest,
704 HashRouter& hashRouter,
706{
709 peer,
710 peerSequence,
711 publisherKey,
712 maxSequence,
713 rawVersion,
714 rawManifest,
715 blobInfos,
716 messages,
717 hashRouter,
718 j);
719}
720
721// static
722void
726{
727 auto const& current = lists.current;
728 auto const& remaining = lists.remaining;
729 blobInfos[current.sequence] = {
730 .blob = current.rawBlob,
731 .signature = current.rawSignature,
732 .manifest = current.rawManifest,
733 };
734 for (auto const& [sequence, vl] : remaining)
735 {
736 blobInfos[sequence] = {
737 .blob = vl.rawBlob,
738 .signature = vl.rawSignature,
739 .manifest = vl.rawManifest,
740 };
741 }
742}
743
744// static
752
753// static
754void
756 PublicKey const& publisherKey,
758 std::size_t maxSequence,
759 UInt256 const& hash,
760 Overlay& overlay,
761 HashRouter& hashRouter,
763{
764 auto const toSkip = hashRouter.shouldRelay(hash);
765
766 if (toSkip)
767 {
768 // Build v2 messages on demand and reuse them when possible. Messages
769 // are indexed by the peer's `publisherListSequence`; for each sequence,
770 // we only send VLs with higher sequences.
772 // If any peers are found that are worth considering, this list will
773 // be built to hold info for all of the valid VLs.
775
776 XRPL_ASSERT(
777 lists.current.sequence == maxSequence || lists.remaining.count(maxSequence) == 1,
778 "xrpl::ValidatorList::broadcastBlobs : valid sequence");
779 // Can't use overlay.foreach here because we need to modify
780 // the peer, and foreach provides a const&
781 for (auto const& peer : overlay.getActivePeers())
782 {
783 if (!toSkip->contains(peer->id()))
784 {
785 auto const peerSequence = peer->publisherListSequence(publisherKey).value_or(0);
786 if (peerSequence < maxSequence)
787 {
788 if (blobInfos.empty())
789 buildBlobInfos(blobInfos, lists);
791 *peer,
792 peerSequence,
793 publisherKey,
794 maxSequence,
795 lists.rawVersion,
796 lists.rawManifest,
797 blobInfos,
798 messages2[peerSequence],
799 hashRouter,
800 j);
801 // Don't send it next time.
802 hashRouter.addSuppressionPeer(hash, peer->id());
803 }
804 }
805 }
806 }
807}
808
811 std::string const& manifest,
812 std::uint32_t version,
814 std::string siteUri,
815 UInt256 const& hash,
816 Overlay& overlay,
817 HashRouter& hashRouter,
818 NetworkOPs& networkOPs)
819{
820 auto const result = applyLists(manifest, version, blobs, std::move(siteUri), hash);
821 auto const disposition = result.bestDisposition();
822
823 if (disposition == ListDisposition::Accepted)
824 {
825 bool good = true;
826
827 // localPublisherList never expires, so localPublisherList is excluded
828 // from the below check.
829 for (auto const& [_, listCollection] : publisherLists_)
830 {
831 if (listCollection.status != PublisherStatus::Available)
832 {
833 good = false;
834 break;
835 }
836 }
837 if (good)
838 {
839 networkOPs.clearUNLBlocked();
840 }
841 }
842 bool const broadcast = disposition <= ListDisposition::KnownSequence;
843
844 // this function is only called for PublicKeys which are not specified
845 // in the config file (Note: Keys specified in the local config file are
846 // stored in ValidatorList::localPublisherList data member).
847 if (broadcast && result.status <= PublisherStatus::Expired && result.publisherKey &&
848 // NOLINTNEXTLINE(bugprone-unchecked-optional-access) publisherKey checked in condition
849 // above
850 publisherLists_[*result.publisherKey].maxSequence)
851 {
852 // NOLINTBEGIN(bugprone-unchecked-optional-access) publisherKey and maxSequence checked in
853 // condition above
854 auto const& pubCollection = publisherLists_[*result.publisherKey];
855
857 *result.publisherKey,
858 pubCollection,
859 *pubCollection.maxSequence,
860 hash,
861 overlay,
862 hashRouter,
863 j_);
864 // NOLINTEND(bugprone-unchecked-optional-access)
865 }
866
867 return result;
868}
869
872 std::string const& manifest,
873 std::uint32_t version,
875 std::string siteUri,
876 std::optional<UInt256> const& hash /* = {} */)
877{
879 1)
881
882 std::scoped_lock const lock{mutex_};
883
884 PublisherListStats result;
885 for (auto const& blobInfo : blobs)
886 {
887 auto stats = applyList(
888 manifest,
889 blobInfo.manifest,
890 blobInfo.blob,
891 blobInfo.signature,
892 version,
893 siteUri,
894 hash,
895 lock);
896
897 if (stats.bestDisposition() < result.bestDisposition() ||
898 (stats.bestDisposition() == result.bestDisposition() &&
899 stats.sequence > result.sequence))
900 {
901 stats.mergeDispositions(result);
902 result = std::move(stats);
903 }
904 else
905 {
906 result.mergeDispositions(stats);
907 }
909 }
910
911 // Clean up the collection, because some of the processing may have made it
912 // inconsistent
913 if (result.publisherKey && publisherLists_.contains(*result.publisherKey))
914 {
915 // NOLINTBEGIN(bugprone-unchecked-optional-access) publisherKey checked in condition above
916 auto& pubCollection = publisherLists_[*result.publisherKey];
917 auto& remaining = pubCollection.remaining;
918 auto const& current = pubCollection.current;
919 for (auto iter = remaining.begin(); iter != remaining.end();)
920 {
921 auto const next = std::next(iter);
922 XRPL_ASSERT(
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))
927 {
928 iter = remaining.erase(iter);
929 }
930 else
931 {
932 iter = next;
933 }
934 }
935
936 cacheValidatorFile(lock, *result.publisherKey);
937
938 pubCollection.fullHash = sha512Half(pubCollection);
939
940 result.sequence = *pubCollection.maxSequence;
941 // NOLINTEND(bugprone-unchecked-optional-access)
942 }
943
944 return result;
945}
946
947void
949 PublicKey const& pubKey,
950 PublisherList const& current,
951 std::vector<PublicKey> const& oldList,
953{
954 // Update keyListings_ for added and removed keys
955 std::vector<PublicKey> const& publisherList = current.list;
956 std::vector<std::string> const& manifests = current.manifests;
957 auto iNew = publisherList.begin();
958 auto iOld = oldList.begin();
959 while (iNew != publisherList.end() || iOld != oldList.end())
960 {
961 if (iOld == oldList.end() || (iNew != publisherList.end() && *iNew < *iOld))
962 {
963 // Increment list count for added keys
964 ++keyListings_[*iNew];
965 // Key is now listed: free its untrusted slot if it had one.
966 validatorManifests_.promoteToTrusted(*iNew);
967 ++iNew;
968 }
969 else if (iNew == publisherList.end() || (iOld != oldList.end() && *iOld < *iNew))
970 {
971 // Decrement list count for removed keys
972 if (keyListings_[*iOld] <= 1)
973 {
974 keyListings_.erase(*iOld);
975 }
976 else
977 {
978 --keyListings_[*iOld];
979 }
980 ++iOld;
981 }
982 else
983 {
984 ++iNew;
985 ++iOld;
986 }
987 }
988
989 if (publisherList.empty())
990 {
991 JLOG(j_.warn()) << "No validator keys included in valid list";
992 }
993
994 for (auto const& valManifest : manifests)
995 {
996 auto m = deserializeManifest(base64Decode(valManifest));
997
998 if (!m || !keyListings_.contains(m->masterKey))
999 {
1000 JLOG(j_.warn()) << "List for " << strHex(pubKey)
1001 << " contained untrusted validator manifest";
1002 continue;
1003 }
1004
1005 if (auto const r = validatorManifests_.applyManifest(
1008 {
1009 JLOG(j_.warn()) << "List for " << strHex(pubKey)
1010 << " contained invalid validator manifest";
1011 }
1012 }
1013}
1014
1017 std::string const& globalManifest,
1018 std::optional<std::string> const& localManifest,
1019 std::string const& blob,
1020 std::string const& signature,
1021 std::uint32_t version,
1022 std::string siteUri,
1023 std::optional<UInt256> const& hash,
1024 ValidatorList::ScopedLock const& lock)
1025{
1026 using namespace std::string_literals;
1027
1028 json::Value list;
1029 auto const& manifest = localManifest ? *localManifest : globalManifest;
1030 // Reject an oversized manifest before decoding it, so we do not allocate
1031 // memory for an input that cannot be a valid manifest. deserializeManifest
1032 // also enforces the decoded-byte limit, but checking here avoids the
1033 // base64 decode entirely.
1034 if (manifest.size() > kMaxManifestBase64)
1035 {
1036 JLOG(j_.warn()) << "UNL manifest exceeds maximum size";
1038 }
1039 auto m = deserializeManifest(base64Decode(manifest));
1040 if (!m)
1041 {
1042 JLOG(j_.warn()) << "UNL manifest cannot be deserialized";
1044 }
1045
1046 auto [result, pubKeyOpt] = verify(lock, list, std::move(*m), blob, signature);
1047
1048 if (!pubKeyOpt)
1049 {
1050 JLOG(j_.warn()) << "UNL manifest is signed with an unrecognized master public key";
1051 return PublisherListStats{result};
1052 }
1053
1054 if (!publicKeyType(*pubKeyOpt))
1055 {
1056 // This is an impossible situation because we will never load an
1057 // invalid public key type (see checks in `ValidatorList::load`) however
1058 // we can only arrive here if the key used by the manifest matched one
1059 // of the loaded keys
1060 // LCOV_EXCL_START
1061 UNREACHABLE("xrpl::ValidatorList::applyList : invalid public key type");
1062 return PublisherListStats{result};
1063 // LCOV_EXCL_STOP
1064 }
1065
1066 PublicKey const pubKey = *pubKeyOpt;
1067 if (result > ListDisposition::Pending)
1068 {
1069 if (publisherLists_.contains(pubKey))
1070 {
1071 auto const& pubCollection = publisherLists_[pubKey];
1072 if (pubCollection.maxSequence &&
1073 (result == ListDisposition::SameSequence ||
1075 {
1076 // We've seen something valid list for this publisher
1077 // already, so return what we know about it.
1078 return PublisherListStats{
1079 result, pubKey, pubCollection.status, *pubCollection.maxSequence};
1080 }
1081 }
1082 return PublisherListStats{result};
1083 }
1084
1085 // Update publisher's list
1086 auto& pubCollection = publisherLists_[pubKey];
1087 auto const sequence = list[jss::sequence].asUInt();
1088 auto const accepted =
1089 (result == ListDisposition::Accepted || result == ListDisposition::Expired);
1090
1091 if (accepted)
1092 {
1093 pubCollection.status = result == ListDisposition::Accepted ? PublisherStatus::Available
1095 }
1096 pubCollection.rawManifest = globalManifest;
1097 if (!pubCollection.maxSequence || sequence > *pubCollection.maxSequence)
1098 pubCollection.maxSequence = sequence;
1099
1100 json::Value const& newList = list[jss::validators];
1101 std::vector<PublicKey> oldList;
1102 if (accepted && pubCollection.remaining.contains(sequence))
1103 {
1104 // We've seen this list before and stored it in "remaining". The
1105 // normal expected process is that the processed list would have
1106 // already been moved in to "current" by "updateTrusted()", but race
1107 // conditions are possible, or the node may have lost sync, so do
1108 // some of that work here.
1109 auto& publisher = pubCollection.current;
1110 // Copy the old validator list
1111 oldList = std::move(pubCollection.current.list);
1112 // Move the publisher info from "remaining" to "current"
1113 publisher = std::move(pubCollection.remaining[sequence]);
1114 // Remove the entry in "remaining"
1115 pubCollection.remaining.erase(sequence);
1116 // Done
1117 XRPL_ASSERT(
1118 publisher.sequence == sequence,
1119 "xrpl::ValidatorList::applyList : publisher sequence match");
1120 }
1121 else
1122 {
1123 auto& publisher = accepted ? pubCollection.current : pubCollection.remaining[sequence];
1124 publisher.sequence = sequence;
1125 publisher.validFrom = TimeKeeper::time_point{TimeKeeper::duration{
1126 list.isMember(jss::effective) ? list[jss::effective].asUInt() : 0}};
1127 publisher.validUntil =
1128 TimeKeeper::time_point{TimeKeeper::duration{list[jss::expiration].asUInt()}};
1129 publisher.siteUri = std::move(siteUri);
1130 publisher.rawBlob = blob;
1131 publisher.rawSignature = signature;
1132 publisher.rawManifest = localManifest;
1133 if (hash)
1134 publisher.hash = *hash;
1135
1136 std::vector<PublicKey>& publisherList = publisher.list;
1137 std::vector<std::string>& manifests = publisher.manifests;
1138
1139 // Copy the old validator list
1140 oldList = std::move(publisherList);
1141 // Build the new validator list from "newList"
1142 publisherList.clear();
1143 publisherList.reserve(newList.size());
1144 for (auto const& val : newList)
1145 {
1146 if (val.isObject() && val.isMember(jss::validation_public_key) &&
1147 val[jss::validation_public_key].isString())
1148 {
1149 std::optional<Blob> const ret =
1150 strUnHex(val[jss::validation_public_key].asString());
1151
1152 if (!ret || !publicKeyType(makeSlice(*ret)))
1153 {
1154 JLOG(j_.error())
1155 << "Invalid node identity: " << val[jss::validation_public_key].asString();
1156 }
1157 else
1158 {
1159 publisherList.emplace_back(Slice{ret->data(), ret->size()});
1160 }
1161
1162 if (val.isMember(jss::manifest) && val[jss::manifest].isString())
1163 manifests.push_back(val[jss::manifest].asString());
1164 }
1165 }
1166
1167 // Standardize the list order by sorting
1168 std::sort(publisherList.begin(), publisherList.end()); // NOLINT(modernize-use-ranges)
1169 }
1170 // If this publisher has ever sent a more updated version than the one
1171 // in this file, keep it. This scenario is unlikely, but legal.
1172 pubCollection.rawVersion = std::max(pubCollection.rawVersion, version);
1173 if (!pubCollection.remaining.empty())
1174 {
1175 // If there are any pending VLs, then this collection must be at least
1176 // version 2.
1177 pubCollection.rawVersion = std::max(pubCollection.rawVersion, 2u);
1178 }
1179
1180 PublisherListStats const applyResult{
1181 result, pubKey, pubCollection.status, *pubCollection.maxSequence};
1182
1183 if (accepted)
1184 {
1185 updatePublisherList(pubKey, pubCollection.current, oldList, lock);
1186 }
1187
1188 return applyResult;
1189}
1190
1193{
1194 using namespace std::string_literals;
1195 using namespace std::filesystem;
1196
1198
1200 sites.reserve(publisherLists_.size());
1201 for (auto const& [pubKey, publisherCollection] : publisherLists_)
1202 {
1203 std::error_code ec;
1204
1205 if (publisherCollection.status == PublisherStatus::Available)
1206 continue;
1207
1208 std::filesystem::path const filename = getCacheFileName(lock, pubKey);
1209
1210 auto const fullPath{canonical(filename, ec)};
1211 if (ec)
1212 continue;
1213
1214 auto size = file_size(fullPath, ec);
1215 if (!ec && (size == 0u))
1216 {
1217 // Treat an empty file as a missing file, because
1218 // nobody else is going to write it.
1219 ec = make_error_code(std::errc::no_such_file_or_directory);
1220 }
1221 if (ec)
1222 continue;
1223
1224 std::string const prefix = [&fullPath] {
1225#if _MSC_VER // MSVC: Windows paths need a leading / added
1226 {
1227 return fullPath.root_path() == "/"s ? "file://" : "file:///";
1228 }
1229#else
1230 {
1231 (void)fullPath;
1232 return "file://";
1233 }
1234#endif
1235 }();
1236 sites.emplace_back(prefix + fullPath.string());
1237 }
1238
1239 // Then let the ValidatorSites do the rest of the work.
1240 return sites;
1241}
1242
1243// The returned PublicKey value is read from the manifest. Manifests do not
1244// contain the default-constructed public keys
1249 Manifest manifest,
1250 std::string const& blob,
1251 std::string const& signature)
1252{
1253 if (!publisherLists_.contains(manifest.masterKey))
1254 return {ListDisposition::Untrusted, {}};
1255
1256 PublicKey masterPubKey = manifest.masterKey;
1257 auto const revoked = manifest.revoked();
1258
1259 // Publisher keys are configured/trusted (checked above), so bypass the
1260 // untrusted cap.
1261 auto const result = publisherManifests_.applyManifest(
1262 std::move(manifest), ManifestRateLimitCapPolicy::Uncapped);
1263
1264 if (revoked && result == ManifestDisposition::Accepted)
1265 {
1267 // If the manifest is revoked, no future list is valid either
1268 publisherLists_[masterPubKey].remaining.clear();
1269 }
1270
1271 auto const signingKey = publisherManifests_.getSigningKey(masterPubKey);
1272
1273 if (revoked || !signingKey || result == ManifestDisposition::Invalid)
1274 return {ListDisposition::Untrusted, masterPubKey};
1275
1276 auto const sig = strUnHex(signature);
1277 auto const data = base64Decode(blob);
1278 if (!sig || !xrpl::verify(*signingKey, makeSlice(data), makeSlice(*sig)))
1279 return {ListDisposition::Invalid, masterPubKey};
1280
1281 json::Reader r;
1282 if (!r.parse(data, list))
1283 return {ListDisposition::Invalid, masterPubKey};
1284
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())
1289 {
1290 auto const sequence = list[jss::sequence].asUInt();
1291 auto const validFrom = TimeKeeper::time_point{TimeKeeper::duration{
1292 list.isMember(jss::effective) ? list[jss::effective].asUInt() : 0}};
1293 auto const validUntil =
1294 TimeKeeper::time_point{TimeKeeper::duration{list[jss::expiration].asUInt()}};
1295 auto const now = timeKeeper_.now();
1296 auto const& listCollection = publisherLists_[masterPubKey];
1297 if (validUntil <= validFrom)
1298 {
1299 return {ListDisposition::Invalid, masterPubKey};
1300 }
1301 if (sequence < listCollection.current.sequence)
1302 {
1303 return {ListDisposition::Stale, masterPubKey};
1304 }
1305 if (sequence == listCollection.current.sequence)
1306 {
1307 return {ListDisposition::SameSequence, masterPubKey};
1308 }
1309 if (validUntil <= now)
1310 {
1311 return {ListDisposition::Expired, masterPubKey};
1312 }
1313 if (validFrom > now)
1314 {
1315 // Not yet valid. Return pending if one of the following is true
1316 // * There's no maxSequence, indicating this is the first blob seen
1317 // for this publisher
1318 // * The sequence is larger than the maxSequence, indicating this
1319 // blob is new
1320 // * There's no entry for this sequence AND this blob is valid
1321 // before the last blob, indicating blobs may be processing out of
1322 // order. This may result in some duplicated processing, but
1323 // prevents the risk of missing valid data. Else return
1324 // known_sequence
1325 return !listCollection.maxSequence || sequence > *listCollection.maxSequence ||
1326 (!listCollection.remaining.contains(sequence) &&
1327 validFrom < listCollection.remaining.at(*listCollection.maxSequence).validFrom)
1330 }
1331 }
1332 else
1333 {
1334 return {ListDisposition::Invalid, masterPubKey};
1335 }
1336
1337 return {ListDisposition::Accepted, masterPubKey};
1338}
1339
1340bool
1342{
1343 std::shared_lock const readLock{mutex_};
1344
1345 auto const pubKey = validatorManifests_.getMasterKey(identity);
1346 return keyListings_.contains(pubKey);
1347}
1348
1349bool
1351{
1352 auto const pubKey = validatorManifests_.getMasterKey(identity);
1353 return trustedMasterKeys_.contains(pubKey);
1354}
1355
1356bool
1358{
1359 std::shared_lock const readLock{mutex_};
1360 return trusted(readLock, identity);
1361}
1362
1365{
1366 std::shared_lock const readLock{mutex_};
1367
1368 auto pubKey = validatorManifests_.getMasterKey(identity);
1369 if (keyListings_.contains(pubKey))
1370 return pubKey;
1371 return std::nullopt;
1372}
1373
1376{
1377 auto pubKey = validatorManifests_.getMasterKey(identity);
1378 if (trustedMasterKeys_.contains(pubKey))
1379 return pubKey;
1380 return std::nullopt;
1381}
1382
1385{
1386 std::shared_lock const readLock{mutex_};
1387
1388 return getTrustedKey(readLock, identity);
1389}
1390
1391bool
1393{
1394 std::shared_lock const readLock{mutex_};
1395 return (identity.size() != 0u) && publisherLists_.contains(identity) &&
1397}
1398
1401{
1402 std::shared_lock const readLock{mutex_};
1403 return localPubKey_;
1404}
1405
1406bool
1409 PublicKey const& publisherKey,
1410 PublisherStatus reason)
1411{
1412 XRPL_ASSERT(
1414 "xrpl::ValidatorList::removePublisherList : valid reason input");
1415 auto const iList = publisherLists_.find(publisherKey);
1416 if (iList == publisherLists_.end())
1417 return false;
1418
1419 JLOG(j_.debug()) << "Removing validator list for publisher " << strHex(publisherKey);
1420
1421 for (auto const& val : iList->second.current.list)
1422 {
1423 auto const& iVal = keyListings_.find(val);
1424 if (iVal == keyListings_.end())
1425 continue;
1426
1427 if (iVal->second <= 1)
1428 {
1429 keyListings_.erase(iVal);
1430 }
1431 else
1432 {
1433 --iVal->second;
1434 }
1435 }
1436
1437 iList->second.current.list.clear();
1438 iList->second.status = reason;
1439
1440 return true;
1441}
1442
1445{
1446 return publisherLists_.size() + static_cast<size_t>(!localPublisherList_.list.empty());
1447}
1448
1451{
1452 std::shared_lock const readLock{mutex_};
1453 return count(readLock);
1454}
1455
1458{
1460 for (auto const& [_, collection] : publisherLists_)
1461 {
1462 // Unfetched
1463 auto const& current = collection.current;
1464 if (current.validUntil == TimeKeeper::time_point{})
1465 {
1466 return std::nullopt;
1467 }
1468
1469 // Find the latest validUntil in a chain where the next validFrom
1470 // overlaps with the previous validUntil. applyLists has already cleaned
1471 // up the list so the validFrom dates are guaranteed increasing.
1472 auto chainedExpiration = current.validUntil;
1473 for (auto const& [sequence, check] : collection.remaining)
1474 {
1475 (void)sequence;
1476 if (check.validFrom <= chainedExpiration)
1477 {
1478 chainedExpiration = check.validUntil;
1479 }
1480 else
1481 {
1482 break;
1483 }
1484 }
1485
1486 // Earliest
1487 if (!res || chainedExpiration < *res)
1488 {
1489 res = chainedExpiration;
1490 }
1491 }
1492
1493 if (!localPublisherList_.list.empty())
1494 {
1495 PublisherList const collection = localPublisherList_;
1496 // Unfetched
1497 auto const& current = collection;
1498 auto const chainedExpiration = current.validUntil;
1499
1500 // Earliest
1501 if (!res || chainedExpiration < *res)
1502 {
1503 res = chainedExpiration;
1504 }
1505 }
1506 return res;
1507}
1508
1511{
1512 std::shared_lock const readLock{mutex_};
1513 return expires(readLock);
1514}
1515
1518{
1520
1521 std::shared_lock const readLock{mutex_};
1522
1523 res[jss::validation_quorum] = static_cast<json::UInt>(quorum_);
1524
1525 {
1526 auto& x = (res[jss::validator_list] = json::ValueType::Object);
1527
1528 x[jss::count] = static_cast<json::UInt>(count(readLock));
1529
1530 if (auto when = expires(readLock))
1531 {
1532 if (*when == TimeKeeper::time_point::max())
1533 {
1534 x[jss::expiration] = "never";
1535 x[jss::status] = "active";
1536 }
1537 else
1538 {
1539 x[jss::expiration] = to_string(*when);
1540
1541 if (*when > timeKeeper_.now())
1542 {
1543 x[jss::status] = "active";
1544 }
1545 else
1546 {
1547 x[jss::status] = "expired";
1548 }
1549 }
1550 }
1551 else
1552 {
1553 x[jss::status] = "unknown";
1554 x[jss::expiration] = "unknown";
1555 }
1556
1557 x[jss::validator_list_threshold] = json::UInt(listThreshold_);
1558 }
1559
1560 // Validator keys listed in the local config file
1561 json::Value& jLocalStaticKeys = (res[jss::local_static_keys] = json::ValueType::Array);
1562
1563 for (auto const& key : localPublisherList_.list)
1564 jLocalStaticKeys.append(toBase58(TokenType::NodePublic, key));
1565
1566 // Publisher lists
1567 json::Value& jPublisherLists = (res[jss::publisher_lists] = json::ValueType::Array);
1568 for (auto const& [publicKey, pubCollection] : publisherLists_)
1569 {
1570 json::Value& curr = jPublisherLists.append(json::ValueType::Object);
1571 curr[jss::pubkey_publisher] = strHex(publicKey);
1572 curr[jss::available] = pubCollection.status == PublisherStatus::Available;
1573
1574 auto const appendList = [](PublisherList const& publisherList, json::Value& target) {
1575 target[jss::uri] = publisherList.siteUri;
1576 if (publisherList.validUntil != TimeKeeper::time_point{})
1577 {
1578 target[jss::seq] = static_cast<json::UInt>(publisherList.sequence);
1579 target[jss::expiration] = to_string(publisherList.validUntil);
1580 }
1581 if (publisherList.validFrom != TimeKeeper::time_point{})
1582 target[jss::effective] = to_string(publisherList.validFrom);
1583 json::Value& keys = (target[jss::list] = json::ValueType::Array);
1584 for (auto const& key : publisherList.list)
1585 {
1587 }
1588 };
1589 {
1590 auto const& current = pubCollection.current;
1591 appendList(current, curr);
1592 if (current.validUntil != TimeKeeper::time_point{})
1593 {
1594 curr[jss::version] = pubCollection.rawVersion;
1595 }
1596 }
1597
1599 for (auto const& [sequence, future] : pubCollection.remaining)
1600 {
1601 using namespace std::chrono_literals;
1602
1603 (void)sequence;
1605 appendList(future, r);
1606 // Race conditions can happen, so make this check "fuzzy"
1607 XRPL_ASSERT(
1608 future.validFrom > timeKeeper_.now() + 600s,
1609 "xrpl::ValidatorList::getJson : minimum valid from");
1610 }
1611 if (remaining.size() != 0u)
1612 curr[jss::remaining] = std::move(remaining);
1613 }
1614
1615 // Trusted validator keys
1616 json::Value& jValidatorKeys = (res[jss::trusted_validator_keys] = json::ValueType::Array);
1617 for (auto const& k : trustedMasterKeys_)
1618 {
1619 jValidatorKeys.append(toBase58(TokenType::NodePublic, k));
1620 }
1621
1622 // signing keys
1623 json::Value& jSigningKeys = (res[jss::signing_keys] = json::ValueType::Object);
1624 validatorManifests_.forEachManifest([&jSigningKeys, this](Manifest const& manifest) {
1625 auto const it = keyListings_.find(manifest.masterKey);
1626 if (it != keyListings_.end() && manifest.signingKey)
1627 {
1628 jSigningKeys[toBase58(TokenType::NodePublic, manifest.masterKey)] =
1630 }
1631 });
1632
1633 // Negative UNL
1634 if (!negativeUNL_.empty())
1635 {
1636 json::Value& jNegativeUNL = (res[jss::NegativeUNL] = json::ValueType::Array);
1637 for (auto const& k : negativeUNL_)
1638 {
1639 jNegativeUNL.append(toBase58(TokenType::NodePublic, k));
1640 }
1641 }
1642
1643 return res;
1644}
1645
1646void
1648{
1649 std::shared_lock const readLock{mutex_};
1650
1651 for (auto const& v : keyListings_)
1652 func(v.first, trusted(readLock, v.first));
1653}
1654
1655void
1657 std::function<void(
1658 std::string const& manifest,
1659 std::uint32_t version,
1661 PublicKey const& pubKey,
1662 std::size_t maxSequence,
1663 UInt256 const& hash)> func) const
1664{
1665 std::shared_lock const readLock{mutex_};
1666
1667 for (auto const& [key, plCollection] : publisherLists_)
1668 {
1669 if (plCollection.status != PublisherStatus::Available)
1670 continue;
1671 XRPL_ASSERT(
1672 plCollection.maxSequence.value_or(0) != 0,
1673 "xrpl::ValidatorList::for_each_available : nonzero maxSequence");
1674 func(
1675 plCollection.rawManifest,
1676 plCollection.rawVersion,
1677 buildBlobInfos(plCollection),
1678 key,
1679 plCollection.maxSequence.value_or(0),
1680 plCollection.fullHash);
1681 }
1682}
1683
1686 std::string_view pubKey,
1687 std::optional<std::uint32_t> forceVersion /* = {} */)
1688{
1689 std::shared_lock const readLock{mutex_};
1690
1691 auto const keyBlob = strUnHex(pubKey);
1692
1693 if (!keyBlob || !publicKeyType(makeSlice(*keyBlob)))
1694 {
1695 JLOG(j_.warn()) << "Invalid requested validator list publisher key: " << pubKey;
1696 return {};
1697 }
1698
1699 auto const id = PublicKey(makeSlice(*keyBlob));
1700
1701 auto const iter = publisherLists_.find(id);
1702
1703 if (iter == publisherLists_.end() || iter->second.status != PublisherStatus::Available)
1704 return {};
1705
1706 json::Value value = buildFileData(std::string{pubKey}, iter->second, forceVersion, j_);
1707
1708 return value;
1709}
1710
1713 std::size_t unlSize,
1714 std::size_t effectiveUnlSize,
1715 std::size_t seenSize)
1716{
1717 // Use quorum if specified via command line.
1718 if (minimumQuorum_ > 0)
1719 {
1720 // NOLINTBEGIN(bugprone-unchecked-optional-access) minimumQuorum_ > 0 implies it has a value
1721 JLOG(j_.warn()) << "Using potentially unsafe quorum of " << *minimumQuorum_
1722 << " as specified on the command line";
1723 return *minimumQuorum_;
1724 // NOLINTEND(bugprone-unchecked-optional-access)
1725 }
1726
1727 if (!publisherLists_.empty())
1728 {
1729 // Do not use achievable quorum until lists from a sufficient number of
1730 // configured publishers are available
1731 std::size_t unavailable = 0;
1732 for (auto const& list : publisherLists_)
1733 {
1734 if (list.second.status != PublisherStatus::Available)
1735 unavailable += 1;
1736 }
1737 // There are two, subtly different, sides to list threshold:
1738 //
1739 // 1. The minimum required intersection between lists listThreshold_
1740 // for a validator to be included in trustedMasterKeys_.
1741 // If this many (or more) publishers are unavailable, we are likely
1742 // to NOT include a validator which otherwise would have been used.
1743 // We disable quorum if this happens.
1744 // 2. The minimum number of publishers which, when unavailable, will
1745 // prevent us from hitting the above threshold on ANY validator.
1746 // This is calculated as:
1747 // N - M + 1
1748 // where
1749 // N: number of publishers i.e. publisherLists_.size()
1750 // M: minimum required intersection i.e. listThreshold_
1751 // If this happens, we still have this local validator and we do not
1752 // want it to form a quorum of 1, so we disable quorum as well.
1753 //
1754 // We disable quorum if the number of unavailable publishers exceeds
1755 // either of the above thresholds
1756 auto const errorThreshold = std::min(
1757 listThreshold_, //
1758 publisherLists_.size() - listThreshold_ + 1);
1759 XRPL_ASSERT(
1760 errorThreshold > 0, "xrpl::ValidatorList::calculateQuorum : nonzero error threshold");
1761 if (unavailable >= errorThreshold)
1763 }
1764
1765 // Use an 80% quorum to balance fork safety, liveness, and required UNL
1766 // overlap.
1767 //
1768 // Theorem 8 of the Analysis of the XRP Ledger Consensus Protocol
1769 // (https://arxiv.org/abs/1802.07242) says:
1770 // XRP LCP guarantees fork safety if Oi,j > nj/2 + ni − qi + ti,j
1771 // for every pair of nodes Pi, Pj.
1772 //
1773 // ni: size of Pi's UNL
1774 // nj: size of Pj's UNL
1775 // Oi,j: number of validators in both UNLs
1776 // qi: validation quorum for Pi's UNL
1777 // ti, tj: maximum number of allowed Byzantine faults in Pi and Pj's
1778 // UNLs ti,j: min{ti, tj, Oi,j}
1779 //
1780 // Assume ni < nj, meaning and ti,j = ti
1781 //
1782 // For qi = .8*ni, we make ti <= .2*ni
1783 // (We could make ti lower and tolerate less UNL overlap. However in
1784 // order to prioritize safety over liveness, we need ti >= ni - qi)
1785 //
1786 // An 80% quorum allows two UNLs to safely have < .2*ni unique
1787 // validators between them:
1788 //
1789 // pi = ni - Oi,j
1790 // pj = nj - Oi,j
1791 //
1792 // Oi,j > nj/2 + ni − qi + ti,j
1793 // ni - pi > (ni - pi + pj)/2 + ni − .8*ni + .2*ni
1794 // pi + pj < .2*ni
1795 //
1796 // Note that the negative UNL protocol introduced the
1797 // AbsoluteMinimumQuorum which is 60% of the original UNL size. The
1798 // effective quorum should not be lower than it.
1799 return static_cast<std::size_t>(
1800 std::max(std::ceil(effectiveUnlSize * 0.8f), std::ceil(unlSize * 0.6f)));
1801}
1802
1805 HashSet<NodeID> const& seenValidators,
1806 NetClock::time_point closeTime,
1807 NetworkOPs& ops,
1808 Overlay& overlay,
1809 HashRouter& hashRouter)
1810{
1811 using namespace std::chrono_literals;
1812 if (timeKeeper_.now() > closeTime + 30s)
1813 closeTime = timeKeeper_.now();
1814
1816
1817 // Rotate pending and remove expired published lists
1818 bool good = true;
1819 // localPublisherList is not processed here. This is because the
1820 // Validators specified in the local config file do not expire nor do
1821 // they have a "remaining" section of PublisherList.
1822 for (auto& [pubKey, collection] : publisherLists_)
1823 {
1824 {
1825 auto& remaining = collection.remaining;
1826 auto const firstIter = remaining.begin();
1827 auto iter = firstIter;
1828 if (iter != remaining.end() && iter->second.validFrom <= closeTime)
1829 {
1830 // Find the LAST candidate that is ready to go live.
1831 for (auto next = std::next(iter);
1832 next != remaining.end() && next->second.validFrom <= closeTime;
1833 ++iter, ++next)
1834 {
1835 XRPL_ASSERT(
1836 std::next(iter) == next,
1837 "xrpl::ValidatorList::updateTrusted : sequential "
1838 "remaining");
1839 }
1840 XRPL_ASSERT(
1841 iter != remaining.end(),
1842 "xrpl::ValidatorList::updateTrusted : non-end of "
1843 "remaining");
1844
1845 // Rotate the pending list in to current
1846 auto const sequence = iter->first;
1847 auto& candidate = iter->second;
1848 auto& current = collection.current;
1849 XRPL_ASSERT(
1850 candidate.validFrom <= closeTime,
1851 "xrpl::ValidatorList::updateTrusted : maximum time");
1852
1853 auto const oldList = current.list;
1854 current = std::move(candidate);
1855 if (collection.status != PublisherStatus::Available)
1856 collection.status = PublisherStatus::Available;
1857 XRPL_ASSERT(
1858 current.sequence == sequence,
1859 "xrpl::ValidatorList::updateTrusted : sequence match");
1860 // If the list is expired, remove the validators so they don't
1861 // get processed in. The expiration check below will do the rest
1862 // of the work
1863 if (current.validUntil <= closeTime)
1864 current.list.clear();
1865
1866 updatePublisherList(pubKey, current, oldList, lock);
1867
1868 // Only broadcast the current, which will consequently only
1869 // send to peers that don't understand v2, or which are
1870 // unknown (unlikely). Those that do understand v2 should
1871 // already have this list and are in the process of
1872 // switching themselves.
1873 broadcastBlobs(pubKey, collection, sequence, current.hash, overlay, hashRouter, j_);
1874
1875 // Erase any candidates that we skipped over, plus this one
1876 remaining.erase(firstIter, std::next(iter));
1877 }
1878 }
1879 // Remove if expired
1880 // ValidatorLists specified in the local config file never expire.
1881 // Hence, the below steps are not relevant for localPublisherList
1882 if (collection.status == PublisherStatus::Available &&
1883 collection.current.validUntil <= closeTime)
1884 {
1886 ops.setUNLBlocked();
1887 }
1888 if (collection.status != PublisherStatus::Available)
1889 good = false;
1890 }
1891 if (good)
1892 ops.clearUNLBlocked();
1893
1894 TrustChanges trustChanges;
1895
1896 auto it = trustedMasterKeys_.cbegin();
1897 while (it != trustedMasterKeys_.cend())
1898 {
1899 auto const kit = keyListings_.find(*it);
1900 if (kit == keyListings_.end() || //
1901 kit->second < listThreshold_ || //
1902 validatorManifests_.revoked(*it))
1903 {
1904 trustChanges.removed.insert(calcNodeID(*it));
1905 it = trustedMasterKeys_.erase(it);
1906 }
1907 else
1908 {
1909 XRPL_ASSERT(
1910 kit->second >= listThreshold_,
1911 "xrpl::ValidatorList::updateTrusted : count meets threshold");
1912 ++it;
1913 }
1914 }
1915
1916 for (auto const& val : keyListings_)
1917 {
1918 if (val.second >= listThreshold_ && !validatorManifests_.revoked(val.first) &&
1919 trustedMasterKeys_.emplace(val.first).second)
1920 trustChanges.added.insert(calcNodeID(val.first));
1921 }
1922
1923 // If there were any changes, we need to update the ephemeral signing
1924 // keys:
1925 if (!trustChanges.added.empty() || !trustChanges.removed.empty())
1926 {
1927 trustedSigningKeys_.clear();
1928
1929 // trustedMasterKeys_ contain non-revoked manifests only. Hence the
1930 // manifests must contain a valid signingKey
1931 for (auto const& k : trustedMasterKeys_)
1932 {
1933 std::optional<PublicKey> const signingKey = validatorManifests_.getSigningKey(k);
1934 XRPL_ASSERT(signingKey, "xrpl::ValidatorList::updateTrusted : found signing key");
1935 trustedSigningKeys_.insert(
1936 *signingKey); // NOLINT(bugprone-unchecked-optional-access) assert above
1937 }
1938 }
1939
1940 JLOG(j_.debug()) << trustedMasterKeys_.size() << " of " << keyListings_.size()
1941 << " listed validators eligible for inclusion in the trusted set";
1942
1943 auto const unlSize = trustedMasterKeys_.size();
1944 auto effectiveUnlSize = unlSize;
1945 auto seenSize = seenValidators.size();
1946 if (!negativeUNL_.empty())
1947 {
1948 for (auto const& k : trustedMasterKeys_)
1949 {
1950 if (negativeUNL_.contains(k))
1951 --effectiveUnlSize;
1952 }
1953 HashSet<NodeID> negUnlNodeIDs;
1954 for (auto const& k : negativeUNL_)
1955 {
1956 negUnlNodeIDs.emplace(calcNodeID(k));
1957 }
1958 for (auto const& nid : seenValidators)
1959 {
1960 if (negUnlNodeIDs.contains(nid))
1961 --seenSize;
1962 }
1963 }
1964 quorum_ = calculateQuorum(unlSize, effectiveUnlSize, seenSize);
1965
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)";
1969
1970 if (unlSize < quorum_)
1971 {
1972 JLOG(j_.warn()) << "New quorum of " << quorum_
1973 << " exceeds the number of trusted validators (" << unlSize << ")";
1974 }
1975
1976 if ((!publisherLists_.empty() || !localPublisherList_.list.empty()) && unlSize == 0)
1977 {
1978 // No validators. Lock down.
1979 ops.setUNLBlocked();
1980 }
1981
1982 return trustChanges;
1983}
1984
1987{
1988 std::shared_lock const readLock{mutex_};
1989 return trustedMasterKeys_;
1990}
1991
1994{
1995 std::shared_lock const readLock{mutex_};
1996 return listThreshold_;
1997}
1998
2001{
2002 std::shared_lock const readLock{mutex_};
2003 return negativeUNL_;
2004}
2005
2006void
2008{
2010 negativeUNL_ = negUnl;
2011}
2012
2015{
2016 // Remove validations that are from validators on the negative UNL.
2017 auto ret = std::move(validations);
2018
2019 std::shared_lock readLock{mutex_};
2020 if (!negativeUNL_.empty())
2021 {
2022 ret.erase(
2024 ret,
2025 [&](auto const& v) -> bool {
2026 if (auto const masterKey = getTrustedKey(readLock, v->getSignerPublic());
2027 masterKey)
2028 {
2029 return negativeUNL_.contains(*masterKey);
2030 }
2031
2032 return false;
2033 })
2034 .begin(),
2035 ret.end());
2036 }
2037
2038 return ret;
2039}
2040
2041} // namespace xrpl
T accumulate(T... args)
T back(T... args)
T begin(T... args)
T canonical(T... args)
T ceil(T... args)
NetClock::time_point time_point
A generic endpoint for log messages.
Definition Journal.h:44
Stream debug() const
Definition Journal.h:344
Stream trace() const
Severity stream access functions.
Definition Journal.h:338
Unserialize a JSON document into a Value.
Definition json_reader.h:20
bool parse(std::string const &document, Value &root)
Read a Value from a JSON document.
Represents a JSON value.
Definition json_value.h:121
bool isArray() const
bool isString() const
Value & append(Value const &value)
Append value to array at the end.
UInt size() const
Number of values in array or object.
UInt asUInt() const
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.
Definition HashRouter.h:96
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.
Definition Manifest.h:374
static std::size_t totalSize(::google::protobuf::Message const &message)
Definition Message.cpp:59
std::chrono::time_point< NetClock > time_point
Definition chrono.h:48
Provides server functionality for clients.
Definition NetworkOPs.h:82
virtual void clearUNLBlocked()=0
virtual void setUNLBlocked()=0
Manages the set of connected peers.
Definition Overlay.h:40
virtual PeerSequence getActivePeers() const =0
Returns a sequence representing the current list of peers.
Represents a peer connection in the overlay.
virtual ID id() const =0
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
A public key.
Definition PublicKey.h:53
An immutable linear range of bytes.
Definition Slice.h:28
Manages various times used by the server.
Definition TimeKeeper.h:15
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.
TimeKeeper & timeKeeper_
HashSet< PublicKey > negativeUNL_
static constexpr std::size_t kMaxSupportedBlobs
void updatePublisherList(PublicKey const &pubKey, PublisherList const &current, 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_
beast::Journal const j_
std::shared_mutex mutex_
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 clear(T... args)
T contains(T... args)
T count(T... args)
T data(T... args)
T emplace_back(T... args)
T emplace(T... args)
T empty(T... args)
T end(T... args)
T file_size(T... args)
T lock(T... args)
T make_pair(T... args)
T make_shared(T... args)
T max(T... args)
T message(T... args)
T min(T... args)
unsigned int UInt
@ Array
array value (ordered list)
Definition json_value.h:32
@ Object
object value (collection of name/value pairs).
Definition json_value.h:33
@ Null
'null' value
Definition json_value.h:26
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
constexpr std::size_t kMaximumMessageSize
Definition Message.h:22
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)
Definition strHex.h:13
ListDisposition
@ 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.
@ Accepted
List is valid.
@ 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.
Definition AccountID.cpp:95
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.
Definition Manifest.h:201
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)
Definition base_uint.h:658
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).
Definition Manifest.h:365
Slice makeSlice(std::array< T, N > const &a)
Definition Slice.h:228
BaseUInt< 256 > UInt256
Definition base_uint.h:581
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.
PublisherStatus
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.
Definition digest.h:215
@ Accepted
Manifest is valid.
Definition Manifest.h:321
@ Invalid
Timely, but invalid signature.
Definition Manifest.h:329
T next(T... args)
T push_back(T... args)
T remove_if(T... args)
T reserve(T... args)
T reset(T... args)
T size(T... args)
T sort(T... args)
static bool revoked(std::uint32_t sequence)
Returns true if manifest revokes master key.
PublicKey masterKey
The master key associated with this manifest.
Definition Manifest.h:84
std::optional< PublicKey > signingKey
The ephemeral key associated with this manifest.
Definition Manifest.h:92
Changes in trusted nodes after updating validator list.
HashSet< NodeID > added
HashSet< NodeID > removed
Used to represent the information stored in the blobs_v2 Json array.
std::optional< std::string > manifest
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)
std::optional< PublicKey > publisherKey
std::map< ListDisposition, std::size_t > dispositions
std::vector< PublicKey > list
TimeKeeper::time_point validFrom
TimeKeeper::time_point validUntil
std::vector< std::string > manifests
T value(T... args)