Skip to content

Commit

Permalink
Merge pull request #812 from IntersectMBO/mgalazyn/fix/make-plutus-v2…
Browse files Browse the repository at this point in the history
…-cost-model-era-dependent

Make genesis creation commands era-sensitive
  • Loading branch information
carbolymer authored Jul 19, 2024
2 parents cace0e6 + bce490f commit 403a01e
Show file tree
Hide file tree
Showing 21 changed files with 462 additions and 295 deletions.
3 changes: 2 additions & 1 deletion cardano-cli/cardano-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ library
Cardano.CLI.EraBased.Run
Cardano.CLI.EraBased.Run.Address
Cardano.CLI.EraBased.Run.Address.Info
Cardano.CLI.EraBased.Run.CreateTestnetData
Cardano.CLI.EraBased.Run.Genesis
Cardano.CLI.EraBased.Run.Genesis.Common
Cardano.CLI.EraBased.Run.Genesis.CreateTestnetData
Cardano.CLI.EraBased.Run.Governance
Cardano.CLI.EraBased.Run.Governance.Actions
Cardano.CLI.EraBased.Run.Governance.Committee
Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/EraBased/Commands.hs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pCmds era envCli =
catMaybes
[ fmap AddressCmds <$> pAddressCmds (toCardanoEra era) envCli
, fmap KeyCmds <$> pKeyCmds
, fmap GenesisCmds <$> pGenesisCmds envCli
, fmap GenesisCmds <$> pGenesisCmds (toCardanoEra era) envCli
, fmap GovernanceCmds <$> pGovernanceCmds (toCardanoEra era)
, fmap NodeCmds <$> pNodeCmds
, fmap QueryCmds <$> pQueryCmds (toCardanoEra era) envCli
Expand Down
28 changes: 16 additions & 12 deletions cardano-cli/src/Cardano/CLI/EraBased/Commands/Genesis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ import Cardano.CLI.Types.Common
import Data.Text (Text)

data GenesisCmds era
= GenesisCreate !GenesisCreateCmdArgs
| GenesisCreateCardano !GenesisCreateCardanoCmdArgs
| GenesisCreateStaked !GenesisCreateStakedCmdArgs
| GenesisCreateTestNetData !GenesisCreateTestNetDataCmdArgs
= GenesisCreate !(GenesisCreateCmdArgs era)
| GenesisCreateCardano !(GenesisCreateCardanoCmdArgs era)
| GenesisCreateStaked !(GenesisCreateStakedCmdArgs era)
| GenesisCreateTestNetData !(GenesisCreateTestNetDataCmdArgs era)
| GenesisKeyGenGenesis !GenesisKeyGenGenesisCmdArgs
| GenesisKeyGenDelegate !GenesisKeyGenDelegateCmdArgs
| GenesisKeyGenUTxO !GenesisKeyGenUTxOCmdArgs
Expand All @@ -41,8 +41,9 @@ data GenesisCmds era
| GenesisHashFile !GenesisFile
deriving Show

data GenesisCreateCmdArgs = GenesisCreateCmdArgs
{ keyOutputFormat :: !KeyOutputFormat
data GenesisCreateCmdArgs era = GenesisCreateCmdArgs
{ eon :: !(ShelleyBasedEra era)
, keyOutputFormat :: !KeyOutputFormat
, genesisDir :: !GenesisDir
, numGenesisKeys :: !Word
, numUTxOKeys :: !Word
Expand All @@ -52,8 +53,9 @@ data GenesisCreateCmdArgs = GenesisCreateCmdArgs
}
deriving Show

data GenesisCreateCardanoCmdArgs = GenesisCreateCardanoCmdArgs
{ genesisDir :: !GenesisDir
data GenesisCreateCardanoCmdArgs era = GenesisCreateCardanoCmdArgs
{ eon :: !(ShelleyBasedEra era)
, genesisDir :: !GenesisDir
, numGenesisKeys :: !Word
, numUTxOKeys :: !Word
, mSystemStart :: !(Maybe SystemStart)
Expand All @@ -70,8 +72,9 @@ data GenesisCreateCardanoCmdArgs = GenesisCreateCardanoCmdArgs
}
deriving Show

data GenesisCreateStakedCmdArgs = GenesisCreateStakedCmdArgs
{ keyOutputFormat :: !KeyOutputFormat
data GenesisCreateStakedCmdArgs era = GenesisCreateStakedCmdArgs
{ eon :: !(ShelleyBasedEra era)
, keyOutputFormat :: !KeyOutputFormat
, genesisDir :: !GenesisDir
, numGenesisKeys :: !Word
, numUTxOKeys :: !Word
Expand All @@ -89,8 +92,9 @@ data GenesisCreateStakedCmdArgs = GenesisCreateStakedCmdArgs
}
deriving Show

data GenesisCreateTestNetDataCmdArgs = GenesisCreateTestNetDataCmdArgs
{ specShelley :: !(Maybe FilePath)
data GenesisCreateTestNetDataCmdArgs era = GenesisCreateTestNetDataCmdArgs
{ eon :: !(ShelleyBasedEra era)
, specShelley :: !(Maybe FilePath)
-- ^ Path to the @genesis-shelley@ file to use. If unspecified, a default one will be used.
, specAlonzo :: !(Maybe FilePath)
-- ^ Path to the @genesis-alonzo@ file to use. If unspecified, a default one will be used.
Expand Down
98 changes: 49 additions & 49 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Genesis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ import Data.Word (Word64)
import Options.Applicative hiding (help, str)
import qualified Options.Applicative as Opt

{- HLINT ignore "Use <$>" -}
{- HLINT ignore "Move brackets to avoid $" -}

pGenesisCmds
:: ()
=> EnvCli
=> CardanoEra era
-> EnvCli
-> Maybe (Parser (GenesisCmds era))
pGenesisCmds envCli =
pGenesisCmds era envCli =
subInfoParser
"genesis"
( Opt.progDesc $
Expand Down Expand Up @@ -67,33 +65,33 @@ pGenesisCmds envCli =
subParser "initial-txin" $
Opt.info (pGenesisTxIn envCli) $
Opt.progDesc "Get the TxIn for an initial UTxO based on the verification key"
, Just $
, forEraInEonMaybe era $ \sbe ->
subParser "create-cardano" $
Opt.info (pGenesisCreateCardano envCli) $
Opt.info (pGenesisCreateCardano sbe envCli) $
Opt.progDesc $
mconcat
[ "Create a Byron and Shelley genesis file from a genesis "
, "template and genesis/delegation/spending keys."
]
, Just $
, forEraInEonMaybe era $ \sbe ->
subParser "create" $
Opt.info (pGenesisCreate envCli) $
Opt.info (pGenesisCreate sbe envCli) $
Opt.progDesc $
mconcat
[ "Create a Shelley genesis file from a genesis "
, "template and genesis/delegation/spending keys."
]
, Just $
, forEraInEonMaybe era $ \sbe ->
subParser "create-staked" $
Opt.info (pGenesisCreateStaked envCli) $
Opt.info (pGenesisCreateStaked sbe envCli) $
Opt.progDesc $
mconcat
[ "Create a staked Shelley genesis file from a genesis "
, "template and genesis/delegation/spending keys."
]
, Just $
, forEraInEonMaybe era $ \sbe ->
subParser "create-testnet-data" $
Opt.info (pGenesisCreateTestNetData envCli) $
Opt.info (pGenesisCreateTestNetData sbe envCli) $
Opt.progDesc $
mconcat
[ "Create data to use for starting a testnet."
Expand Down Expand Up @@ -154,10 +152,10 @@ pGenesisTxIn envCli =
<*> pNetworkId envCli
<*> pMaybeOutputFile

pGenesisCreateCardano :: EnvCli -> Parser (GenesisCmds era)
pGenesisCreateCardano envCli =
pGenesisCreateCardano :: ShelleyBasedEra era -> EnvCli -> Parser (GenesisCmds era)
pGenesisCreateCardano sbe envCli =
fmap GenesisCreateCardano $
GenesisCreateCardanoCmdArgs
GenesisCreateCardanoCmdArgs sbe
<$> pGenesisDir
<*> pGenesisNumGenesisKeys
<*> pGenesisNumUTxOKeys
Expand All @@ -181,10 +179,10 @@ pGenesisCreateCardano envCli =
"JSON file with genesis defaults for conway."
<*> pNodeConfigTemplate

pGenesisCreate :: EnvCli -> Parser (GenesisCmds era)
pGenesisCreate envCli =
pGenesisCreate :: ShelleyBasedEra era -> EnvCli -> Parser (GenesisCmds era)
pGenesisCreate sbe envCli =
fmap GenesisCreate $
GenesisCreateCmdArgs
GenesisCreateCmdArgs sbe
<$> pKeyOutputFormat
<*> pGenesisDir
<*> pGenesisNumGenesisKeys
Expand All @@ -193,10 +191,10 @@ pGenesisCreate envCli =
<*> pInitialSupplyNonDelegated
<*> pNetworkId envCli

pGenesisCreateStaked :: EnvCli -> Parser (GenesisCmds era)
pGenesisCreateStaked envCli =
pGenesisCreateStaked :: ShelleyBasedEra era -> EnvCli -> Parser (GenesisCmds era)
pGenesisCreateStaked sbe envCli =
fmap GenesisCreateStaked $
GenesisCreateStakedCmdArgs
GenesisCreateStakedCmdArgs sbe
<$> pKeyOutputFormat
<*> pGenesisDir
<*> pGenesisNumGenesisKeys
Expand All @@ -222,13 +220,13 @@ pGenesisCreateStaked envCli =
, Opt.completer (Opt.bashCompleter "file")
]

pGenesisCreateTestNetData :: EnvCli -> Parser (GenesisCmds era)
pGenesisCreateTestNetData envCli =
pGenesisCreateTestNetData :: ShelleyBasedEra era -> EnvCli -> Parser (GenesisCmds era)
pGenesisCreateTestNetData sbe envCli =
fmap GenesisCreateTestNetData $
GenesisCreateTestNetDataCmdArgs
<$> (optional $ pSpecFile "shelley")
<*> (optional $ pSpecFile "alonzo")
<*> (optional $ pSpecFile "conway")
GenesisCreateTestNetDataCmdArgs sbe
<$> optional (pSpecFile "shelley")
<*> optional (pSpecFile "alonzo")
<*> optional (pSpecFile "conway")
<*> pNumGenesisKeys
<*> pNumPools
<*> pNumStakeDelegs
Expand All @@ -237,18 +235,18 @@ pGenesisCreateTestNetData envCli =
<*> pNumUtxoKeys
<*> pSupply
<*> pSupplyDelegated
<*> (optional $ pNetworkIdForTestnetData envCli)
<*> optional (pNetworkIdForTestnetData envCli)
<*> Opt.optional pRelays
<*> pMaybeSystemStart
<*> pOutputDir
where
pSpecFile era =
pSpecFile eraStr =
Opt.strOption $
mconcat
[ Opt.long $ "spec-" <> era
[ Opt.long $ "spec-" <> eraStr
, Opt.metavar "FILE"
, Opt.help $
"The " <> era <> " specification file to use as input. A default one is generated if omitted."
"The " <> eraStr <> " specification file to use as input. A default one is generated if omitted."
]
pNumGenesisKeys =
Opt.option Opt.auto $
Expand All @@ -275,14 +273,15 @@ pGenesisCreateTestNetData envCli =
pDReps :: CredentialGenerationMode -> String -> String -> Parser DRepCredentials
pDReps mode modeOptionName modeExplanation =
DRepCredentials mode
<$> ( Opt.option Opt.auto $
mconcat
[ Opt.long modeOptionName
, Opt.help $ "The number of DRep credentials to make (default is 0). " <> modeExplanation
, Opt.metavar "INT"
, Opt.value 0
]
)
<$> Opt.option
Opt.auto
( mconcat
[ Opt.long modeOptionName
, Opt.help $ "The number of DRep credentials to make (default is 0). " <> modeExplanation
, Opt.metavar "INT"
, Opt.value 0
]
)
pNumStakeDelegs :: Parser StakeDelegators
pNumStakeDelegs =
pStakeDelegators OnDisk "stake-delegators" "Credentials are written to disk."
Expand All @@ -291,15 +290,16 @@ pGenesisCreateTestNetData envCli =
pStakeDelegators :: CredentialGenerationMode -> String -> String -> Parser StakeDelegators
pStakeDelegators mode modeOptionName modeExplanation =
StakeDelegators mode
<$> ( Opt.option Opt.auto $
mconcat
[ Opt.long modeOptionName
, Opt.help $
"The number of stake delegator credential sets to make (default is 0). " <> modeExplanation
, Opt.metavar "INT"
, Opt.value 0
]
)
<$> Opt.option
Opt.auto
( mconcat
[ Opt.long modeOptionName
, Opt.help $
"The number of stake delegator credential sets to make (default is 0). " <> modeExplanation
, Opt.metavar "INT"
, Opt.value 0
]
)
pNumStuffedUtxoCount :: Parser Word
pNumStuffedUtxoCount =
Opt.option Opt.auto $
Expand Down
Loading

0 comments on commit 403a01e

Please sign in to comment.