Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move missed rounds to Word16 instead Int16
Browse files Browse the repository at this point in the history
drsk committed Oct 22, 2024
1 parent b7a0f7e commit 7aa54d3
Showing 5 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -48,7 +48,6 @@ import Control.Monad.Trans.Except
import Control.Monad.Trans.Maybe
import qualified Data.ByteString as BS
import Data.Foldable (foldl')
import Data.Int
import Data.Kind (Type)
import qualified Data.Map as Map
import qualified Data.Sequence as Seq
@@ -1511,7 +1510,7 @@ class (BlockStateQuery m) => BlockStateOperations m where
bsoIsProtocolUpdateEffective :: UpdatableBlockState m -> m Bool

-- | Update the count of missed rounds for a given validator
bsoUpdateMissedBlocks :: (PVSupportsDelegation (MPV m)) => UpdatableBlockState m -> (BakerId, Int16) -> m (UpdatableBlockState m)
bsoUpdateMissedBlocks :: (PVSupportsDelegation (MPV m)) => UpdatableBlockState m -> (BakerId, Word16) -> m (UpdatableBlockState m)

-- | Clear the missed round count for a given validator
bsoClearMissedBlocks :: (PVSupportsDelegation (MPV m)) => UpdatableBlockState m -> BakerId -> m (UpdatableBlockState m)
Original file line number Diff line number Diff line change
@@ -116,7 +116,6 @@ import qualified Control.Monad.State.Strict as MTL
import qualified Control.Monad.Writer.Strict as MTL
import Data.Bool.Singletons
import Data.IORef
import Data.Int
import Data.Kind (Type)
import qualified Data.Map.Strict as Map
import Data.Maybe
@@ -3465,7 +3464,7 @@ doGetProtocolUpdateStatus = protocolUpdateStatus . bspUpdates <=< loadPBS
doIsProtocolUpdateEffective :: (SupportsPersistentState pv m) => PersistentBlockState pv -> m Bool
doIsProtocolUpdateEffective = isProtocolUpdateEffective . bspUpdates <=< loadPBS

doUpdateMissedBlocks :: (PVSupportsDelegation pv, SupportsPersistentState pv m) => PersistentBlockState pv -> (BakerId, Int16) -> m (PersistentBlockState pv)
doUpdateMissedBlocks :: (PVSupportsDelegation pv, SupportsPersistentState pv m) => PersistentBlockState pv -> (BakerId, Word16) -> m (PersistentBlockState pv)
doUpdateMissedBlocks pbs (bId, newMissedRounds) = do
bsp <- loadPBS pbs
bsp' <-
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@

module Concordium.GlobalState.PoolRewards where

import Data.Int
import Data.Serialize
import Data.Word

@@ -24,7 +23,7 @@ data BakerPoolRewardDetails = BakerPoolRewardDetails
-- | Whether the pool contributed to a finalization proof in the reward period
finalizationAwake :: !Bool,
-- | The number of missed rounds in the reward period
missedRounds :: !Int16
missedRounds :: !Word16
}
deriving (Eq, Show)

@@ -34,7 +33,7 @@ instance Serialize BakerPoolRewardDetails where
put transactionFeesAccrued
putBool finalizationAwake

get = BakerPoolRewardDetails <$> getWord64be <*> get <*> getBool <*> getInt16be
get = BakerPoolRewardDetails <$> getWord64be <*> get <*> getBool <*> getWord16be

instance HashableTo Hash.Hash BakerPoolRewardDetails where
getHash = Hash.hash . encode
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ import Control.Monad.Reader
import Control.Monad.State
import Control.Monad.Trans.Maybe
import Data.Function
import Data.Int
import Data.Word
import Data.Ord
import Data.Time
import Data.List (group)
@@ -1386,7 +1386,7 @@ computeMissedRounds ::
Option TimeoutCertificate ->
BlockPointer (MPV m) ->
Round ->
m [(BakerId, Int16)]
m [(BakerId, Word16)]
computeMissedRounds tc _parent _rnd | isAbsent tc = return []
computeMissedRounds _tc parent rnd = do
let parentBlockState = bpState parent
4 changes: 2 additions & 2 deletions concordium-consensus/src/Concordium/KonsensusV1/Scheduler.hs
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ module Concordium.KonsensusV1.Scheduler where

import Control.Monad
import Data.Bool.Singletons
import Data.Int
import Data.Word
import qualified Data.Map as Map
import Data.Time
import Data.Maybe
@@ -84,7 +84,7 @@ data BlockExecutionData (pv :: ProtocolVersion) = BlockExecutionData
-- | Number of rounds a validator has missed (e.g. the validator was
-- elected leader but a timeout certificate exist for the round) since the parent
-- block.
bedMissedRounds :: [(BakerId, Int16)]
bedMissedRounds :: [(BakerId, Word16)]
}

-- | Details of the transactions in a block that are used for computing rewards that accrue to the

0 comments on commit 7aa54d3

Please sign in to comment.