Skip to content

Commit 244ea9f

Browse files
authored
ChainDB q-s-m: make loeHasImmutableAnchor an invariant (#1313)
Tiny follow-up to #1308, see the commit description
2 parents 7aeafae + c02712b commit 244ea9f

File tree

1 file changed

+10
-10
lines changed
  • ouroboros-consensus/test/storage-test/Test/Ouroboros/Storage/ChainDB

1 file changed

+10
-10
lines changed

ouroboros-consensus/test/storage-test/Test/Ouroboros/Storage/ChainDB/StateMachine.hs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,6 @@ precondition :: forall m blk. TestConstraints blk
10751075
precondition Model {..} (At cmd) =
10761076
forAll (iters cmd) (`member` RE.keys knownIters) .&&
10771077
forAll (flrs cmd) (`member` RE.keys knownFollowers) .&&
1078-
loeHasImmutableAnchor .&&
10791078
case cmd of
10801079
-- Even though we ensure this in the generator, shrinking might change
10811080
-- it.
@@ -1103,14 +1102,6 @@ precondition Model {..} (At cmd) =
11031102
garbageCollectableIteratorNext it = Boolean $
11041103
Model.garbageCollectableIteratorNext secParam dbModel (knownIters RE.! it)
11051104

1106-
loeHasImmutableAnchor :: Logic
1107-
loeHasImmutableAnchor = case Model.getLoEFragment dbModel of
1108-
LoEEnabled frag ->
1109-
Boolean $ Chain.pointOnChain (AF.anchorPoint frag) immChain
1110-
LoEDisabled -> Top
1111-
where
1112-
immChain = Model.immutableChain secParam dbModel
1113-
11141105
cfg :: TopLevelConfig blk
11151106
cfg = unOpaque modelConfig
11161107

@@ -1139,7 +1130,8 @@ invariant ::
11391130
-> Model blk m Concrete
11401131
-> Logic
11411132
invariant cfg Model {..} =
1142-
forAll ptsOnCurChain (Boolean . fromMaybe False . Model.getIsValid dbModel)
1133+
forAll ptsOnCurChain (Boolean . fromMaybe False . Model.getIsValid dbModel) .&&
1134+
loeHasImmutableAnchor
11431135
where
11441136
-- | The blocks occurring on the current volatile chain fragment
11451137
ptsOnCurChain :: [RealPoint blk]
@@ -1149,6 +1141,14 @@ invariant cfg Model {..} =
11491141
. Model.volatileChain (configSecurityParam cfg) id
11501142
$ dbModel
11511143

1144+
loeHasImmutableAnchor :: Logic
1145+
loeHasImmutableAnchor = case Model.getLoEFragment dbModel of
1146+
LoEEnabled frag ->
1147+
Boolean $ Chain.pointOnChain (AF.anchorPoint frag) immChain
1148+
LoEDisabled -> Top
1149+
where
1150+
immChain = Model.immutableChain (configSecurityParam cfg) dbModel
1151+
11521152
postcondition :: TestConstraints blk
11531153
=> Model blk m Concrete
11541154
-> At Cmd blk m Concrete

0 commit comments

Comments
 (0)