Skip to content

Commit

Permalink
Address some review comments from Jordan
Browse files Browse the repository at this point in the history
  • Loading branch information
carlhammann committed Nov 23, 2023
1 parent 4c00091 commit 250443a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ pShelleyToAlonzoPParams =

pAlonzoOnwardsPParams :: Parser (AlonzoOnwardsPParams ledgerera)
pAlonzoOnwardsPParams =
AlonzoOnwardsPParams SNothing
AlonzoOnwardsPParams SNothing -- The cost models are read separately from a file, so we use 'SNothing' as the place holder here
<$> convertToLedger (either (\e -> error $ "pAlonzoOnwardsPParams: " <> show e) id . toAlonzoPrices)
(optional pExecutionUnitPrices)
<*> convertToLedger toAlonzoExUnits (optional pMaxTxExecutionUnits)
Expand Down
30 changes: 14 additions & 16 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Actions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -237,24 +237,20 @@ runGovernanceActionCreateProtocolParametersUpdateCmd eraBasedPParams' = do
<- hoistMaybe (GovernanceActionsValueUpdateProtocolParametersNotFound anyEra)
$ uppPreConway eraBasedPParams'

eraBasedPParams
<- case uppCostModelsFile eraBasedPParams' of
Nothing -> pure $ uppNewPParams eraBasedPParams'
Just (Cmd.CostModelsFile alonzoOnwards costModelsFile) -> do
costModels <- firstExceptT GovernanceActionsCmdCostModelsError
$ readCostModels costModelsFile
pure . addCostModelsToEraBasedProtocolParametersUpdate alonzoOnwards costModels
$ uppNewPParams eraBasedPParams'
eraBasedPParams <- theUpdate

let updateProtocolParams = createEraBasedProtocolParamUpdate sbe eraBasedPParams
apiUpdateProtocolParamsType = fromLedgerPParamsUpdate sbe updateProtocolParams

genVKeys <- sequence
[ firstExceptT GovernanceActionsCmdReadTextEnvelopeFileError . newExceptT
$ readFileTextEnvelope (AsVerificationKey AsGenesisKey) vkeyFile
| vkeyFile <- genesisVerKeys
]

let genKeyHashes = fmap verificationKeyHash genVKeys
upProp = makeShelleyUpdateProposal apiUpdateProtocolParamsType genKeyHashes expEpoch

firstExceptT GovernanceActionsCmdWriteFileError . newExceptT
$ writeLazyByteStringFile oFp $ textEnvelopeToJSON Nothing upProp
)
Expand All @@ -267,14 +263,7 @@ runGovernanceActionCreateProtocolParametersUpdateCmd eraBasedPParams' = do
<- hoistMaybe (GovernanceActionsValueUpdateProtocolParametersNotFound anyEra)
$ uppConwayOnwards eraBasedPParams'

eraBasedPParams
<- case uppCostModelsFile eraBasedPParams' of
Nothing -> pure $ uppNewPParams eraBasedPParams'
Just (Cmd.CostModelsFile alonzoOnwards costModelsFile) -> do
costModels <- firstExceptT GovernanceActionsCmdCostModelsError
$ readCostModels costModelsFile
pure . addCostModelsToEraBasedProtocolParametersUpdate alonzoOnwards costModels
$ uppNewPParams eraBasedPParams'
eraBasedPParams <- theUpdate

returnKeyHash <- readStakeKeyHash returnAddr

Expand All @@ -295,6 +284,15 @@ runGovernanceActionCreateProtocolParametersUpdateCmd eraBasedPParams' = do
$ writeFileTextEnvelope oFp Nothing proposalProcedure
)
sbe
where
theUpdate =
case uppCostModelsFile eraBasedPParams' of
Nothing -> pure $ uppNewPParams eraBasedPParams'
Just (Cmd.CostModelsFile alonzoOnwards costModelsFile) -> do
costModels <- firstExceptT GovernanceActionsCmdCostModelsError
$ readCostModels costModelsFile
pure . addCostModelsToEraBasedProtocolParametersUpdate alonzoOnwards costModels
$ uppNewPParams eraBasedPParams'

readStakeKeyHash :: VerificationKeyOrHashOrFile StakeKey -> ExceptT GovernanceActionsError IO (Hash StakeKey)
readStakeKeyHash stake =
Expand Down

0 comments on commit 250443a

Please sign in to comment.