Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add blake2b function to R code, update cost model #3676

Merged
merged 10 commits into from
Aug 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5,274 changes: 2,064 additions & 3,210 deletions plutus-core/cost-model/data/benching.csv

Large diffs are not rendered by default.

106 changes: 53 additions & 53 deletions plutus-core/cost-model/data/builtinCostModel.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
},
"cpu": {
"arguments": {
"slope": 980,
"intercept": 187278
"slope": 100,
"intercept": 11501
},
"type": "min_size"
}
Expand All @@ -19,8 +19,8 @@
},
"cpu": {
"arguments": {
"slope": 980,
"intercept": 187278
"slope": 100,
"intercept": 11501
},
"type": "min_size"
}
Expand All @@ -32,8 +32,8 @@
},
"cpu": {
"arguments": {
"slope": 81356,
"intercept": 1260296,
"slope": 82258,
"intercept": 3944346,
"orientation": "x"
},
"type": "linear_cost"
Expand All @@ -59,8 +59,8 @@
},
"cpu": {
"arguments": {
"slope": 11464,
"intercept": 78642
"slope": 13197,
"intercept": 0
},
"type": "added_sizes"
}
Expand All @@ -72,8 +72,8 @@
},
"cpu": {
"arguments": {
"slope": 227,
"intercept": 204537
"slope": 247,
"intercept": 0
},
"type": "min_size"
}
Expand All @@ -89,8 +89,8 @@
},
"cpu": {
"arguments": {
"model_split_const_intercept": 330895,
"model_split_const_slope": 427
"model_split_const_intercept": 150970,
"model_split_const_slope": 519
},
"type": "split_const_multi"
}
Expand All @@ -102,8 +102,8 @@
},
"cpu": {
"arguments": {
"slope": 699,
"intercept": 216015
"slope": 891,
"intercept": 0
},
"type": "min_size"
}
Expand All @@ -115,8 +115,8 @@
},
"cpu": {
"arguments": {
"slope": 699,
"intercept": 216015
"slope": 891,
"intercept": 0
},
"type": "min_size"
}
Expand All @@ -128,8 +128,8 @@
},
"cpu": {
"arguments": {
"slope": 227,
"intercept": 204537
"slope": 247,
"intercept": 0
},
"type": "min_size"
}
Expand All @@ -141,8 +141,8 @@
},
"cpu": {
"arguments": {
"slope": 867,
"intercept": 211716
"slope": 450,
"intercept": 0
},
"type": "min_size"
}
Expand All @@ -153,7 +153,7 @@
"type": "constant_cost"
},
"cpu": {
"arguments": 3420288,
"arguments": 3612479,
"type": "constant_cost"
}
},
Expand All @@ -168,8 +168,8 @@
},
"cpu": {
"arguments": {
"model_split_const_intercept": 330895,
"model_split_const_slope": 427
"model_split_const_intercept": 150970,
"model_split_const_slope": 519
},
"type": "split_const_multi"
}
Expand All @@ -184,8 +184,8 @@
},
"cpu": {
"arguments": {
"slope": 1722,
"intercept": 235735
"slope": 1000,
"intercept": 37885
},
"type": "max_size"
}
Expand All @@ -200,8 +200,8 @@
},
"cpu": {
"arguments": {
"slope": 515,
"intercept": 420084
"slope": 605,
"intercept": 195193
},
"type": "added_sizes"
}
Expand All @@ -216,8 +216,8 @@
},
"cpu": {
"arguments": {
"slope": 1722,
"intercept": 235735
"slope": 1000,
"intercept": 37885
},
"type": "max_size"
}
Expand All @@ -233,8 +233,8 @@
},
"cpu": {
"arguments": {
"model_split_const_intercept": 330895,
"model_split_const_slope": 427
"model_split_const_intercept": 150970,
"model_split_const_slope": 519
},
"type": "split_const_multi"
}
Expand All @@ -246,8 +246,8 @@
},
"cpu": {
"arguments": {
"slope": 246,
"intercept": 188562
"slope": 235,
"intercept": 78803
},
"type": "min_size"
}
Expand All @@ -258,7 +258,7 @@
"type": "constant_cost"
},
"cpu": {
"arguments": 5082989,
"arguments": 3188043,
"type": "constant_cost"
}
},
Expand All @@ -269,8 +269,8 @@
},
"cpu": {
"arguments": {
"slope": 28904,
"intercept": 2267819,
"slope": 29258,
"intercept": 1233304,
"orientation": "x"
},
"type": "linear_cost"
Expand All @@ -282,10 +282,24 @@
"type": "constant_cost"
},
"cpu": {
"arguments": 3418326,
"arguments": 3642928,
"type": "constant_cost"
}
},
"blake2b": {
"memory": {
"arguments": 4,
"type": "constant_cost"
},
"cpu": {
"arguments": {
"slope": 29258,
"intercept": 1233304,
"orientation": "x"
},
"type": "linear_cost"
}
},
"remainderInteger": {
"memory": {
"arguments": {
Expand All @@ -297,24 +311,10 @@
},
"cpu": {
"arguments": {
"model_split_const_intercept": 330895,
"model_split_const_slope": 427
"model_split_const_intercept": 150970,
"model_split_const_slope": 519
},
"type": "split_const_multi"
}
},
"blake2b": {
"memory": {
"arguments": 0,
"type": "constant_cost"
},
"cpu": {
"arguments": {
"slope": 0,
"intercept": 0,
"orientation": "x"
},
"type": "linear_cost"
}
}
}
16 changes: 8 additions & 8 deletions plutus-core/cost-model/data/cekMachineCosts.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"cekStartupCost" : {"_exBudgetCPU": 1000000, "_exBudgetMemory": 0},
"cekVarCost" : {"_exBudgetCPU": 39000, "_exBudgetMemory": 10},
"cekConstCost" : {"_exBudgetCPU": 39000, "_exBudgetMemory": 10},
"cekLamCost" : {"_exBudgetCPU": 39000, "_exBudgetMemory": 10},
"cekDelayCost" : {"_exBudgetCPU": 39000, "_exBudgetMemory": 10},
"cekForceCost" : {"_exBudgetCPU": 39000, "_exBudgetMemory": 10},
"cekApplyCost" : {"_exBudgetCPU": 39000, "_exBudgetMemory": 10},
"cekBuiltinCost" : {"_exBudgetCPU": 39000, "_exBudgetMemory": 10}
"cekStartupCost" : {"_exBudgetCPU": 100, "_exBudgetMemory": 10},
"cekVarCost" : {"_exBudgetCPU": 31000, "_exBudgetMemory": 10},
"cekConstCost" : {"_exBudgetCPU": 31000, "_exBudgetMemory": 10},
"cekLamCost" : {"_exBudgetCPU": 31000, "_exBudgetMemory": 10},
"cekDelayCost" : {"_exBudgetCPU": 31000, "_exBudgetMemory": 10},
"cekForceCost" : {"_exBudgetCPU": 31000, "_exBudgetMemory": 10},
"cekApplyCost" : {"_exBudgetCPU": 31000, "_exBudgetMemory": 10},
"cekBuiltinCost" : {"_exBudgetCPU": 31000, "_exBudgetMemory": 10}
}

