Context
Part 1 of #6510. Pure refactoring — no behavior change.
This refactoring is necessary to enable the realisation of #6511 in a way that is robust (statically checked). Check #6510 for more details.
This PR is meant to be a pure refactoring — there should be no behaviour changes.
Originally #6512 proposed extracting testnet path conventions into a new cardano-testnet-paths micro-package. However, since both cardano-testnet and tx-generator already depend on cardano-node, we can place the shared path definitions directly in the cardano-node package instead. This avoids introducing a new package while achieving the same compile-time safety for directory layout conventions.
Unused path definitions will be dead-code eliminated by GHC and won't appear in the cardano-node executable.
This replaces #6512.
Changes
New: module in cardano-node (e.g. Cardano.Node.Testnet.Paths)
Add a new module to the cardano-node library. Depends only on base and filepath (already available). Exports:
defaultNodeName :: Int -> String -- "node" <> show n
defaultNodeDataDir :: Int -> FilePath -- "node-data" </> defaultNodeName n
defaultUtxoKeyDir :: Int -> FilePath -- "utxo-keys" </> "utxo" <> show n
defaultUtxoSKeyPath :: Int -> FilePath -- defaultUtxoKeyDir n </> "utxo.skey"
defaultUtxoVKeyPath :: Int -> FilePath -- defaultUtxoKeyDir n </> "utxo.vkey"
defaultUtxoAddrPath :: Int -> FilePath -- defaultUtxoKeyDir n </> "utxo.addr"
defaultSocketDir :: FilePath -- "socket"
defaultSocketName :: FilePath -- "sock"
defaultSocketPath :: Int -> FilePath -- defaultSocketDir </> defaultNodeName n </> defaultSocketName
defaultConfigFile :: FilePath -- "configuration.yaml"
defaultPortFile :: Int -> FilePath -- defaultNodeDataDir n </> "port"
Modify: cardano-testnet/src/Testnet/Defaults.hs
Import and re-use defaultNodeName, defaultNodeDataDir from the new module instead of defining locally. defaultUtxoKeys delegates to defaultUtxoSKeyPath and defaultUtxoVKeyPath for path construction.
Modify: cardano-testnet/src/Testnet/Runtime.hs
Import defaultSocketDir, defaultSocketName from the new module instead of using bare "socket" and "sock" string literals.
Modify: cardano-testnet/src/Testnet/Filepath.hs
Import defaultSocketDir from the new module instead of using bare "socket" string literal.
Modify: cardano-testnet/src/Testnet/Start/Cardano.hs
Import defaultConfigFile and defaultUtxoAddrPath from the new module instead of using inline string literals.
Modify: cardano-testnet/cardano-testnet.cabal
No new dependency needed — cardano-testnet already depends on cardano-node.
Advantages over #6512
- No new package (
cardano-testnet-paths) to create and maintain
- No changes to
cabal.project
- Both consumers (
cardano-testnet, tx-generator) already depend on cardano-node
- GHC prunes unused definitions from the node executable — no binary size or runtime cost
Context
Part 1 of #6510. Pure refactoring — no behavior change.
This refactoring is necessary to enable the realisation of #6511 in a way that is robust (statically checked). Check #6510 for more details.
This PR is meant to be a pure refactoring — there should be no behaviour changes.
Originally #6512 proposed extracting testnet path conventions into a new
cardano-testnet-pathsmicro-package. However, since bothcardano-testnetandtx-generatoralready depend oncardano-node, we can place the shared path definitions directly in thecardano-nodepackage instead. This avoids introducing a new package while achieving the same compile-time safety for directory layout conventions.Unused path definitions will be dead-code eliminated by GHC and won't appear in the
cardano-nodeexecutable.This replaces #6512.
Changes
New: module in
cardano-node(e.g.Cardano.Node.Testnet.Paths)Add a new module to the
cardano-nodelibrary. Depends only onbaseandfilepath(already available). Exports:Modify:
cardano-testnet/src/Testnet/Defaults.hsImport and re-use
defaultNodeName,defaultNodeDataDirfrom the new module instead of defining locally.defaultUtxoKeysdelegates todefaultUtxoSKeyPathanddefaultUtxoVKeyPathfor path construction.Modify:
cardano-testnet/src/Testnet/Runtime.hsImport
defaultSocketDir,defaultSocketNamefrom the new module instead of using bare"socket"and"sock"string literals.Modify:
cardano-testnet/src/Testnet/Filepath.hsImport
defaultSocketDirfrom the new module instead of using bare"socket"string literal.Modify:
cardano-testnet/src/Testnet/Start/Cardano.hsImport
defaultConfigFileanddefaultUtxoAddrPathfrom the new module instead of using inline string literals.Modify:
cardano-testnet/cardano-testnet.cabalNo new dependency needed —
cardano-testnetalready depends oncardano-node.Advantages over #6512
cardano-testnet-paths) to create and maintaincabal.projectcardano-testnet,tx-generator) already depend oncardano-node