Skip to content

Commit

Permalink
CardanoHardForkTriggers: add crypto c parameter
Browse files Browse the repository at this point in the history
This makes a few things more convenient in a follow-up commit, and should be
very easy for downstream users to adapt to.
  • Loading branch information
amesgen committed Nov 11, 2024
1 parent 8736167 commit 66b5b9d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -543,20 +543,19 @@ toTriggerHardFork = \case
CardanoTriggerHardForkAtEpoch epochNo ->
TriggerHardForkAtEpoch epochNo

newtype CardanoHardForkTriggers = CardanoHardForkTriggers {
newtype CardanoHardForkTriggers c = CardanoHardForkTriggers {
getCardanoHardForkTriggers ::
NP CardanoHardForkTrigger (CardanoShelleyEras StandardCrypto)
NP CardanoHardForkTrigger (CardanoShelleyEras c)
}

pattern CardanoHardForkTriggers' ::
(c ~ StandardCrypto)
=> CardanoHardForkTrigger (ShelleyBlock (TPraos c) (ShelleyEra c))
CardanoHardForkTrigger (ShelleyBlock (TPraos c) (ShelleyEra c))
-> CardanoHardForkTrigger (ShelleyBlock (TPraos c) (AllegraEra c))
-> CardanoHardForkTrigger (ShelleyBlock (TPraos c) (MaryEra c))
-> CardanoHardForkTrigger (ShelleyBlock (TPraos c) (AlonzoEra c))
-> CardanoHardForkTrigger (ShelleyBlock (Praos c) (BabbageEra c))
-> CardanoHardForkTrigger (ShelleyBlock (Praos c) (ConwayEra c))
-> CardanoHardForkTriggers
-> CardanoHardForkTriggers c
pattern CardanoHardForkTriggers' {
triggerHardForkShelley
, triggerHardForkAllegra
Expand Down Expand Up @@ -602,7 +601,7 @@ pattern CardanoHardForkTriggers' {
data CardanoProtocolParams c = CardanoProtocolParams {
byronProtocolParams :: ProtocolParamsByron
, shelleyBasedProtocolParams :: ProtocolParamsShelleyBased c
, cardanoHardForkTriggers :: CardanoHardForkTriggers
, cardanoHardForkTriggers :: CardanoHardForkTriggers c
, cardanoLedgerTransitionConfig :: L.TransitionConfig (L.LatestKnownEra c)
, cardanoCheckpoints :: CheckpointsMap (CardanoBlock c)
-- | The greatest protocol version that this node's software and config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ protocolVersionZero = SL.ProtVer versionZero 0
versionZero :: SL.Version
versionZero = SL.natVersion @0

hardForkOnDefaultProtocolVersions :: CardanoHardForkTriggers
hardForkOnDefaultProtocolVersions :: CardanoHardForkTriggers c
hardForkOnDefaultProtocolVersions =
CardanoHardForkTriggers
$ hpure CardanoTriggerHardForkAtDefaultVersion

hardForkInto :: Era -> CardanoHardForkTriggers
hardForkInto :: Era -> CardanoHardForkTriggers c
hardForkInto Byron = hardForkOnDefaultProtocolVersions
hardForkInto Shelley =
hardForkOnDefaultProtocolVersions
Expand Down Expand Up @@ -151,7 +151,7 @@ mkSimpleTestProtocolInfo ::
-> ByronSlotLengthInSeconds
-> ShelleySlotLengthInSeconds
-> SL.ProtVer
-> CardanoHardForkTriggers
-> CardanoHardForkTriggers c
-> ProtocolInfo (CardanoBlock c)
mkSimpleTestProtocolInfo
decentralizationParam
Expand Down Expand Up @@ -230,7 +230,7 @@ mkTestProtocolInfo ::
-- ^ See 'protocolInfoCardano' for the details of what is the
-- relation between this version and any 'TriggerHardForkAtVersion'
-- that __might__ appear in the 'CardanoHardForkTriggers' parameter.
-> CardanoHardForkTriggers
-> CardanoHardForkTriggers c
-- ^ Specification of the era to which the initial state should hard-fork to.
-> (ProtocolInfo (CardanoBlock c), m [BlockForging m (CardanoBlock c)])
mkTestProtocolInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ data CardanoConfig = CardanoConfig {
, conwayGenesisPath :: FilePath

-- | @Test*HardForkAtEpoch@ for each Shelley era
, cfgHardForkTriggers :: CardanoHardForkTriggers
, cfgHardForkTriggers :: CardanoHardForkTriggers StandardCrypto
}

instance AdjustFilePaths CardanoConfig where
Expand Down Expand Up @@ -363,7 +363,7 @@ mkCardanoProtocolInfo ::
-> Maybe PBftSignatureThreshold
-> SL.TransitionConfig (L.LatestKnownEra StandardCrypto)
-> Nonce
-> CardanoHardForkTriggers
-> CardanoHardForkTriggers StandardCrypto
-> ProtocolInfo (CardanoBlock StandardCrypto)
mkCardanoProtocolInfo genesisByron signatureThreshold transitionConfig initialNonce triggers =
fst $ protocolInfoCardano @_ @IO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ data SimpleTestProtocolInfoSetup = SimpleTestProtocolInfoSetup
, securityParam :: SecurityParam
, byronSlotLength :: ByronSlotLengthInSeconds
, shelleySlotLength :: ShelleySlotLengthInSeconds
, hardForkTriggers :: CardanoHardForkTriggers
, hardForkTriggers :: CardanoHardForkTriggers StandardCrypto
}

instance Arbitrary SimpleTestProtocolInfoSetup where
Expand Down

0 comments on commit 66b5b9d

Please sign in to comment.