20 #ifndef RIPPLE_APP_MISC_VALIDATORLIST_H_INCLUDED
21 #define RIPPLE_APP_MISC_VALIDATORLIST_H_INCLUDED
23 #include <ripple/app/misc/Manifest.h>
24 #include <ripple/basics/Log.h>
25 #include <ripple/basics/UnorderedContainers.h>
26 #include <ripple/core/TimeKeeper.h>
27 #include <ripple/crypto/csprng.h>
28 #include <ripple/json/json_value.h>
29 #include <ripple/overlay/Message.h>
30 #include <ripple/protocol/PublicKey.h>
31 #include <boost/iterator/counting_iterator.hpp>
32 #include <boost/range/adaptors.hpp>
33 #include <boost/thread/shared_mutex.hpp>
39 class TMValidatorList;
40 class TMValidatorListCollection;
347 parseBlobs(protocol::TMValidatorList
const& body);
350 parseBlobs(protocol::TMValidatorListCollection
const& body);
618 uint256 const& hash)> func)
const;
625 boost::beast::string_view
const& pubKey,
772 PublisherList
const& current,
779 PublisherListCollection
const& lists);
787 PublisherListCollection
const& lists,
809 boost::filesystem::path
818 PublisherListCollection
const& pubCollection,
827 PublisherListCollection
const& pubCollection,
831 template <
class Hasher>
895 template <
class Hasher>
907 template <
class Hasher>
911 for (
auto const& item : blobs)
915 template <
class Hasher>
919 for (
auto const& [_, item] : blobs)
930 template <
class Hasher>
935 hash_append(h, msg.manifest(), msg.blob(), msg.signature(), msg.version());
938 template <
class Hasher>
Provides server functionality for clients.
MessageWithHash()=default
ManifestCache & validatorManifests_
@ pending
List will be valid in the future.
void for_each_listed(std::function< void(PublicKey const &, bool)> func) const
Invokes the callback once for every listed validation public key.
PublicKey localPublicKey() const
Returns local validator public key.
PublisherListStats()=default
constexpr std::size_t maximiumMessageSize
std::shared_ptr< Message > message
Changes in trusted nodes after updating validator list.
@ stale
Trusted publisher key, but seq is too old.
static constexpr std::uint32_t supportedListVersions[]
static void buildBlobInfos(std::map< std::size_t, ValidatorBlobInfo > &blobInfos, PublisherListCollection const &lists)
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.
void setNegativeUNL(hash_set< PublicKey > const &negUnl)
set the Negative UNL with validators' master public keys
QuorumKeys getQuorumKeys() const
Get the quorum and all of the trusted keys.
Describes the result of processing a Validator List (UNL), including some of the information from the...
hash_set< PublicKey > negativeUNL_
static const std::string filePrefix_
TimeKeeper::time_point validUntil
hash_set< PublicKey > getTrustedMasterKeys() const
get the trusted master 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 constexpr std::size_t maxSupportedBlobs
std::lock_guard< decltype(mutex_)> lock_guard
ListDisposition bestDisposition() const
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...
@ expired
List is expired, but has the largest non-pending sequence seen so far.
Routing table for objects identified by hash.
std::optional< std::size_t > maxSequence
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)
bool removePublisherList(lock_guard const &, PublicKey const &publisherKey, PublisherStatus reason)
Stop trusting publisher's list of keys.
void cacheValidatorFile(lock_guard const &lock, PublicKey const &pubKey) const
Write a JSON UNL to a cache file.
friend void hash_append(Hasher &h, PublisherListCollection pl)
ValidatorList(ManifestCache &validatorManifests, ManifestCache &publisherManifests, TimeKeeper &timeKeeper, std::string const &databasePath, beast::Journal j, std::optional< std::size_t > minimumQuorum=std::nullopt)
const boost::filesystem::path dataPath_
boost::filesystem::path getCacheFileName(lock_guard const &, PublicKey const &pubKey) const
Get the filename used for caching UNLs.
ListDisposition verify(lock_guard const &, Json::Value &list, PublicKey &pubKey, std::string const &manifest, std::string const &blob, std::string const &signature)
Check response for trusted valid published list.
void mergeDispositions(PublisherListStats const &src)
std::vector< PublicKey > list
std::optional< PublicKey > getListedKey(PublicKey const &identity) const
Returns listed master public if public key is included on any lists.
Used to represent the information stored in the blobs_v2 Json array.
hash_set< NodeID > removed
TrustChanges updateTrusted(hash_set< NodeID > const &seenValidators, NetClock::time_point closeTime, NetworkOPs &ops, Overlay &overlay, HashRouter &hashRouter)
Update trusted nodes.
std::map< std::size_t, PublisherList > remaining
ManifestCache & publisherManifests_
static void broadcastBlobs(PublicKey const &publisherKey, PublisherListCollection const &lists, std::size_t maxSequence, uint256 const &hash, Overlay &overlay, HashRouter &hashRouter, beast::Journal j)
std::vector< std::string > manifests
bool listed(PublicKey const &identity) const
Returns true if public key is included on any lists.
std::optional< Json::Value > getAvailable(boost::beast::string_view const &pubKey, std::optional< std::uint32_t > forceVersion={})
Returns the current valid list for the given publisher key, if available, as a Json object.
@ untrusted
List signed by untrusted publisher key.
A generic endpoint for log messages.
Manages various times used by the server.
@ unsupported_version
List version is not supported.
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,...
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.
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.
@ known_sequence
Future sequence already seen.
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.
Remembers manifests with the highest sequence number.
std::vector< std::string > loadLists()
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
hash_set< PublicKey > trustedSigningKeys_
bool load(PublicKey const &localSigningKey, std::vector< std::string > const &configKeys, std::vector< std::string > const &publisherKeys)
Load configured trusted keys.
Manages the set of connected peers.
@ same_sequence
Same sequence as current list.
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.
@ invalid
Invalid format or signature.
TimeKeeper::time_point validFrom
boost::shared_mutex mutex_
std::shared_lock< decltype(mutex_)> shared_lock
ListDisposition worstDisposition() const
std::optional< PublicKey > publisherKey
Json::Value getJson() const
Return a JSON representation of the state of the validator list.
std::string to_string(Manifest const &m)
Format the specified manifest to a string for debugging purposes.
std::optional< std::string > rawManifest
std::optional< std::string > manifest
std::map< ListDisposition, std::size_t > dispositions
bool trusted(PublicKey const &identity) const
Returns true if public key is trusted.
hash_set< PublicKey > trustedMasterKeys_
hash_set< PublicKey > getNegativeUNL() const
get the master public keys of Negative UNL validators
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.
void hash_append(Hasher &h, ValidatorBlobInfo const &blobInfo)
std::size_t count() const
Return the number of configured validator list sites.
typename NetClock ::time_point time_point
hash_map< PublicKey, PublisherListCollection > publisherLists_
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.
hash_map< PublicKey, std::size_t > keyListings_
std::atomic< std::size_t > quorum_
void updatePublisherList(PublicKey const &pubKey, PublisherList const ¤t, std::vector< PublicKey > const &oldList, lock_guard const &)
void hash_append(Hasher &h, TMValidatorList const &msg)
std::size_t quorum() const
Get quorum value for current trusted key set.
std::optional< std::size_t > minimumQuorum_
Represents a peer connection in the overlay.