Skip to content

Commit 40345c9

Browse files
author
Kenneth MacKenzie
authored
Add blake2b function to R code, update cost model (IntersectMBO#3676)
* Add blake2b function to R code, unpdate cost model * Get rid of zero slopes in built-in cost model as a workaround for a failing test * Update test results * Make startup cost nonzero but small (problem with ExpensivePlus test and slippage) * Update test output again * Decrease startup cost again * Update test output again * Accidental Haddock * Nudge CI * Update test results
1 parent 810c506 commit 40345c9

File tree

21 files changed

+2315
-3456
lines changed

21 files changed

+2315
-3456
lines changed

plutus-core/cost-model/data/benching.csv

Lines changed: 2064 additions & 3210 deletions
Large diffs are not rendered by default.

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

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
},
77
"cpu": {
88
"arguments": {
9-
"slope": 980,
10-
"intercept": 187278
9+
"slope": 100,
10+
"intercept": 11501
1111
},
1212
"type": "min_size"
1313
}
@@ -19,8 +19,8 @@
1919
},
2020
"cpu": {
2121
"arguments": {
22-
"slope": 980,
23-
"intercept": 187278
22+
"slope": 100,
23+
"intercept": 11501
2424
},
2525
"type": "min_size"
2626
}
@@ -32,8 +32,8 @@
3232
},
3333
"cpu": {
3434
"arguments": {
35-
"slope": 81356,
36-
"intercept": 1260296,
35+
"slope": 82258,
36+
"intercept": 3944346,
3737
"orientation": "x"
3838
},
3939
"type": "linear_cost"
@@ -59,8 +59,8 @@
5959
},
6060
"cpu": {
6161
"arguments": {
62-
"slope": 11464,
63-
"intercept": 78642
62+
"slope": 13197,
63+
"intercept": 0
6464
},
6565
"type": "added_sizes"
6666
}
@@ -72,8 +72,8 @@
7272
},
7373
"cpu": {
7474
"arguments": {
75-
"slope": 227,
76-
"intercept": 204537
75+
"slope": 247,
76+
"intercept": 0
7777
},
7878
"type": "min_size"
7979
}
@@ -89,8 +89,8 @@
8989
},
9090
"cpu": {
9191
"arguments": {
92-
"model_split_const_intercept": 330895,
93-
"model_split_const_slope": 427
92+
"model_split_const_intercept": 150970,
93+
"model_split_const_slope": 519
9494
},
9595
"type": "split_const_multi"
9696
}
@@ -102,8 +102,8 @@
102102
},
103103
"cpu": {
104104
"arguments": {
105-
"slope": 699,
106-
"intercept": 216015
105+
"slope": 891,
106+
"intercept": 0
107107
},
108108
"type": "min_size"
109109
}
@@ -115,8 +115,8 @@
115115
},
116116
"cpu": {
117117
"arguments": {
118-
"slope": 699,
119-
"intercept": 216015
118+
"slope": 891,
119+
"intercept": 0
120120
},
121121
"type": "min_size"
122122
}
@@ -128,8 +128,8 @@
128128
},
129129
"cpu": {
130130
"arguments": {
131-
"slope": 227,
132-
"intercept": 204537
131+
"slope": 247,
132+
"intercept": 0
133133
},
134134
"type": "min_size"
135135
}
@@ -141,8 +141,8 @@
141141
},
142142
"cpu": {
143143
"arguments": {
144-
"slope": 867,
145-
"intercept": 211716
144+
"slope": 450,
145+
"intercept": 0
146146
},
147147
"type": "min_size"
148148
}
@@ -153,7 +153,7 @@
153153
"type": "constant_cost"
154154
},
155155
"cpu": {
156-
"arguments": 3420288,
156+
"arguments": 3612479,
157157
"type": "constant_cost"
158158
}
159159
},
@@ -168,8 +168,8 @@
168168
},
169169
"cpu": {
170170
"arguments": {
171-
"model_split_const_intercept": 330895,
172-
"model_split_const_slope": 427
171+
"model_split_const_intercept": 150970,
172+
"model_split_const_slope": 519
173173
},
174174
"type": "split_const_multi"
175175
}
@@ -184,8 +184,8 @@
184184
},
185185
"cpu": {
186186
"arguments": {
187-
"slope": 1722,
188-
"intercept": 235735
187+
"slope": 1000,
188+
"intercept": 37885
189189
},
190190
"type": "max_size"
191191
}
@@ -200,8 +200,8 @@
200200
},
201201
"cpu": {
202202
"arguments": {
203-
"slope": 515,
204-
"intercept": 420084
203+
"slope": 605,
204+
"intercept": 195193
205205
},
206206
"type": "added_sizes"
207207
}
@@ -216,8 +216,8 @@
216216
},
217217
"cpu": {
218218
"arguments": {
219-
"slope": 1722,
220-
"intercept": 235735
219+
"slope": 1000,
220+
"intercept": 37885
221221
},
222222
"type": "max_size"
223223
}
@@ -233,8 +233,8 @@
233233
},
234234
"cpu": {
235235
"arguments": {
236-
"model_split_const_intercept": 330895,
237-
"model_split_const_slope": 427
236+
"model_split_const_intercept": 150970,
237+
"model_split_const_slope": 519
238238
},
239239
"type": "split_const_multi"
240240
}
@@ -246,8 +246,8 @@
246246
},
247247
"cpu": {
248248
"arguments": {
249-
"slope": 246,
250-
"intercept": 188562
249+
"slope": 235,
250+
"intercept": 78803
251251
},
252252
"type": "min_size"
253253
}
@@ -258,7 +258,7 @@
258258
"type": "constant_cost"
259259
},
260260
"cpu": {
261-
"arguments": 5082989,
261+
"arguments": 3188043,
262262
"type": "constant_cost"
263263
}
264264
},
@@ -269,8 +269,8 @@
269269
},
270270
"cpu": {
271271
"arguments": {
272-
"slope": 28904,
273-
"intercept": 2267819,
272+
"slope": 29258,
273+
"intercept": 1233304,
274274
"orientation": "x"
275275
},
276276
"type": "linear_cost"
@@ -282,10 +282,24 @@
282282
"type": "constant_cost"
283283
},
284284
"cpu": {
285-
"arguments": 3418326,
285+
"arguments": 3642928,
286286
"type": "constant_cost"
287287
}
288288
},
289+
"blake2b": {
290+
"memory": {
291+
"arguments": 4,
292+
"type": "constant_cost"
293+
},
294+
"cpu": {
295+
"arguments": {
296+
"slope": 29258,
297+
"intercept": 1233304,
298+
"orientation": "x"
299+
},
300+
"type": "linear_cost"
301+
}
302+
},
289303
"remainderInteger": {
290304
"memory": {
291305
"arguments": {
@@ -297,24 +311,10 @@
297311
},
298312
"cpu": {
299313
"arguments": {
300-
"model_split_const_intercept": 330895,
301-
"model_split_const_slope": 427
314+
"model_split_const_intercept": 150970,
315+
"model_split_const_slope": 519
302316
},
303317
"type": "split_const_multi"
304318
}
305-
},
306-
"blake2b": {
307-
"memory": {
308-
"arguments": 0,
309-
"type": "constant_cost"
310-
},
311-
"cpu": {
312-
"arguments": {
313-
"slope": 0,
314-
"intercept": 0,
315-
"orientation": "x"
316-
},
317-
"type": "linear_cost"
318-
}
319319
}
320320
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"cekStartupCost" : {"_exBudgetCPU": 1000000, "_exBudgetMemory": 0},
3-
"cekVarCost" : {"_exBudgetCPU": 39000, "_exBudgetMemory": 10},
4-
"cekConstCost" : {"_exBudgetCPU": 39000, "_exBudgetMemory": 10},
5-
"cekLamCost" : {"_exBudgetCPU": 39000, "_exBudgetMemory": 10},
6-
"cekDelayCost" : {"_exBudgetCPU": 39000, "_exBudgetMemory": 10},
7-
"cekForceCost" : {"_exBudgetCPU": 39000, "_exBudgetMemory": 10},
8-
"cekApplyCost" : {"_exBudgetCPU": 39000, "_exBudgetMemory": 10},
9-
"cekBuiltinCost" : {"_exBudgetCPU": 39000, "_exBudgetMemory": 10}
2+
"cekStartupCost" : {"_exBudgetCPU": 100, "_exBudgetMemory": 10},
3+
"cekVarCost" : {"_exBudgetCPU": 31000, "_exBudgetMemory": 10},
4+
"cekConstCost" : {"_exBudgetCPU": 31000, "_exBudgetMemory": 10},
5+
"cekLamCost" : {"_exBudgetCPU": 31000, "_exBudgetMemory": 10},
6+
"cekDelayCost" : {"_exBudgetCPU": 31000, "_exBudgetMemory": 10},
7+
"cekForceCost" : {"_exBudgetCPU": 31000, "_exBudgetMemory": 10},
8+
"cekApplyCost" : {"_exBudgetCPU": 31000, "_exBudgetMemory": 10},
9+
"cekBuiltinCost" : {"_exBudgetCPU": 31000, "_exBudgetMemory": 10}
1010
}
1111

