Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
smelc committed Sep 25, 2024
1 parent f6296b2 commit 5181d0a
Show file tree
Hide file tree
Showing 4 changed files with 191 additions and 182 deletions.
1 change: 1 addition & 0 deletions cardano-cli/cardano-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ test-suite cardano-cli-golden
cborg,
containers,
directory,
exceptions,
extra,
filepath,
hedgehog ^>=1.4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import qualified Cardano.CLI.EraBased.Commands.Governance.DRep as DRep
import qualified Cardano.CLI.EraBased.Commands.Node as Cmd
import Cardano.CLI.EraBased.Run.Address (generateAndWriteKeyFiles)
import Cardano.CLI.EraBased.Run.Genesis.Common
import qualified Cardano.CLI.EraBased.Run.Genesis.NodeConfiguration as NodeConfiguration
import qualified Cardano.CLI.EraBased.Run.Governance.DRep as DRep
import qualified Cardano.CLI.EraBased.Run.Key as Key
import Cardano.CLI.EraBased.Run.Node (runNodeIssueOpCertCmd, runNodeKeyGenColdCmd,
Expand Down Expand Up @@ -337,39 +338,51 @@ runGenesisCreateTestNetDataCmd
liftIO $ LBS.writeFile shelleyGenesisPath $ Aeson.encode shelleyGenesis'
liftIO $ LBS.writeFile alonzoGenesisPath $ Aeson.encode alonzoGenesis

case specNodeConfig of
Nothing -> {- TODO create fresh node config -} pure ()
Just inputNodeConfigPath -> do
let tmpOutputNodeConfigPath = outputDir </> "config.tmp.json"
tmpOutputNodeConfigPath2 = outputDir </> "config.tmp.2.json"
outputNodeConfigPath = outputDir </> "config.json"
-- Write hashes
conwayGenesisHash <- getShelleyOnwardsGenesisHash conwayGenesisPath
shelleyGenesisHash <- getShelleyOnwardsGenesisHash shelleyGenesisPath
alonzoGenesisHash <- getShelleyOnwardsGenesisHash alonzoGenesisPath
liftIO $ copyFile inputNodeConfigPath tmpOutputNodeConfigPath
liftIO $
writeGenesisHashesToNodeConfigFile
tmpOutputNodeConfigPath
( Map.fromList
[ ("ConwayGenesisHash", conwayGenesisHash)
, ("ShelleyGenesisHash", shelleyGenesisHash)
, ("AlonzoGenesisHash", alonzoGenesisHash)
]
)
tmpOutputNodeConfigPath2
-- Write filepaths
liftIO $
writeGenesisPathsToNodeConfigFile
tmpOutputNodeConfigPath2
( Map.fromList
[ ("ConwayGenesisFile", Text.pack $ conwayGenesisFilename)
, ("ShelleyGenesisFile", Text.pack $ shelleyGenesisFilename)
, ("AlonzoGenesisFile", Text.pack $ alonzoGenesisFilename)
]
)
outputNodeConfigPath
liftIO $ forM_ [tmpOutputNodeConfigPath, tmpOutputNodeConfigPath2] removeFile
(inputNodeConfigPath, rmInputNodeConfigPath) <-
case specNodeConfig of
Nothing -> do
-- Use a default template, delete it afterwards
let result = outputDir </> "config.template.json"
liftIO $ LBS.writeFile result $ Aeson.encode $ NodeConfiguration.defaultHardforkViaConfig eon
return (result, True)
Just x ->
-- Use the template used as input, don't delete it afterwards
pure (x, False)

let tmpOutputNodeConfigPath = outputDir </> "config.tmp.json"
tmpOutputNodeConfigPath2 = outputDir </> "config.tmp.2.json"
outputNodeConfigPath = outputDir </> "config.json"
-- Write hashes
conwayGenesisHash <- getShelleyOnwardsGenesisHash conwayGenesisPath
shelleyGenesisHash <- getShelleyOnwardsGenesisHash shelleyGenesisPath
alonzoGenesisHash <- getShelleyOnwardsGenesisHash alonzoGenesisPath
liftIO $ copyFile inputNodeConfigPath tmpOutputNodeConfigPath
liftIO $
writeGenesisHashesToNodeConfigFile
tmpOutputNodeConfigPath
( Map.fromList
[ ("ConwayGenesisHash", conwayGenesisHash)
, ("ShelleyGenesisHash", shelleyGenesisHash)
, ("AlonzoGenesisHash", alonzoGenesisHash)
]
)
tmpOutputNodeConfigPath2
-- Write filepaths
liftIO $
writeGenesisPathsToNodeConfigFile
tmpOutputNodeConfigPath2
( Map.fromList
[ ("ConwayGenesisFile", Text.pack $ conwayGenesisFilename)

Check notice

Code scanning / HLint

Redundant $ Note

cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis/CreateTestnetData.hs:375:47: Suggestion: Redundant $
  
Found:
  Text.pack $ conwayGenesisFilename
  
Perhaps:
  Text.pack conwayGenesisFilename
, ("ShelleyGenesisFile", Text.pack $ shelleyGenesisFilename)

Check notice

Code scanning / HLint

Redundant $ Note

cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis/CreateTestnetData.hs:376:48: Suggestion: Redundant $
  
Found:
  Text.pack $ shelleyGenesisFilename
  
Perhaps:
  Text.pack shelleyGenesisFilename
, ("AlonzoGenesisFile", Text.pack $ alonzoGenesisFilename)

Check notice

Code scanning / HLint

Redundant $ Note

cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis/CreateTestnetData.hs:377:47: Suggestion: Redundant $
  
Found:
  Text.pack $ alonzoGenesisFilename
  
Perhaps:
  Text.pack alonzoGenesisFilename
]
)
outputNodeConfigPath
-- Cleanup
liftIO $
forM_
([tmpOutputNodeConfigPath, tmpOutputNodeConfigPath2] ++ [inputNodeConfigPath | rmInputNodeConfigPath])
removeFile
where
genesisDir = outputDir </> "genesis-keys"
delegateDir = outputDir </> "delegate-keys"
Expand Down
Loading

0 comments on commit 5181d0a

Please sign in to comment.