From bce490ff96858d2c264af8c42c0d54f8fdfc4d1b Mon Sep 17 00:00:00 2001 From: Mateusz Galazyn Date: Tue, 2 Jul 2024 16:49:55 +0200 Subject: [PATCH] Make genesis creation commands era-sensitive --- cardano-cli/cardano-cli.cabal | 3 +- .../src/Cardano/CLI/EraBased/Commands.hs | 2 +- .../Cardano/CLI/EraBased/Commands/Genesis.hs | 28 ++-- .../Cardano/CLI/EraBased/Options/Genesis.hs | 98 ++++++------- .../src/Cardano/CLI/EraBased/Run/Genesis.hs | 122 ++++++---------- .../CLI/EraBased/Run/Genesis/Common.hs | 136 ++++++++++++++++++ .../Run/{ => Genesis}/CreateTestnetData.hs | 102 ++----------- .../CLI/EraBased/Run/Governance/DRep.hs | 2 +- .../src/Cardano/CLI/EraBased/Run/Query.hs | 14 +- .../Cardano/CLI/EraBased/Run/Transaction.hs | 2 +- .../Cardano/CLI/Legacy/Commands/Genesis.hs | 3 + cardano-cli/src/Cardano/CLI/Legacy/Options.hs | 9 +- .../src/Cardano/CLI/Legacy/Run/Genesis.hs | 36 +++-- .../CLI/Types/Errors/GenesisCmdError.hs | 44 +++--- .../cardano-cli-golden/files/golden/help.cli | 60 +++++++- .../golden/help/genesis_create-cardano.cli | 16 ++- .../golden/help/genesis_create-staked.cli | 16 ++- .../files/golden/help/genesis_create.cli | 16 ++- .../help/legacy_genesis_create-cardano.cli | 16 ++- .../help/legacy_genesis_create-staked.cli | 16 ++- .../golden/help/legacy_genesis_create.cli | 16 ++- 21 files changed, 462 insertions(+), 295 deletions(-) create mode 100644 cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis/Common.hs rename cardano-cli/src/Cardano/CLI/EraBased/Run/{ => Genesis}/CreateTestnetData.hs (90%) diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index 023f6bea04..91d19955b5 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -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 diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands.hs index 9baa344a89..f00b05a6b0 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands.hs @@ -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 diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Genesis.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Genesis.hs index c6df5dba9d..b37258c7bb 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Genesis.hs @@ -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 @@ -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 @@ -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) @@ -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 @@ -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. diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Genesis.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Genesis.hs index e0fcb7ee0b..87fa312377 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Genesis.hs @@ -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 $ @@ -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." @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 $ @@ -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." @@ -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 $ diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs index cd1c7bd661..4b8c9e29f8 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs @@ -12,14 +12,8 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TupleSections #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} {-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-} -{- HLINT ignore "Replace case with maybe" -} -{- HLINT ignore "Reduce duplication" -} -{- HLINT ignore "Redundant <$>" -} -{- HLINT ignore "Use let" -} - module Cardano.CLI.EraBased.Run.Genesis ( runGenesisCmds , runGenesisAddrCmd @@ -30,9 +24,6 @@ module Cardano.CLI.EraBased.Run.Genesis , runGenesisKeyHashCmd , runGenesisTxInCmd , runGenesisVerKeyCmd - - -- * Protocol Parameters - , readProtocolParameters ) where @@ -55,7 +46,8 @@ import Cardano.CLI.Byron.Genesis as Byron import qualified Cardano.CLI.Byron.Key as Byron import Cardano.CLI.EraBased.Commands.Genesis as Cmd import qualified Cardano.CLI.EraBased.Commands.Node as Cmd -import qualified Cardano.CLI.EraBased.Run.CreateTestnetData as TN +import Cardano.CLI.EraBased.Run.Genesis.Common +import qualified Cardano.CLI.EraBased.Run.Genesis.CreateTestnetData as TN import Cardano.CLI.EraBased.Run.Node (runNodeIssueOpCertCmd, runNodeKeyGenColdCmd, runNodeKeyGenKesCmd, runNodeKeyGenVrfCmd) import Cardano.CLI.EraBased.Run.StakeAddress (runStakeAddressKeyGenCmd) @@ -63,7 +55,6 @@ import qualified Cardano.CLI.IO.Lazy as Lazy import Cardano.CLI.Types.Common import Cardano.CLI.Types.Errors.GenesisCmdError import Cardano.CLI.Types.Errors.NodeCmdError -import Cardano.CLI.Types.Errors.ProtocolParamsError import Cardano.CLI.Types.Errors.StakePoolCmdError import Cardano.CLI.Types.Key import qualified Cardano.Crypto as CC @@ -74,6 +65,7 @@ import Cardano.Slotting.Slot (EpochSize (EpochSize)) import Ouroboros.Consensus.Shelley.Node (ShelleyGenesisStaking (..)) import Control.DeepSeq (NFData, force) +import Control.Exception (evaluate) import Control.Monad (forM, forM_, unless, when) import Data.Aeson hiding (Key) import qualified Data.Aeson as Aeson @@ -84,7 +76,6 @@ import Data.ByteString (ByteString) import qualified Data.ByteString.Char8 as BS import qualified Data.ByteString.Lazy.Char8 as LBS import Data.Char (isDigit) -import Data.Either (fromRight) import Data.Fixed (Fixed (MkFixed)) import Data.Function (on) import Data.Functor (void) @@ -241,11 +232,12 @@ writeOutput Nothing = Text.putStrLn -- runGenesisCreateCmd - :: GenesisCreateCmdArgs + :: GenesisCreateCmdArgs era -> ExceptT GenesisCmdError IO () runGenesisCreateCmd Cmd.GenesisCreateCmdArgs - { Cmd.keyOutputFormat + { Cmd.eon + , Cmd.keyOutputFormat , Cmd.genesisDir , Cmd.numGenesisKeys , Cmd.numUTxOKeys @@ -257,15 +249,16 @@ runGenesisCreateCmd gendir = rootdir "genesis-keys" deldir = rootdir "delegate-keys" utxodir = rootdir "utxo-keys" + era = toCardanoEra eon liftIO $ do createDirectoryIfMissing False rootdir createDirectoryIfMissing False gendir createDirectoryIfMissing False deldir createDirectoryIfMissing False utxodir - template <- readShelleyGenesisWithDefault (rootdir "genesis.spec.json") adjustTemplate - alonzoGenesis <- readAlonzoGenesis (rootdir "genesis.alonzo.spec.json") - conwayGenesis <- readConwayGenesis (rootdir "genesis.conway.spec.json") + template <- decodeShelleyGenesisWithDefault (rootdir "genesis.spec.json") adjustTemplate + alonzoGenesis <- decodeAlonzoGenesisFile (Just era) $ rootdir "genesis.alonzo.spec.json" + conwayGenesis <- decodeConwayGenesisFile $ rootdir "genesis.conway.spec.json" forM_ [1 .. numGenesisKeys] $ \index -> do createGenesisKeys gendir index @@ -276,7 +269,7 @@ runGenesisCreateCmd genDlgs <- readGenDelegsMap gendir deldir utxoAddrs <- readInitialFundAddresses utxodir network - start <- maybe (SystemStart <$> TN.getCurrentTimePlus30) pure mSystemStart + start <- maybe (SystemStart <$> getCurrentTimePlus30) pure mSystemStart let shelleyGenesis = updateTemplate @@ -385,11 +378,12 @@ generateShelleyNodeSecrets shelleyDelegateKeys shelleyGenesisvkeys = do -- runGenesisCreateCardanoCmd - :: GenesisCreateCardanoCmdArgs + :: GenesisCreateCardanoCmdArgs era -> ExceptT GenesisCmdError IO () runGenesisCreateCardanoCmd Cmd.GenesisCreateCardanoCmdArgs - { Cmd.genesisDir + { Cmd.eon + , Cmd.genesisDir , Cmd.numGenesisKeys , Cmd.numUTxOKeys , Cmd.mSystemStart @@ -404,7 +398,7 @@ runGenesisCreateCardanoCmd , Cmd.conwayGenesisTemplate , Cmd.mNodeConfigTemplate } = do - start <- maybe (SystemStart <$> TN.getCurrentTimePlus30) pure mSystemStart + start <- maybe (SystemStart <$> getCurrentTimePlus30) pure mSystemStart (byronGenesis', byronSecrets) <- convertToShelleyError $ Byron.mkGenesis $ byronParams start let byronGenesis = @@ -431,6 +425,7 @@ runGenesisCreateCardanoCmd utxoKeys = gsPoorSecrets byronSecrets byronUtxoKeys = map (ByronSigningKey . Genesis.poorSecretToKey) utxoKeys shelleyUtxoKeys = map (convertPoor . Genesis.poorSecretToKey) utxoKeys + era = toCardanoEra eon dlgCerts <- convertToShelleyError $ mapM (findDelegateCert byronGenesis) byronDelegateKeys let @@ -438,22 +433,18 @@ runGenesisCreateCardanoCmd t { sgNetworkMagic = unNetworkMagic (toNetworkMagic network) , sgNetworkId = toShelleyNetwork network - , sgActiveSlotsCoeff = - fromMaybe (error $ "Could not convert from Rational: " ++ show slotCoeff) $ - L.boundRational slotCoeff + , sgActiveSlotsCoeff = unsafeBoundedRational slotCoeff , sgSecurityParam = unBlockCount security , sgUpdateQuorum = fromIntegral $ ((numGenesisKeys `div` 3) * 2) + 1 , sgEpochLength = EpochSize $ floor $ (fromIntegral (unBlockCount security) * 10) / slotCoeff , sgMaxLovelaceSupply = 45_000_000_000_000_000 , sgSystemStart = getSystemStart start - , sgSlotLength = L.secondsToNominalDiffTimeMicro $ MkFixed (fromIntegral slotLength) * 1000 + , sgSlotLength = L.secondsToNominalDiffTimeMicro $ MkFixed (fromIntegral slotLength) * 1_000 } shelleyGenesisTemplate' <- - liftIO $ - overrideShelleyGenesis . fromRight (error "shelley genesis template not found") - <$> TN.readAndDecodeGenesisFile shelleyGenesisTemplate - alonzoGenesis <- readAlonzoGenesis alonzoGenesisTemplate - conwayGenesis <- readConwayGenesis conwayGenesisTemplate + overrideShelleyGenesis <$> decodeShelleyGenesisFile shelleyGenesisTemplate + alonzoGenesis <- decodeAlonzoGenesisFile (Just era) alonzoGenesisTemplate + conwayGenesis <- decodeConwayGenesisFile conwayGenesisTemplate (delegateMap, vrfKeys, kesKeys, opCerts) <- liftIO $ generateShelleyNodeSecrets shelleyDelegateKeys shelleyGenesisvkeys let @@ -581,11 +572,12 @@ runGenesisCreateCardanoCmd dlgCertMap byronGenesis = Genesis.unGenesisDelegation $ Genesis.gdHeavyDelegation byronGenesis runGenesisCreateStakedCmd - :: GenesisCreateStakedCmdArgs + :: GenesisCreateStakedCmdArgs era -> ExceptT GenesisCmdError IO () runGenesisCreateStakedCmd Cmd.GenesisCreateStakedCmdArgs - { Cmd.keyOutputFormat + { eon + , Cmd.keyOutputFormat , Cmd.genesisDir , Cmd.numGenesisKeys , Cmd.numUTxOKeys @@ -606,6 +598,7 @@ runGenesisCreateStakedCmd pooldir = rootdir "pools" stdeldir = rootdir "stake-delegator-keys" utxodir = rootdir "utxo-keys" + era = toCardanoEra eon liftIO $ do createDirectoryIfMissing False rootdir @@ -615,9 +608,9 @@ runGenesisCreateStakedCmd createDirectoryIfMissing False stdeldir createDirectoryIfMissing False utxodir - template <- readShelleyGenesisWithDefault (rootdir "genesis.spec.json") adjustTemplate - alonzoGenesis <- readAlonzoGenesis (rootdir "genesis.alonzo.spec.json") - conwayGenesis <- readConwayGenesis (rootdir "genesis.conway.spec.json") + template <- decodeShelleyGenesisWithDefault (rootdir "genesis.spec.json") adjustTemplate + alonzoGenesis <- decodeAlonzoGenesisFile (Just era) $ rootdir "genesis.alonzo.spec.json" + conwayGenesis <- decodeConwayGenesisFile $ rootdir "genesis.conway.spec.json" forM_ [1 .. numGenesisKeys] $ \index -> do createGenesisKeys gendir index @@ -626,11 +619,11 @@ runGenesisCreateStakedCmd forM_ [1 .. numUTxOKeys] $ \index -> createUtxoKeys utxodir index - mayStakePoolRelays <- forM mStakePoolRelaySpecFile TN.readRelays + mStakePoolRelays <- forM mStakePoolRelaySpecFile readRelays poolParams <- forM [1 .. numPools] $ \index -> do createPoolCredentials keyOutputFormat pooldir index - buildPoolParams networkId pooldir (Just index) (fromMaybe mempty mayStakePoolRelays) + buildPoolParams networkId pooldir (Just index) (fromMaybe mempty mStakePoolRelays) when (numBulkPoolCredFiles * numBulkPoolsPerFile > numPools) $ left $ @@ -662,11 +655,11 @@ runGenesisCreateStakedCmd genDlgs <- readGenDelegsMap gendir deldir nonDelegAddrs <- readInitialFundAddresses utxodir networkId - start <- maybe (SystemStart <$> TN.getCurrentTimePlus30) pure mSystemStart + start <- maybe (SystemStart <$> getCurrentTimePlus30) pure mSystemStart let network = toShelleyNetwork networkId stuffedUtxoAddrs <- - liftIO $ Lazy.replicateM (fromIntegral numStuffedUtxo) $ TN.genStuffedAddress network + liftIO $ Lazy.replicateM (fromIntegral numStuffedUtxo) $ genStuffedAddress network let stake = second L.ppId . mkDelegationMapEntry <$> delegations stakePools = [(L.ppId poolParams', poolParams') | poolParams' <- snd . mkDelegationMapEntry <$> delegations] @@ -999,7 +992,7 @@ writeBulkPoolCredentials dir bulkIx poolIxs = do content <- handleIOExceptT (GenesisCmdFileError . FileIOError fp) $ BS.readFile fp - firstExceptT (GenesisCmdAesonDecodeError fp . Text.pack) . hoistEither $ + firstExceptT (GenesisCmdFileDecodeError fp . Text.pack) . hoistEither $ Aeson.eitherDecodeStrict' content -- | This function should only be used for testing purposes. @@ -1014,31 +1007,29 @@ computeInsecureDelegation g0 nw pool = do (stakeVK, g2) <- first getVerificationKey <$> generateInsecureSigningKey g1 AsStakeKey let stakeAddressReference = StakeAddressByValue . StakeCredentialByKey . verificationKeyHash $ stakeVK - let initialUtxoAddr = + initialUtxoAddr = makeShelleyAddress nw (PaymentCredentialByKey (verificationKeyHash paymentVK)) stakeAddressReference - delegation <- - pure $ - force + delegation = Delegation { dInitialUtxoAddr = shelleyAddressInEra ShelleyBasedEraShelley initialUtxoAddr , dDelegStaking = L.hashKey (unStakeVerificationKey stakeVK) , dPoolParams = pool } - pure (g2, delegation) + evaluate . force $ (g2, delegation) -- | Attempts to read Shelley genesis from disk -- and if not found creates a default Shelley genesis. -readShelleyGenesisWithDefault +decodeShelleyGenesisWithDefault :: FilePath -> (ShelleyGenesis L.StandardCrypto -> ShelleyGenesis L.StandardCrypto) -> ExceptT GenesisCmdError IO (ShelleyGenesis L.StandardCrypto) -readShelleyGenesisWithDefault fpath adjustDefaults = do - newExceptT (TN.readAndDecodeGenesisFile fpath) +decodeShelleyGenesisWithDefault fpath adjustDefaults = do + decodeShelleyGenesisFile fpath `catchError` \err -> case err of - GenesisCmdGenesisFileReadError (FileIOError _ ioe) + GenesisCmdGenesisFileError (FileIOError _ ioe) | isDoesNotExistError ioe -> writeDefault _ -> left err where @@ -1374,36 +1365,3 @@ runGenesisHashFileCmd (GenesisFile fpath) = do let gh :: Crypto.Hash Crypto.Blake2b_256 ByteString gh = Crypto.hashWith id content liftIO $ Text.putStrLn (Crypto.hashToTextAsHex gh) - -readAlonzoGenesis - :: FilePath - -> ExceptT GenesisCmdError IO L.AlonzoGenesis -readAlonzoGenesis fpath = do - lbs <- handleIOExceptT (GenesisCmdGenesisFileError . FileIOError fpath) $ LBS.readFile fpath - firstExceptT (GenesisCmdAesonDecodeError fpath . Text.pack) - . hoistEither - $ Aeson.eitherDecode' lbs - -readConwayGenesis - :: FilePath - -> ExceptT GenesisCmdError IO (L.ConwayGenesis L.StandardCrypto) -readConwayGenesis fpath = do - lbs <- handleIOExceptT (GenesisCmdGenesisFileError . FileIOError fpath) $ LBS.readFile fpath - firstExceptT (GenesisCmdAesonDecodeError fpath . Text.pack) - . hoistEither - $ Aeson.eitherDecode' lbs - --- Protocol Parameters - --- TODO: eliminate this and get only the necessary params, and get them in a more --- helpful way rather than requiring them as a local file. -readProtocolParameters - :: () - => ShelleyBasedEra era - -> ProtocolParamsFile - -> ExceptT ProtocolParamsError IO (L.PParams (ShelleyLedgerEra era)) -readProtocolParameters sbe (ProtocolParamsFile fpath) = do - pparams <- handleIOExceptT (ProtocolParamsErrorFile . FileIOError fpath) $ LBS.readFile fpath - firstExceptT (ProtocolParamsErrorJSON fpath . Text.pack) . hoistEither $ - shelleyBasedEraConstraints sbe $ - Aeson.eitherDecode' pparams diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis/Common.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis/Common.hs new file mode 100644 index 0000000000..287c14002c --- /dev/null +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis/Common.hs @@ -0,0 +1,136 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE DerivingStrategies #-} +{-# LANGUAGE DuplicateRecordFields #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeApplications #-} + +module Cardano.CLI.EraBased.Run.Genesis.Common + ( decodeShelleyGenesisFile + , decodeAlonzoGenesisFile + , decodeConwayGenesisFile + , genStuffedAddress + , getCurrentTimePlus30 + , readRelays + + -- * Protocol Parameters + , readProtocolParameters + ) +where + +import Cardano.Api hiding (ConwayEra) +import Cardano.Api.Ledger (AlonzoGenesis, ConwayGenesis, StandardCrypto) +import qualified Cardano.Api.Ledger as L +import Cardano.Api.Shelley (Address (ShelleyAddress), ShelleyGenesis, ShelleyLedgerEra, + decodeAlonzoGenesis) + +import Cardano.CLI.Types.Common +import Cardano.CLI.Types.Errors.GenesisCmdError +import Cardano.CLI.Types.Errors.ProtocolParamsError +import Cardano.Crypto.Hash (HashAlgorithm) +import qualified Cardano.Crypto.Hash as Hash +import qualified Cardano.Crypto.Random as Crypto + +import qualified Data.Aeson as A +import qualified Data.Binary.Get as Bin +import Data.ByteString (ByteString) +import qualified Data.ByteString.Lazy.Char8 as LBS +import Data.Coerce (coerce) +import Data.Data (Proxy (..)) +import Data.Map.Strict (Map) +import qualified Data.Text as Text +import Data.Time (NominalDiffTime, UTCTime, addUTCTime, getCurrentTime) +import Data.Word (Word64) + +import Crypto.Random (getRandomBytes) + +decodeShelleyGenesisFile + :: MonadIOTransError GenesisCmdError t m + => FilePath + -> t m (ShelleyGenesis StandardCrypto) +decodeShelleyGenesisFile = readAndDecodeGenesisFileWith A.eitherDecode + +-- | Decode Alonzo Genesis file. See 'Cardano.Api.Genesis.decodeAlonzoGenesis' haddocks for details. +decodeAlonzoGenesisFile + :: MonadIOTransError GenesisCmdError t m + => Maybe (CardanoEra era) + -- ^ Optional era in which we're decoding alonzo genesis. + -> FilePath + -> t m AlonzoGenesis +decodeAlonzoGenesisFile mEra = readAndDecodeGenesisFileWith (runExcept . decodeAlonzoGenesis mEra) + +decodeConwayGenesisFile + :: MonadIOTransError GenesisCmdError t m + => FilePath + -> t m (ConwayGenesis StandardCrypto) +decodeConwayGenesisFile = readAndDecodeGenesisFileWith A.eitherDecode + +readAndDecodeGenesisFileWith + :: MonadIOTransError GenesisCmdError t m + => (LBS.ByteString -> Either String a) + -> FilePath + -> t m a +readAndDecodeGenesisFileWith decode' fpath = do + lbs <- + handleIOExceptionsLiftWith (GenesisCmdGenesisFileError . FileIOError fpath) . liftIO $ + LBS.readFile fpath + modifyError (GenesisCmdGenesisFileDecodeError fpath . Text.pack) + . hoistEither + $ decode' lbs + +genStuffedAddress :: L.Network -> IO (AddressInEra ShelleyEra) +genStuffedAddress network = do + paymentCredential <- + L.KeyHashObj . mkKeyHash . read64BitInt <$> Crypto.runSecureRandom (getRandomBytes 8) + pure . shelleyAddressInEra ShelleyBasedEraShelley $ + ShelleyAddress network paymentCredential L.StakeRefNull + where + read64BitInt :: ByteString -> Int + read64BitInt = + (fromIntegral :: Word64 -> Int) + . Bin.runGet Bin.getWord64le + . LBS.fromStrict + + mkDummyHash :: forall h a. HashAlgorithm h => Proxy h -> Int -> Hash.Hash h a + mkDummyHash _ = coerce . L.hashWithSerialiser @h L.toCBOR + + mkKeyHash :: forall c discriminator. L.Crypto c => Int -> L.KeyHash discriminator c + mkKeyHash = L.KeyHash . mkDummyHash (Proxy @(L.ADDRHASH c)) + +-- | Current UTCTime plus 30 seconds +getCurrentTimePlus30 :: MonadIO m => m UTCTime +getCurrentTimePlus30 = + plus30sec <$> liftIO getCurrentTime + where + plus30sec :: UTCTime -> UTCTime + plus30sec = addUTCTime (30 :: NominalDiffTime) + +-- @readRelays fp@ reads the relays specification from a file +readRelays + :: () + => MonadIO m + => FilePath + -- ^ The file to read from + -> ExceptT GenesisCmdError m (Map Word [L.StakePoolRelay]) +readRelays fp = do + relaySpecJsonBs <- + handleIOExceptT (GenesisCmdStakePoolRelayFileError fp) (LBS.readFile fp) + firstExceptT (GenesisCmdStakePoolRelayJsonDecodeError fp) + . hoistEither + $ A.eitherDecode relaySpecJsonBs + +-- TODO: eliminate this and get only the necessary params, and get them in a more +-- helpful way rather than requiring them as a local file. +readProtocolParameters + :: () + => ShelleyBasedEra era + -> ProtocolParamsFile + -> ExceptT ProtocolParamsError IO (L.PParams (ShelleyLedgerEra era)) +readProtocolParameters sbe (ProtocolParamsFile fpath) = do + pparams <- handleIOExceptT (ProtocolParamsErrorFile . FileIOError fpath) $ LBS.readFile fpath + firstExceptT (ProtocolParamsErrorJSON fpath . Text.pack) . hoistEither $ + shelleyBasedEraConstraints sbe $ + A.eitherDecode' pparams diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/CreateTestnetData.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis/CreateTestnetData.hs similarity index 90% rename from cardano-cli/src/Cardano/CLI/EraBased/Run/CreateTestnetData.hs rename to cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis/CreateTestnetData.hs index d9cb37f5ae..89b31839a3 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/CreateTestnetData.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis/CreateTestnetData.hs @@ -12,15 +12,8 @@ {-# LANGUAGE TupleSections #-} {-# LANGUAGE TypeApplications #-} -{- HLINT ignore "Redundant <$>" -} -{- HLINT ignore "Use let" -} - -module Cardano.CLI.EraBased.Run.CreateTestnetData - ( genStuffedAddress - , getCurrentTimePlus30 - , readRelays - , readAndDecodeGenesisFile - , runGenesisKeyGenUTxOCmd +module Cardano.CLI.EraBased.Run.Genesis.CreateTestnetData + ( runGenesisKeyGenUTxOCmd , runGenesisKeyGenGenesisCmd , runGenesisKeyGenDelegateCmd , runGenesisCreateTestNetDataCmd @@ -31,8 +24,8 @@ where import Cardano.Api hiding (ConwayEra) import Cardano.Api.Ledger (StrictMaybe (SNothing)) import qualified Cardano.Api.Ledger as L -import Cardano.Api.Shelley (Address (ShelleyAddress), - Hash (DRepKeyHash, GenesisDelegateKeyHash, GenesisKeyHash, StakeKeyHash, VrfKeyHash), +import Cardano.Api.Shelley + (Hash (DRepKeyHash, GenesisDelegateKeyHash, GenesisKeyHash, StakeKeyHash, VrfKeyHash), KESPeriod (KESPeriod), OperationalCertificateIssueCounter (OperationalCertificateIssueCounter), ShelleyGenesis (ShelleyGenesis, sgGenDelegs, sgInitialFunds, sgMaxLovelaceSupply, sgNetworkMagic, sgProtocolParams, sgStaking, sgSystemStart), @@ -44,6 +37,7 @@ import Cardano.CLI.EraBased.Commands.Genesis as Cmd 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.Governance.DRep as DRep import qualified Cardano.CLI.EraBased.Run.Key as Key import Cardano.CLI.EraBased.Run.Node (runNodeIssueOpCertCmd, runNodeKeyGenColdCmd, @@ -55,20 +49,13 @@ import Cardano.CLI.Types.Errors.GenesisCmdError import Cardano.CLI.Types.Errors.NodeCmdError import Cardano.CLI.Types.Errors.StakePoolCmdError import Cardano.CLI.Types.Key -import Cardano.Crypto.Hash (HashAlgorithm) -import qualified Cardano.Crypto.Hash as Hash -import qualified Cardano.Crypto.Random as Crypto import Ouroboros.Consensus.Shelley.Node (ShelleyGenesisStaking (..)) import Control.DeepSeq (NFData, deepseq) import Control.Monad (forM, forM_, unless, void, when) import qualified Data.Aeson as Aeson import Data.Bifunctor (Bifunctor (..)) -import qualified Data.Binary.Get as Bin -import Data.ByteString (ByteString) import qualified Data.ByteString.Lazy.Char8 as LBS -import Data.Coerce (coerce) -import Data.Data (Proxy (..)) import Data.ListMap (ListMap (..)) import qualified Data.ListMap as ListMap import Data.Map.Strict (Map, fromList, toList) @@ -77,7 +64,6 @@ import Data.Maybe (fromMaybe) import qualified Data.Sequence.Strict as Seq import Data.String (fromString) import qualified Data.Text as Text -import Data.Time (NominalDiffTime, UTCTime, addUTCTime, getCurrentTime) import Data.Tuple (swap) import Data.Word (Word64) import GHC.Generics (Generic) @@ -88,8 +74,6 @@ import System.FilePath (()) import qualified System.Random as Random import System.Random (StdGen) -import Crypto.Random (getRandomBytes) - runGenesisKeyGenGenesisCmd :: GenesisKeyGenGenesisCmdArgs -> ExceptT GenesisCmdError IO () @@ -180,11 +164,12 @@ runGenesisKeyGenUTxOCmd vkeyDesc = "Genesis Initial UTxO Verification Key" runGenesisCreateTestNetDataCmd - :: GenesisCreateTestNetDataCmdArgs + :: GenesisCreateTestNetDataCmdArgs era -> ExceptT GenesisCmdError IO () runGenesisCreateTestNetDataCmd Cmd.GenesisCreateTestNetDataCmdArgs - { networkId + { eon + , networkId , specShelley , specAlonzo , specConway @@ -209,9 +194,12 @@ runGenesisCreateTestNetDataCmd , outputDir } = do liftIO $ createDirectoryIfMissing False outputDir - shelleyGenesisInit <- maybeReadAndDecodeGenesisFileSpec specShelley shelleyGenesisDefaults - alonzoGenesis <- maybeReadAndDecodeGenesisFileSpec specAlonzo (alonzoGenesisDefaults BabbageEra) -- FIXED in https://github.com/IntersectMBO/cardano-cli/pull/812 - conwayGenesis <- maybeReadAndDecodeGenesisFileSpec specConway conwayGenesisDefaults + let era = toCardanoEra eon + shelleyGenesisInit <- + fromMaybe shelleyGenesisDefaults <$> traverse decodeShelleyGenesisFile specShelley + alonzoGenesis <- + fromMaybe (alonzoGenesisDefaults era) <$> traverse (decodeAlonzoGenesisFile (Just era)) specAlonzo + conwayGenesis <- fromMaybe conwayGenesisDefaults <$> traverse decodeConwayGenesisFile specConway -- Read NetworkId either from file or from the flag. Flag overrides template file. let actualNetworkId = @@ -484,29 +472,6 @@ mkPaths numKeys dir segment filename = | idx <- [1 .. numKeys] ] -genStuffedAddress :: L.Network -> IO (AddressInEra ShelleyEra) -genStuffedAddress network = - shelleyAddressInEra ShelleyBasedEraShelley - <$> ( ShelleyAddress - <$> pure network - <*> ( L.KeyHashObj . mkKeyHash . read64BitInt - <$> Crypto.runSecureRandom (getRandomBytes 8) - ) - <*> pure L.StakeRefNull - ) - where - read64BitInt :: ByteString -> Int - read64BitInt = - (fromIntegral :: Word64 -> Int) - . Bin.runGet Bin.getWord64le - . LBS.fromStrict - - mkDummyHash :: forall h a. HashAlgorithm h => Proxy h -> Int -> Hash.Hash h a - mkDummyHash _ = coerce . L.hashWithSerialiser @h L.toCBOR - - mkKeyHash :: forall c discriminator. L.Crypto c => Int -> L.KeyHash discriminator c - mkKeyHash = L.KeyHash . mkDummyHash (Proxy @(L.ADDRHASH c)) - createDelegateKeys :: KeyOutputFormat -> FilePath -> ExceptT GenesisCmdError IO () createDelegateKeys fmt dir = do liftIO $ createDirectoryIfMissing True dir @@ -800,45 +765,6 @@ updateOutputTemplate unLovelace :: Integral a => L.Coin -> a unLovelace (L.Coin coin) = fromIntegral coin -maybeReadAndDecodeGenesisFileSpec - :: FromJSON a => Maybe FilePath -> a -> ExceptT GenesisCmdError IO a -maybeReadAndDecodeGenesisFileSpec spec defaultSpec = - case spec of - Just specPath -> - newExceptT $ readAndDecodeGenesisFile specPath - Nothing -> - -- No template given: a default file is created - pure defaultSpec - -readAndDecodeGenesisFile :: FromJSON a => FilePath -> IO (Either GenesisCmdError a) -readAndDecodeGenesisFile fpath = runExceptT $ do - lbs <- handleIOExceptT (GenesisCmdGenesisFileReadError . FileIOError fpath) $ LBS.readFile fpath - firstExceptT (GenesisCmdGenesisFileDecodeError fpath . Text.pack) - . hoistEither - $ Aeson.eitherDecode' lbs - --- @readRelays fp@ reads the relays specification from a file -readRelays - :: () - => MonadIO m - => FilePath - -- ^ The file to read from - -> ExceptT GenesisCmdError m (Map Word [L.StakePoolRelay]) -readRelays fp = do - relaySpecJsonBs <- - handleIOExceptT (GenesisCmdStakePoolRelayFileError fp) (LBS.readFile fp) - firstExceptT (GenesisCmdStakePoolRelayJsonDecodeError fp) - . hoistEither - $ Aeson.eitherDecode relaySpecJsonBs - --- | Current UTCTime plus 30 seconds -getCurrentTimePlus30 :: ExceptT a IO UTCTime -getCurrentTimePlus30 = - plus30sec <$> liftIO getCurrentTime - where - plus30sec :: UTCTime -> UTCTime - plus30sec = addUTCTime (30 :: NominalDiffTime) - readGenDelegsMap :: Map Int FilePath -> Map Int FilePath diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/DRep.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/DRep.hs index bb43df259a..0c5f546c57 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/DRep.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/DRep.hs @@ -168,7 +168,7 @@ runGovernanceDRepMetadataHashCmd { metadataFile , mOutFile } = do - metadataBytes <- firstExceptT ReadFileError $ newExceptT (readByteStringFile metadataFile) + metadataBytes <- firstExceptT ReadFileError . newExceptT $ readByteStringFile metadataFile let (_metadata, metadataHash) = hashDRepMetadata metadataBytes firstExceptT WriteFileError . newExceptT diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs index ea411348cc..7658cfd66d 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs @@ -47,7 +47,7 @@ import qualified Cardano.Api.Ledger as L import Cardano.Api.Shelley hiding (QueryInShelleyBasedEra (..)) import qualified Cardano.CLI.EraBased.Commands.Query as Cmd -import Cardano.CLI.EraBased.Run.CreateTestnetData (readAndDecodeGenesisFile) +import Cardano.CLI.EraBased.Run.Genesis.Common import Cardano.CLI.Helpers import Cardano.CLI.Types.Common import Cardano.CLI.Types.Errors.NodeEraMismatchError @@ -178,8 +178,8 @@ runQueryProtocolParametersCmd sbe <- forEraInEon @ShelleyBasedEra era (left QueryCmdByronEra) pure let qInMode = QueryInEra $ QueryInShelleyBasedEra sbe Api.QueryProtocolParameters pp <- - firstExceptT QueryCmdConvenienceError $ - executeQueryAnyMode localNodeConnInfo qInMode + executeQueryAnyMode localNodeConnInfo qInMode + & modifyError QueryCmdConvenienceError writeProtocolParameters sbe mOutFile pp where writeProtocolParameters @@ -729,7 +729,9 @@ runQueryTxMempoolCmd localQuery <- case query of TxMempoolQueryTxExists tx -> do - AnyCardanoEra era <- modifyError QueryCmdAcquireFailure (determineEra localNodeConnInfo) + AnyCardanoEra era <- + determineEra localNodeConnInfo + & modifyError QueryCmdAcquireFailure pure $ LocalTxMonitoringQueryTx $ TxIdInMode era tx TxMempoolQueryNextTx -> pure LocalTxMonitoringSendNextTx TxMempoolQueryInfo -> pure LocalTxMonitoringMempoolInformation @@ -1431,8 +1433,8 @@ runQueryLeadershipScheduleCmd readFileTextEnvelope (AsSigningKey AsVrfKey) vrkSkeyFp shelleyGenesis <- - modifyError QueryCmdGenesisReadError . hoistIOEither $ - readAndDecodeGenesisFile @(ShelleyGenesis StandardCrypto) genFile + modifyError QueryCmdGenesisReadError $ + decodeShelleyGenesisFile genFile join $ lift diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs index e3613e1f4a..2c1d4ad94d 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs @@ -42,7 +42,7 @@ import Cardano.Api.Shelley import qualified Cardano.Binary as CBOR import qualified Cardano.Chain.Common as Byron import qualified Cardano.CLI.EraBased.Commands.Transaction as Cmd -import Cardano.CLI.EraBased.Run.Genesis +import Cardano.CLI.EraBased.Run.Genesis.Common (readProtocolParameters) import Cardano.CLI.EraBased.Run.Query import Cardano.CLI.Json.Friendly (friendlyTx, friendlyTxBody, viewOutputFormatToFriendlyFormat) diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Commands/Genesis.hs b/cardano-cli/src/Cardano/CLI/Legacy/Commands/Genesis.hs index 637b2ff803..8d07aca335 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Commands/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Commands/Genesis.hs @@ -17,6 +17,7 @@ import Data.Text (Text) data LegacyGenesisCmds = GenesisCreate + (EraInEon ShelleyBasedEra) KeyOutputFormat GenesisDir Word @@ -25,6 +26,7 @@ data LegacyGenesisCmds (Maybe Coin) NetworkId | GenesisCreateCardano + (EraInEon ShelleyBasedEra) GenesisDir Word Word @@ -41,6 +43,7 @@ data LegacyGenesisCmds (Maybe FilePath) | -- | Relay specification filepath GenesisCreateStaked + (EraInEon ShelleyBasedEra) KeyOutputFormat GenesisDir Word diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Options.hs b/cardano-cli/src/Cardano/CLI/Legacy/Options.hs index ecce2d8162..b915c59f54 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Options.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Options.hs @@ -1052,7 +1052,8 @@ pGenesisCmds envCli = pGenesisCreateCardano :: Parser LegacyGenesisCmds pGenesisCreateCardano = GenesisCreateCardano - <$> pGenesisDir + <$> pAnyShelleyBasedEra envCli + <*> pGenesisDir <*> pGenesisNumGenesisKeys <*> pGenesisNumUTxOKeys <*> pMaybeSystemStart @@ -1078,7 +1079,8 @@ pGenesisCmds envCli = pGenesisCreate :: Parser LegacyGenesisCmds pGenesisCreate = GenesisCreate - <$> pKeyOutputFormat + <$> pAnyShelleyBasedEra envCli + <*> pKeyOutputFormat <*> pGenesisDir <*> pGenesisNumGenesisKeys <*> pGenesisNumUTxOKeys @@ -1089,7 +1091,8 @@ pGenesisCmds envCli = pGenesisCreateStaked :: Parser LegacyGenesisCmds pGenesisCreateStaked = GenesisCreateStaked - <$> pKeyOutputFormat + <$> pAnyShelleyBasedEra envCli + <*> pKeyOutputFormat <*> pGenesisDir <*> pGenesisNumGenesisKeys <*> pGenesisNumUTxOKeys diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Run/Genesis.hs b/cardano-cli/src/Cardano/CLI/Legacy/Run/Genesis.hs index 6f0364bbf5..20b56b42aa 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Run/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Run/Genesis.hs @@ -16,8 +16,8 @@ import Cardano.Chain.Common (BlockCount) import Cardano.CLI.EraBased.Commands.Genesis (GenesisKeyGenGenesisCmdArgs (GenesisKeyGenGenesisCmdArgs)) import qualified Cardano.CLI.EraBased.Commands.Genesis as Cmd -import qualified Cardano.CLI.EraBased.Run.CreateTestnetData as CreateTestnetData import Cardano.CLI.EraBased.Run.Genesis +import qualified Cardano.CLI.EraBased.Run.Genesis.CreateTestnetData as CreateTestnetData import Cardano.CLI.Legacy.Commands.Genesis import Cardano.CLI.Types.Common import Cardano.CLI.Types.Errors.GenesisCmdError @@ -38,12 +38,12 @@ runLegacyGenesisCmds = \case runLegacyGenesisTxInCmd vk nw mOutFile GenesisAddr vk nw mOutFile -> runLegacyGenesisAddrCmd vk nw mOutFile - GenesisCreate fmt gd gn un ms am nw -> - runLegacyGenesisCreateCmd fmt gd gn un ms am nw - GenesisCreateCardano gd gn un ms am k slotLength sc nw bg sg ag cg mNodeCfg -> - runLegacyGenesisCreateCardanoCmd gd gn un ms am k slotLength sc nw bg sg ag cg mNodeCfg - GenesisCreateStaked fmt gd gn gp gl un ms am ds nw bf bp su relayJsonFp -> - runLegacyGenesisCreateStakedCmd fmt gd gn gp gl un ms am ds nw bf bp su relayJsonFp + GenesisCreate eSbe fmt gd gn un ms am nw -> + runLegacyGenesisCreateCmd eSbe fmt gd gn un ms am nw + GenesisCreateCardano eSbe gd gn un ms am k slotLength sc nw bg sg ag cg mNodeCfg -> + runLegacyGenesisCreateCardanoCmd eSbe gd gn un ms am k slotLength sc nw bg sg ag cg mNodeCfg + GenesisCreateStaked eSbe fmt gd gn gp gl un ms am ds nw bf bp su relayJsonFp -> + runLegacyGenesisCreateStakedCmd eSbe fmt gd gn gp gl un ms am ds nw bf bp su relayJsonFp GenesisHashFile gf -> runLegacyGenesisHashFileCmd gf @@ -124,7 +124,8 @@ runLegacyGenesisAddrCmd vkf nid mOf = runLegacyGenesisCreateCmd :: () - => KeyOutputFormat + => EraInEon ShelleyBasedEra + -> KeyOutputFormat -> GenesisDir -> Word -- ^ num genesis & delegate keys to make @@ -134,10 +135,11 @@ runLegacyGenesisCreateCmd -> Maybe Coin -> NetworkId -> ExceptT GenesisCmdError IO () -runLegacyGenesisCreateCmd fmt genDir nGenKeys nUTxOKeys mStart mSupply network = +runLegacyGenesisCreateCmd (EraInEon asbe) fmt genDir nGenKeys nUTxOKeys mStart mSupply network = runGenesisCreateCmd Cmd.GenesisCreateCmdArgs - { Cmd.keyOutputFormat = fmt + { Cmd.eon = asbe + , Cmd.keyOutputFormat = fmt , Cmd.genesisDir = genDir , Cmd.numGenesisKeys = nGenKeys , Cmd.numUTxOKeys = nUTxOKeys @@ -148,7 +150,8 @@ runLegacyGenesisCreateCmd fmt genDir nGenKeys nUTxOKeys mStart mSupply network = runLegacyGenesisCreateCardanoCmd :: () - => GenesisDir + => EraInEon ShelleyBasedEra + -> GenesisDir -> Word -- ^ num genesis & delegate keys to make -> Word @@ -171,6 +174,7 @@ runLegacyGenesisCreateCardanoCmd -> Maybe FilePath -> ExceptT GenesisCmdError IO () runLegacyGenesisCreateCardanoCmd + (EraInEon sbe) genDir nGenKeys nUTxOKeys @@ -187,7 +191,8 @@ runLegacyGenesisCreateCardanoCmd mNodeCfg = runGenesisCreateCardanoCmd Cmd.GenesisCreateCardanoCmdArgs - { Cmd.genesisDir = genDir + { Cmd.eon = sbe + , Cmd.genesisDir = genDir , Cmd.numGenesisKeys = nGenKeys , Cmd.numUTxOKeys = nUTxOKeys , Cmd.mSystemStart = mStart @@ -205,7 +210,8 @@ runLegacyGenesisCreateCardanoCmd runLegacyGenesisCreateStakedCmd :: () - => KeyOutputFormat + => EraInEon ShelleyBasedEra + -> KeyOutputFormat -- ^ key output format -> GenesisDir -> Word @@ -232,6 +238,7 @@ runLegacyGenesisCreateStakedCmd -- ^ Specified stake pool relays -> ExceptT GenesisCmdError IO () runLegacyGenesisCreateStakedCmd + (EraInEon sbe) keyOutputFormat genesisDir numGenesisKeys @@ -248,7 +255,8 @@ runLegacyGenesisCreateStakedCmd mStakePoolRelaySpecFile = runGenesisCreateStakedCmd Cmd.GenesisCreateStakedCmdArgs - { Cmd.keyOutputFormat = keyOutputFormat + { Cmd.eon = sbe + , Cmd.keyOutputFormat = keyOutputFormat , Cmd.genesisDir = genesisDir , Cmd.numGenesisKeys = numGenesisKeys , Cmd.numUTxOKeys = numUTxOKeys diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/GenesisCmdError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/GenesisCmdError.hs index 7a442f9100..aa9e92f05c 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/GenesisCmdError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/GenesisCmdError.hs @@ -19,39 +19,35 @@ import Control.Exception (IOException) import Data.Text (Text) data GenesisCmdError - = GenesisCmdAesonDecodeError !FilePath !Text - | GenesisCmdGenesisFileReadError !(FileError IOException) + = GenesisCmdAddressCmdError !AddressCmdError + | GenesisCmdByronError !ByronGenesisError + | GenesisCmdCostModelsError !FilePath + | -- | First @Integer@ is the delegate supply, second @Integer@ is the total supply + GenesisCmdDelegatedSupplyExceedsTotalSupply !Integer !Integer + | GenesisCmdFileError !(FileError ()) + | GenesisCmdFileDecodeError !FilePath !Text + | GenesisCmdFilesDupIndex [FilePath] + | GenesisCmdFilesNoIndex [FilePath] | GenesisCmdGenesisFileDecodeError !FilePath !Text | GenesisCmdGenesisFileError !(FileError ()) - | GenesisCmdFileError !(FileError ()) | GenesisCmdMismatchedGenesisKeyFiles [Int] [Int] [Int] - | GenesisCmdFilesNoIndex [FilePath] - | GenesisCmdFilesDupIndex [FilePath] - | GenesisCmdTextEnvReadFileError !(FileError TextEnvelopeError) - | GenesisCmdUnexpectedAddressVerificationKey - !(VerificationKeyFile In) - !Text - !SomeAddressVerificationKey - | GenesisCmdTooFewPoolsForBulkCreds !Word !Word !Word - | GenesisCmdAddressCmdError !AddressCmdError | GenesisCmdNodeCmdError !NodeCmdError | GenesisCmdStakeAddressCmdError !StakeAddressCmdError | GenesisCmdStakePoolCmdError !StakePoolCmdError - | GenesisCmdCostModelsError !FilePath - | GenesisCmdByronError !ByronGenesisError - | -- | First @Int@ is the number of SPOs, second @Int@ is number of relays - GenesisCmdTooManyRelaysError !FilePath !Int !Int | GenesisCmdStakePoolRelayFileError !FilePath !IOException | GenesisCmdStakePoolRelayJsonDecodeError !FilePath !String - | GenesisCmdFileInputDecodeError !(FileError InputDecodeError) - | -- | First @Integer@ is the delegate supply, second @Integer@ is the total supply - GenesisCmdDelegatedSupplyExceedsTotalSupply !Integer !Integer + | GenesisCmdTextEnvReadFileError !(FileError TextEnvelopeError) + | GenesisCmdTooFewPoolsForBulkCreds !Word !Word !Word + | -- | First @Int@ is the number of SPOs, second @Int@ is number of relays + GenesisCmdTooManyRelaysError !FilePath !Int !Int + | GenesisCmdUnexpectedAddressVerificationKey + !(VerificationKeyFile In) + !Text + !SomeAddressVerificationKey deriving Show instance Error GenesisCmdError where prettyError = \case - GenesisCmdAesonDecodeError fp decErr -> - "Error while decoding Shelley genesis at: " <> pretty fp <> " Error: " <> pretty decErr GenesisCmdGenesisFileError fe -> prettyError fe GenesisCmdFileError fe -> @@ -72,6 +68,8 @@ instance Error GenesisCmdError where GenesisCmdFilesDupIndex files -> "The genesis keys files are expected to have a unique numeric index but these do not:\n" <> vsep (fmap pretty files) + GenesisCmdFileDecodeError path errorTxt -> + "Cannot decode file:" <+> pretty path <+> "\nError:" <+> pretty errorTxt GenesisCmdTextEnvReadFileError fileErr -> prettyError fileErr GenesisCmdUnexpectedAddressVerificationKey (File file) expect got -> @@ -108,8 +106,6 @@ instance Error GenesisCmdError where <> pretty fp <> " Error: " <> pretty e - GenesisCmdGenesisFileReadError e -> - prettyError e GenesisCmdByronError e -> pshow e GenesisCmdTooManyRelaysError fp nbSPOs nbRelays -> pretty fp @@ -129,8 +125,6 @@ instance Error GenesisCmdError where <> pretty fp <> " Error: " <> pretty e - GenesisCmdFileInputDecodeError ide -> - "Error occured while decoding a file: " <> pshow ide GenesisCmdDelegatedSupplyExceedsTotalSupply delegated total -> "Provided delegated supply is " <> pretty delegated diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli index f8d0931490..d3610b6194 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli @@ -9828,7 +9828,15 @@ Usage: cardano-cli legacy genesis initial-txin --verification-key-file FILE Get the TxIn for an initial UTxO based on the verification key -Usage: cardano-cli legacy genesis create-cardano --genesis-dir DIR +Usage: cardano-cli legacy genesis create-cardano + [ --shelley-era + | --allegra-era + | --mary-era + | --alonzo-era + | --babbage-era + | --conway-era + ] + --genesis-dir DIR [--gen-genesis-keys INT] [--gen-utxo-keys INT] [--start-time UTC-TIME] @@ -9848,7 +9856,15 @@ Usage: cardano-cli legacy genesis create-cardano --genesis-dir DIR Create a Byron and Shelley genesis file from a genesis template and genesis/delegation/spending keys. -Usage: cardano-cli legacy genesis create [--key-output-format STRING] +Usage: cardano-cli legacy genesis create + [ --shelley-era + | --allegra-era + | --mary-era + | --alonzo-era + | --babbage-era + | --conway-era + ] + [--key-output-format STRING] --genesis-dir DIR [--gen-genesis-keys INT] [--gen-utxo-keys INT] @@ -9859,7 +9875,15 @@ Usage: cardano-cli legacy genesis create [--key-output-format STRING] Create a Shelley genesis file from a genesis template and genesis/delegation/spending keys. -Usage: cardano-cli legacy genesis create-staked [--key-output-format STRING] +Usage: cardano-cli legacy genesis create-staked + [ --shelley-era + | --allegra-era + | --mary-era + | --alonzo-era + | --babbage-era + | --conway-era + ] + [--key-output-format STRING] --genesis-dir DIR [--gen-genesis-keys INT] [--gen-utxo-keys INT] @@ -11103,7 +11127,15 @@ Usage: cardano-cli genesis initial-txin --verification-key-file FILE Get the TxIn for an initial UTxO based on the verification key -Usage: cardano-cli genesis create-cardano --genesis-dir DIR +Usage: cardano-cli genesis create-cardano + [ --shelley-era + | --allegra-era + | --mary-era + | --alonzo-era + | --babbage-era + | --conway-era + ] + --genesis-dir DIR [--gen-genesis-keys INT] [--gen-utxo-keys INT] [--start-time UTC-TIME] @@ -11123,7 +11155,15 @@ Usage: cardano-cli genesis create-cardano --genesis-dir DIR Create a Byron and Shelley genesis file from a genesis template and genesis/delegation/spending keys. -Usage: cardano-cli genesis create [--key-output-format STRING] +Usage: cardano-cli genesis create + [ --shelley-era + | --allegra-era + | --mary-era + | --alonzo-era + | --babbage-era + | --conway-era + ] + [--key-output-format STRING] --genesis-dir DIR [--gen-genesis-keys INT] [--gen-utxo-keys INT] @@ -11134,7 +11174,15 @@ Usage: cardano-cli genesis create [--key-output-format STRING] Create a Shelley genesis file from a genesis template and genesis/delegation/spending keys. -Usage: cardano-cli genesis create-staked [--key-output-format STRING] +Usage: cardano-cli genesis create-staked + [ --shelley-era + | --allegra-era + | --mary-era + | --alonzo-era + | --babbage-era + | --conway-era + ] + [--key-output-format STRING] --genesis-dir DIR [--gen-genesis-keys INT] [--gen-utxo-keys INT] diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/genesis_create-cardano.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/genesis_create-cardano.cli index d630a99e9d..ad83ead8e7 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/genesis_create-cardano.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/genesis_create-cardano.cli @@ -1,4 +1,12 @@ -Usage: cardano-cli genesis create-cardano --genesis-dir DIR +Usage: cardano-cli genesis create-cardano + [ --shelley-era + | --allegra-era + | --mary-era + | --alonzo-era + | --babbage-era + | --conway-era + ] + --genesis-dir DIR [--gen-genesis-keys INT] [--gen-utxo-keys INT] [--start-time UTC-TIME] @@ -19,6 +27,12 @@ Usage: cardano-cli genesis create-cardano --genesis-dir DIR genesis/delegation/spending keys. Available options: + --shelley-era Specify the Shelley era + --allegra-era Specify the Allegra era + --mary-era Specify the Mary era + --alonzo-era Specify the Alonzo era + --babbage-era Specify the Babbage era (default) + --conway-era Specify the Conway era --genesis-dir DIR The genesis directory containing the genesis template and required genesis/delegation/spending keys. --gen-genesis-keys INT The number of genesis keys to make [default is 3]. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/genesis_create-staked.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/genesis_create-staked.cli index 5aee77d221..2ef56d89c5 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/genesis_create-staked.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/genesis_create-staked.cli @@ -1,4 +1,12 @@ -Usage: cardano-cli genesis create-staked [--key-output-format STRING] +Usage: cardano-cli genesis create-staked + [ --shelley-era + | --allegra-era + | --mary-era + | --alonzo-era + | --babbage-era + | --conway-era + ] + [--key-output-format STRING] --genesis-dir DIR [--gen-genesis-keys INT] [--gen-utxo-keys INT] @@ -17,6 +25,12 @@ Usage: cardano-cli genesis create-staked [--key-output-format STRING] genesis/delegation/spending keys. Available options: + --shelley-era Specify the Shelley era + --allegra-era Specify the Allegra era + --mary-era Specify the Mary era + --alonzo-era Specify the Alonzo era + --babbage-era Specify the Babbage era (default) + --conway-era Specify the Conway era --key-output-format STRING Optional key output format. Accepted output formats are "text-envelope" and "bech32" (default is diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/genesis_create.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/genesis_create.cli index 9b7e8bf664..bd6f7b1c31 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/genesis_create.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/genesis_create.cli @@ -1,4 +1,12 @@ -Usage: cardano-cli genesis create [--key-output-format STRING] +Usage: cardano-cli genesis create + [ --shelley-era + | --allegra-era + | --mary-era + | --alonzo-era + | --babbage-era + | --conway-era + ] + [--key-output-format STRING] --genesis-dir DIR [--gen-genesis-keys INT] [--gen-utxo-keys INT] @@ -10,6 +18,12 @@ Usage: cardano-cli genesis create [--key-output-format STRING] genesis/delegation/spending keys. Available options: + --shelley-era Specify the Shelley era + --allegra-era Specify the Allegra era + --mary-era Specify the Mary era + --alonzo-era Specify the Alonzo era + --babbage-era Specify the Babbage era (default) + --conway-era Specify the Conway era --key-output-format STRING Optional key output format. Accepted output formats are "text-envelope" and "bech32" (default is diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_genesis_create-cardano.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_genesis_create-cardano.cli index 541c2e0ef0..f98fe2ccbc 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_genesis_create-cardano.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_genesis_create-cardano.cli @@ -1,4 +1,12 @@ -Usage: cardano-cli legacy genesis create-cardano --genesis-dir DIR +Usage: cardano-cli legacy genesis create-cardano + [ --shelley-era + | --allegra-era + | --mary-era + | --alonzo-era + | --babbage-era + | --conway-era + ] + --genesis-dir DIR [--gen-genesis-keys INT] [--gen-utxo-keys INT] [--start-time UTC-TIME] @@ -19,6 +27,12 @@ Usage: cardano-cli legacy genesis create-cardano --genesis-dir DIR genesis/delegation/spending keys. Available options: + --shelley-era Specify the Shelley era + --allegra-era Specify the Allegra era + --mary-era Specify the Mary era + --alonzo-era Specify the Alonzo era + --babbage-era Specify the Babbage era (default) + --conway-era Specify the Conway era --genesis-dir DIR The genesis directory containing the genesis template and required genesis/delegation/spending keys. --gen-genesis-keys INT The number of genesis keys to make [default is 3]. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_genesis_create-staked.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_genesis_create-staked.cli index f2e9002e7a..3d89e00c9c 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_genesis_create-staked.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_genesis_create-staked.cli @@ -1,4 +1,12 @@ -Usage: cardano-cli legacy genesis create-staked [--key-output-format STRING] +Usage: cardano-cli legacy genesis create-staked + [ --shelley-era + | --allegra-era + | --mary-era + | --alonzo-era + | --babbage-era + | --conway-era + ] + [--key-output-format STRING] --genesis-dir DIR [--gen-genesis-keys INT] [--gen-utxo-keys INT] @@ -19,6 +27,12 @@ Usage: cardano-cli legacy genesis create-staked [--key-output-format STRING] genesis/delegation/spending keys. Available options: + --shelley-era Specify the Shelley era + --allegra-era Specify the Allegra era + --mary-era Specify the Mary era + --alonzo-era Specify the Alonzo era + --babbage-era Specify the Babbage era (default) + --conway-era Specify the Conway era --key-output-format STRING Optional key output format. Accepted output formats are "text-envelope" and "bech32" (default is diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_genesis_create.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_genesis_create.cli index ceb617891a..deb636083d 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_genesis_create.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_genesis_create.cli @@ -1,4 +1,12 @@ -Usage: cardano-cli legacy genesis create [--key-output-format STRING] +Usage: cardano-cli legacy genesis create + [ --shelley-era + | --allegra-era + | --mary-era + | --alonzo-era + | --babbage-era + | --conway-era + ] + [--key-output-format STRING] --genesis-dir DIR [--gen-genesis-keys INT] [--gen-utxo-keys INT] @@ -10,6 +18,12 @@ Usage: cardano-cli legacy genesis create [--key-output-format STRING] genesis/delegation/spending keys. Available options: + --shelley-era Specify the Shelley era + --allegra-era Specify the Allegra era + --mary-era Specify the Mary era + --alonzo-era Specify the Alonzo era + --babbage-era Specify the Babbage era (default) + --conway-era Specify the Conway era --key-output-format STRING Optional key output format. Accepted output formats are "text-envelope" and "bech32" (default is