Struct cardano_serialization_lib::plutus::Costmdls
source · pub struct Costmdls(_);
Implementations§
source§impl Costmdls
impl Costmdls
pub fn from_bytes(bytes: Vec<u8>) -> Result<Costmdls, DeserializeError>
source§impl Costmdls
impl Costmdls
sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
More examples
src/tx_builder_constants.rs (line 18)
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
pub fn plutus_alonzo_cost_models() -> Costmdls {
let mut res = Costmdls::new();
res.insert(
&Language::new_plutus_v1(),
&CostModel::from(vec![
197209, 0, 1, 1, 396231, 621, 0, 1, 150000, 1000, 0, 1, 150000, 32, 2477736, 29175,
4, 29773, 100, 29773, 100, 29773, 100, 29773, 100, 29773, 100, 29773, 100, 100,
100, 29773, 100, 150000, 32, 150000, 32, 150000, 32, 150000, 1000, 0, 1, 150000,
32, 150000, 1000, 0, 8, 148000, 425507, 118, 0, 1, 1, 150000, 1000, 0, 8, 150000,
112536, 247, 1, 150000, 10000, 1, 136542, 1326, 1, 1000, 150000, 1000, 1, 150000,
32, 150000, 32, 150000, 32, 1, 1, 150000, 1, 150000, 4, 103599, 248, 1, 103599,
248, 1, 145276, 1366, 1, 179690, 497, 1, 150000, 32, 150000, 32, 150000, 32,
150000, 32, 150000, 32, 150000, 32, 148000, 425507, 118, 0, 1, 1, 61516, 11218, 0,
1, 150000, 32, 148000, 425507, 118, 0, 1, 1, 148000, 425507, 118, 0, 1, 1, 2477736,
29175, 4, 0, 82363, 4, 150000, 5000, 0, 1, 150000, 32, 197209, 0, 1, 1, 150000, 32,
150000, 32, 150000, 32, 150000, 32, 150000, 32, 150000, 32, 150000, 32, 3345831, 1,
1,
]),
);
res
}
pub fn plutus_vasil_cost_models() -> Costmdls {
let mut res = Costmdls::new();
res.insert(
&Language::new_plutus_v1(),
&CostModel::from(vec![
205665, 812, 1, 1, 1000, 571, 0, 1, 1000, 24177, 4, 1, 1000, 32, 117366, 10475, 4,
23000, 100, 23000, 100, 23000, 100, 23000, 100, 23000, 100, 23000, 100, 100, 100,
23000, 100, 19537, 32, 175354, 32, 46417, 4, 221973, 511, 0, 1, 89141, 32, 497525,
14068, 4, 2, 196500, 453240, 220, 0, 1, 1, 1000, 28662, 4, 2, 245000, 216773, 62,
1, 1060367, 12586, 1, 208512, 421, 1, 187000, 1000, 52998, 1, 80436, 32, 43249, 32,
1000, 32, 80556, 1, 57667, 4, 1000, 10, 197145, 156, 1, 197145, 156, 1, 204924,
473, 1, 208896, 511, 1, 52467, 32, 64832, 32, 65493, 32, 22558, 32, 16563, 32,
76511, 32, 196500, 453240, 220, 0, 1, 1, 69522, 11687, 0, 1, 60091, 32, 196500,
453240, 220, 0, 1, 1, 196500, 453240, 220, 0, 1, 1, 806990, 30482, 4, 1927926,
82523, 4, 265318, 0, 4, 0, 85931, 32, 205665, 812, 1, 1, 41182, 32, 212342, 32,
31220, 32, 32696, 32, 43357, 32, 32247, 32, 38314, 32, 9462713, 1021, 10,
]),
);
res.insert(
&Language::new_plutus_v2(),
&CostModel::from(vec![
205665,
812,
1,
1,
1000,
571,
0,
1,
1000,
24177,
4,
1,
1000,
32,
117366,
10475,
4,
23000,
100,
23000,
100,
23000,
100,
23000,
100,
23000,
100,
23000,
100,
100,
100,
23000,
100,
19537,
32,
175354,
32,
46417,
4,
221973,
511,
0,
1,
89141,
32,
497525,
14068,
4,
2,
196500,
453240,
220,
0,
1,
1,
1000,
28662,
4,
2,
245000,
216773,
62,
1,
1060367,
12586,
1,
208512,
421,
1,
187000,
1000,
52998,
1,
80436,
32,
43249,
32,
1000,
32,
80556,
1,
57667,
4,
1000,
10,
197145,
156,
1,
197145,
156,
1,
204924,
473,
1,
208896,
511,
1,
52467,
32,
64832,
32,
65493,
32,
22558,
32,
16563,
32,
76511,
32,
196500,
453240,
220,
0,
1,
1,
69522,
11687,
0,
1,
60091,
32,
196500,
453240,
220,
0,
1,
1,
196500,
453240,
220,
0,
1,
1,
1159724,
392670,
0,
2,
806990,
30482,
4,
1927926,
82523,
4,
265318,
0,
4,
0,
85931,
32,
205665,
812,
1,
1,
41182,
32,
212342,
32,
31220,
32,
32696,
32,
43357,
32,
32247,
32,
38314,
32,
20000000000,
20000000000,
9462713,
1021,
10,
20000000000,
0,
20000000000,
]),
);
res
}
src/tx_builder.rs (line 1694)
1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731
pub fn calc_script_data_hash(&mut self, cost_models: &Costmdls) -> Result<(), JsError> {
let mut used_langs = BTreeSet::new();
let mut retained_cost_models = Costmdls::new();
let mut plutus_witnesses = PlutusWitnesses::new();
if let Some(mut inputs_plutus) = self.inputs.get_plutus_input_scripts() {
used_langs.append(&mut self.inputs.get_used_plutus_lang_versions());
plutus_witnesses.0.append(&mut inputs_plutus.0)
}
if let Some(mut collateral_plutus) = self.collateral.get_plutus_input_scripts() {
used_langs.append(&mut self.collateral.get_used_plutus_lang_versions());
plutus_witnesses.0.append(&mut collateral_plutus.0)
}
if let Some(mint_builder) = &self.mint {
used_langs.append(&mut mint_builder.get_used_plutus_lang_versions());
plutus_witnesses.0.append(&mut mint_builder.get_plutus_witnesses().0)
}
if plutus_witnesses.len() > 0 {
let (_scripts, datums, redeemers) = plutus_witnesses.collect();
for lang in used_langs {
match cost_models.get(&lang) {
Some(cost) => {
retained_cost_models.insert(&lang, &cost);
}
_ => {
return Err(JsError::from_str(&format!(
"Missing cost model for language version: {:?}",
lang
)))
}
}
}
self.script_data_hash = Some(hash_script_data(
&redeemers,
&retained_cost_models,
datums,
));
}
Ok(())
}
pub fn len(&self) -> usize
sourcepub fn insert(&mut self, key: &Language, value: &CostModel) -> Option<CostModel>
pub fn insert(&mut self, key: &Language, value: &CostModel) -> Option<CostModel>
Examples found in repository?
More examples
src/tx_builder_constants.rs (lines 19-35)
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
pub fn plutus_alonzo_cost_models() -> Costmdls {
let mut res = Costmdls::new();
res.insert(
&Language::new_plutus_v1(),
&CostModel::from(vec![
197209, 0, 1, 1, 396231, 621, 0, 1, 150000, 1000, 0, 1, 150000, 32, 2477736, 29175,
4, 29773, 100, 29773, 100, 29773, 100, 29773, 100, 29773, 100, 29773, 100, 100,
100, 29773, 100, 150000, 32, 150000, 32, 150000, 32, 150000, 1000, 0, 1, 150000,
32, 150000, 1000, 0, 8, 148000, 425507, 118, 0, 1, 1, 150000, 1000, 0, 8, 150000,
112536, 247, 1, 150000, 10000, 1, 136542, 1326, 1, 1000, 150000, 1000, 1, 150000,
32, 150000, 32, 150000, 32, 1, 1, 150000, 1, 150000, 4, 103599, 248, 1, 103599,
248, 1, 145276, 1366, 1, 179690, 497, 1, 150000, 32, 150000, 32, 150000, 32,
150000, 32, 150000, 32, 150000, 32, 148000, 425507, 118, 0, 1, 1, 61516, 11218, 0,
1, 150000, 32, 148000, 425507, 118, 0, 1, 1, 148000, 425507, 118, 0, 1, 1, 2477736,
29175, 4, 0, 82363, 4, 150000, 5000, 0, 1, 150000, 32, 197209, 0, 1, 1, 150000, 32,
150000, 32, 150000, 32, 150000, 32, 150000, 32, 150000, 32, 150000, 32, 3345831, 1,
1,
]),
);
res
}
pub fn plutus_vasil_cost_models() -> Costmdls {
let mut res = Costmdls::new();
res.insert(
&Language::new_plutus_v1(),
&CostModel::from(vec![
205665, 812, 1, 1, 1000, 571, 0, 1, 1000, 24177, 4, 1, 1000, 32, 117366, 10475, 4,
23000, 100, 23000, 100, 23000, 100, 23000, 100, 23000, 100, 23000, 100, 100, 100,
23000, 100, 19537, 32, 175354, 32, 46417, 4, 221973, 511, 0, 1, 89141, 32, 497525,
14068, 4, 2, 196500, 453240, 220, 0, 1, 1, 1000, 28662, 4, 2, 245000, 216773, 62,
1, 1060367, 12586, 1, 208512, 421, 1, 187000, 1000, 52998, 1, 80436, 32, 43249, 32,
1000, 32, 80556, 1, 57667, 4, 1000, 10, 197145, 156, 1, 197145, 156, 1, 204924,
473, 1, 208896, 511, 1, 52467, 32, 64832, 32, 65493, 32, 22558, 32, 16563, 32,
76511, 32, 196500, 453240, 220, 0, 1, 1, 69522, 11687, 0, 1, 60091, 32, 196500,
453240, 220, 0, 1, 1, 196500, 453240, 220, 0, 1, 1, 806990, 30482, 4, 1927926,
82523, 4, 265318, 0, 4, 0, 85931, 32, 205665, 812, 1, 1, 41182, 32, 212342, 32,
31220, 32, 32696, 32, 43357, 32, 32247, 32, 38314, 32, 9462713, 1021, 10,
]),
);
res.insert(
&Language::new_plutus_v2(),
&CostModel::from(vec![
205665,
812,
1,
1,
1000,
571,
0,
1,
1000,
24177,
4,
1,
1000,
32,
117366,
10475,
4,
23000,
100,
23000,
100,
23000,
100,
23000,
100,
23000,
100,
23000,
100,
100,
100,
23000,
100,
19537,
32,
175354,
32,
46417,
4,
221973,
511,
0,
1,
89141,
32,
497525,
14068,
4,
2,
196500,
453240,
220,
0,
1,
1,
1000,
28662,
4,
2,
245000,
216773,
62,
1,
1060367,
12586,
1,
208512,
421,
1,
187000,
1000,
52998,
1,
80436,
32,
43249,
32,
1000,
32,
80556,
1,
57667,
4,
1000,
10,
197145,
156,
1,
197145,
156,
1,
204924,
473,
1,
208896,
511,
1,
52467,
32,
64832,
32,
65493,
32,
22558,
32,
16563,
32,
76511,
32,
196500,
453240,
220,
0,
1,
1,
69522,
11687,
0,
1,
60091,
32,
196500,
453240,
220,
0,
1,
1,
196500,
453240,
220,
0,
1,
1,
1159724,
392670,
0,
2,
806990,
30482,
4,
1927926,
82523,
4,
265318,
0,
4,
0,
85931,
32,
205665,
812,
1,
1,
41182,
32,
212342,
32,
31220,
32,
32696,
32,
43357,
32,
32247,
32,
38314,
32,
20000000000,
20000000000,
9462713,
1021,
10,
20000000000,
0,
20000000000,
]),
);
res
}
src/tx_builder.rs (line 1714)
1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731
pub fn calc_script_data_hash(&mut self, cost_models: &Costmdls) -> Result<(), JsError> {
let mut used_langs = BTreeSet::new();
let mut retained_cost_models = Costmdls::new();
let mut plutus_witnesses = PlutusWitnesses::new();
if let Some(mut inputs_plutus) = self.inputs.get_plutus_input_scripts() {
used_langs.append(&mut self.inputs.get_used_plutus_lang_versions());
plutus_witnesses.0.append(&mut inputs_plutus.0)
}
if let Some(mut collateral_plutus) = self.collateral.get_plutus_input_scripts() {
used_langs.append(&mut self.collateral.get_used_plutus_lang_versions());
plutus_witnesses.0.append(&mut collateral_plutus.0)
}
if let Some(mint_builder) = &self.mint {
used_langs.append(&mut mint_builder.get_used_plutus_lang_versions());
plutus_witnesses.0.append(&mut mint_builder.get_plutus_witnesses().0)
}
if plutus_witnesses.len() > 0 {
let (_scripts, datums, redeemers) = plutus_witnesses.collect();
for lang in used_langs {
match cost_models.get(&lang) {
Some(cost) => {
retained_cost_models.insert(&lang, &cost);
}
_ => {
return Err(JsError::from_str(&format!(
"Missing cost model for language version: {:?}",
lang
)))
}
}
}
self.script_data_hash = Some(hash_script_data(
&redeemers,
&retained_cost_models,
datums,
));
}
Ok(())
}
sourcepub fn get(&self, key: &Language) -> Option<CostModel>
pub fn get(&self, key: &Language) -> Option<CostModel>
Examples found in repository?
More examples
src/tx_builder.rs (line 1712)
1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731
pub fn calc_script_data_hash(&mut self, cost_models: &Costmdls) -> Result<(), JsError> {
let mut used_langs = BTreeSet::new();
let mut retained_cost_models = Costmdls::new();
let mut plutus_witnesses = PlutusWitnesses::new();
if let Some(mut inputs_plutus) = self.inputs.get_plutus_input_scripts() {
used_langs.append(&mut self.inputs.get_used_plutus_lang_versions());
plutus_witnesses.0.append(&mut inputs_plutus.0)
}
if let Some(mut collateral_plutus) = self.collateral.get_plutus_input_scripts() {
used_langs.append(&mut self.collateral.get_used_plutus_lang_versions());
plutus_witnesses.0.append(&mut collateral_plutus.0)
}
if let Some(mint_builder) = &self.mint {
used_langs.append(&mut mint_builder.get_used_plutus_lang_versions());
plutus_witnesses.0.append(&mut mint_builder.get_plutus_witnesses().0)
}
if plutus_witnesses.len() > 0 {
let (_scripts, datums, redeemers) = plutus_witnesses.collect();
for lang in used_langs {
match cost_models.get(&lang) {
Some(cost) => {
retained_cost_models.insert(&lang, &cost);
}
_ => {
return Err(JsError::from_str(&format!(
"Missing cost model for language version: {:?}",
lang
)))
}
}
}
self.script_data_hash = Some(hash_script_data(
&redeemers,
&retained_cost_models,
datums,
));
}
Ok(())
}
pub fn keys(&self) -> Languages
pub fn retain_language_versions(&self, languages: &Languages) -> Costmdls
Trait Implementations§
source§impl<'de> Deserialize<'de> for Costmdls
impl<'de> Deserialize<'de> for Costmdls
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Deserialize for Costmdls
impl Deserialize for Costmdls
fn deserialize<R: BufRead + Seek>(
raw: &mut Deserializer<R>
) -> Result<Self, DeserializeError>
source§impl JsonSchema for Costmdls
impl JsonSchema for Costmdls
source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref
keyword. Read moresource§impl Ord for Costmdls
impl Ord for Costmdls
source§impl PartialEq<Costmdls> for Costmdls
impl PartialEq<Costmdls> for Costmdls
source§impl PartialOrd<Costmdls> for Costmdls
impl PartialOrd<Costmdls> for Costmdls
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more