plutus-core/cost-model/data/models.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,9 @@ modelFun <- function(path) {
321321

322322
ifThenElseModel <- 0
323323

324+
blake2bModel <- sha2_256Model
325+
## TODO: Fix this and add other missing models
326+
324327
list(
325328
addIntegerModel = addIntegerModel,
326329
equalsIntegerModel = equalsIntegerModel,
@@ -343,7 +346,8 @@ modelFun <- function(path) {
343346
lessThanByteStringModel = lessThanByteStringModel,
344347
greaterThanByteStringModel = greaterThanByteStringModel,
345348
verifySignatureModel = verifySignatureModel,
346-
ifThenElseModel = ifThenElseModel
349+
ifThenElseModel = ifThenElseModel,
350+
blake2bModel = blake2bModel
347351
)
348352

349353
}

plutus-core/plutus-core/src/PlutusCore/Default/Builtins.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,12 @@ data DefaultFun
9595
| MkNilData
9696
| MkNilPairData
9797
| MkCons
98+
| Blake2b_256
99+
-- ## ANY NEW BUILTINS SHOULD BE ADDED BEFORE THIS LINE ##
98100
-- TODO. These are only used for costing calibration and shouldn't be included in the defaults.
99101
| Nop1
100102
| Nop2
101103
| Nop3
102-
| Blake2b_256
103104
deriving (Show, Eq, Ord, Enum, Bounded, Generic, NFData, Hashable, Ix, PrettyBy PrettyConfigPlc)
104105

105106
instance Pretty DefaultFun where
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
( (Right (1))
2-
, ({ tally: ({ BStep BConst causes ({ cpu: 117000
2+
, ({ tally: ({ BStep BConst causes ({ cpu: 93000
33
| mem: 30
44
})
5-
| BStep BVar causes ({ cpu: 507000
5+
| BStep BVar causes ({ cpu: 403000
66
| mem: 130
77
})
8-
| BStep BLamAbs causes ({ cpu: 546000
8+
| BStep BLamAbs causes ({ cpu: 434000
99
| mem: 140
1010
})
11-
| BStep BApply causes ({ cpu: 702000
11+
| BStep BApply causes ({ cpu: 558000
1212
| mem: 180
1313
})
14-
| BStep BDelay causes ({ cpu: 195000
14+
| BStep BDelay causes ({ cpu: 155000
1515
| mem: 50
1616
})
17-
| BStep BForce causes ({ cpu: 234000
17+
| BStep BForce causes ({ cpu: 186000
1818
| mem: 60
1919
})
20-
| BStep BBuiltin causes ({ cpu: 78000
20+
| BStep BBuiltin causes ({ cpu: 62000
2121
| mem: 20
2222
})
23-
| BBuiltinApp LessThanEqualsInteger causes ({ cpu: 216714
23+
| BBuiltinApp LessThanEqualsInteger causes ({ cpu: 891
2424
| mem: 1
2525
})
2626
| BBuiltinApp IfThenElse causes ({ cpu: 0
2727
| mem: 0
2828
})
29-
| BStartup causes ({ cpu: 1000000
30-
| mem: 0
29+
| BStartup causes ({ cpu: 100
30+
| mem: 10
3131
})})
32-
| budget: ({ cpu: 3595714
33-
| mem: 611
32+
| budget: ({ cpu: 1891991
33+
| mem: 621
3434
})
3535
}) )

0 commit comments

Comments
 (0)