linear -> pricing
This commit is contained in:
parent
dffa9bcef6
commit
ac3acdef71
@ -33,10 +33,10 @@
|
|||||||
"enode://248f12bc8b18d5289358085520ac78cd8076485211e6d96ab0bc93d6cd25442db0ce3a937dc404f64f207b0b9aed50e25e98ce32af5ac7cb321ff285b97de485@parity-node-zero.ethcore.io:30303"
|
"enode://248f12bc8b18d5289358085520ac78cd8076485211e6d96ab0bc93d6cd25442db0ce3a937dc404f64f207b0b9aed50e25e98ce32af5ac7cb321ff285b97de485@parity-node-zero.ethcore.io:30303"
|
||||||
],
|
],
|
||||||
"accounts": {
|
"accounts": {
|
||||||
"0000000000000000000000000000000000000001": { "builtin": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } } },
|
"0000000000000000000000000000000000000001": { "builtin": { "name": "ecrecover", "pricing": { "base": 3000, "word": 0 } } },
|
||||||
"0000000000000000000000000000000000000002": { "builtin": { "name": "sha256", "linear": { "base": 60, "word": 12 } } },
|
"0000000000000000000000000000000000000002": { "builtin": { "name": "sha256", "pricing": { "base": 60, "word": 12 } } },
|
||||||
"0000000000000000000000000000000000000003": { "builtin": { "name": "ripemd160", "linear": { "base": 600, "word": 120 } } },
|
"0000000000000000000000000000000000000003": { "builtin": { "name": "ripemd160", "pricing": { "base": 600, "word": 120 } } },
|
||||||
"0000000000000000000000000000000000000004": { "builtin": { "name": "identity", "linear": { "base": 15, "word": 3 } } },
|
"0000000000000000000000000000000000000004": { "builtin": { "name": "identity", "pricing": { "base": 15, "word": 3 } } },
|
||||||
"3282791d6fd713f1e94f4bfd565eaa78b3a0599d": {
|
"3282791d6fd713f1e94f4bfd565eaa78b3a0599d": {
|
||||||
"balance": "1337000000000000000000"
|
"balance": "1337000000000000000000"
|
||||||
},
|
},
|
||||||
|
@ -26,9 +26,9 @@
|
|||||||
"gasLimit": "0x1388"
|
"gasLimit": "0x1388"
|
||||||
},
|
},
|
||||||
"accounts": {
|
"accounts": {
|
||||||
"0000000000000000000000000000000000000001": { "builtin": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } } },
|
"0000000000000000000000000000000000000001": { "builtin": { "name": "ecrecover", "pricing": { "base": 3000, "word": 0 } } },
|
||||||
"0000000000000000000000000000000000000002": { "builtin": { "name": "sha256", "linear": { "base": 60, "word": 12 } } },
|
"0000000000000000000000000000000000000002": { "builtin": { "name": "sha256", "pricing": { "base": 60, "word": 12 } } },
|
||||||
"0000000000000000000000000000000000000003": { "builtin": { "name": "ripemd160", "linear": { "base": 600, "word": 120 } } },
|
"0000000000000000000000000000000000000003": { "builtin": { "name": "ripemd160", "pricing": { "base": 600, "word": 120 } } },
|
||||||
"0000000000000000000000000000000000000004": { "builtin": { "name": "identity", "linear": { "base": 15, "word": 3 } } }
|
"0000000000000000000000000000000000000004": { "builtin": { "name": "identity", "pricing": { "base": 15, "word": 3 } } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,9 +26,9 @@
|
|||||||
"gasLimit": "0x1388"
|
"gasLimit": "0x1388"
|
||||||
},
|
},
|
||||||
"accounts": {
|
"accounts": {
|
||||||
"0000000000000000000000000000000000000001": { "builtin": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } } },
|
"0000000000000000000000000000000000000001": { "builtin": { "name": "ecrecover", "pricing": { "base": 3000, "word": 0 } } },
|
||||||
"0000000000000000000000000000000000000002": { "builtin": { "name": "sha256", "linear": { "base": 60, "word": 12 } } },
|
"0000000000000000000000000000000000000002": { "builtin": { "name": "sha256", "pricing": { "base": 60, "word": 12 } } },
|
||||||
"0000000000000000000000000000000000000003": { "builtin": { "name": "ripemd160", "linear": { "base": 600, "word": 120 } } },
|
"0000000000000000000000000000000000000003": { "builtin": { "name": "ripemd160", "pricing": { "base": 600, "word": 120 } } },
|
||||||
"0000000000000000000000000000000000000004": { "builtin": { "name": "identity", "linear": { "base": 15, "word": 3 } } }
|
"0000000000000000000000000000000000000004": { "builtin": { "name": "identity", "pricing": { "base": 15, "word": 3 } } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,9 +26,9 @@
|
|||||||
"gasLimit": "0x1388"
|
"gasLimit": "0x1388"
|
||||||
},
|
},
|
||||||
"accounts": {
|
"accounts": {
|
||||||
"0000000000000000000000000000000000000001": { "balance": "1", "builtin": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } } },
|
"0000000000000000000000000000000000000001": { "balance": "1", "builtin": { "name": "ecrecover", "pricing": { "base": 3000, "word": 0 } } },
|
||||||
"0000000000000000000000000000000000000002": { "balance": "1", "builtin": { "name": "sha256", "linear": { "base": 60, "word": 12 } } },
|
"0000000000000000000000000000000000000002": { "balance": "1", "builtin": { "name": "sha256", "pricing": { "base": 60, "word": 12 } } },
|
||||||
"0000000000000000000000000000000000000003": { "balance": "1", "builtin": { "name": "ripemd160", "linear": { "base": 600, "word": 120 } } },
|
"0000000000000000000000000000000000000003": { "balance": "1", "builtin": { "name": "ripemd160", "pricing": { "base": 600, "word": 120 } } },
|
||||||
"0000000000000000000000000000000000000004": { "balance": "1", "builtin": { "name": "identity", "linear": { "base": 15, "word": 3 } } }
|
"0000000000000000000000000000000000000004": { "balance": "1", "builtin": { "name": "identity", "pricing": { "base": 15, "word": 3 } } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,10 +29,10 @@
|
|||||||
"enode://b1217cbaa440e35ed471157123fe468e19e8b5ad5bedb4b1fdbcbdab6fb2f5ed3e95dd9c24a22a79fdb2352204cea207df27d92bfd21bfd41545e8b16f637499@104.44.138.37:30303"
|
"enode://b1217cbaa440e35ed471157123fe468e19e8b5ad5bedb4b1fdbcbdab6fb2f5ed3e95dd9c24a22a79fdb2352204cea207df27d92bfd21bfd41545e8b16f637499@104.44.138.37:30303"
|
||||||
],
|
],
|
||||||
"accounts": {
|
"accounts": {
|
||||||
"0000000000000000000000000000000000000001": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } } },
|
"0000000000000000000000000000000000000001": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ecrecover", "pricing": { "base": 3000, "word": 0 } } },
|
||||||
"0000000000000000000000000000000000000002": { "balance": "1", "nonce": "1048576", "builtin": { "name": "sha256", "linear": { "base": 60, "word": 12 } } },
|
"0000000000000000000000000000000000000002": { "balance": "1", "nonce": "1048576", "builtin": { "name": "sha256", "pricing": { "base": 60, "word": 12 } } },
|
||||||
"0000000000000000000000000000000000000003": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ripemd160", "linear": { "base": 600, "word": 120 } } },
|
"0000000000000000000000000000000000000003": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ripemd160", "pricing": { "base": 600, "word": 120 } } },
|
||||||
"0000000000000000000000000000000000000004": { "balance": "1", "nonce": "1048576", "builtin": { "name": "identity", "linear": { "base": 15, "word": 3 } } },
|
"0000000000000000000000000000000000000004": { "balance": "1", "nonce": "1048576", "builtin": { "name": "identity", "pricing": { "base": 15, "word": 3 } } },
|
||||||
"102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "1048576" }
|
"102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "1048576" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,10 @@
|
|||||||
"gasLimit": "0x2fefd8"
|
"gasLimit": "0x2fefd8"
|
||||||
},
|
},
|
||||||
"accounts": {
|
"accounts": {
|
||||||
"0000000000000000000000000000000000000001": { "balance": "1", "builtin": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } } },
|
"0000000000000000000000000000000000000001": { "balance": "1", "builtin": { "name": "ecrecover", "pricing": { "base": 3000, "word": 0 } } },
|
||||||
"0000000000000000000000000000000000000002": { "balance": "1", "builtin": { "name": "sha256", "linear": { "base": 60, "word": 12 } } },
|
"0000000000000000000000000000000000000002": { "balance": "1", "builtin": { "name": "sha256", "pricing": { "base": 60, "word": 12 } } },
|
||||||
"0000000000000000000000000000000000000003": { "balance": "1", "builtin": { "name": "ripemd160", "linear": { "base": 600, "word": 120 } } },
|
"0000000000000000000000000000000000000003": { "balance": "1", "builtin": { "name": "ripemd160", "pricing": { "base": 600, "word": 120 } } },
|
||||||
"0000000000000000000000000000000000000004": { "balance": "1", "builtin": { "name": "identity", "linear": { "base": 15, "word": 3 } } },
|
"0000000000000000000000000000000000000004": { "balance": "1", "builtin": { "name": "identity", "pricing": { "base": 15, "word": 3 } } },
|
||||||
"dbdbdb2cbd23b783741e8d7fcf51e459b497e4a6": { "balance": "1606938044258990275541962092341162602522202993782792835301376" },
|
"dbdbdb2cbd23b783741e8d7fcf51e459b497e4a6": { "balance": "1606938044258990275541962092341162602522202993782792835301376" },
|
||||||
"e6716f9544a56c530d868e4bfbacb172315bdead": { "balance": "1606938044258990275541962092341162602522202993782792835301376" },
|
"e6716f9544a56c530d868e4bfbacb172315bdead": { "balance": "1606938044258990275541962092341162602522202993782792835301376" },
|
||||||
"b9c015918bdaba24b4ff057a92a3873d6eb201be": { "balance": "1606938044258990275541962092341162602522202993782792835301376" },
|
"b9c015918bdaba24b4ff057a92a3873d6eb201be": { "balance": "1606938044258990275541962092341162602522202993782792835301376" },
|
||||||
|
@ -26,10 +26,10 @@
|
|||||||
"gasLimit": "0x2fefd8"
|
"gasLimit": "0x2fefd8"
|
||||||
},
|
},
|
||||||
"accounts": {
|
"accounts": {
|
||||||
"0000000000000000000000000000000000000001": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } } },
|
"0000000000000000000000000000000000000001": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ecrecover", "pricing": { "base": 3000, "word": 0 } } },
|
||||||
"0000000000000000000000000000000000000002": { "balance": "1", "nonce": "1048576", "builtin": { "name": "sha256", "linear": { "base": 60, "word": 12 } } },
|
"0000000000000000000000000000000000000002": { "balance": "1", "nonce": "1048576", "builtin": { "name": "sha256", "pricing": { "base": 60, "word": 12 } } },
|
||||||
"0000000000000000000000000000000000000003": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ripemd160", "linear": { "base": 600, "word": 120 } } },
|
"0000000000000000000000000000000000000003": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ripemd160", "pricing": { "base": 600, "word": 120 } } },
|
||||||
"0000000000000000000000000000000000000004": { "balance": "1", "nonce": "1048576", "builtin": { "name": "identity", "linear": { "base": 15, "word": 3 } } },
|
"0000000000000000000000000000000000000004": { "balance": "1", "nonce": "1048576", "builtin": { "name": "identity", "pricing": { "base": 15, "word": 3 } } },
|
||||||
"102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "1048576" }
|
"102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "1048576" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ mod tests {
|
|||||||
fn account_deserialization() {
|
fn account_deserialization() {
|
||||||
let s = r#"{
|
let s = r#"{
|
||||||
"balance": "1",
|
"balance": "1",
|
||||||
"builtin": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } }
|
"builtin": { "name": "ecrecover", "pricing": { "base": 3000, "word": 0 } }
|
||||||
}"#;
|
}"#;
|
||||||
let _deserialized: Account = serde_json::from_str(s).unwrap();
|
let _deserialized: Account = serde_json::from_str(s).unwrap();
|
||||||
// TODO: validate all fields
|
// TODO: validate all fields
|
||||||
|
@ -16,18 +16,35 @@
|
|||||||
|
|
||||||
//! Spec builtin deserialization.
|
//! Spec builtin deserialization.
|
||||||
|
|
||||||
/// Linear builin options.
|
use serde::de::{Deserialize, Deserializer};
|
||||||
|
|
||||||
|
/// Linear pricing.
|
||||||
#[derive(Debug, PartialEq, Deserialize)]
|
#[derive(Debug, PartialEq, Deserialize)]
|
||||||
pub struct Linear {
|
pub struct Linear {
|
||||||
base: u64,
|
base: u64,
|
||||||
word: u64,
|
word: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Pricing variants.
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
pub enum Pricing {
|
||||||
|
/// Linear pricing.
|
||||||
|
Linear(Linear),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Deserialize for Pricing {
|
||||||
|
fn deserialize<D>(deserializer: &mut D) -> Result<Self, D::Error>
|
||||||
|
where D: Deserializer {
|
||||||
|
Deserialize::deserialize(deserializer).map(Pricing::Linear)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Spec builtin.
|
/// Spec builtin.
|
||||||
#[derive(Debug, PartialEq, Deserialize)]
|
#[derive(Debug, PartialEq, Deserialize)]
|
||||||
pub struct Builtin {
|
pub struct Builtin {
|
||||||
name: String,
|
name: String,
|
||||||
linear: Linear,
|
pricing: Pricing,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@ -39,7 +56,7 @@ mod tests {
|
|||||||
fn builtin_deserialization() {
|
fn builtin_deserialization() {
|
||||||
let s = r#"{
|
let s = r#"{
|
||||||
"name": "ecrecover",
|
"name": "ecrecover",
|
||||||
"linear": { "base": 3000, "word": 0 }
|
"pricing": { "base": 3000, "word": 0 }
|
||||||
}"#;
|
}"#;
|
||||||
let _deserialized: Builtin = serde_json::from_str(s).unwrap();
|
let _deserialized: Builtin = serde_json::from_str(s).unwrap();
|
||||||
// TODO: validate all fields
|
// TODO: validate all fields
|
||||||
|
@ -71,10 +71,10 @@ mod tests {
|
|||||||
"enode://b1217cbaa440e35ed471157123fe468e19e8b5ad5bedb4b1fdbcbdab6fb2f5ed3e95dd9c24a22a79fdb2352204cea207df27d92bfd21bfd41545e8b16f637499@104.44.138.37:30303"
|
"enode://b1217cbaa440e35ed471157123fe468e19e8b5ad5bedb4b1fdbcbdab6fb2f5ed3e95dd9c24a22a79fdb2352204cea207df27d92bfd21bfd41545e8b16f637499@104.44.138.37:30303"
|
||||||
],
|
],
|
||||||
"accounts": {
|
"accounts": {
|
||||||
"0000000000000000000000000000000000000001": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } } },
|
"0000000000000000000000000000000000000001": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ecrecover", "pricing": { "base": 3000, "word": 0 } } },
|
||||||
"0000000000000000000000000000000000000002": { "balance": "1", "nonce": "1048576", "builtin": { "name": "sha256", "linear": { "base": 60, "word": 12 } } },
|
"0000000000000000000000000000000000000002": { "balance": "1", "nonce": "1048576", "builtin": { "name": "sha256", "pricing": { "base": 60, "word": 12 } } },
|
||||||
"0000000000000000000000000000000000000003": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ripemd160", "linear": { "base": 600, "word": 120 } } },
|
"0000000000000000000000000000000000000003": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ripemd160", "pricing": { "base": 600, "word": 120 } } },
|
||||||
"0000000000000000000000000000000000000004": { "balance": "1", "nonce": "1048576", "builtin": { "name": "identity", "linear": { "base": 15, "word": 3 } } },
|
"0000000000000000000000000000000000000004": { "balance": "1", "nonce": "1048576", "builtin": { "name": "identity", "pricing": { "base": 15, "word": 3 } } },
|
||||||
"102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "1048576" }
|
"102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "1048576" }
|
||||||
}
|
}
|
||||||
}"#;
|
}"#;
|
||||||
|
Loading…
Reference in New Issue
Block a user