Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Share code in parsers of protocol version #869

Merged
merged 2 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3420,18 +3420,23 @@ pProtocolVersion =
Opt.option Opt.auto $
mconcat
[ Opt.long "protocol-major-version"
, Opt.metavar "NATURAL"
, Opt.help "Major protocol version. An increase indicates a hard fork."
, Opt.metavar "MAJOR"
, Opt.help $
mconcat
[ "Specify the major protocol version to fork into. An increase indicates a hard fork. "
, "It must be the next natural number after the current version and must be supported by the node."
]
]
pProtocolMinorVersion =
Opt.option Opt.auto $
mconcat
[ Opt.long "protocol-minor-version"
, Opt.metavar "NATURAL"
, Opt.metavar "MINOR"
, Opt.help $
mconcat
[ "Minor protocol version. An increase indicates a soft fork"
, " (old software canvalidate but not produce new blocks)."
[ "Minor protocol version. An increase indicates a soft fork "
, "(old software can validate but not produce new blocks). "
, "Must be zero when the major protocol version is increased."
]
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,33 +402,8 @@ pNetwork =
]
]

pNewProtVer :: Parser (Natural, Natural)
pNewProtVer = (,) <$> pProtMajor <*> pProtMinor
where
pProtMajor :: Parser Natural
pProtMajor =
Opt.option Opt.auto $
mconcat
[ Opt.long "protocol-major-version"
, Opt.metavar "MAJOR"
, Opt.help $
mconcat
[ "Specify the major protocol version to fork into. It must be the next natural number "
, "after the current version and must be supported by the node."
]
]

pProtMinor :: Parser Natural
pProtMinor =
Opt.option Opt.auto $
mconcat
[ Opt.long "protocol-minor-version"
, Opt.metavar "MINOR"
, Opt.help "Minor protocol version. Must be zero when the major protocol version is increased."
]

pPV :: Parser L.ProtVer
pPV = mkProtocolVersionOrErr <$> pNewProtVer
pPV = mkProtocolVersionOrErr <$> pProtocolVersion

pGovernanceActionHardforkInitCmd
:: CardanoEra era
Expand Down
32 changes: 16 additions & 16 deletions cardano-cli/test/cardano-cli-golden/files/golden/help.cli
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,8 @@ Usage: cardano-cli shelley governance action create-protocol-parameters-update -
[--monetary-expansion RATIONAL]
[--min-pool-cost NATURAL]
[--min-utxo-value NATURAL]
[--protocol-major-version NATURAL
--protocol-minor-version NATURAL]
[--protocol-major-version MAJOR
--protocol-minor-version MINOR]
[ --extra-entropy HEX
| --reset-extra-entropy
]
Expand Down Expand Up @@ -1571,8 +1571,8 @@ Usage: cardano-cli allegra governance action create-protocol-parameters-update -
| --reset-extra-entropy
]
[--decentralization-parameter RATIONAL]
[--protocol-major-version NATURAL
--protocol-minor-version NATURAL]
[--protocol-major-version MAJOR
--protocol-minor-version MINOR]
--out-file FILE

Create a protocol parameters update.
Expand Down Expand Up @@ -2764,8 +2764,8 @@ Usage: cardano-cli mary governance action create-protocol-parameters-update --ep
| --reset-extra-entropy
]
[--decentralization-parameter RATIONAL]
[--protocol-major-version NATURAL
--protocol-minor-version NATURAL]
[--protocol-major-version MAJOR
--protocol-minor-version MINOR]
--out-file FILE

Create a protocol parameters update.
Expand Down Expand Up @@ -4079,8 +4079,8 @@ Usage: cardano-cli alonzo governance action create-protocol-parameters-update --
[--max-value-size INT]
[--collateral-percent INT]
[--max-collateral-inputs INT]
[--protocol-major-version NATURAL
--protocol-minor-version NATURAL]
[--protocol-major-version MAJOR
--protocol-minor-version MINOR]
[--cost-model-file FILE]
--out-file FILE

