From a59978f9ea9e7f9d271e5fc4c5c61fd969cbd5cd Mon Sep 17 00:00:00 2001 From: Andronik Ordian Date: Tue, 10 Sep 2019 17:16:12 +0200 Subject: [PATCH 1/2] [json-spec] make blake2 pricing spec more readable --- json/src/spec/builtin.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/json/src/spec/builtin.rs b/json/src/spec/builtin.rs index 20ebbc3c636..c4f9f4e1ec8 100644 --- a/json/src/spec/builtin.rs +++ b/json/src/spec/builtin.rs @@ -18,8 +18,6 @@ use uint::Uint; -/// Price per round of Blake2 compression. -pub type Blake2F = u64; /// Linear pricing. #[derive(Debug, PartialEq, Deserialize, Clone)] @@ -69,7 +67,10 @@ pub struct AltBn128Pairing { #[serde(rename_all = "snake_case")] pub enum Pricing { /// Pricing for Blake2 compression function: each call costs the same amount per round. - Blake2F(Blake2F), + Blake2F { + /// Price per round of Blake2 compression function. + gas_per_round: u64, + }, /// Linear pricing. Linear(Linear), /// Pricing for modular exponentiation. @@ -117,11 +118,11 @@ mod tests { let s = r#"{ "name": "blake2_f", "activate_at": "0xffffff", - "pricing": { "blake2_f": 123 } + "pricing": { "blake2_f": { "gas_per_round": 123 } } }"#; let deserialized: Builtin = serde_json::from_str(s).unwrap(); assert_eq!(deserialized.name, "blake2_f"); - assert_eq!(deserialized.pricing, Pricing::Blake2F(123)); + assert_eq!(deserialized.pricing, Pricing::Blake2F { gas_per_round: 123 }); assert!(deserialized.activate_at.is_some()); } From 92c93876ab016ae67b38ce5fe1e99bf0c052f6da Mon Sep 17 00:00:00 2001 From: Andronik Ordian Date: Tue, 10 Sep 2019 17:24:15 +0200 Subject: [PATCH 2/2] [ethcore] fix compilation --- ethcore/builtin/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ethcore/builtin/src/lib.rs b/ethcore/builtin/src/lib.rs index 71504aee4ae..a3c50c3c381 100644 --- a/ethcore/builtin/src/lib.rs +++ b/ethcore/builtin/src/lib.rs @@ -218,8 +218,8 @@ impl Builtin { impl From for Builtin { fn from(b: ethjson::spec::Builtin) -> Self { let pricer: Box = match b.pricing { - ethjson::spec::Pricing::Blake2F(cost_per_round) => { - Box::new(cost_per_round) + ethjson::spec::Pricing::Blake2F { gas_per_round } => { + Box::new(gas_per_round) }, ethjson::spec::Pricing::Linear(linear) => { Box::new(Linear {