Skip to content

Commit 75bd7a5

Browse files
committed
Add insertCoin and unionValue costing skeleton
1 parent 7eebe28 commit 75bd7a5

File tree

8 files changed

+1336
-1255
lines changed

8 files changed

+1336
-1255
lines changed

plutus-core/cost-model/create-cost-model/BuiltinMemoryModels.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,5 +181,7 @@ builtinMemoryModels = BuiltinCostModelBase
181181
, paramValueContains = Id $ ModelTwoArgumentsConstantCost 1
182182
, paramValueData = Id $ ModelOneArgumentConstantCost 1
183183
, paramUnValueData = Id $ ModelOneArgumentConstantCost 1
184+
, paramInsertCoin = Id $ ModelFourArgumentsConstantCost 1
185+
, paramUnionValue = Id $ ModelTwoArgumentsConstantCost 1
184186
}
185187
where identityFunction = OneVariableLinearFunction 0 1

plutus-core/cost-model/create-cost-model/CreateBuiltinCostModel.hs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ builtinCostModelNames = BuiltinCostModelBase
136136
, paramValueContains = "valueContainsModel"
137137
, paramValueData = "valueDataModel"
138138
, paramUnValueData = "unValueDataModel"
139+
, paramInsertCoin = "insertCoinModel"
140+
, paramUnionValue = "unionValueModel"
139141
}
140142

141143

@@ -289,6 +291,9 @@ createBuiltinCostModel bmfile rfile = do
289291
paramValueContains <- getParams readCF2 paramValueContains
290292
paramValueData <- getParams readCF1 paramValueData
291293
paramUnValueData <- getParams readCF1 paramUnValueData
294+
-- Values
295+
paramInsertCoin <- getParams readCF4 paramInsertCoin
296+
paramUnionValue <- getParams readCF2 paramUnionValue
292297

293298
pure $ BuiltinCostModelBase {..}
294299

@@ -452,6 +457,13 @@ readCF3 e = do
452457
"exp_mod_cost" -> ModelThreeArgumentsExpModCost <$> readExpModCostingFunction "y_mem" "z_mem" e
453458
_ -> error $ "Unknown three-variable model type: " ++ ty
454459

460+
readCF4 :: MonadR m => SomeSEXP (Region m) -> m ModelFourArguments
461+
readCF4 e = do
462+
ty <- getType e
463+
case ty of
464+
"constant_cost" -> ModelFourArgumentsConstantCost <$> getConstant e
465+
_ -> error $ "Unknown four-variable model type: " ++ ty
466+
455467
readCF6 :: MonadR m => SomeSEXP (Region m) -> m ModelSixArguments
456468
readCF6 e = do
457469
ty <- getType e

0 commit comments

Comments
 (0)