Expand Down Expand Up @@ -5412,8 +5412,8 @@ Usage: cardano-cli babbage governance action create-protocol-parameters-update -
[--max-value-size INT]
[--collateral-percent INT]
[--max-collateral-inputs INT]
[--protocol-major-version NATURAL
--protocol-minor-version NATURAL]
[--protocol-major-version MAJOR
--protocol-minor-version MINOR]
[--utxo-cost-per-byte LOVELACE]
[--cost-model-file FILE]
--out-file FILE
Expand Down Expand Up @@ -8670,8 +8670,8 @@ Usage: cardano-cli latest governance action create-protocol-parameters-update --
[--max-value-size INT]
[--collateral-percent INT]
[--max-collateral-inputs INT]
[--protocol-major-version NATURAL
--protocol-minor-version NATURAL]
[--protocol-major-version MAJOR
--protocol-minor-version MINOR]
[--utxo-cost-per-byte LOVELACE]
[--cost-model-file FILE]
--out-file FILE
Expand Down Expand Up @@ -9769,8 +9769,8 @@ Usage: cardano-cli legacy governance create-genesis-key-delegation-certificate
Usage: cardano-cli legacy governance create-update-proposal --out-file FILE
--epoch NATURAL
(--genesis-verification-key-file FILE)
[--protocol-major-version NATURAL
--protocol-minor-version NATURAL]
[--protocol-major-version MAJOR
--protocol-minor-version MINOR]
[--decentralization-parameter RATIONAL]
[ --extra-entropy HEX
| --reset-extra-entropy
Expand Down Expand Up @@ -11082,8 +11082,8 @@ Usage: cardano-cli governance create-genesis-key-delegation-certificate
Usage: cardano-cli governance create-update-proposal --out-file FILE
--epoch NATURAL
(--genesis-verification-key-file FILE)
[--protocol-major-version NATURAL
--protocol-minor-version NATURAL]
[--protocol-major-version MAJOR
--protocol-minor-version MINOR]
[--decentralization-parameter RATIONAL]
[ --extra-entropy HEX
| --reset-extra-entropy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ Usage: cardano-cli allegra governance action create-protocol-parameters-update -
| --reset-extra-entropy
]
[--decentralization-parameter RATIONAL]
[--protocol-major-version NATURAL
--protocol-minor-version NATURAL]
[--protocol-major-version MAJOR
--protocol-minor-version MINOR]
--out-file FILE

Create a protocol parameters update.
Expand Down Expand Up @@ -60,12 +60,15 @@ Available options:
--reset-extra-entropy Reset the Praos extra entropy to none.
--decentralization-parameter RATIONAL
Decentralization parameter.
--protocol-major-version NATURAL
Major protocol version. An increase indicates a hard
fork.
--protocol-minor-version NATURAL
--protocol-major-version MAJOR
Specify the major protocol version to fork into. An
increase indicates a hard fork. It must be the next
natural number after the current version and must be
supported by the node.
--protocol-minor-version MINOR
Minor protocol version. An increase indicates a soft
fork (old software canvalidate but not produce new
blocks).
fork (old software can validate but not produce new
blocks). Must be zero when the major protocol version
is increased.
--out-file FILE The output file.
-h,--help Show this help text
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ Usage: cardano-cli alonzo governance action create-protocol-parameters-update --
[--max-value-size INT]
[--collateral-percent INT]
[--max-collateral-inputs INT]
[--protocol-major-version NATURAL
--protocol-minor-version NATURAL]
[--protocol-major-version MAJOR
--protocol-minor-version MINOR]
[--cost-model-file FILE]
--out-file FILE

Expand Down Expand Up @@ -89,13 +89,16 @@ Available options:
--max-collateral-inputs INT
The maximum number of collateral inputs allowed in a
transaction (from Alonzo era).
--protocol-major-version NATURAL
Major protocol version. An increase indicates a hard
fork.
--protocol-minor-version NATURAL
--protocol-major-version MAJOR
Specify the major protocol version to fork into. An
increase indicates a hard fork. It must be the next
natural number after the current version and must be
supported by the node.
--protocol-minor-version MINOR
Minor protocol version. An increase indicates a soft
fork (old software canvalidate but not produce new
blocks).
fork (old software can validate but not produce new
blocks). Must be zero when the major protocol version
is increased.
--cost-model-file FILE Filepath of the JSON formatted cost model
--out-file FILE The output file.
-h,--help Show this help text
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Usage: cardano-cli babbage governance action create-protocol-parameters-update -
[--max-value-size INT]
[--collateral-percent INT]
[--max-collateral-inputs INT]
[--protocol-major-version NATURAL
--protocol-minor-version NATURAL]
[--protocol-major-version MAJOR
--protocol-minor-version MINOR]
[--utxo-cost-per-byte LOVELACE]
[--cost-model-file FILE]
--out-file FILE
Expand Down Expand Up @@ -82,13 +82,16 @@ Available options:
--max-collateral-inputs INT
The maximum number of collateral inputs allowed in a
transaction (from Alonzo era).
--protocol-major-version NATURAL
Major protocol version. An increase indicates a hard
fork.
--protocol-minor-version NATURAL
--protocol-major-version MAJOR
Specify the major protocol version to fork into. An
increase indicates a hard fork. It must be the next
natural number after the current version and must be
supported by the node.
--protocol-minor-version MINOR
Minor protocol version. An increase indicates a soft
fork (old software canvalidate but not produce new
blocks).
fork (old software can validate but not produce new
blocks). Must be zero when the major protocol version
is increased.
--utxo-cost-per-byte LOVELACE
Cost in lovelace per unit of UTxO storage (from
Babbage era).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@ Available options:
--anchor-data-hash HASH Proposal anchor data hash (obtain it with
"cardano-cli hash anchor-data ...")
--protocol-major-version MAJOR
Specify the major protocol version to fork into. It
must be the next natural number after the current
version and must be supported by the node.
Specify the major protocol version to fork into. An
increase indicates a hard fork. It must be the next
natural number after the current version and must be
supported by the node.
--protocol-minor-version MINOR
Minor protocol version. Must be zero when the major
protocol version is increased.
Minor protocol version. An increase indicates a soft
fork (old software can validate but not produce new
blocks). Must be zero when the major protocol version
is increased.
--out-file FILE Output filepath of the hardfork proposal.
-h,--help Show this help text
Loading
Loading