Skip to content

Commit

Permalink
sentry addition
Browse files Browse the repository at this point in the history
  • Loading branch information
rmourey26 committed Oct 24, 2021
1 parent df86be0 commit 2853cbb
Show file tree
Hide file tree
Showing 23 changed files with 80 additions and 80 deletions.
2 changes: 1 addition & 1 deletion aurum/impl/src/Bcc/Ledger/Aurum/Rules/AurumConstraints.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- Developing an Vested Seal evaluator invloves multiple steps to ensure it meets specifications
-- Developing an Vested Sentry evaluator invloves multiple steps to ensure it meets specifications
-- First, we develop a language to express logic problems
type Var = String
type Value = String
Expand Down
2 changes: 1 addition & 1 deletion bcc-ledger-core/src/Bcc/Ledger/BaseTypes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ activeSlotLog f = fromIntegral (unActiveSlotLog f) / fpPrecision

data Globals = Globals
{ epochInfoWithErr :: !(EpochInfo (Either Text)),
-- | the current open seal period
-- | the current open sentry period
vestMultiple :: !Word64,
slotsPerKESPeriod :: !Word64,
-- | The window size in which our chosen chain growth property
Expand Down
4 changes: 2 additions & 2 deletions bcc-ledger-core/src/Bcc/Ledger/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ type family Script era :: Type
-- | AuxiliaryData which may be attached to a transaction
type family AuxiliaryData era = (r :: Type) | r -> era

-- | VestedSealData which is utilized for vested calculations
type family VestedSeal era = ( r :: Type ) | r -> era
-- | VestedSentryData which is utilized for vested calculations
type family VestedSentry era = ( r :: Type ) | r -> era

-- | Protocol parameters
type family PParams era = (r :: Type) | r -> era
Expand Down
4 changes: 2 additions & 2 deletions bcc-ledger-core/src/Bcc/Ledger/Credential.hs
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ instance FromCBORGroup Ptr where
fromCBORGroup = Ptr <$> fromCBOR <*> fromCBOR <*> fromCBOR
-- | instance for Aptr - the vested specific credential pointer
instance ToCBORGroup Aptr where
toCBORGroup (Aptr sl txIx sealIx certIx) =
toCBORGroup (Aptr sl txIx sentryIx certIx) =
toCBOR sl
<> toCBOR txIx
<> toCBOR sealIx
<> toCBOR sentryIx
<> toCBOR certIx
encodedGroupSizeExpr size_ proxy =
encodedSizeExpr size_ (getSlotNo <$> proxy)
Expand Down
4 changes: 2 additions & 2 deletions bcc-ledger-core/src/Bcc/Ledger/addressindev.hs
Original file line number Diff line number Diff line change
Expand Up @@ -459,10 +459,10 @@ getPtr =
<*> getVariableLengthWord64

putAptr :: Aptr -> Put
putAptr (Aptr slot txIx sealIx certIx) = do
putAptr (Aptr slot txIx sentryIx certIx) = do
putSlot slot
putVariableLengthWord64 txIx
putVariableLengthWord64 sealIx
putVariableLengthWord64 sentryIx
putVariableLengthWord64 certIx
where
putSlot (SlotNo n) = putVariableLengthWord64 n
Expand Down
8 changes: 4 additions & 4 deletions bcc-protocol-toptimum/src/Bcc/Protocol/TOptimum.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,26 @@ import GHC.Generics (Generic)
import NoThunks.Class (NoThunks (..))
import Numeric.Natural (Natural)

data ProtVer = ProtVer {pvMajor :: !Natural, pvSeal :: !Natural}
data ProtVer = ProtVer {pvMajor :: !Natural, pvSentry :: !Natural}
deriving (Show, Eq, Generic, Ord, NFData)
deriving (ToCBOR) via (CBORGroup ProtVer)
deriving (FromCBOR) via (CBORGroup ProtVer)

instance NoThunks ProtVer

instance ToJSON ProtVer where
toJSON (ProtVer major seal) =
toJSON (ProtVer major sentry) =
Aeson.object
[ "major" .= major,
"seal" .= seal
"sentry" .= sentry
]

instance FromJSON ProtVer where
parseJSON =
Aeson.withObject "ProtVer" $ \obj ->
ProtVer
<$> obj .: "major"
<*> obj .: "seal"
<*> obj .: "sentry"

instance ToCBORGroup ProtVer where
toCBORGroup (ProtVer x y ) = toCBOR x <> toCBOR y
Expand Down
10 changes: 5 additions & 5 deletions cole/ledger/executable-spec/src/Cole/Spec/Ledger/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ verify :: Eq a => VKey -> a -> Sig a -> Bool
verify (VKey vk) vd (Sig sd sk) = vk == sk && vd == sd

---------------------------------------------------------------------------------
-- Slots, Epochs, Seals
-- Slots, Epochs, Sentrys
---------------------------------------------------------------------------------

newtype Epoch = Epoch {unEpoch :: Word64}
Expand All @@ -191,7 +191,7 @@ newtype Slot = Slot {unSlot :: Word64}
deriving newtype (Eq, Ord, Hashable, ToCBOR, NoThunks)
deriving anyclass (HasTypeReps)

newtype Seal = Seal {unSeal :: Word64}
newtype Sentry = Sentry {unSentry :: Word64}
deriving stock (Show, Generic, Data, Typeable)
deriving newtype (Eq, Ord, Hashable, ToCBOR, NoThunks)
deriving anyclass (HasTypeReps)
Expand Down Expand Up @@ -520,7 +520,7 @@ deriveShepard ''Owner
deriveShepard ''Sig
deriveShepard ''Slot
deriveShepard ''SlotCount
deriveShepard ''Seal
deriveShepard ''Sentry
deriveShepard ''VKey
deriveShepard ''VKeyGenesis
deriveShepard ''VKeyVested
Expand Down Expand Up @@ -559,7 +559,7 @@ deriveAddShrinks ''Hash
deriveAddShrinks ''Entropic
deriveAddShrinks ''Owner
deriveAddShrinks ''Sig
deriveAddShrinks ''Seal
deriveAddShrinks ''Sentry
deriveAddShrinks ''Slot
deriveAddShrinks ''SlotCount
deriveAddShrinks ''VKey
Expand All @@ -576,7 +576,7 @@ deriveSeedShepard ''Epoch
deriveSeedShepard ''Hash
deriveSeedShepard ''Entropic
deriveSeedShepard ''Owner
deriveSeedShepard ''Seal
deriveSeedShepard ''Sentry
deriveSeedShepard ''Slot
deriveSeedShepard ''SlotCount
deriveSeedShepard ''VKey
Expand Down
8 changes: 4 additions & 4 deletions cole/ledger/executable-spec/src/Cole/Spec/Ledger/Update.hs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ newtype UpId = UpId Int
-- | Protocol version
data ProtVer = ProtVer
{ _pvMaj :: Natural,
_pvSeal :: Natural
_pvSentry :: Natural
}
deriving (Eq, Generic, Ord, Show, Hashable, Data, Typeable, NoThunks)

Expand Down Expand Up @@ -1100,20 +1100,20 @@ instance HasTrace UPIREG where
nextAltVersion
<$> Gen.element
[ (_pvMaj pv + 1, 0),
(_pvMaj pv, _pvSeal pv + 1)
(_pvMaj pv, _pvSentry pv + 1)
]
where
nextAltVersion :: (Natural, Natural) -> ProtVer
nextAltVersion (maj, mn) =
dom (range rpus)
& Set.filter protocolVersionEqualsMajMin
& Set.map _pvSeal
& Set.map _pvSentry
& Set.toDescList
& nextVersion
where
protocolVersionEqualsMajMin :: ProtVer -> Bool
protocolVersionEqualsMajMin pv' =
_pvMaj pv' == maj && _pvSeal pv' == mn
_pvMaj pv' == maj && _pvSentry pv' == mn

nextVersion :: [Natural] -> ProtVer
nextVersion [] = ProtVer maj mn
Expand Down
8 changes: 4 additions & 4 deletions cole/ledger/impl/src/Bcc/Chain/Update/ProtocolVersion.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ import qualified Prelude
-- | Communication protocol version
data ProtocolVersion = ProtocolVersion
{ pvMajor :: !Word16,
pvSeal :: !Word16
pvSentry :: !Word16
}
deriving (Eq, Generic, Ord)
deriving anyclass (NFData, NoThunks)

instance Show ProtocolVersion where
show pv =
intercalate "." [show (pvMajor pv), show (pvSeal pv)]
intercalate "." [show (pvMajor pv), show (pvSentry pv)]

instance Buildable ProtocolVersion where
build = bprint shown
Expand All @@ -37,12 +37,12 @@ instance ToJSON ProtocolVersion

instance ToCBOR ProtocolVersion where
toCBOR pv =
encodeListLen 2 <> toCBOR (pvMajor pv) <> toCBOR (pvSeal pv)
encodeListLen 2 <> toCBOR (pvMajor pv) <> toCBOR (pvSentry pv)

encodedSizeExpr f pv =
1
+ encodedSizeExpr f (pvMajor <$> pv)
+ encodedSizeExpr f (pvSeal <$> pv)
+ encodedSizeExpr f (pvSentry <$> pv)

instance FromCBOR ProtocolVersion where
fromCBOR = do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,11 +445,11 @@ registerProtocolUpdate adoptedPV adoptedPP registeredPUPs proposal = do
pvCanFollow :: ProtocolVersion -> ProtocolVersion -> Bool
pvCanFollow newPV adoptedPV = adoptedPV < newPV && isNextVersion
where
ProtocolVersion newMajor newSeal = newPV
ProtocolVersion adoptedMajor adoptedSeal = adoptedPV
ProtocolVersion newMajor newSentry = newPV
ProtocolVersion adoptedMajor adoptedSentry = adoptedPV
isNextVersion = case newMajor - adoptedMajor of
0 -> newSeal == adoptedSeal + 1
1 -> newSeal == 0
0 -> newSentry == adoptedSentry + 1
1 -> newSentry == 0
_ -> False

-- | Check that the new 'ProtocolParameters' represent a valid update
Expand Down
4 changes: 2 additions & 2 deletions cole/ledger/impl/test/Test/Bcc/Chain/Elaboration/Update.hs
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ elaborateFeePolicy (Abstract.FactorA a) (Abstract.FactorB b) =
elaborateProtocolVersion ::
Abstract.ProtVer ->
Concrete.ProtocolVersion
elaborateProtocolVersion (Abstract.ProtVer major seal) =
elaborateProtocolVersion (Abstract.ProtVer major sentry) =
-- TODO: the abstract version numbers should have the same type as the
-- concrete ones!
Concrete.ProtocolVersion
(fromIntegral major)
(fromIntegral seal)
(fromIntegral sentry)


elaborateSoftwareVersion ::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ instance Crypto c => PrettyA (CompactAddr c) where
-- Sophie.Spec.Ledger.PParams

ppProtVer :: ProtVer -> PDoc
ppProtVer (ProtVer maj se) = ppRecord "Version" [("major", ppNatural maj), ("seal", ppNatural se)]
ppProtVer (ProtVer maj se) = ppRecord "Version" [("major", ppNatural maj), ("sentry", ppNatural se)]

ppPParams :: PParams' Identity era -> PDoc
ppPParams (PParams feeA feeB mbb mtx mbh kd pd em no a0 rho tau d ex pv mutxo mpool) =
Expand Down Expand Up @@ -1495,7 +1495,7 @@ ppGlobals
stab
ran
sec
seal
sentry
maxkes
quor
maxmaj
Expand All @@ -1511,7 +1511,7 @@ ppGlobals
("stabilityWindow", pretty stab),
("randomnessStabilisationWindow", pretty ran),
("securityParameter", pretty sec),
("vestMultiple", pretty seal),
("vestMultiple", pretty sentry),
("maxKESEvo", pretty maxkes),
("quorum", pretty quor),
("maxMajorPV", pretty maxmaj),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import Bcc.Ledger.Keys as X
hashKey,
hashVerKeyVRF,
)
import Bcc.Protocol.TOptimum as X -- #TODO Sophie version depracated, pull in Seal Type from Cole
import Bcc.Protocol.TOptimum as X -- #TODO Sophie version depracated, pull in Sentry Type from Cole
( PoolDistr (..),
individualPoolStake,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ data ValidationErr
= EpochNotLongEnough EpochSize Word64 Rational EpochSize
| MaxKESEvolutionsUnsupported Word64 Word
| QuorumTooSmall Word64 Word64 Word64
| SealNotValid Word64 Word64 Word64
| SentryNotValid Word64 Word64 Word64
deriving (Eq, Show)

describeValidationErr :: ValidationErr -> Text
Expand Down Expand Up @@ -375,16 +375,16 @@ describeValidationErr (QuorumTooSmall q maxTooSmal nodes) =
" genesis nodes 'updateQuorum' must be greater than ",
Text.pack (show maxTooSmal)
]
describeValidationErr (SealNotValid s sealVerVal numSeal ) =
describeValidationErr (SentryNotValid s sentryVerVal numSentry ) =
mconcat
[ "You have specified a 'vestMultiple' which is",
" invalid compared to the seal val verification.",
" invalid compared to the sentry val verification.",
" You requested ",
Text.pack (show s),
", but given ",
Text.pack (show numSeal),
Text.pack (show numSentry),
" vested holders, 'vestMultiple must be greater than",
Text.pack (show sealVerVal)
Text.pack (show sentryVerVal)
]

