Skip to content

Commit

Permalink
logs: log more when locally mined cuts result in timeouts or validati…
Browse files Browse the repository at this point in the history
…on errors (#1918)

Change-Id: I116087bd9a9f2150b48f9325fd208649a942a65f

Co-authored-by: Edmund Noble <[email protected]>
  • Loading branch information
thoughtpolice and edmundnoble authored May 10, 2024
1 parent ef9e165 commit 12896d7
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/Chainweb/CutDB.hs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ import Data.LogMessage
import Data.Maybe
import Data.Monoid
import Data.Ord
import Data.Text (Text)
import qualified Data.Text as T
import Data.These

Expand Down Expand Up @@ -759,11 +760,15 @@ cutHashesToBlockHeaderMap
cutHashesToBlockHeaderMap conf logfun headerStore payloadStore hs =
timeout (_cutDbParamsFetchTimeout conf) go >>= \case
Nothing -> do
logfun Warn
let cutOriginText = case _cutHashesLocalPayload hs of
Nothing -> "from " <> maybe "unknown origin" (\p -> "origin " <> toText p) origin
Just _ -> "which was locally mined - the mining loop will stall until unstuck by another miner"

logfun (maybe Warn (\_ -> Error) (_cutHashesLocalPayload hs))
$ "Timeout while processing cut "
<> cutIdToTextShort hsid
<> " at height " <> sshow (_cutHashesHeight hs)
<> maybe " from unknown origin" (\p -> " from origin " <> toText p) origin
<> cutOriginText
return $! Left $! T2 hsid mempty
Just x -> return $! x
where
Expand All @@ -787,8 +792,12 @@ cutHashesToBlockHeaderMap conf logfun headerStore payloadStore hs =
& S.fold_ (\x (cid, h) -> HM.insert cid h x) mempty id
& S.fold (\x (cid, h) -> HM.insert cid h x) mempty id
if null missing
then return (Right headers)
else return $! Left $! T2 hsid missing
then return (Right headers)
else do
when (isJust $ _cutHashesLocalPayload hs) $
logfun @Text Error
"error validating locally mined cut; the mining loop will stall until unstuck by another mining node"
return $! Left $! T2 hsid missing

origin = _cutOrigin hs
priority = Priority (- int (_cutHashesHeight hs))
Expand Down

0 comments on commit 12896d7

Please sign in to comment.