Skip to content

Commit

Permalink
Try #1285:
Browse files Browse the repository at this point in the history
  • Loading branch information
iohk-bors[bot] committed Jan 20, 2020
2 parents d93e09f + 76bf85a commit 2f00d71
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
8 changes: 7 additions & 1 deletion lib/core/src/Cardano/Pool/Metrics.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import Cardano.Wallet.Primitive.Types
, PoolId
, PoolOwner (..)
, PoolRegistrationCertificate (..)
, SlotId
)
import Control.Arrow
( first )
Expand Down Expand Up @@ -161,6 +162,7 @@ monitorStakePools tr nl db@DBLayer{..} = do
follow nl trFollow cursor forward header >>= \case
Nothing -> pure ()
Just point -> do
traceWith tr $ MsgRollingBackTo point
liftIO . atomically $ rollbackTo point
monitorStakePools tr nl db
where
Expand All @@ -175,7 +177,7 @@ monitorStakePools tr nl db@DBLayer{..} = do
readPoolRegistration poolId >>= \case
Nothing -> putPoolRegistration sl0 r
Just{} -> pure ()
readPoolProductionCursor k
readPoolProductionCursor (max 100 k)

forward
:: NonEmpty Block
Expand Down Expand Up @@ -514,6 +516,7 @@ data StakePoolLog
| MsgFollow FollowLog
| MsgStakeDistribution EpochNo
| MsgStakePoolRegistration PoolRegistrationCertificate
| MsgRollingBackTo SlotId
| MsgApplyError ErrMonitorStakePools
deriving (Show, Eq)

Expand All @@ -531,6 +534,7 @@ instance DefineSeverity StakePoolLog where
MsgFollow msg -> defineSeverity msg
MsgStakeDistribution _ -> Info
MsgStakePoolRegistration _ -> Info
MsgRollingBackTo _ -> Info
MsgApplyError e -> case e of
ErrMonitorStakePoolsNetworkUnavailable{} -> Notice
ErrMonitorStakePoolsNetworkTip{} -> Notice
Expand Down Expand Up @@ -568,6 +572,8 @@ instance ToText StakePoolLog where
"Writing stake-distribution for epoch " <> pretty ep
MsgStakePoolRegistration pool ->
"Discovered stake pool registration: " <> pretty pool
MsgRollingBackTo point ->
"Rolling back to " <> pretty point
MsgApplyError e -> case e of
ErrMonitorStakePoolsNetworkUnavailable{} ->
"Network is not available."
Expand Down
11 changes: 9 additions & 2 deletions lib/jormungandr/src/Cardano/Wallet/Jormungandr/Network.hs
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,16 @@ mkRawNetworkLayer (block0, bp) batchSize st j = NetworkLayer
_getAccountBalance
}
where
-- security parameter, the maximum number of unstable blocks
-- security parameter, the maximum number of unstable blocks.
-- When @k@ is too small, we use an arbitrary bigger (although still
-- reasonably sized) value to make sure that our observation window is
-- big-enough. This allows for re-syncing faster when connecting to a
-- network after a long period of time where the node might have drifted
-- completely. In theory, nodes can't switch to chains that are longer than
-- @k@ but in practice with Jörmungandr, nodes can make jumps longer than
-- that.
k :: Quantity "block" Word32
k = getEpochStability bp
k = (max 100) <$> getEpochStability bp

genesis :: Hash "Genesis"
genesis = getGenesisBlockHash bp
Expand Down

0 comments on commit 2f00d71

Please sign in to comment.