consensus-test
Safe HaskellSafe-Inferred
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

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

data PointSchedule blk Source #

Constructors

PointSchedule 

Fields

data RunGenesisTestResult Source #

All the data describing the result of a test

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.

Also shifts all tick start times so that the first tip point is announced at the very beginning of the test, keeping the relative delays of the schedule intact. This is a preliminary measure to make the long range attack test work, since that relies on the honest node sending headers later than the adversary, which is not possible if the adversary's first tip point is delayed by 20 or more seconds due to being in a later slot.

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 ∷ (schedule → [String]) → GenesisTest TestBlock schedule → [String] Source #

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

Wrap a ST generator in Gen.