Skip to content

Commit ddb4119

Browse files
committed
fixup! ChainDB: implement chain selection for Peras certificates
1 parent 953f3fb commit ddb4119

File tree

2 files changed

+5
-5
lines changed
  • ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Storage/ChainDB/Impl

2 files changed

+5
-5
lines changed

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Storage/ChainDB/Impl/ChainSel.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,12 +487,12 @@ chainSelSync cdb@CDB{..} (ChainSelAddBlock BlockToAdd{blockToAdd = b, ..}) = do
487487
-- performing chain selection if a candidate is now better than our selection.
488488
chainSelSync cdb@CDB{..} (ChainSelAddPerasCert cert varProcessed) = do
489489
curChain <- lift $ atomically $ Query.getCurrentChain cdb
490-
let immTip = castPoint $ AF.anchorPoint curChain
490+
let immTip = AF.castAnchor $ AF.anchor curChain
491491

492492
withEarlyExit_ $ do
493493
-- Ignore the certificate if it boosts a block that is so old that it can't
494494
-- influence our selection.
495-
when (pointSlot boostedBlock < pointSlot immTip) $ do
495+
when (pointSlot boostedBlock < AF.anchorToSlotNo immTip) $ do
496496
lift $ lift $ traceWith tracer $ IgnorePerasCertTooOld certRound boostedBlock immTip
497497
exitEarly
498498

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Storage/ChainDB/Impl/Types.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ import Ouroboros.Consensus.Util.Enclose (Enclosing, Enclosing' (..))
141141
import Ouroboros.Consensus.Util.IOLike
142142
import Ouroboros.Consensus.Util.Orphans ()
143143
import Ouroboros.Consensus.Util.STM (WithFingerprint)
144-
import Ouroboros.Network.AnchoredFragment (AnchoredFragment)
144+
import Ouroboros.Network.AnchoredFragment (Anchor, AnchoredFragment)
145145
import qualified Ouroboros.Network.AnchoredFragment as AF
146146
import Ouroboros.Network.Block (MaxSlotNo (..))
147147
import Ouroboros.Network.BlockFetch.ConsensusInterface
@@ -620,7 +620,7 @@ addPerasCertToQueue tracer ChainSelQueue{varChainSelQueue} cert = do
620620
traceWith tracer $ addedToQueue $ FallingEdgeWith $ fromIntegral queueSize
621621
pure
622622
AddPerasCertPromise
623-
{ waitPerasCertProcessed = atomically $ takeTMVar varProcessed
623+
{ waitPerasCertProcessed = atomically $ readTMVar varProcessed
624624
}
625625
where
626626
addedToQueue = AddedPerasCertToQueue (getPerasCertRound cert) (getPerasCertBoostedBlock cert)
@@ -1068,7 +1068,7 @@ data TraceAddPerasCertEvent blk
10681068
| -- | The Peras certificate from the given round boosting the given block was
10691069
-- too old, ie its slot was older than the current immutable slot (the third
10701070
-- argument).
1071-
IgnorePerasCertTooOld PerasRoundNo (Point blk) (Point blk)
1071+
IgnorePerasCertTooOld PerasRoundNo (Point blk) (Anchor blk)
10721072
| -- | The Peras certificate from the given round boosts a block on the
10731073
-- current selection.
10741074
PerasCertBoostsCurrentChain PerasRoundNo (Point blk)

0 commit comments

Comments
 (0)