diff --git a/cardano-config/src/Cardano/Config/Types.hs b/cardano-config/src/Cardano/Config/Types.hs index 87489acb542..5e645c253c5 100644 --- a/cardano-config/src/Cardano/Config/Types.hs +++ b/cardano-config/src/Cardano/Config/Types.hs @@ -39,7 +39,6 @@ import qualified Data.IP as IP import qualified Data.Text as T import Data.Yaml (decodeFileThrow) import Network.Socket (PortNumber) -import System.Directory (doesFileExist) import System.FilePath ((), takeDirectory) import qualified Cardano.Chain.Update as Update @@ -163,7 +162,7 @@ instance FromJSON NodeConfiguration where parseJSON = withObject "NodeConfiguration" $ \v -> do nId <- v .:? "NodeId" ptcl <- v .: "Protocol" .!= RealPBFT - genFile <- v .: "GenesisFile" .!= "configuration/genesis/genesis.json" + genFile <- v .: "GenesisFile" .!= "genesis/genesis.json" numCoreNode <- v .:? "NumCoreNodes" rNetworkMagic <- v .:? "RequiresNetworkMagic" .!= RequiresNoMagic pbftSignatureThresh <- v .:? "PBftSignatureThreshold" @@ -248,20 +247,15 @@ parseNodeConfigurationFP :: ConfigYamlFilePath -> IO NodeConfiguration parseNodeConfigurationFP (ConfigYamlFilePath fp) = do nc <- decodeFileThrow fp let genFile = unGenesisFile $ ncGenesisFile nc - exists <- doesFileExist genFile - case exists of - -- Genesis file is an absolute path - True -> pure nc - -- Genesis file is a relative path (relative to configuration yaml filepath) - False -> do let d = takeDirectory fp - pure $ nc { ncGenesisFile = GenesisFile $ d genFile } - --- TODO: Make genesisfile relative to configuration file as above. + -- Make genesis file relative to configuration yaml filepath. + let d = takeDirectory fp + pure $ nc { ncGenesisFile = GenesisFile $ d genFile } + parseNodeConfiguration :: NodeProtocolMode -> IO NodeConfiguration parseNodeConfiguration npm = case npm of - MockProtocolMode (NodeMockCLI _ _ cy _) -> decodeFileThrow $ unConfigPath cy - RealProtocolMode (NodeCLI _ _ cy _) -> decodeFileThrow $ unConfigPath cy + MockProtocolMode (NodeMockCLI _ _ cy _) -> parseNodeConfigurationFP cy + RealProtocolMode (NodeCLI _ _ cy _) -> parseNodeConfigurationFP cy -- TODO: we don't want ByronLegacy in Protocol. Let's wrap Protocol with another -- sum type for cases where it's required. diff --git a/configuration/configuration-mainnet.yaml b/configuration/configuration-mainnet.yaml index cb70f66dca8..e09db596f60 100644 --- a/configuration/configuration-mainnet.yaml +++ b/configuration/configuration-mainnet.yaml @@ -5,7 +5,7 @@ ##### Locations ##### -GenesisFile: configuration/mainnet-genesis.json +GenesisFile: mainnet-genesis.json SocketPath: db/node.socket #TODO: These parameters cannot yet be used in the config file, only on the CLI: diff --git a/configuration/log-config-0.liveview.yaml b/configuration/log-config-0.liveview.yaml index 1f854642314..ccd895af91a 100644 --- a/configuration/log-config-0.liveview.yaml +++ b/configuration/log-config-0.liveview.yaml @@ -88,7 +88,7 @@ options: NodeId: Protocol: RealPBFT -GenesisFile: configuration/genesis/genesis.json +GenesisFile: genesis/genesis.json NumCoreNodes: 1 RequiresNetworkMagic: RequiresMagic PBftSignatureThreshold: diff --git a/configuration/log-config-0.yaml b/configuration/log-config-0.yaml index b1d3f91552d..f35cbbed21e 100644 --- a/configuration/log-config-0.yaml +++ b/configuration/log-config-0.yaml @@ -89,7 +89,7 @@ options: NodeId: Protocol: RealPBFT -GenesisFile: configuration/genesis/genesis.json +GenesisFile: genesis/genesis.json NumCoreNodes: 1 RequiresNetworkMagic: RequiresMagic PBftSignatureThreshold: diff --git a/configuration/log-config-1.liveview.yaml b/configuration/log-config-1.liveview.yaml index 8ed65ec376f..486c9ebb9d5 100644 --- a/configuration/log-config-1.liveview.yaml +++ b/configuration/log-config-1.liveview.yaml @@ -82,7 +82,7 @@ options: NodeId: Protocol: RealPBFT -GenesisFile: configuration/genesis/genesis.json +GenesisFile: genesis/genesis.json NumCoreNodes: 1 RequiresNetworkMagic: RequiresMagic PBftSignatureThreshold: diff --git a/configuration/log-config-1.yaml b/configuration/log-config-1.yaml index 2dfa53d7d20..227dfc3e525 100644 --- a/configuration/log-config-1.yaml +++ b/configuration/log-config-1.yaml @@ -88,7 +88,7 @@ options: NodeId: Protocol: RealPBFT -GenesisFile: configuration/genesis/genesis.json +GenesisFile: genesis/genesis.json NumCoreNodes: 1 RequiresNetworkMagic: RequiresMagic PBftSignatureThreshold: diff --git a/configuration/log-config-2.liveview.yaml b/configuration/log-config-2.liveview.yaml index aeb7352dbca..c4216beb30a 100644 --- a/configuration/log-config-2.liveview.yaml +++ b/configuration/log-config-2.liveview.yaml @@ -88,7 +88,7 @@ options: NodeId: Protocol: RealPBFT -GenesisFile: configuration/genesis/genesis.json +GenesisFile: genesis/genesis.json NumCoreNodes: 1 RequiresNetworkMagic: RequiresMagic PBftSignatureThreshold: diff --git a/configuration/log-config-2.yaml b/configuration/log-config-2.yaml index 2bdde12216d..aa7831c5b8d 100644 --- a/configuration/log-config-2.yaml +++ b/configuration/log-config-2.yaml @@ -94,7 +94,7 @@ options: NodeId: Protocol: RealPBFT -GenesisFile: configuration/genesis/genesis.json +GenesisFile: genesis/genesis.json NumCoreNodes: 1 RequiresNetworkMagic: RequiresMagic PBftSignatureThreshold: