Skip to content

Commit 3c5708d

Browse files
committed
WIP: insertCoin and unionValue costing
1 parent accb457 commit 3c5708d

File tree

6 files changed

+70
-0
lines changed

6 files changed

+70
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,5 +176,6 @@ builtinMemoryModels = BuiltinCostModelBase
176176
, paramLengthOfArray = Id $ ModelOneArgumentConstantCost 10
177177
, paramListToArray = Id $ ModelOneArgumentLinearInX $ OneVariableLinearFunction 7 1
178178
, paramIndexArray = Id $ ModelTwoArgumentsConstantCost 32
179+
, paramInsertCoin = Id $ ModelFourArgumentsConstantCost 1
179180
}
180181
where identityFunction = OneVariableLinearFunction 0 1

plutus-core/cost-model/data/builtinCostModelA.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,4 +1206,24 @@
12061206
"type": "constant_cost"
12071207
}
12081208
}
1209+
, "insertCoin": {
1210+
"cpu": {
1211+
"arguments": 1000,
1212+
"type": "constant_cost"
1213+
},
1214+
"memory": {
1215+
"arguments": 10,
1216+
"type": "constant_cost"
1217+
}
1218+
}
1219+
, "unionValue": {
1220+
"cpu": {
1221+
"arguments": 1000,
1222+
"type": "constant_cost"
1223+
},
1224+
"memory": {
1225+
"arguments": 10,
1226+
"type": "constant_cost"
1227+
}
1228+
}
12091229
}

plutus-core/cost-model/data/builtinCostModelB.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,4 +1206,24 @@
12061206
"type": "constant_cost"
12071207
}
12081208
}
1209+
, "insertCoin": {
1210+
"cpu": {
1211+
"arguments": 1000,
1212+
"type": "constant_cost"
1213+
},
1214+
"memory": {
1215+
"arguments": 10,
1216+
"type": "constant_cost"
1217+
}
1218+
}
1219+
, "unionValue": {
1220+
"cpu": {
1221+
"arguments": 1000,
1222+
"type": "constant_cost"
1223+
},
1224+
"memory": {
1225+
"arguments": 10,
1226+
"type": "constant_cost"
1227+
}
1228+
}
12091229
}

plutus-core/cost-model/data/builtinCostModelC.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,4 +1224,24 @@
12241224
"type": "constant_cost"
12251225
}
12261226
}
1227+
, "insertCoin": {
1228+
"cpu": {
1229+
"arguments": 1000,
1230+
"type": "constant_cost"
1231+
},
1232+
"memory": {
1233+
"arguments": 10,
1234+
"type": "constant_cost"
1235+
}
1236+
}
1237+
, "unionValue": {
1238+
"cpu": {
1239+
"arguments": 1000,
1240+
"type": "constant_cost"
1241+
},
1242+
"memory": {
1243+
"arguments": 10,
1244+
"type": "constant_cost"
1245+
}
1246+
}
12271247
}

plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/BuiltinCostModel.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ data BuiltinCostModelBase f =
193193
, paramLengthOfArray :: f ModelOneArgument
194194
, paramListToArray :: f ModelOneArgument
195195
, paramIndexArray :: f ModelTwoArguments
196+
-- Values
197+
, paramInsertCoin :: f ModelFourArguments
198+
, paramUnionValue :: f ModelTwoArguments
196199
}
197200
deriving stock (Generic)
198201
deriving anyclass (FunctorB, TraversableB, ConstraintsB)

plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/ExBudgetingDefaults.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ unitCostTwoArguments = CostingFun (ModelTwoArgumentsConstantCost 1) (ModelTwo
238238
unitCostThreeArguments :: CostingFun ModelThreeArguments
239239
unitCostThreeArguments = CostingFun (ModelThreeArgumentsConstantCost 1) (ModelThreeArgumentsConstantCost 0)
240240

241+
unitCostFourArguments :: CostingFun ModelFourArguments
242+
unitCostFourArguments = CostingFun (ModelFourArgumentsConstantCost 1) (ModelFourArgumentsConstantCost 0)
243+
241244
unitCostSixArguments :: CostingFun ModelSixArguments
242245
unitCostSixArguments = CostingFun (ModelSixArgumentsConstantCost 1) (ModelSixArgumentsConstantCost 0)
243246

@@ -355,6 +358,9 @@ unitCostBuiltinCostModel = BuiltinCostModelBase
355358
, paramLengthOfArray = unitCostOneArgument
356359
, paramListToArray = unitCostOneArgument
357360
, paramIndexArray = unitCostTwoArguments
361+
-- Values
362+
, paramInsertCoin = unitCostFourArguments
363+
, paramUnionValue = unitCostTwoArguments
358364
}
359365

360366
unitCekParameters :: Typeable ann => MachineParameters CekMachineCosts DefaultFun (CekValue DefaultUni DefaultFun ann)

0 commit comments

Comments
 (0)