From b1beddee98867e4c2c6dee644165f4f3b5acf767 Mon Sep 17 00:00:00 2001 From: zeme Date: Mon, 16 Feb 2026 21:14:20 +0100 Subject: [PATCH 1/7] Replace use of TH in readJSONFromFile with unsafePerformIO --- .../src/Cardano/Constitution/Config.hs | 2 +- .../test/Cardano/Constitution/Config/Tests.hs | 3 +- .../plutus-core/src/Data/Aeson/THReader.hs | 13 ++++---- .../Evaluation/Machine/ExBudgetingDefaults.hs | 30 +++++++------------ .../Machine/SimpleBuiltinCostModel.hs | 3 +- 5 files changed, 20 insertions(+), 31 deletions(-) diff --git a/cardano-constitution/src/Cardano/Constitution/Config.hs b/cardano-constitution/src/Cardano/Constitution/Config.hs index 81a1103ea36..2d2d98a9145 100644 --- a/cardano-constitution/src/Cardano/Constitution/Config.hs +++ b/cardano-constitution/src/Cardano/Constitution/Config.hs @@ -19,7 +19,7 @@ import Data.Aeson.THReader as Aeson -- | The default config read from "data/defaultConstitution.json" defaultConstitutionConfig :: ConstitutionConfig -defaultConstitutionConfig = $$(Aeson.readJSONFromFile DFP.defaultConstitutionConfigFile) +defaultConstitutionConfig = Aeson.readJSONFromFile DFP.defaultConstitutionConfigFile {-# INLINEABLE defaultConstitutionConfig #-} -- | NOTE: **BE CAREFUL** of the ordering. Expected value is first arg, Proposed Value is second arg diff --git a/cardano-constitution/test/Cardano/Constitution/Config/Tests.hs b/cardano-constitution/test/Cardano/Constitution/Config/Tests.hs index 4ef58cd5f6a..0e2f4fd8aff 100644 --- a/cardano-constitution/test/Cardano/Constitution/Config/Tests.hs +++ b/cardano-constitution/test/Cardano/Constitution/Config/Tests.hs @@ -19,8 +19,7 @@ import Helpers.TestBuilders import Test.Tasty.QuickCheck defaultConstitutionJSONSchema :: Aeson.Value -defaultConstitutionJSONSchema = - $$(Aeson.readJSONFromFile DFP.defaultConstitutionJSONSchemaFile) +defaultConstitutionJSONSchema = Aeson.readJSONFromFile DFP.defaultConstitutionJSONSchemaFile {-| All the examples in the JSON schema are parseable as a list of ConstitutionConfigs. Actually the examples 9005 and 9006 should not normally parse, diff --git a/plutus-core/plutus-core/src/Data/Aeson/THReader.hs b/plutus-core/plutus-core/src/Data/Aeson/THReader.hs index e2ae91f50bb..f4c60119ff3 100644 --- a/plutus-core/plutus-core/src/Data/Aeson/THReader.hs +++ b/plutus-core/plutus-core/src/Data/Aeson/THReader.hs @@ -4,11 +4,12 @@ module Data.Aeson.THReader where import Data.Aeson import Language.Haskell.TH.Syntax +import System.IO.Unsafe import TH.RelativePaths -readJSONFromFile :: (FromJSON a, Lift a) => String -> Code Q a -readJSONFromFile name = liftCode $ do - contents <- qReadFileLBS name - case eitherDecode contents of - Left err -> fail err - Right res -> examineCode [||res||] +{-# OPAQUE readJSONFromFile #-} +readJSONFromFile :: FromJSON a => String -> a +readJSONFromFile path = + case unsafePerformIO (eitherDecodeFileStrict path) of + Left err -> error ("Failed to decode json file " <> path <> ":\n" <> err) + Right res -> res diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/ExBudgetingDefaults.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/ExBudgetingDefaults.hs index 0b526fa1f47..6d6b141f1c2 100644 --- a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/ExBudgetingDefaults.hs +++ b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/ExBudgetingDefaults.hs @@ -64,8 +64,7 @@ import PlutusPrelude -- | The default cost model for built-in functions (variant A) builtinCostModelVariantA :: BuiltinCostModel -builtinCostModelVariantA = - $$(readJSONFromFile DFP.builtinCostModelFileA) +builtinCostModelVariantA = readJSONFromFile DFP.builtinCostModelFileA -- This is a huge record, inlining it is wasteful. {-# OPAQUE builtinCostModelVariantA #-} @@ -75,8 +74,7 @@ appears faster than 'CekMachineCosts' that we get in production after applying the costing parameters provided by the ledger. -} -- | Default costs for CEK machine instructions (variant A) cekMachineCostsVariantA :: CekMachineCosts -cekMachineCostsVariantA = - $$(readJSONFromFile DFP.cekMachineCostsFileA) +cekMachineCostsVariantA = readJSONFromFile DFP.cekMachineCostsFileA {-# OPAQUE cekMachineCostsVariantA #-} {-| The default cost model, including both builtin costs and machine step costs. @@ -91,56 +89,48 @@ cekCostModelVariantA :: CostModel CekMachineCosts BuiltinCostModel cekCostModelVariantA = CostModel cekMachineCostsVariantA builtinCostModelVariantA builtinCostModelVariantB :: BuiltinCostModel -builtinCostModelVariantB = - $$(readJSONFromFile DFP.builtinCostModelFileB) +builtinCostModelVariantB = readJSONFromFile DFP.builtinCostModelFileB {-# OPAQUE builtinCostModelVariantB #-} -- See Note [No inlining for CekMachineCosts] cekMachineCostsVariantB :: CekMachineCosts -cekMachineCostsVariantB = - $$(readJSONFromFile DFP.cekMachineCostsFileB) +cekMachineCostsVariantB = readJSONFromFile DFP.cekMachineCostsFileB {-# OPAQUE cekMachineCostsVariantB #-} cekCostModelVariantB :: CostModel CekMachineCosts BuiltinCostModel cekCostModelVariantB = CostModel cekMachineCostsVariantB builtinCostModelVariantB builtinCostModelVariantC :: BuiltinCostModel -builtinCostModelVariantC = - $$(readJSONFromFile DFP.builtinCostModelFileC) +builtinCostModelVariantC = readJSONFromFile DFP.builtinCostModelFileC {-# OPAQUE builtinCostModelVariantC #-} -- See Note [No inlining for CekMachineCosts] cekMachineCostsVariantC :: CekMachineCosts -cekMachineCostsVariantC = - $$(readJSONFromFile DFP.cekMachineCostsFileC) +cekMachineCostsVariantC = readJSONFromFile DFP.cekMachineCostsFileC {-# OPAQUE cekMachineCostsVariantC #-} cekCostModelVariantC :: CostModel CekMachineCosts BuiltinCostModel cekCostModelVariantC = CostModel cekMachineCostsVariantC builtinCostModelVariantC builtinCostModelVariantD :: BuiltinCostModel -builtinCostModelVariantD = - $$(readJSONFromFile DFP.builtinCostModelFileD) +builtinCostModelVariantD = readJSONFromFile DFP.builtinCostModelFileD {-# OPAQUE builtinCostModelVariantD #-} -- See Note [No inlining for CekMachineCosts] cekMachineCostsVariantD :: CekMachineCosts -cekMachineCostsVariantD = - $$(readJSONFromFile DFP.cekMachineCostsFileD) +cekMachineCostsVariantD = readJSONFromFile DFP.cekMachineCostsFileD {-# OPAQUE cekMachineCostsVariantD #-} cekCostModelVariantD :: CostModel CekMachineCosts BuiltinCostModel cekCostModelVariantD = CostModel cekMachineCostsVariantD builtinCostModelVariantD builtinCostModelVariantE :: BuiltinCostModel -builtinCostModelVariantE = - $$(readJSONFromFile DFP.builtinCostModelFileE) +builtinCostModelVariantE = readJSONFromFile DFP.builtinCostModelFileE {-# OPAQUE builtinCostModelVariantE #-} -- See Note [No inlining for CekMachineCosts] cekMachineCostsVariantE :: CekMachineCosts -cekMachineCostsVariantE = - $$(readJSONFromFile DFP.cekMachineCostsFileE) +cekMachineCostsVariantE = readJSONFromFile DFP.cekMachineCostsFileE {-# OPAQUE cekMachineCostsVariantE #-} cekCostModelVariantE :: CostModel CekMachineCosts BuiltinCostModel diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/SimpleBuiltinCostModel.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/SimpleBuiltinCostModel.hs index b9323f8d9e6..7b3a9f56832 100644 --- a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/SimpleBuiltinCostModel.hs +++ b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/SimpleBuiltinCostModel.hs @@ -27,8 +27,7 @@ type BuiltinCostKeyMap = KeyMap.KeyMap CpuAndMemoryModel {-| The default builtin cost map. TODO: maybe we should take account of the semantic variant here. -} defaultBuiltinCostKeyMap :: BuiltinCostKeyMap -defaultBuiltinCostKeyMap = - $$(readJSONFromFile DFP.latestBuiltinCostModelFile) +defaultBuiltinCostKeyMap = readJSONFromFile DFP.latestBuiltinCostModelFile -- replace underscores _ by dashes - builtinName :: Text -> Text From 4fc87d2dfbb450ad20a92e8d8e5c6864132c776e Mon Sep 17 00:00:00 2001 From: zeme Date: Tue, 17 Feb 2026 07:55:42 +0100 Subject: [PATCH 2/7] wip --- plutus-core/plutus-core/src/Data/Aeson/THReader.hs | 2 -- 1 file changed, 2 deletions(-) diff --git a/plutus-core/plutus-core/src/Data/Aeson/THReader.hs b/plutus-core/plutus-core/src/Data/Aeson/THReader.hs index f4c60119ff3..e152342dd5d 100644 --- a/plutus-core/plutus-core/src/Data/Aeson/THReader.hs +++ b/plutus-core/plutus-core/src/Data/Aeson/THReader.hs @@ -3,9 +3,7 @@ module Data.Aeson.THReader where import Data.Aeson -import Language.Haskell.TH.Syntax import System.IO.Unsafe -import TH.RelativePaths {-# OPAQUE readJSONFromFile #-} readJSONFromFile :: FromJSON a => String -> a From 70efb790039842a86a5549b0a86e1ac7bb8aa974 Mon Sep 17 00:00:00 2001 From: zeme Date: Tue, 17 Feb 2026 08:27:14 +0100 Subject: [PATCH 3/7] wip --- plutus-core/plutus-core.cabal | 1 - 1 file changed, 1 deletion(-) diff --git a/plutus-core/plutus-core.cabal b/plutus-core/plutus-core.cabal index 5afd8ca1ceb..eb166c96359 100644 --- a/plutus-core/plutus-core.cabal +++ b/plutus-core/plutus-core.cabal @@ -350,7 +350,6 @@ library , text , th-lift , th-lift-instances - , th-utilities , time , transformers , unordered-containers From 5565fc23c192ca59f7272ebc62c49044452dd0a4 Mon Sep 17 00:00:00 2001 From: zeme Date: Tue, 17 Feb 2026 09:18:41 +0100 Subject: [PATCH 4/7] wip --- plutus-core/cost-model/CostModelGeneration.md | 40 +++++++-------- .../cost-model/create-cost-model/Main.hs | 43 ++++++++++++---- plutus-core/plutus-core.cabal | 21 ++++---- .../src/PlutusCore/DataFilePaths.hs | 48 +++--------------- .../CostModel/Generated/BuiltinCostModelA.hs | 11 ++++ .../CostModel/Generated/BuiltinCostModelB.hs | 11 ++++ .../CostModel/Generated/BuiltinCostModelC.hs | 11 ++++ .../CostModel/Generated/CekMachineCostsA.hs | 24 +++++++++ .../CostModel/Generated/CekMachineCostsB.hs | 24 +++++++++ .../CostModel/Generated/CekMachineCostsC.hs | 24 +++++++++ .../Evaluation/Machine/ExBudgetingDefaults.hs | 50 +++++++++---------- .../Machine/SimpleBuiltinCostModel.hs | 18 ++++--- 12 files changed, 212 insertions(+), 113 deletions(-) create mode 100644 plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/BuiltinCostModelA.hs create mode 100644 plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/BuiltinCostModelB.hs create mode 100644 plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/BuiltinCostModelC.hs create mode 100644 plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsA.hs create mode 100644 plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsB.hs create mode 100644 plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsC.hs diff --git a/plutus-core/cost-model/CostModelGeneration.md b/plutus-core/cost-model/CostModelGeneration.md index f1431016da7..95e8c66d2e2 100644 --- a/plutus-core/cost-model/CostModelGeneration.md +++ b/plutus-core/cost-model/CostModelGeneration.md @@ -40,9 +40,9 @@ costing functions involves a number of steps. when testing costing benchmarks. * Change directory to `plutus-core/cost-model/data/` and run `cabal run - plutus-core:generate-cost-model -- --csv `, where `` is the CSV - file produced in the previous step. This runs some R code in - [`plutus-core/cost-model/data/models.R`](./data/models.R) which fits a linear + plutus-core:generate-cost-model -- --csv -o `, where `` is the CSV + file produced in the previous step and `` is the Haskell module file to generate. + This runs some R code in [`plutus-core/cost-model/data/models.R`](./data/models.R) which fits a linear model to the data for each builtin; the general form of the model for each builtin is coded into `models.R`. Certain checks are performed during this process: for example it is possible that R will generate a model with a @@ -50,7 +50,7 @@ costing functions involves a number of steps. constant) and if that happens then a warning is printed and the coefficient is replaced by zero. - * The output of `generate-cost-model` is a JSON object describing the form of + * The output of `generate-cost-model` is a Haskell module file describing the form of the models for each builtin, together with the model coefficients fitted by R. By default this is written to the terminal, but an output file can be specified with `-o`. The model coefficients are converted from floating point @@ -60,23 +60,23 @@ costing functions involves a number of steps. on different machines). * The specific cost model data to be used by the Plutus Core evaluator should be - checked in to git in the file - [`plutus-core/cost-model/data/builtinCostModelC.json`](./data/builtinCostModelC.json). - There are also files called `builtinCostModelA.json` and - `builtinCostModelB.json` which are used for evaluating scripts prior to the - Chang hard fork: data for new builtins can (if fact, must) be added to these - files, but the existing content must not be changed. The CSV file containing - the benchmark results used to generate the cost model should be checked in to - the repository; this is not strictly necessary but it can be useful to have - the raw data available if the details of the cost model need to be looked at - at some later time. The benchmarking results used to generate the current cost - model (March 2025) are checked in in + checked in to git as Haskell modules in the directory + [`plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/`](../plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/). + The module `BuiltinCostModelC.hs` contains the cost model for the latest version. + There are also modules called `BuiltinCostModelA.hs` and `BuiltinCostModelB.hs` + which are used for evaluating scripts prior to the Chang hard fork: data for new + builtins can (if fact, must) be added to these files, but the existing content + must not be changed. The CSV file containing the benchmark results used to generate + the cost model should be checked in to the repository; this is not strictly necessary + but it can be useful to have the raw data available if the details of the cost model + need to be looked at at some later time. The benchmarking results used to generate + the current cost model (March 2025) are checked in in [`plutus-core/cost-model/data/benching-conway.csv`](./data/benching-conway.csv) and any new results should be added to the end of that file. -* When the rest of the `plutus-core` package is compiled, the contents of - `builtCostModelC.json` are read and used by some Template Haskell code to - construct Haskell functions which implement the cost models. +* When the rest of the `plutus-core` package is compiled, the generated Haskell + modules are directly imported and used to construct the cost models. This + eliminates the need for Template Haskell file reading at compile time. * To ensure consistency, `cabal bench plutus-core:cost-model-test` runs some QuickCheck tests to run the R models and the Haskell models and checks that @@ -96,8 +96,8 @@ costing functions involves a number of steps. predicted by the builtin cost model, and divide the remaining time by the number of basic machine steps executed to arrive at an average time for each machine step (see the earlier discussion). - This is then stored in another JSON file, - [`plutus-core/cost-model/data/cekMachineCosts.json`](./data/cekMachineCosts.json). + This is then stored in Haskell modules in the `CostModel/Generated/` directory, + such as [`CekMachineCostsC.hs`](../plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsC.hs). This cost is currently the same for each step, but more careful testing may enable us to produce more precise costs per step at some future date. The JSON file also contains a constant cost for diff --git a/plutus-core/cost-model/create-cost-model/Main.hs b/plutus-core/cost-model/create-cost-model/Main.hs index 4671a470e5d..9e619c0e552 100644 --- a/plutus-core/cost-model/create-cost-model/Main.hs +++ b/plutus-core/cost-model/create-cost-model/Main.hs @@ -1,19 +1,21 @@ module Main where import CreateBuiltinCostModel (createBuiltinCostModel) +import PlutusCore.Evaluation.Machine.BuiltinCostModel (BuiltinCostModel) -import Data.Aeson.Encode.Pretty -import Data.ByteString.Lazy qualified as BSL (ByteString, putStr, writeFile) +import Data.Text qualified as T +import Data.Text.IO qualified as T import Options.Applicative import System.Directory import System.Exit +import System.FilePath import System.IO (hPutStrLn, stderr) import Language.R (defaultConfig, runRegion, withEmbeddedR) {-| This takes a CSV file of benchmark results for built-in functions, runs the R code in `models.R` to construct costing functions based on the benchmark - results, and then produces JSON output containing the types and coefficients + results, and then produces Haskell module output containing the types and coefficients of the costing functions. For best results, run this in `plutus-core/cost-model/data` to make `models.R` easy to find; if that's inconvenient for some reason, use the `-m` option to provide a path to @@ -36,7 +38,7 @@ data RFile = RFile FilePath defaultRFile :: RFile defaultRFile = RFile "models.R" --- | Where to write the JSON output, stdout by default +-- | Where to write the Haskell module output, stdout by default data Output = NamedOutput FilePath | StdOutput ---------------- Option parsers ---------------- @@ -80,8 +82,8 @@ fileOutput = <$> strOption ( long "output" <> short 'o' - <> metavar "FILENAME" - <> help "Output file" + <> metavar "BASENAME" + <> help "Output basename, e.g. builtinCostModelA or cekMachineCostsB, will be places in PlutusCore/Evaluation/Machine/CostModel/Generated" ) stdOutput :: Parser Output @@ -102,7 +104,7 @@ arguments = ( fullDesc <> header "Plutus Core cost model creation tool" <> progDesc - ( "Creates a JSON description of Plutus Core cost model " + ( "Creates a Haskell module containing the Plutus Core cost model " ++ "for built-in functions from a set of benchmark results " ++ "produced by cost-model-budgeting-bench" ) @@ -146,11 +148,29 @@ checkBenchmarkFile file = in checkInputFile file "benchmark results file" advice writeOutput - :: Output -> BSL.ByteString -> IO () + :: Output -> T.Text -> IO () writeOutput outp v = do case outp of - NamedOutput file -> BSL.writeFile file v - StdOutput -> BSL.putStr v + NamedOutput file -> T.writeFile file v + StdOutput -> T.putStr v + +{-| Convert a BuiltinCostModel to a Haskell module. + The module exports a single value of type BuiltinCostModel. -} +costModelToHaskellModule :: FilePath -> BuiltinCostModel -> T.Text +costModelToHaskellModule basename model = + T.unlines + [ "-- This file is auto-generated by the generate-cost-model executable." + , "-- Do not edit this file manually." + , "{-# LANGUAGE RecordWildCards #-}" + , "{-# OPTIONS_GHC -Wno-missing-signatures #-}" + , "" + , "module PlutusCore.Evaluation.Machine.CostModel.Generated" <> modName <> " where" + , "" + , varName <> " = " <> T.pack (show model) + ] + where + modName = T.pack (T.toTile basename) + varName = T.pack basename main :: IO () main = do @@ -158,4 +178,5 @@ main = do checkBenchmarkFile bmfile checkRFile rfile model <- withEmbeddedR defaultConfig $ runRegion $ createBuiltinCostModel bmfile rfile - writeOutput out $ encodePretty' (defConfig {confCompare = \_ _ -> EQ}) model + let hsModule = costModelToHaskellModule variant model + writeOutput out hsModule diff --git a/plutus-core/plutus-core.cabal b/plutus-core/plutus-core.cabal index eb166c96359..deddef057ca 100644 --- a/plutus-core/plutus-core.cabal +++ b/plutus-core/plutus-core.cabal @@ -22,13 +22,9 @@ extra-doc-files: -- `data-files`. See https://github.com/haskell/cabal/pull/6889 and the issue -- #4746 that it mentions. extra-source-files: + cost-model/data/*.csv cost-model/data/*.R - cost-model/data/builtinCostModelA.json - cost-model/data/builtinCostModelB.json - cost-model/data/builtinCostModelC.json - cost-model/data/cekMachineCostsA.json - cost-model/data/cekMachineCostsB.json - cost-model/data/cekMachineCostsC.json + plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/*.hs plutus-core/test/CostModelInterface/defaultCostModelParams.json source-repository head @@ -136,6 +132,12 @@ library PlutusCore.Evaluation.Machine.CostingFun.Core PlutusCore.Evaluation.Machine.CostingFun.JSON PlutusCore.Evaluation.Machine.CostingFun.SimpleJSON + PlutusCore.Evaluation.Machine.CostModel.Generated.BuiltinCostModelA + PlutusCore.Evaluation.Machine.CostModel.Generated.BuiltinCostModelB + PlutusCore.Evaluation.Machine.CostModel.Generated.BuiltinCostModelC + PlutusCore.Evaluation.Machine.CostModel.Generated.CekMachineCostsA + PlutusCore.Evaluation.Machine.CostModel.Generated.CekMachineCostsB + PlutusCore.Evaluation.Machine.CostModel.Generated.CekMachineCostsC PlutusCore.Evaluation.Machine.CostModelInterface PlutusCore.Evaluation.Machine.CostStream PlutusCore.Evaluation.Machine.ExBudget @@ -983,19 +985,18 @@ executable generate-cost-model -- This fails on Darwin with strange errors and I don't know why -- > Error: C stack usage 17556409549320 is too close to the limit -- > Fatal error: unable to initialize the JI - if os(osx) - buildable: False + -- if os(osx) + -- buildable: False -- Can't build on windows as it depends on R. if os(windows) buildable: False build-depends: - , aeson-pretty , barbies , base >=4.9 && <5 - , bytestring , directory + , filepath , inline-r >=1.0.1 , optparse-applicative , plutus-core ^>=1.58 diff --git a/plutus-core/plutus-core/src/PlutusCore/DataFilePaths.hs b/plutus-core/plutus-core/src/PlutusCore/DataFilePaths.hs index 29e4b7a783b..fc22ae1d491 100644 --- a/plutus-core/plutus-core/src/PlutusCore/DataFilePaths.hs +++ b/plutus-core/plutus-core/src/PlutusCore/DataFilePaths.hs @@ -1,5 +1,7 @@ -{-| Various file paths used in plutus-core, currently all to do with the cost -model. -} +{-| Various file paths used in plutus-core. + These paths are primarily used for testing and benchmarking. + Cost models are embedded as Haskell modules in + PlutusCore.Evaluation.Machine.CostModel.Generated.* -} module PlutusCore.DataFilePaths where @@ -8,47 +10,11 @@ import System.FilePath costModelDataDir :: FilePath costModelDataDir = "cost-model" "data" -builtinCostModelFileA :: FilePath -builtinCostModelFileA = costModelDataDir "builtinCostModelA" <.> "json" - -builtinCostModelFileB :: FilePath -builtinCostModelFileB = costModelDataDir "builtinCostModelB" <.> "json" - -builtinCostModelFileC :: FilePath -builtinCostModelFileC = costModelDataDir "builtinCostModelC" <.> "json" - -builtinCostModelFileD :: FilePath -builtinCostModelFileD = costModelDataDir "builtinCostModelB" <.> "json" - -builtinCostModelFileE :: FilePath -builtinCostModelFileE = costModelDataDir "builtinCostModelC" <.> "json" - -latestBuiltinCostModelFile :: FilePath -latestBuiltinCostModelFile = builtinCostModelFileC - -cekMachineCostsFileA :: FilePath -cekMachineCostsFileA = costModelDataDir "cekMachineCostsA" <.> "json" - -cekMachineCostsFileB :: FilePath -cekMachineCostsFileB = costModelDataDir "cekMachineCostsB" <.> "json" - -cekMachineCostsFileC :: FilePath -cekMachineCostsFileC = costModelDataDir "cekMachineCostsC" <.> "json" - -cekMachineCostsFileD :: FilePath -cekMachineCostsFileD = costModelDataDir "cekMachineCostsB" <.> "json" - -cekMachineCostsFileE :: FilePath -cekMachineCostsFileE = costModelDataDir "cekMachineCostsC" <.> "json" - -latestMachineCostsFile :: FilePath -latestMachineCostsFile = cekMachineCostsFileC - --- | The file containing the R models: only needed for cost-model-test. +-- | The file containing the R models: needed for cost-model-test and generate-cost-model. rModelFile :: FilePath rModelFile = costModelDataDir "models" <.> "R" -{-| The file containing the benchmark results for the built-in functions: only -needed for cost-model-test. -} +{-| The file containing the benchmark results for the built-in functions: +needed for cost-model-test and generate-cost-model. -} benchingResultsFile :: FilePath benchingResultsFile = costModelDataDir "benching-conway" <.> "csv" diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/BuiltinCostModelA.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/BuiltinCostModelA.hs new file mode 100644 index 00000000000..4df260a0cee --- /dev/null +++ b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/BuiltinCostModelA.hs @@ -0,0 +1,11 @@ +-- This file is a placeholder for the generated builtin cost model for variant A. +-- It needs to be regenerated by running the generate-cost-model executable. +-- Run: cabal run plutus-core:generate-cost-model -- -o +{-# LANGUAGE RecordWildCards #-} + +module PlutusCore.Evaluation.Machine.CostModel.Generated.BuiltinCostModelA (builtinCostModelA) where + +import PlutusCore.Evaluation.Machine.BuiltinCostModel + +builtinCostModelA :: BuiltinCostModel +builtinCostModelA = error "BuiltinCostModelA needs to be regenerated using generate-cost-model" diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/BuiltinCostModelB.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/BuiltinCostModelB.hs new file mode 100644 index 00000000000..562fa129ce6 --- /dev/null +++ b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/BuiltinCostModelB.hs @@ -0,0 +1,11 @@ +-- This file is a placeholder for the generated builtin cost model for variant B. +-- It needs to be regenerated by running the generate-cost-model executable. +-- Run: cabal run plutus-core:generate-cost-model -- -o +{-# LANGUAGE RecordWildCards #-} + +module PlutusCore.Evaluation.Machine.CostModel.Generated.BuiltinCostModelB (builtinCostModelB) where + +import PlutusCore.Evaluation.Machine.BuiltinCostModel + +builtinCostModelB :: BuiltinCostModel +builtinCostModelB = error "BuiltinCostModelB needs to be regenerated using generate-cost-model" diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/BuiltinCostModelC.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/BuiltinCostModelC.hs new file mode 100644 index 00000000000..a4d2a85688d --- /dev/null +++ b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/BuiltinCostModelC.hs @@ -0,0 +1,11 @@ +-- This file is a placeholder for the generated builtin cost model for variant C. +-- It needs to be regenerated by running the generate-cost-model executable. +-- Run: cabal run plutus-core:generate-cost-model -- -o +{-# LANGUAGE RecordWildCards #-} + +module PlutusCore.Evaluation.Machine.CostModel.Generated.BuiltinCostModelC (builtinCostModelC) where + +import PlutusCore.Evaluation.Machine.BuiltinCostModel + +builtinCostModelC :: BuiltinCostModel +builtinCostModelC = error "BuiltinCostModelC needs to be regenerated using generate-cost-model" diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsA.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsA.hs new file mode 100644 index 00000000000..d9f39a579ab --- /dev/null +++ b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsA.hs @@ -0,0 +1,24 @@ +-- This file contains the CEK machine costs for variant A. +-- It corresponds to the previous cekMachineCostsA.json file. +{-# LANGUAGE RecordWildCards #-} + +module PlutusCore.Evaluation.Machine.CostModel.Generated.CekMachineCostsA (cekMachineCostsA) where + +import Data.Functor.Identity +import PlutusCore.Evaluation.Machine.ExMemory +import UntypedPlutusCore.Evaluation.Machine.Cek.CekMachineCosts + +cekMachineCostsA :: CekMachineCosts +cekMachineCostsA = + CekMachineCostsBase + { cekStartupCost = Identity (ExBudget 100 100) + , cekVarCost = Identity (ExBudget 23000 100) + , cekConstCost = Identity (ExBudget 23000 100) + , cekLamCost = Identity (ExBudget 23000 100) + , cekDelayCost = Identity (ExBudget 23000 100) + , cekForceCost = Identity (ExBudget 23000 100) + , cekApplyCost = Identity (ExBudget 23000 100) + , cekBuiltinCost = Identity (ExBudget 23000 100) + , cekConstrCost = Identity (ExBudget 23000 100) + , cekCaseCost = Identity (ExBudget 23000 100) + } diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsB.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsB.hs new file mode 100644 index 00000000000..f9b0634497d --- /dev/null +++ b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsB.hs @@ -0,0 +1,24 @@ +-- This file contains the CEK machine costs for variant B. +-- It corresponds to the previous cekMachineCostsB.json file. +{-# LANGUAGE RecordWildCards #-} + +module PlutusCore.Evaluation.Machine.CostModel.Generated.CekMachineCostsB (cekMachineCostsB) where + +import Data.Functor.Identity +import PlutusCore.Evaluation.Machine.ExMemory +import UntypedPlutusCore.Evaluation.Machine.Cek.CekMachineCosts + +cekMachineCostsB :: CekMachineCosts +cekMachineCostsB = + CekMachineCostsBase + { cekStartupCost = Identity (ExBudget 100 100) + , cekVarCost = Identity (ExBudget 16000 100) + , cekConstCost = Identity (ExBudget 16000 100) + , cekLamCost = Identity (ExBudget 16000 100) + , cekDelayCost = Identity (ExBudget 16000 100) + , cekForceCost = Identity (ExBudget 16000 100) + , cekApplyCost = Identity (ExBudget 16000 100) + , cekBuiltinCost = Identity (ExBudget 16000 100) + , cekConstrCost = Identity (ExBudget 16000 100) + , cekCaseCost = Identity (ExBudget 16000 100) + } diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsC.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsC.hs new file mode 100644 index 00000000000..450d0308282 --- /dev/null +++ b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsC.hs @@ -0,0 +1,24 @@ +-- This file contains the CEK machine costs for variant C. +-- It corresponds to the previous cekMachineCostsC.json file. +{-# LANGUAGE RecordWildCards #-} + +module PlutusCore.Evaluation.Machine.CostModel.Generated.CekMachineCostsC (cekMachineCostsC) where + +import Data.Functor.Identity +import PlutusCore.Evaluation.Machine.ExMemory +import UntypedPlutusCore.Evaluation.Machine.Cek.CekMachineCosts + +cekMachineCostsC :: CekMachineCosts +cekMachineCostsC = + CekMachineCostsBase + { cekStartupCost = Identity (ExBudget 100 100) + , cekVarCost = Identity (ExBudget 16000 100) + , cekConstCost = Identity (ExBudget 16000 100) + , cekLamCost = Identity (ExBudget 16000 100) + , cekDelayCost = Identity (ExBudget 16000 100) + , cekForceCost = Identity (ExBudget 16000 100) + , cekApplyCost = Identity (ExBudget 16000 100) + , cekBuiltinCost = Identity (ExBudget 16000 100) + , cekConstrCost = Identity (ExBudget 16000 100) + , cekCaseCost = Identity (ExBudget 16000 100) + } diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/ExBudgetingDefaults.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/ExBudgetingDefaults.hs index 6d6b141f1c2..bfcd810ee13 100644 --- a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/ExBudgetingDefaults.hs +++ b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/ExBudgetingDefaults.hs @@ -1,7 +1,6 @@ -- editorconfig-checker-disable-file {-# LANGUAGE DataKinds #-} {-# LANGUAGE LambdaCase #-} -{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeFamilies #-} module PlutusCore.Evaluation.Machine.ExBudgetingDefaults @@ -23,7 +22,6 @@ where import PlutusCore.Builtin -import PlutusCore.DataFilePaths qualified as DFP import PlutusCore.Default import PlutusCore.Evaluation.Machine.BuiltinCostModel import PlutusCore.Evaluation.Machine.CostModelInterface @@ -32,7 +30,13 @@ import PlutusCore.Evaluation.Machine.MachineParameters import UntypedPlutusCore.Evaluation.Machine.Cek.CekMachineCosts import UntypedPlutusCore.Evaluation.Machine.Cek.Internal -import Data.Aeson.THReader +-- Import generated cost model modules +import PlutusCore.Evaluation.Machine.CostModel.Generated.BuiltinCostModelA (builtinCostModelA) +import PlutusCore.Evaluation.Machine.CostModel.Generated.BuiltinCostModelB (builtinCostModelB) +import PlutusCore.Evaluation.Machine.CostModel.Generated.BuiltinCostModelC (builtinCostModelC) +import PlutusCore.Evaluation.Machine.CostModel.Generated.CekMachineCostsA (cekMachineCostsA) +import PlutusCore.Evaluation.Machine.CostModel.Generated.CekMachineCostsB (cekMachineCostsB) +import PlutusCore.Evaluation.Machine.CostModel.Generated.CekMachineCostsC (cekMachineCostsC) -- Not using 'noinline' from "GHC.Exts", because our CI was unable to find it there, somehow. import GHC.Magic (noinline) @@ -41,30 +45,26 @@ import PlutusPrelude {- Note [Modifying the cost model] When the Haskell representation of the cost model is changed, for example by adding a new builtin or changing the name of an existing one, - readJSONFromFile will fail when it tries to read a JSON file generated using - the previous version. When this happens, uncomment the three lines below (and - comment out the three above) then rerun + the generated Haskell modules will need to be regenerated. When this happens, + you may need to temporarily use default values. To do this, uncomment the three + lines below and comment out the import from the generated module, then rerun cabal run plutus-core:generate-cost-model + with appropriate output file specified (e.g., -o plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/BuiltinCostModelC.hs). (You may also need to add 'data-default' to the 'build-depends' for the - library in plutus-core.cabal). This will generate a new JSON file filled with - default values. After that, restore this file to its previous state and then - run "generate-cost-model" again to fill in the JSON file with the correct - values (assuming that suitable benchmarking data is in benching.csv and that + library in plutus-core.cabal). This will generate a new Haskell module filled with + the correct values (assuming that suitable benchmarking data is in benching.csv and that models.R contains R code to generate cost models for any new functions). - - Alternatively, modify the appropriate 'builtinCostModelX.json' by hand so - that it matches the new format. -} -- import Data.Default --- defaultBuiltinCostModel :: BuiltinCostModel --- defaultBuiltinCostModel = def +-- builtinCostModelVariantA :: BuiltinCostModel +-- builtinCostModelVariantA = def -- | The default cost model for built-in functions (variant A) builtinCostModelVariantA :: BuiltinCostModel -builtinCostModelVariantA = readJSONFromFile DFP.builtinCostModelFileA +builtinCostModelVariantA = builtinCostModelA -- This is a huge record, inlining it is wasteful. {-# OPAQUE builtinCostModelVariantA #-} @@ -74,7 +74,7 @@ appears faster than 'CekMachineCosts' that we get in production after applying the costing parameters provided by the ledger. -} -- | Default costs for CEK machine instructions (variant A) cekMachineCostsVariantA :: CekMachineCosts -cekMachineCostsVariantA = readJSONFromFile DFP.cekMachineCostsFileA +cekMachineCostsVariantA = cekMachineCostsA {-# OPAQUE cekMachineCostsVariantA #-} {-| The default cost model, including both builtin costs and machine step costs. @@ -89,48 +89,48 @@ cekCostModelVariantA :: CostModel CekMachineCosts BuiltinCostModel cekCostModelVariantA = CostModel cekMachineCostsVariantA builtinCostModelVariantA builtinCostModelVariantB :: BuiltinCostModel -builtinCostModelVariantB = readJSONFromFile DFP.builtinCostModelFileB +builtinCostModelVariantB = builtinCostModelB {-# OPAQUE builtinCostModelVariantB #-} -- See Note [No inlining for CekMachineCosts] cekMachineCostsVariantB :: CekMachineCosts -cekMachineCostsVariantB = readJSONFromFile DFP.cekMachineCostsFileB +cekMachineCostsVariantB = cekMachineCostsB {-# OPAQUE cekMachineCostsVariantB #-} cekCostModelVariantB :: CostModel CekMachineCosts BuiltinCostModel cekCostModelVariantB = CostModel cekMachineCostsVariantB builtinCostModelVariantB builtinCostModelVariantC :: BuiltinCostModel -builtinCostModelVariantC = readJSONFromFile DFP.builtinCostModelFileC +builtinCostModelVariantC = builtinCostModelC {-# OPAQUE builtinCostModelVariantC #-} -- See Note [No inlining for CekMachineCosts] cekMachineCostsVariantC :: CekMachineCosts -cekMachineCostsVariantC = readJSONFromFile DFP.cekMachineCostsFileC +cekMachineCostsVariantC = cekMachineCostsC {-# OPAQUE cekMachineCostsVariantC #-} cekCostModelVariantC :: CostModel CekMachineCosts BuiltinCostModel cekCostModelVariantC = CostModel cekMachineCostsVariantC builtinCostModelVariantC builtinCostModelVariantD :: BuiltinCostModel -builtinCostModelVariantD = readJSONFromFile DFP.builtinCostModelFileD +builtinCostModelVariantD = builtinCostModelB -- D uses B's model {-# OPAQUE builtinCostModelVariantD #-} -- See Note [No inlining for CekMachineCosts] cekMachineCostsVariantD :: CekMachineCosts -cekMachineCostsVariantD = readJSONFromFile DFP.cekMachineCostsFileD +cekMachineCostsVariantD = cekMachineCostsB -- D uses B's costs {-# OPAQUE cekMachineCostsVariantD #-} cekCostModelVariantD :: CostModel CekMachineCosts BuiltinCostModel cekCostModelVariantD = CostModel cekMachineCostsVariantD builtinCostModelVariantD builtinCostModelVariantE :: BuiltinCostModel -builtinCostModelVariantE = readJSONFromFile DFP.builtinCostModelFileE +builtinCostModelVariantE = builtinCostModelC -- E uses C's model {-# OPAQUE builtinCostModelVariantE #-} -- See Note [No inlining for CekMachineCosts] cekMachineCostsVariantE :: CekMachineCosts -cekMachineCostsVariantE = readJSONFromFile DFP.cekMachineCostsFileE +cekMachineCostsVariantE = cekMachineCostsC -- E uses C's costs {-# OPAQUE cekMachineCostsVariantE #-} cekCostModelVariantE :: CostModel CekMachineCosts BuiltinCostModel diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/SimpleBuiltinCostModel.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/SimpleBuiltinCostModel.hs index 7b3a9f56832..006f872cb28 100644 --- a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/SimpleBuiltinCostModel.hs +++ b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/SimpleBuiltinCostModel.hs @@ -1,10 +1,9 @@ {-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE TemplateHaskell #-} -- TODO: Extend this to handle the different variants of the cost model -{-| A program to parse a JSON representation of costing functions for Plutus Core - builtins and and produce a simple cost model which can be used from Agda and other +{-| A program to parse a representation of costing functions for Plutus Core + builtins and produce a simple cost model which can be used from Agda and other executables -} module PlutusCore.Evaluation.Machine.SimpleBuiltinCostModel ( BuiltinCostMap @@ -13,12 +12,15 @@ module PlutusCore.Evaluation.Machine.SimpleBuiltinCostModel , defaultSimpleBuiltinCostModel ) where +import Data.Aeson (ToJSON, encode) import Data.Aeson.Key as Key (toText) import Data.Aeson.KeyMap qualified as KeyMap -import Data.Aeson.THReader (readJSONFromFile) +import Data.Aeson.Types (parseEither, parseMaybe) import Data.Bifunctor +import Data.ByteString.Lazy qualified as BSL import Data.Text (Text, replace) -import PlutusCore.DataFilePaths qualified as DFP +import PlutusCore.Evaluation.Machine.BuiltinCostModel +import PlutusCore.Evaluation.Machine.CostModel.Generated.BuiltinCostModelC (builtinCostModelC) import PlutusCore.Evaluation.Machine.CostingFun.SimpleJSON type BuiltinCostMap = [(Text, CpuAndMemoryModel)] @@ -27,7 +29,11 @@ type BuiltinCostKeyMap = KeyMap.KeyMap CpuAndMemoryModel {-| The default builtin cost map. TODO: maybe we should take account of the semantic variant here. -} defaultBuiltinCostKeyMap :: BuiltinCostKeyMap -defaultBuiltinCostKeyMap = readJSONFromFile DFP.latestBuiltinCostModelFile +defaultBuiltinCostKeyMap = + -- Convert the Haskell cost model to JSON and then parse it as a KeyMap + case Data.Aeson.Types.parseEither KeyMap.parseJSON <$> Data.Aeson.decode (Data.Aeson.encode builtinCostModelC) of + Just (Right keyMap) -> keyMap + _ -> error "Failed to convert builtinCostModelC to KeyMap" -- replace underscores _ by dashes - builtinName :: Text -> Text From a2d2c154a8b7ab772227de247c2f2950c90ed183 Mon Sep 17 00:00:00 2001 From: zeme Date: Wed, 18 Feb 2026 15:33:09 +0100 Subject: [PATCH 5/7] wip --- .../cost-model/create-cost-model/Main.hs | 55 +++++++++++-------- plutus-core/plutus-core.cabal | 7 ++- .../CostModel/Generated/BuiltinCostModelA.hs | 2 +- .../CostModel/Generated/CekMachineCostsA.hs | 14 +---- .../CostModel/Generated/CekMachineCostsB.hs | 14 +---- .../CostModel/Generated/CekMachineCostsC.hs | 14 +---- .../Machine/SimpleBuiltinCostModel.hs | 6 +- 7 files changed, 41 insertions(+), 71 deletions(-) diff --git a/plutus-core/cost-model/create-cost-model/Main.hs b/plutus-core/cost-model/create-cost-model/Main.hs index 9e619c0e552..de4363eb0e6 100644 --- a/plutus-core/cost-model/create-cost-model/Main.hs +++ b/plutus-core/cost-model/create-cost-model/Main.hs @@ -3,6 +3,8 @@ module Main where import CreateBuiltinCostModel (createBuiltinCostModel) import PlutusCore.Evaluation.Machine.BuiltinCostModel (BuiltinCostModel) +import Data.Aeson.Encode.Pretty (Config (..), defConfig, encodePretty') +import Data.ByteString.Lazy.Char8 qualified as BSL import Data.Text qualified as T import Data.Text.IO qualified as T import Options.Applicative @@ -147,30 +149,36 @@ checkBenchmarkFile file = ++ "The default results file is plutus-core/cost-model/data/benching.csv." in checkInputFile file "benchmark results file" advice -writeOutput - :: Output -> T.Text -> IO () -writeOutput outp v = do +writeOutput :: Output -> BuiltinCostModel -> IO () +writeOutput outp model = do case outp of - NamedOutput file -> T.writeFile file v - StdOutput -> T.putStr v - -{-| Convert a BuiltinCostModel to a Haskell module. - The module exports a single value of type BuiltinCostModel. -} -costModelToHaskellModule :: FilePath -> BuiltinCostModel -> T.Text -costModelToHaskellModule basename model = - T.unlines - [ "-- This file is auto-generated by the generate-cost-model executable." - , "-- Do not edit this file manually." - , "{-# LANGUAGE RecordWildCards #-}" - , "{-# OPTIONS_GHC -Wno-missing-signatures #-}" - , "" - , "module PlutusCore.Evaluation.Machine.CostModel.Generated" <> modName <> " where" - , "" - , varName <> " = " <> T.pack (show model) - ] + NamedOutput modelName -> do + let (modulePath, moduleCode) = generateCostModelHaskellModule modelName model + T.writeFile modulePath moduleCode + StdOutput -> + BSL.putStr modelJson where - modName = T.pack (T.toTile basename) - varName = T.pack basename + modelJson = encodePretty' (defConfig {confCompare = \_ _ -> EQ}) model + +generateCostModelHaskellModule :: String -> BuiltinCostModel -> (FilePath, T.Text) +generateCostModelHaskellModule modelName model = (modulePath, moduleCode) + where + moduleName = T.toTitle (T.pack modelName) + modelExportName = T.pack modelName + modulePath = "plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/" <> T.unpack moduleName <> ".hs" + moduleCode = + T.unlines + [ T.pack "-- This file is auto-generated by the generate-cost-model executable." + , T.pack "-- Do not edit this file manually." + , T.pack "{-# LANGUAGE RecordWildCards #-}" + , T.pack "{-# OPTIONS_GHC -Wno-missing-signatures #-}" + , T.pack "" + , T.pack "module PlutusCore.Evaluation.Machine.CostModel.Generated." <> moduleName <> T.pack " (" <> modelExportName <> T.pack ") where" + , T.pack "" + , T.pack "import Data.Aeson" + , T.pack "" + , modelExportName <> T.pack " = " <> T.pack (show model) + ] main :: IO () main = do @@ -178,5 +186,4 @@ main = do checkBenchmarkFile bmfile checkRFile rfile model <- withEmbeddedR defaultConfig $ runRegion $ createBuiltinCostModel bmfile rfile - let hsModule = costModelToHaskellModule variant model - writeOutput out hsModule + writeOutput out model diff --git a/plutus-core/plutus-core.cabal b/plutus-core/plutus-core.cabal index deddef057ca..d19277c4afa 100644 --- a/plutus-core/plutus-core.cabal +++ b/plutus-core/plutus-core.cabal @@ -993,8 +993,11 @@ executable generate-cost-model buildable: False build-depends: + , aeson + , aeson-pretty , barbies , base >=4.9 && <5 + , bytestring , directory , filepath , inline-r >=1.0.1 @@ -1029,8 +1032,8 @@ benchmark cost-model-test -- This fails on Darwin with strange errors and I don't know why -- > Error: C stack usage 17556409549320 is too close to the limit -- > Fatal error: unable to initialize the JI - if os(osx) - buildable: False + -- if os(osx) + -- buildable: False -- Can't build on windows as it depends on R. if os(windows) diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/BuiltinCostModelA.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/BuiltinCostModelA.hs index 4df260a0cee..63f58a41c6f 100644 --- a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/BuiltinCostModelA.hs +++ b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/BuiltinCostModelA.hs @@ -1,6 +1,6 @@ -- This file is a placeholder for the generated builtin cost model for variant A. -- It needs to be regenerated by running the generate-cost-model executable. --- Run: cabal run plutus-core:generate-cost-model -- -o +-- Run: cabal run plutus-core:generate-cost-model -- -o builtinCostModelA {-# LANGUAGE RecordWildCards #-} module PlutusCore.Evaluation.Machine.CostModel.Generated.BuiltinCostModelA (builtinCostModelA) where diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsA.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsA.hs index d9f39a579ab..238e2b133d3 100644 --- a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsA.hs +++ b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsA.hs @@ -9,16 +9,4 @@ import PlutusCore.Evaluation.Machine.ExMemory import UntypedPlutusCore.Evaluation.Machine.Cek.CekMachineCosts cekMachineCostsA :: CekMachineCosts -cekMachineCostsA = - CekMachineCostsBase - { cekStartupCost = Identity (ExBudget 100 100) - , cekVarCost = Identity (ExBudget 23000 100) - , cekConstCost = Identity (ExBudget 23000 100) - , cekLamCost = Identity (ExBudget 23000 100) - , cekDelayCost = Identity (ExBudget 23000 100) - , cekForceCost = Identity (ExBudget 23000 100) - , cekApplyCost = Identity (ExBudget 23000 100) - , cekBuiltinCost = Identity (ExBudget 23000 100) - , cekConstrCost = Identity (ExBudget 23000 100) - , cekCaseCost = Identity (ExBudget 23000 100) - } +cekMachineCostsA = undefined diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsB.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsB.hs index f9b0634497d..8713f5c43b8 100644 --- a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsB.hs +++ b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsB.hs @@ -9,16 +9,4 @@ import PlutusCore.Evaluation.Machine.ExMemory import UntypedPlutusCore.Evaluation.Machine.Cek.CekMachineCosts cekMachineCostsB :: CekMachineCosts -cekMachineCostsB = - CekMachineCostsBase - { cekStartupCost = Identity (ExBudget 100 100) - , cekVarCost = Identity (ExBudget 16000 100) - , cekConstCost = Identity (ExBudget 16000 100) - , cekLamCost = Identity (ExBudget 16000 100) - , cekDelayCost = Identity (ExBudget 16000 100) - , cekForceCost = Identity (ExBudget 16000 100) - , cekApplyCost = Identity (ExBudget 16000 100) - , cekBuiltinCost = Identity (ExBudget 16000 100) - , cekConstrCost = Identity (ExBudget 16000 100) - , cekCaseCost = Identity (ExBudget 16000 100) - } +cekMachineCostsB = undefined diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsC.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsC.hs index 450d0308282..e8930d9e33b 100644 --- a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsC.hs +++ b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsC.hs @@ -9,16 +9,4 @@ import PlutusCore.Evaluation.Machine.ExMemory import UntypedPlutusCore.Evaluation.Machine.Cek.CekMachineCosts cekMachineCostsC :: CekMachineCosts -cekMachineCostsC = - CekMachineCostsBase - { cekStartupCost = Identity (ExBudget 100 100) - , cekVarCost = Identity (ExBudget 16000 100) - , cekConstCost = Identity (ExBudget 16000 100) - , cekLamCost = Identity (ExBudget 16000 100) - , cekDelayCost = Identity (ExBudget 16000 100) - , cekForceCost = Identity (ExBudget 16000 100) - , cekApplyCost = Identity (ExBudget 16000 100) - , cekBuiltinCost = Identity (ExBudget 16000 100) - , cekConstrCost = Identity (ExBudget 16000 100) - , cekCaseCost = Identity (ExBudget 16000 100) - } +cekMachineCostsC = undefined diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/SimpleBuiltinCostModel.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/SimpleBuiltinCostModel.hs index 006f872cb28..c1b4c5c4a35 100644 --- a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/SimpleBuiltinCostModel.hs +++ b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/SimpleBuiltinCostModel.hs @@ -29,11 +29,7 @@ type BuiltinCostKeyMap = KeyMap.KeyMap CpuAndMemoryModel {-| The default builtin cost map. TODO: maybe we should take account of the semantic variant here. -} defaultBuiltinCostKeyMap :: BuiltinCostKeyMap -defaultBuiltinCostKeyMap = - -- Convert the Haskell cost model to JSON and then parse it as a KeyMap - case Data.Aeson.Types.parseEither KeyMap.parseJSON <$> Data.Aeson.decode (Data.Aeson.encode builtinCostModelC) of - Just (Right keyMap) -> keyMap - _ -> error "Failed to convert builtinCostModelC to KeyMap" +defaultBuiltinCostKeyMap = undefined -- replace underscores _ by dashes - builtinName :: Text -> Text From e82a18df678ecacfa3d3c9820e5570f7c6a5334b Mon Sep 17 00:00:00 2001 From: zeme Date: Wed, 18 Feb 2026 15:39:41 +0100 Subject: [PATCH 6/7] wip --- .../cost-model/create-cost-model/Main.hs | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/plutus-core/cost-model/create-cost-model/Main.hs b/plutus-core/cost-model/create-cost-model/Main.hs index de4363eb0e6..5659ebd580e 100644 --- a/plutus-core/cost-model/create-cost-model/Main.hs +++ b/plutus-core/cost-model/create-cost-model/Main.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE OverloadedStrings #-} + module Main where import CreateBuiltinCostModel (createBuiltinCostModel) @@ -168,16 +170,16 @@ generateCostModelHaskellModule modelName model = (modulePath, moduleCode) modulePath = "plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/" <> T.unpack moduleName <> ".hs" moduleCode = T.unlines - [ T.pack "-- This file is auto-generated by the generate-cost-model executable." - , T.pack "-- Do not edit this file manually." - , T.pack "{-# LANGUAGE RecordWildCards #-}" - , T.pack "{-# OPTIONS_GHC -Wno-missing-signatures #-}" - , T.pack "" - , T.pack "module PlutusCore.Evaluation.Machine.CostModel.Generated." <> moduleName <> T.pack " (" <> modelExportName <> T.pack ") where" - , T.pack "" - , T.pack "import Data.Aeson" - , T.pack "" - , modelExportName <> T.pack " = " <> T.pack (show model) + [ "-- This file is auto-generated by the generate-cost-model executable." + , "-- Do not edit this file manually." + , "{-# LANGUAGE RecordWildCards #-}" + , "{-# OPTIONS_GHC -Wno-missing-signatures #-}" + , "" + , "module PlutusCore.Evaluation.Machine.CostModel.Generated." <> moduleName <> " (" <> modelExportName <> ") where" + , "" + , "import Data.Aeson" + , "" + , modelExportName <> " = " <> T.pack (show model) ] main :: IO () From 992d5e8ce7a225af8c71d97cb8ed38f7ef943940 Mon Sep 17 00:00:00 2001 From: zeme Date: Wed, 18 Feb 2026 19:13:12 +0000 Subject: [PATCH 7/7] wip --- .../cost-model/create-cost-model/Main.hs | 47 +- plutus-core/plutus-core.cabal | 24 +- .../src/PlutusCore/DataFilePaths.hs | 5 +- .../Machine/CostModel/BuiltinCostModelA.hs | 1002 ++++++++++++++++ .../Machine/CostModel/BuiltinCostModelB.hs | 1002 ++++++++++++++++ .../Machine/CostModel/BuiltinCostModelC.hs | 1020 +++++++++++++++++ .../Machine/CostModel/CekMachineCostsA.hs | 20 + .../Machine/CostModel/CekMachineCostsB.hs | 20 + .../Machine/CostModel/CekMachineCostsC.hs | 20 + .../CostModel/Generated/BuiltinCostModelA.hs | 11 - .../CostModel/Generated/BuiltinCostModelB.hs | 11 - .../CostModel/Generated/BuiltinCostModelC.hs | 11 - .../CostModel/Generated/CekMachineCostsA.hs | 12 - .../CostModel/Generated/CekMachineCostsB.hs | 12 - .../CostModel/Generated/CekMachineCostsC.hs | 12 - .../Evaluation/Machine/ExBudgetingDefaults.hs | 14 +- .../Machine/SimpleBuiltinCostModel.hs | 28 +- 17 files changed, 3153 insertions(+), 118 deletions(-) create mode 100644 plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/BuiltinCostModelA.hs create mode 100644 plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/BuiltinCostModelB.hs create mode 100644 plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/BuiltinCostModelC.hs create mode 100644 plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/CekMachineCostsA.hs create mode 100644 plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/CekMachineCostsB.hs create mode 100644 plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/CekMachineCostsC.hs delete mode 100644 plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/BuiltinCostModelA.hs delete mode 100644 plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/BuiltinCostModelB.hs delete mode 100644 plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/BuiltinCostModelC.hs delete mode 100644 plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsA.hs delete mode 100644 plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsB.hs delete mode 100644 plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsC.hs diff --git a/plutus-core/cost-model/create-cost-model/Main.hs b/plutus-core/cost-model/create-cost-model/Main.hs index 5659ebd580e..794c6e4a86d 100644 --- a/plutus-core/cost-model/create-cost-model/Main.hs +++ b/plutus-core/cost-model/create-cost-model/Main.hs @@ -5,15 +5,17 @@ module Main where import CreateBuiltinCostModel (createBuiltinCostModel) import PlutusCore.Evaluation.Machine.BuiltinCostModel (BuiltinCostModel) +import Data.Aeson import Data.Aeson.Encode.Pretty (Config (..), defConfig, encodePretty') import Data.ByteString.Lazy.Char8 qualified as BSL +import Data.Char (toLower) import Data.Text qualified as T import Data.Text.IO qualified as T import Options.Applicative import System.Directory import System.Exit -import System.FilePath import System.IO (hPutStrLn, stderr) +import Text.Show.Pretty (ppShow) import Language.R (defaultConfig, runRegion, withEmbeddedR) @@ -86,8 +88,8 @@ fileOutput = <$> strOption ( long "output" <> short 'o' - <> metavar "BASENAME" - <> help "Output basename, e.g. builtinCostModelA or cekMachineCostsB, will be places in PlutusCore/Evaluation/Machine/CostModel/Generated" + <> metavar "MODULENAME" + <> help "Output Haskell module name, e.g. BuiltinCostModelA, will be placed under PlutusCore/Evaluation/Machine/CostModel/Generated" ) stdOutput :: Parser Output @@ -154,8 +156,8 @@ checkBenchmarkFile file = writeOutput :: Output -> BuiltinCostModel -> IO () writeOutput outp model = do case outp of - NamedOutput modelName -> do - let (modulePath, moduleCode) = generateCostModelHaskellModule modelName model + NamedOutput moduleName -> do + let (modulePath, moduleCode) = generateCostModelHaskellModule moduleName model T.writeFile modulePath moduleCode StdOutput -> BSL.putStr modelJson @@ -163,29 +165,38 @@ writeOutput outp model = do modelJson = encodePretty' (defConfig {confCompare = \_ _ -> EQ}) model generateCostModelHaskellModule :: String -> BuiltinCostModel -> (FilePath, T.Text) -generateCostModelHaskellModule modelName model = (modulePath, moduleCode) +generateCostModelHaskellModule moduleName model = (modulePath, moduleCode) where - moduleName = T.toTitle (T.pack modelName) - modelExportName = T.pack modelName - modulePath = "plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/" <> T.unpack moduleName <> ".hs" + modulePath = "plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/" <> moduleName <> ".hs" + modelId = T.pack (toLowerFirstCharOnly moduleName) moduleCode = T.unlines [ "-- This file is auto-generated by the generate-cost-model executable." , "-- Do not edit this file manually." - , "{-# LANGUAGE RecordWildCards #-}" - , "{-# OPTIONS_GHC -Wno-missing-signatures #-}" , "" - , "module PlutusCore.Evaluation.Machine.CostModel.Generated." <> moduleName <> " (" <> modelExportName <> ") where" + , "module PlutusCore.Evaluation.Machine.CostModel." <> T.pack moduleName <> " (" <> modelId <> ") where" , "" - , "import Data.Aeson" + , "import PlutusCore.Evaluation.Machine.BuiltinCostModel" , "" - , modelExportName <> " = " <> T.pack (show model) + , modelId <> " :: BuiltinCostModel" + , modelId <> " = " <> T.pack (ppShow model) ] + toLowerFirstCharOnly :: String -> String + toLowerFirstCharOnly "" = "" + toLowerFirstCharOnly (c : cs) = toLower c : cs + main :: IO () main = do (BenchmarkFile bmfile, RFile rfile, out) <- execParser arguments - checkBenchmarkFile bmfile - checkRFile rfile - model <- withEmbeddedR defaultConfig $ runRegion $ createBuiltinCostModel bmfile rfile - writeOutput out model + -- checkBenchmarkFile bmfile + -- checkRFile rfile + -- model <- withEmbeddedR defaultConfig $ runRegion $ createBuiltinCostModel bmfile rfile + -- writeOutput out model + case out of + NamedOutput moduleName -> do + model <- eitherDecodeFileStrict ("plutus-core/cost-model/data/builtinCostModelA.json") + case model of + Left err -> putStrLn err + Right model' -> writeOutput out model' + _ -> undefined diff --git a/plutus-core/plutus-core.cabal b/plutus-core/plutus-core.cabal index d19277c4afa..cd7534a349d 100644 --- a/plutus-core/plutus-core.cabal +++ b/plutus-core/plutus-core.cabal @@ -24,7 +24,6 @@ extra-doc-files: extra-source-files: cost-model/data/*.csv cost-model/data/*.R - plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/*.hs plutus-core/test/CostModelInterface/defaultCostModelParams.json source-repository head @@ -132,12 +131,12 @@ library PlutusCore.Evaluation.Machine.CostingFun.Core PlutusCore.Evaluation.Machine.CostingFun.JSON PlutusCore.Evaluation.Machine.CostingFun.SimpleJSON - PlutusCore.Evaluation.Machine.CostModel.Generated.BuiltinCostModelA - PlutusCore.Evaluation.Machine.CostModel.Generated.BuiltinCostModelB - PlutusCore.Evaluation.Machine.CostModel.Generated.BuiltinCostModelC - PlutusCore.Evaluation.Machine.CostModel.Generated.CekMachineCostsA - PlutusCore.Evaluation.Machine.CostModel.Generated.CekMachineCostsB - PlutusCore.Evaluation.Machine.CostModel.Generated.CekMachineCostsC + PlutusCore.Evaluation.Machine.CostModel.BuiltinCostModelA + PlutusCore.Evaluation.Machine.CostModel.BuiltinCostModelB + PlutusCore.Evaluation.Machine.CostModel.BuiltinCostModelC + PlutusCore.Evaluation.Machine.CostModel.CekMachineCostsA + PlutusCore.Evaluation.Machine.CostModel.CekMachineCostsB + PlutusCore.Evaluation.Machine.CostModel.CekMachineCostsC PlutusCore.Evaluation.Machine.CostModelInterface PlutusCore.Evaluation.Machine.CostStream PlutusCore.Evaluation.Machine.ExBudget @@ -985,8 +984,8 @@ executable generate-cost-model -- This fails on Darwin with strange errors and I don't know why -- > Error: C stack usage 17556409549320 is too close to the limit -- > Fatal error: unable to initialize the JI - -- if os(osx) - -- buildable: False + if os(osx) + buildable: False -- Can't build on windows as it depends on R. if os(windows) @@ -999,13 +998,12 @@ executable generate-cost-model , base >=4.9 && <5 , bytestring , directory - , filepath , inline-r >=1.0.1 , optparse-applicative , plutus-core ^>=1.58 + , pretty-show , text - -- , exceptions other-modules: BuiltinMemoryModels CreateBuiltinCostModel @@ -1032,8 +1030,8 @@ benchmark cost-model-test -- This fails on Darwin with strange errors and I don't know why -- > Error: C stack usage 17556409549320 is too close to the limit -- > Fatal error: unable to initialize the JI - -- if os(osx) - -- buildable: False + if os(osx) + buildable: False -- Can't build on windows as it depends on R. if os(windows) diff --git a/plutus-core/plutus-core/src/PlutusCore/DataFilePaths.hs b/plutus-core/plutus-core/src/PlutusCore/DataFilePaths.hs index fc22ae1d491..379005a54a1 100644 --- a/plutus-core/plutus-core/src/PlutusCore/DataFilePaths.hs +++ b/plutus-core/plutus-core/src/PlutusCore/DataFilePaths.hs @@ -1,9 +1,8 @@ {-| Various file paths used in plutus-core. These paths are primarily used for testing and benchmarking. Cost models are embedded as Haskell modules in - PlutusCore.Evaluation.Machine.CostModel.Generated.* -} -module PlutusCore.DataFilePaths -where + PlutusCore.Evaluation.Machine.CostModel.* -} +module PlutusCore.DataFilePaths where import System.FilePath diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/BuiltinCostModelA.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/BuiltinCostModelA.hs new file mode 100644 index 00000000000..fd9a5a904a3 --- /dev/null +++ b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/BuiltinCostModelA.hs @@ -0,0 +1,1002 @@ +-- This file is auto-generated by the generate-cost-model executable. +-- Do not edit this file manually. + +module PlutusCore.Evaluation.Machine.CostModel.BuiltinCostModelA (builtinCostModelA) where + +import PlutusCore.Evaluation.Machine.BuiltinCostModel + +builtinCostModelA :: BuiltinCostModel +builtinCostModelA = + BuiltinCostModelBase + { paramAddInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsMaxSize + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 205665 + , oneVariableLinearFunctionSlope = 812 + } + , costingFunMemory = + ModelTwoArgumentsMaxSize + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramSubtractInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsMaxSize + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 205665 + , oneVariableLinearFunctionSlope = 812 + } + , costingFunMemory = + ModelTwoArgumentsMaxSize + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramMultiplyInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsAddedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 69522 + , oneVariableLinearFunctionSlope = 11687 + } + , costingFunMemory = + ModelTwoArgumentsAddedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramDivideInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsConstAboveDiagonal + ModelConstantOrTwoArguments + { modelConstantOrTwoArgumentsConstant = 196500 + , modelConstantOrTwoArgumentsModel = + ModelTwoArgumentsMultipliedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 453240 + , oneVariableLinearFunctionSlope = 220 + } + } + , costingFunMemory = + ModelTwoArgumentsSubtractedSizes + ModelSubtractedSizes + { modelSubtractedSizesIntercept = 0 + , modelSubtractedSizesSlope = 1 + , modelSubtractedSizesMinimum = 1 + } + } + , paramQuotientInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsConstAboveDiagonal + ModelConstantOrTwoArguments + { modelConstantOrTwoArgumentsConstant = 196500 + , modelConstantOrTwoArgumentsModel = + ModelTwoArgumentsMultipliedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 453240 + , oneVariableLinearFunctionSlope = 220 + } + } + , costingFunMemory = + ModelTwoArgumentsSubtractedSizes + ModelSubtractedSizes + { modelSubtractedSizesIntercept = 0 + , modelSubtractedSizesSlope = 1 + , modelSubtractedSizesMinimum = 1 + } + } + , paramRemainderInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsConstAboveDiagonal + ModelConstantOrTwoArguments + { modelConstantOrTwoArgumentsConstant = 196500 + , modelConstantOrTwoArgumentsModel = + ModelTwoArgumentsMultipliedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 453240 + , oneVariableLinearFunctionSlope = 220 + } + } + , costingFunMemory = + ModelTwoArgumentsSubtractedSizes + ModelSubtractedSizes + { modelSubtractedSizesIntercept = 0 + , modelSubtractedSizesSlope = 1 + , modelSubtractedSizesMinimum = 1 + } + } + , paramModInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsConstAboveDiagonal + ModelConstantOrTwoArguments + { modelConstantOrTwoArgumentsConstant = 196500 + , modelConstantOrTwoArgumentsModel = + ModelTwoArgumentsMultipliedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 453240 + , oneVariableLinearFunctionSlope = 220 + } + } + , costingFunMemory = + ModelTwoArgumentsSubtractedSizes + ModelSubtractedSizes + { modelSubtractedSizesIntercept = 0 + , modelSubtractedSizesSlope = 1 + , modelSubtractedSizesMinimum = 1 + } + } + , paramEqualsInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsMinSize + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 208512 + , oneVariableLinearFunctionSlope = 421 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramLessThanInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsMinSize + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 208896 + , oneVariableLinearFunctionSlope = 511 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramLessThanEqualsInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsMinSize + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 204924 + , oneVariableLinearFunctionSlope = 473 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramAppendByteString = + CostingFun + { costingFunCpu = + ModelTwoArgumentsAddedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1000 + , oneVariableLinearFunctionSlope = 571 + } + , costingFunMemory = + ModelTwoArgumentsAddedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramConsByteString = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInY + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 221973 + , oneVariableLinearFunctionSlope = 511 + } + , costingFunMemory = + ModelTwoArgumentsAddedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramSliceByteString = + CostingFun + { costingFunCpu = + ModelThreeArgumentsLinearInZ + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 265318 + , oneVariableLinearFunctionSlope = 0 + } + , costingFunMemory = + ModelThreeArgumentsLinearInZ + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 4 + , oneVariableLinearFunctionSlope = 0 + } + } + , paramLengthOfByteString = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 1000 + , costingFunMemory = ModelOneArgumentConstantCost 10 + } + , paramIndexByteString = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 57667 + , costingFunMemory = ModelTwoArgumentsConstantCost 4 + } + , paramEqualsByteString = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearOnDiagonal + ModelConstantOrLinear + { modelConstantOrLinearConstant = 245000 + , modelConstantOrLinearIntercept = 216773 + , modelConstantOrLinearSlope = 62 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramLessThanByteString = + CostingFun + { costingFunCpu = + ModelTwoArgumentsMinSize + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 197145 + , oneVariableLinearFunctionSlope = 156 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramLessThanEqualsByteString = + CostingFun + { costingFunCpu = + ModelTwoArgumentsMinSize + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 197145 + , oneVariableLinearFunctionSlope = 156 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramSha2_256 = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 806990 + , oneVariableLinearFunctionSlope = 30482 + } + , costingFunMemory = ModelOneArgumentConstantCost 4 + } + , paramSha3_256 = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1927926 + , oneVariableLinearFunctionSlope = 82523 + } + , costingFunMemory = ModelOneArgumentConstantCost 4 + } + , paramBlake2b_256 = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 117366 + , oneVariableLinearFunctionSlope = 10475 + } + , costingFunMemory = ModelOneArgumentConstantCost 4 + } + , paramVerifyEd25519Signature = + CostingFun + { costingFunCpu = + ModelThreeArgumentsLinearInZ + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 57996947 + , oneVariableLinearFunctionSlope = 18975 + } + , costingFunMemory = ModelThreeArgumentsConstantCost 10 + } + , paramVerifyEcdsaSecp256k1Signature = + CostingFun + { costingFunCpu = ModelThreeArgumentsConstantCost 35190005 + , costingFunMemory = ModelThreeArgumentsConstantCost 10 + } + , paramVerifySchnorrSecp256k1Signature = + CostingFun + { costingFunCpu = + ModelThreeArgumentsLinearInY + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 39121781 + , oneVariableLinearFunctionSlope = 32260 + } + , costingFunMemory = ModelThreeArgumentsConstantCost 10 + } + , paramAppendString = + CostingFun + { costingFunCpu = + ModelTwoArgumentsAddedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1000 + , oneVariableLinearFunctionSlope = 24177 + } + , costingFunMemory = + ModelTwoArgumentsAddedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 4 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramEqualsString = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearOnDiagonal + ModelConstantOrLinear + { modelConstantOrLinearConstant = 187000 + , modelConstantOrLinearIntercept = 1000 + , modelConstantOrLinearSlope = 52998 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramEncodeUtf8 = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1000 + , oneVariableLinearFunctionSlope = 28662 + } + , costingFunMemory = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 4 + , oneVariableLinearFunctionSlope = 2 + } + } + , paramDecodeUtf8 = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 497525 + , oneVariableLinearFunctionSlope = 14068 + } + , costingFunMemory = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 4 + , oneVariableLinearFunctionSlope = 2 + } + } + , paramIfThenElse = + CostingFun + { costingFunCpu = ModelThreeArgumentsConstantCost 80556 + , costingFunMemory = ModelThreeArgumentsConstantCost 1 + } + , paramChooseUnit = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 46417 + , costingFunMemory = ModelTwoArgumentsConstantCost 4 + } + , paramTrace = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 212342 + , costingFunMemory = ModelTwoArgumentsConstantCost 32 + } + , paramFstPair = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 80436 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramSndPair = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 85931 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramChooseList = + CostingFun + { costingFunCpu = ModelThreeArgumentsConstantCost 175354 + , costingFunMemory = ModelThreeArgumentsConstantCost 32 + } + , paramMkCons = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 65493 + , costingFunMemory = ModelTwoArgumentsConstantCost 32 + } + , paramHeadList = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 43249 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramTailList = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 41182 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramNullList = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 60091 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramChooseData = + CostingFun + { costingFunCpu = ModelSixArgumentsConstantCost 19537 + , costingFunMemory = ModelSixArgumentsConstantCost 32 + } + , paramConstrData = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 89141 + , costingFunMemory = ModelTwoArgumentsConstantCost 32 + } + , paramMapData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 64832 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramListData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 52467 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramIData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 1000 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramBData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 1000 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramUnConstrData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 32696 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramUnMapData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 38314 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramUnListData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 32247 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramUnIData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 43357 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramUnBData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 31220 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramEqualsData = + CostingFun + { costingFunCpu = + ModelTwoArgumentsMinSize + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1060367 + , oneVariableLinearFunctionSlope = 12586 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramMkPairData = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 76511 + , costingFunMemory = ModelTwoArgumentsConstantCost 32 + } + , paramMkNilData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 22558 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramMkNilPairData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 16563 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramSerialiseData = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1159724 + , oneVariableLinearFunctionSlope = 392670 + } + , costingFunMemory = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 2 + } + } + , paramBls12_381_G1_add = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 962335 + , costingFunMemory = ModelTwoArgumentsConstantCost 18 + } + , paramBls12_381_G1_neg = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 267929 + , costingFunMemory = ModelOneArgumentConstantCost 18 + } + , paramBls12_381_G1_scalarMul = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 76433006 + , oneVariableLinearFunctionSlope = 8868 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 18 + } + , paramBls12_381_G1_multiScalarMul = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 321837444 + , oneVariableLinearFunctionSlope = 25087669 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 18 + } + , paramBls12_381_G1_equal = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 442008 + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramBls12_381_G1_compress = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 2780678 + , costingFunMemory = ModelOneArgumentConstantCost 6 + } + , paramBls12_381_G1_uncompress = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 52948122 + , costingFunMemory = ModelOneArgumentConstantCost 18 + } + , paramBls12_381_G1_hashToGroup = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 52538055 + , oneVariableLinearFunctionSlope = 3756 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 18 + } + , paramBls12_381_G2_add = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 1995836 + , costingFunMemory = ModelTwoArgumentsConstantCost 36 + } + , paramBls12_381_G2_neg = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 284546 + , costingFunMemory = ModelOneArgumentConstantCost 36 + } + , paramBls12_381_G2_scalarMul = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 158221314 + , oneVariableLinearFunctionSlope = 26549 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 36 + } + , paramBls12_381_G2_equal = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 901022 + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramBls12_381_G2_multiScalarMul = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 617887431 + , oneVariableLinearFunctionSlope = 67302824 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 36 + } + , paramBls12_381_G2_compress = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 3227919 + , costingFunMemory = ModelOneArgumentConstantCost 12 + } + , paramBls12_381_G2_uncompress = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 74698472 + , costingFunMemory = ModelOneArgumentConstantCost 36 + } + , paramBls12_381_G2_hashToGroup = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 166917843 + , oneVariableLinearFunctionSlope = 4307 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 36 + } + , paramBls12_381_millerLoop = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 254006273 + , costingFunMemory = ModelTwoArgumentsConstantCost 72 + } + , paramBls12_381_mulMlResult = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 2174038 + , costingFunMemory = ModelTwoArgumentsConstantCost 72 + } + , paramBls12_381_finalVerify = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 333849714 + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramKeccak_256 = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 2261318 + , oneVariableLinearFunctionSlope = 64571 + } + , costingFunMemory = ModelOneArgumentConstantCost 4 + } + , paramBlake2b_224 = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 207616 + , oneVariableLinearFunctionSlope = 8310 + } + , costingFunMemory = ModelOneArgumentConstantCost 4 + } + , paramIntegerToByteString = + CostingFun + { costingFunCpu = + ModelThreeArgumentsQuadraticInZ + OneVariableQuadraticFunction + { oneVariableQuadraticFunctionC0 = 1293828 + , oneVariableQuadraticFunctionC1 = 28716 + , oneVariableQuadraticFunctionC2 = 63 + } + , costingFunMemory = + ModelThreeArgumentsLiteralInYOrLinearInZ + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramByteStringToInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsQuadraticInY + OneVariableQuadraticFunction + { oneVariableQuadraticFunctionC0 = 1006041 + , oneVariableQuadraticFunctionC1 = 43623 + , oneVariableQuadraticFunctionC2 = 251 + } + , costingFunMemory = + ModelTwoArgumentsLinearInY + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramAndByteString = + CostingFun + { costingFunCpu = + ModelThreeArgumentsLinearInYAndZ + TwoVariableLinearFunction + { twoVariableLinearFunctionIntercept = 100181 + , twoVariableLinearFunctionSlope1 = 726 + , twoVariableLinearFunctionSlope2 = 719 + } + , costingFunMemory = + ModelThreeArgumentsLinearInMaxYZ + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramOrByteString = + CostingFun + { costingFunCpu = + ModelThreeArgumentsLinearInYAndZ + TwoVariableLinearFunction + { twoVariableLinearFunctionIntercept = 100181 + , twoVariableLinearFunctionSlope1 = 726 + , twoVariableLinearFunctionSlope2 = 719 + } + , costingFunMemory = + ModelThreeArgumentsLinearInMaxYZ + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramXorByteString = + CostingFun + { costingFunCpu = + ModelThreeArgumentsLinearInYAndZ + TwoVariableLinearFunction + { twoVariableLinearFunctionIntercept = 100181 + , twoVariableLinearFunctionSlope1 = 726 + , twoVariableLinearFunctionSlope2 = 719 + } + , costingFunMemory = + ModelThreeArgumentsLinearInMaxYZ + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramComplementByteString = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 107878 + , oneVariableLinearFunctionSlope = 680 + } + , costingFunMemory = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramReadBit = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 95336 + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramWriteBits = + CostingFun + { costingFunCpu = + ModelThreeArgumentsLinearInY + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 281145 + , oneVariableLinearFunctionSlope = 18848 + } + , costingFunMemory = + ModelThreeArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramReplicateByte = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 180194 + , oneVariableLinearFunctionSlope = 159 + } + , costingFunMemory = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramShiftByteString = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 158519 + , oneVariableLinearFunctionSlope = 8942 + } + , costingFunMemory = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramRotateByteString = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 159378 + , oneVariableLinearFunctionSlope = 8813 + } + , costingFunMemory = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramCountSetBits = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 107490 + , oneVariableLinearFunctionSlope = 3298 + } + , costingFunMemory = ModelOneArgumentConstantCost 1 + } + , paramFindFirstSetBit = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 106057 + , oneVariableLinearFunctionSlope = 655 + } + , costingFunMemory = ModelOneArgumentConstantCost 1 + } + , paramRipemd_160 = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1964219 + , oneVariableLinearFunctionSlope = 24520 + } + , costingFunMemory = ModelOneArgumentConstantCost 3 + } + , paramExpModInteger = + CostingFun + { costingFunCpu = + ModelThreeArgumentsExpModCost + ExpModCostingFunction + { coefficient00 = 607153 + , coefficient11 = 231697 + , coefficient12 = 53144 + } + , costingFunMemory = + ModelThreeArgumentsLinearInZ + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramDropList = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 116711 + , oneVariableLinearFunctionSlope = 1957 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 4 + } + , paramLengthOfArray = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 231883 + , costingFunMemory = ModelOneArgumentConstantCost 10 + } + , paramListToArray = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1000 + , oneVariableLinearFunctionSlope = 24838 + } + , costingFunMemory = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 7 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramIndexArray = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 232010 + , costingFunMemory = ModelTwoArgumentsConstantCost 32 + } + , paramLookupCoin = + CostingFun + { costingFunCpu = + ModelThreeArgumentsLinearInZ + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 219951 + , oneVariableLinearFunctionSlope = 9444 + } + , costingFunMemory = ModelThreeArgumentsConstantCost 1 + } + , paramValueContains = + CostingFun + { costingFunCpu = + ModelTwoArgumentsConstAboveDiagonal + ModelConstantOrTwoArguments + { modelConstantOrTwoArgumentsConstant = 213283 + , modelConstantOrTwoArgumentsModel = + ModelTwoArgumentsLinearInXAndY + TwoVariableLinearFunction + { twoVariableLinearFunctionIntercept = 618401 + , twoVariableLinearFunctionSlope1 = 1998 + , twoVariableLinearFunctionSlope2 = 28258 + } + } + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramValueData = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1000 + , oneVariableLinearFunctionSlope = 38159 + } + , costingFunMemory = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 2 + , oneVariableLinearFunctionSlope = 22 + } + } + , paramUnValueData = + CostingFun + { costingFunCpu = + ModelOneArgumentQuadraticInX + OneVariableQuadraticFunction + { oneVariableQuadraticFunctionC0 = 1000 + , oneVariableQuadraticFunctionC1 = 95933 + , oneVariableQuadraticFunctionC2 = 1 + } + , costingFunMemory = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 11 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramInsertCoin = + CostingFun + { costingFunCpu = + ModelFourArgumentsLinearInU + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 356924 + , oneVariableLinearFunctionSlope = 18413 + } + , costingFunMemory = + ModelFourArgumentsLinearInU + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 45 + , oneVariableLinearFunctionSlope = 21 + } + } + , paramUnionValue = + CostingFun + { costingFunCpu = + ModelTwoArgumentsWithInteractionInXAndY + TwoVariableWithInteractionFunction + { twoVariableWithInteractionFunctionC00 = 1000 + , twoVariableWithInteractionFunctionC10 = 172116 + , twoVariableWithInteractionFunctionC01 = 183150 + , twoVariableWithInteractionFunctionC11 = 6 + } + , costingFunMemory = + ModelTwoArgumentsAddedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 24 + , oneVariableLinearFunctionSlope = 21 + } + } + , paramScaleValue = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInY + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1000 + , oneVariableLinearFunctionSlope = 277577 + } + , costingFunMemory = + ModelTwoArgumentsLinearInY + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 12 + , oneVariableLinearFunctionSlope = 21 + } + } + } diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/BuiltinCostModelB.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/BuiltinCostModelB.hs new file mode 100644 index 00000000000..fd1c7ad83d0 --- /dev/null +++ b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/BuiltinCostModelB.hs @@ -0,0 +1,1002 @@ +-- This file is auto-generated by the generate-cost-model executable. +-- Do not edit this file manually. + +module PlutusCore.Evaluation.Machine.CostModel.BuiltinCostModelB (builtinCostModelB) where + +import PlutusCore.Evaluation.Machine.BuiltinCostModel + +builtinCostModelB :: BuiltinCostModel +builtinCostModelB = + BuiltinCostModelBase + { paramAddInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsMaxSize + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 100788 + , oneVariableLinearFunctionSlope = 420 + } + , costingFunMemory = + ModelTwoArgumentsMaxSize + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramSubtractInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsMaxSize + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 100788 + , oneVariableLinearFunctionSlope = 420 + } + , costingFunMemory = + ModelTwoArgumentsMaxSize + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramMultiplyInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsMultipliedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 90434 + , oneVariableLinearFunctionSlope = 519 + } + , costingFunMemory = + ModelTwoArgumentsAddedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramDivideInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsConstAboveDiagonal + ModelConstantOrTwoArguments + { modelConstantOrTwoArgumentsConstant = 85848 + , modelConstantOrTwoArgumentsModel = + ModelTwoArgumentsMultipliedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 228465 + , oneVariableLinearFunctionSlope = 122 + } + } + , costingFunMemory = + ModelTwoArgumentsSubtractedSizes + ModelSubtractedSizes + { modelSubtractedSizesIntercept = 0 + , modelSubtractedSizesSlope = 1 + , modelSubtractedSizesMinimum = 1 + } + } + , paramQuotientInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsConstAboveDiagonal + ModelConstantOrTwoArguments + { modelConstantOrTwoArgumentsConstant = 85848 + , modelConstantOrTwoArgumentsModel = + ModelTwoArgumentsMultipliedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 228465 + , oneVariableLinearFunctionSlope = 122 + } + } + , costingFunMemory = + ModelTwoArgumentsSubtractedSizes + ModelSubtractedSizes + { modelSubtractedSizesIntercept = 0 + , modelSubtractedSizesSlope = 1 + , modelSubtractedSizesMinimum = 1 + } + } + , paramRemainderInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsConstAboveDiagonal + ModelConstantOrTwoArguments + { modelConstantOrTwoArgumentsConstant = 85848 + , modelConstantOrTwoArgumentsModel = + ModelTwoArgumentsMultipliedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 228465 + , oneVariableLinearFunctionSlope = 122 + } + } + , costingFunMemory = + ModelTwoArgumentsSubtractedSizes + ModelSubtractedSizes + { modelSubtractedSizesIntercept = 0 + , modelSubtractedSizesSlope = 1 + , modelSubtractedSizesMinimum = 1 + } + } + , paramModInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsConstAboveDiagonal + ModelConstantOrTwoArguments + { modelConstantOrTwoArgumentsConstant = 85848 + , modelConstantOrTwoArgumentsModel = + ModelTwoArgumentsMultipliedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 228465 + , oneVariableLinearFunctionSlope = 122 + } + } + , costingFunMemory = + ModelTwoArgumentsSubtractedSizes + ModelSubtractedSizes + { modelSubtractedSizesIntercept = 0 + , modelSubtractedSizesSlope = 1 + , modelSubtractedSizesMinimum = 1 + } + } + , paramEqualsInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsMinSize + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 51775 + , oneVariableLinearFunctionSlope = 558 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramLessThanInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsMinSize + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 44749 + , oneVariableLinearFunctionSlope = 541 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramLessThanEqualsInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsMinSize + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 43285 + , oneVariableLinearFunctionSlope = 552 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramAppendByteString = + CostingFun + { costingFunCpu = + ModelTwoArgumentsAddedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1000 + , oneVariableLinearFunctionSlope = 173 + } + , costingFunMemory = + ModelTwoArgumentsAddedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramConsByteString = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInY + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 72010 + , oneVariableLinearFunctionSlope = 178 + } + , costingFunMemory = + ModelTwoArgumentsAddedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramSliceByteString = + CostingFun + { costingFunCpu = + ModelThreeArgumentsLinearInZ + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 20467 + , oneVariableLinearFunctionSlope = 1 + } + , costingFunMemory = + ModelThreeArgumentsLinearInZ + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 4 + , oneVariableLinearFunctionSlope = 0 + } + } + , paramLengthOfByteString = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 22100 + , costingFunMemory = ModelOneArgumentConstantCost 10 + } + , paramIndexByteString = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 13169 + , costingFunMemory = ModelTwoArgumentsConstantCost 4 + } + , paramEqualsByteString = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearOnDiagonal + ModelConstantOrLinear + { modelConstantOrLinearConstant = 24548 + , modelConstantOrLinearIntercept = 29498 + , modelConstantOrLinearSlope = 38 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramLessThanByteString = + CostingFun + { costingFunCpu = + ModelTwoArgumentsMinSize + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 28999 + , oneVariableLinearFunctionSlope = 74 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramLessThanEqualsByteString = + CostingFun + { costingFunCpu = + ModelTwoArgumentsMinSize + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 28999 + , oneVariableLinearFunctionSlope = 74 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramSha2_256 = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 270652 + , oneVariableLinearFunctionSlope = 22588 + } + , costingFunMemory = ModelOneArgumentConstantCost 4 + } + , paramSha3_256 = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1457325 + , oneVariableLinearFunctionSlope = 64566 + } + , costingFunMemory = ModelOneArgumentConstantCost 4 + } + , paramBlake2b_256 = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 201305 + , oneVariableLinearFunctionSlope = 8356 + } + , costingFunMemory = ModelOneArgumentConstantCost 4 + } + , paramVerifyEd25519Signature = + CostingFun + { costingFunCpu = + ModelThreeArgumentsLinearInY + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 53384111 + , oneVariableLinearFunctionSlope = 14333 + } + , costingFunMemory = ModelThreeArgumentsConstantCost 10 + } + , paramVerifyEcdsaSecp256k1Signature = + CostingFun + { costingFunCpu = ModelThreeArgumentsConstantCost 43053543 + , costingFunMemory = ModelThreeArgumentsConstantCost 10 + } + , paramVerifySchnorrSecp256k1Signature = + CostingFun + { costingFunCpu = + ModelThreeArgumentsLinearInY + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 43574283 + , oneVariableLinearFunctionSlope = 26308 + } + , costingFunMemory = ModelThreeArgumentsConstantCost 10 + } + , paramAppendString = + CostingFun + { costingFunCpu = + ModelTwoArgumentsAddedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1000 + , oneVariableLinearFunctionSlope = 59957 + } + , costingFunMemory = + ModelTwoArgumentsAddedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 4 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramEqualsString = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearOnDiagonal + ModelConstantOrLinear + { modelConstantOrLinearConstant = 39184 + , modelConstantOrLinearIntercept = 1000 + , modelConstantOrLinearSlope = 60594 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramEncodeUtf8 = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1000 + , oneVariableLinearFunctionSlope = 42921 + } + , costingFunMemory = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 4 + , oneVariableLinearFunctionSlope = 2 + } + } + , paramDecodeUtf8 = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 91189 + , oneVariableLinearFunctionSlope = 769 + } + , costingFunMemory = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 4 + , oneVariableLinearFunctionSlope = 2 + } + } + , paramIfThenElse = + CostingFun + { costingFunCpu = ModelThreeArgumentsConstantCost 76049 + , costingFunMemory = ModelThreeArgumentsConstantCost 1 + } + , paramChooseUnit = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 61462 + , costingFunMemory = ModelTwoArgumentsConstantCost 4 + } + , paramTrace = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 59498 + , costingFunMemory = ModelTwoArgumentsConstantCost 32 + } + , paramFstPair = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 141895 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramSndPair = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 141992 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramChooseList = + CostingFun + { costingFunCpu = ModelThreeArgumentsConstantCost 132994 + , costingFunMemory = ModelThreeArgumentsConstantCost 32 + } + , paramMkCons = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 72362 + , costingFunMemory = ModelTwoArgumentsConstantCost 32 + } + , paramHeadList = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 83150 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramTailList = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 81663 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramNullList = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 74433 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramChooseData = + CostingFun + { costingFunCpu = ModelSixArgumentsConstantCost 94375 + , costingFunMemory = ModelSixArgumentsConstantCost 32 + } + , paramConstrData = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 22151 + , costingFunMemory = ModelTwoArgumentsConstantCost 32 + } + , paramMapData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 68246 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramListData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 33852 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramIData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 15299 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramBData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 11183 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramUnConstrData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 24588 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramUnMapData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 24623 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramUnListData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 25933 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramUnIData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 20744 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramUnBData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 20142 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramEqualsData = + CostingFun + { costingFunCpu = + ModelTwoArgumentsMinSize + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 898148 + , oneVariableLinearFunctionSlope = 27279 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramMkPairData = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 11546 + , costingFunMemory = ModelTwoArgumentsConstantCost 32 + } + , paramMkNilData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 7243 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramMkNilPairData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 7391 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramSerialiseData = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 955506 + , oneVariableLinearFunctionSlope = 213312 + } + , costingFunMemory = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 2 + } + } + , paramBls12_381_G1_add = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 962335 + , costingFunMemory = ModelTwoArgumentsConstantCost 18 + } + , paramBls12_381_G1_neg = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 267929 + , costingFunMemory = ModelOneArgumentConstantCost 18 + } + , paramBls12_381_G1_scalarMul = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 76433006 + , oneVariableLinearFunctionSlope = 8868 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 18 + } + , paramBls12_381_G1_multiScalarMul = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 321837444 + , oneVariableLinearFunctionSlope = 25087669 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 18 + } + , paramBls12_381_G1_equal = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 442008 + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramBls12_381_G1_compress = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 2780678 + , costingFunMemory = ModelOneArgumentConstantCost 6 + } + , paramBls12_381_G1_uncompress = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 52948122 + , costingFunMemory = ModelOneArgumentConstantCost 18 + } + , paramBls12_381_G1_hashToGroup = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 52538055 + , oneVariableLinearFunctionSlope = 3756 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 18 + } + , paramBls12_381_G2_add = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 1995836 + , costingFunMemory = ModelTwoArgumentsConstantCost 36 + } + , paramBls12_381_G2_neg = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 284546 + , costingFunMemory = ModelOneArgumentConstantCost 36 + } + , paramBls12_381_G2_scalarMul = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 158221314 + , oneVariableLinearFunctionSlope = 26549 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 36 + } + , paramBls12_381_G2_equal = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 901022 + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramBls12_381_G2_multiScalarMul = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 617887431 + , oneVariableLinearFunctionSlope = 67302824 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 36 + } + , paramBls12_381_G2_compress = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 3227919 + , costingFunMemory = ModelOneArgumentConstantCost 12 + } + , paramBls12_381_G2_uncompress = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 74698472 + , costingFunMemory = ModelOneArgumentConstantCost 36 + } + , paramBls12_381_G2_hashToGroup = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 166917843 + , oneVariableLinearFunctionSlope = 4307 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 36 + } + , paramBls12_381_millerLoop = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 254006273 + , costingFunMemory = ModelTwoArgumentsConstantCost 72 + } + , paramBls12_381_mulMlResult = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 2174038 + , costingFunMemory = ModelTwoArgumentsConstantCost 72 + } + , paramBls12_381_finalVerify = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 333849714 + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramKeccak_256 = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 2261318 + , oneVariableLinearFunctionSlope = 64571 + } + , costingFunMemory = ModelOneArgumentConstantCost 4 + } + , paramBlake2b_224 = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 207616 + , oneVariableLinearFunctionSlope = 8310 + } + , costingFunMemory = ModelOneArgumentConstantCost 4 + } + , paramIntegerToByteString = + CostingFun + { costingFunCpu = + ModelThreeArgumentsQuadraticInZ + OneVariableQuadraticFunction + { oneVariableQuadraticFunctionC0 = 1293828 + , oneVariableQuadraticFunctionC1 = 28716 + , oneVariableQuadraticFunctionC2 = 63 + } + , costingFunMemory = + ModelThreeArgumentsLiteralInYOrLinearInZ + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramByteStringToInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsQuadraticInY + OneVariableQuadraticFunction + { oneVariableQuadraticFunctionC0 = 1006041 + , oneVariableQuadraticFunctionC1 = 43623 + , oneVariableQuadraticFunctionC2 = 251 + } + , costingFunMemory = + ModelTwoArgumentsLinearInY + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramAndByteString = + CostingFun + { costingFunCpu = + ModelThreeArgumentsLinearInYAndZ + TwoVariableLinearFunction + { twoVariableLinearFunctionIntercept = 100181 + , twoVariableLinearFunctionSlope1 = 726 + , twoVariableLinearFunctionSlope2 = 719 + } + , costingFunMemory = + ModelThreeArgumentsLinearInMaxYZ + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramOrByteString = + CostingFun + { costingFunCpu = + ModelThreeArgumentsLinearInYAndZ + TwoVariableLinearFunction + { twoVariableLinearFunctionIntercept = 100181 + , twoVariableLinearFunctionSlope1 = 726 + , twoVariableLinearFunctionSlope2 = 719 + } + , costingFunMemory = + ModelThreeArgumentsLinearInMaxYZ + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramXorByteString = + CostingFun + { costingFunCpu = + ModelThreeArgumentsLinearInYAndZ + TwoVariableLinearFunction + { twoVariableLinearFunctionIntercept = 100181 + , twoVariableLinearFunctionSlope1 = 726 + , twoVariableLinearFunctionSlope2 = 719 + } + , costingFunMemory = + ModelThreeArgumentsLinearInMaxYZ + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramComplementByteString = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 107878 + , oneVariableLinearFunctionSlope = 680 + } + , costingFunMemory = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramReadBit = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 95336 + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramWriteBits = + CostingFun + { costingFunCpu = + ModelThreeArgumentsLinearInY + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 281145 + , oneVariableLinearFunctionSlope = 18848 + } + , costingFunMemory = + ModelThreeArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramReplicateByte = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 180194 + , oneVariableLinearFunctionSlope = 159 + } + , costingFunMemory = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramShiftByteString = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 158519 + , oneVariableLinearFunctionSlope = 8942 + } + , costingFunMemory = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramRotateByteString = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 159378 + , oneVariableLinearFunctionSlope = 8813 + } + , costingFunMemory = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramCountSetBits = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 107490 + , oneVariableLinearFunctionSlope = 3298 + } + , costingFunMemory = ModelOneArgumentConstantCost 1 + } + , paramFindFirstSetBit = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 106057 + , oneVariableLinearFunctionSlope = 655 + } + , costingFunMemory = ModelOneArgumentConstantCost 1 + } + , paramRipemd_160 = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1964219 + , oneVariableLinearFunctionSlope = 24520 + } + , costingFunMemory = ModelOneArgumentConstantCost 3 + } + , paramExpModInteger = + CostingFun + { costingFunCpu = + ModelThreeArgumentsExpModCost + ExpModCostingFunction + { coefficient00 = 607153 + , coefficient11 = 231697 + , coefficient12 = 53144 + } + , costingFunMemory = + ModelThreeArgumentsLinearInZ + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramDropList = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 116711 + , oneVariableLinearFunctionSlope = 1957 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 4 + } + , paramLengthOfArray = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 231883 + , costingFunMemory = ModelOneArgumentConstantCost 10 + } + , paramListToArray = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1000 + , oneVariableLinearFunctionSlope = 24838 + } + , costingFunMemory = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 7 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramIndexArray = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 232010 + , costingFunMemory = ModelTwoArgumentsConstantCost 32 + } + , paramLookupCoin = + CostingFun + { costingFunCpu = + ModelThreeArgumentsLinearInZ + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 219951 + , oneVariableLinearFunctionSlope = 9444 + } + , costingFunMemory = ModelThreeArgumentsConstantCost 1 + } + , paramValueContains = + CostingFun + { costingFunCpu = + ModelTwoArgumentsConstAboveDiagonal + ModelConstantOrTwoArguments + { modelConstantOrTwoArgumentsConstant = 213283 + , modelConstantOrTwoArgumentsModel = + ModelTwoArgumentsLinearInXAndY + TwoVariableLinearFunction + { twoVariableLinearFunctionIntercept = 618401 + , twoVariableLinearFunctionSlope1 = 1998 + , twoVariableLinearFunctionSlope2 = 28258 + } + } + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramValueData = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1000 + , oneVariableLinearFunctionSlope = 38159 + } + , costingFunMemory = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 2 + , oneVariableLinearFunctionSlope = 22 + } + } + , paramUnValueData = + CostingFun + { costingFunCpu = + ModelOneArgumentQuadraticInX + OneVariableQuadraticFunction + { oneVariableQuadraticFunctionC0 = 1000 + , oneVariableQuadraticFunctionC1 = 95933 + , oneVariableQuadraticFunctionC2 = 1 + } + , costingFunMemory = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 11 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramInsertCoin = + CostingFun + { costingFunCpu = + ModelFourArgumentsLinearInU + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 356924 + , oneVariableLinearFunctionSlope = 18413 + } + , costingFunMemory = + ModelFourArgumentsLinearInU + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 45 + , oneVariableLinearFunctionSlope = 21 + } + } + , paramUnionValue = + CostingFun + { costingFunCpu = + ModelTwoArgumentsWithInteractionInXAndY + TwoVariableWithInteractionFunction + { twoVariableWithInteractionFunctionC00 = 1000 + , twoVariableWithInteractionFunctionC10 = 172116 + , twoVariableWithInteractionFunctionC01 = 183150 + , twoVariableWithInteractionFunctionC11 = 6 + } + , costingFunMemory = + ModelTwoArgumentsAddedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 24 + , oneVariableLinearFunctionSlope = 21 + } + } + , paramScaleValue = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInY + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1000 + , oneVariableLinearFunctionSlope = 277577 + } + , costingFunMemory = + ModelTwoArgumentsLinearInY + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 12 + , oneVariableLinearFunctionSlope = 21 + } + } + } diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/BuiltinCostModelC.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/BuiltinCostModelC.hs new file mode 100644 index 00000000000..cd641e32feb --- /dev/null +++ b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/BuiltinCostModelC.hs @@ -0,0 +1,1020 @@ +-- This file is auto-generated by the generate-cost-model executable. +-- Do not edit this file manually. + +module PlutusCore.Evaluation.Machine.CostModel.BuiltinCostModelC (builtinCostModelC) where + +import PlutusCore.Evaluation.Machine.BuiltinCostModel + +builtinCostModelC :: BuiltinCostModel +builtinCostModelC = + BuiltinCostModelBase + { paramAddInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsMaxSize + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 100788 + , oneVariableLinearFunctionSlope = 420 + } + , costingFunMemory = + ModelTwoArgumentsMaxSize + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramSubtractInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsMaxSize + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 100788 + , oneVariableLinearFunctionSlope = 420 + } + , costingFunMemory = + ModelTwoArgumentsMaxSize + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramMultiplyInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsMultipliedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 90434 + , oneVariableLinearFunctionSlope = 519 + } + , costingFunMemory = + ModelTwoArgumentsAddedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramDivideInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsConstAboveDiagonal + ModelConstantOrTwoArguments + { modelConstantOrTwoArgumentsConstant = 85848 + , modelConstantOrTwoArgumentsModel = + ModelTwoArgumentsQuadraticInXAndY + TwoVariableQuadraticFunction + { twoVariableQuadraticFunctionMinimum = 85848 + , twoVariableQuadraticFunctionC00 = 123203 + , twoVariableQuadraticFunctionC10 = 1716 + , twoVariableQuadraticFunctionC01 = 7305 + , twoVariableQuadraticFunctionC20 = 57 + , twoVariableQuadraticFunctionC11 = 549 + , twoVariableQuadraticFunctionC02 = -900 + } + } + , costingFunMemory = + ModelTwoArgumentsSubtractedSizes + ModelSubtractedSizes + { modelSubtractedSizesIntercept = 0 + , modelSubtractedSizesSlope = 1 + , modelSubtractedSizesMinimum = 1 + } + } + , paramQuotientInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsConstAboveDiagonal + ModelConstantOrTwoArguments + { modelConstantOrTwoArgumentsConstant = 85848 + , modelConstantOrTwoArgumentsModel = + ModelTwoArgumentsQuadraticInXAndY + TwoVariableQuadraticFunction + { twoVariableQuadraticFunctionMinimum = 85848 + , twoVariableQuadraticFunctionC00 = 123203 + , twoVariableQuadraticFunctionC10 = 1716 + , twoVariableQuadraticFunctionC01 = 7305 + , twoVariableQuadraticFunctionC20 = 57 + , twoVariableQuadraticFunctionC11 = 549 + , twoVariableQuadraticFunctionC02 = -900 + } + } + , costingFunMemory = + ModelTwoArgumentsSubtractedSizes + ModelSubtractedSizes + { modelSubtractedSizesIntercept = 0 + , modelSubtractedSizesSlope = 1 + , modelSubtractedSizesMinimum = 1 + } + } + , paramRemainderInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsConstAboveDiagonal + ModelConstantOrTwoArguments + { modelConstantOrTwoArgumentsConstant = 85848 + , modelConstantOrTwoArgumentsModel = + ModelTwoArgumentsQuadraticInXAndY + TwoVariableQuadraticFunction + { twoVariableQuadraticFunctionMinimum = 85848 + , twoVariableQuadraticFunctionC00 = 123203 + , twoVariableQuadraticFunctionC10 = 1716 + , twoVariableQuadraticFunctionC01 = 7305 + , twoVariableQuadraticFunctionC20 = 57 + , twoVariableQuadraticFunctionC11 = 549 + , twoVariableQuadraticFunctionC02 = -900 + } + } + , costingFunMemory = + ModelTwoArgumentsLinearInY + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramModInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsConstAboveDiagonal + ModelConstantOrTwoArguments + { modelConstantOrTwoArgumentsConstant = 85848 + , modelConstantOrTwoArgumentsModel = + ModelTwoArgumentsQuadraticInXAndY + TwoVariableQuadraticFunction + { twoVariableQuadraticFunctionMinimum = 85848 + , twoVariableQuadraticFunctionC00 = 123203 + , twoVariableQuadraticFunctionC10 = 1716 + , twoVariableQuadraticFunctionC01 = 7305 + , twoVariableQuadraticFunctionC20 = 57 + , twoVariableQuadraticFunctionC11 = 549 + , twoVariableQuadraticFunctionC02 = -900 + } + } + , costingFunMemory = + ModelTwoArgumentsLinearInY + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramEqualsInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsMinSize + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 51775 + , oneVariableLinearFunctionSlope = 558 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramLessThanInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsMinSize + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 44749 + , oneVariableLinearFunctionSlope = 541 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramLessThanEqualsInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsMinSize + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 43285 + , oneVariableLinearFunctionSlope = 552 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramAppendByteString = + CostingFun + { costingFunCpu = + ModelTwoArgumentsAddedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1000 + , oneVariableLinearFunctionSlope = 173 + } + , costingFunMemory = + ModelTwoArgumentsAddedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramConsByteString = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInY + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 72010 + , oneVariableLinearFunctionSlope = 178 + } + , costingFunMemory = + ModelTwoArgumentsAddedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramSliceByteString = + CostingFun + { costingFunCpu = + ModelThreeArgumentsLinearInZ + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 20467 + , oneVariableLinearFunctionSlope = 1 + } + , costingFunMemory = + ModelThreeArgumentsLinearInZ + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 4 + , oneVariableLinearFunctionSlope = 0 + } + } + , paramLengthOfByteString = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 22100 + , costingFunMemory = ModelOneArgumentConstantCost 10 + } + , paramIndexByteString = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 13169 + , costingFunMemory = ModelTwoArgumentsConstantCost 4 + } + , paramEqualsByteString = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearOnDiagonal + ModelConstantOrLinear + { modelConstantOrLinearConstant = 24548 + , modelConstantOrLinearIntercept = 29498 + , modelConstantOrLinearSlope = 38 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramLessThanByteString = + CostingFun + { costingFunCpu = + ModelTwoArgumentsMinSize + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 28999 + , oneVariableLinearFunctionSlope = 74 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramLessThanEqualsByteString = + CostingFun + { costingFunCpu = + ModelTwoArgumentsMinSize + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 28999 + , oneVariableLinearFunctionSlope = 74 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramSha2_256 = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 270652 + , oneVariableLinearFunctionSlope = 22588 + } + , costingFunMemory = ModelOneArgumentConstantCost 4 + } + , paramSha3_256 = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1457325 + , oneVariableLinearFunctionSlope = 64566 + } + , costingFunMemory = ModelOneArgumentConstantCost 4 + } + , paramBlake2b_256 = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 201305 + , oneVariableLinearFunctionSlope = 8356 + } + , costingFunMemory = ModelOneArgumentConstantCost 4 + } + , paramVerifyEd25519Signature = + CostingFun + { costingFunCpu = + ModelThreeArgumentsLinearInY + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 53384111 + , oneVariableLinearFunctionSlope = 14333 + } + , costingFunMemory = ModelThreeArgumentsConstantCost 10 + } + , paramVerifyEcdsaSecp256k1Signature = + CostingFun + { costingFunCpu = ModelThreeArgumentsConstantCost 43053543 + , costingFunMemory = ModelThreeArgumentsConstantCost 10 + } + , paramVerifySchnorrSecp256k1Signature = + CostingFun + { costingFunCpu = + ModelThreeArgumentsLinearInY + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 43574283 + , oneVariableLinearFunctionSlope = 26308 + } + , costingFunMemory = ModelThreeArgumentsConstantCost 10 + } + , paramAppendString = + CostingFun + { costingFunCpu = + ModelTwoArgumentsAddedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1000 + , oneVariableLinearFunctionSlope = 59957 + } + , costingFunMemory = + ModelTwoArgumentsAddedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 4 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramEqualsString = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearOnDiagonal + ModelConstantOrLinear + { modelConstantOrLinearConstant = 39184 + , modelConstantOrLinearIntercept = 1000 + , modelConstantOrLinearSlope = 60594 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramEncodeUtf8 = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1000 + , oneVariableLinearFunctionSlope = 42921 + } + , costingFunMemory = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 4 + , oneVariableLinearFunctionSlope = 2 + } + } + , paramDecodeUtf8 = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 91189 + , oneVariableLinearFunctionSlope = 769 + } + , costingFunMemory = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 4 + , oneVariableLinearFunctionSlope = 2 + } + } + , paramIfThenElse = + CostingFun + { costingFunCpu = ModelThreeArgumentsConstantCost 76049 + , costingFunMemory = ModelThreeArgumentsConstantCost 1 + } + , paramChooseUnit = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 61462 + , costingFunMemory = ModelTwoArgumentsConstantCost 4 + } + , paramTrace = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 59498 + , costingFunMemory = ModelTwoArgumentsConstantCost 32 + } + , paramFstPair = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 141895 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramSndPair = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 141992 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramChooseList = + CostingFun + { costingFunCpu = ModelThreeArgumentsConstantCost 132994 + , costingFunMemory = ModelThreeArgumentsConstantCost 32 + } + , paramMkCons = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 72362 + , costingFunMemory = ModelTwoArgumentsConstantCost 32 + } + , paramHeadList = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 83150 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramTailList = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 81663 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramNullList = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 74433 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramChooseData = + CostingFun + { costingFunCpu = ModelSixArgumentsConstantCost 94375 + , costingFunMemory = ModelSixArgumentsConstantCost 32 + } + , paramConstrData = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 22151 + , costingFunMemory = ModelTwoArgumentsConstantCost 32 + } + , paramMapData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 68246 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramListData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 33852 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramIData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 15299 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramBData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 11183 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramUnConstrData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 24588 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramUnMapData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 24623 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramUnListData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 25933 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramUnIData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 20744 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramUnBData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 20142 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramEqualsData = + CostingFun + { costingFunCpu = + ModelTwoArgumentsMinSize + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 898148 + , oneVariableLinearFunctionSlope = 27279 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramMkPairData = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 11546 + , costingFunMemory = ModelTwoArgumentsConstantCost 32 + } + , paramMkNilData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 7243 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramMkNilPairData = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 7391 + , costingFunMemory = ModelOneArgumentConstantCost 32 + } + , paramSerialiseData = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 955506 + , oneVariableLinearFunctionSlope = 213312 + } + , costingFunMemory = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 2 + } + } + , paramBls12_381_G1_add = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 962335 + , costingFunMemory = ModelTwoArgumentsConstantCost 18 + } + , paramBls12_381_G1_neg = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 267929 + , costingFunMemory = ModelOneArgumentConstantCost 18 + } + , paramBls12_381_G1_scalarMul = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 76433006 + , oneVariableLinearFunctionSlope = 8868 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 18 + } + , paramBls12_381_G1_multiScalarMul = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 321837444 + , oneVariableLinearFunctionSlope = 25087669 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 18 + } + , paramBls12_381_G1_equal = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 442008 + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramBls12_381_G1_compress = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 2780678 + , costingFunMemory = ModelOneArgumentConstantCost 6 + } + , paramBls12_381_G1_uncompress = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 52948122 + , costingFunMemory = ModelOneArgumentConstantCost 18 + } + , paramBls12_381_G1_hashToGroup = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 52538055 + , oneVariableLinearFunctionSlope = 3756 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 18 + } + , paramBls12_381_G2_add = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 1995836 + , costingFunMemory = ModelTwoArgumentsConstantCost 36 + } + , paramBls12_381_G2_neg = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 284546 + , costingFunMemory = ModelOneArgumentConstantCost 36 + } + , paramBls12_381_G2_scalarMul = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 158221314 + , oneVariableLinearFunctionSlope = 26549 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 36 + } + , paramBls12_381_G2_equal = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 901022 + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramBls12_381_G2_multiScalarMul = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 617887431 + , oneVariableLinearFunctionSlope = 67302824 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 36 + } + , paramBls12_381_G2_compress = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 3227919 + , costingFunMemory = ModelOneArgumentConstantCost 12 + } + , paramBls12_381_G2_uncompress = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 74698472 + , costingFunMemory = ModelOneArgumentConstantCost 36 + } + , paramBls12_381_G2_hashToGroup = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 166917843 + , oneVariableLinearFunctionSlope = 4307 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 36 + } + , paramBls12_381_millerLoop = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 254006273 + , costingFunMemory = ModelTwoArgumentsConstantCost 72 + } + , paramBls12_381_mulMlResult = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 2174038 + , costingFunMemory = ModelTwoArgumentsConstantCost 72 + } + , paramBls12_381_finalVerify = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 333849714 + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramKeccak_256 = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 2261318 + , oneVariableLinearFunctionSlope = 64571 + } + , costingFunMemory = ModelOneArgumentConstantCost 4 + } + , paramBlake2b_224 = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 207616 + , oneVariableLinearFunctionSlope = 8310 + } + , costingFunMemory = ModelOneArgumentConstantCost 4 + } + , paramIntegerToByteString = + CostingFun + { costingFunCpu = + ModelThreeArgumentsQuadraticInZ + OneVariableQuadraticFunction + { oneVariableQuadraticFunctionC0 = 1293828 + , oneVariableQuadraticFunctionC1 = 28716 + , oneVariableQuadraticFunctionC2 = 63 + } + , costingFunMemory = + ModelThreeArgumentsLiteralInYOrLinearInZ + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramByteStringToInteger = + CostingFun + { costingFunCpu = + ModelTwoArgumentsQuadraticInY + OneVariableQuadraticFunction + { oneVariableQuadraticFunctionC0 = 1006041 + , oneVariableQuadraticFunctionC1 = 43623 + , oneVariableQuadraticFunctionC2 = 251 + } + , costingFunMemory = + ModelTwoArgumentsLinearInY + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramAndByteString = + CostingFun + { costingFunCpu = + ModelThreeArgumentsLinearInYAndZ + TwoVariableLinearFunction + { twoVariableLinearFunctionIntercept = 100181 + , twoVariableLinearFunctionSlope1 = 726 + , twoVariableLinearFunctionSlope2 = 719 + } + , costingFunMemory = + ModelThreeArgumentsLinearInMaxYZ + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramOrByteString = + CostingFun + { costingFunCpu = + ModelThreeArgumentsLinearInYAndZ + TwoVariableLinearFunction + { twoVariableLinearFunctionIntercept = 100181 + , twoVariableLinearFunctionSlope1 = 726 + , twoVariableLinearFunctionSlope2 = 719 + } + , costingFunMemory = + ModelThreeArgumentsLinearInMaxYZ + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramXorByteString = + CostingFun + { costingFunCpu = + ModelThreeArgumentsLinearInYAndZ + TwoVariableLinearFunction + { twoVariableLinearFunctionIntercept = 100181 + , twoVariableLinearFunctionSlope1 = 726 + , twoVariableLinearFunctionSlope2 = 719 + } + , costingFunMemory = + ModelThreeArgumentsLinearInMaxYZ + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramComplementByteString = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 107878 + , oneVariableLinearFunctionSlope = 680 + } + , costingFunMemory = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramReadBit = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 95336 + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramWriteBits = + CostingFun + { costingFunCpu = + ModelThreeArgumentsLinearInY + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 281145 + , oneVariableLinearFunctionSlope = 18848 + } + , costingFunMemory = + ModelThreeArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramReplicateByte = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 180194 + , oneVariableLinearFunctionSlope = 159 + } + , costingFunMemory = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramShiftByteString = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 158519 + , oneVariableLinearFunctionSlope = 8942 + } + , costingFunMemory = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramRotateByteString = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 159378 + , oneVariableLinearFunctionSlope = 8813 + } + , costingFunMemory = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramCountSetBits = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 107490 + , oneVariableLinearFunctionSlope = 3298 + } + , costingFunMemory = ModelOneArgumentConstantCost 1 + } + , paramFindFirstSetBit = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 106057 + , oneVariableLinearFunctionSlope = 655 + } + , costingFunMemory = ModelOneArgumentConstantCost 1 + } + , paramRipemd_160 = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1964219 + , oneVariableLinearFunctionSlope = 24520 + } + , costingFunMemory = ModelOneArgumentConstantCost 3 + } + , paramExpModInteger = + CostingFun + { costingFunCpu = + ModelThreeArgumentsExpModCost + ExpModCostingFunction + { coefficient00 = 607153 + , coefficient11 = 231697 + , coefficient12 = 53144 + } + , costingFunMemory = + ModelThreeArgumentsLinearInZ + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 0 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramDropList = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 116711 + , oneVariableLinearFunctionSlope = 1957 + } + , costingFunMemory = ModelTwoArgumentsConstantCost 4 + } + , paramLengthOfArray = + CostingFun + { costingFunCpu = ModelOneArgumentConstantCost 231883 + , costingFunMemory = ModelOneArgumentConstantCost 10 + } + , paramListToArray = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1000 + , oneVariableLinearFunctionSlope = 24838 + } + , costingFunMemory = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 7 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramIndexArray = + CostingFun + { costingFunCpu = ModelTwoArgumentsConstantCost 232010 + , costingFunMemory = ModelTwoArgumentsConstantCost 32 + } + , paramLookupCoin = + CostingFun + { costingFunCpu = + ModelThreeArgumentsLinearInZ + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 219951 + , oneVariableLinearFunctionSlope = 9444 + } + , costingFunMemory = ModelThreeArgumentsConstantCost 1 + } + , paramValueContains = + CostingFun + { costingFunCpu = + ModelTwoArgumentsConstAboveDiagonal + ModelConstantOrTwoArguments + { modelConstantOrTwoArgumentsConstant = 213283 + , modelConstantOrTwoArgumentsModel = + ModelTwoArgumentsLinearInXAndY + TwoVariableLinearFunction + { twoVariableLinearFunctionIntercept = 618401 + , twoVariableLinearFunctionSlope1 = 1998 + , twoVariableLinearFunctionSlope2 = 28258 + } + } + , costingFunMemory = ModelTwoArgumentsConstantCost 1 + } + , paramValueData = + CostingFun + { costingFunCpu = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1000 + , oneVariableLinearFunctionSlope = 38159 + } + , costingFunMemory = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 2 + , oneVariableLinearFunctionSlope = 22 + } + } + , paramUnValueData = + CostingFun + { costingFunCpu = + ModelOneArgumentQuadraticInX + OneVariableQuadraticFunction + { oneVariableQuadraticFunctionC0 = 1000 + , oneVariableQuadraticFunctionC1 = 95933 + , oneVariableQuadraticFunctionC2 = 1 + } + , costingFunMemory = + ModelOneArgumentLinearInX + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 11 + , oneVariableLinearFunctionSlope = 1 + } + } + , paramInsertCoin = + CostingFun + { costingFunCpu = + ModelFourArgumentsLinearInU + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 356924 + , oneVariableLinearFunctionSlope = 18413 + } + , costingFunMemory = + ModelFourArgumentsLinearInU + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 45 + , oneVariableLinearFunctionSlope = 21 + } + } + , paramUnionValue = + CostingFun + { costingFunCpu = + ModelTwoArgumentsWithInteractionInXAndY + TwoVariableWithInteractionFunction + { twoVariableWithInteractionFunctionC00 = 1000 + , twoVariableWithInteractionFunctionC10 = 172116 + , twoVariableWithInteractionFunctionC01 = 183150 + , twoVariableWithInteractionFunctionC11 = 6 + } + , costingFunMemory = + ModelTwoArgumentsAddedSizes + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 24 + , oneVariableLinearFunctionSlope = 21 + } + } + , paramScaleValue = + CostingFun + { costingFunCpu = + ModelTwoArgumentsLinearInY + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 1000 + , oneVariableLinearFunctionSlope = 277577 + } + , costingFunMemory = + ModelTwoArgumentsLinearInY + OneVariableLinearFunction + { oneVariableLinearFunctionIntercept = 12 + , oneVariableLinearFunctionSlope = 21 + } + } + } diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/CekMachineCostsA.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/CekMachineCostsA.hs new file mode 100644 index 00000000000..50fe9338987 --- /dev/null +++ b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/CekMachineCostsA.hs @@ -0,0 +1,20 @@ +module PlutusCore.Evaluation.Machine.CostModel.CekMachineCostsA (cekMachineCostsA) where + +import Data.Functor.Identity +import PlutusCore.Evaluation.Machine.ExBudget +import UntypedPlutusCore.Evaluation.Machine.Cek.CekMachineCosts + +cekMachineCostsA :: CekMachineCosts +cekMachineCostsA = + CekMachineCostsBase + { cekStartupCost = Identity $ ExBudget 100 100 + , cekVarCost = Identity $ ExBudget 23000 100 + , cekConstCost = Identity $ ExBudget 23000 100 + , cekLamCost = Identity $ ExBudget 23000 100 + , cekDelayCost = Identity $ ExBudget 23000 100 + , cekForceCost = Identity $ ExBudget 23000 100 + , cekApplyCost = Identity $ ExBudget 23000 100 + , cekBuiltinCost = Identity $ ExBudget 23000 100 + , cekConstrCost = Identity $ ExBudget 23000 100 + , cekCaseCost = Identity $ ExBudget 23000 100 + } diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/CekMachineCostsB.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/CekMachineCostsB.hs new file mode 100644 index 00000000000..19ffcdb8e33 --- /dev/null +++ b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/CekMachineCostsB.hs @@ -0,0 +1,20 @@ +module PlutusCore.Evaluation.Machine.CostModel.CekMachineCostsB (cekMachineCostsB) where + +import Data.Functor.Identity +import PlutusCore.Evaluation.Machine.ExBudget +import UntypedPlutusCore.Evaluation.Machine.Cek.CekMachineCosts + +cekMachineCostsB :: CekMachineCosts +cekMachineCostsB = + CekMachineCostsBase + { cekStartupCost = Identity $ ExBudget 100 100 + , cekVarCost = Identity $ ExBudget 16000 100 + , cekConstCost = Identity $ ExBudget 16000 100 + , cekLamCost = Identity $ ExBudget 16000 100 + , cekDelayCost = Identity $ ExBudget 16000 100 + , cekForceCost = Identity $ ExBudget 16000 100 + , cekApplyCost = Identity $ ExBudget 16000 100 + , cekBuiltinCost = Identity $ ExBudget 16000 100 + , cekConstrCost = Identity $ ExBudget 16000 100 + , cekCaseCost = Identity $ ExBudget 16000 100 + } diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/CekMachineCostsC.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/CekMachineCostsC.hs new file mode 100644 index 00000000000..91189a99a06 --- /dev/null +++ b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/CekMachineCostsC.hs @@ -0,0 +1,20 @@ +module PlutusCore.Evaluation.Machine.CostModel.CekMachineCostsC (cekMachineCostsC) where + +import Data.Functor.Identity +import PlutusCore.Evaluation.Machine.ExBudget +import UntypedPlutusCore.Evaluation.Machine.Cek.CekMachineCosts + +cekMachineCostsC :: CekMachineCosts +cekMachineCostsC = + CekMachineCostsBase + { cekStartupCost = Identity $ ExBudget 100 100 + , cekVarCost = Identity $ ExBudget 16000 100 + , cekConstCost = Identity $ ExBudget 16000 100 + , cekLamCost = Identity $ ExBudget 16000 100 + , cekDelayCost = Identity $ ExBudget 16000 100 + , cekForceCost = Identity $ ExBudget 16000 100 + , cekApplyCost = Identity $ ExBudget 16000 100 + , cekBuiltinCost = Identity $ ExBudget 16000 100 + , cekConstrCost = Identity $ ExBudget 16000 100 + , cekCaseCost = Identity $ ExBudget 16000 100 + } diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/BuiltinCostModelA.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/BuiltinCostModelA.hs deleted file mode 100644 index 63f58a41c6f..00000000000 --- a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/BuiltinCostModelA.hs +++ /dev/null @@ -1,11 +0,0 @@ --- This file is a placeholder for the generated builtin cost model for variant A. --- It needs to be regenerated by running the generate-cost-model executable. --- Run: cabal run plutus-core:generate-cost-model -- -o builtinCostModelA -{-# LANGUAGE RecordWildCards #-} - -module PlutusCore.Evaluation.Machine.CostModel.Generated.BuiltinCostModelA (builtinCostModelA) where - -import PlutusCore.Evaluation.Machine.BuiltinCostModel - -builtinCostModelA :: BuiltinCostModel -builtinCostModelA = error "BuiltinCostModelA needs to be regenerated using generate-cost-model" diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/BuiltinCostModelB.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/BuiltinCostModelB.hs deleted file mode 100644 index 562fa129ce6..00000000000 --- a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/BuiltinCostModelB.hs +++ /dev/null @@ -1,11 +0,0 @@ --- This file is a placeholder for the generated builtin cost model for variant B. --- It needs to be regenerated by running the generate-cost-model executable. --- Run: cabal run plutus-core:generate-cost-model -- -o -{-# LANGUAGE RecordWildCards #-} - -module PlutusCore.Evaluation.Machine.CostModel.Generated.BuiltinCostModelB (builtinCostModelB) where - -import PlutusCore.Evaluation.Machine.BuiltinCostModel - -builtinCostModelB :: BuiltinCostModel -builtinCostModelB = error "BuiltinCostModelB needs to be regenerated using generate-cost-model" diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/BuiltinCostModelC.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/BuiltinCostModelC.hs deleted file mode 100644 index a4d2a85688d..00000000000 --- a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/BuiltinCostModelC.hs +++ /dev/null @@ -1,11 +0,0 @@ --- This file is a placeholder for the generated builtin cost model for variant C. --- It needs to be regenerated by running the generate-cost-model executable. --- Run: cabal run plutus-core:generate-cost-model -- -o -{-# LANGUAGE RecordWildCards #-} - -module PlutusCore.Evaluation.Machine.CostModel.Generated.BuiltinCostModelC (builtinCostModelC) where - -import PlutusCore.Evaluation.Machine.BuiltinCostModel - -builtinCostModelC :: BuiltinCostModel -builtinCostModelC = error "BuiltinCostModelC needs to be regenerated using generate-cost-model" diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsA.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsA.hs deleted file mode 100644 index 238e2b133d3..00000000000 --- a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsA.hs +++ /dev/null @@ -1,12 +0,0 @@ --- This file contains the CEK machine costs for variant A. --- It corresponds to the previous cekMachineCostsA.json file. -{-# LANGUAGE RecordWildCards #-} - -module PlutusCore.Evaluation.Machine.CostModel.Generated.CekMachineCostsA (cekMachineCostsA) where - -import Data.Functor.Identity -import PlutusCore.Evaluation.Machine.ExMemory -import UntypedPlutusCore.Evaluation.Machine.Cek.CekMachineCosts - -cekMachineCostsA :: CekMachineCosts -cekMachineCostsA = undefined diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsB.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsB.hs deleted file mode 100644 index 8713f5c43b8..00000000000 --- a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsB.hs +++ /dev/null @@ -1,12 +0,0 @@ --- This file contains the CEK machine costs for variant B. --- It corresponds to the previous cekMachineCostsB.json file. -{-# LANGUAGE RecordWildCards #-} - -module PlutusCore.Evaluation.Machine.CostModel.Generated.CekMachineCostsB (cekMachineCostsB) where - -import Data.Functor.Identity -import PlutusCore.Evaluation.Machine.ExMemory -import UntypedPlutusCore.Evaluation.Machine.Cek.CekMachineCosts - -cekMachineCostsB :: CekMachineCosts -cekMachineCostsB = undefined diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsC.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsC.hs deleted file mode 100644 index e8930d9e33b..00000000000 --- a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/CekMachineCostsC.hs +++ /dev/null @@ -1,12 +0,0 @@ --- This file contains the CEK machine costs for variant C. --- It corresponds to the previous cekMachineCostsC.json file. -{-# LANGUAGE RecordWildCards #-} - -module PlutusCore.Evaluation.Machine.CostModel.Generated.CekMachineCostsC (cekMachineCostsC) where - -import Data.Functor.Identity -import PlutusCore.Evaluation.Machine.ExMemory -import UntypedPlutusCore.Evaluation.Machine.Cek.CekMachineCosts - -cekMachineCostsC :: CekMachineCosts -cekMachineCostsC = undefined diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/ExBudgetingDefaults.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/ExBudgetingDefaults.hs index bfcd810ee13..6a8179605df 100644 --- a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/ExBudgetingDefaults.hs +++ b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/ExBudgetingDefaults.hs @@ -31,12 +31,12 @@ import UntypedPlutusCore.Evaluation.Machine.Cek.CekMachineCosts import UntypedPlutusCore.Evaluation.Machine.Cek.Internal -- Import generated cost model modules -import PlutusCore.Evaluation.Machine.CostModel.Generated.BuiltinCostModelA (builtinCostModelA) -import PlutusCore.Evaluation.Machine.CostModel.Generated.BuiltinCostModelB (builtinCostModelB) -import PlutusCore.Evaluation.Machine.CostModel.Generated.BuiltinCostModelC (builtinCostModelC) -import PlutusCore.Evaluation.Machine.CostModel.Generated.CekMachineCostsA (cekMachineCostsA) -import PlutusCore.Evaluation.Machine.CostModel.Generated.CekMachineCostsB (cekMachineCostsB) -import PlutusCore.Evaluation.Machine.CostModel.Generated.CekMachineCostsC (cekMachineCostsC) +import PlutusCore.Evaluation.Machine.CostModel.BuiltinCostModelA (builtinCostModelA) +import PlutusCore.Evaluation.Machine.CostModel.BuiltinCostModelB (builtinCostModelB) +import PlutusCore.Evaluation.Machine.CostModel.BuiltinCostModelC (builtinCostModelC) +import PlutusCore.Evaluation.Machine.CostModel.CekMachineCostsA (cekMachineCostsA) +import PlutusCore.Evaluation.Machine.CostModel.CekMachineCostsB (cekMachineCostsB) +import PlutusCore.Evaluation.Machine.CostModel.CekMachineCostsC (cekMachineCostsC) -- Not using 'noinline' from "GHC.Exts", because our CI was unable to find it there, somehow. import GHC.Magic (noinline) @@ -51,7 +51,7 @@ import PlutusPrelude cabal run plutus-core:generate-cost-model - with appropriate output file specified (e.g., -o plutus-core/src/PlutusCore/Evaluation/Machine/CostModel/Generated/BuiltinCostModelC.hs). + with appropriate output file specified (e.g., -o BuiltinCostModelC). (You may also need to add 'data-default' to the 'build-depends' for the library in plutus-core.cabal). This will generate a new Haskell module filled with the correct values (assuming that suitable benchmarking data is in benching.csv and that diff --git a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/SimpleBuiltinCostModel.hs b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/SimpleBuiltinCostModel.hs index c1b4c5c4a35..b7934a8dc8f 100644 --- a/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/SimpleBuiltinCostModel.hs +++ b/plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/SimpleBuiltinCostModel.hs @@ -1,10 +1,8 @@ {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE TemplateHaskell #-} -- TODO: Extend this to handle the different variants of the cost model -{-| A program to parse a representation of costing functions for Plutus Core - builtins and produce a simple cost model which can be used from Agda and other - executables -} module PlutusCore.Evaluation.Machine.SimpleBuiltinCostModel ( BuiltinCostMap , BuiltinCostKeyMap @@ -12,16 +10,17 @@ module PlutusCore.Evaluation.Machine.SimpleBuiltinCostModel , defaultSimpleBuiltinCostModel ) where -import Data.Aeson (ToJSON, encode) +import Data.Aeson (Result (..), eitherDecodeFileStrict, fromJSON, toJSON) import Data.Aeson.Key as Key (toText) import Data.Aeson.KeyMap qualified as KeyMap -import Data.Aeson.Types (parseEither, parseMaybe) +import Data.Aeson.THReader (readJSONFromFile) import Data.Bifunctor -import Data.ByteString.Lazy qualified as BSL import Data.Text (Text, replace) +import PlutusCore.DataFilePaths qualified as DFP import PlutusCore.Evaluation.Machine.BuiltinCostModel -import PlutusCore.Evaluation.Machine.CostModel.Generated.BuiltinCostModelC (builtinCostModelC) +import PlutusCore.Evaluation.Machine.CostModel.BuiltinCostModelC (builtinCostModelC) import PlutusCore.Evaluation.Machine.CostingFun.SimpleJSON +import System.IO.Unsafe type BuiltinCostMap = [(Text, CpuAndMemoryModel)] type BuiltinCostKeyMap = KeyMap.KeyMap CpuAndMemoryModel @@ -29,7 +28,7 @@ type BuiltinCostKeyMap = KeyMap.KeyMap CpuAndMemoryModel {-| The default builtin cost map. TODO: maybe we should take account of the semantic variant here. -} defaultBuiltinCostKeyMap :: BuiltinCostKeyMap -defaultBuiltinCostKeyMap = undefined +defaultBuiltinCostKeyMap = builtinCostModelToBuiltinCostKeyMap builtinCostModelC -- replace underscores _ by dashes - builtinName :: Text -> Text @@ -40,3 +39,16 @@ toSimpleBuiltinCostModel m = map (first (builtinName . toText)) (KeyMap.toList m defaultSimpleBuiltinCostModel :: BuiltinCostMap defaultSimpleBuiltinCostModel = toSimpleBuiltinCostModel defaultBuiltinCostKeyMap + +-- We rely on +builtinCostModelToBuiltinCostKeyMap :: BuiltinCostModel -> BuiltinCostKeyMap +builtinCostModelToBuiltinCostKeyMap model = do + unsafePerformIO $ do + r <- eitherDecodeFileStrict "plutus-core/cost-model/data/builtinCostModelC.json" + case r of + Left str -> error ("Uexpected malformed json for builtin model: " <> str) + Right x -> return x + +-- case fromJSON (toJSON model) of +-- Error str -> error ("Uexpected malformed json for builtin model: " <> str) +-- Success x -> x