From 4fbd082593af75b4fdda9d1164b69370164732bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Wed, 21 Aug 2024 10:23:54 +0200 Subject: [PATCH 1/2] Share code in parsers of protocol version --- .../Cardano/CLI/EraBased/Options/Common.hs | 15 +++++++---- .../EraBased/Options/Governance/Actions.hs | 27 +------------------ 2 files changed, 11 insertions(+), 31 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs index ba79990b61..062df16d70 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs @@ -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." ] ] diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Actions.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Actions.hs index 7ee4982d5e..5b8908b744 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Actions.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Actions.hs @@ -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 From ddfff6841591741caa4909036e0e2073b307b683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Wed, 21 Aug 2024 10:24:12 +0200 Subject: [PATCH 2/2] Adapt golden files --- .../cardano-cli-golden/files/golden/help.cli | 32 +++++++++---------- ...tion_create-protocol-parameters-update.cli | 19 ++++++----- ...tion_create-protocol-parameters-update.cli | 19 ++++++----- ...tion_create-protocol-parameters-update.cli | 19 ++++++----- ...nway_governance_action_create-hardfork.cli | 13 +++++--- .../governance_create-update-proposal.cli | 19 ++++++----- ...tion_create-protocol-parameters-update.cli | 19 ++++++----- ...gacy_governance_create-update-proposal.cli | 19 ++++++----- ...tion_create-protocol-parameters-update.cli | 19 ++++++----- ...tion_create-protocol-parameters-update.cli | 19 ++++++----- 10 files changed, 112 insertions(+), 85 deletions(-) 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 c3e393e5a4..a3c951f4fd 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli @@ -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 ] @@ -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. @@ -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. @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/allegra_governance_action_create-protocol-parameters-update.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/allegra_governance_action_create-protocol-parameters-update.cli index 129c29ef01..76461c012f 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/allegra_governance_action_create-protocol-parameters-update.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/allegra_governance_action_create-protocol-parameters-update.cli @@ -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. @@ -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 diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/alonzo_governance_action_create-protocol-parameters-update.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/alonzo_governance_action_create-protocol-parameters-update.cli index 7e77d15659..a768f6456f 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/alonzo_governance_action_create-protocol-parameters-update.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/alonzo_governance_action_create-protocol-parameters-update.cli @@ -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 @@ -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 diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance_action_create-protocol-parameters-update.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance_action_create-protocol-parameters-update.cli index d8851b10ac..18ecee9903 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance_action_create-protocol-parameters-update.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/babbage_governance_action_create-protocol-parameters-update.cli @@ -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 @@ -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). diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_create-hardfork.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_create-hardfork.cli index 9843b3ebc9..4ffd0c3539 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_create-hardfork.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_create-hardfork.cli @@ -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 diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/governance_create-update-proposal.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/governance_create-update-proposal.cli index f1a4bfc3db..b7ebe76c2a 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/governance_create-update-proposal.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/governance_create-update-proposal.cli @@ -1,8 +1,8 @@ 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 @@ -39,13 +39,16 @@ Available options: valid. --genesis-verification-key-file FILE Filepath of the genesis verification key. - --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. --decentralization-parameter RATIONAL Decentralization parameter. --extra-entropy HEX Praos extra entropy seed, as a hex byte string. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance_action_create-protocol-parameters-update.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance_action_create-protocol-parameters-update.cli index 037db77bfb..aa6a3acd9e 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance_action_create-protocol-parameters-update.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance_action_create-protocol-parameters-update.cli @@ -20,8 +20,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 @@ -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). diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_governance_create-update-proposal.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_governance_create-update-proposal.cli index 0b63e919fb..b66c833b13 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_governance_create-update-proposal.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/legacy_governance_create-update-proposal.cli @@ -1,8 +1,8 @@ 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 @@ -39,13 +39,16 @@ Available options: valid. --genesis-verification-key-file FILE Filepath of the genesis verification key. - --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. --decentralization-parameter RATIONAL Decentralization parameter. --extra-entropy HEX Praos extra entropy seed, as a hex byte string. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/mary_governance_action_create-protocol-parameters-update.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/mary_governance_action_create-protocol-parameters-update.cli index d494ef432f..07582d9599 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/mary_governance_action_create-protocol-parameters-update.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/mary_governance_action_create-protocol-parameters-update.cli @@ -18,8 +18,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. @@ -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 diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/shelley_governance_action_create-protocol-parameters-update.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/shelley_governance_action_create-protocol-parameters-update.cli index 1abe0097c9..86fae3b0ce 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/shelley_governance_action_create-protocol-parameters-update.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/shelley_governance_action_create-protocol-parameters-update.cli @@ -14,8 +14,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 ] @@ -56,13 +56,16 @@ Available options: --min-pool-cost NATURAL The minimum allowed cost parameter for stake pools. --min-utxo-value NATURAL The minimum allowed UTxO value (Shelley to Mary eras). - --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. --extra-entropy HEX Praos extra entropy seed, as a hex byte string. --reset-extra-entropy Reset the Praos extra entropy to none. --decentralization-parameter RATIONAL