Skip to content

Commit

Permalink
Add some tracing when using big ledger peers from snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
crocodile-dentist committed Apr 24, 2024
1 parent cac0700 commit c074f34
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,7 @@ ledgerPeersThread PeerActionsDNS {
paDnsSemaphore }
WithLedgerPeersArgs {
wlpRng,
wlpConsensusInterface = wlpConsensusInterface@LedgerPeersConsensusInterface {
lpGetLatestSlot,
lpGetLedgerStateJudgement },
wlpConsensusInterface,
wlpTracer,
wlpGetUseLedgerPeers,
wlpGetLedgerPeerSnapshot }
Expand Down Expand Up @@ -260,25 +258,25 @@ ledgerPeersThread PeerActionsDNS {
traceWith wlpTracer DisabledLedgerPeers
return (Map.empty, Map.empty, now)
UseLedgerPeers ula -> do
(ledgerStateJudgement, consensusSlotNo, consensusPeers, peerSnapshot) <-
atomically ((,,,) <$> lpGetLedgerStateJudgement
<*> lpGetLatestSlot
<*> getLedgerPeers wlpConsensusInterface ula
<*> wlpGetLedgerPeerSnapshot)
(consensusSlotNo, consensusPeers, peerSnapshot) <-
atomically ((,,) <$> lpGetLatestSlot wlpConsensusInterface
<*> getLedgerPeers wlpConsensusInterface ula
<*> wlpGetLedgerPeerSnapshot)

-- we have to assess which of, if any, peers we get from consensus vs.
-- peers we may have from the snapshot file is more recent, and use that
let (accPoolStake -> peersStake, bigPeersStakeMap) =
(accPoolStake -> peersStake, bigPeersStakeMap) <-
case (consensusSlotNo, consensusPeers, peerSnapshot) of
(At t, LedgerPeers _ lp, Just (LedgerPeerSnapshot (At t', sp {- snapshot peer-})))
| t' > t -> (lp, Map.fromAscList sp)
| otherwise -> (lp, accBigPoolStakeMap lp)
| t' > t -> traceWith wlpTracer UsingBigLedgerPeerSnapshot >> return (lp, Map.fromAscList sp)
| otherwise -> return (lp, accBigPoolStakeMap lp)

(_, LedgerPeers _ lp, Nothing) -> (lp, accBigPoolStakeMap lp)
(_, LedgerPeers _ lp, Nothing) -> return (lp, accBigPoolStakeMap lp)

(_, _, Just (LedgerPeerSnapshot (At t', sp)))
| After slot <- ula, t' >= slot -> ([], Map.fromAscList sp)
otherwise -> ([], Map.empty)
| After slot <- ula, t' >= slot ->
traceWith wlpTracer UsingBigLedgerPeerSnapshot >> return ([], Map.fromAscList sp)
otherwise -> return ([], Map.empty)

traceWith wlpTracer $ FetchingNewLedgerState (Map.size peersStake) (Map.size bigPeersStakeMap)
return (peersStake, bigPeersStakeMap, now)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ data TraceLedgerPeers =
| FallingBackToPublicRootPeers
| NotEnoughBigLedgerPeers NumberOfPeers Int
| NotEnoughLedgerPeers NumberOfPeers Int
| UsingBigLedgerPeerSnapshot


instance Show TraceLedgerPeers where
Expand Down Expand Up @@ -102,3 +103,4 @@ instance Show TraceLedgerPeers where
"Resolution success " ++ show domain ++ " " ++ show l
show (TraceLedgerPeersFailure domain err) =
"Resolution failed " ++ show domain ++ " " ++ show err
show UsingBigLedgerPeerSnapshot = "Using peer snapshot for big ledger peers"

0 comments on commit c074f34

Please sign in to comment.