-- | Do some basic sanity checking on the Sophie genesis file. #TODO vested 777 check
Expand Down Expand Up @@ -412,7 +412,7 @@ validateGenesis
[ checkEpochLength,
checkKesEvolutions,
checkQuorumSize,
checkSealVal,
checkSentryVal,
checkVestedSize
]
checkEpochLength =
Expand Down Expand Up @@ -445,12 +445,12 @@ validateGenesis
in if numGenesisNodes == 0 || sgUpdateQuorum > maxTooSmal
then Nothing
else Just $ QuorumTooSmall sgUpdateQuorum maxTooSmal numGenesisNodes
checkSealVal =
let numSeal = fromIntegral $ length sgVestedDelegs `div` 3
sealVerVal = numSeal `div` 2
in if numSeal == 0 || sgVestMultiple > sealVerVal
checkSentryVal =
let numSentry = fromIntegral $ length sgVestedDelegs `div` 3
sentryVerVal = numSentry `div` 2
in if numSentry == 0 || sgVestMultiple > sentryVerVal
then Nothing
else Just $ SealNotValid sgVestMultiple sealVerVal numSeal
else Just $ SentryNotValid sgVestMultiple sentryVerVal numSentry
checkVestedSize =
let numVested = fromIntegral $ length sgVestedDelegs
maxTooSmal = numVested `div` 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Sophie.Spec.Ledger.HardForks
validatePoolRewardAccountNetID,
allowScriptStakeCredsToEarnRewards,
translateTimeForZerepochScripts,
sealRewards,
sentryRewards,
)
where

