From bb2960da0740bcbb48cefe06c506fe98679f16df Mon Sep 17 00:00:00 2001 From: Carl Hammann Date: Tue, 14 Nov 2023 12:13:06 +0100 Subject: [PATCH 1/5] Add cost models to protocol parameter update --- .../EraBased/Commands/Governance/Actions.hs | 18 +- .../Cardano/CLI/EraBased/Options/Common.hs | 11 +- .../EraBased/Options/Governance/Actions.hs | 17 +- .../CLI/EraBased/Run/Governance/Actions.hs | 51 +- cardano-cli/src/Cardano/CLI/Read.hs | 29 +- .../Types/Errors/GovernanceActionsError.hs | 3 + .../Test/Golden/ErrorsSpec.hs | 15 + .../Test/Golden/Governance/Action.hs | 25 + .../GovernanceActionsCmdCostModelsError.txt | 1 + .../CostModelsErrorEmpty.txt | 1 + .../CostModelsErrorJSONDecode.txt | 1 + .../CostModelsErrorReadFile.txt | 1 + ...y-create-protocol-parameters-update.action | 5 + .../cardano-cli-golden/files/golden/help.cli | 18 +- ...tion_create-protocol-parameters-update.cli | 2 + ...tion_create-protocol-parameters-update.cli | 2 + ..._governance_action_create-constitution.cli | 12 +- ...tion_create-protocol-parameters-update.cli | 21 +- ...way_governance_action_update-committee.cli | 12 +- ...tion_create-protocol-parameters-update.cli | 2 + .../files/input/governance/costmodels.json | 573 ++++++++++++++++++ 21 files changed, 781 insertions(+), 39 deletions(-) create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/errors/Cardano.CLI.EraBased.Run.Governance.Actions.GovernanceActionsError/GovernanceActionsCmdCostModelsError.txt create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/errors/Cardano.CLI.Read.CostModelsError/CostModelsErrorEmpty.txt create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/errors/Cardano.CLI.Read.CostModelsError/CostModelsErrorJSONDecode.txt create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/errors/Cardano.CLI.Read.CostModelsError/CostModelsErrorReadFile.txt create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/governance/action/conway-create-protocol-parameters-update.action create mode 100644 cardano-cli/test/cardano-cli-golden/files/input/governance/costmodels.json diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Actions.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Actions.hs index ff01ddcf0e..88f8f035ab 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Actions.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Actions.hs @@ -17,6 +17,7 @@ module Cardano.CLI.EraBased.Commands.Governance.Actions , GovernanceActionTreasuryWithdrawalCmdArgs(..) , UpdateProtocolParametersConwayOnwards(..) , UpdateProtocolParametersPreConway(..) + , CostModelsFile(..) , renderGovernanceActionCmds ) where @@ -32,6 +33,7 @@ import qualified Cardano.Ledger.SafeHash as Ledger import Data.Text (Text) import Data.Word +import qualified Cardano.Ledger.Alonzo.Scripts as Alonzo data GovernanceActionCmds era = GovernanceActionCreateConstitutionCmd !(GovernanceActionCreateConstitutionCmdArgs era) @@ -102,7 +104,15 @@ data GovernanceActionProtocolParametersUpdateCmdArgs era { uppShelleyBasedEra :: !(ShelleyBasedEra era) , uppPreConway :: !(Maybe (UpdateProtocolParametersPreConway era)) , uppConwayOnwards :: !(Maybe (UpdateProtocolParametersConwayOnwards era)) - , uppNewPParams :: !(EraBasedProtocolParametersUpdate era) + -- | New parameters to be proposed. From Alonzo onwards, the type + -- 'EraBasedProtocolParametersUpdate' also contains cost models. Since all + -- other protocol parameters are read from command line arguments, whereas + -- the cost models are read from a file, we separate the cost models from + -- the rest of the protocol parameters to ease parsing. + , uppNewPParams :: !(EraBasedProtocolParametersUpdate era) + -- | The new cost models proposed. See the comment at 'uppNewPParams' for + -- why this is a separate field. + , uppCostModelsFile :: !(Maybe (CostModelsFile era)) , uppFilePath :: !(File () Out) } deriving Show @@ -137,6 +147,12 @@ data UpdateProtocolParametersConwayOnwards era , governanceActionId :: !(Maybe (TxId, Word32)) } +data CostModelsFile era + = CostModelsFile + { eon :: !(AlonzoEraOnwards era) + , costModelsFile :: !(File Alonzo.CostModels In) + } deriving Show + deriving instance Show (UpdateProtocolParametersConwayOnwards era) data UpdateProtocolParametersPreConway era diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs index 70d313a8e0..ad1a29e520 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs @@ -903,6 +903,13 @@ pGovActionDeposit = , Opt.help "Deposit required to submit a governance action." ] +pNewGovActionDeposit :: Parser Lovelace +pNewGovActionDeposit = + Opt.option (readerFromParsecParser parseLovelace) $ mconcat + [ Opt.long "new-governance-action-deposit" + , Opt.metavar "NATURAL" + , Opt.help "Proposed new value of the deposit required to submit a governance action." + ] -- | First argument is the optional prefix pStakeVerificationKeyOrHashOrFile :: Maybe String -> Parser (VerificationKeyOrHashOrFile StakeKey) @@ -3197,8 +3204,8 @@ pAnchorDataHash = pPreviousGovernanceAction :: Parser (Maybe (TxId, Word32)) pPreviousGovernanceAction = optional $ - (,) <$> pTxId "governance-action-tx-id" "Previous txid of the governance action." - <*> pWord32 "governance-action-index" "Previous tx's governance action index." + (,) <$> pTxId "prev-governance-action-tx-id" "Txid of the previous governance action." + <*> pWord32 "prev-governance-action-index" "Action index of the previous governance action." pGovernanceActionId :: Parser (TxId, Word32) pGovernanceActionId = 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 98dfb3f529..c96c719cdf 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Actions.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Actions.hs @@ -180,6 +180,7 @@ pUpdateProtocolParametersCmd = <$> fmap Just (pUpdateProtocolParametersPreConway shelleyToBab) <*> pure Nothing <*> dpGovActionProtocolParametersUpdate sbe + <*> pCostModelsFile sbe <*> pOutputFile ) $ Opt.progDesc "Create a protocol parameters update.") @@ -191,12 +192,24 @@ pUpdateProtocolParametersCmd = (conwayEraOnwardsToShelleyBasedEra conwayOnwards) Nothing <$> fmap Just (pUpdateProtocolParametersPostConway conwayOnwards) <*> dpGovActionProtocolParametersUpdate sbe + <*> pCostModelsFile sbe <*> pOutputFile ) $ Opt.progDesc "Create a protocol parameters update." ) +-- | Cost models only makes sense in eras from Alonzo onwards. For earlier +-- eras, this parser doesn't show up in the command line and returns 'Nothing'. +pCostModelsFile :: ShelleyBasedEra era -> Parser (Maybe (Cmd.CostModelsFile era)) +pCostModelsFile = + caseShelleyToMaryOrAlonzoEraOnwards + (const $ pure Nothing) + ( \alonzoOnwards -> + fmap (Cmd.CostModelsFile alonzoOnwards . File) + <$> optional pCostModels + ) + pGovernanceActionProtocolParametersUpdateCmd :: () => CardanoEra era -> Maybe (Parser (Cmd.GovernanceActionCmds era)) @@ -260,7 +273,7 @@ pShelleyToAlonzoPParams = pAlonzoOnwardsPParams :: Parser (AlonzoOnwardsPParams ledgerera) pAlonzoOnwardsPParams = - AlonzoOnwardsPParams SNothing -- TODO: Conway era cost model + AlonzoOnwardsPParams SNothing <$> convertToLedger (either (\e -> error $ "pAlonzoOnwardsPParams: " <> show e) id . toAlonzoPrices) (optional pExecutionUnitPrices) <*> convertToLedger toAlonzoExUnits (optional pMaxTxExecutionUnits) @@ -283,7 +296,7 @@ pIntroducedInConwayPParams = <*> convertToLedger id (optional pMinCommitteeSize) <*> convertToLedger id (optional (fromIntegral . unEpochNo <$> pCommitteeTermLength)) <*> convertToLedger id (optional pGovActionLifetime) - <*> convertToLedger toShelleyLovelace (optional pGovActionDeposit) + <*> convertToLedger toShelleyLovelace (optional pNewGovActionDeposit) <*> convertToLedger toShelleyLovelace (optional pDRepDeposit) <*> convertToLedger id (optional pDRepActivity) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Actions.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Actions.hs index ea6895e9c6..23f2855817 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Actions.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Actions.hs @@ -8,9 +8,11 @@ module Cardano.CLI.EraBased.Run.Governance.Actions ( runGovernanceActionCmds , GovernanceActionsError(..) + , addCostModelsToEraBasedProtocolParametersUpdate ) where import Cardano.Api +import Cardano.Api.Ledger (StrictMaybe (..)) import qualified Cardano.Api.Ledger as Ledger import Cardano.Api.Shelley @@ -21,6 +23,7 @@ import Cardano.CLI.Read import Cardano.CLI.Types.Common import Cardano.CLI.Types.Errors.GovernanceActionsError import Cardano.CLI.Types.Key +import qualified Cardano.Ledger.Alonzo.Scripts as Alonzo import Control.Monad import Control.Monad.Except (ExceptT) @@ -230,11 +233,20 @@ runGovernanceActionCreateProtocolParametersUpdateCmd eraBasedPParams' = do (\sToB -> do let oFp = uppFilePath eraBasedPParams' anyEra = AnyShelleyBasedEra $ shelleyToBabbageEraToShelleyBasedEra sToB - UpdateProtocolParametersPreConway _cOn expEpoch genesisVerKeys + UpdateProtocolParametersPreConway _stB expEpoch genesisVerKeys <- hoistMaybe (GovernanceActionsValueUpdateProtocolParametersNotFound anyEra) $ uppPreConway eraBasedPParams' - let eraBasedPParams = uppNewPParams eraBasedPParams' - updateProtocolParams = createEraBasedProtocolParamUpdate sbe 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' + + let updateProtocolParams = createEraBasedProtocolParamUpdate sbe eraBasedPParams apiUpdateProtocolParamsType = fromLedgerPParamsUpdate sbe updateProtocolParams genVKeys <- sequence [ firstExceptT GovernanceActionsCmdReadTextEnvelopeFileError . newExceptT @@ -255,10 +267,18 @@ 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' + returnKeyHash <- readStakeKeyHash returnAddr - let eraBasedPParams = uppNewPParams eraBasedPParams' - updateProtocolParams = createEraBasedProtocolParamUpdate sbe eraBasedPParams + let updateProtocolParams = createEraBasedProtocolParamUpdate sbe eraBasedPParams prevGovActId = Ledger.maybeToStrictMaybe $ uncurry createPreviousGovernanceActionId <$> mPrevGovActId proposalAnchor = Ledger.Anchor @@ -281,6 +301,27 @@ readStakeKeyHash stake = firstExceptT GovernanceActionsCmdReadFileError . newExceptT $ readVerificationKeyOrHashOrFile AsStakeKey stake +addCostModelsToEraBasedProtocolParametersUpdate + :: AlonzoEraOnwards era + -> Alonzo.CostModels + -> EraBasedProtocolParametersUpdate era + -> EraBasedProtocolParametersUpdate era +addCostModelsToEraBasedProtocolParametersUpdate + AlonzoEraOnwardsAlonzo + cmdls + (AlonzoEraBasedProtocolParametersUpdate common sTa aOn depAfterB) = + AlonzoEraBasedProtocolParametersUpdate common sTa (aOn { alCostModels = SJust cmdls }) depAfterB +addCostModelsToEraBasedProtocolParametersUpdate + AlonzoEraOnwardsBabbage + cmdls + (BabbageEraBasedProtocolParametersUpdate common aOn depAfterB inB) = + BabbageEraBasedProtocolParametersUpdate common (aOn { alCostModels = SJust cmdls }) depAfterB inB +addCostModelsToEraBasedProtocolParametersUpdate + AlonzoEraOnwardsConway + cmdls + (ConwayEraBasedProtocolParametersUpdate common aOn inB inC) = + ConwayEraBasedProtocolParametersUpdate common (aOn { alCostModels = SJust cmdls }) inB inC + runGovernanceActionTreasuryWithdrawalCmd :: () => GovernanceActionTreasuryWithdrawalCmdArgs era -> ExceptT GovernanceActionsError IO () diff --git a/cardano-cli/src/Cardano/CLI/Read.hs b/cardano-cli/src/Cardano/CLI/Read.hs index a927f0383c..910bad01cd 100644 --- a/cardano-cli/src/Cardano/CLI/Read.hs +++ b/cardano-cli/src/Cardano/CLI/Read.hs @@ -59,6 +59,8 @@ module Cardano.CLI.Read , readTxGovernanceActions , constitutionHashSourceToHash , readProposal + , CostModelsError (..) + , readCostModels -- * FileOrPipe , FileOrPipe @@ -108,6 +110,7 @@ import Cardano.CLI.Types.Errors.StakeCredentialError import Cardano.CLI.Types.Governance import Cardano.CLI.Types.Key import qualified Cardano.Crypto.Hash.Class as Crypto +import qualified Cardano.Ledger.Alonzo.Scripts as Alonzo import qualified Cardano.Ledger.BaseTypes as L import qualified Cardano.Ledger.BaseTypes as Ledger import qualified Cardano.Ledger.Conway.Governance as Ledger @@ -121,7 +124,7 @@ import qualified Cardano.Ledger.SafeHash as Ledger import Prelude import Control.Exception (bracket, displayException) -import Control.Monad (forM, unless) +import Control.Monad (forM, unless, when) import Control.Monad.IO.Class import Control.Monad.Trans (MonadTrans (..)) import Control.Monad.Trans.Except @@ -858,6 +861,30 @@ constitutionHashSourceToHash constitutionHashSource = do ConstitutionHashSourceHash h -> pure h +data CostModelsError + = CostModelsErrorReadFile (FileError ()) + | CostModelsErrorJSONDecode FilePath String + | CostModelsErrorEmpty FilePath + deriving Show + +instance Error CostModelsError where + prettyError = \case + CostModelsErrorReadFile e -> + "Cannot read cost model: " <> prettyError e + CostModelsErrorJSONDecode fp err -> + "Error decoding JSON cost model at " <> pshow fp <> ": " <> pshow err + CostModelsErrorEmpty fp -> + "The decoded cost model was empty at: " <> pshow fp + +readCostModels + :: File Alonzo.CostModels In + -> ExceptT CostModelsError IO Alonzo.CostModels +readCostModels (File fp) = do + bytes <- handleIOExceptT (CostModelsErrorReadFile . FileIOError fp) $ LBS.readFile fp + costModels <- firstExceptT (CostModelsErrorJSONDecode fp) . except $ Aeson.eitherDecode bytes + when (null $ fromAlonzoCostModels costModels) $ throwE $ CostModelsErrorEmpty fp + return costModels + -- Misc -- readFileInByronEra = undefined diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceActionsError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceActionsError.hs index 3a0feafd13..e7e9ad80ca 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceActionsError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceActionsError.hs @@ -12,6 +12,7 @@ import Cardano.CLI.Read data GovernanceActionsError = GovernanceActionsCmdConstitutionError ConstitutionError | GovernanceActionsCmdProposalError ProposalError + | GovernanceActionsCmdCostModelsError CostModelsError | GovernanceActionsCmdReadFileError (FileError InputDecodeError) | GovernanceActionsCmdReadTextEnvelopeFileError (FileError TextEnvelopeError) | GovernanceActionsCmdWriteFileError (FileError ()) @@ -20,6 +21,8 @@ data GovernanceActionsError instance Error GovernanceActionsError where prettyError = \case + GovernanceActionsCmdCostModelsError e -> + prettyError e GovernanceActionsCmdProposalError e -> "Cannot read proposal: " <> pshow e -- TODO Conway render this properly GovernanceActionsCmdConstitutionError e -> diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/ErrorsSpec.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/ErrorsSpec.hs index 9f86430822..e1f2cb43a9 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/ErrorsSpec.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/ErrorsSpec.hs @@ -7,6 +7,7 @@ module Test.Golden.ErrorsSpec , test_GovernanceComitteeError , test_RegistrationError , test_VoteReadError + , test_CostModelsError ) where import Cardano.Api @@ -176,8 +177,22 @@ test_GovernanceActionsError = , GovernanceActionsCmdConstitutionError $ ConstitutionNotUnicodeError $ DecodeError "seq" Nothing) + , ("GovernanceActionsCmdCostModelsError" + , GovernanceActionsCmdCostModelsError + $ CostModelsErrorReadFile + $ FileError "some/file.txt" ()) ] +test_CostModelsError :: TestTree +test_CostModelsError = + testErrorMessagesRendering "Cardano.CLI.Read" "CostModelsError" + [ ("CostModelsErrorReadFile" + , CostModelsErrorReadFile $ FileError "some/file.txt" ()) + , ("CostModelsErrorJSONDecode" + , CostModelsErrorJSONDecode "some/file.txt" "some error") + , ("CostModelsErrorEmpty" + , CostModelsErrorEmpty "some/file.txt") + ] goldenFilesPath :: FilePath goldenFilesPath = "test/cardano-cli-golden/files/golden/errors" diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Action.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Action.hs index 15037e359b..bec0950689 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Action.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Action.hs @@ -173,3 +173,28 @@ hprop_golden_governanceActionCreateNoConfidence = , "--out-file", actionViewFile ] H.diffFileVsGoldenFile actionViewFile goldenActionViewFile + +hprop_golden_conway_governance_action_create_protocol_parameters_update :: Property +hprop_golden_conway_governance_action_create_protocol_parameters_update = + propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do + stakeAddressVKeyFile <- H.note "test/cardano-cli-golden/files/input/governance/stake-address.vkey" + costModelsFile <- H.note "test/cardano-cli-golden/files/input/governance/costmodels.json" + + actionFile <- noteTempFile tempDir "action" + + void $ execCardanoCLI + [ "conway", "governance", "action", "create-protocol-parameters-update" + , "--anchor-url", "example.com" + , "--anchor-data-hash", "c7ddb5b493faa4d3d2d679847740bdce0c5d358d56f9b1470ca67f5652a02745" + , "--mainnet" + , "--stake-verification-key-file", stakeAddressVKeyFile + , "--governance-action-deposit", "12345" + , "--new-governance-action-deposit", "123454321" + , "--max-tx-size", "1234" + , "--cost-model-file", costModelsFile + , "--out-file", actionFile + ] + + goldenActionFile <- H.note "test/cardano-cli-golden/files/golden/governance/action/conway-create-protocol-parameters-update.action" + H.diffFileVsGoldenFile actionFile goldenActionFile + diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/errors/Cardano.CLI.EraBased.Run.Governance.Actions.GovernanceActionsError/GovernanceActionsCmdCostModelsError.txt b/cardano-cli/test/cardano-cli-golden/files/golden/errors/Cardano.CLI.EraBased.Run.Governance.Actions.GovernanceActionsError/GovernanceActionsCmdCostModelsError.txt new file mode 100644 index 0000000000..71a2000238 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/errors/Cardano.CLI.EraBased.Run.Governance.Actions.GovernanceActionsError/GovernanceActionsCmdCostModelsError.txt @@ -0,0 +1 @@ +Cannot read cost model: some/file.txt: \ No newline at end of file diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/errors/Cardano.CLI.Read.CostModelsError/CostModelsErrorEmpty.txt b/cardano-cli/test/cardano-cli-golden/files/golden/errors/Cardano.CLI.Read.CostModelsError/CostModelsErrorEmpty.txt new file mode 100644 index 0000000000..cf699f830a --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/errors/Cardano.CLI.Read.CostModelsError/CostModelsErrorEmpty.txt @@ -0,0 +1 @@ +The decoded cost model was empty at: "some/file.txt" \ No newline at end of file diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/errors/Cardano.CLI.Read.CostModelsError/CostModelsErrorJSONDecode.txt b/cardano-cli/test/cardano-cli-golden/files/golden/errors/Cardano.CLI.Read.CostModelsError/CostModelsErrorJSONDecode.txt new file mode 100644 index 0000000000..e3b97861c4 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/errors/Cardano.CLI.Read.CostModelsError/CostModelsErrorJSONDecode.txt @@ -0,0 +1 @@ +Error decoding JSON cost model at "some/file.txt": "some error" \ No newline at end of file diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/errors/Cardano.CLI.Read.CostModelsError/CostModelsErrorReadFile.txt b/cardano-cli/test/cardano-cli-golden/files/golden/errors/Cardano.CLI.Read.CostModelsError/CostModelsErrorReadFile.txt new file mode 100644 index 0000000000..71a2000238 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/errors/Cardano.CLI.Read.CostModelsError/CostModelsErrorReadFile.txt @@ -0,0 +1 @@ +Cannot read cost model: some/file.txt: \ No newline at end of file diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/governance/action/conway-create-protocol-parameters-update.action b/cardano-cli/test/cardano-cli-golden/files/golden/governance/action/conway-create-protocol-parameters-update.action new file mode 100644 index 0000000000..5b54ff4611 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/governance/action/conway-create-protocol-parameters-update.action @@ -0,0 +1,5 @@ +{ + "type": "Governance proposal", + "description": "", + "cborHex": "84193039581de18f4a3466a404c11eb410313015b88e447d81b60089e25f611600e6058300f6a3031904d212a3009f1a000302590001011a00060bc719026d00011a000249f01903e800011a000249f018201a0025cea81971f70419744d186419744d186419744d186419744d186419744d186419744d18641864186419744d18641a000249f018201a000249f018201a000249f018201a000249f01903e800011a000249f018201a000249f01903e800081a000242201a00067e2318760001011a000249f01903e800081a000249f01a0001b79818f7011a000249f0192710011a0002155e19052e011903e81a000249f01903e8011a000249f018201a000249f018201a000249f0182001011a000249f0011a000249f0041a000194af18f8011a000194af18f8011a0002377c190556011a0002bdea1901f1011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000242201a00067e23187600010119f04c192bd200011a000249f018201a000242201a00067e2318760001011a000242201a00067e2318760001011a0025cea81971f707001a000141bb041a000249f019138800011a000249f018201a000302590001011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a00330da70101ff019f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a0011b22c1a0005fdde00021a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a0223accc0a1a009063b91903fd0a1a02515e841980b30aff029f01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101ff181e1a075bc371826b6578616d706c652e636f6d5820c7ddb5b493faa4d3d2d679847740bdce0c5d358d56f9b1470ca67f5652a02745" +} 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 6eb6e12180..1dc2757cff 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli @@ -3709,6 +3709,7 @@ Usage: cardano-cli alonzo governance action create-protocol-parameters-update -- [--max-collateral-inputs INT] [--protocol-major-version NATURAL --protocol-minor-version NATURAL] + [--cost-model-file FILE] --out-file FILE Create a protocol parameters update. @@ -4839,6 +4840,7 @@ Usage: cardano-cli babbage governance action create-protocol-parameters-update - [--protocol-major-version NATURAL --protocol-minor-version NATURAL] [--utxo-cost-per-byte LOVELACE] + [--cost-model-file FILE] --out-file FILE Create a protocol parameters update. @@ -5919,8 +5921,8 @@ Usage: cardano-cli conway governance action create-constitution | --deposit-return-stake-verification-key-file FILE | --deposit-return-stake-key-hash HASH ) - [--governance-action-tx-id TXID - --governance-action-index WORD32] + [--prev-governance-action-tx-id TXID + --prev-governance-action-index WORD32] --anchor-url TEXT --anchor-data-hash HASH --constitution-url TEXT @@ -5951,8 +5953,8 @@ Usage: cardano-cli conway governance action update-committee ) --epoch NATURAL] --quorum RATIONAL - [--governance-action-tx-id TXID - --governance-action-index WORD32] + [--prev-governance-action-tx-id TXID + --prev-governance-action-index WORD32] --out-file FILE Create or update a new committee proposal. @@ -5997,8 +5999,8 @@ Usage: cardano-cli conway governance action create-protocol-parameters-update ) --anchor-url TEXT --anchor-data-hash HASH - [--governance-action-tx-id TXID - --governance-action-index WORD32] + [--prev-governance-action-tx-id TXID + --prev-governance-action-index WORD32] [--min-fee-constant LOVELACE] [--min-fee-linear LOVELACE] [--max-block-body-size NATURAL] @@ -6037,9 +6039,10 @@ Usage: cardano-cli conway governance action create-protocol-parameters-update [--min-committee-size INT] [--committee-term-length INT] [--governance-action-lifetime NATURAL] - [--governance-action-deposit NATURAL] + [--new-governance-action-deposit NATURAL] [--drep-deposit LOVELACE] [--drep-activity NATURAL] + [--cost-model-file FILE] --out-file FILE Create a protocol parameters update. @@ -7456,6 +7459,7 @@ Usage: cardano-cli latest governance action create-protocol-parameters-update -- [--protocol-major-version NATURAL --protocol-minor-version NATURAL] [--utxo-cost-per-byte LOVELACE] + [--cost-model-file FILE] --out-file FILE Create a protocol parameters update. 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 157cef1c2b..5f2a034faa 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 @@ -26,6 +26,7 @@ Usage: cardano-cli alonzo governance action create-protocol-parameters-update -- [--max-collateral-inputs INT] [--protocol-major-version NATURAL --protocol-minor-version NATURAL] + [--cost-model-file FILE] --out-file FILE Create a protocol parameters update. @@ -95,5 +96,6 @@ Available options: Minor protocol version. An increase indicates a soft fork (old software canvalidate but not produce new blocks). + --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 3959d17348..8cb6783991 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 @@ -23,6 +23,7 @@ Usage: cardano-cli babbage governance action create-protocol-parameters-update - [--protocol-major-version NATURAL --protocol-minor-version NATURAL] [--utxo-cost-per-byte LOVELACE] + [--cost-model-file FILE] --out-file FILE Create a protocol parameters update. @@ -91,5 +92,6 @@ Available options: --utxo-cost-per-byte LOVELACE Cost in lovelace per unit of UTxO storage (from Babbage era). + --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/conway_governance_action_create-constitution.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_create-constitution.cli index 19d7cee41d..6173f056db 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_create-constitution.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_create-constitution.cli @@ -7,8 +7,8 @@ Usage: cardano-cli conway governance action create-constitution | --deposit-return-stake-verification-key-file FILE | --deposit-return-stake-key-hash HASH ) - [--governance-action-tx-id TXID - --governance-action-index WORD32] + [--prev-governance-action-tx-id TXID + --prev-governance-action-index WORD32] --anchor-url TEXT --anchor-data-hash HASH --constitution-url TEXT @@ -28,10 +28,10 @@ Available options: Filepath of the staking verification key. --deposit-return-stake-key-hash HASH Stake verification key hash (hex-encoded). - --governance-action-tx-id TXID - Previous txid of the governance action. - --governance-action-index WORD32 - Previous tx's governance action index. + --prev-governance-action-tx-id TXID + Txid of the previous governance action. + --prev-governance-action-index WORD32 + Action index of the previous governance action. --anchor-url TEXT Anchor URL --anchor-data-hash HASH Proposal anchor data hash (obtain it with "cardano-cli conway governance hash ...") diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_create-protocol-parameters-update.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_create-protocol-parameters-update.cli index 6a914eb12d..fe4448ba5c 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_create-protocol-parameters-update.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_create-protocol-parameters-update.cli @@ -9,8 +9,8 @@ Usage: cardano-cli conway governance action create-protocol-parameters-update ) --anchor-url TEXT --anchor-data-hash HASH - [--governance-action-tx-id TXID - --governance-action-index WORD32] + [--prev-governance-action-tx-id TXID + --prev-governance-action-index WORD32] [--min-fee-constant LOVELACE] [--min-fee-linear LOVELACE] [--max-block-body-size NATURAL] @@ -49,9 +49,10 @@ Usage: cardano-cli conway governance action create-protocol-parameters-update [--min-committee-size INT] [--committee-term-length INT] [--governance-action-lifetime NATURAL] - [--governance-action-deposit NATURAL] + [--new-governance-action-deposit NATURAL] [--drep-deposit LOVELACE] [--drep-activity NATURAL] + [--cost-model-file FILE] --out-file FILE Create a protocol parameters update. @@ -70,10 +71,10 @@ Available options: --anchor-url TEXT Anchor URL --anchor-data-hash HASH Proposal anchor data hash (obtain it with "cardano-cli conway governance hash ...") - --governance-action-tx-id TXID - Previous txid of the governance action. - --governance-action-index WORD32 - Previous tx's governance action index. + --prev-governance-action-tx-id TXID + Txid of the previous governance action. + --prev-governance-action-index WORD32 + Action index of the previous governance action. --min-fee-constant LOVELACE The constant factor for the minimum fee calculation. --min-fee-linear LOVELACE @@ -159,9 +160,11 @@ Available options: TODO --governance-action-lifetime NATURAL TODO - --governance-action-deposit NATURAL - Deposit required to submit a governance action. + --new-governance-action-deposit NATURAL + Proposed new value of the deposit required to submit + a governance action. --drep-deposit LOVELACE TODO --drep-activity NATURAL TODO + --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/conway_governance_action_update-committee.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_update-committee.cli index 883b9a36c8..2ac2a04cc4 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_update-committee.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_update-committee.cli @@ -20,8 +20,8 @@ Usage: cardano-cli conway governance action update-committee ) --epoch NATURAL] --quorum RATIONAL - [--governance-action-tx-id TXID - --governance-action-index WORD32] + [--prev-governance-action-tx-id TXID + --prev-governance-action-index WORD32] --out-file FILE Create or update a new committee proposal. @@ -55,9 +55,9 @@ Available options: --epoch NATURAL Committee member expiry epoch --quorum RATIONAL Quorum of the committee that is necessary for a successful vote. - --governance-action-tx-id TXID - Previous txid of the governance action. - --governance-action-index WORD32 - Previous tx's governance action index. + --prev-governance-action-tx-id TXID + Txid of the previous governance action. + --prev-governance-action-index WORD32 + Action index of the previous governance action. --out-file FILE The output file. -h,--help Show this help text 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 e604642e17..1adeb6e4a6 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 @@ -23,6 +23,7 @@ Usage: cardano-cli latest governance action create-protocol-parameters-update -- [--protocol-major-version NATURAL --protocol-minor-version NATURAL] [--utxo-cost-per-byte LOVELACE] + [--cost-model-file FILE] --out-file FILE Create a protocol parameters update. @@ -91,5 +92,6 @@ Available options: --utxo-cost-per-byte LOVELACE Cost in lovelace per unit of UTxO storage (from Babbage era). + --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/input/governance/costmodels.json b/cardano-cli/test/cardano-cli-golden/files/input/governance/costmodels.json new file mode 100644 index 0000000000..2a342d5eac --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/governance/costmodels.json @@ -0,0 +1,573 @@ +{ + "PlutusV1": + { + "sha2_256-memory-arguments": 7, + "equalsString-cpu-arguments-constant": 1000, + "cekDelayCost-exBudgetMemory": 100, + "lessThanEqualsByteString-cpu-arguments-intercept": 103599, + "divideInteger-memory-arguments-minimum": 1, + "appendByteString-cpu-arguments-slope": 621, + "blake2b-cpu-arguments-slope": 29175, + "iData-cpu-arguments": 150000, + "encodeUtf8-cpu-arguments-slope": 1000, + "unBData-cpu-arguments": 150000, + "multiplyInteger-cpu-arguments-intercept": 61516, + "cekConstCost-exBudgetMemory": 100, + "nullList-cpu-arguments": 150000, + "equalsString-cpu-arguments-intercept": 150000, + "trace-cpu-arguments": 150000, + "mkNilData-memory-arguments": 32, + "lengthOfByteString-cpu-arguments": 150000, + "cekBuiltinCost-exBudgetCPU": 29773, + "bData-cpu-arguments": 150000, + "subtractInteger-cpu-arguments-slope": 0, + "unIData-cpu-arguments": 150000, + "consByteString-memory-arguments-intercept": 0, + "divideInteger-memory-arguments-slope": 1, + "divideInteger-cpu-arguments-model-arguments-slope": 118, + "listData-cpu-arguments": 150000, + "headList-cpu-arguments": 150000, + "chooseData-memory-arguments": 32, + "equalsInteger-cpu-arguments-intercept": 136542, + "sha3_256-cpu-arguments-slope": 82363, + "sliceByteString-cpu-arguments-slope": 5000, + "unMapData-cpu-arguments": 150000, + "lessThanInteger-cpu-arguments-intercept": 179690, + "mkCons-cpu-arguments": 150000, + "appendString-memory-arguments-intercept": 0, + "modInteger-cpu-arguments-model-arguments-slope": 118, + "ifThenElse-cpu-arguments": 1, + "mkNilPairData-cpu-arguments": 150000, + "lessThanEqualsInteger-cpu-arguments-intercept": 145276, + "addInteger-memory-arguments-slope": 1, + "chooseList-memory-arguments": 32, + "constrData-memory-arguments": 32, + "decodeUtf8-cpu-arguments-intercept": 150000, + "equalsData-memory-arguments": 1, + "subtractInteger-memory-arguments-slope": 1, + "appendByteString-memory-arguments-intercept": 0, + "lengthOfByteString-memory-arguments": 4, + "headList-memory-arguments": 32, + "listData-memory-arguments": 32, + "consByteString-cpu-arguments-intercept": 150000, + "unIData-memory-arguments": 32, + "remainderInteger-memory-arguments-minimum": 1, + "bData-memory-arguments": 32, + "lessThanByteString-cpu-arguments-slope": 248, + "encodeUtf8-memory-arguments-intercept": 0, + "cekStartupCost-exBudgetCPU": 100, + "multiplyInteger-memory-arguments-intercept": 0, + "unListData-memory-arguments": 32, + "remainderInteger-cpu-arguments-model-arguments-slope": 118, + "cekVarCost-exBudgetCPU": 29773, + "remainderInteger-memory-arguments-slope": 1, + "cekForceCost-exBudgetCPU": 29773, + "sha2_256-cpu-arguments-slope": 29175, + "equalsInteger-memory-arguments": 1, + "indexByteString-memory-arguments": 1, + "addInteger-memory-arguments-intercept": 1, + "chooseUnit-cpu-arguments": 150000, + "sndPair-cpu-arguments": 150000, + "cekLamCost-exBudgetCPU": 29773, + "fstPair-cpu-arguments": 150000, + "quotientInteger-memory-arguments-minimum": 1, + "decodeUtf8-cpu-arguments-slope": 1000, + "lessThanInteger-memory-arguments": 1, + "lessThanEqualsInteger-cpu-arguments-slope": 1366, + "fstPair-memory-arguments": 32, + "modInteger-memory-arguments-intercept": 0, + "unConstrData-cpu-arguments": 150000, + "lessThanEqualsInteger-memory-arguments": 1, + "chooseUnit-memory-arguments": 32, + "sndPair-memory-arguments": 32, + "addInteger-cpu-arguments-intercept": 197209, + "decodeUtf8-memory-arguments-slope": 8, + "equalsData-cpu-arguments-intercept": 150000, + "mapData-cpu-arguments": 150000, + "mkPairData-cpu-arguments": 150000, + "quotientInteger-cpu-arguments-constant": 148000, + "consByteString-memory-arguments-slope": 1, + "cekVarCost-exBudgetMemory": 100, + "indexByteString-cpu-arguments": 150000, + "unListData-cpu-arguments": 150000, + "equalsInteger-cpu-arguments-slope": 1326, + "cekStartupCost-exBudgetMemory": 100, + "subtractInteger-cpu-arguments-intercept": 197209, + "divideInteger-cpu-arguments-model-arguments-intercept": 425507, + "divideInteger-memory-arguments-intercept": 0, + "cekForceCost-exBudgetMemory": 100, + "blake2b-cpu-arguments-intercept": 2477736, + "remainderInteger-cpu-arguments-constant": 148000, + "tailList-cpu-arguments": 150000, + "encodeUtf8-cpu-arguments-intercept": 150000, + "equalsString-cpu-arguments-slope": 1000, + "lessThanByteString-memory-arguments": 1, + "multiplyInteger-cpu-arguments-slope": 11218, + "appendByteString-cpu-arguments-intercept": 396231, + "lessThanEqualsByteString-cpu-arguments-slope": 248, + "modInteger-memory-arguments-slope": 1, + "addInteger-cpu-arguments-slope": 0, + "equalsData-cpu-arguments-slope": 10000, + "decodeUtf8-memory-arguments-intercept": 0, + "chooseList-cpu-arguments": 150000, + "constrData-cpu-arguments": 150000, + "equalsByteString-memory-arguments": 1, + "cekApplyCost-exBudgetCPU": 29773, + "quotientInteger-memory-arguments-slope": 1, + "verifySignature-cpu-arguments-intercept": 3345831, + "unMapData-memory-arguments": 32, + "mkCons-memory-arguments": 32, + "sliceByteString-memory-arguments-slope": 1, + "sha3_256-memory-arguments": 4, + "ifThenElse-memory-arguments": 1, + "mkNilPairData-memory-arguments": 32, + "equalsByteString-cpu-arguments-slope": 247, + "appendString-cpu-arguments-intercept": 150000, + "quotientInteger-cpu-arguments-model-arguments-slope": 118, + "cekApplyCost-exBudgetMemory": 100, + "equalsString-memory-arguments": 1, + "multiplyInteger-memory-arguments-slope": 1, + "cekBuiltinCost-exBudgetMemory": 100, + "remainderInteger-memory-arguments-intercept": 0, + "sha2_256-cpu-arguments-intercept": 2477736, + "remainderInteger-cpu-arguments-model-arguments-intercept": 425507, + "lessThanEqualsByteString-memory-arguments": 1, + "tailList-memory-arguments": 32, + "mkNilData-cpu-arguments": 150000, + "chooseData-cpu-arguments": 150000, + "unBData-memory-arguments": 32, + "blake2b-memory-arguments": 4, + "iData-memory-arguments": 32, + "nullList-memory-arguments": 32, + "cekDelayCost-exBudgetCPU": 29773, + "subtractInteger-memory-arguments-intercept": 1, + "lessThanByteString-cpu-arguments-intercept": 103599, + "consByteString-cpu-arguments-slope": 1000, + "appendByteString-memory-arguments-slope": 1, + "trace-memory-arguments": 32, + "divideInteger-cpu-arguments-constant": 148000, + "cekConstCost-exBudgetCPU": 29773, + "encodeUtf8-memory-arguments-slope": 8, + "quotientInteger-cpu-arguments-model-arguments-intercept": 425507, + "mapData-memory-arguments": 32, + "appendString-cpu-arguments-slope": 1000, + "modInteger-cpu-arguments-constant": 148000, + "verifySignature-cpu-arguments-slope": 1, + "unConstrData-memory-arguments": 32, + "quotientInteger-memory-arguments-intercept": 0, + "equalsByteString-cpu-arguments-constant": 150000, + "sliceByteString-memory-arguments-intercept": 0, + "mkPairData-memory-arguments": 32, + "equalsByteString-cpu-arguments-intercept": 112536, + "appendString-memory-arguments-slope": 1, + "lessThanInteger-cpu-arguments-slope": 497, + "modInteger-cpu-arguments-model-arguments-intercept": 425507, + "modInteger-memory-arguments-minimum": 1, + "sha3_256-cpu-arguments-intercept": 0, + "verifySignature-memory-arguments": 1, + "cekLamCost-exBudgetMemory": 100, + "sliceByteString-cpu-arguments-intercept": 150000 + }, + "PlutusV2": { + "addInteger-cpu-arguments-intercept": 205665, + "addInteger-cpu-arguments-slope": 812, + "addInteger-memory-arguments-intercept": 1, + "addInteger-memory-arguments-slope": 1, + "appendByteString-cpu-arguments-intercept": 1000, + "appendByteString-cpu-arguments-slope": 571, + "appendByteString-memory-arguments-intercept": 0, + "appendByteString-memory-arguments-slope": 1, + "appendString-cpu-arguments-intercept": 1000, + "appendString-cpu-arguments-slope": 24177, + "appendString-memory-arguments-intercept": 4, + "appendString-memory-arguments-slope": 1, + "bData-cpu-arguments": 1000, + "bData-memory-arguments": 32, + "blake2b_256-cpu-arguments-intercept": 117366, + "blake2b_256-cpu-arguments-slope": 10475, + "blake2b_256-memory-arguments": 4, + "cekApplyCost-exBudgetCPU": 23000, + "cekApplyCost-exBudgetMemory": 100, + "cekBuiltinCost-exBudgetCPU": 23000, + "cekBuiltinCost-exBudgetMemory": 100, + "cekConstCost-exBudgetCPU": 23000, + "cekConstCost-exBudgetMemory": 100, + "cekDelayCost-exBudgetCPU": 23000, + "cekDelayCost-exBudgetMemory": 100, + "cekForceCost-exBudgetCPU": 23000, + "cekForceCost-exBudgetMemory": 100, + "cekLamCost-exBudgetCPU": 23000, + "cekLamCost-exBudgetMemory": 100, + "cekStartupCost-exBudgetCPU": 100, + "cekStartupCost-exBudgetMemory": 100, + "cekVarCost-exBudgetCPU": 23000, + "cekVarCost-exBudgetMemory": 100, + "chooseData-cpu-arguments": 19537, + "chooseData-memory-arguments": 32, + "chooseList-cpu-arguments": 175354, + "chooseList-memory-arguments": 32, + "chooseUnit-cpu-arguments": 46417, + "chooseUnit-memory-arguments": 4, + "consByteString-cpu-arguments-intercept": 221973, + "consByteString-cpu-arguments-slope": 511, + "consByteString-memory-arguments-intercept": 0, + "consByteString-memory-arguments-slope": 1, + "constrData-cpu-arguments": 89141, + "constrData-memory-arguments": 32, + "decodeUtf8-cpu-arguments-intercept": 497525, + "decodeUtf8-cpu-arguments-slope": 14068, + "decodeUtf8-memory-arguments-intercept": 4, + "decodeUtf8-memory-arguments-slope": 2, + "divideInteger-cpu-arguments-constant": 196500, + "divideInteger-cpu-arguments-model-arguments-intercept": 453240, + "divideInteger-cpu-arguments-model-arguments-slope": 220, + "divideInteger-memory-arguments-intercept": 0, + "divideInteger-memory-arguments-minimum": 1, + "divideInteger-memory-arguments-slope": 1, + "encodeUtf8-cpu-arguments-intercept": 1000, + "encodeUtf8-cpu-arguments-slope": 28662, + "encodeUtf8-memory-arguments-intercept": 4, + "encodeUtf8-memory-arguments-slope": 2, + "equalsByteString-cpu-arguments-constant": 245000, + "equalsByteString-cpu-arguments-intercept": 216773, + "equalsByteString-cpu-arguments-slope": 62, + "equalsByteString-memory-arguments": 1, + "equalsData-cpu-arguments-intercept": 1060367, + "equalsData-cpu-arguments-slope": 12586, + "equalsData-memory-arguments": 1, + "equalsInteger-cpu-arguments-intercept": 208512, + "equalsInteger-cpu-arguments-slope": 421, + "equalsInteger-memory-arguments": 1, + "equalsString-cpu-arguments-constant": 187000, + "equalsString-cpu-arguments-intercept": 1000, + "equalsString-cpu-arguments-slope": 52998, + "equalsString-memory-arguments": 1, + "fstPair-cpu-arguments": 80436, + "fstPair-memory-arguments": 32, + "headList-cpu-arguments": 43249, + "headList-memory-arguments": 32, + "iData-cpu-arguments": 1000, + "iData-memory-arguments": 32, + "ifThenElse-cpu-arguments": 80556, + "ifThenElse-memory-arguments": 1, + "indexByteString-cpu-arguments": 57667, + "indexByteString-memory-arguments": 4, + "lengthOfByteString-cpu-arguments": 1000, + "lengthOfByteString-memory-arguments": 10, + "lessThanByteString-cpu-arguments-intercept": 197145, + "lessThanByteString-cpu-arguments-slope": 156, + "lessThanByteString-memory-arguments": 1, + "lessThanEqualsByteString-cpu-arguments-intercept": 197145, + "lessThanEqualsByteString-cpu-arguments-slope": 156, + "lessThanEqualsByteString-memory-arguments": 1, + "lessThanEqualsInteger-cpu-arguments-intercept": 204924, + "lessThanEqualsInteger-cpu-arguments-slope": 473, + "lessThanEqualsInteger-memory-arguments": 1, + "lessThanInteger-cpu-arguments-intercept": 208896, + "lessThanInteger-cpu-arguments-slope": 511, + "lessThanInteger-memory-arguments": 1, + "listData-cpu-arguments": 52467, + "listData-memory-arguments": 32, + "mapData-cpu-arguments": 64832, + "mapData-memory-arguments": 32, + "mkCons-cpu-arguments": 65493, + "mkCons-memory-arguments": 32, + "mkNilData-cpu-arguments": 22558, + "mkNilData-memory-arguments": 32, + "mkNilPairData-cpu-arguments": 16563, + "mkNilPairData-memory-arguments": 32, + "mkPairData-cpu-arguments": 76511, + "mkPairData-memory-arguments": 32, + "modInteger-cpu-arguments-constant": 196500, + "modInteger-cpu-arguments-model-arguments-intercept": 453240, + "modInteger-cpu-arguments-model-arguments-slope": 220, + "modInteger-memory-arguments-intercept": 0, + "modInteger-memory-arguments-minimum": 1, + "modInteger-memory-arguments-slope": 1, + "multiplyInteger-cpu-arguments-intercept": 69522, + "multiplyInteger-cpu-arguments-slope": 11687, + "multiplyInteger-memory-arguments-intercept": 0, + "multiplyInteger-memory-arguments-slope": 1, + "nullList-cpu-arguments": 60091, + "nullList-memory-arguments": 32, + "quotientInteger-cpu-arguments-constant": 196500, + "quotientInteger-cpu-arguments-model-arguments-intercept": 453240, + "quotientInteger-cpu-arguments-model-arguments-slope": 220, + "quotientInteger-memory-arguments-intercept": 0, + "quotientInteger-memory-arguments-minimum": 1, + "quotientInteger-memory-arguments-slope": 1, + "remainderInteger-cpu-arguments-constant": 196500, + "remainderInteger-cpu-arguments-model-arguments-intercept": 453240, + "remainderInteger-cpu-arguments-model-arguments-slope": 220, + "remainderInteger-memory-arguments-intercept": 0, + "remainderInteger-memory-arguments-minimum": 1, + "remainderInteger-memory-arguments-slope": 1, + "serialiseData-cpu-arguments-intercept": 1159724, + "serialiseData-cpu-arguments-slope": 392670, + "serialiseData-memory-arguments-intercept": 0, + "serialiseData-memory-arguments-slope": 2, + "sha2_256-cpu-arguments-intercept": 806990, + "sha2_256-cpu-arguments-slope": 30482, + "sha2_256-memory-arguments": 4, + "sha3_256-cpu-arguments-intercept": 1927926, + "sha3_256-cpu-arguments-slope": 82523, + "sha3_256-memory-arguments": 4, + "sliceByteString-cpu-arguments-intercept": 265318, + "sliceByteString-cpu-arguments-slope": 0, + "sliceByteString-memory-arguments-intercept": 4, + "sliceByteString-memory-arguments-slope": 0, + "sndPair-cpu-arguments": 85931, + "sndPair-memory-arguments": 32, + "subtractInteger-cpu-arguments-intercept": 205665, + "subtractInteger-cpu-arguments-slope": 812, + "subtractInteger-memory-arguments-intercept": 1, + "subtractInteger-memory-arguments-slope": 1, + "tailList-cpu-arguments": 41182, + "tailList-memory-arguments": 32, + "trace-cpu-arguments": 212342, + "trace-memory-arguments": 32, + "unBData-cpu-arguments": 31220, + "unBData-memory-arguments": 32, + "unConstrData-cpu-arguments": 32696, + "unConstrData-memory-arguments": 32, + "unIData-cpu-arguments": 43357, + "unIData-memory-arguments": 32, + "unListData-cpu-arguments": 32247, + "unListData-memory-arguments": 32, + "unMapData-cpu-arguments": 38314, + "unMapData-memory-arguments": 32, + "verifyEcdsaSecp256k1Signature-cpu-arguments": 35892428, + "verifyEcdsaSecp256k1Signature-memory-arguments": 10, + "verifyEd25519Signature-cpu-arguments-intercept": 9462713, + "verifyEd25519Signature-cpu-arguments-slope": 1021, + "verifyEd25519Signature-memory-arguments": 10, + "verifySchnorrSecp256k1Signature-cpu-arguments-intercept": 38887044, + "verifySchnorrSecp256k1Signature-cpu-arguments-slope": 32947, + "verifySchnorrSecp256k1Signature-memory-arguments": 10 + }, + "PlutusV3" : { + "addInteger-cpu-arguments-intercept": 1, + "addInteger-cpu-arguments-slope": 1, + "addInteger-memory-arguments-intercept": 1, + "addInteger-memory-arguments-slope": 1, + "appendByteString-cpu-arguments-intercept": 1, + "appendByteString-cpu-arguments-slope": 1, + "appendByteString-memory-arguments-intercept": 1, + "appendByteString-memory-arguments-slope": 1, + "appendString-cpu-arguments-intercept": 1, + "appendString-cpu-arguments-slope": 1, + "appendString-memory-arguments-intercept": 1, + "appendString-memory-arguments-slope": 1, + "bData-cpu-arguments": 1, + "bData-memory-arguments": 1, + "blake2b_256-cpu-arguments-intercept": 1, + "blake2b_256-cpu-arguments-slope": 1, + "blake2b_256-memory-arguments": 1, + "cekApplyCost-exBudgetCPU": 1, + "cekApplyCost-exBudgetMemory": 1, + "cekBuiltinCost-exBudgetCPU": 1, + "cekBuiltinCost-exBudgetMemory": 1, + "cekConstCost-exBudgetCPU": 1, + "cekConstCost-exBudgetMemory": 1, + "cekDelayCost-exBudgetCPU": 1, + "cekDelayCost-exBudgetMemory": 1, + "cekForceCost-exBudgetCPU": 1, + "cekForceCost-exBudgetMemory": 1, + "cekLamCost-exBudgetCPU": 1, + "cekLamCost-exBudgetMemory": 1, + "cekStartupCost-exBudgetCPU": 1, + "cekStartupCost-exBudgetMemory": 1, + "cekVarCost-exBudgetCPU": 1, + "cekVarCost-exBudgetMemory": 1, + "chooseData-cpu-arguments": 1, + "chooseData-memory-arguments": 1, + "chooseList-cpu-arguments": 1, + "chooseList-memory-arguments": 1, + "chooseUnit-cpu-arguments": 1, + "chooseUnit-memory-arguments": 1, + "consByteString-cpu-arguments-intercept": 1, + "consByteString-cpu-arguments-slope": 1, + "consByteString-memory-arguments-intercept": 1, + "consByteString-memory-arguments-slope": 1, + "constrData-cpu-arguments": 1, + "constrData-memory-arguments": 1, + "decodeUtf8-cpu-arguments-intercept": 1, + "decodeUtf8-cpu-arguments-slope": 1, + "decodeUtf8-memory-arguments-intercept": 1, + "decodeUtf8-memory-arguments-slope": 1, + "divideInteger-cpu-arguments-constant": 1, + "divideInteger-cpu-arguments-model-arguments-intercept": 1, + "divideInteger-cpu-arguments-model-arguments-slope": 1, + "divideInteger-memory-arguments-intercept": 1, + "divideInteger-memory-arguments-minimum": 1, + "divideInteger-memory-arguments-slope": 1, + "encodeUtf8-cpu-arguments-intercept": 1, + "encodeUtf8-cpu-arguments-slope": 1, + "encodeUtf8-memory-arguments-intercept": 1, + "encodeUtf8-memory-arguments-slope": 1, + "equalsByteString-cpu-arguments-constant": 1, + "equalsByteString-cpu-arguments-intercept": 1, + "equalsByteString-cpu-arguments-slope": 1, + "equalsByteString-memory-arguments": 1, + "equalsData-cpu-arguments-intercept": 1, + "equalsData-cpu-arguments-slope": 1, + "equalsData-memory-arguments": 1, + "equalsInteger-cpu-arguments-intercept": 1, + "equalsInteger-cpu-arguments-slope": 1, + "equalsInteger-memory-arguments": 1, + "equalsString-cpu-arguments-constant": 1, + "equalsString-cpu-arguments-intercept": 1, + "equalsString-cpu-arguments-slope": 1, + "equalsString-memory-arguments": 1, + "fstPair-cpu-arguments": 1, + "fstPair-memory-arguments": 1, + "headList-cpu-arguments": 1, + "headList-memory-arguments": 1, + "iData-cpu-arguments": 1, + "iData-memory-arguments": 1, + "ifThenElse-cpu-arguments": 1, + "ifThenElse-memory-arguments": 1, + "indexByteString-cpu-arguments": 1, + "indexByteString-memory-arguments": 1, + "lengthOfByteString-cpu-arguments": 1, + "lengthOfByteString-memory-arguments": 1, + "lessThanByteString-cpu-arguments-intercept": 1, + "lessThanByteString-cpu-arguments-slope": 1, + "lessThanByteString-memory-arguments": 1, + "lessThanEqualsByteString-cpu-arguments-intercept": 1, + "lessThanEqualsByteString-cpu-arguments-slope": 1, + "lessThanEqualsByteString-memory-arguments": 1, + "lessThanEqualsInteger-cpu-arguments-intercept": 1, + "lessThanEqualsInteger-cpu-arguments-slope": 1, + "lessThanEqualsInteger-memory-arguments": 1, + "lessThanInteger-cpu-arguments-intercept": 1, + "lessThanInteger-cpu-arguments-slope": 1, + "lessThanInteger-memory-arguments": 1, + "listData-cpu-arguments": 1, + "listData-memory-arguments": 1, + "mapData-cpu-arguments": 1, + "mapData-memory-arguments": 1, + "mkCons-cpu-arguments": 1, + "mkCons-memory-arguments": 1, + "mkNilData-cpu-arguments": 1, + "mkNilData-memory-arguments": 1, + "mkNilPairData-cpu-arguments": 1, + "mkNilPairData-memory-arguments": 1, + "mkPairData-cpu-arguments": 1, + "mkPairData-memory-arguments": 1, + "modInteger-cpu-arguments-constant": 1, + "modInteger-cpu-arguments-model-arguments-intercept": 1, + "modInteger-cpu-arguments-model-arguments-slope": 1, + "modInteger-memory-arguments-intercept": 1, + "modInteger-memory-arguments-minimum": 1, + "modInteger-memory-arguments-slope": 1, + "multiplyInteger-cpu-arguments-intercept": 1, + "multiplyInteger-cpu-arguments-slope": 1, + "multiplyInteger-memory-arguments-intercept": 1, + "multiplyInteger-memory-arguments-slope": 1, + "nullList-cpu-arguments": 1, + "nullList-memory-arguments": 1, + "quotientInteger-cpu-arguments-constant": 1, + "quotientInteger-cpu-arguments-model-arguments-intercept": 1, + "quotientInteger-cpu-arguments-model-arguments-slope": 1, + "quotientInteger-memory-arguments-intercept": 1, + "quotientInteger-memory-arguments-minimum": 1, + "quotientInteger-memory-arguments-slope": 1, + "remainderInteger-cpu-arguments-constant": 1, + "remainderInteger-cpu-arguments-model-arguments-intercept": 1, + "remainderInteger-cpu-arguments-model-arguments-slope": 1, + "remainderInteger-memory-arguments-intercept": 1, + "remainderInteger-memory-arguments-minimum": 1, + "remainderInteger-memory-arguments-slope": 1, + "serialiseData-cpu-arguments-intercept": 1, + "serialiseData-cpu-arguments-slope": 1, + "serialiseData-memory-arguments-intercept": 1, + "serialiseData-memory-arguments-slope": 1, + "sha2_256-cpu-arguments-intercept": 1, + "sha2_256-cpu-arguments-slope": 1, + "sha2_256-memory-arguments": 1, + "sha3_256-cpu-arguments-intercept": 1, + "sha3_256-cpu-arguments-slope": 1, + "sha3_256-memory-arguments": 1, + "sliceByteString-cpu-arguments-intercept": 1, + "sliceByteString-cpu-arguments-slope": 1, + "sliceByteString-memory-arguments-intercept": 1, + "sliceByteString-memory-arguments-slope": 1, + "sndPair-cpu-arguments": 1, + "sndPair-memory-arguments": 1, + "subtractInteger-cpu-arguments-intercept": 1, + "subtractInteger-cpu-arguments-slope": 1, + "subtractInteger-memory-arguments-intercept": 1, + "subtractInteger-memory-arguments-slope": 1, + "tailList-cpu-arguments": 1, + "tailList-memory-arguments": 1, + "trace-cpu-arguments": 1, + "trace-memory-arguments": 1, + "unBData-cpu-arguments": 1, + "unBData-memory-arguments": 1, + "unConstrData-cpu-arguments": 1, + "unConstrData-memory-arguments": 1, + "unIData-cpu-arguments": 1, + "unIData-memory-arguments": 1, + "unListData-cpu-arguments": 1, + "unListData-memory-arguments": 1, + "unMapData-cpu-arguments": 1, + "unMapData-memory-arguments": 1, + "verifyEcdsaSecp256k1Signature-cpu-arguments": 1, + "verifyEcdsaSecp256k1Signature-memory-arguments": 1, + "verifyEd25519Signature-cpu-arguments-intercept": 1, + "verifyEd25519Signature-cpu-arguments-slope": 1, + "verifyEd25519Signature-memory-arguments": 1, + "verifySchnorrSecp256k1Signature-cpu-arguments-intercept": 1, + "verifySchnorrSecp256k1Signature-cpu-arguments-slope": 1, + "verifySchnorrSecp256k1Signature-memory-arguments": 1, + "cekConstrCost-exBudgetCPU": 1, + "cekConstrCost-exBudgetMemory": 1, + "cekCaseCost-exBudgetCPU": 1, + "cekCaseCost-exBudgetMemory": 1, + "bls12_381_G1_add-cpu-arguments": 1, + "bls12_381_G1_add-memory-arguments": 1, + "bls12_381_G1_compress-cpu-arguments": 1, + "bls12_381_G1_compress-memory-arguments": 1, + "bls12_381_G1_equal-cpu-arguments": 1, + "bls12_381_G1_equal-memory-arguments": 1, + "bls12_381_G1_hashToGroup-cpu-arguments-intercept": 1, + "bls12_381_G1_hashToGroup-cpu-arguments-slope": 1, + "bls12_381_G1_hashToGroup-memory-arguments": 1, + "bls12_381_G1_neg-cpu-arguments": 1, + "bls12_381_G1_neg-memory-arguments": 1, + "bls12_381_G1_scalarMul-cpu-arguments-intercept": 1, + "bls12_381_G1_scalarMul-cpu-arguments-slope": 1, + "bls12_381_G1_scalarMul-memory-arguments": 1, + "bls12_381_G1_uncompress-cpu-arguments": 1, + "bls12_381_G1_uncompress-memory-arguments": 1, + "bls12_381_G2_add-cpu-arguments": 1, + "bls12_381_G2_add-memory-arguments": 1, + "bls12_381_G2_compress-cpu-arguments": 1, + "bls12_381_G2_compress-memory-arguments": 1, + "bls12_381_G2_equal-cpu-arguments": 1, + "bls12_381_G2_equal-memory-arguments": 1, + "bls12_381_G2_hashToGroup-cpu-arguments-intercept": 1, + "bls12_381_G2_hashToGroup-cpu-arguments-slope": 1, + "bls12_381_G2_hashToGroup-memory-arguments": 1, + "bls12_381_G2_neg-cpu-arguments": 1, + "bls12_381_G2_neg-memory-arguments": 1, + "bls12_381_G2_scalarMul-cpu-arguments-intercept": 1, + "bls12_381_G2_scalarMul-cpu-arguments-slope": 1, + "bls12_381_G2_scalarMul-memory-arguments": 1, + "bls12_381_G2_uncompress-cpu-arguments": 1, + "bls12_381_G2_uncompress-memory-arguments": 1, + "bls12_381_finalVerify-cpu-arguments": 1, + "bls12_381_finalVerify-memory-arguments": 1, + "bls12_381_millerLoop-cpu-arguments": 1, + "bls12_381_millerLoop-memory-arguments": 1, + "bls12_381_mulMlResult-cpu-arguments": 1, + "bls12_381_mulMlResult-memory-arguments": 1, + "keccak_256-cpu-arguments-intercept": 1, + "keccak_256-cpu-arguments-slope": 1, + "keccak_256-memory-arguments": 1, + "blake2b_224-cpu-arguments-intercept": 1, + "blake2b_224-cpu-arguments-slope": 1, + "blake2b_224-memory-arguments": 1 + } +} From 02628c15183906d1e43d62c52dd1a74648065dd2 Mon Sep 17 00:00:00 2001 From: Carl Hammann Date: Tue, 14 Nov 2023 12:13:55 +0100 Subject: [PATCH 2/5] Sketch round trip test for addCostModelsToEraBasedProtocolParametersUpdate Use whole cost models in the roundtrip test --- cardano-cli/cardano-cli.cabal | 7 ++- .../Test/Cli/AddCostModels.hs | 57 +++++++++++++++++++ 2 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 cardano-cli/test/cardano-cli-test/Test/Cli/AddCostModels.hs diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index e0640f2703..5f2f020a8f 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -298,10 +298,10 @@ test-suite cardano-cli-test , base16-bytestring , bech32 >= 1.1.0 , bytestring - , cardano-api:{cardano-api, internal} - , cardano-api-gen ^>= 8.2.0.0 + , cardano-api:{cardano-api, gen, internal} , cardano-cli , cardano-cli:cardano-cli-test-lib + , cardano-ledger-alonzo , cardano-slotting , containers , filepath @@ -315,7 +315,8 @@ test-suite cardano-cli-test build-tool-depends: tasty-discover:tasty-discover - other-modules: Test.Cli.CliIntermediateFormat + other-modules: Test.Cli.AddCostModels + Test.Cli.CliIntermediateFormat Test.Cli.FilePermissions Test.Cli.Governance.Hash Test.Cli.ITN diff --git a/cardano-cli/test/cardano-cli-test/Test/Cli/AddCostModels.hs b/cardano-cli/test/cardano-cli-test/Test/Cli/AddCostModels.hs new file mode 100644 index 0000000000..8dc4868d25 --- /dev/null +++ b/cardano-cli/test/cardano-cli-test/Test/Cli/AddCostModels.hs @@ -0,0 +1,57 @@ +{-# LANGUAGE GADTs #-} + +module Test.Cli.AddCostModels where + +import Cardano.Api +import Cardano.Api.Ledger (StrictMaybe (..)) +import Cardano.Api.ProtocolParameters + +import Cardano.CLI.EraBased.Run.Governance.Actions +import qualified Cardano.Ledger.Alonzo.Scripts as Alonzo + +import Test.Gen.Cardano.Api.ProtocolParameters +import Test.Gen.Cardano.Api.Typed + +import Hedgehog + +hprop_roundtrip_Alonzo_addCostModelsToEraBasedProtocolParametersUpdate :: Property +hprop_roundtrip_Alonzo_addCostModelsToEraBasedProtocolParametersUpdate = + property $ do + ppu <- forAll genAlonzoEraBasedProtocolParametersUpdate + cmdl <- forAll genCostModels + tripping + cmdl + (flip (addCostModelsToEraBasedProtocolParametersUpdate AlonzoEraOnwardsAlonzo) ppu) + getCostModels + where + getCostModels :: EraBasedProtocolParametersUpdate era -> Maybe Alonzo.CostModels + getCostModels (AlonzoEraBasedProtocolParametersUpdate _ _ AlonzoOnwardsPParams {alCostModels = SJust cmdls} _) = Just cmdls + getCostModels _ = Nothing + +hprop_roundtrip_Babbage_addCostModelsToEraBasedProtocolParametersUpdate :: Property +hprop_roundtrip_Babbage_addCostModelsToEraBasedProtocolParametersUpdate = + property $ do + ppu <- forAll genBabbageEraBasedProtocolParametersUpdate + cmdl <- forAll genCostModels + tripping + cmdl + (flip (addCostModelsToEraBasedProtocolParametersUpdate AlonzoEraOnwardsBabbage) ppu) + getCostModels + where + getCostModels :: EraBasedProtocolParametersUpdate era -> Maybe Alonzo.CostModels + getCostModels (BabbageEraBasedProtocolParametersUpdate _ AlonzoOnwardsPParams {alCostModels = SJust cmdls} _ _) = Just cmdls + getCostModels _ = Nothing + +hprop_roundtrip_Conway_addCostModelsToEraBasedProtocolParametersUpdate :: Property +hprop_roundtrip_Conway_addCostModelsToEraBasedProtocolParametersUpdate = + property $ do + ppu <- forAll genConwayEraBasedProtocolParametersUpdate + cmdl <- forAll genCostModels + tripping + cmdl + (flip (addCostModelsToEraBasedProtocolParametersUpdate AlonzoEraOnwardsConway) ppu) + getCostModels + where + getCostModels :: EraBasedProtocolParametersUpdate era -> Maybe Alonzo.CostModels + getCostModels (ConwayEraBasedProtocolParametersUpdate _ AlonzoOnwardsPParams {alCostModels = SJust cmdls} _ _) = Just cmdls + getCostModels _ = Nothing From 4c000913f8eb8d9cb1bcc8c73d0d69b19b8e477c Mon Sep 17 00:00:00 2001 From: Carl Hammann Date: Tue, 21 Nov 2023 15:09:41 +0100 Subject: [PATCH 3/5] Add a test for a partial cost models file --- .../Test/Golden/Governance/Action.hs | 24 ++- ...arameters-update-partial-costmodels.action | 5 + .../input/governance/costmodels-partial.json | 179 ++++++++++++++++++ 3 files changed, 207 insertions(+), 1 deletion(-) create mode 100644 cardano-cli/test/cardano-cli-golden/files/golden/governance/action/conway-create-protocol-parameters-update-partial-costmodels.action create mode 100644 cardano-cli/test/cardano-cli-golden/files/input/governance/costmodels-partial.json diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Action.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Action.hs index bec0950689..cc33d33550 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Action.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Action.hs @@ -187,7 +187,7 @@ hprop_golden_conway_governance_action_create_protocol_parameters_update = , "--anchor-url", "example.com" , "--anchor-data-hash", "c7ddb5b493faa4d3d2d679847740bdce0c5d358d56f9b1470ca67f5652a02745" , "--mainnet" - , "--stake-verification-key-file", stakeAddressVKeyFile + , "--deposit-return-stake-verification-key-file", stakeAddressVKeyFile , "--governance-action-deposit", "12345" , "--new-governance-action-deposit", "123454321" , "--max-tx-size", "1234" @@ -198,3 +198,25 @@ hprop_golden_conway_governance_action_create_protocol_parameters_update = goldenActionFile <- H.note "test/cardano-cli-golden/files/golden/governance/action/conway-create-protocol-parameters-update.action" H.diffFileVsGoldenFile actionFile goldenActionFile +hprop_golden_conway_governance_action_create_protocol_parameters_update_partial_costmodel :: Property +hprop_golden_conway_governance_action_create_protocol_parameters_update_partial_costmodel = + propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do + stakeAddressVKeyFile <- H.note "test/cardano-cli-golden/files/input/governance/stake-address.vkey" + costModelsFile <- H.note "test/cardano-cli-golden/files/input/governance/costmodels-partial.json" + + actionFile <- noteTempFile tempDir "action" + + void $ execCardanoCLI + [ "conway", "governance", "action", "create-protocol-parameters-update" + , "--anchor-url", "example.com" + , "--anchor-data-hash", "c7ddb5b493faa4d3d2d679847740bdce0c5d358d56f9b1470ca67f5652a02745" + , "--mainnet" + , "--deposit-return-stake-verification-key-file", stakeAddressVKeyFile + , "--governance-action-deposit", "12345" + , "--cost-model-file", costModelsFile + , "--out-file", actionFile + ] + + goldenActionFile <- H.note "test/cardano-cli-golden/files/golden/governance/action/conway-create-protocol-parameters-update-partial-costmodels.action" + H.diffFileVsGoldenFile actionFile goldenActionFile + diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/governance/action/conway-create-protocol-parameters-update-partial-costmodels.action b/cardano-cli/test/cardano-cli-golden/files/golden/governance/action/conway-create-protocol-parameters-update-partial-costmodels.action new file mode 100644 index 0000000000..6760d63cf7 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/governance/action/conway-create-protocol-parameters-update-partial-costmodels.action @@ -0,0 +1,5 @@ +{ + "type": "Governance proposal", + "description": "", + "cborHex": "84193039581de18f4a3466a404c11eb410313015b88e447d81b60089e25f611600e6058300f6a112a1019f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a0011b22c1a0005fdde00021a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a0223accc0a1a009063b91903fd0a1a02515e841980b30aff826b6578616d706c652e636f6d5820c7ddb5b493faa4d3d2d679847740bdce0c5d358d56f9b1470ca67f5652a02745" +} diff --git a/cardano-cli/test/cardano-cli-golden/files/input/governance/costmodels-partial.json b/cardano-cli/test/cardano-cli-golden/files/input/governance/costmodels-partial.json new file mode 100644 index 0000000000..240c942ec7 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/input/governance/costmodels-partial.json @@ -0,0 +1,179 @@ +{ + "PlutusV2": { + "addInteger-cpu-arguments-intercept": 205665, + "addInteger-cpu-arguments-slope": 812, + "addInteger-memory-arguments-intercept": 1, + "addInteger-memory-arguments-slope": 1, + "appendByteString-cpu-arguments-intercept": 1000, + "appendByteString-cpu-arguments-slope": 571, + "appendByteString-memory-arguments-intercept": 0, + "appendByteString-memory-arguments-slope": 1, + "appendString-cpu-arguments-intercept": 1000, + "appendString-cpu-arguments-slope": 24177, + "appendString-memory-arguments-intercept": 4, + "appendString-memory-arguments-slope": 1, + "bData-cpu-arguments": 1000, + "bData-memory-arguments": 32, + "blake2b_256-cpu-arguments-intercept": 117366, + "blake2b_256-cpu-arguments-slope": 10475, + "blake2b_256-memory-arguments": 4, + "cekApplyCost-exBudgetCPU": 23000, + "cekApplyCost-exBudgetMemory": 100, + "cekBuiltinCost-exBudgetCPU": 23000, + "cekBuiltinCost-exBudgetMemory": 100, + "cekConstCost-exBudgetCPU": 23000, + "cekConstCost-exBudgetMemory": 100, + "cekDelayCost-exBudgetCPU": 23000, + "cekDelayCost-exBudgetMemory": 100, + "cekForceCost-exBudgetCPU": 23000, + "cekForceCost-exBudgetMemory": 100, + "cekLamCost-exBudgetCPU": 23000, + "cekLamCost-exBudgetMemory": 100, + "cekStartupCost-exBudgetCPU": 100, + "cekStartupCost-exBudgetMemory": 100, + "cekVarCost-exBudgetCPU": 23000, + "cekVarCost-exBudgetMemory": 100, + "chooseData-cpu-arguments": 19537, + "chooseData-memory-arguments": 32, + "chooseList-cpu-arguments": 175354, + "chooseList-memory-arguments": 32, + "chooseUnit-cpu-arguments": 46417, + "chooseUnit-memory-arguments": 4, + "consByteString-cpu-arguments-intercept": 221973, + "consByteString-cpu-arguments-slope": 511, + "consByteString-memory-arguments-intercept": 0, + "consByteString-memory-arguments-slope": 1, + "constrData-cpu-arguments": 89141, + "constrData-memory-arguments": 32, + "decodeUtf8-cpu-arguments-intercept": 497525, + "decodeUtf8-cpu-arguments-slope": 14068, + "decodeUtf8-memory-arguments-intercept": 4, + "decodeUtf8-memory-arguments-slope": 2, + "divideInteger-cpu-arguments-constant": 196500, + "divideInteger-cpu-arguments-model-arguments-intercept": 453240, + "divideInteger-cpu-arguments-model-arguments-slope": 220, + "divideInteger-memory-arguments-intercept": 0, + "divideInteger-memory-arguments-minimum": 1, + "divideInteger-memory-arguments-slope": 1, + "encodeUtf8-cpu-arguments-intercept": 1000, + "encodeUtf8-cpu-arguments-slope": 28662, + "encodeUtf8-memory-arguments-intercept": 4, + "encodeUtf8-memory-arguments-slope": 2, + "equalsByteString-cpu-arguments-constant": 245000, + "equalsByteString-cpu-arguments-intercept": 216773, + "equalsByteString-cpu-arguments-slope": 62, + "equalsByteString-memory-arguments": 1, + "equalsData-cpu-arguments-intercept": 1060367, + "equalsData-cpu-arguments-slope": 12586, + "equalsData-memory-arguments": 1, + "equalsInteger-cpu-arguments-intercept": 208512, + "equalsInteger-cpu-arguments-slope": 421, + "equalsInteger-memory-arguments": 1, + "equalsString-cpu-arguments-constant": 187000, + "equalsString-cpu-arguments-intercept": 1000, + "equalsString-cpu-arguments-slope": 52998, + "equalsString-memory-arguments": 1, + "fstPair-cpu-arguments": 80436, + "fstPair-memory-arguments": 32, + "headList-cpu-arguments": 43249, + "headList-memory-arguments": 32, + "iData-cpu-arguments": 1000, + "iData-memory-arguments": 32, + "ifThenElse-cpu-arguments": 80556, + "ifThenElse-memory-arguments": 1, + "indexByteString-cpu-arguments": 57667, + "indexByteString-memory-arguments": 4, + "lengthOfByteString-cpu-arguments": 1000, + "lengthOfByteString-memory-arguments": 10, + "lessThanByteString-cpu-arguments-intercept": 197145, + "lessThanByteString-cpu-arguments-slope": 156, + "lessThanByteString-memory-arguments": 1, + "lessThanEqualsByteString-cpu-arguments-intercept": 197145, + "lessThanEqualsByteString-cpu-arguments-slope": 156, + "lessThanEqualsByteString-memory-arguments": 1, + "lessThanEqualsInteger-cpu-arguments-intercept": 204924, + "lessThanEqualsInteger-cpu-arguments-slope": 473, + "lessThanEqualsInteger-memory-arguments": 1, + "lessThanInteger-cpu-arguments-intercept": 208896, + "lessThanInteger-cpu-arguments-slope": 511, + "lessThanInteger-memory-arguments": 1, + "listData-cpu-arguments": 52467, + "listData-memory-arguments": 32, + "mapData-cpu-arguments": 64832, + "mapData-memory-arguments": 32, + "mkCons-cpu-arguments": 65493, + "mkCons-memory-arguments": 32, + "mkNilData-cpu-arguments": 22558, + "mkNilData-memory-arguments": 32, + "mkNilPairData-cpu-arguments": 16563, + "mkNilPairData-memory-arguments": 32, + "mkPairData-cpu-arguments": 76511, + "mkPairData-memory-arguments": 32, + "modInteger-cpu-arguments-constant": 196500, + "modInteger-cpu-arguments-model-arguments-intercept": 453240, + "modInteger-cpu-arguments-model-arguments-slope": 220, + "modInteger-memory-arguments-intercept": 0, + "modInteger-memory-arguments-minimum": 1, + "modInteger-memory-arguments-slope": 1, + "multiplyInteger-cpu-arguments-intercept": 69522, + "multiplyInteger-cpu-arguments-slope": 11687, + "multiplyInteger-memory-arguments-intercept": 0, + "multiplyInteger-memory-arguments-slope": 1, + "nullList-cpu-arguments": 60091, + "nullList-memory-arguments": 32, + "quotientInteger-cpu-arguments-constant": 196500, + "quotientInteger-cpu-arguments-model-arguments-intercept": 453240, + "quotientInteger-cpu-arguments-model-arguments-slope": 220, + "quotientInteger-memory-arguments-intercept": 0, + "quotientInteger-memory-arguments-minimum": 1, + "quotientInteger-memory-arguments-slope": 1, + "remainderInteger-cpu-arguments-constant": 196500, + "remainderInteger-cpu-arguments-model-arguments-intercept": 453240, + "remainderInteger-cpu-arguments-model-arguments-slope": 220, + "remainderInteger-memory-arguments-intercept": 0, + "remainderInteger-memory-arguments-minimum": 1, + "remainderInteger-memory-arguments-slope": 1, + "serialiseData-cpu-arguments-intercept": 1159724, + "serialiseData-cpu-arguments-slope": 392670, + "serialiseData-memory-arguments-intercept": 0, + "serialiseData-memory-arguments-slope": 2, + "sha2_256-cpu-arguments-intercept": 806990, + "sha2_256-cpu-arguments-slope": 30482, + "sha2_256-memory-arguments": 4, + "sha3_256-cpu-arguments-intercept": 1927926, + "sha3_256-cpu-arguments-slope": 82523, + "sha3_256-memory-arguments": 4, + "sliceByteString-cpu-arguments-intercept": 265318, + "sliceByteString-cpu-arguments-slope": 0, + "sliceByteString-memory-arguments-intercept": 4, + "sliceByteString-memory-arguments-slope": 0, + "sndPair-cpu-arguments": 85931, + "sndPair-memory-arguments": 32, + "subtractInteger-cpu-arguments-intercept": 205665, + "subtractInteger-cpu-arguments-slope": 812, + "subtractInteger-memory-arguments-intercept": 1, + "subtractInteger-memory-arguments-slope": 1, + "tailList-cpu-arguments": 41182, + "tailList-memory-arguments": 32, + "trace-cpu-arguments": 212342, + "trace-memory-arguments": 32, + "unBData-cpu-arguments": 31220, + "unBData-memory-arguments": 32, + "unConstrData-cpu-arguments": 32696, + "unConstrData-memory-arguments": 32, + "unIData-cpu-arguments": 43357, + "unIData-memory-arguments": 32, + "unListData-cpu-arguments": 32247, + "unListData-memory-arguments": 32, + "unMapData-cpu-arguments": 38314, + "unMapData-memory-arguments": 32, + "verifyEcdsaSecp256k1Signature-cpu-arguments": 35892428, + "verifyEcdsaSecp256k1Signature-memory-arguments": 10, + "verifyEd25519Signature-cpu-arguments-intercept": 9462713, + "verifyEd25519Signature-cpu-arguments-slope": 1021, + "verifyEd25519Signature-memory-arguments": 10, + "verifySchnorrSecp256k1Signature-cpu-arguments-intercept": 38887044, + "verifySchnorrSecp256k1Signature-cpu-arguments-slope": 32947, + "verifySchnorrSecp256k1Signature-memory-arguments": 10 + } +} From 250443aad49c1d0ede7815556a451843bf82f249 Mon Sep 17 00:00:00 2001 From: Carl Hammann Date: Thu, 23 Nov 2023 15:29:57 +0100 Subject: [PATCH 4/5] Address some review comments from Jordan --- .../EraBased/Options/Governance/Actions.hs | 2 +- .../CLI/EraBased/Run/Governance/Actions.hs | 30 +++++++++---------- 2 files changed, 15 insertions(+), 17 deletions(-) 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 c96c719cdf..c1e57fe831 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Actions.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Actions.hs @@ -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) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Actions.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Actions.hs index 23f2855817..ad51e4d1f8 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Actions.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Actions.hs @@ -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 ) @@ -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 @@ -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 = From 04984863fa4adc9fe76f21a396791cc97b726c69 Mon Sep 17 00:00:00 2001 From: Carl Hammann Date: Thu, 23 Nov 2023 16:39:35 +0100 Subject: [PATCH 5/5] Document and test the cost model file format --- cardano-cli/src/Cardano/CLI/Read.hs | 22 +- .../CostModelsErrorEmpty.txt | 14 +- .../CostModelsErrorJSONDecode.txt | 14 +- .../input/governance/costmodels-partial.json | 355 +++++++++--------- 4 files changed, 223 insertions(+), 182 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/Read.hs b/cardano-cli/src/Cardano/CLI/Read.hs index 910bad01cd..aebcdf61fd 100644 --- a/cardano-cli/src/Cardano/CLI/Read.hs +++ b/cardano-cli/src/Cardano/CLI/Read.hs @@ -149,6 +149,7 @@ import Data.Word import GHC.IO.Handle (hClose, hIsSeekable) import GHC.IO.Handle.FD (openFileBlocking) import qualified Options.Applicative as Opt +import Prettyprinter (vsep) import System.IO (IOMode (ReadMode)) -- Metadata @@ -872,9 +873,26 @@ instance Error CostModelsError where CostModelsErrorReadFile e -> "Cannot read cost model: " <> prettyError e CostModelsErrorJSONDecode fp err -> - "Error decoding JSON cost model at " <> pshow fp <> ": " <> pshow err + "Error decoding JSON cost model at " <> pshow fp <> ": " <> pshow err <> formatExplanation CostModelsErrorEmpty fp -> - "The decoded cost model was empty at: " <> pshow fp + "The decoded cost model was empty at: " <> pshow fp <> formatExplanation + where + formatExplanation = + vsep [ "" + , "The expected format of the cost models file is " + , "{" + , " \"PlutusV1\" : ," + , " \"PlutusV2\" : ," + , " \"PlutusV3\" : ," + , "}" + , "where each of the three entries may be ommited, and a is either an ordered list of parameter values like" + , "[205665, 812, 1, ...]" + , "or a map like" + , "{ \"addInteger-cpu-arguments-intercept\": 205665, \"addInteger-cpu-arguments-slope\": 812, \"addInteger-memory-arguments-intercept\": 1, ... }" + , "In both cases, the cost model must be complete, i.e. it must specify all parameters that are needed for the specific Plutus version." + , "It's not specified what will happen if you provide more parameters than necessary." + ] + readCostModels :: File Alonzo.CostModels In diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/errors/Cardano.CLI.Read.CostModelsError/CostModelsErrorEmpty.txt b/cardano-cli/test/cardano-cli-golden/files/golden/errors/Cardano.CLI.Read.CostModelsError/CostModelsErrorEmpty.txt index cf699f830a..7d9fe74cc4 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/errors/Cardano.CLI.Read.CostModelsError/CostModelsErrorEmpty.txt +++ b/cardano-cli/test/cardano-cli-golden/files/golden/errors/Cardano.CLI.Read.CostModelsError/CostModelsErrorEmpty.txt @@ -1 +1,13 @@ -The decoded cost model was empty at: "some/file.txt" \ No newline at end of file +The decoded cost model was empty at: "some/file.txt" +The expected format of the cost models file is +{ + "PlutusV1" : , + "PlutusV2" : , + "PlutusV3" : , +} +where each of the three entries may be ommited, and a is either an ordered list of parameter values like +[205665, 812, 1, ...] +or a map like +{ "addInteger-cpu-arguments-intercept": 205665, "addInteger-cpu-arguments-slope": 812, "addInteger-memory-arguments-intercept": 1, ... } +In both cases, the cost model must be complete, i.e. it must specify all parameters that are needed for the specific Plutus version. +It's not specified what will happen if you provide more parameters than necessary. \ No newline at end of file diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/errors/Cardano.CLI.Read.CostModelsError/CostModelsErrorJSONDecode.txt b/cardano-cli/test/cardano-cli-golden/files/golden/errors/Cardano.CLI.Read.CostModelsError/CostModelsErrorJSONDecode.txt index e3b97861c4..15859578bb 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/errors/Cardano.CLI.Read.CostModelsError/CostModelsErrorJSONDecode.txt +++ b/cardano-cli/test/cardano-cli-golden/files/golden/errors/Cardano.CLI.Read.CostModelsError/CostModelsErrorJSONDecode.txt @@ -1 +1,13 @@ -Error decoding JSON cost model at "some/file.txt": "some error" \ No newline at end of file +Error decoding JSON cost model at "some/file.txt": "some error" +The expected format of the cost models file is +{ + "PlutusV1" : , + "PlutusV2" : , + "PlutusV3" : , +} +where each of the three entries may be ommited, and a is either an ordered list of parameter values like +[205665, 812, 1, ...] +or a map like +{ "addInteger-cpu-arguments-intercept": 205665, "addInteger-cpu-arguments-slope": 812, "addInteger-memory-arguments-intercept": 1, ... } +In both cases, the cost model must be complete, i.e. it must specify all parameters that are needed for the specific Plutus version. +It's not specified what will happen if you provide more parameters than necessary. \ No newline at end of file diff --git a/cardano-cli/test/cardano-cli-golden/files/input/governance/costmodels-partial.json b/cardano-cli/test/cardano-cli-golden/files/input/governance/costmodels-partial.json index 240c942ec7..eb44f4cb36 100644 --- a/cardano-cli/test/cardano-cli-golden/files/input/governance/costmodels-partial.json +++ b/cardano-cli/test/cardano-cli-golden/files/input/governance/costmodels-partial.json @@ -1,179 +1,178 @@ -{ - "PlutusV2": { - "addInteger-cpu-arguments-intercept": 205665, - "addInteger-cpu-arguments-slope": 812, - "addInteger-memory-arguments-intercept": 1, - "addInteger-memory-arguments-slope": 1, - "appendByteString-cpu-arguments-intercept": 1000, - "appendByteString-cpu-arguments-slope": 571, - "appendByteString-memory-arguments-intercept": 0, - "appendByteString-memory-arguments-slope": 1, - "appendString-cpu-arguments-intercept": 1000, - "appendString-cpu-arguments-slope": 24177, - "appendString-memory-arguments-intercept": 4, - "appendString-memory-arguments-slope": 1, - "bData-cpu-arguments": 1000, - "bData-memory-arguments": 32, - "blake2b_256-cpu-arguments-intercept": 117366, - "blake2b_256-cpu-arguments-slope": 10475, - "blake2b_256-memory-arguments": 4, - "cekApplyCost-exBudgetCPU": 23000, - "cekApplyCost-exBudgetMemory": 100, - "cekBuiltinCost-exBudgetCPU": 23000, - "cekBuiltinCost-exBudgetMemory": 100, - "cekConstCost-exBudgetCPU": 23000, - "cekConstCost-exBudgetMemory": 100, - "cekDelayCost-exBudgetCPU": 23000, - "cekDelayCost-exBudgetMemory": 100, - "cekForceCost-exBudgetCPU": 23000, - "cekForceCost-exBudgetMemory": 100, - "cekLamCost-exBudgetCPU": 23000, - "cekLamCost-exBudgetMemory": 100, - "cekStartupCost-exBudgetCPU": 100, - "cekStartupCost-exBudgetMemory": 100, - "cekVarCost-exBudgetCPU": 23000, - "cekVarCost-exBudgetMemory": 100, - "chooseData-cpu-arguments": 19537, - "chooseData-memory-arguments": 32, - "chooseList-cpu-arguments": 175354, - "chooseList-memory-arguments": 32, - "chooseUnit-cpu-arguments": 46417, - "chooseUnit-memory-arguments": 4, - "consByteString-cpu-arguments-intercept": 221973, - "consByteString-cpu-arguments-slope": 511, - "consByteString-memory-arguments-intercept": 0, - "consByteString-memory-arguments-slope": 1, - "constrData-cpu-arguments": 89141, - "constrData-memory-arguments": 32, - "decodeUtf8-cpu-arguments-intercept": 497525, - "decodeUtf8-cpu-arguments-slope": 14068, - "decodeUtf8-memory-arguments-intercept": 4, - "decodeUtf8-memory-arguments-slope": 2, - "divideInteger-cpu-arguments-constant": 196500, - "divideInteger-cpu-arguments-model-arguments-intercept": 453240, - "divideInteger-cpu-arguments-model-arguments-slope": 220, - "divideInteger-memory-arguments-intercept": 0, - "divideInteger-memory-arguments-minimum": 1, - "divideInteger-memory-arguments-slope": 1, - "encodeUtf8-cpu-arguments-intercept": 1000, - "encodeUtf8-cpu-arguments-slope": 28662, - "encodeUtf8-memory-arguments-intercept": 4, - "encodeUtf8-memory-arguments-slope": 2, - "equalsByteString-cpu-arguments-constant": 245000, - "equalsByteString-cpu-arguments-intercept": 216773, - "equalsByteString-cpu-arguments-slope": 62, - "equalsByteString-memory-arguments": 1, - "equalsData-cpu-arguments-intercept": 1060367, - "equalsData-cpu-arguments-slope": 12586, - "equalsData-memory-arguments": 1, - "equalsInteger-cpu-arguments-intercept": 208512, - "equalsInteger-cpu-arguments-slope": 421, - "equalsInteger-memory-arguments": 1, - "equalsString-cpu-arguments-constant": 187000, - "equalsString-cpu-arguments-intercept": 1000, - "equalsString-cpu-arguments-slope": 52998, - "equalsString-memory-arguments": 1, - "fstPair-cpu-arguments": 80436, - "fstPair-memory-arguments": 32, - "headList-cpu-arguments": 43249, - "headList-memory-arguments": 32, - "iData-cpu-arguments": 1000, - "iData-memory-arguments": 32, - "ifThenElse-cpu-arguments": 80556, - "ifThenElse-memory-arguments": 1, - "indexByteString-cpu-arguments": 57667, - "indexByteString-memory-arguments": 4, - "lengthOfByteString-cpu-arguments": 1000, - "lengthOfByteString-memory-arguments": 10, - "lessThanByteString-cpu-arguments-intercept": 197145, - "lessThanByteString-cpu-arguments-slope": 156, - "lessThanByteString-memory-arguments": 1, - "lessThanEqualsByteString-cpu-arguments-intercept": 197145, - "lessThanEqualsByteString-cpu-arguments-slope": 156, - "lessThanEqualsByteString-memory-arguments": 1, - "lessThanEqualsInteger-cpu-arguments-intercept": 204924, - "lessThanEqualsInteger-cpu-arguments-slope": 473, - "lessThanEqualsInteger-memory-arguments": 1, - "lessThanInteger-cpu-arguments-intercept": 208896, - "lessThanInteger-cpu-arguments-slope": 511, - "lessThanInteger-memory-arguments": 1, - "listData-cpu-arguments": 52467, - "listData-memory-arguments": 32, - "mapData-cpu-arguments": 64832, - "mapData-memory-arguments": 32, - "mkCons-cpu-arguments": 65493, - "mkCons-memory-arguments": 32, - "mkNilData-cpu-arguments": 22558, - "mkNilData-memory-arguments": 32, - "mkNilPairData-cpu-arguments": 16563, - "mkNilPairData-memory-arguments": 32, - "mkPairData-cpu-arguments": 76511, - "mkPairData-memory-arguments": 32, - "modInteger-cpu-arguments-constant": 196500, - "modInteger-cpu-arguments-model-arguments-intercept": 453240, - "modInteger-cpu-arguments-model-arguments-slope": 220, - "modInteger-memory-arguments-intercept": 0, - "modInteger-memory-arguments-minimum": 1, - "modInteger-memory-arguments-slope": 1, - "multiplyInteger-cpu-arguments-intercept": 69522, - "multiplyInteger-cpu-arguments-slope": 11687, - "multiplyInteger-memory-arguments-intercept": 0, - "multiplyInteger-memory-arguments-slope": 1, - "nullList-cpu-arguments": 60091, - "nullList-memory-arguments": 32, - "quotientInteger-cpu-arguments-constant": 196500, - "quotientInteger-cpu-arguments-model-arguments-intercept": 453240, - "quotientInteger-cpu-arguments-model-arguments-slope": 220, - "quotientInteger-memory-arguments-intercept": 0, - "quotientInteger-memory-arguments-minimum": 1, - "quotientInteger-memory-arguments-slope": 1, - "remainderInteger-cpu-arguments-constant": 196500, - "remainderInteger-cpu-arguments-model-arguments-intercept": 453240, - "remainderInteger-cpu-arguments-model-arguments-slope": 220, - "remainderInteger-memory-arguments-intercept": 0, - "remainderInteger-memory-arguments-minimum": 1, - "remainderInteger-memory-arguments-slope": 1, - "serialiseData-cpu-arguments-intercept": 1159724, - "serialiseData-cpu-arguments-slope": 392670, - "serialiseData-memory-arguments-intercept": 0, - "serialiseData-memory-arguments-slope": 2, - "sha2_256-cpu-arguments-intercept": 806990, - "sha2_256-cpu-arguments-slope": 30482, - "sha2_256-memory-arguments": 4, - "sha3_256-cpu-arguments-intercept": 1927926, - "sha3_256-cpu-arguments-slope": 82523, - "sha3_256-memory-arguments": 4, - "sliceByteString-cpu-arguments-intercept": 265318, - "sliceByteString-cpu-arguments-slope": 0, - "sliceByteString-memory-arguments-intercept": 4, - "sliceByteString-memory-arguments-slope": 0, - "sndPair-cpu-arguments": 85931, - "sndPair-memory-arguments": 32, - "subtractInteger-cpu-arguments-intercept": 205665, - "subtractInteger-cpu-arguments-slope": 812, - "subtractInteger-memory-arguments-intercept": 1, - "subtractInteger-memory-arguments-slope": 1, - "tailList-cpu-arguments": 41182, - "tailList-memory-arguments": 32, - "trace-cpu-arguments": 212342, - "trace-memory-arguments": 32, - "unBData-cpu-arguments": 31220, - "unBData-memory-arguments": 32, - "unConstrData-cpu-arguments": 32696, - "unConstrData-memory-arguments": 32, - "unIData-cpu-arguments": 43357, - "unIData-memory-arguments": 32, - "unListData-cpu-arguments": 32247, - "unListData-memory-arguments": 32, - "unMapData-cpu-arguments": 38314, - "unMapData-memory-arguments": 32, - "verifyEcdsaSecp256k1Signature-cpu-arguments": 35892428, - "verifyEcdsaSecp256k1Signature-memory-arguments": 10, - "verifyEd25519Signature-cpu-arguments-intercept": 9462713, - "verifyEd25519Signature-cpu-arguments-slope": 1021, - "verifyEd25519Signature-memory-arguments": 10, - "verifySchnorrSecp256k1Signature-cpu-arguments-intercept": 38887044, - "verifySchnorrSecp256k1Signature-cpu-arguments-slope": 32947, - "verifySchnorrSecp256k1Signature-memory-arguments": 10 - } +{ "PlutusV2": [ + 205665, + 812, + 1, + 1, + 1000, + 571, + 0, + 1, + 1000, + 24177, + 4, + 1, + 1000, + 32, + 117366, + 10475, + 4, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 100, + 100, + 23000, + 100, + 19537, + 32, + 175354, + 32, + 46417, + 4, + 221973, + 511, + 0, + 1, + 89141, + 32, + 497525, + 14068, + 4, + 2, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1000, + 28662, + 4, + 2, + 245000, + 216773, + 62, + 1, + 1060367, + 12586, + 1, + 208512, + 421, + 1, + 187000, + 1000, + 52998, + 1, + 80436, + 32, + 43249, + 32, + 1000, + 32, + 80556, + 1, + 57667, + 4, + 1000, + 10, + 197145, + 156, + 1, + 197145, + 156, + 1, + 204924, + 473, + 1, + 208896, + 511, + 1, + 52467, + 32, + 64832, + 32, + 65493, + 32, + 22558, + 32, + 16563, + 32, + 76511, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 69522, + 11687, + 0, + 1, + 60091, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1159724, + 392670, + 0, + 2, + 806990, + 30482, + 4, + 1927926, + 82523, + 4, + 265318, + 0, + 4, + 0, + 85931, + 32, + 205665, + 812, + 1, + 1, + 41182, + 32, + 212342, + 32, + 31220, + 32, + 32696, + 32, + 43357, + 32, + 32247, + 32, + 38314, + 32, + 35892428, + 10, + 9462713, + 1021, + 10, + 38887044, + 32947, + 10 + ] }