Skip to content

Commit f05f993

Browse files
committed
Support leios-late-ib-inclusion
1 parent f20c11d commit f05f993

File tree

4 files changed

+29
-12
lines changed

4 files changed

+29
-12
lines changed

data/simulation/config.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ export interface Config {
3939
* Only supported by Haskell simulation. */
4040
"leios-vote-send-recv-stages": boolean;
4141
/**
42-
* Extends Leios so that EB producers include IBs directly from previous pipelines
43-
* where no certified EB was observed.
44-
*
45-
* Only supported by Rust simulation. */
42+
* Extends Leios so that EB producers include IBs directly from previous pipelines.
43+
* Due to casuality, the EB must always include them, even if those IBs end up being
44+
* certified in their own pipeline.
45+
*/
4646
"leios-late-ib-inclusion": boolean;
4747
/**
4848
* The expected time it takes a header to fully diffuse across the network.

leios-trace-hs/src/LeiosConfig.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ data Config = Config
9999
, leiosStageActiveVotingSlots :: Word
100100
, leiosVoteSendRecvStages :: Bool
101101
, leiosVariant :: LeiosVariant
102+
, leiosLateIbInclusion :: Bool
102103
, leiosHeaderDiffusionTimeMs :: DurationMs
103104
, praosChainQuality :: Double
104105
, txGenerationDistribution :: Distribution
@@ -171,6 +172,7 @@ instance Default Config where
171172
, leiosStageActiveVotingSlots = 1
172173
, leiosVoteSendRecvStages = False
173174
, leiosVariant = Short
175+
, leiosLateIbInclusion = False
174176
, leiosHeaderDiffusionTimeMs = 1000
175177
, praosChainQuality = 40
176178
, txGenerationDistribution = Exp{lambda = 0.85, scale = Just 1000}
@@ -243,6 +245,7 @@ configToKVsWith getter cfg =
243245
, get @"treatBlocksAsFull" getter cfg
244246
, get @"cleanupPolicies" getter cfg
245247
, get @"leiosVariant" getter cfg
248+
, get @"leiosLateIbInclusion" getter cfg
246249
, get @"leiosHeaderDiffusionTimeMs" getter cfg
247250
, get @"praosChainQuality" getter cfg
248251
, get @"simulateTransactions" getter cfg
@@ -329,6 +332,7 @@ instance FromJSON Config where
329332
treatBlocksAsFull <- parseFieldOrDefault @Config @"treatBlocksAsFull" obj
330333
cleanupPolicies <- parseFieldOrDefault @Config @"cleanupPolicies" obj
331334
leiosVariant <- parseFieldOrDefault @Config @"leiosVariant" obj
335+
leiosLateIbInclusion <- parseFieldOrDefault @Config @"leiosLateIbInclusion" obj
332336
leiosHeaderDiffusionTimeMs <- parseFieldOrDefault @Config @"leiosHeaderDiffusionTimeMs" obj
333337
praosChainQuality <- parseFieldOrDefault @Config @"praosChainQuality" obj
334338
simulateTransactions <- parseFieldOrDefault @Config @"simulateTransactions" obj

simulation/src/LeiosProtocol/Short.hs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ data LeiosConfig = forall p. IsPipeline p => LeiosConfig
111111
, variant :: LeiosVariant
112112
, headerDiffusionTime :: NominalDiffTime
113113
-- ^ Δ_{hdr}.
114+
, leiosLateIbInclusion :: Bool
115+
-- ^ Whether an EB also includes IBs from the two previous iterations.
116+
--
117+
-- TODO Merely one previous iteration if 'pipeline' is 'SingleVote'?
114118
, pipelinesToReferenceFromEB :: Int
115119
-- ^ how many older pipelines to reference from an EB when `variant = Full`.
116120
, votingFrequencyPerStage :: Double
@@ -147,6 +151,7 @@ convertConfig disk =
147151
, cleanupPolicies = disk.cleanupPolicies
148152
, variant = disk.leiosVariant
149153
, headerDiffusionTime = realToFrac $ durationMsToDiffTime disk.leiosHeaderDiffusionTimeMs
154+
, leiosLateIbInclusion = disk.leiosLateIbInclusion
150155
, pipelinesToReferenceFromEB =
151156
if disk.leiosVariant == Full
152157
then
@@ -285,6 +290,7 @@ delaysAndSizesAsFull cfg@LeiosConfig{pipeline, voteSendStage} =
285290
, cleanupPolicies = cfg.cleanupPolicies
286291
, variant = cfg.variant
287292
, headerDiffusionTime = cfg.headerDiffusionTime
293+
, leiosLateIbInclusion = cfg.leiosLateIbInclusion
288294
, pipelinesToReferenceFromEB = cfg.pipelinesToReferenceFromEB
289295
, activeVotingStageLength = cfg.activeVotingStageLength
290296
, votingFrequencyPerStage = cfg.votingFrequencyPerStage
@@ -671,14 +677,20 @@ inputBlocksToEndorse ::
671677
InputBlocksSnapshot ->
672678
[InputBlockId]
673679
inputBlocksToEndorse cfg@LeiosConfig{pipeline = _ :: SingPipeline p} current buffer = fromMaybe [] $ do
674-
generatedBetween <- stageRange @p cfg Endorse current Propose
675-
receivedBy <- stageEnd @p cfg Endorse current Deliver2
676-
pure $
677-
buffer.validInputBlocks
678-
InputBlocksQuery
679-
{ generatedBetween
680-
, receivedBy
681-
}
680+
let each sl = do
681+
generatedBetween <- stageRange @p cfg Endorse sl Propose
682+
receivedBy <- stageEnd @p cfg Endorse sl Deliver2
683+
pure $
684+
buffer.validInputBlocks
685+
InputBlocksQuery
686+
{ generatedBetween
687+
, receivedBy
688+
}
689+
let capL = fromIntegral cfg.sliceLength
690+
oldest =
691+
if not cfg.leiosLateIbInclusion then current
692+
else current - min current (2 * capL)
693+
concat <$> mapM each [ oldest, oldest + capL .. current ]
682694

683695
-- | Returns possible EBs to reference from current pipeline EB.
684696
endorseBlocksToReference ::

simulation/src/LeiosProtocol/Short/Sim.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ traceRelayLink1 connectionOptions =
426426
, cleanupPolicies = def
427427
, variant = Short
428428
, headerDiffusionTime = 1
429+
, leiosLateIbInclusion = False
429430
, pipelinesToReferenceFromEB = 0
430431
, activeVotingStageLength = 1
431432
, pipeline = SingSingleVote

0 commit comments

Comments
 (0)