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 {}
- data CSJParams = CSJParams {}
- data DowntimeParams
- newtype ForecastRange = ForecastRange {}
- data GenesisTest blk schedule = GenesisTest {
- gtSecurityParam ∷ SecurityParam
- gtGenesisWindow ∷ GenesisWindow
- gtForecastRange ∷ ForecastRange
- gtDelay ∷ Delta
- gtBlockTree ∷ BlockTree blk
- gtChainSyncTimeouts ∷ ChainSyncTimeout
- gtBlockFetchTimeouts ∷ BlockFetchTimeout
- gtLoPBucketParams ∷ LoPBucketParams
- gtCSJParams ∷ CSJParams
- gtSlotLength ∷ SlotLength
- gtExtraHonestPeers ∷ Word
- gtSchedule ∷ schedule
- type GenesisTestFull blk = GenesisTest blk (PointSchedule blk)
- newtype GenesisWindow = GenesisWindow {}
- data LoPBucketParams = LoPBucketParams {}
- type PeerSchedule blk = [(Time, SchedulePoint blk)]
- data PointSchedule blk = PointSchedule {
- psSchedule ∷ Peers (PeerSchedule blk)
- psMinEndTime ∷ Time
- data PointsGeneratorParams = PointsGeneratorParams {}
- data RunGenesisTestResult = RunGenesisTestResult {}
- enrichedWith ∷ (Functor f, Monad m) ⇒ m (f a) → (f a → m b) → m (f b)
- ensureScheduleDuration ∷ GenesisTest blk a → PointSchedule blk → PointSchedule blk
- genesisNodeState ∷ NodeState blk
- longRangeAttack ∷ (StatefulGen g m, HasHeader blk) ⇒ BlockTree blk → g → m (PointSchedule blk)
- mkPointSchedule ∷ Peers (PeerSchedule blk) → PointSchedule blk
- peerSchedulesBlocks ∷ Peers (PeerSchedule blk) → [blk]
- peerStates ∷ Peer (PeerSchedule blk) → [(Time, Peer (NodeState blk))]
- peersStates ∷ PointSchedule blk → [(Time, Peer (NodeState blk))]
- peersStatesRelative ∷ PointSchedule blk → [(DiffTime, Peer (NodeState blk))]
- prettyGenesisTest ∷ (schedule → [String]) → GenesisTest TestBlock schedule → [String]
- prettyPointSchedule ∷ ∀ blk. CondenseList (NodeState blk) ⇒ PointSchedule blk → [String]
- stToGen ∷ (∀ s. STGenM QCGen s → ST s a) → Gen a
- uniformPoints ∷ (StatefulGen g m, HasHeader blk) ⇒ PointsGeneratorParams → BlockTree blk → g → m (PointSchedule 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.
GenesisTest | |
|
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 (PointSchedule blk) Source #
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
.
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 |
type PeerSchedule blk = [(Time, SchedulePoint blk)] Source #
data PointSchedule blk Source #
PointSchedule | |
|
data PointsGeneratorParams 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 #
ensureScheduleDuration ∷ GenesisTest blk a → PointSchedule blk → PointSchedule blk Source #
genesisNodeState ∷ NodeState blk 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.
mkPointSchedule ∷ Peers (PeerSchedule blk) → PointSchedule blk Source #
peerSchedulesBlocks ∷ Peers (PeerSchedule 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 ∷ PointSchedule 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 ∷ PointSchedule 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 #
prettyPointSchedule ∷ ∀ blk. CondenseList (NodeState blk) ⇒ PointSchedule blk → [String] Source #
uniformPoints ∷ (StatefulGen g m, HasHeader blk) ⇒ PointsGeneratorParams → BlockTree blk → g → m (PointSchedule blk) Source #