20#ifndef RIPPLE_APP_MISC_VALIDATORLIST_H_INCLUDED 
   21#define RIPPLE_APP_MISC_VALIDATORLIST_H_INCLUDED 
   23#include <xrpld/app/misc/Manifest.h> 
   24#include <xrpld/core/TimeKeeper.h> 
   25#include <xrpld/overlay/Message.h> 
   27#include <xrpl/basics/Log.h> 
   28#include <xrpl/basics/UnorderedContainers.h> 
   29#include <xrpl/crypto/csprng.h> 
   30#include <xrpl/json/json_value.h> 
   31#include <xrpl/protocol/PublicKey.h> 
   33#include <boost/thread/shared_mutex.hpp> 
   40class TMValidatorListCollection;
 
 
  361    parseBlobs(protocol::TMValidatorList 
const& body);
 
  364    parseBlobs(protocol::TMValidatorListCollection 
const& body);
 
  486        hash_set<NodeID> 
const& seenValidators,
 
  490        HashRouter& hashRouter);
 
  633            uint256 const& hash)> func) 
const;
 
  803        PublisherListCollection 
const& lists);
 
  811        PublisherListCollection 
const& lists,
 
  833    boost::filesystem::path
 
  842        PublisherListCollection 
const& pubCollection,
 
  851        PublisherListCollection 
const& pubCollection,
 
  855    template <
class Hasher>
 
 
  918template <
class Hasher>
 
  930template <
class Hasher>
 
  934    for (
auto const& item : blobs)
 
 
  938template <
class Hasher>
 
  942    for (
auto const& [_, item] : blobs)
 
 
  953template <
class Hasher>
 
  958    hash_append(h, msg.manifest(), msg.blob(), msg.signature(), msg.version());
 
 
  961template <
class Hasher>
 
A generic endpoint for log messages.
 
typename Clock::time_point time_point
 
Routing table for objects identified by hash.
 
Remembers manifests with the highest sequence number.
 
std::chrono::time_point< NetClock > time_point
 
Provides server functionality for clients.
 
Manages the set of connected peers.
 
Represents a peer connection in the overlay.
 
Manages various times used by the server.
 
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.
 
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_
 
hash_set< PublicKey > getTrustedMasterKeys() const
get the trusted master public keys
 
std::atomic< std::size_t > quorum_
 
void updatePublisherList(PublicKey const &pubKey, PublisherList const ¤t, std::vector< PublicKey > const &oldList, lock_guard const &)
 
void setNegativeUNL(hash_set< PublicKey > const &negUnl)
set the Negative UNL with validators' master public keys
 
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.
 
std::size_t listThreshold_
 
void cacheValidatorFile(lock_guard const &lock, PublicKey const &pubKey) const
Write a JSON UNL to a cache file.
 
hash_set< PublicKey > trustedMasterKeys_
 
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.
 
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.
 
hash_set< PublicKey > negativeUNL_
 
Json::Value getJson() const
Return a JSON representation of the state of the validator list.
 
void for_each_available(std::function< void(std::string const &manifest, std::uint32_t version, std::map< std::size_t, ValidatorBlobInfo > const &blobInfos, PublicKey const &pubKey, std::size_t maxSequence, uint256 const &hash)> func) const
Invokes the callback once for every available publisher list's raw data members.
 
std::optional< TimeKeeper::time_point > expires() const
Return the time when the validator list will expire.
 
std::size_t calculateQuorum(std::size_t unlSize, std::size_t effectiveUnlSize, std::size_t seenSize)
Return quorum for trusted validator set.
 
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::lock_guard< decltype(mutex_)> lock_guard
 
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_
 
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
 
TrustChanges updateTrusted(hash_set< NodeID > const &seenValidators, NetClock::time_point closeTime, NetworkOPs &ops, Overlay &overlay, HashRouter &hashRouter)
Update trusted nodes.
 
std::size_t getListThreshold() const
get the validator list threshold
 
void for_each_listed(std::function< void(PublicKey const &, bool)> func) const
Invokes the callback once for every listed validation public key.
 
std::optional< PublicKey > localPubKey_
 
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.
 
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::optional< std::size_t > minimumQuorum_
 
std::pair< ListDisposition, std::optional< PublicKey > > verify(lock_guard const &, Json::Value &list, Manifest manifest, std::string const &blob, std::string const &signature)
Check response for trusted valid published list.
 
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::size_t quorum() const
Get quorum value for current trusted key set.
 
static std::string const filePrefix_
 
hash_set< PublicKey > trustedSigningKeys_
 
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)
 
QuorumKeys getQuorumKeys() const
Get the quorum and all of the trusted keys.
 
std::shared_lock< decltype(mutex_)> shared_lock
 
ManifestCache & publisherManifests_
 
static constexpr std::uint32_t supportedListVersions[]
 
hash_set< PublicKey > getNegativeUNL() const
get the master public keys of Negative UNL validators
 
friend void hash_append(Hasher &h, PublisherListCollection pl)
 
std::enable_if_t< is_contiguously_hashable< T, Hasher >::value > hash_append(Hasher &h, T const &t) noexcept
Logically concatenate input data to a Hasher.
 
void hash_append(Hasher &h, TMValidatorList const &msg)
 
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
 
void hash_append(Hasher &h, Slice const &v)
 
@ current
This was a new validation and was added.
 
@ unsupported_version
List version is not supported.
 
@ 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.
 
@ stale
Sequence is too old.
 
@ accepted
Manifest is valid.
 
@ invalid
Timely, but invalid signature.
 
std::string to_string(base_uint< Bits, Tag > const &a)
 
constexpr std::size_t maximiumMessageSize
 
Changes in trusted nodes after updating validator list.
 
hash_set< NodeID > removed
 
Used to represent the information stored in the blobs_v2 Json array.
 
std::optional< std::string > manifest
 
MessageWithHash()=default
 
std::shared_ptr< Message > message
 
std::map< std::size_t, PublisherList > remaining
 
std::optional< std::size_t > maxSequence
 
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
 
std::optional< std::string > rawManifest
 
TimeKeeper::time_point validUntil
 
TimeKeeper::time_point validFrom
 
std::vector< std::string > manifests