Skip to content

Commit 403754f

Browse files
palaskoslambrou
andcommitted
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 <konstantinos.lambrou@iohk.io>
1 parent 1bae352 commit 403754f

3 files changed

Lines changed: 66 additions & 11 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
description: |
2+
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.
3+
kind:
4+
- feature
5+
pr: 1428
6+
project: cardano-cli

cardano-cli/src/Cardano/CLI/EraBased/Governance/Actions/Option.hs

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import Cardano.CLI.EraBased.Governance.Actions.Command qualified as Cmd
2121
import Cardano.CLI.Option.Flag (setDefault)
2222
import Cardano.CLI.Parser
2323
import Cardano.CLI.Type.Common
24+
import Cardano.Ledger.BaseTypes (NonZero, PositiveInterval, nonZero)
2425

2526
import Data.Foldable
2627
import Data.Function ((&))
@@ -304,6 +305,56 @@ pIntroducedInConwayPParams =
304305
<*> convertToLedger id (optional pDRepActivity)
305306
<*> convertToLedger id (optional pMinFeeRefScriptCostPerByte)
306307

308+
pIntroducedInDijkstraPParams :: Parser (IntroducedInDijkstraPParams ledgerera)
309+
pIntroducedInDijkstraPParams =
310+
IntroducedInDijkstraPParams
311+
<$> convertToLedger id (optional pMaxRefScriptSizePerBlock)
312+
<*> convertToLedger id (optional pMaxRefScriptSizePerTx)
313+
<*> convertToLedger id (optional pRefScriptCostStride)
314+
<*> convertToLedger id (optional pRefScriptCostMultiplier)
315+
316+
pMaxRefScriptSizePerBlock :: Parser Word32
317+
pMaxRefScriptSizePerBlock =
318+
Opt.option integralReader $
319+
mconcat
320+
[ Opt.long "max-ref-script-size-per-block"
321+
, Opt.metavar "WORD32"
322+
, Opt.help "Maximum total size of reference scripts per block."
323+
]
324+
325+
pMaxRefScriptSizePerTx :: Parser Word32
326+
pMaxRefScriptSizePerTx =
327+
Opt.option integralReader $
328+
mconcat
329+
[ Opt.long "max-ref-script-size-per-tx"
330+
, Opt.metavar "WORD32"
331+
, Opt.help "Maximum total size of reference scripts per transaction."
332+
]
333+
334+
pRefScriptCostStride :: Parser (NonZero Word32)
335+
pRefScriptCostStride =
336+
Opt.option
337+
(integralReader >>= maybe (fail "ref-script-cost-stride must be non-zero") pure . nonZero)
338+
$ mconcat
339+
[ Opt.long "ref-script-cost-stride"
340+
, Opt.metavar "WORD32"
341+
, Opt.help "Reference script cost stride (non-zero) for fee calculation."
342+
]
343+
344+
pRefScriptCostMultiplier :: Parser PositiveInterval
345+
pRefScriptCostMultiplier =
346+
Opt.option (readRational >>= toPositiveInterval) $
347+
mconcat
348+
[ Opt.long "ref-script-cost-multiplier"
349+
, Opt.metavar "RATIONAL"
350+
, Opt.help "Reference script cost multiplier for fee calculation."
351+
]
352+
353+
toPositiveInterval :: Rational -> Opt.ReadM PositiveInterval
354+
toPositiveInterval r =
355+
maybe (Opt.readerError $ "expected a positive rational, got: " <> show r) pure $
356+
L.boundRational r
357+
307358
-- Not necessary in Conway era onwards
308359
pProtocolParametersUpdateGenesisKeys :: Parser [VerificationKeyFile In]
309360
pProtocolParametersUpdateGenesisKeys = some pGenesisVerificationKeyFile
@@ -348,8 +399,12 @@ pGovActionProtocolParametersUpdate = \case
348399
<*> pIntroducedInBabbagePParams
349400
<*> pIntroducedInConwayPParams
350401
ShelleyBasedEraDijkstra ->
351-
-- TODO: Dijkstra
352-
error "pGovActionProtocolParametersUpdate: Dijkstra era not supported yet"
402+
DijkstraEraBasedProtocolParametersUpdate
403+
<$> pCommonProtocolParameters
404+
<*> pAlonzoOnwardsPParams
405+
<*> pIntroducedInBabbagePParams
406+
<*> pIntroducedInConwayPParams
407+
<*> pIntroducedInDijkstraPParams
353408

354409
pGovernanceActionTreasuryWithdrawalCmd
355410
:: Exp.IsEra era => Maybe (Parser (Cmd.GovernanceActionCmds era))

cardano-cli/src/Cardano/CLI/EraBased/Governance/Actions/Run.hs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -373,15 +373,9 @@ addCostModelsToEraBasedProtocolParametersUpdate
373373
ConwayEraBasedProtocolParametersUpdate common (aOn{alCostModels = SJust cmdls}) inB inC
374374
addCostModelsToEraBasedProtocolParametersUpdate
375375
AlonzoEraOnwardsDijkstra
376-
_
377-
_ =
378-
-- TODO: Dijkstra
379-
-- Add new protocol parameters from
380-
-- https://github.com/IntersectMBO/cardano-ledger/blob/master/eras/dijkstra/src/Cardano/Ledger/Dijkstra/PParams.hs#L75
381-
-- to
382-
-- https://github.com/IntersectMBO/cardano-api/blob/master/cardano-api/src/Cardano/Api/ProtocolParameters.hs#L190
383-
-- and remove this `error`
384-
error "addCostModelsToEraBasedProtocolParametersUpdate: Dijkstra not supported yet"
376+
cmdls
377+
(DijkstraEraBasedProtocolParametersUpdate common aOn inB inC inD) =
378+
DijkstraEraBasedProtocolParametersUpdate common (aOn{alCostModels = SJust cmdls}) inB inC inD
385379

386380
runGovernanceActionTreasuryWithdrawalCmd
387381
:: forall era e

0 commit comments

Comments
 (0)