xrpld
Loading...
Searching...
No Matches
xrpl::test::csf Namespace Reference

Classes

class  Validations_test
class  BasicNetwork
 Peer to peer network simulator. More...
class  CollectorRef
 Holds a type-erased reference to an arbitrary collector. More...
class  CollectorRefs
 A container of CollectorRefs. More...
class  Collectors
 Group of collectors. More...
struct  CollectByNode
 Maintain an instance of a Collector per peer. More...
struct  NullCollector
 Collector which ignores all events. More...
struct  SimDurationCollector
 Tracks the overall duration of a simulation. More...
struct  TxCollector
 Tracks the submission -> accepted -> validated evolution of transactions. More...
struct  LedgerCollector
 Tracks the accepted -> validated evolution of ledgers. More...
struct  StreamCollector
 Write out stream of ledger activity. More...
struct  JumpCollector
 Saves information about Jumps for closed and fully validated ledgers. More...
class  Digraph
 Directed graph. More...
struct  Share
 A value to be flooded to all other peers starting from this peer. More...
struct  Relay
 A value relayed to another peer as part of flooding. More...
struct  Receive
 A value received from another peer as part of flooding. More...
struct  SubmitTx
 A transaction submitted to a peer. More...
struct  StartRound
 Peer starts a new consensus round. More...
struct  CloseLedger
 Peer closed the open ledger. More...
struct  AcceptLedger
 Peer accepted consensus results. More...
struct  WrongPrevLedger
 Peer detected a wrong prior ledger during consensus. More...
struct  FullyValidateLedger
 Peer fully validated a new ledger. More...
class  Histogram
 Basic histogram. More...
class  Ledger
 A ledger is a set of observed transactions and a sequence number identifying the ledger. More...
class  LedgerOracle
 Oracle maintaining unique ledgers for a simulation. More...
struct  LedgerHistoryHelper
 Helper for writing unit tests with controlled ledger histories. More...
struct  Peer
 A single peer in the simulation. More...
class  PeerGroup
 A group of simulation Peers. More...
class  Selector
 Invocable that returns random samples from a range according to a discrete distribution. More...
class  ConstantDistribution
 Constant "distribution" that always returns the same value. More...
class  PowerLawDistribution
 Power-law distribution with PDF. More...
class  Scheduler
 Simulated discrete-event scheduler. More...
class  BasicSink
 Sink that prepends simulation time to messages. More...
class  Sim
struct  Rate
 Represents rate as a count/duration. More...
class  Submitter
 Submits transactions to a specified peer. More...
class  HeartbeatTimer
 Gives heartbeat of simulation to signal simulation progression. More...
class  TrustGraph
 Trust graph. More...
class  Tx
 A single transaction. More...
class  TxSet
 TxSet is a set of transactions to consider including in the ledger. More...
class  Validation
 Validation of a specific ledger by a specific Peer. More...

Typedefs

using Proposal = ConsensusProposal<PeerID, Ledger::ID, TxSet::ID>
 Proposal is a position taken in the consensus process and is represented directly from the generic types.
using RealClock = std::chrono::system_clock
using RealDuration = RealClock::duration
using RealTime = RealClock::time_point
using SimClock = beast::ManualClock<std::chrono::steady_clock>
using SimDuration = SimClock::duration
using SimTime = SimClock::time_point
using TxSetType = boost::container::flat_set<Tx>
using PeerID = TaggedInteger<std::uint32_t, PeerIDTag>
using PeerKey = std::pair<PeerID, std::uint32_t>
 The current key of a peer.

Functions

 BEAST_DEFINE_TESTSUITE (Validations, consensus, xrpl)
template<class... Cs>
Collectors< Cs... > makeCollectors (Cs &... cs)
 Create an instance of Collectors<Cs...>.
Ledger::Seq mismatch (Ledger const &a, Ledger const &b)
template<class RandomNumberDistribution, class Generator>
std::vector< PeerGrouprandomRankedGroups (PeerGroup &peers, std::vector< double > const &ranks, int numGroups, RandomNumberDistribution sizeDist, Generator &g)
 Randomly generate peer groups according to ranks.
template<class RandomNumberDistribution, class Generator>
void randomRankedTrust (PeerGroup &peers, std::vector< double > const &ranks, int numGroups, RandomNumberDistribution sizeDist, Generator &g)
 Generate random trust groups based on peer rankings.
template<class RandomNumberDistribution, class Generator>
void randomRankedConnect (PeerGroup &peers, std::vector< double > const &ranks, int numGroups, RandomNumberDistribution sizeDist, Generator &g, SimDuration delay)
 Generate random network groups based on peer rankings.
template<class T, class G>
std::vector< T > randomWeightedShuffle (std::vector< T > v, std::vector< double > w, G &g)
 Return a randomly shuffled copy of vector based on weights w.
template<class RandomNumberDistribution, class Generator>
std::vector< typename RandomNumberDistribution::result_type > sample (std::size_t size, RandomNumberDistribution dist, Generator &g)
 Generate a vector of random samples.
template<typename Iter, typename Generator>
Selector< Iter, Generator > makeSelector (Iter first, Iter last, std::vector< double > const &w, Generator &g)
template<class Distribution, class Generator, class Selector>
Submitter< Distribution, Generator, SelectormakeSubmitter (Distribution dist, SimTime start, SimTime end, Selector &sel, Scheduler &s, Generator &g)
std::ostreamoperator<< (std::ostream &o, Tx const &t)
template<class T>
std::ostreamoperator<< (std::ostream &o, boost::container::flat_set< T > const &ts)
std::string to_string (TxSetType const &txs)
template<class Hasher>
void hash_append (Hasher &h, Tx const &tx)

Typedef Documentation

◆ Proposal

