Skip to content
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
Original file line number Diff line number Diff line change
@@ -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.
Comment thread
palas marked this conversation as resolved.
kind:
- feature
pr: 1429
project: cardano-cli
Original file line number Diff line number Diff line change
Expand Up @@ -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 ((&))
Expand Down Expand Up @@ -304,6 +305,60 @@ 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"
Comment thread
palas marked this conversation as resolved.
, 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 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]
pProtocolParametersUpdateGenesisKeys = some pGenesisVerificationKeyFile
Expand Down Expand Up @@ -348,8 +403,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))
Expand Down
12 changes: 3 additions & 9 deletions cardano-cli/src/Cardano/CLI/EraBased/Governance/Actions/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading