From 901f075c11df00d0bb65e8f86e9bb4460a2ff6fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Mon, 4 Nov 2024 21:25:00 +0100 Subject: [PATCH 1/4] Run/Governance: internally expose functions to generate committee keys --- .../CLI/EraBased/Run/Governance/Committee.hs | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Committee.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Committee.hs index f5c37c6ab9..fc2839717f 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Committee.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Committee.hs @@ -5,6 +5,8 @@ module Cardano.CLI.EraBased.Run.Governance.Committee ( runGovernanceCommitteeCmds + , runGovernanceCommitteeKeyGenCold + , runGovernanceCommitteeKeyGenHot , GovernanceCommitteeError (..) ) where @@ -21,6 +23,7 @@ import Cardano.CLI.Types.Common (PotentiallyCheckedAnchor (..)) import Cardano.CLI.Types.Errors.GovernanceCommitteeError import Cardano.CLI.Types.Key.VerificationKey +import Control.Monad (void) import Data.ByteString (ByteString) import qualified Data.ByteString.Char8 as BS import Data.Function @@ -31,9 +34,9 @@ runGovernanceCommitteeCmds -> ExceptT GovernanceCommitteeError IO () runGovernanceCommitteeCmds = \case GovernanceCommitteeKeyGenColdCmd cmd -> - runGovernanceCommitteeKeyGenCold cmd + void $ runGovernanceCommitteeKeyGenCold cmd GovernanceCommitteeKeyGenHotCmd cmd -> - runGovernanceCommitteeKeyGenHot cmd + void $ runGovernanceCommitteeKeyGenHot cmd GovernanceCommitteeKeyHashCmd cmd -> runGovernanceCommitteeKeyHash cmd GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmd cmd -> @@ -44,26 +47,26 @@ runGovernanceCommitteeCmds = \case runGovernanceCommitteeKeyGenCold :: () => Cmd.GovernanceCommitteeKeyGenColdCmdArgs era - -> ExceptT GovernanceCommitteeError IO () + -> ExceptT GovernanceCommitteeError IO (VerificationKey CommitteeColdKey, SigningKey CommitteeColdKey) runGovernanceCommitteeKeyGenCold Cmd.GovernanceCommitteeKeyGenColdCmdArgs { Cmd.vkeyOutFile = vkeyPath , Cmd.skeyOutFile = skeyPath } = do skey <- generateSigningKey AsCommitteeColdKey - let vkey = getVerificationKey skey - writeLazyByteStringFile skeyPath (textEnvelopeToJSON (Just Key.ccColdSkeyDesc) skey) - & onLeft (left . GovernanceCommitteeCmdWriteFileError) + firstExceptT GovernanceCommitteeCmdWriteFileError . newExceptT $ + writeLazyByteStringFile skeyPath (textEnvelopeToJSON (Just Key.ccColdSkeyDesc) skey) + firstExceptT GovernanceCommitteeCmdWriteFileError . newExceptT $ + writeLazyByteStringFile vkeyPath (textEnvelopeToJSON (Just Key.ccColdVkeyDesc) vkey) - writeLazyByteStringFile vkeyPath (textEnvelopeToJSON (Just Key.ccColdVkeyDesc) vkey) - & onLeft (left . GovernanceCommitteeCmdWriteFileError) + return (vkey, skey) runGovernanceCommitteeKeyGenHot :: () => Cmd.GovernanceCommitteeKeyGenHotCmdArgs era - -> ExceptT GovernanceCommitteeError IO () + -> ExceptT GovernanceCommitteeError IO (VerificationKey CommitteeHotKey, SigningKey CommitteeHotKey) runGovernanceCommitteeKeyGenHot Cmd.GovernanceCommitteeKeyGenHotCmdArgs { Cmd.eon = _eon @@ -84,6 +87,8 @@ runGovernanceCommitteeKeyGenHot $ writeLazyByteStringFile vkeyPath $ textEnvelopeToJSON (Just Key.ccHotVkeyDesc) vkey + return (vkey, skey) + data SomeCommitteeKey = ACommitteeHotKey (VerificationKey CommitteeHotKey) | ACommitteeHotExtendedKey (VerificationKey CommitteeHotExtendedKey) From 46502a6104c4a9694322710ae2f8d649f4f2f3a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Mon, 4 Nov 2024 12:05:56 +0100 Subject: [PATCH 2/4] create-testnet-data: generate committee members --- .../Cardano/CLI/EraBased/Commands/Genesis.hs | 2 + .../Cardano/CLI/EraBased/Options/Genesis.hs | 10 +++ .../EraBased/Run/Genesis/CreateTestnetData.hs | 63 +++++++++++++++++-- .../CLI/EraBased/Run/Governance/Committee.hs | 17 ++--- .../CLI/Types/Errors/GenesisCmdError.hs | 5 ++ 5 files changed, 81 insertions(+), 16 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Genesis.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Genesis.hs index 0c7abbc8fe..50410f3da0 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Genesis.hs @@ -105,6 +105,8 @@ data GenesisCreateTestNetDataCmdArgs era = GenesisCreateTestNetDataCmdArgs , numPools :: !Word -- ^ The number of stake pools credentials to create and write to disk. , stakeDelegators :: !StakeDelegators + -- ^ The number of members of the constitutional committee + , numCommitteeKeys :: !Word -- ^ The number of delegators to pools and DReps to create. , numDRepKeys :: !DRepCredentials -- ^ The number of DRep keys to create. They are registered and get delegated to by stake delegators diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Genesis.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Genesis.hs index ab8caa71ba..f6e749b04a 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Genesis.hs @@ -227,6 +227,7 @@ pGenesisCreateTestNetData sbe envCli = <*> pNumGenesisKeys <*> pNumPools <*> pNumStakeDelegs + <*> pNumCommittee <*> pNumDReps <*> pNumStuffedUtxoCount <*> pNumUtxoKeys @@ -258,6 +259,15 @@ pGenesisCreateTestNetData sbe envCli = , Opt.help "The number of stake pool credential sets to make (default is 0)." , Opt.value 0 ] + pNumCommittee :: Parser Word + pNumCommittee = + Opt.option integralReader $ + mconcat + [ Opt.long "committee-keys" + , Opt.metavar "INT" + , Opt.help "The number of constitutional committee credentials to make (default is 0)." + , Opt.value 0 + ] pNumDReps :: Parser DRepCredentials pNumDReps = pDReps OnDisk "drep-keys" "Credentials are written to disk." diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis/CreateTestnetData.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis/CreateTestnetData.hs index 510789c815..d225efee18 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis/CreateTestnetData.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis/CreateTestnetData.hs @@ -24,9 +24,7 @@ where import Cardano.Api hiding (ConwayEra) import Cardano.Api.Ledger (StrictMaybe (SNothing)) import qualified Cardano.Api.Ledger as L -import Cardano.Api.Shelley - (Hash (DRepKeyHash, GenesisDelegateKeyHash, GenesisKeyHash, StakeKeyHash, VrfKeyHash), - KESPeriod (KESPeriod), +import Cardano.Api.Shelley (Hash (..), KESPeriod (KESPeriod), OperationalCertificateIssueCounter (OperationalCertificateIssueCounter), ShelleyGenesis (ShelleyGenesis, sgGenDelegs, sgInitialFunds, sgMaxLovelaceSupply, sgNetworkMagic, sgProtocolParams, sgStaking, sgSystemStart), StakeCredential (StakeCredentialByKey), VerificationKey (VrfVerificationKey), @@ -35,8 +33,10 @@ import Cardano.Api.Shelley import qualified Cardano.CLI.Commands.Node as Cmd import Cardano.CLI.EraBased.Commands.Genesis as Cmd +import qualified Cardano.CLI.EraBased.Commands.Governance.Committee as CC import qualified Cardano.CLI.EraBased.Commands.Governance.DRep as DRep import Cardano.CLI.EraBased.Run.Genesis.Common +import qualified Cardano.CLI.EraBased.Run.Governance.Committee as CC import qualified Cardano.CLI.EraBased.Run.Governance.DRep as DRep import Cardano.CLI.EraBased.Run.StakeAddress (runStakeAddressKeyGenCmd) import qualified Cardano.CLI.IO.Lazy as Lazy @@ -56,6 +56,7 @@ import Control.Monad (forM, forM_, unless, void, when) import qualified Data.Aeson as Aeson import Data.Bifunctor (Bifunctor (..)) import qualified Data.ByteString.Lazy.Char8 as LBS +import Data.Function ((&)) import Data.ListMap (ListMap (..)) import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map @@ -181,6 +182,7 @@ runGenesisCreateTestNetDataCmd { stakeDelegatorsGenerationMode , numOfStakeDelegators } + , numCommitteeKeys , numDRepKeys = DRepCredentials { dRepCredentialGenerationMode @@ -253,6 +255,26 @@ runGenesisCreateTestNetDataCmd when (0 < numPools) $ writeREADME poolsDir poolsREADME + -- CC members + ccColdKeys <- forM [1 .. numCommitteeKeys] $ \index -> do + let committeeDir = committeesDir "cc" <> show index + vkeyHotFile = File @(VerificationKey ()) $ committeeDir "cc.hot.vkey" + skeyHotFile = File @(SigningKey ()) $ committeeDir "cc.hot.skey" + vkeyColdFile = File @(VerificationKey ()) $ committeeDir "cc.cold.vkey" + skeyColdFile = File @(SigningKey ()) $ committeeDir "cc.cold.skey" + hotArgs = CC.GovernanceCommitteeKeyGenHotCmdArgs ConwayEraOnwardsConway vkeyHotFile skeyHotFile + coldArgs = CC.GovernanceCommitteeKeyGenColdCmdArgs ConwayEraOnwardsConway vkeyColdFile skeyColdFile + liftIO $ createDirectoryIfMissing True committeeDir + void $ + withExceptT GenesisCmdGovernanceCommitteeError $ + CC.runGovernanceCommitteeKeyGenHot hotArgs + (vColdKey, _) <- + withExceptT GenesisCmdGovernanceCommitteeError $ + CC.runGovernanceCommitteeKeyGenCold coldArgs + return vColdKey + + when (0 < numCommitteeKeys) $ writeREADME committeesDir committeeREADME + -- DReps g <- Random.getStdGen @@ -302,7 +324,9 @@ runGenesisCreateTestNetDataCmd stuffedUtxoAddrs <- liftIO $ Lazy.replicateM (fromIntegral numStuffedUtxo) $ genStuffedAddress network - let conwayGenesis' = addDRepsToConwayGenesis dRepKeys (map snd delegatorKeys) conwayGenesis + let conwayGenesis' = + addDRepsToConwayGenesis dRepKeys (map snd delegatorKeys) conwayGenesis + & addCommitteeToConwayGenesis ccColdKeys let stake = second L.ppId . mkDelegationMapEntry <$> delegations stakePools = [(L.ppId poolParams', poolParams') | poolParams' <- snd . mkDelegationMapEntry <$> delegations] @@ -328,6 +352,7 @@ runGenesisCreateTestNetDataCmd where genesisDir = outputDir "genesis-keys" delegateDir = outputDir "delegate-keys" + committeesDir = outputDir "cc-keys" drepsDir = outputDir "drep-keys" utxoKeysDir = outputDir "utxo-keys" poolsDir = outputDir "pools-keys" @@ -336,6 +361,28 @@ runGenesisCreateTestNetDataCmd :: Delegation -> (L.KeyHash L.Staking L.StandardCrypto, L.PoolParams L.StandardCrypto) mkDelegationMapEntry d = (dDelegStaking d, dPoolParams d) + addCommitteeToConwayGenesis + :: [VerificationKey CommitteeColdKey] + -> L.ConwayGenesis L.StandardCrypto + -> L.ConwayGenesis L.StandardCrypto + addCommitteeToConwayGenesis ccColdKeys conwayGenesis = + conwayGenesis + { L.cgCommittee = + L.Committee + { L.committeeMembers = + Map.fromList $ map ((,EpochNo maxBound) . toCommitteeColdCredential) ccColdKeys + , L.committeeThreshold = zeroUnitInterval -- Taken from cardano-testnet at the time of writing. Change to 0.5 in the future? + } + } + where + zeroUnitInterval = unsafeBoundedRational @L.UnitInterval 0 + toCommitteeColdCredential + :: VerificationKey CommitteeColdKey -> L.Credential L.ColdCommitteeRole L.StandardCrypto + toCommitteeColdCredential vk = toCredential (verificationKeyHash vk) + where + toCredential :: Hash CommitteeColdKey -> L.Credential L.ColdCommitteeRole L.StandardCrypto + toCredential (CommitteeColdKeyHash v) = L.KeyHashObj v + addDRepsToConwayGenesis :: [VerificationKey DRepKey] -> [VerificationKey StakeKey] @@ -434,6 +481,14 @@ genesisREADME = , "With the introduction of Conway, these keys should become useless" ] +committeeREADME :: Text.Text +committeeREADME = + Text.intercalate + "\n" + [ "Keys generated by the --committee-keys flag. These keys are used to run the constitutional committee." + , "A pair of both cold keys and hot keys are generated for each committee member." + ] + delegatesREADME :: Text.Text delegatesREADME = Text.intercalate diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Committee.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Committee.hs index fc2839717f..7dee0445e9 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Committee.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Committee.hs @@ -56,9 +56,8 @@ runGovernanceCommitteeKeyGenCold skey <- generateSigningKey AsCommitteeColdKey let vkey = getVerificationKey skey - firstExceptT GovernanceCommitteeCmdWriteFileError . newExceptT $ - writeLazyByteStringFile skeyPath (textEnvelopeToJSON (Just Key.ccColdSkeyDesc) skey) - firstExceptT GovernanceCommitteeCmdWriteFileError . newExceptT $ + void $ firstExceptT GovernanceCommitteeCmdWriteFileError $ do + void $ writeLazyByteStringFile skeyPath (textEnvelopeToJSON (Just Key.ccColdSkeyDesc) skey) writeLazyByteStringFile vkeyPath (textEnvelopeToJSON (Just Key.ccColdVkeyDesc) vkey) return (vkey, skey) @@ -77,15 +76,9 @@ runGovernanceCommitteeKeyGenHot let vkey = getVerificationKey skey - firstExceptT GovernanceCommitteeCmdWriteFileError - . newExceptT - $ writeLazyByteStringFile skeyPath - $ textEnvelopeToJSON (Just Key.ccHotSkeyDesc) skey - - firstExceptT GovernanceCommitteeCmdWriteFileError - . newExceptT - $ writeLazyByteStringFile vkeyPath - $ textEnvelopeToJSON (Just Key.ccHotVkeyDesc) vkey + void $ firstExceptT GovernanceCommitteeCmdWriteFileError $ do + void $ writeLazyByteStringFile skeyPath $ textEnvelopeToJSON (Just Key.ccHotSkeyDesc) skey + writeLazyByteStringFile vkeyPath $ textEnvelopeToJSON (Just Key.ccHotVkeyDesc) vkey return (vkey, skey) diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/GenesisCmdError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/GenesisCmdError.hs index aa9e92f05c..a897a03172 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/GenesisCmdError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/GenesisCmdError.hs @@ -9,6 +9,7 @@ where import Cardano.Api import Cardano.CLI.Byron.Genesis as Byron +import Cardano.CLI.EraBased.Run.Governance.Committee (GovernanceCommitteeError) import Cardano.CLI.Types.Common import Cardano.CLI.Types.Errors.AddressCmdError import Cardano.CLI.Types.Errors.NodeCmdError @@ -30,6 +31,7 @@ data GenesisCmdError | GenesisCmdFilesNoIndex [FilePath] | GenesisCmdGenesisFileDecodeError !FilePath !Text | GenesisCmdGenesisFileError !(FileError ()) + | GenesisCmdGovernanceCommitteeError !GovernanceCommitteeError | GenesisCmdMismatchedGenesisKeyFiles [Int] [Int] [Int] | GenesisCmdNodeCmdError !NodeCmdError | GenesisCmdStakeAddressCmdError !StakeAddressCmdError @@ -133,3 +135,6 @@ instance Error GenesisCmdError where <> "." <> "This is incorrect: the delegated supply should be less or equal to the total supply." <> " Note that the total supply can either come from --total-supply or from the default template. Please fix what you use." + GenesisCmdGovernanceCommitteeError govCommitteeError -> + "Error during committee creation: " + <> prettyError govCommitteeError From 350b08be3ac7600e802fb8aa359a803560b528b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Tue, 5 Nov 2024 10:54:24 +0100 Subject: [PATCH 3/4] Adapt golden files --- cardano-cli/test/cardano-cli-golden/files/golden/help.cli | 7 +++++++ .../golden/help/allegra_genesis_create-testnet-data.cli | 3 +++ .../golden/help/alonzo_genesis_create-testnet-data.cli | 3 +++ .../golden/help/babbage_genesis_create-testnet-data.cli | 3 +++ .../golden/help/conway_genesis_create-testnet-data.cli | 3 +++ .../golden/help/latest_genesis_create-testnet-data.cli | 3 +++ .../files/golden/help/mary_genesis_create-testnet-data.cli | 3 +++ .../golden/help/shelley_genesis_create-testnet-data.cli | 3 +++ 8 files changed, 28 insertions(+) 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 43b3c0f35a..14e47f6556 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli @@ -1202,6 +1202,7 @@ Usage: cardano-cli shelley genesis create-testnet-data [--spec-shelley FILEPATH] [ --stake-delegators INT | --transient-stake-delegators INT ] + [--committee-keys INT] [ --drep-keys INT | --transient-drep-keys INT ] @@ -2274,6 +2275,7 @@ Usage: cardano-cli allegra genesis create-testnet-data [--spec-shelley FILEPATH] [ --stake-delegators INT | --transient-stake-delegators INT ] + [--committee-keys INT] [ --drep-keys INT | --transient-drep-keys INT ] @@ -3344,6 +3346,7 @@ Usage: cardano-cli mary genesis create-testnet-data [--spec-shelley FILEPATH] [ --stake-delegators INT | --transient-stake-delegators INT ] + [--committee-keys INT] [ --drep-keys INT | --transient-drep-keys INT ] @@ -4406,6 +4409,7 @@ Usage: cardano-cli alonzo genesis create-testnet-data [--spec-shelley FILEPATH] [ --stake-delegators INT | --transient-stake-delegators INT ] + [--committee-keys INT] [ --drep-keys INT | --transient-drep-keys INT ] @@ -5485,6 +5489,7 @@ Usage: cardano-cli babbage genesis create-testnet-data [--spec-shelley FILEPATH] [ --stake-delegators INT | --transient-stake-delegators INT ] + [--committee-keys INT] [ --drep-keys INT | --transient-drep-keys INT ] @@ -6840,6 +6845,7 @@ Usage: cardano-cli conway genesis create-testnet-data [--spec-shelley FILEPATH] [ --stake-delegators INT | --transient-stake-delegators INT ] + [--committee-keys INT] [ --drep-keys INT | --transient-drep-keys INT ] @@ -8839,6 +8845,7 @@ Usage: cardano-cli latest genesis create-testnet-data [--spec-shelley FILEPATH] [ --stake-delegators INT | --transient-stake-delegators INT ] + [--committee-keys INT] [ --drep-keys INT | --transient-drep-keys INT ] diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/allegra_genesis_create-testnet-data.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/allegra_genesis_create-testnet-data.cli index 1a3618c481..46ab77f9c7 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/allegra_genesis_create-testnet-data.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/allegra_genesis_create-testnet-data.cli @@ -6,6 +6,7 @@ Usage: cardano-cli allegra genesis create-testnet-data [--spec-shelley FILEPATH] [ --stake-delegators INT | --transient-stake-delegators INT ] + [--committee-keys INT] [ --drep-keys INT | --transient-drep-keys INT ] @@ -36,6 +37,8 @@ Available options: The number of stake delegator credential sets to make (default is 0). The credentials are NOT written to disk. + --committee-keys INT The number of constitutional committee credentials to + make (default is 0). --drep-keys INT The number of DRep credentials to make (default is 0). Credentials are written to disk. --transient-drep-keys INT diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/alonzo_genesis_create-testnet-data.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/alonzo_genesis_create-testnet-data.cli index 8592038d19..4673b3c135 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/alonzo_genesis_create-testnet-data.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/alonzo_genesis_create-testnet-data.cli @@ -6,6 +6,7 @@ Usage: cardano-cli alonzo genesis create-testnet-data [--spec-shelley FILEPATH] [ --stake-delegators INT | --transient-stake-delegators INT ] + [--committee-keys INT] [ --drep-keys INT | --transient-drep-keys INT ] @@ -36,6 +37,8 @@ Available options: The number of stake delegator credential sets to make (default is 0). The credentials are NOT written to disk. + --committee-keys INT The number of constitutional committee credentials to + make (default is 0). --drep-keys INT The number of DRep credentials to make (default is 0). Credentials are written to disk. --transient-drep-keys INT diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_genesis_create-testnet-data.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_genesis_create-testnet-data.cli index 8423981ef1..0c3619bdd4 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_genesis_create-testnet-data.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_genesis_create-testnet-data.cli @@ -6,6 +6,7 @@ Usage: cardano-cli babbage genesis create-testnet-data [--spec-shelley FILEPATH] [ --stake-delegators INT | --transient-stake-delegators INT ] + [--committee-keys INT] [ --drep-keys INT | --transient-drep-keys INT ] @@ -36,6 +37,8 @@ Available options: The number of stake delegator credential sets to make (default is 0). The credentials are NOT written to disk. + --committee-keys INT The number of constitutional committee credentials to + make (default is 0). --drep-keys INT The number of DRep credentials to make (default is 0). Credentials are written to disk. --transient-drep-keys INT diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_genesis_create-testnet-data.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_genesis_create-testnet-data.cli index 072b8491c8..6def83c403 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_genesis_create-testnet-data.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_genesis_create-testnet-data.cli @@ -6,6 +6,7 @@ Usage: cardano-cli conway genesis create-testnet-data [--spec-shelley FILEPATH] [ --stake-delegators INT | --transient-stake-delegators INT ] + [--committee-keys INT] [ --drep-keys INT | --transient-drep-keys INT ] @@ -36,6 +37,8 @@ Available options: The number of stake delegator credential sets to make (default is 0). The credentials are NOT written to disk. + --committee-keys INT The number of constitutional committee credentials to + make (default is 0). --drep-keys INT The number of DRep credentials to make (default is 0). Credentials are written to disk. --transient-drep-keys INT diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_genesis_create-testnet-data.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_genesis_create-testnet-data.cli index bc63feed12..19f60e007a 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_genesis_create-testnet-data.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_genesis_create-testnet-data.cli @@ -6,6 +6,7 @@ Usage: cardano-cli latest genesis create-testnet-data [--spec-shelley FILEPATH] [ --stake-delegators INT | --transient-stake-delegators INT ] + [--committee-keys INT] [ --drep-keys INT | --transient-drep-keys INT ] @@ -36,6 +37,8 @@ Available options: The number of stake delegator credential sets to make (default is 0). The credentials are NOT written to disk. + --committee-keys INT The number of constitutional committee credentials to + make (default is 0). --drep-keys INT The number of DRep credentials to make (default is 0). Credentials are written to disk. --transient-drep-keys INT diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/mary_genesis_create-testnet-data.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/mary_genesis_create-testnet-data.cli index 91df13ecce..7ecfe83700 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/mary_genesis_create-testnet-data.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/mary_genesis_create-testnet-data.cli @@ -6,6 +6,7 @@ Usage: cardano-cli mary genesis create-testnet-data [--spec-shelley FILEPATH] [ --stake-delegators INT | --transient-stake-delegators INT ] + [--committee-keys INT] [ --drep-keys INT | --transient-drep-keys INT ] @@ -36,6 +37,8 @@ Available options: The number of stake delegator credential sets to make (default is 0). The credentials are NOT written to disk. + --committee-keys INT The number of constitutional committee credentials to + make (default is 0). --drep-keys INT The number of DRep credentials to make (default is 0). Credentials are written to disk. --transient-drep-keys INT diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/shelley_genesis_create-testnet-data.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/shelley_genesis_create-testnet-data.cli index 280f8a995e..6acb078b35 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/shelley_genesis_create-testnet-data.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/shelley_genesis_create-testnet-data.cli @@ -6,6 +6,7 @@ Usage: cardano-cli shelley genesis create-testnet-data [--spec-shelley FILEPATH] [ --stake-delegators INT | --transient-stake-delegators INT ] + [--committee-keys INT] [ --drep-keys INT | --transient-drep-keys INT ] @@ -36,6 +37,8 @@ Available options: The number of stake delegator credential sets to make (default is 0). The credentials are NOT written to disk. + --committee-keys INT The number of constitutional committee credentials to + make (default is 0). --drep-keys INT The number of DRep credentials to make (default is 0). Credentials are written to disk. --transient-drep-keys INT From ee17ed5405dd73281562352bf7da523092667834 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Tue, 5 Nov 2024 12:35:02 +0100 Subject: [PATCH 4/4] create-testnet-data: extend an existing golden test to use --committee-keys --- .../Test/Golden/CreateTestnetData.hs | 10 +++++++ .../golden/conway/create-testnet-data.out | 29 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/CreateTestnetData.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/CreateTestnetData.hs index de04c4a41e..dc4c5fa354 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/CreateTestnetData.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/CreateTestnetData.hs @@ -34,6 +34,9 @@ import qualified Hedgehog.Extras.Test.Golden as H networkMagic :: Word32 networkMagic = 623 +numCommitteeKeys :: Int +numCommitteeKeys = 7 + numDReps :: Int numDReps = 5 @@ -62,6 +65,8 @@ mkArguments outputDir = , show numPools , "--drep-keys" , show numDReps + , "--committee-keys" + , show numCommitteeKeys , -- Relays file specifies two relays, like the number of SPOs "--relays" , "test/cardano-cli-golden/files/input/shelley/genesis/relays.json" @@ -137,6 +142,9 @@ golden_create_testnet_data mShelleyTemplate = forM_ (L.sgsPools $ sgStaking shelleyGenesis) $ \pool -> Seq.length (L.ppRelays pool) H.=== 1 + actualNumCCs <- liftIO $ listDirectories $ outputDir "cc-keys" + length actualNumCCs H.=== numCommitteeKeys + actualNumDReps <- liftIO $ listDirectories $ outputDir "drep-keys" length actualNumDReps H.=== numDReps @@ -146,6 +154,8 @@ golden_create_testnet_data mShelleyTemplate = conwayGenesis :: ConwayGenesis StandardCrypto <- H.readJsonFileOk $ outputDir "conway-genesis.json" + length (L.committeeMembers $ cgCommittee conwayGenesis) H.=== numCommitteeKeys + length (cgInitialDReps conwayGenesis) H.=== numDReps length (cgDelegs conwayGenesis) H.=== numStakeDelegs diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/conway/create-testnet-data.out b/cardano-cli/test/cardano-cli-golden/files/golden/conway/create-testnet-data.out index bde7c603ad..fdac79263f 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/conway/create-testnet-data.out +++ b/cardano-cli/test/cardano-cli-golden/files/golden/conway/create-testnet-data.out @@ -1,4 +1,33 @@ alonzo-genesis.json +cc-keys/README.md +cc-keys/cc1/cc.cold.skey +cc-keys/cc1/cc.cold.vkey +cc-keys/cc1/cc.hot.skey +cc-keys/cc1/cc.hot.vkey +cc-keys/cc2/cc.cold.skey +cc-keys/cc2/cc.cold.vkey +cc-keys/cc2/cc.hot.skey +cc-keys/cc2/cc.hot.vkey +cc-keys/cc3/cc.cold.skey +cc-keys/cc3/cc.cold.vkey +cc-keys/cc3/cc.hot.skey +cc-keys/cc3/cc.hot.vkey +cc-keys/cc4/cc.cold.skey +cc-keys/cc4/cc.cold.vkey +cc-keys/cc4/cc.hot.skey +cc-keys/cc4/cc.hot.vkey +cc-keys/cc5/cc.cold.skey +cc-keys/cc5/cc.cold.vkey +cc-keys/cc5/cc.hot.skey +cc-keys/cc5/cc.hot.vkey +cc-keys/cc6/cc.cold.skey +cc-keys/cc6/cc.cold.vkey +cc-keys/cc6/cc.hot.skey +cc-keys/cc6/cc.hot.vkey +cc-keys/cc7/cc.cold.skey +cc-keys/cc7/cc.cold.vkey +cc-keys/cc7/cc.hot.skey +cc-keys/cc7/cc.hot.vkey conway-genesis.json delegate-keys/README.md delegate-keys/delegate1/kes.skey