Skip to content

Commit

Permalink
cosmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
drsk committed Nov 4, 2024
1 parent 090491d commit 0876c4f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3479,7 +3479,7 @@ doUpdateMissedRounds pbs rds = do
modifyBakerPoolRewardDetailsInPoolRewards
bsp0
bId
(\bprd -> bprd{missedRounds = fmap (+ newMissedRounds) $ missedRounds bprd})
(\bprd -> bprd{missedRounds = (+ newMissedRounds) <$> missedRounds bprd})
)
bsp
rds
Expand Down Expand Up @@ -3681,11 +3681,9 @@ doNotifyBlockBaked pbs bid = do
let incBPR bpr =
bpr
{ blockCount = blockCount bpr + 1,
missedRounds = conditionally hasValidatorSuspension 0
missedRounds = 0 <$ missedRounds bpr
}
in storePBS pbs =<< modifyBakerPoolRewardDetailsInPoolRewards bsp bid incBPR
where
hasValidatorSuspension = sSupportsValidatorSuspension (accountVersion @(AccountVersionFor pv))

doUpdateAccruedTransactionFeesBaker :: forall pv m. (PVSupportsDelegation pv, SupportsPersistentState pv m) => PersistentBlockState pv -> BakerId -> AmountDelta -> m (PersistentBlockState pv)
doUpdateAccruedTransactionFeesBaker pbs bid delta = do
Expand Down Expand Up @@ -3719,8 +3717,14 @@ doMarkFinalizationAwakeBakers pbs bids = do
error "Invariant violation: unable to find baker in baker pool reward details tree"
Just ((), newBPRs) ->
return newBPRs
setAwake bpr = return ((), bpr{finalizationAwake = True, missedRounds = conditionally hasValidatorSuspension 0})
hasValidatorSuspension = sSupportsValidatorSuspension (accountVersion @(AccountVersionFor pv))
setAwake bpr =
return
( (),
bpr
{ finalizationAwake = True,
missedRounds = 0 <$ missedRounds bpr
}
)

doUpdateAccruedTransactionFeesPassive :: forall pv m. (PVSupportsDelegation pv, SupportsPersistentState pv m) => PersistentBlockState pv -> AmountDelta -> m (PersistentBlockState pv)
doUpdateAccruedTransactionFeesPassive pbs delta = do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import Data.Word
import Concordium.Crypto.SHA256 as Hash

import Concordium.Types
import Concordium.Types.Conditionally
import Concordium.Types.HashableTo
import Concordium.Utils.BinarySearch
import Concordium.Utils.Serialization.Put (MonadPut (..))
Expand Down Expand Up @@ -133,7 +132,6 @@ migratePoolRewardsP1 curBakers nextBakers blockCounts npEpoch npMintRate = do
nextPaydayMintRate = npMintRate
return PoolRewards{..}
where
hasValidatorSuspension = sSupportsValidatorSuspension (accountVersion @av)
makeCD bkrs =
makeHashed $
CapitalDistribution
Expand All @@ -148,7 +146,7 @@ migratePoolRewardsP1 curBakers nextBakers blockCounts npEpoch npMintRate = do
{ blockCount = Map.findWithDefault 0 bid blockCounts,
transactionFeesAccrued = 0,
finalizationAwake = False,
missedRounds = conditionally hasValidatorSuspension 0
missedRounds = 0 <$ missedRounds bprd
}
(!newRef, _) <- refFlush =<< refMake bprd
return newRef
Expand Down
8 changes: 8 additions & 0 deletions concordium-consensus/src/Concordium/KonsensusV1/Scheduler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,14 @@ processBlockRewards ::
UpdatableBlockState m ->
m (UpdatableBlockState m)
processBlockRewards ParticipatingBakers{..} TransactionRewardParameters{..} missedRounds theState0 = do
-- Note: The order of the following operations is important.
--
-- The finalization awake bakers are the ones that signed the QC (possibly
-- a timeout) for the parent block. If it was a timeout, missed rounds are counted
-- between this last timeout round and the round of the block that is baked next. So if
-- a validator signed the QC for the parent block, but missed a round in the interim,
-- then its missed round counter would be 1. Though if it also baked the new block, it
-- would be reset to 0.
theState1 <- bsoMarkFinalizationAwakeBakers theState0 pbQCSignatories
theState2 <- bsoUpdateMissedRounds theState1 missedRounds
theState3 <- bsoNotifyBlockBaked theState2 pbBlockBaker
Expand Down

0 comments on commit 0876c4f

Please sign in to comment.