Expand All @@ -22,11 +22,11 @@ aggregatedRewards ::
Bool
aggregatedRewards pp = pvMajor (getField @"_protocolVersion" pp) > 2

sealRewards ::
sentryRewards ::
(HasField "_protocolVersion" pp ProtVer) =>
pp ->
Bool
sealRewards pp = pvSeal (getField @"_protocolVersion" pp) > 0
sentryRewards pp = pvSentry (getField @"_protocolVersion" pp) > 0

-- | Starting with protocol version 5, the MIR certs will also be
-- able to transfer funds between the reserves and the treasury.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
-- Module : LedgerState
-- Description : Operational Rules
--
-- This module implements the operation rules for treating UTxO transactions ('Tx') #TODO move seal operations here
-- This module implements the operation rules for treating UTxO transactions ('Tx') #TODO move sentry operations here
-- as state transformations on a ledger state ('LedgerState'),
-- as specified in /A Simplified Formal Specification of a UTxO Ledger/.
module Sophie.Spec.Ledger.LedgerState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ data RewardProvenance crypto = RewardProvenance
blocksCount :: !Integer,
-- | The decentralization parameter.
d :: !Rational,
-- | The Vested Seal dist parameter.
-- | The Vested Sentry dist parameter.
sd :: !Rational,
-- | The number of blocks expected to be produced during the given epoch.
expBlocks :: !Integer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import Sophie.Spec.Ledger.LedgerState
import Sophie.Spec.Ledger.PParams (ProposedPPUpdates (..), ProtVer)
import Sophie.Spec.Ledger.STS.Newpp (NEWPP, NewppEnv (..), NewppState (..))

-- | Update epoch change #TODO sealValidate
-- | Update epoch change #TODO sentryValidate
data UPEC era

newtype UpecPredicateFailure era
Expand Down
Loading

0 comments on commit 2853cbb

Please sign in to comment.