Skip to content

Commit 87bd4c5

Browse files
committed
lateIbInclusion flag from config
1 parent acb6a70 commit 87bd4c5

File tree

5 files changed

+38
-21
lines changed

5 files changed

+38
-21
lines changed

flake.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
url = "github:input-output-hk/iogx";
88
};
99

10-
leios-spec.url = "github:input-output-hk/ouroboros-leios-formal-spec?rev=eff49274ed5e8dced0906cb6c7bff0f0bab1712d";
10+
leios-spec.url = "github:input-output-hk/ouroboros-leios-formal-spec?rev=e39a1568e55f7c52b6419e7dec3c0ab63da83f15";
1111
};
1212

1313

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

leios-trace-verifier/Parser.agda

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,20 @@ record TraceEvent : Type where
104104

105105
{-# COMPILE GHC TraceEvent = data TraceEvent (TraceEvent) #-}
106106

107-
module _ (numberOfParties : ℕ) (sutId : ℕ) (stakeDistr : List (Pair String ℕ)) (sl : ℕ) (eta : ℕ) where
107+
module _
108+
(numberOfParties : ℕ)
109+
(sutId : ℕ)
110+
(stakeDistr : List (Pair String ℕ))
111+
(stageLength : ℕ)
112+
(ledgerQuality : ℕ)
113+
(lateIBInclusion : Bool) -- TODO: Pass config and topology instead
114+
where
108115

109116
from-id : Fin numberOfParties
110117
from-id n =
111118
case n <? numberOfParties of λ where
112119
(yes p) #_ n {numberOfParties} {fromWitness p}
113-
(no _) error "Conversion to Fin not possible!"
120+
(no _) error $ "Conversion to Fin not possible! " ◇ show n ◇ " / " ◇ show numberOfParties
114121

115122
nodePrefix : String
116123
nodePrefix = "node-"
@@ -119,13 +126,13 @@ module _ (numberOfParties : ℕ) (sutId : ℕ) (stakeDistr : List (Pair String
119126
SUT-id = from-id sutId
120127

121128
instance
122-
sl-NonZero : NonZero sl
123-
sl-NonZero with sl0
129+
stageLength-NonZero : NonZero stageLength
130+
stageLength-NonZero with stageLength0
124131
... | yes _ = error "Stage length is 0"
125132
... | no ¬p = ≢-nonZero ¬p
126133

127-
np-NonZero : NonZero numberOfParties
128-
np-NonZero with numberOfParties ≟ 0
134+
numberOfParties-NonZero : NonZero numberOfParties
135+
numberOfParties-NonZero with numberOfParties ≟ 0
129136
... | yes _ = error "Number of parties is 0"
130137
... | no ¬p = ≢-nonZero ¬p
131138

@@ -137,8 +144,8 @@ module _ (numberOfParties : ℕ) (sutId : ℕ) (stakeDistr : List (Pair String
137144

138145
open FunTot (completeFin numberOfParties) (maximalFin numberOfParties)
139146

140-
sd : TotalMap (Fin numberOfParties) ℕ
141-
sd =
147+
stakeDistribution : TotalMap (Fin numberOfParties) ℕ
148+
stakeDistribution =
142149
let (r , l) = fromListᵐ (L.map (λ (x , y) (nodeId x , y)) stakeDistr)
143150
in case (¿ total r ¿) of λ where
144151
(yes p) record { rel = r ; left-unique-rel = l ; total-rel = p }
@@ -192,10 +199,10 @@ module _ (numberOfParties : ℕ) (sutId : ℕ) (stakeDistr : List (Pair String
192199
{ networkParams =
193200
record
194201
{ numberOfParties = numberOfParties
195-
; eta = eta
196-
; stakeDistribution = sd
197-
; stageLength = sl
198-
; lateIBInclusion = false
202+
; ledgerQuality = ledgerQuality
203+
; stakeDistribution = stakeDistribution
204+
; stageLength = stageLength
205+
; lateIBInclusion = lateIBInclusion
199206
}
200207
; sutId = SUT-id
201208
; winning-slots = fromList (L.catMaybes $ L.map winningSlot l)
@@ -385,7 +392,7 @@ module _ (numberOfParties : ℕ) (sutId : ℕ) (stakeDistr : List (Pair String
385392
unquoteDecl Show-LeiosInput = derive-Show [ (quote LeiosInput , Show-LeiosInput) ]
386393

387394
s₀ : LeiosState
388-
s₀ = initLeiosState tt sd tt ((SUT-id , tt) ∷ [])
395+
s₀ = initLeiosState tt stakeDistribution tt ((SUT-id , tt) ∷ [])
389396

390397
format-Err-verifyAction : {α i s} Err-verifyAction α i s Pair String String
391398
format-Err-verifyAction {α} {i} {s} (E-Err e) =

leios-trace-verifier/hs-src/app/Main.hs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,22 @@ main :: IO ()
2222
main =
2323
do
2424
Command{..} <- execParser commandParser
25+
26+
-- Prameters from topology
2527
(top :: Topology COORD2D) <- decodeFileThrow topologyFile
26-
(config :: Config) <- decodeFileThrow configFile
2728
let nrNodes = toInteger $ Prelude.length (elems $ nodes top)
2829
let nodeNames = Prelude.map unNodeName (keys $ nodes top)
2930
let stakes = Prelude.map (toInteger . stake . nodeInfo) (elems $ nodes top)
3031
let stakeDistribution = Prelude.zip nodeNames stakes
32+
33+
-- Parameters from config
34+
(config :: Config) <- decodeFileThrow configFile
3135
let stageLength = toInteger (leiosStageLengthSlots config)
32-
let tau = 0 -- TODO: get tau from config
36+
let ledgerQuality = ceiling (praosChainQuality config) -- TODO: int in schema?
37+
let lateIBInclusion = leiosLateIbInclusion config
38+
3339
result <-
34-
verifyTrace nrNodes idSut stakeDistribution stageLength tau
40+
verifyTrace nrNodes idSut stakeDistribution stageLength ledgerQuality lateIBInclusion
3541
. decodeJSONL
3642
<$> BSL.readFile logFile
3743
hPutStrLn stderr $ "Applying " <> show (fst result) <> " actions"

0 commit comments

Comments
 (0)