@@ -116,6 +116,8 @@ import qualified Cardano.Crypto.ProtocolMagic
116
116
import qualified Cardano.Crypto.VRF as Crypto
117
117
import qualified Cardano.Crypto.VRF.Class as VRF
118
118
import Cardano.Ledger.Alonzo.Genesis (AlonzoGenesis (.. ))
119
+ import qualified Cardano.Ledger.Api.Era as Ledger
120
+ import qualified Cardano.Ledger.Api.Transition as Ledger
119
121
import Cardano.Ledger.BaseTypes (Globals (.. ), Nonce , ProtVer (.. ), natVersion , (⭒) )
120
122
import qualified Cardano.Ledger.BaseTypes as Ledger
121
123
import qualified Cardano.Ledger.BHeaderView as Ledger
@@ -126,7 +128,6 @@ import qualified Cardano.Ledger.PoolDistr as SL
126
128
import qualified Cardano.Ledger.Shelley.API as ShelleyAPI
127
129
import qualified Cardano.Ledger.Shelley.Core as Core
128
130
import qualified Cardano.Ledger.Shelley.Genesis as Ledger
129
- import Cardano.Ledger.Shelley.Translation (emptyFromByronTranslationContext )
130
131
import qualified Cardano.Protocol.TPraos.API as TPraos
131
132
import Cardano.Protocol.TPraos.BHeader (checkLeaderNatValue )
132
133
import qualified Cardano.Protocol.TPraos.BHeader as TPraos
@@ -156,7 +157,6 @@ import Ouroboros.Consensus.Protocol.Abstract (ChainDepState, Consensus
156
157
import qualified Ouroboros.Consensus.Protocol.Abstract as Consensus
157
158
import qualified Ouroboros.Consensus.Protocol.Praos.Common as Consensus
158
159
import Ouroboros.Consensus.Protocol.Praos.VRF (mkInputVRF , vrfLeaderValue )
159
- import Ouroboros.Consensus.Protocol.TPraos (TPraos )
160
160
import qualified Ouroboros.Consensus.Protocol.TPraos as TPraos
161
161
import qualified Ouroboros.Consensus.Shelley.Eras as Shelley
162
162
import qualified Ouroboros.Consensus.Shelley.Ledger.Block as Shelley
@@ -760,18 +760,18 @@ genesisConfigToEnv
760
760
-- enp
761
761
genCfg =
762
762
case genCfg of
763
- GenesisCardano _ bCfg sCfg _ _
764
- | Cardano.Crypto.ProtocolMagic. unProtocolMagicId (Cardano.Chain.Genesis. configProtocolMagicId bCfg) /= Ledger. sgNetworkMagic (scConfig sCfg) ->
763
+ GenesisCardano _ bCfg _ transCfg
764
+ | Cardano.Crypto.ProtocolMagic. unProtocolMagicId (Cardano.Chain.Genesis. configProtocolMagicId bCfg) /= Ledger. sgNetworkMagic shelleyGenesis ->
765
765
Left . NECardanoConfig $
766
766
mconcat
767
767
[ " ProtocolMagicId " , textShow (Cardano.Crypto.ProtocolMagic. unProtocolMagicId $ Cardano.Chain.Genesis. configProtocolMagicId bCfg)
768
- , " /= " , textShow (Ledger. sgNetworkMagic $ scConfig sCfg )
768
+ , " /= " , textShow (Ledger. sgNetworkMagic shelleyGenesis )
769
769
]
770
- | Cardano.Chain.Genesis. gdStartTime (Cardano.Chain.Genesis. configGenesisData bCfg) /= Ledger. sgSystemStart (scConfig sCfg) ->
770
+ | Cardano.Chain.Genesis. gdStartTime (Cardano.Chain.Genesis. configGenesisData bCfg) /= Ledger. sgSystemStart shelleyGenesis ->
771
771
Left . NECardanoConfig $
772
772
mconcat
773
773
[ " SystemStart " , textShow (Cardano.Chain.Genesis. gdStartTime $ Cardano.Chain.Genesis. configGenesisData bCfg)
774
- , " /= " , textShow (Ledger. sgSystemStart $ scConfig sCfg )
774
+ , " /= " , textShow (Ledger. sgSystemStart shelleyGenesis )
775
775
]
776
776
| otherwise ->
777
777
let
@@ -781,6 +781,8 @@ genesisConfigToEnv
781
781
{ envLedgerConfig = Consensus. topLevelConfigLedger topLevelConfig
782
782
, envProtocolConfig = Consensus. topLevelConfigProtocol topLevelConfig
783
783
}
784
+ where
785
+ shelleyGenesis = transCfg ^. Ledger. tcShelleyGenesisL
784
786
785
787
readNodeConfig :: NodeConfigFile 'In -> ExceptT Text IO NodeConfig
786
788
readNodeConfig (File ncf) = do
@@ -804,23 +806,7 @@ data NodeConfig = NodeConfig
804
806
, ncConwayGenesisHash :: ! GenesisHashConway
805
807
, ncRequiresNetworkMagic :: ! Cardano.Crypto. RequiresNetworkMagic
806
808
, ncByronProtocolVersion :: ! Cardano.Chain.Update. ProtocolVersion
807
-
808
- -- Per-era parameters for the hardfok transitions:
809
- , ncByronToShelley :: ! (Consensus. ProtocolTransitionParams
810
- Byron. ByronBlock
811
- (Shelley. ShelleyBlock (TPraos Shelley. StandardCrypto ) Shelley. StandardShelley )
812
- )
813
- , ncShelleyToAllegra :: ! (Consensus. ProtocolTransitionParams
814
- (Shelley. ShelleyBlock (TPraos Shelley. StandardCrypto ) Shelley. StandardShelley )
815
- (Shelley. ShelleyBlock (TPraos Shelley. StandardCrypto ) Shelley. StandardAllegra )
816
- )
817
- , ncAllegraToMary :: ! (Consensus. ProtocolTransitionParams
818
- (Shelley. ShelleyBlock (TPraos Shelley. StandardCrypto ) Shelley. StandardAllegra )
819
- (Shelley. ShelleyBlock (TPraos Shelley. StandardCrypto ) Shelley. StandardMary )
820
- )
821
- , ncMaryToAlonzo :: ! Consensus. TriggerHardFork
822
- , ncAlonzoToBabbage :: ! Consensus. TriggerHardFork
823
- , ncBabbageToConway :: ! Consensus. TriggerHardFork
809
+ , ncHardForkTriggers :: ! Consensus. CardanoHardForkTriggers
824
810
}
825
811
826
812
instance FromJSON NodeConfig where
@@ -841,15 +827,7 @@ instance FromJSON NodeConfig where
841
827
<*> fmap GenesisHashConway (o .: " ConwayGenesisHash" )
842
828
<*> o .: " RequiresNetworkMagic"
843
829
<*> parseByronProtocolVersion o
844
- <*> (Consensus. ProtocolTransitionParamsByronToShelley emptyFromByronTranslationContext
845
- <$> parseShelleyHardForkEpoch o)
846
- <*> (Consensus. ProtocolTransitionParamsIntraShelley ()
847
- <$> parseAllegraHardForkEpoch o)
848
- <*> (Consensus. ProtocolTransitionParamsIntraShelley ()
849
- <$> parseMaryHardForkEpoch o)
850
- <*> parseAlonzoHardForkEpoch o
851
- <*> parseBabbageHardForkEpoch o
852
- <*> parseConwayHardForkEpoch o
830
+ <*> parseHardForkTriggers o
853
831
854
832
parseByronProtocolVersion :: Object -> Parser Cardano.Chain.Update. ProtocolVersion
855
833
parseByronProtocolVersion o =
@@ -858,6 +836,16 @@ instance FromJSON NodeConfig where
858
836
<*> o .: " LastKnownBlockVersion-Minor"
859
837
<*> o .: " LastKnownBlockVersion-Alt"
860
838
839
+ parseHardForkTriggers :: Object -> Parser Consensus. CardanoHardForkTriggers
840
+ parseHardForkTriggers o =
841
+ Consensus. CardanoHardForkTriggers'
842
+ <$> parseShelleyHardForkEpoch o
843
+ <*> parseAllegraHardForkEpoch o
844
+ <*> parseMaryHardForkEpoch o
845
+ <*> parseAlonzoHardForkEpoch o
846
+ <*> parseBabbageHardForkEpoch o
847
+ <*> parseConwayHardForkEpoch o
848
+
861
849
parseShelleyHardForkEpoch :: Object -> Parser Consensus. TriggerHardFork
862
850
parseShelleyHardForkEpoch o =
863
851
asum
@@ -982,9 +970,8 @@ data GenesisConfig
982
970
= GenesisCardano
983
971
! NodeConfig
984
972
! Cardano.Chain.Genesis. Config
985
- ! ShelleyConfig
986
- ! AlonzoGenesis
987
- ! (ConwayGenesis Shelley. StandardCrypto )
973
+ ! GenesisHashShelley
974
+ ! (Ledger. TransitionConfig (Ledger. LatestKnownEra Shelley. StandardCrypto ))
988
975
989
976
newtype LedgerStateDir = LedgerStateDir
990
977
{ unLedgerStateDir :: FilePath
@@ -1003,7 +990,7 @@ mkProtocolInfoCardano ::
1003
990
(Consensus. CardanoEras Consensus. StandardCrypto ))
1004
991
, IO [BlockForging IO (HFC. HardForkBlock
1005
992
(Consensus. CardanoEras Consensus. StandardCrypto ))])
1006
- mkProtocolInfoCardano (GenesisCardano dnc byronGenesis shelleyGenesis alonzoGenesis conwayGenesis )
993
+ mkProtocolInfoCardano (GenesisCardano dnc byronGenesis shelleyGenesisHash transCfg )
1007
994
= Consensus. protocolInfoCardano Consensus. CardanoProtocolParams
1008
995
{ Consensus. paramsByron =
1009
996
Consensus. ProtocolParamsByron
@@ -1016,8 +1003,7 @@ mkProtocolInfoCardano (GenesisCardano dnc byronGenesis shelleyGenesis alonzoGene
1016
1003
}
1017
1004
, Consensus. paramsShelleyBased =
1018
1005
Consensus. ProtocolParamsShelleyBased
1019
- { Consensus. shelleyBasedGenesis = scConfig shelleyGenesis
1020
- , Consensus. shelleyBasedInitialNonce = shelleyPraosNonce shelleyGenesis
1006
+ { Consensus. shelleyBasedInitialNonce = shelleyPraosNonce shelleyGenesisHash
1021
1007
, Consensus. shelleyBasedLeaderCredentials = []
1022
1008
}
1023
1009
, Consensus. paramsShelley =
@@ -1050,43 +1036,25 @@ mkProtocolInfoCardano (GenesisCardano dnc byronGenesis shelleyGenesis alonzoGene
1050
1036
{ Consensus. conwayProtVer = ProtVer (natVersion @ 10 ) 0
1051
1037
, Consensus. conwayMaxTxCapacityOverrides = TxLimits. mkOverrides TxLimits. noOverridesMeasure
1052
1038
}
1053
- , Consensus. transitionParamsByronToShelley =
1054
- ncByronToShelley dnc
1055
- , Consensus. transitionParamsShelleyToAllegra =
1056
- ncShelleyToAllegra dnc
1057
- , Consensus. transitionParamsAllegraToMary =
1058
- ncAllegraToMary dnc
1059
- , Consensus. transitionParamsMaryToAlonzo =
1060
- Consensus. ProtocolTransitionParamsIntraShelley
1061
- { Consensus. transitionIntraShelleyTranslationContext = alonzoGenesis
1062
- , Consensus. transitionIntraShelleyTrigger = ncMaryToAlonzo dnc
1063
- }
1064
- , Consensus. transitionParamsAlonzoToBabbage =
1065
- Consensus. ProtocolTransitionParamsIntraShelley
1066
- { Consensus. transitionIntraShelleyTranslationContext = ()
1067
- , Consensus. transitionIntraShelleyTrigger = ncAlonzoToBabbage dnc
1068
- }
1069
- , Consensus. transitionParamsBabbageToConway =
1070
- Consensus. ProtocolTransitionParamsIntraShelley
1071
- { Consensus. transitionIntraShelleyTranslationContext = conwayGenesis
1072
- , Consensus. transitionIntraShelleyTrigger = ncBabbageToConway dnc
1073
- }
1039
+ , Consensus. hardForkTriggers = ncHardForkTriggers dnc
1040
+ , Consensus. ledgerTransitionConfig = transCfg
1074
1041
}
1075
1042
1076
- -- | Compute the Nonce from the ShelleyGenesis file.
1077
- shelleyPraosNonce :: ShelleyConfig -> Ledger. Nonce
1078
- shelleyPraosNonce sCfg =
1079
- Ledger. Nonce (Cardano.Crypto.Hash.Class. castHash . unGenesisHashShelley $ scGenesisHash sCfg )
1043
+ -- | Compute the Nonce from the hash of the Genesis file.
1044
+ shelleyPraosNonce :: GenesisHashShelley -> Ledger. Nonce
1045
+ shelleyPraosNonce genesisHash =
1046
+ Ledger. Nonce (Cardano.Crypto.Hash.Class. castHash $ unGenesisHashShelley genesisHash )
1080
1047
1081
1048
readCardanoGenesisConfig
1082
1049
:: NodeConfig
1083
1050
-> ExceptT GenesisConfigError IO GenesisConfig
1084
- readCardanoGenesisConfig enc =
1085
- GenesisCardano enc
1086
- <$> readByronGenesisConfig enc
1087
- <*> readShelleyGenesisConfig enc
1088
- <*> readAlonzoGenesisConfig enc
1089
- <*> readConwayGenesisConfig enc
1051
+ readCardanoGenesisConfig enc = do
1052
+ byronGenesis <- readByronGenesisConfig enc
1053
+ ShelleyConfig shelleyGenesis shelleyGenesisHash <- readShelleyGenesisConfig enc
1054
+ alonzoGenesis <- readAlonzoGenesisConfig enc
1055
+ conwayGenesis <- readConwayGenesisConfig enc
1056
+ let transCfg = Ledger. mkLatestTransitionConfig shelleyGenesis alonzoGenesis conwayGenesis
1057
+ pure $ GenesisCardano enc byronGenesis shelleyGenesisHash transCfg
1090
1058
1091
1059
data GenesisConfigError
1092
1060
= NEError ! Text
0 commit comments