From cb3cc3ff59bfe7303b5048ae2a0878b0aa31ed96 Mon Sep 17 00:00:00 2001 From: Pablo Lamela Date: Wed, 26 Aug 2026 12:38:35 +0000 Subject: [PATCH 1/2] Support Dijkstra protocol-parameter updates Creating a protocol-parameter update in the Dijkstra era hit an error stub; build DijkstraEraBasedProtocolParametersUpdate instead, with option parsers for the four parameters the era introduces (maximum reference-script size per block and per transaction, reference-script cost stride and multiplier), and extend cost-model attachment to the era. Co-Authored-By: Konstantinos Lambrou-Latreille --- ...dano-cli_palas_dijkstra_pparam_updates.yml | 6 ++ .../CLI/EraBased/Governance/Actions/Option.hs | 59 ++++++++++++++++++- .../CLI/EraBased/Governance/Actions/Run.hs | 12 +--- 3 files changed, 66 insertions(+), 11 deletions(-) create mode 100644 .changes/20260827_131104_cardano-cli_palas_dijkstra_pparam_updates.yml diff --git a/.changes/20260827_131104_cardano-cli_palas_dijkstra_pparam_updates.yml b/.changes/20260827_131104_cardano-cli_palas_dijkstra_pparam_updates.yml new file mode 100644 index 0000000000..ef1c351479 --- /dev/null +++ b/.changes/20260827_131104_cardano-cli_palas_dijkstra_pparam_updates.yml @@ -0,0 +1,6 @@ +description: | + Protocol-parameter update proposals can now be created in the Dijkstra era with `governance action create-protocol-parameters-update`, including cost models and the parameters the era introduces: maximum reference-script size per block and per transaction, and the reference-script cost stride and multiplier. +kind: +- feature +pr: 1429 +project: cardano-cli diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Governance/Actions/Option.hs b/cardano-cli/src/Cardano/CLI/EraBased/Governance/Actions/Option.hs index 72a7918043..beaf66e449 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Governance/Actions/Option.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Governance/Actions/Option.hs @@ -21,6 +21,7 @@ import Cardano.CLI.EraBased.Governance.Actions.Command qualified as Cmd import Cardano.CLI.Option.Flag (setDefault) import Cardano.CLI.Parser import Cardano.CLI.Type.Common +import Cardano.Ledger.BaseTypes (NonZero, PositiveInterval, nonZero) import Data.Foldable import Data.Function ((&)) @@ -304,6 +305,56 @@ pIntroducedInConwayPParams = <*> convertToLedger id (optional pDRepActivity) <*> convertToLedger id (optional pMinFeeRefScriptCostPerByte) +pIntroducedInDijkstraPParams :: Parser (IntroducedInDijkstraPParams ledgerera) +pIntroducedInDijkstraPParams = + IntroducedInDijkstraPParams + <$> convertToLedger id (optional pMaxRefScriptSizePerBlock) + <*> convertToLedger id (optional pMaxRefScriptSizePerTx) + <*> convertToLedger id (optional pRefScriptCostStride) + <*> convertToLedger id (optional pRefScriptCostMultiplier) + +pMaxRefScriptSizePerBlock :: Parser Word32 +pMaxRefScriptSizePerBlock = + Opt.option integralReader $ + mconcat + [ Opt.long "max-ref-script-size-per-block" + , Opt.metavar "WORD32" + , Opt.help "Maximum total size of reference scripts per block." + ] + +pMaxRefScriptSizePerTx :: Parser Word32 +pMaxRefScriptSizePerTx = + Opt.option integralReader $ + mconcat + [ Opt.long "max-ref-script-size-per-tx" + , Opt.metavar "WORD32" + , Opt.help "Maximum total size of reference scripts per transaction." + ] + +pRefScriptCostStride :: Parser (NonZero Word32) +pRefScriptCostStride = + Opt.option + (integralReader >>= maybe (fail "ref-script-cost-stride must be non-zero") pure . nonZero) + $ mconcat + [ Opt.long "ref-script-cost-stride" + , Opt.metavar "WORD32" + , Opt.help "Reference script cost stride (non-zero) for fee calculation." + ] + +pRefScriptCostMultiplier :: Parser PositiveInterval +pRefScriptCostMultiplier = + Opt.option (readRational >>= toPositiveInterval) $ + mconcat + [ Opt.long "ref-script-cost-multiplier" + , Opt.metavar "RATIONAL" + , Opt.help "Reference script cost multiplier for fee calculation." + ] + +toPositiveInterval :: Rational -> Opt.ReadM PositiveInterval +toPositiveInterval r = + maybe (Opt.readerError $ "expected a positive rational, got: " <> show r) pure $ + L.boundRational r + -- Not necessary in Conway era onwards pProtocolParametersUpdateGenesisKeys :: Parser [VerificationKeyFile In] pProtocolParametersUpdateGenesisKeys = some pGenesisVerificationKeyFile @@ -348,8 +399,12 @@ pGovActionProtocolParametersUpdate = \case <*> pIntroducedInBabbagePParams <*> pIntroducedInConwayPParams ShelleyBasedEraDijkstra -> - -- TODO: Dijkstra - error "pGovActionProtocolParametersUpdate: Dijkstra era not supported yet" + DijkstraEraBasedProtocolParametersUpdate + <$> pCommonProtocolParameters + <*> pAlonzoOnwardsPParams + <*> pIntroducedInBabbagePParams + <*> pIntroducedInConwayPParams + <*> pIntroducedInDijkstraPParams pGovernanceActionTreasuryWithdrawalCmd :: Exp.IsEra era => Maybe (Parser (Cmd.GovernanceActionCmds era)) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Governance/Actions/Run.hs b/cardano-cli/src/Cardano/CLI/EraBased/Governance/Actions/Run.hs index 266c4ab3bb..4214d838cc 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Governance/Actions/Run.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Governance/Actions/Run.hs @@ -373,15 +373,9 @@ addCostModelsToEraBasedProtocolParametersUpdate ConwayEraBasedProtocolParametersUpdate common (aOn{alCostModels = SJust cmdls}) inB inC addCostModelsToEraBasedProtocolParametersUpdate AlonzoEraOnwardsDijkstra - _ - _ = - -- TODO: Dijkstra - -- Add new protocol parameters from - -- https://github.com/IntersectMBO/cardano-ledger/blob/master/eras/dijkstra/src/Cardano/Ledger/Dijkstra/PParams.hs#L75 - -- to - -- https://github.com/IntersectMBO/cardano-api/blob/master/cardano-api/src/Cardano/Api/ProtocolParameters.hs#L190 - -- and remove this `error` - error "addCostModelsToEraBasedProtocolParametersUpdate: Dijkstra not supported yet" + cmdls + (DijkstraEraBasedProtocolParametersUpdate common aOn inB inC inD) = + DijkstraEraBasedProtocolParametersUpdate common (aOn{alCostModels = SJust cmdls}) inB inC inD runGovernanceActionTreasuryWithdrawalCmd :: forall era e From 9f54f16c2cb61105351b9cb090af285c563f7d9c Mon Sep 17 00:00:00 2001 From: Pablo Lamela Date: Thu, 27 Aug 2026 13:48:50 +0000 Subject: [PATCH 2/2] Describe the accepted range when rejecting a cost multiplier The reference-script cost multiplier reader rejected values with "expected a positive rational", which is misleading for positive values it also rejects: rationals whose numerator or denominator does not fit in 64 bits; state the representable range in the error. --- .../src/Cardano/CLI/EraBased/Governance/Actions/Option.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Governance/Actions/Option.hs b/cardano-cli/src/Cardano/CLI/EraBased/Governance/Actions/Option.hs index beaf66e449..bc9a51f7b7 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Governance/Actions/Option.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Governance/Actions/Option.hs @@ -352,8 +352,12 @@ pRefScriptCostMultiplier = toPositiveInterval :: Rational -> Opt.ReadM PositiveInterval toPositiveInterval r = - maybe (Opt.readerError $ "expected a positive rational, got: " <> show r) pure $ - L.boundRational r + maybe + ( Opt.readerError $ + "expected a positive rational with numerator and denominator fitting in 64 bits, got: " <> show r + ) + pure + $ L.boundRational r -- Not necessary in Conway era onwards pProtocolParametersUpdateGenesisKeys :: Parser [VerificationKeyFile In]