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?

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.

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 #

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

data NodeState blk Source #

The state of a peer at a given point in time.

Constructors

NodeState 

Fields

Instances

Instances details
Show blk ⇒ Show (NodeState blk) Source # 
Instance details

Defined in Test.Consensus.PointSchedule

Methods

showsPrecIntNodeState blk → ShowS #

showNodeState blk → String #

showList ∷ [NodeState blk] → ShowS #

Eq blk ⇒ Eq (NodeState blk) Source # 
Instance details

Defined in Test.Consensus.PointSchedule

Methods

(==)NodeState blk → NodeState blk → Bool #

(/=)NodeState blk → NodeState blk → Bool #

Condense (NodeState TestBlock) Source # 
Instance details

Defined in Test.Consensus.PointSchedule

CondenseList (NodeState TestBlock) Source # 
Instance details

Defined in Test.Consensus.PointSchedule

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

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 (PeersSchedule 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.

nsTipTipHasHeader blk ⇒ NodeState blk → Tip blk Source #

peerSchedulesBlocksPeersSchedule 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

peersStatesPeersSchedule 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.

peersStatesRelativePeersSchedule 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.

uniformPoints ∷ (StatefulGen g m, HasHeader blk) ⇒ BlockTree blk → g → m (PeersSchedule blk) Source #

Generate a schedule in which the trunk and branches are served by one peer each, using a single tip point, without specifically assigned delay intervals like in newLongRangeAttack.

Include rollbacks in a percentage of adversaries, in which case that peer uses two branchs.