-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
create-testnet-data: use experimental API and make arguments era specific #968
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE DuplicateRecordFields #-} | ||
{-# LANGUAGE ExistentialQuantification #-} | ||
{-# LANGUAGE LambdaCase #-} | ||
|
||
module Cardano.CLI.EraBased.Commands.Genesis | ||
|
@@ -19,6 +20,7 @@ module Cardano.CLI.EraBased.Commands.Genesis | |
where | ||
|
||
import qualified Cardano.Api.Byron as Byron | ||
import qualified Cardano.Api.Experimental as Exp | ||
import Cardano.Api.Ledger (Coin) | ||
import Cardano.Api.Shelley | ||
|
||
|
@@ -30,7 +32,7 @@ data GenesisCmds era | |
= GenesisCreate !(GenesisCreateCmdArgs era) | ||
| GenesisCreateCardano !(GenesisCreateCardanoCmdArgs era) | ||
| GenesisCreateStaked !(GenesisCreateStakedCmdArgs era) | ||
| GenesisCreateTestNetData !(GenesisCreateTestNetDataCmdArgs era) | ||
| GenesisCreateTestNetData !GenesisCreateTestNetDataCmdArgs | ||
| GenesisKeyGenGenesis !GenesisKeyGenGenesisCmdArgs | ||
| GenesisKeyGenDelegate !GenesisKeyGenDelegateCmdArgs | ||
| GenesisKeyGenUTxO !GenesisKeyGenUTxOCmdArgs | ||
|
@@ -92,8 +94,10 @@ data GenesisCreateStakedCmdArgs era = GenesisCreateStakedCmdArgs | |
} | ||
deriving Show | ||
|
||
data GenesisCreateTestNetDataCmdArgs era = GenesisCreateTestNetDataCmdArgs | ||
{ eon :: !(ShelleyBasedEra era) | ||
-- TODO This existential type parameter should become a regular type parameter | ||
-- when we parameterize the parent type by the experimental era API. | ||
data GenesisCreateTestNetDataCmdArgs = forall era. GenesisCreateTestNetDataCmdArgs | ||
{ eon :: !(Exp.Era era) | ||
, specShelley :: !(Maybe FilePath) | ||
-- ^ Path to the @genesis-shelley@ file to use. If unspecified, a default one will be used. | ||
, specAlonzo :: !(Maybe FilePath) | ||
|
@@ -127,7 +131,9 @@ data GenesisCreateTestNetDataCmdArgs era = GenesisCreateTestNetDataCmdArgs | |
, outputDir :: !FilePath | ||
-- ^ Directory where to write credentials and files. | ||
} | ||
deriving Show | ||
|
||
instance Show GenesisCreateTestNetDataCmdArgs where | ||
show _ = "GenesisCreateTestNetDataCmdArgs" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't derive anymore? It is odd because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @palas> it doesn't derive anymore because there's an existential type in |
||
|
||
data GenesisKeyGenGenesisCmdArgs = GenesisKeyGenGenesisCmdArgs | ||
{ verificationKeyPath :: !(VerificationKeyFile Out) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ where | |
|
||
import Cardano.Api hiding (QueryInShelleyBasedEra (..)) | ||
import qualified Cardano.Api.Byron as Byron | ||
import qualified Cardano.Api.Experimental as Exp | ||
import Cardano.Api.Ledger (Coin (..)) | ||
|
||
import Cardano.CLI.Environment (EnvCli (..)) | ||
|
@@ -217,18 +218,18 @@ pGenesisCreateStaked sbe envCli = | |
pRelayJsonFp = | ||
parseFilePath "relay-specification-file" "JSON file that specifies the relays of each stake pool." | ||
|
||
pGenesisCreateTestNetData :: ShelleyBasedEra era -> EnvCli -> Parser (GenesisCmds era) | ||
pGenesisCreateTestNetData sbe envCli = | ||
pGenesisCreateTestNetData :: Exp.Era era -> EnvCli -> Parser (GenesisCmds era) | ||
pGenesisCreateTestNetData era envCli = | ||
fmap GenesisCreateTestNetData $ | ||
GenesisCreateTestNetDataCmdArgs sbe | ||
GenesisCreateTestNetDataCmdArgs era | ||
<$> optional (pSpecFile "shelley") | ||
<*> optional (pSpecFile "alonzo") | ||
<*> optional (pSpecFile "conway") | ||
<*> pNumGenesisKeys | ||
<*> pNumPools | ||
<*> pNumStakeDelegs | ||
<*> pNumCommittee | ||
<*> pNumDReps | ||
<*> (case era of Exp.BabbageEra -> pure 0; Exp.ConwayEra -> pNumCommittee) -- Committee doesn't exist in babbage | ||
<*> (case era of Exp.BabbageEra -> pure $ DRepCredentials OnDisk 0; Exp.ConwayEra -> pNumDReps) -- DReps don't exist in babbage | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Making it unrepresentable on the type would be safer. But this is probably much simpler, so it seems a reasonable trade-off There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Those inlined cases are not very readable, can you move them to a values in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd also use if someEra < Some Exp.ConwayEra
then pure 0
else pNumCommittee and if someEra < Some Exp.ConwayEra
then pure $ DRepCredentials OnDisk 0
else pNumDReps Rationale: less maintenance burden when introducing new eras - you won't have to change each usage site of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@carbolymer> I'm not sure this is really better, because there are at most two experimental eras at any point in time and when we delete one era, the index of the other era (the one being kept) shrinks from 1 to 0. So I wouldn't rely on the ordering here. I think pattern matching makes the intent more explicit. |
||
<*> pNumStuffedUtxoCount | ||
<*> pNumUtxoKeys | ||
<*> pSupply | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not
Some Exp.Era
instead?