Skip to content

Commit 572b241

Browse files
committed
ChainSync.Client: remove overzealous assertion
In case of data loss in the VolatileDB and a node restart, this condition can be violated until we received `k` headers again. Additionally, Ouroboros Peras will use a different immutability criterion where it is perfectly fine to have less than `k` headers on our chain (as long as they have sufficient weight).
1 parent cfae3c7 commit 572b241

File tree

1 file changed

+9
-31
lines changed
  • ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/MiniProtocol/ChainSync

1 file changed

+9
-31
lines changed

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/MiniProtocol/ChainSync/Client.hs

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -691,12 +691,10 @@ checkKnownIntersectionInvariants ::
691691
( HasHeader blk
692692
, HasHeader (Header blk)
693693
, HasAnnTip blk
694-
, ConsensusProtocol (BlockProtocol blk)
695694
) =>
696-
ConsensusConfig (BlockProtocol blk) ->
697695
KnownIntersectionState blk ->
698696
Either String ()
699-
checkKnownIntersectionInvariants cfg kis
697+
checkKnownIntersectionInvariants kis
700698
-- 'theirHeaderStateHistory' invariant
701699
| let HeaderStateHistory snapshots = theirHeaderStateHistory
702700
historyTips :: [WithOrigin (AnnTip blk)]
@@ -723,19 +721,6 @@ checkKnownIntersectionInvariants cfg kis
723721
, show fragmentAnchorPoint
724722
]
725723
-- 'ourFrag' invariants
726-
| let nbHeaders = AF.length ourFrag
727-
ourAnchorPoint = AF.anchorPoint ourFrag
728-
, nbHeaders < fromIntegral (unNonZero k)
729-
, ourAnchorPoint /= GenesisPoint =
730-
throwError $
731-
unwords
732-
[ "ourFrag contains fewer than k headers and not close to genesis:"
733-
, show nbHeaders
734-
, "vs"
735-
, show k
736-
, "with anchor"
737-
, show ourAnchorPoint
738-
]
739724
| let ourFragAnchor = AF.anchorPoint ourFrag
740725
theirFragAnchor = AF.anchorPoint theirFrag
741726
, ourFragAnchor /= castPoint theirFragAnchor =
@@ -761,8 +746,6 @@ checkKnownIntersectionInvariants cfg kis
761746
| otherwise =
762747
return ()
763748
where
764-
SecurityParam k = protocolSecurityParam cfg
765-
766749
KnownIntersectionState
767750
{ mostRecentIntersection
768751
, ourFrag
@@ -774,14 +757,12 @@ assertKnownIntersectionInvariants ::
774757
( HasHeader blk
775758
, HasHeader (Header blk)
776759
, HasAnnTip blk
777-
, ConsensusProtocol (BlockProtocol blk)
778760
, HasCallStack
779761
) =>
780-
ConsensusConfig (BlockProtocol blk) ->
781762
KnownIntersectionState blk ->
782763
KnownIntersectionState blk
783-
assertKnownIntersectionInvariants cfg kis =
784-
assertWithMsg (checkKnownIntersectionInvariants cfg kis) kis
764+
assertKnownIntersectionInvariants kis =
765+
assertWithMsg (checkKnownIntersectionInvariants kis) kis
785766

786767
{-------------------------------------------------------------------------------
787768
The ChainSync client definition
@@ -892,8 +873,7 @@ chainSyncClient cfgEnv dynEnv =
892873
(ForkTooDeep GenesisPoint)
893874
where
894875
ConfigEnv
895-
{ cfg
896-
, chainDbView
876+
{ chainDbView
897877
, tracer
898878
} = cfgEnv
899879

@@ -995,7 +975,7 @@ chainSyncClient cfgEnv dynEnv =
995975
-- we will /never/ adopt them, which is handled in the "no
996976
-- more intersection case".
997977
StillIntersects () $
998-
assertKnownIntersectionInvariants (configConsensus cfg) $
978+
assertKnownIntersectionInvariants $
999979
KnownIntersectionState
1000980
{ mostRecentIntersection = castPoint intersection
1001981
, ourFrag = ourFrag'
@@ -1158,7 +1138,7 @@ findIntersectionTop cfgEnv dynEnv intEnv =
11581138
(ourTipFromChain ourFrag)
11591139
theirTip
11601140
let kis =
1161-
assertKnownIntersectionInvariants (configConsensus cfg) $
1141+
assertKnownIntersectionInvariants $
11621142
KnownIntersectionState
11631143
{ mostRecentIntersection = intersection
11641144
, ourFrag
@@ -1234,7 +1214,6 @@ knownIntersectionStateTop cfgEnv dynEnv intEnv =
12341214
ConfigEnv
12351215
{ mkPipelineDecision0
12361216
, tracer
1237-
, cfg
12381217
, historicityCheck
12391218
} = cfgEnv
12401219

@@ -1622,9 +1601,8 @@ knownIntersectionStateTop cfgEnv dynEnv intEnv =
16221601
else mostRecentIntersection
16231602

16241603
kis' =
1625-
assertKnownIntersectionInvariants
1626-
(configConsensus cfg)
1627-
$ KnownIntersectionState
1604+
assertKnownIntersectionInvariants $
1605+
KnownIntersectionState
16281606
{ mostRecentIntersection = mostRecentIntersection'
16291607
, ourFrag = ourFrag
16301608
, theirFrag = theirFrag'
@@ -1961,7 +1939,7 @@ checkValid cfgEnv intEnv hdr hdrSlotTime theirTip kis ledgerView = do
19611939
traceWith (tracer cfgEnv) $ TraceValidatedHeader hdr
19621940

19631941
pure $
1964-
assertKnownIntersectionInvariants (configConsensus cfg) $
1942+
assertKnownIntersectionInvariants $
19651943
KnownIntersectionState
19661944
{ mostRecentIntersection = mostRecentIntersection'
19671945
, ourFrag = ourFrag

0 commit comments

Comments
 (0)