@@ -36,6 +36,9 @@ module Ouroboros.Consensus.Cardano.Node (
36
36
, CardanoHardForkTriggers (.. , CardanoHardForkTriggers' , triggerHardForkShelley , triggerHardForkAllegra , triggerHardForkMary , triggerHardForkAlonzo , triggerHardForkBabbage , triggerHardForkConway )
37
37
, CardanoProtocolParams (.. )
38
38
, MaxMajorProtVer (.. )
39
+ , ProtocolParamsByron
40
+ , ProtocolParamsShelleyBased
41
+ , CheckpointsMap
39
42
, TriggerHardFork (.. )
40
43
, protocolClientInfoCardano
41
44
, protocolInfoCardano
@@ -64,8 +67,8 @@ import qualified Cardano.Ledger.Api.Transition as L
64
67
import qualified Cardano.Ledger.BaseTypes as SL
65
68
import qualified Cardano.Ledger.Shelley.API as SL
66
69
import Cardano.Prelude (cborError )
67
- import qualified Cardano.Protocol.TPraos.OCert as Absolute (KESPeriod (.. ),
68
- ocertKESPeriod )
70
+ import qualified Cardano.Protocol.TPraos.OCert as Absolute (KESPeriod (.. ))
71
+ import qualified Cardano.Protocol.TPraos.OCert as SL
69
72
import Cardano.Slotting.Time (SystemStart (SystemStart ))
70
73
import qualified Codec.CBOR.Decoding as CBOR
71
74
import Codec.CBOR.Encoding (Encoding )
@@ -100,10 +103,8 @@ import Ouroboros.Consensus.Ledger.Extended
100
103
import Ouroboros.Consensus.Node.NetworkProtocolVersion
101
104
import Ouroboros.Consensus.Node.ProtocolInfo
102
105
import Ouroboros.Consensus.Node.Run
103
- import qualified Ouroboros.Consensus.Protocol.Ledger.HotKey as HotKey
104
106
import Ouroboros.Consensus.Protocol.Praos (Praos , PraosParams (.. ))
105
- import Ouroboros.Consensus.Protocol.Praos.Common
106
- (praosCanBeLeaderOpCert )
107
+ import Ouroboros.Consensus.Protocol.Praos.Common (PraosCanBeLeader (.. ), instantiatePraosCredentials )
107
108
import Ouroboros.Consensus.Protocol.TPraos (TPraos , TPraosParams (.. ))
108
109
import qualified Ouroboros.Consensus.Protocol.TPraos as Shelley
109
110
import Ouroboros.Consensus.Shelley.HFEras ()
@@ -112,9 +113,9 @@ import qualified Ouroboros.Consensus.Shelley.Ledger as Shelley
112
113
import Ouroboros.Consensus.Shelley.Ledger.Block (IsShelleyBlock ,
113
114
ShelleyBlockLedgerEra )
114
115
import Ouroboros.Consensus.Shelley.Ledger.NetworkProtocolVersion
116
+ import qualified Ouroboros.Consensus.Protocol.Ledger.HotKey as HotKey
115
117
import Ouroboros.Consensus.Shelley.Node
116
- import Ouroboros.Consensus.Shelley.Node.Common (ShelleyEraWithCrypto ,
117
- shelleyBlockIssuerVKey )
118
+ import Ouroboros.Consensus.Shelley.Node.Common (ShelleyEraWithCrypto , shelleyBlockIssuerVKey )
118
119
import qualified Ouroboros.Consensus.Shelley.Node.Praos as Praos
119
120
import qualified Ouroboros.Consensus.Shelley.Node.TPraos as TPraos
120
121
import Ouroboros.Consensus.Storage.Serialisation
@@ -609,12 +610,12 @@ protocolInfoCardano paramsCardano
609
610
, length credssShelleyBased > 1
610
611
= error " Multiple Shelley-based credentials not allowed for mainnet"
611
612
| otherwise
612
- = assertWithMsg (validateGenesis genesisShelley)
613
+ = assertWithMsg (validateGenesis genesisShelley) $
613
614
( ProtocolInfo {
614
615
pInfoConfig = cfg
615
616
, pInfoInitLedger = initExtLedgerStateCardano
616
617
}
617
- , blockForging
618
+ , mkBlockForgings
618
619
)
619
620
where
620
621
CardanoProtocolParams {
@@ -975,8 +976,8 @@ protocolInfoCardano paramsCardano
975
976
-- credentials. If there are multiple Shelley credentials, we merge the
976
977
-- Byron credentials with the first Shelley one but still have separate
977
978
-- threads for the remaining Shelley ones.
978
- blockForging :: m [BlockForging m (CardanoBlock c )]
979
- blockForging = do
979
+ mkBlockForgings :: m ( [BlockForging m (CardanoBlock c )])
980
+ mkBlockForgings = do
980
981
shelleyBased <- traverse blockForgingShelleyBased credssShelleyBased
981
982
let blockForgings :: [NonEmptyOptNP (BlockForging m ) (CardanoEras c )]
982
983
blockForgings = case (mBlockForgingByron, shelleyBased) of
@@ -1002,24 +1003,26 @@ protocolInfoCardano paramsCardano
1002
1003
ShelleyLeaderCredentials c
1003
1004
-> m (NonEmptyOptNP (BlockForging m ) (CardanoEras c ))
1004
1005
blockForgingShelleyBased credentials = do
1005
- let ShelleyLeaderCredentials
1006
- { shelleyLeaderCredentialsInitSignKey = initSignKey
1007
- , shelleyLeaderCredentialsCanBeLeader = canBeLeader
1008
- } = credentials
1009
-
1010
- hotKey <- do
1011
- let maxKESEvo :: Word64
1012
- maxKESEvo = assert (tpraosMaxKESEvo == praosMaxKESEvo) praosMaxKESEvo
1013
-
1014
- startPeriod :: Absolute. KESPeriod
1015
- startPeriod = Absolute. ocertKESPeriod $ praosCanBeLeaderOpCert canBeLeader
1016
-
1017
- HotKey. mkHotKey @ m @ c initSignKey startPeriod maxKESEvo
1006
+ let canBeLeader = shelleyLeaderCredentialsCanBeLeader credentials
1018
1007
1019
1008
let slotToPeriod :: SlotNo -> Absolute. KESPeriod
1020
1009
slotToPeriod (SlotNo slot) = assert (tpraosSlotsPerKESPeriod == praosSlotsPerKESPeriod) $
1021
1010
Absolute. KESPeriod $ fromIntegral $ slot `div` praosSlotsPerKESPeriod
1022
1011
1012
+ (ocert, sk) <- instantiatePraosCredentials (praosCanBeLeaderCredentialsSource canBeLeader)
1013
+
1014
+ let startPeriod :: Absolute. KESPeriod
1015
+ startPeriod = SL. ocertKESPeriod ocert
1016
+
1017
+ let maxKESEvo :: Word64
1018
+ maxKESEvo = assert (tpraosMaxKESEvo == praosMaxKESEvo) praosMaxKESEvo
1019
+
1020
+ hotKey :: HotKey. HotKey c m <- HotKey. mkHotKey
1021
+ ocert
1022
+ sk
1023
+ startPeriod
1024
+ maxKESEvo
1025
+
1023
1026
let tpraos :: forall era .
1024
1027
ShelleyEraWithCrypto c (TPraos c) era
1025
1028
=> BlockForging m (ShelleyBlock (TPraos c) era)
0 commit comments