Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Data types and generators for point schedules.
Each generator takes a set of AnchoredFragment
s corresponding to the tested
peers' chains, and converts them to a point schedule consisting of a sequence
of NodeState
s, 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
- data BlockFetchTimeout = BlockFetchTimeout {}
- newtype ForecastRange = ForecastRange {}
- data GenesisTest blk schedule = GenesisTest {}
- type GenesisTestFull blk = GenesisTest blk (PeersSchedule blk)
- newtype GenesisWindow = GenesisWindow {}
- data LoPBucketParams = LoPBucketParams {}
- data NodeState blk = NodeState {
- nsTip ∷ WithOrigin blk
- nsHeader ∷ WithOrigin blk
- nsBlock ∷ WithOrigin blk
- type PeerSchedule blk = [(Time, SchedulePoint blk)]
- type PeersSchedule blk = Peers (PeerSchedule blk)
- data RunGenesisTestResult = RunGenesisTestResult {}
- enrichedWith ∷ (Functor f, Monad m) ⇒ m (f a) → (f a → m b) → m (f b)
- genesisNodeState ∷ NodeState blk
- longRangeAttack ∷ (StatefulGen g m, HasHeader blk) ⇒ BlockTree blk → g → m (PeersSchedule blk)
- nsTipTip ∷ HasHeader blk ⇒ NodeState blk → Tip blk
- peerSchedulesBlocks ∷ PeersSchedule blk → [blk]
- peerStates ∷ Peer (PeerSchedule blk) → [(Time, Peer (NodeState blk))]
- peersStates ∷ PeersSchedule blk → [(Time, Peer (NodeState blk))]
- peersStatesRelative ∷ PeersSchedule blk → [(DiffTime, Peer (NodeState blk))]
- prettyGenesisTest ∷ (schedule → [String]) → GenesisTest TestBlock schedule → [String]
- prettyPeersSchedule ∷ ∀ blk. CondenseList (NodeState blk) ⇒ PeersSchedule blk → [String]
- stToGen ∷ (∀ s. STGenM QCGen s → ST s a) → Gen a
- uniformPoints ∷ (StatefulGen g m, HasHeader blk) ⇒ BlockTree blk → g → m (PeersSchedule blk)
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 #
Instances
Show ForecastRange Source # | |
Defined in Test.Consensus.PointSchedule showsPrec ∷ Int → ForecastRange → ShowS # show ∷ ForecastRange → String # showList ∷ [ForecastRange] → ShowS # |
data GenesisTest blk schedule Source #
All the data used by point schedule tests.
Instances
Functor (GenesisTest blk) Source # | |
Defined in Test.Consensus.PointSchedule fmap ∷ (a → b) → GenesisTest blk a → GenesisTest blk b # (<$) ∷ a → GenesisTest blk b → GenesisTest blk a # |
type GenesisTestFull blk = GenesisTest blk (PeersSchedule blk) Source #
newtype GenesisWindow Source #
Instances
Num GenesisWindow | |
Defined in Ouroboros.Consensus.Block.Abstract | |
Show GenesisWindow | |
Defined in Ouroboros.Consensus.Block.Abstract showsPrec ∷ Int → GenesisWindow → ShowS # show ∷ GenesisWindow → String # showList ∷ [GenesisWindow] → ShowS # | |
Eq GenesisWindow | |
Defined in Ouroboros.Consensus.Block.Abstract (==) ∷ GenesisWindow → GenesisWindow → Bool # (/=) ∷ GenesisWindow → GenesisWindow → Bool # | |
Ord GenesisWindow | |
Defined in Ouroboros.Consensus.Block.Abstract compare ∷ GenesisWindow → GenesisWindow → Ordering # (<) ∷ GenesisWindow → GenesisWindow → Bool # (<=) ∷ GenesisWindow → GenesisWindow → Bool # (>) ∷ GenesisWindow → GenesisWindow → Bool # (>=) ∷ GenesisWindow → GenesisWindow → Bool # | |
NoThunks GenesisWindow | |
Defined in Ouroboros.Consensus.Block.Abstract |
The state of a peer at a given point in time.
NodeState | |
|
type PeerSchedule blk = [(Time, SchedulePoint blk)] Source #
type PeersSchedule blk = Peers (PeerSchedule 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 #
genesisNodeState ∷ NodeState blk 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.
peerSchedulesBlocks ∷ PeersSchedule blk → [blk] Source #
List of all blocks appearing in the schedules.
peerStates ∷ Peer (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
peersStates ∷ PeersSchedule 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.
peersStatesRelative ∷ PeersSchedule 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 #
prettyPeersSchedule ∷ ∀ blk. CondenseList (NodeState blk) ⇒ PeersSchedule blk → [String] Source #
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.