6 changes: 5 additions & 1 deletion plutus-core/cost-model/data/models.R
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,9 @@ modelFun <- function(path) {

ifThenElseModel <- 0

blake2bModel <- sha2_256Model
## TODO: Fix this and add other missing models

list(
addIntegerModel = addIntegerModel,
equalsIntegerModel = equalsIntegerModel,
Expand All @@ -343,7 +346,8 @@ modelFun <- function(path) {
lessThanByteStringModel = lessThanByteStringModel,
greaterThanByteStringModel = greaterThanByteStringModel,
verifySignatureModel = verifySignatureModel,
ifThenElseModel = ifThenElseModel
ifThenElseModel = ifThenElseModel,
blake2bModel = blake2bModel
)

}
3 changes: 2 additions & 1 deletion plutus-core/plutus-core/src/PlutusCore/Default/Builtins.hs
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,12 @@ data DefaultFun
| MkNilData
| MkNilPairData
| MkCons
| Blake2b_256
-- ## ANY NEW BUILTINS SHOULD BE ADDED BEFORE THIS LINE ##
-- TODO. These are only used for costing calibration and shouldn't be included in the defaults.
| Nop1
| Nop2
| Nop3
| Blake2b_256
deriving (Show, Eq, Ord, Enum, Bounded, Generic, NFData, Hashable, Ix, PrettyBy PrettyConfigPlc)

instance Pretty DefaultFun where
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
( (Right (1))
, ({ tally: ({ BStep BConst causes ({ cpu: 117000
, ({ tally: ({ BStep BConst causes ({ cpu: 93000
| mem: 30
})
| BStep BVar causes ({ cpu: 507000
| BStep BVar causes ({ cpu: 403000
| mem: 130
})
| BStep BLamAbs causes ({ cpu: 546000
| BStep BLamAbs causes ({ cpu: 434000
| mem: 140
})
| BStep BApply causes ({ cpu: 702000
| BStep BApply causes ({ cpu: 558000
| mem: 180
})
| BStep BDelay causes ({ cpu: 195000
| BStep BDelay causes ({ cpu: 155000
| mem: 50
})
| BStep BForce causes ({ cpu: 234000
| BStep BForce causes ({ cpu: 186000
| mem: 60
})
| BStep BBuiltin causes ({ cpu: 78000
| BStep BBuiltin causes ({ cpu: 62000
| mem: 20
})
| BBuiltinApp LessThanEqualsInteger causes ({ cpu: 216714
| BBuiltinApp LessThanEqualsInteger causes ({ cpu: 891
| mem: 1
})
| BBuiltinApp IfThenElse causes ({ cpu: 0
| mem: 0
})
| BStartup causes ({ cpu: 1000000
| mem: 0
| BStartup causes ({ cpu: 100
| mem: 10
})})
| budget: ({ cpu: 3595714
| mem: 611
| budget: ({ cpu: 1891991
| mem: 621
})
}) )
Loading