consensus-diffusion-test
Safe HaskellNone
LanguageHaskell2010

Test.Consensus.PointSchedule

Description

Data types and generators for point schedules.

Each generator takes a set of AnchoredFragments corresponding to the tested peers' chains, and converts them to a point schedule consisting of a sequence of NodeStates, each of which is associated with a single peer.

When a schedule is executed in a test, each tick is processed in order. The peer associated with the current tick is considered "active", which means that its ChainSync server is allowed to continue processing messages, while all the other peers' servers suspend operation by blocking on a concurrency primitive. The state in the current tick determines the actions that the peer is allowed to perform, and once it fulfills the state's criteria, it yields control back to the scheduler, who then activates the next tick's peer.

Synopsis

Documentation

data BlockFetchTimeout Source #

Similar to ChainSyncTimeout for BlockFetch. Only the states in which the server has agency are specified. REVIEW: Should it be upstreamed to ouroboros-network-protocols?

data CSJParams Source #

Constructors

CSJParams 

Fields

Instances

Instances details
Show CSJParams Source # 
Instance details

Defined in Test.Consensus.PointSchedule

Methods

showsPrecIntCSJParamsShowS #

showCSJParamsString #

showList ∷ [CSJParams] → ShowS #

newtype ForecastRange Source #

Constructors

ForecastRange 

Instances

Instances details
Show ForecastRange Source # 
Instance details

Defined in Test.Consensus.PointSchedule

data GenesisTest blk schedule Source #

All the data used by point schedule tests.

Constructors

GenesisTest 

Fields

Instances

Instances details
Functor (GenesisTest blk) Source # 
Instance details

Defined in Test.Consensus.PointSchedule

Methods

fmap ∷ (a → b) → GenesisTest blk a → GenesisTest blk b #

(<$) ∷ a → GenesisTest blk b → GenesisTest blk a #

newtype GenesisWindow Source #

Size of the Genesis window, in number of slots.

This is the number of slots that the GDD Governor (Genesis Density Disconnection Governor -- see Governor) will consider when deciding whether to disconnect from a peer. It has to be smaller or equal to the stability window. For instance, for Shelley-based eras, this will be equal to a stability window, that is 3k/f.

Constructors

GenesisWindow 

Instances

Instances details
Num GenesisWindow 
Instance details

Defined in Ouroboros.Consensus.Block.Abstract

Show GenesisWindow 
Instance details

Defined in Ouroboros.Consensus.Block.Abstract

Eq GenesisWindow 
Instance details

Defined in Ouroboros.Consensus.Block.Abstract

Ord GenesisWindow 
Instance details

Defined in Ouroboros.Consensus.Block.Abstract

NoThunks GenesisWindow 
Instance details

Defined in Ouroboros.Consensus.Block.Abstract

class HasPointScheduleTestParams blk where Source #

This class exists to house some of the functions required of a block type in order to be used by point schedule tests in nodeLifecycle. It was introduced to help generalize the tests from TestBlocks to live block types. It has no laws, and all these functions have in common is that they provide bits of state required to run the tests that did not already have a class to live in.

Associated Types

data ProtocolInfoArgs blk Source #

Methods

getProtocolInfoArgsIO (ProtocolInfoArgs blk) Source #

The requirement of IO comes from needing to parse configuration files.

mkProtocolInfoSecurityParamForecastRangeGenesisWindowProtocolInfoArgs blk → ProtocolInfo blk Source #

getChunkInfoFromTopLevelConfigTopLevelConfig blk → ChunkInfo Source #

Instances

Instances details
a ~ () ⇒ HasPointScheduleTestParams (TestBlockWith a) Source #

If you are here because you tried to implement HasPointScheduleTestParams for some type `TestBlockWith Foo` and got an overlapping instance warning, the `a ~ ()` constraint is only here to get your attention. The tests should remain as block polymorphic as possible, so maybe there should be a class for the types a that can appear in `TestBlockWith a`. But we in the past do not know what that class should look like! So the choice is yours: if what you need from this class can be made polymorphic in a, consider adding a class. If not, specialize this instance.

Instance details

Defined in Test.Consensus.PeerSimulator.Config

type PeerSchedule blk = [(Time, SchedulePoint blk)] Source #

data PointSchedule blk Source #

Constructors

PointSchedule 

Fields

data RunGenesisTestResult blk Source #

All the data describing the result of a test

Constructors

RunGenesisTestResult 

enrichedWith ∷ (Functor f, Monad m) ⇒ m (f a) → (f a → m b) → m (f b) Source #

longRangeAttack ∷ (StatefulGen g m, HasHeader blk) ⇒ BlockTree blk → g → m (PointSchedule blk) Source #

Produce a schedule similar to Frequencies (Peers 1 [10]), using the new SinglePeer generator.

We hardcode the two schedules to use the latest block as the initial tip point. The honest peer gets a substantially larger (and disconnected) delay interval to ensure that k+1 blocks are sent fast enough to trigger selection of a fork.

peerSchedulesBlocksPeers (PeerSchedule blk) → [blk] Source #

List of all blocks appearing in the schedules.

peerStatesPeer (PeerSchedule blk) → [(Time, Peer (NodeState blk))] Source #

Convert a SinglePeer schedule to a NodeState schedule.

Accumulates the new points in each tick into the previous state, starting with a set of all Origin points.

Finally, drops the first state, since all points being Origin (in particular the tip) has no useful effects in the simulator, but it could set the tip in the GDD governor to Origin, which causes slow nodes to be disconnected right away.

TODO Remove dropping the first state in favor of better GDD logic

peersStatesPointSchedule blk → [(Time, Peer (NodeState blk))] Source #

Convert several SinglePeer schedules to a common NodeState schedule.

The resulting schedule contains all the peers. Items are sorted by time.

peersStatesRelativePointSchedule blk → [(DiffTime, Peer (NodeState blk))] Source #

Same as peersStates but returns the duration of a state instead of the absolute time at which it starts holding.

prettyGenesisTest ∷ (HasHeader blk, Terse blk) ⇒ (schedule → [String]) → GenesisTest blk schedule → [String] Source #

stToGen ∷ (∀ s. STGenM QCGen s → ST s a) → Gen a Source #

Wrap a ST generator in Gen.

timeLimitsChainSyncChainSyncTimeoutProtocolTimeLimits (ChainSync header point tip) Source #

Time Limits

'TokIdle'               'waitForever' (ie never times out)
'TokNext TokCanAwait'   the given 'canAwaitTimeout'
'TokNext TokMustReply'  the given 'mustReplyTimeout'
'TokIntersect'          the given 'intersectTimeout'