Proposal is a position taken in the consensus process and is represented directly from the generic types.

Definition at line 13 of file Proposal.h.

◆ RealClock

Definition at line 9 of file SimTime.h.

◆ RealDuration

using xrpl::test::csf::RealDuration = RealClock::duration

Definition at line 10 of file SimTime.h.

◆ RealTime

using xrpl::test::csf::RealTime = RealClock::time_point

Definition at line 11 of file SimTime.h.

◆ SimClock

◆ SimDuration

Definition at line 14 of file SimTime.h.

◆ SimTime

Definition at line 15 of file SimTime.h.

◆ TxSetType

using xrpl::test::csf::TxSetType = boost::container::flat_set<Tx>

All sets of Tx are represented as a flat_set for performance.

Definition at line 58 of file Tx.h.

◆ PeerID

Definition at line 15 of file Validation.h.

◆ PeerKey

The current key of a peer.

Eventually, the second entry in the pair can be used to model ephemeral keys. Right now, the convention is to have the second entry 0 as the master key.

Definition at line 23 of file Validation.h.

Function Documentation

◆ BEAST_DEFINE_TESTSUITE()

xrpl::test::csf::BEAST_DEFINE_TESTSUITE ( Validations ,
consensus ,
xrpl  )

◆ makeCollectors()

template<class... Cs>
Collectors< Cs... > xrpl::test::csf::makeCollectors ( Cs &... cs)

Create an instance of Collectors<Cs...>.

Definition at line 71 of file collectors.h.

◆ mismatch()

Ledger::Seq xrpl::test::csf::mismatch ( Ledger const & a,
Ledger const & b )

Definition at line 48 of file ledgers.cpp.

◆ randomRankedGroups()

template<class RandomNumberDistribution, class Generator>
std::vector< PeerGroup > xrpl::test::csf::randomRankedGroups ( PeerGroup & peers,
std::vector< double > const & ranks,
int numGroups,
RandomNumberDistribution sizeDist,
Generator & g )

Randomly generate peer groups according to ranks.

Generates random peer groups based on a provided ranking of peers. This mimics a process of randomly generating UNLs, where more "important" peers are more likely to appear in a UNL.

numGroups subgroups are generated by randomly sampling without without replacement from peers according to the ranks.

Parameters
peersThe group of peers
ranksThe relative importance of each peer, must match the size of peers. Higher relative rank means more likely to be sampled.
numGroupsThe number of peer link groups to generate
sizeDistThe distribution that determines the size of a link group
gThe uniform random bit generator

Definition at line 268 of file PeerGroup.h.

◆ randomRankedTrust()

template<class RandomNumberDistribution, class Generator>
void xrpl::test::csf::randomRankedTrust ( PeerGroup & peers,
std::vector< double > const & ranks,
int numGroups,
RandomNumberDistribution sizeDist,
Generator & g )

Generate random trust groups based on peer rankings.

See also
randomRankedGroups for descriptions of the arguments

Definition at line 295 of file PeerGroup.h.

◆ randomRankedConnect()

template<class RandomNumberDistribution, class Generator>
void xrpl::test::csf::randomRankedConnect ( PeerGroup & peers,
std::vector< double > const & ranks,
int numGroups,
RandomNumberDistribution sizeDist,
Generator & g,
SimDuration delay )

Generate random network groups based on peer rankings.

See also
randomRankedGroups for descriptions of the arguments

Definition at line 318 of file PeerGroup.h.

◆ randomWeightedShuffle()

template<class T, class G>
std::vector< T > xrpl::test::csf::randomWeightedShuffle ( std::vector< T > v,
std::vector< double > w,
G & g )

Return a randomly shuffled copy of vector based on weights w.

Parameters
vThe set of values
wThe set of weights of each value
gA pseudo-random number generator
Returns
A vector with entries randomly sampled without replacement from the original vector based on the provided weights. I.e. res[0] comes from sample v[i] with weight w[i]/suk_ w[k]

Definition at line 19 of file src/test/csf/random.h.

◆ sample()

template<class RandomNumberDistribution, class Generator>
std::vector< typename RandomNumberDistribution::result_type > xrpl::test::csf::sample ( std::size_t size,
RandomNumberDistribution dist,
Generator & g )

Generate a vector of random samples.

Parameters
sizethe size of the sample
distthe distribution to sample
gthe pseudo-random number generator
Returns
vector of samples

Definition at line 44 of file src/test/csf/random.h.

◆ makeSelector()

template<typename Iter, typename Generator>
Selector< Iter, Generator > xrpl::test::csf::makeSelector ( Iter first,
Iter last,
std::vector< double > const & w,
Generator & g )

Definition at line 92 of file src/test/csf/random.h.

◆ makeSubmitter()

template<class Distribution, class Generator, class Selector>
Submitter< Distribution, Generator, Selector > xrpl::test::csf::makeSubmitter ( Distribution dist,
SimTime start,
SimTime end,
Selector & sel,
Scheduler & s,
Generator & g )

Definition at line 95 of file submitters.h.

◆ operator<<() [1/2]

std::ostream & xrpl::test::csf::operator<< ( std::ostream & o,
Tx const & t )

Definition at line 170 of file Tx.h.

◆ operator<<() [2/2]

template<class T>
std::ostream & xrpl::test::csf::operator<< ( std::ostream & o,
boost::container::flat_set< T > const & ts )

Definition at line 177 of file Tx.h.

◆ to_string()

std::string xrpl::test::csf::to_string ( TxSetType const & txs)

Definition at line 199 of file Tx.h.

◆ hash_append()

template<class Hasher>
void xrpl::test::csf::hash_append ( Hasher & h,
Tx const & tx )

Definition at line 208 of file Tx.h.