Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cardano-testnet: modify API to accept user-provided configuration file #6099

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions cardano-testnet/src/Testnet/Start/Cardano.hs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ cardanoTestnetDefault testnetOptions shelleyOptions conf = do
AnyShelleyBasedEra sbe <- pure cardanoNodeEra
alonzoGenesis <- getDefaultAlonzoGenesis sbe
shelleyGenesis <- getDefaultShelleyGenesis cardanoNodeEra cardanoMaxSupply shelleyOptions
cardanoTestnet testnetOptions conf shelleyGenesis alonzoGenesis Defaults.defaultConwayGenesis
cardanoTestnet testnetOptions conf Nothing shelleyGenesis alonzoGenesis Defaults.defaultConwayGenesis
where
CardanoTestnetOptions{cardanoNodeEra, cardanoMaxSupply} = testnetOptions

Expand Down Expand Up @@ -194,13 +194,14 @@ cardanoTestnet :: ()
=> HasCallStack
=> CardanoTestnetOptions -- ^ The options to use
-> Conf
-> Maybe FilePath -- ^ The node configuration file to use. If omitted it's generated.
-> ShelleyGenesis StandardCrypto -- ^ The shelley genesis to use, for example 'getDefaultShelleyGenesis' from this module.
-- Some fields are overridden by the accompanying 'CardanoTestnetOptions'.
-> AlonzoGenesis -- ^ The alonzo genesis to use, for example 'getDefaultAlonzoGenesis' from this module.
-> ConwayGenesis StandardCrypto -- ^ The conway genesis to use, for example 'Defaults.defaultConwayGenesis'.
-> H.Integration TestnetRuntime
cardanoTestnet
testnetOptions Conf{tempAbsPath=TmpAbsolutePath tmpAbsPath}
testnetOptions Conf{tempAbsPath=TmpAbsolutePath tmpAbsPath} mNodeConfigFile
shelleyGenesis alonzoGenesis conwayGenesis = do
let CardanoTestnetOptions
{ cardanoNodeEra=asbe
Expand Down Expand Up @@ -232,8 +233,6 @@ cardanoTestnet
writeGenesisSpecFile "alonzo" alonzoGenesis
writeGenesisSpecFile "conway" conwayGenesis

configurationFile <- H.noteShow . File $ tmpAbsPath </> "configuration.yaml"

_ <- createSPOGenesisAndFiles nPools nDReps maxSupply asbe shelleyGenesis alonzoGenesis conwayGenesis (TmpAbsolutePath tmpAbsPath)

-- TODO: This should come from the configuration!
Expand Down Expand Up @@ -272,12 +271,18 @@ cardanoTestnet
}
}

-- Add Byron, Shelley and Alonzo genesis hashes to node configuration
config <- createConfigJson (TmpAbsolutePath tmpAbsPath) sbe
H.evalIO $ LBS.writeFile (unFile configurationFile) config
nodeConfigFile <- case mNodeConfigFile of
Nothing -> do
configurationFile <- H.noteShow $ tmpAbsPath </> "configuration.yaml"
-- Add Byron, Shelley and Alonzo genesis hashes to node configuration
config <- createConfigJson (TmpAbsolutePath tmpAbsPath) sbe
H.evalIO $ LBS.writeFile configurationFile config
return configurationFile
Just userSubmittedNodeConfigFile -> pure userSubmittedNodeConfigFile

execCli_
[ "debug", "check-node-configuration"
, "--node-configuration-file", unFile configurationFile
, "--node-configuration-file", nodeConfigFile
]

portNumbersWithNodeOptions <- forM cardanoNodes $ \nodeOption -> (nodeOption,) <$> H.randomPort testnetDefaultIpv4Address
Expand Down Expand Up @@ -324,7 +329,7 @@ cardanoTestnet
eRuntime <- runExceptT . retryOnAddressInUseError $
startNode (TmpAbsolutePath tmpAbsPath) nodeName testnetDefaultIpv4Address port testnetMagic $
[ "run"
, "--config", unFile configurationFile
, "--config", nodeConfigFile
, "--topology", nodeDataDir </> "topology.json"
, "--database-path", nodeDataDir </> "db"
]
Expand Down Expand Up @@ -352,7 +357,7 @@ cardanoTestnet
H.cat . verificationKeyFp $ paymentKeyInfoPair wallet

let runtime = TestnetRuntime
{ configurationFile
{ configurationFile = File nodeConfigFile
, shelleyGenesisFile = tmpAbsPath </> Defaults.defaultGenesisFilepath ShelleyEra
, testnetMagic
, testnetNodes=testnetNodes'
Expand Down
Loading