Skip to content

Commit

Permalink
Log primed validators in SpecialTransactionOutcome
Browse files Browse the repository at this point in the history
  • Loading branch information
drsk committed Nov 28, 2024
1 parent a32d64b commit 561e906
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
4 changes: 2 additions & 2 deletions concordium-consensus/src/Concordium/GlobalState/BlockState.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1519,14 +1519,14 @@ class (BlockStateQuery m) => BlockStateOperations m where
bsoUpdateMissedRounds :: (PVSupportsDelegation (MPV m), PVSupportsValidatorSuspension (MPV m)) => UpdatableBlockState m -> Map.Map BakerId Word64 -> m (UpdatableBlockState m)

-- | Mark given validators for possible suspension at the next snapshot epoch.
bsoPrimeForSuspension :: (PVSupportsDelegation (MPV m), PVSupportsValidatorSuspension (MPV m)) => UpdatableBlockState m -> Word64 -> [BakerId] -> m (UpdatableBlockState m)
bsoPrimeForSuspension :: (PVSupportsDelegation (MPV m), PVSupportsValidatorSuspension (MPV m)) => UpdatableBlockState m -> Word64 -> [BakerId] -> m ([BakerId], UpdatableBlockState m)

-- \| Suspend validators with the given account indices, if
-- 1) the account index points to an existing account
-- 2) the account belongs to a validator
-- 3) the account was not already suspended
-- Returns the subset of account indices that were suspended.
bsoSuspendValidators :: UpdatableBlockState m -> [AccountIndex] -> m ([AccountIndex], UpdatableBlockState m)
bsoSuspendValidators :: (PVSupportsValidatorSuspension (MPV m)) => UpdatableBlockState m -> [AccountIndex] -> m ([AccountIndex], UpdatableBlockState m)

-- | A snapshot of the block state that can be used to roll back to a previous state.
type StateSnapshot m
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3516,20 +3516,30 @@ doPrimeForSuspension ::
PersistentBlockState pv ->
Word64 ->
[BakerId] ->
m (PersistentBlockState pv)
m ([BakerId], PersistentBlockState pv)
doPrimeForSuspension pbs threshold bids = do
bsp <- loadPBS pbs
bsp' <-
bprds <- doGetBakerPoolRewardDetails pbs
bsp0 <- loadPBS pbs
(bidsUpd, bsp') <- do
foldM
( \bsp0 bId ->
modifyBakerPoolRewardDetailsInPoolRewards
bsp0
bId
(\bprd -> bprd{suspensionInfo = (\SuspensionInfo{..} -> SuspensionInfo{primedForSuspension = missedRounds > threshold, ..}) <$> suspensionInfo bprd})
( \res@(acc, bsp) bId -> do
let mBprd = Map.lookup bId bprds
case mBprd of
Just bprd
| CTrue SuspensionInfo{..} <- suspensionInfo bprd,
missedRounds > threshold -> do
bsp' <-
modifyBakerPoolRewardDetailsInPoolRewards
bsp
bId
(\bpr -> bpr{suspensionInfo = (\suspInfo -> suspInfo{primedForSuspension = True}) <$> suspensionInfo bpr})
return (bId : acc, bsp')
_otherwise -> return res
)
bsp
([], bsp0)
bids
storePBS pbs bsp'
pbs' <- storePBS pbs bsp'
return (bidsUpd, pbs')

-- | Suspend validators with the given account indices, if
-- 1) the account index points to an existing account
Expand Down
3 changes: 2 additions & 1 deletion concordium-consensus/src/Concordium/KonsensusV1/Scheduler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,8 @@ processPaydayRewards (Just PaydayParameters{..}) theState0 = do
case _cpValidatorScoreParameters cps of
NoParam -> return theState1
SomeParam (ValidatorScoreParameters{..}) -> do
bsoPrimeForSuspension theState2 _vspMaxMissedRounds (Map.keys paydayPoolRewards)
(bids, theState3) <- bsoPrimeForSuspension theState2 _vspMaxMissedRounds (Map.keys paydayPoolRewards)
foldM bsoAddSpecialTransactionOutcome theState3 (ValidatorPrimedForSuspension <$> bids)
where
hasValidatorSuspension = sSupportsValidatorSuspension (sAccountVersionFor (protocolVersion @pv))

Expand Down

0 comments on commit 561e906

Please sign in to comment.