@@ -38,6 +38,9 @@ module Ouroboros.Consensus.Cardano.Node (
38
38
, CardanoHardForkTriggers (.. , CardanoHardForkTriggers' , triggerHardForkShelley , triggerHardForkAllegra , triggerHardForkMary , triggerHardForkAlonzo , triggerHardForkBabbage , triggerHardForkConway )
39
39
, CardanoProtocolParams (.. )
40
40
, MaxMajorProtVer (.. )
41
+ , ProtocolParamsByron
42
+ , ProtocolParamsShelleyBased
43
+ , CheckpointsMap
41
44
, TriggerHardFork (.. )
42
45
, protocolClientInfoCardano
43
46
, protocolInfoCardano
@@ -92,10 +95,8 @@ import Ouroboros.Consensus.Ledger.Extended
92
95
import Ouroboros.Consensus.Node.NetworkProtocolVersion
93
96
import Ouroboros.Consensus.Node.ProtocolInfo
94
97
import Ouroboros.Consensus.Node.Run
95
- import qualified Ouroboros.Consensus.Protocol.Ledger.HotKey as HotKey
96
98
import Ouroboros.Consensus.Protocol.Praos (Praos , PraosParams (.. ))
97
- import Ouroboros.Consensus.Protocol.Praos.Common
98
- (praosCanBeLeaderOpCert )
99
+ import Ouroboros.Consensus.Protocol.Praos.Common (PraosCanBeLeader (.. ), instantiatePraosCredentials )
99
100
import Ouroboros.Consensus.Protocol.TPraos (TPraos , TPraosParams (.. ))
100
101
import qualified Ouroboros.Consensus.Protocol.TPraos as Shelley
101
102
import Ouroboros.Consensus.Shelley.HFEras ()
@@ -104,9 +105,9 @@ import qualified Ouroboros.Consensus.Shelley.Ledger as Shelley
104
105
import Ouroboros.Consensus.Shelley.Ledger.Block (IsShelleyBlock ,
105
106
ShelleyBlockLedgerEra )
106
107
import Ouroboros.Consensus.Shelley.Ledger.NetworkProtocolVersion
108
+ import qualified Ouroboros.Consensus.Protocol.Ledger.HotKey as HotKey
107
109
import Ouroboros.Consensus.Shelley.Node
108
- import Ouroboros.Consensus.Shelley.Node.Common (ShelleyEraWithCrypto ,
109
- shelleyBlockIssuerVKey )
110
+ import Ouroboros.Consensus.Shelley.Node.Common (ShelleyEraWithCrypto , shelleyBlockIssuerVKey )
110
111
import qualified Ouroboros.Consensus.Shelley.Node.Praos as Praos
111
112
import qualified Ouroboros.Consensus.Shelley.Node.TPraos as TPraos
112
113
import Ouroboros.Consensus.Storage.Serialisation
@@ -475,12 +476,12 @@ protocolInfoCardano paramsCardano
475
476
, length credssShelleyBased > 1
476
477
= error " Multiple Shelley-based credentials not allowed for mainnet"
477
478
| otherwise
478
- = assertWithMsg (validateGenesis genesisShelley)
479
+ = assertWithMsg (validateGenesis genesisShelley) $
479
480
( ProtocolInfo {
480
481
pInfoConfig = cfg
481
482
, pInfoInitLedger = initExtLedgerStateCardano
482
483
}
483
- , blockForging
484
+ , mkBlockForgings
484
485
)
485
486
where
486
487
CardanoProtocolParams {
@@ -827,8 +828,8 @@ protocolInfoCardano paramsCardano
827
828
-- credentials. If there are multiple Shelley credentials, we merge the
828
829
-- Byron credentials with the first Shelley one but still have separate
829
830
-- threads for the remaining Shelley ones.
830
- blockForging :: m [BlockForging m (CardanoBlock c )]
831
- blockForging = do
831
+ mkBlockForgings :: m ( [BlockForging m (CardanoBlock c )])
832
+ mkBlockForgings = do
832
833
shelleyBased <- traverse blockForgingShelleyBased credssShelleyBased
833
834
let blockForgings :: [NonEmptyOptNP (BlockForging m ) (CardanoEras c )]
834
835
blockForgings = case (mBlockForgingByron, shelleyBased) of
@@ -854,24 +855,26 @@ protocolInfoCardano paramsCardano
854
855
ShelleyLeaderCredentials c
855
856
-> m (NonEmptyOptNP (BlockForging m ) (CardanoEras c ))
856
857
blockForgingShelleyBased credentials = do
857
- let ShelleyLeaderCredentials
858
- { shelleyLeaderCredentialsInitSignKey = initSignKey
859
- , shelleyLeaderCredentialsCanBeLeader = canBeLeader
860
- } = credentials
861
-
862
- hotKey <- do
863
- let maxKESEvo :: Word64
864
- maxKESEvo = assert (tpraosMaxKESEvo == praosMaxKESEvo) praosMaxKESEvo
865
-
866
- startPeriod :: Absolute. KESPeriod
867
- startPeriod = Absolute. ocertKESPeriod $ praosCanBeLeaderOpCert canBeLeader
868
-
869
- HotKey. mkHotKey @ m @ c initSignKey startPeriod maxKESEvo
858
+ let canBeLeader = shelleyLeaderCredentialsCanBeLeader credentials
870
859
871
860
let slotToPeriod :: SlotNo -> Absolute. KESPeriod
872
861
slotToPeriod (SlotNo slot) = assert (tpraosSlotsPerKESPeriod == praosSlotsPerKESPeriod) $
873
862
Absolute. KESPeriod $ fromIntegral $ slot `div` praosSlotsPerKESPeriod
874
863
864
+ (ocert, sk) <- instantiatePraosCredentials (praosCanBeLeaderCredentialsSource canBeLeader)
865
+
866
+ let startPeriod :: Absolute. KESPeriod
867
+ startPeriod = Absolute. ocertKESPeriod ocert
868
+
869
+ let maxKESEvo :: Word64
870
+ maxKESEvo = assert (tpraosMaxKESEvo == praosMaxKESEvo) praosMaxKESEvo
871
+
872
+ hotKey :: HotKey. HotKey c m <- HotKey. mkHotKey
873
+ ocert
874
+ sk
875
+ startPeriod
876
+ maxKESEvo
877
+
875
878
let tpraos :: forall era .
876
879
ShelleyEraWithCrypto c (TPraos c) era
877
880
=> BlockForging m (ShelleyBlock (TPraos c) era)
0 commit comments