diff --git a/cardano-node/src/Cardano/Node/Configuration/POM.hs b/cardano-node/src/Cardano/Node/Configuration/POM.hs index 1028f03c9ab..35a5e6ef37a 100644 --- a/cardano-node/src/Cardano/Node/Configuration/POM.hs +++ b/cardano-node/src/Cardano/Node/Configuration/POM.hs @@ -145,6 +145,7 @@ instance FromJSON PartialNodeConfiguration where CardanoProtocol -> Last . Just <$> (NodeProtocolConfigurationCardano <$> parseByronProtocol v <*> parseShelleyProtocol v + <*> parseAlonzoProtocol v <*> parseHardForkProtocol v) pure PartialNodeConfiguration { pncProtocolConfig = pncProtocolConfig' @@ -220,6 +221,24 @@ instance FromJSON PartialNodeConfiguration where , npcShelleyGenesisFileHash } + parseAlonzoProtocol v = do + primary <- v .:? "AlonzoGenesisFile" + secondary <- v .:? "GenesisFile" + npcAlonzoGenesisFile <- + case (primary, secondary) of + (Just g, Nothing) -> return g + (Nothing, Just g) -> return g + (Nothing, Nothing) -> fail $ "Missing required field, either " + ++ "AlonzoGenesisFile or GenesisFile" + (Just _, Just _) -> fail $ "Specify either AlonzoGenesisFile" + ++ "or GenesisFile, but not both" + npcAlonzoGenesisFileHash <- v .:? "AlonzoGenesisHash" + + pure NodeAlonzoProtocolConfiguration { + npcAlonzoGenesisFile + , npcAlonzoGenesisFileHash + } + parseHardForkProtocol v = do npcTestShelleyHardForkAtEpoch <- v .:? "TestShelleyHardForkAtEpoch" npcTestShelleyHardForkAtVersion <- v .:? "TestShelleyHardForkAtVersion" diff --git a/cardano-node/src/Cardano/Node/Protocol.hs b/cardano-node/src/Cardano/Node/Protocol.hs index f5454c9627b..8600be86c31 100644 --- a/cardano-node/src/Cardano/Node/Protocol.hs +++ b/cardano-node/src/Cardano/Node/Protocol.hs @@ -39,11 +39,13 @@ mkConsensusProtocol NodeConfiguration{ncProtocolConfig, ncProtocolFiles} = NodeProtocolConfigurationCardano byronConfig shelleyConfig + alonzoConfig hardForkConfig -> firstExceptT CardanoProtocolInstantiationError $ mkSomeConsensusProtocolCardano byronConfig shelleyConfig + alonzoConfig hardForkConfig (Just ncProtocolFiles) diff --git a/cardano-node/src/Cardano/Node/Protocol/Cardano.hs b/cardano-node/src/Cardano/Node/Protocol/Cardano.hs index 66dc44f2a44..5fd300bcdb9 100644 --- a/cardano-node/src/Cardano/Node/Protocol/Cardano.hs +++ b/cardano-node/src/Cardano/Node/Protocol/Cardano.hs @@ -60,6 +60,7 @@ import Cardano.Node.Protocol.Types mkSomeConsensusProtocolCardano :: NodeByronProtocolConfiguration -> NodeShelleyProtocolConfiguration + -> NodeAlonzoProtocolConfiguration -> NodeHardForkProtocolConfiguration -> Maybe ProtocolFilepaths -> ExceptT CardanoProtocolInstantiationError IO SomeConsensusProtocol @@ -78,6 +79,7 @@ mkSomeConsensusProtocolCardano NodeByronProtocolConfiguration { npcShelleyGenesisFile, npcShelleyGenesisFileHash } + _AlonzoProtocolConfig NodeHardForkProtocolConfiguration { npcTestShelleyHardForkAtEpoch, npcTestShelleyHardForkAtVersion, diff --git a/cardano-node/src/Cardano/Node/Types.hs b/cardano-node/src/Cardano/Node/Types.hs index e2d3d52fd46..b9d7ecd3b06 100644 --- a/cardano-node/src/Cardano/Node/Types.hs +++ b/cardano-node/src/Cardano/Node/Types.hs @@ -43,6 +43,7 @@ module Cardano.Node.Types , NodeHardForkProtocolConfiguration(..) , NodeProtocolConfiguration(..) , NodeShelleyProtocolConfiguration(..) + , NodeAlonzoProtocolConfiguration(..) , VRFPrivateKeyFilePermissionError(..) , protocolName , renderVRFPrivateKeyFilePermissionError @@ -261,9 +262,17 @@ data NodeProtocolConfiguration = | NodeProtocolConfigurationShelley NodeShelleyProtocolConfiguration | NodeProtocolConfigurationCardano NodeByronProtocolConfiguration NodeShelleyProtocolConfiguration + NodeAlonzoProtocolConfiguration NodeHardForkProtocolConfiguration deriving (Eq, Show) +data NodeAlonzoProtocolConfiguration = + NodeAlonzoProtocolConfiguration + { npcAlonzoGenesisFile :: !GenesisFile + , npcAlonzoGenesisFileHash :: !(Maybe GenesisHash) + } deriving (Eq, Show) + + data NodeShelleyProtocolConfiguration = NodeShelleyProtocolConfiguration { npcShelleyGenesisFile :: !GenesisFile @@ -348,17 +357,24 @@ data NodeHardForkProtocolConfiguration = , npcTestMaryHardForkAtEpoch :: Maybe EpochNo -- | For testing purposes we support specifying that the hard fork - -- happens at an exact epoch number (ie the first epoch of the new era). + -- happens at a given major protocol version. -- -- Obviously if this is used, all the nodes in the test cluster must be -- configured the same, or they will disagree. -- + -- , npcTestMaryHardForkAtVersion :: Maybe Word + -- | For testing purposes we support specifying that the hard fork + -- happens at an exact epoch number (ie the first epoch of the new era). + -- + -- Obviously if this is used, all the nodes in the test cluster must be + -- configured the same, or they will disagree. + -- , npcTestAlonzoHardForkAtEpoch :: Maybe EpochNo -- | For testing purposes we support specifying that the hard fork - -- happens at an exact epoch number (ie the first epoch of the new era). + -- happens at a given major protocol version. -- -- Obviously if this is used, all the nodes in the test cluster must be -- configured the same, or they will disagree. @@ -384,9 +400,10 @@ instance AdjustFilePaths NodeProtocolConfiguration where adjustFilePaths f (NodeProtocolConfigurationShelley pc) = NodeProtocolConfigurationShelley (adjustFilePaths f pc) - adjustFilePaths f (NodeProtocolConfigurationCardano pcb pcs pch) = + adjustFilePaths f (NodeProtocolConfigurationCardano pcb pcs pca pch) = NodeProtocolConfigurationCardano (adjustFilePaths f pcb) (adjustFilePaths f pcs) + (adjustFilePaths f pca) pch instance AdjustFilePaths NodeByronProtocolConfiguration where @@ -401,6 +418,14 @@ instance AdjustFilePaths NodeShelleyProtocolConfiguration where } = x { npcShelleyGenesisFile = adjustFilePaths f npcShelleyGenesisFile } + +instance AdjustFilePaths NodeAlonzoProtocolConfiguration where + adjustFilePaths f x@NodeAlonzoProtocolConfiguration { + npcAlonzoGenesisFile + } = + x { npcAlonzoGenesisFile = adjustFilePaths f npcAlonzoGenesisFile } + + instance AdjustFilePaths SocketPath where adjustFilePaths f (SocketPath p) = SocketPath (f p)