diff --git a/Cargo.lock b/Cargo.lock index 4305a617cc5..f225c962161 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1179,6 +1179,7 @@ dependencies = [ "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "macros 0.1.0", "num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2561,6 +2562,7 @@ dependencies = [ "account-state 0.1.0", "client-traits 0.1.0", "common-types 0.1.0", + "criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "ethabi 9.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "ethabi-contract 9.0.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/ethcore/builtin/Cargo.toml b/ethcore/builtin/Cargo.toml index f69b65d974b..d36a3e7620d 100644 --- a/ethcore/builtin/Cargo.toml +++ b/ethcore/builtin/Cargo.toml @@ -7,16 +7,17 @@ edition = "2018" [dependencies] bn = { git = "https://github.com/paritytech/bn", default-features = false } +byteorder = "1.3.2" common-types = { path = "../types" } +eip-152 = { path = "../../util/EIP-152" } ethereum-types = "0.8.0" ethjson = { path = "../../json" } keccak-hash = "0.4.0" log = "0.4" +macros = { path = "../../util/macros" } num = { version = "0.1", default-features = false, features = ["bigint"] } parity-bytes = "0.1" -eip-152 = { path = "../../util/EIP-152" } parity-crypto = { version = "0.4.2", features = ["publickey"] } -byteorder = "1.3.2" [dev-dependencies] hex-literal = "0.2.1" diff --git a/ethcore/builtin/src/lib.rs b/ethcore/builtin/src/lib.rs index d0b0e93ec4b..d39f980d30c 100644 --- a/ethcore/builtin/src/lib.rs +++ b/ethcore/builtin/src/lib.rs @@ -16,18 +16,20 @@ //! Standard built-in contracts. +#![warn(missing_docs)] + use std::{ cmp::{max, min}, + collections::BTreeMap, convert::{TryFrom, TryInto}, io::{self, Read, Cursor}, mem::size_of, + str::FromStr }; -use bn; use byteorder::{BigEndian, LittleEndian, ReadBytesExt}; use common_types::errors::EthcoreError; use ethereum_types::{H256, U256}; -use ethjson; use parity_crypto::publickey::{Signature, recover as ec_recover}; use keccak_hash::keccak; use log::{warn, trace}; @@ -43,10 +45,9 @@ pub trait Implementation: Send + Sync { } /// A gas pricing scheme for built-in contracts. -// TODO: refactor this trait, see https://github.com/paritytech/parity-ethereum/issues/11014 trait Pricer: Send + Sync { /// The gas cost of running this built-in for the given input data at block number `at` - fn cost(&self, input: &[u8], at: u64) -> U256; + fn cost(&self, input: &[u8]) -> U256; } /// Pricing for the Blake2 compression function (aka "F"). @@ -55,7 +56,7 @@ trait Pricer: Send + Sync { pub type Blake2FPricer = u64; impl Pricer for Blake2FPricer { - fn cost(&self, input: &[u8], _at: u64) -> U256 { + fn cost(&self, input: &[u8]) -> U256 { const FOUR: usize = std::mem::size_of::(); // Returning zero if the conversion fails is fine because `execute()` will check the length // and bail with the appropriate error. @@ -68,68 +69,81 @@ impl Pricer for Blake2FPricer { } } +/// Pricing model +#[derive(Debug)] +enum Pricing { + AltBn128Pairing(AltBn128PairingPricer), + AltBn128ConstOperations(AltBn128ConstOperations), + Blake2F(Blake2FPricer), + Linear(Linear), + Modexp(ModexpPricer), +} + +impl Pricer for Pricing { + fn cost(&self, input: &[u8]) -> U256 { + match self { + Pricing::AltBn128Pairing(inner) => inner.cost(input), + Pricing::AltBn128ConstOperations(inner) => inner.cost(input), + Pricing::Blake2F(inner) => inner.cost(input), + Pricing::Linear(inner) => inner.cost(input), + Pricing::Modexp(inner) => inner.cost(input), + } + } +} + /// A linear pricing model. This computes a price using a base cost and a cost per-word. +#[derive(Debug)] struct Linear { - base: usize, - word: usize, + base: u64, + word: u64, } /// A special pricing model for modular exponentiation. +#[derive(Debug)] struct ModexpPricer { - divisor: usize, + divisor: u64, } impl Pricer for Linear { - fn cost(&self, input: &[u8], _at: u64) -> U256 { + fn cost(&self, input: &[u8]) -> U256 { U256::from(self.base) + U256::from(self.word) * U256::from((input.len() + 31) / 32) } } -/// alt_bn128 constant operations (add and mul) pricing model. -struct AltBn128ConstOperations { - price: usize, - eip1108_transition_at: u64, - eip1108_transition_price: usize, -} - -impl Pricer for AltBn128ConstOperations { - fn cost(&self, _input: &[u8], at: u64) -> U256 { - if at >= self.eip1108_transition_at { - self.eip1108_transition_price.into() - } else { - self.price.into() - } - } -} - /// alt_bn128 pairing price #[derive(Debug, Copy, Clone)] struct AltBn128PairingPrice { - base: usize, - pair: usize, + base: u64, + pair: u64, } /// alt_bn128_pairing pricing model. This computes a price using a base cost and a cost per pair. +#[derive(Debug)] struct AltBn128PairingPricer { price: AltBn128PairingPrice, - eip1108_transition_at: u64, - eip1108_transition_price: AltBn128PairingPrice, } -impl Pricer for AltBn128PairingPricer { - fn cost(&self, input: &[u8], at: u64) -> U256 { - let price = if at >= self.eip1108_transition_at { - self.eip1108_transition_price - } else { - self.price - }; +/// Pricing for constant alt_bn128 operations (ECADD and ECMUL) +#[derive(Debug, Copy, Clone)] +pub struct AltBn128ConstOperations { + /// Fixed price. + pub price: u64, +} - U256::from(price.base) + U256::from(price.pair) * U256::from(input.len() / 192) +impl Pricer for AltBn128ConstOperations { + fn cost(&self, _input: &[u8]) -> U256 { + self.price.into() + } +} + +impl Pricer for AltBn128PairingPricer { + fn cost(&self, input: &[u8]) -> U256 { + U256::from(self.price.base) + U256::from(self.price.pair) * U256::from(input.len() / 192) } } impl Pricer for ModexpPricer { - fn cost(&self, input: &[u8], _at: u64) -> U256 { + fn cost(&self, input: &[u8]) -> U256 { let mut reader = input.chain(io::repeat(0)); let mut buf = [0; 32]; @@ -154,8 +168,10 @@ impl Pricer for ModexpPricer { let m = max(mod_len, base_len); // read fist 32-byte word of the exponent. - let exp_low = if base_len + 96 >= input.len() as u64 { U256::zero() } else { - let mut buf = [0; 32]; + let exp_low = if base_len + 96 >= input.len() as u64 { + U256::zero() + } else { + buf.iter_mut().for_each(|b| *b = 0); let mut reader = input[(96 + base_len as usize)..].chain(io::repeat(0)); let len = min(exp_len, 32) as usize; reader.read_exact(&mut buf[(32 - len)..]).expect("reading from zero-extended memory cannot fail; qed"); @@ -186,7 +202,7 @@ impl ModexpPricer { match x { x if x <= 64 => x * x, x if x <= 1024 => (x * x) / 4 + 96 * x - 3072, - x => (x * x) / 16 + 480 * x - 199680, + x => (x * x) / 16 + 480 * x - 199_680, } } } @@ -195,114 +211,152 @@ impl ModexpPricer { /// /// Call `cost` to compute cost for the given input, `execute` to execute the contract /// on the given input, and `is_active` to determine whether the contract is active. -/// -/// Unless `is_active` is true, pub struct Builtin { - pricer: Box, - native: Box, - activate_at: u64, + pricer: BTreeMap, + native: EthereumBuiltin, } impl Builtin { /// Simple forwarder for cost. + /// + /// Return the cost of the most recently activated pricer at the current block number. + /// + /// If no pricer is actived `zero` is returned + /// + /// If multiple `activation_at` has the same block number the last one is used + /// (follows `BTreeMap` semantics). + #[inline] pub fn cost(&self, input: &[u8], at: u64) -> U256 { - self.pricer.cost(input, at) + if let Some((_, pricer)) = self.pricer.range(0..=at).last() { + pricer.cost(input) + } else { + U256::zero() + } } /// Simple forwarder for execute. + #[inline] pub fn execute(&self, input: &[u8], output: &mut BytesRef) -> Result<(), &'static str> { self.native.execute(input, output) } /// Whether the builtin is activated at the given block number. + #[inline] pub fn is_active(&self, at: u64) -> bool { - at >= self.activate_at + self.pricer.range(0..=at).last().is_some() } } -impl TryFrom for Builtin { +impl TryFrom for Builtin { type Error = EthcoreError; - fn try_from(b: ethjson::spec::Builtin) -> Result { - let pricer: Box = match b.pricing { - ethjson::spec::Pricing::Blake2F { gas_per_round } => { - Box::new(gas_per_round) - }, - ethjson::spec::Pricing::Linear(linear) => { - Box::new(Linear { + fn try_from(b: ethjson::spec::builtin::Builtin) -> Result { + let native = EthereumBuiltin::from_str(&b.name)?; + let mut pricer = BTreeMap::new(); + + for (activate_at, p) in b.pricing { + pricer.insert(activate_at, p.price.into()); + } + + Ok(Self { pricer, native }) + } +} + +impl From for Pricing { + fn from(pricing: ethjson::spec::builtin::Pricing) -> Self { + match pricing { + ethjson::spec::builtin::Pricing::Blake2F { gas_per_round } => { + Pricing::Blake2F(gas_per_round) + } + ethjson::spec::builtin::Pricing::Linear(linear) => { + Pricing::Linear(Linear { base: linear.base, word: linear.word, }) } - ethjson::spec::Pricing::Modexp(exp) => { - Box::new(ModexpPricer { + ethjson::spec::builtin::Pricing::Modexp(exp) => { + Pricing::Modexp(ModexpPricer { divisor: if exp.divisor == 0 { - warn!(target: "builtin", "Zero modexp divisor specified. Falling back to default."); + warn!(target: "builtin", "Zero modexp divisor specified. Falling back to default: 10."); 10 } else { exp.divisor } }) } - ethjson::spec::Pricing::AltBn128Pairing(pricer) => { - Box::new(AltBn128PairingPricer { + ethjson::spec::builtin::Pricing::AltBn128Pairing(pricer) => { + Pricing::AltBn128Pairing(AltBn128PairingPricer { price: AltBn128PairingPrice { base: pricer.base, pair: pricer.pair, }, - eip1108_transition_at: b.eip1108_transition.map_or(u64::max_value(), Into::into), - eip1108_transition_price: AltBn128PairingPrice { - base: pricer.eip1108_transition_base, - pair: pricer.eip1108_transition_pair, - }, }) } - ethjson::spec::Pricing::AltBn128ConstOperations(pricer) => { - Box::new(AltBn128ConstOperations { - price: pricer.price, - eip1108_transition_price: pricer.eip1108_transition_price, - eip1108_transition_at: b.eip1108_transition.map_or(u64::max_value(), Into::into) + ethjson::spec::builtin::Pricing::AltBn128ConstOperations(pricer) => { + Pricing::AltBn128ConstOperations(AltBn128ConstOperations { + price: pricer.price }) } - }; - - let native = ethereum_builtin(&b.name)?; - Ok(Builtin { - pricer, - native, - activate_at: b.activate_at.map_or(0, Into::into), - }) + } } } -/// Ethereum built-in factory. -fn ethereum_builtin(name: &str) -> Result, EthcoreError> { - let implementation = match name { - "identity" => Box::new(Identity) as Box, - "ecrecover" => Box::new(EcRecover) as Box, - "sha256" => Box::new(Sha256) as Box, - "ripemd160" => Box::new(Ripemd160) as Box, - "modexp" => Box::new(Modexp) as Box, - "alt_bn128_add" => Box::new(Bn128Add) as Box, - "alt_bn128_mul" => Box::new(Bn128Mul) as Box, - "alt_bn128_pairing" => Box::new(Bn128Pairing) as Box, - "blake2_f" => Box::new(Blake2F) as Box, - _ => return Err(EthcoreError::Msg(format!("invalid builtin name: {}", name))), - }; - Ok(implementation) +/// Ethereum builtins: +enum EthereumBuiltin { + /// The identity function + Identity(Identity), + /// ec recovery + EcRecover(EcRecover), + /// sha256 + Sha256(Sha256), + /// ripemd160 + Ripemd160(Ripemd160), + /// modexp (EIP 198) + Modexp(Modexp), + /// alt_bn128_add + Bn128Add(Bn128Add), + /// alt_bn128_mul + Bn128Mul(Bn128Mul), + /// alt_bn128_pairing + Bn128Pairing(Bn128Pairing), + /// blake2_f (The Blake2 compression function F, EIP-152) + Blake2F(Blake2F) } -// Ethereum builtins: -// -// - The identity function -// - ec recovery -// - sha256 -// - ripemd160 -// - modexp (EIP198) -// - alt_bn128_add -// - alt_bn128_mul -// - alt_bn128_pairing -// - blake2_f (The Blake2 compression function F, EIP-152) +impl FromStr for EthereumBuiltin { + type Err = EthcoreError; + + fn from_str(name: &str) -> Result { + match name { + "identity" => Ok(EthereumBuiltin::Identity(Identity)), + "ecrecover" => Ok(EthereumBuiltin::EcRecover(EcRecover)), + "sha256" => Ok(EthereumBuiltin::Sha256(Sha256)), + "ripemd160" => Ok(EthereumBuiltin::Ripemd160(Ripemd160)), + "modexp" => Ok(EthereumBuiltin::Modexp(Modexp)), + "alt_bn128_add" => Ok(EthereumBuiltin::Bn128Add(Bn128Add)), + "alt_bn128_mul" => Ok(EthereumBuiltin::Bn128Mul(Bn128Mul)), + "alt_bn128_pairing" => Ok(EthereumBuiltin::Bn128Pairing(Bn128Pairing)), + "blake2_f" => Ok(EthereumBuiltin::Blake2F(Blake2F)), + _ => return Err(EthcoreError::Msg(format!("invalid builtin name: {}", name))), + } + } +} + +impl Implementation for EthereumBuiltin { + fn execute(&self, input: &[u8], output: &mut BytesRef) -> Result<(), &'static str> { + match self { + EthereumBuiltin::Identity(inner) => inner.execute(input, output), + EthereumBuiltin::EcRecover(inner) => inner.execute(input, output), + EthereumBuiltin::Sha256(inner) => inner.execute(input, output), + EthereumBuiltin::Ripemd160(inner) => inner.execute(input, output), + EthereumBuiltin::Modexp(inner) => inner.execute(input, output), + EthereumBuiltin::Bn128Add(inner) => inner.execute(input, output), + EthereumBuiltin::Bn128Mul(inner) => inner.execute(input, output), + EthereumBuiltin::Bn128Pairing(inner) => inner.execute(input, output), + EthereumBuiltin::Blake2F(inner) => inner.execute(input, output), + } + } +} #[derive(Debug)] pub struct Identity; @@ -351,7 +405,7 @@ impl Implementation for EcRecover { let s = H256::from_slice(&input[96..128]); let bit = match v[31] { - 27 | 28 if &v.0[..31] == &[0; 31] => v[31] - 27, + 27 | 28 if v.0[..31] == [0; 31] => v[31] - 27, _ => { return Ok(()); }, }; @@ -393,13 +447,13 @@ impl Implementation for Blake2F { // state vector, h let mut h = [0u64; 8]; - for state_word in h.iter_mut() { + for state_word in &mut h { *state_word = cursor.read_u64::().expect(PROOF); } // message block vector, m let mut m = [0u64; 16]; - for msg_word in m.iter_mut() { + for msg_word in &mut m { *msg_word = cursor.read_u64::().expect(PROOF); } @@ -452,7 +506,7 @@ fn modexp(mut base: BigUint, exp: Vec, modulus: BigUint) -> BigUint { let mut exp = exp.into_iter().skip_while(|d| *d == 0).peekable(); // n^0 % m - if let None = exp.peek() { + if exp.peek().is_none() { return BigUint::one(); } @@ -461,7 +515,7 @@ fn modexp(mut base: BigUint, exp: Vec, modulus: BigUint) -> BigUint { return BigUint::zero(); } - base = base % &modulus; + base %= &modulus; // Fast path for base divisible by modulus. if base.is_zero() { return BigUint::zero() } @@ -630,10 +684,11 @@ impl Bn128Pairing { fn execute_with_error(&self, input: &[u8], output: &mut BytesRef) -> Result<(), &'static str> { use bn::{AffineG1, AffineG2, Fq, Fq2, pairing_batch, G1, G2, Gt, Group}; - let elements = input.len() / 192; // (a, b_a, b_b - each 64-byte affine coordinates) - let ret_val = if input.len() == 0 { + let ret_val = if input.is_empty() { U256::one() } else { + // (a, b_a, b_b - each 64-byte affine coordinates) + let elements = input.len() / 192; let mut vals = Vec::new(); for idx in 0..elements { let a_x = Fq::from_slice(&input[idx*192..idx*192+32]) @@ -690,18 +745,24 @@ impl Bn128Pairing { mod tests { use std::convert::TryFrom; use ethereum_types::U256; - use ethjson::uint::Uint; + use ethjson::spec::builtin::{ + Builtin as JsonBuiltin, Linear as JsonLinearPricing, + PricingAt, AltBn128Pairing as JsonAltBn128PairingPricing, Pricing as JsonPricing, + }; + use hex_literal::hex; + use macros::map; use num::{BigUint, Zero, One}; use parity_bytes::BytesRef; - use hex_literal::hex; - use super::{Builtin, Linear, ethereum_builtin, Pricer, ModexpPricer, modexp as me}; + use super::{ + BTreeMap, Builtin, EthereumBuiltin, FromStr, Implementation, Linear, + ModexpPricer, modexp as me, Pricing + }; #[test] fn blake2f_cost() { let f = Builtin { - pricer: Box::new(123), - native: ethereum_builtin("blake2_f").expect("known builtin"), - activate_at: 0, + pricer: map![0 => Pricing::Blake2F(123)], + native: EthereumBuiltin::from_str("blake2_f").unwrap(), }; // 5 rounds let input = hex!("0000000548c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b61626300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000001"); @@ -714,9 +775,8 @@ mod tests { #[test] fn blake2f_cost_on_invalid_length() { let f = Builtin { - pricer: Box::new(123), - native: ethereum_builtin("blake2_f").expect("known builtin"), - activate_at: 0, + pricer: map![0 => Pricing::Blake2F(123)], + native: EthereumBuiltin::from_str("blake2_f").expect("known builtin"), }; // invalid input (too short) let input = hex!("00"); @@ -726,7 +786,7 @@ mod tests { #[test] fn blake2_f_is_err_on_invalid_length() { - let blake2 = ethereum_builtin("blake2_f").expect("known builtin"); + let blake2 = EthereumBuiltin::from_str("blake2_f").unwrap(); // Test vector 1 and expected output from https://github.com/ethereum/EIPs/blob/master/EIPS/eip-152.md#test-vector-1 let input = hex!("00000c48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b61626300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000001"); let mut out = [0u8; 64]; @@ -738,7 +798,7 @@ mod tests { #[test] fn blake2_f_is_err_on_invalid_length_2() { - let blake2 = ethereum_builtin("blake2_f").expect("known builtin"); + let blake2 = EthereumBuiltin::from_str("blake2_f").unwrap(); // Test vector 2 and expected output from https://github.com/ethereum/EIPs/blob/master/EIPS/eip-152.md#test-vector-2 let input = hex!("000000000c48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b61626300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000001"); let mut out = [0u8; 64]; @@ -750,7 +810,7 @@ mod tests { #[test] fn blake2_f_is_err_on_bad_finalization_flag() { - let blake2 = ethereum_builtin("blake2_f").expect("known builtin"); + let blake2 = EthereumBuiltin::from_str("blake2_f").unwrap(); // Test vector 3 and expected output from https://github.com/ethereum/EIPs/blob/master/EIPS/eip-152.md#test-vector-3 let input = hex!("0000000c48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b61626300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000002"); let mut out = [0u8; 64]; @@ -762,7 +822,7 @@ mod tests { #[test] fn blake2_f_zero_rounds_is_ok_test_vector_4() { - let blake2 = ethereum_builtin("blake2_f").expect("known builtin"); + let blake2 = EthereumBuiltin::from_str("blake2_f").unwrap(); // Test vector 4 and expected output from https://github.com/ethereum/EIPs/blob/master/EIPS/eip-152.md#test-vector-4 let input = hex!("0000000048c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b61626300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000001"); let expected = hex!("08c9bcf367e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d282e6ad7f520e511f6c3e2b8c68059b9442be0454267ce079217e1319cde05b"); @@ -773,7 +833,7 @@ mod tests { #[test] fn blake2_f_test_vector_5() { - let blake2 = ethereum_builtin("blake2_f").expect("known builtin"); + let blake2 = EthereumBuiltin::from_str("blake2_f").unwrap(); // Test vector 5 and expected output from https://github.com/ethereum/EIPs/blob/master/EIPS/eip-152.md#test-vector-5 let input = hex!("0000000c48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b61626300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000001"); let expected = hex!("ba80a53f981c4d0d6a2797b69f12f6e94c212f14685ac4b74b12bb6fdbffa2d17d87c5392aab792dc252d5de4533cc9518d38aa8dbf1925ab92386edd4009923"); @@ -784,7 +844,7 @@ mod tests { #[test] fn blake2_f_test_vector_6() { - let blake2 = ethereum_builtin("blake2_f").expect("known builtin"); + let blake2 = EthereumBuiltin::from_str("blake2_f").unwrap(); // Test vector 6 and expected output from https://github.com/ethereum/EIPs/blob/master/EIPS/eip-152.md#test-vector-6 let input = hex!("0000000c48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b61626300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000"); let expected = hex!("75ab69d3190a562c51aef8d88f1c2775876944407270c42c9844252c26d2875298743e7f6d5ea2f2d3e8d226039cd31b4e426ac4f2d3d666a610c2116fde4735"); @@ -795,7 +855,7 @@ mod tests { #[test] fn blake2_f_test_vector_7() { - let blake2 = ethereum_builtin("blake2_f").expect("known builtin"); + let blake2 = EthereumBuiltin::from_str("blake2_f").unwrap(); // Test vector 7 and expected output from https://github.com/ethereum/EIPs/blob/master/EIPS/eip-152.md#test-vector-7 let input = hex!("0000000148c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b61626300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000001"); let expected = hex!("b63a380cb2897d521994a85234ee2c181b5f844d2c624c002677e9703449d2fba551b3a8333bcdf5f2f7e08993d53923de3d64fcc68c034e717b9293fed7a421"); @@ -807,7 +867,7 @@ mod tests { #[ignore] #[test] fn blake2_f_test_vector_8() { - let blake2 = ethereum_builtin("blake2_f").expect("known builtin"); + let blake2 = EthereumBuiltin::from_str("blake2_f").unwrap(); // Test vector 8 and expected output from https://github.com/ethereum/EIPs/blob/master/EIPS/eip-152.md#test-vector-8 // Note this test is slow, 4294967295/0xffffffff rounds take a while. let input = hex!("ffffffff48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b61626300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000001"); @@ -852,8 +912,7 @@ mod tests { #[test] fn identity() { - let f = ethereum_builtin("identity").expect("known builtin"); - + let f = EthereumBuiltin::from_str("identity").unwrap(); let i = [0u8, 1, 2, 3]; let mut o2 = [255u8; 2]; @@ -872,8 +931,7 @@ mod tests { #[test] fn sha256() { - let f = ethereum_builtin("sha256").expect("known builtin"); - + let f = EthereumBuiltin::from_str("sha256").unwrap(); let i = [0u8; 0]; let mut o = [255u8; 32]; @@ -895,8 +953,7 @@ mod tests { #[test] fn ripemd160() { - let f = ethereum_builtin("ripemd160").expect("known builtin"); - + let f = EthereumBuiltin::from_str("ripemd160").unwrap(); let i = [0u8; 0]; let mut o = [255u8; 32]; @@ -914,7 +971,7 @@ mod tests { #[test] fn ecrecover() { - let f = ethereum_builtin("ecrecover").expect("known builtin"); + let f = EthereumBuiltin::from_str("ecrecover").unwrap(); let i = hex!("47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad000000000000000000000000000000000000000000000000000000000000001b650acf9d3f5f0a2c799776a1254355d5f4061762a237396a99a0e0e3fc2bcd6729514a0dacb2e623ac4abd157cb18163ff942280db4d5caad66ddf941ba12e03"); @@ -964,18 +1021,16 @@ mod tests { #[test] fn modexp() { - let f = Builtin { - pricer: Box::new(ModexpPricer { divisor: 20 }), - native: ethereum_builtin("modexp").expect("known builtin"), - activate_at: 0, + pricer: map![0 => Pricing::Modexp(ModexpPricer { divisor: 20 })], + native: EthereumBuiltin::from_str("modexp").unwrap(), }; // test for potential gas cost multiplication overflow { let input = hex!("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000003b27bafd00000000000000000000000000000000000000000000000000000000503c8ac3"); let expected_cost = U256::max_value(); - assert_eq!(f.cost(&input[..], 0), expected_cost.into()); + assert_eq!(f.cost(&input[..], 0), expected_cost); } // test for potential exp len overflow @@ -992,7 +1047,7 @@ mod tests { f.execute(&input[..], &mut BytesRef::Fixed(&mut output[..])).expect("Builtin should fail"); assert_eq!(output, expected); - assert_eq!(f.cost(&input[..], 0), expected_cost.into()); + assert_eq!(f.cost(&input[..], 0), expected_cost); } // fermat's little theorem example. @@ -1077,9 +1132,8 @@ mod tests { fn bn128_add() { let f = Builtin { - pricer: Box::new(Linear { base: 0, word: 0 }), - native: ethereum_builtin("alt_bn128_add").expect("known builtin"), - activate_at: 0, + pricer: map![0 => Pricing::Linear(Linear { base: 0, word: 0 })], + native: EthereumBuiltin::from_str("alt_bn128_add").unwrap(), }; // zero-points additions @@ -1136,9 +1190,8 @@ mod tests { fn bn128_mul() { let f = Builtin { - pricer: Box::new(Linear { base: 0, word: 0 }), - native: ethereum_builtin("alt_bn128_mul").expect("known builtin"), - activate_at: 0, + pricer: map![0 => Pricing::Linear(Linear { base: 0, word: 0 })], + native: EthereumBuiltin::from_str("alt_bn128_mul").unwrap(), }; // zero-point multiplication @@ -1176,9 +1229,8 @@ mod tests { fn builtin_pairing() -> Builtin { Builtin { - pricer: Box::new(Linear { base: 0, word: 0 }), - native: ethereum_builtin("alt_bn128_pairing").expect("known builtin"), - activate_at: 0, + pricer: map![0 => Pricing::Linear(Linear { base: 0, word: 0 })], + native: EthereumBuiltin::from_str("alt_bn128_pairing").unwrap(), } } @@ -1249,16 +1301,15 @@ mod tests { #[test] #[should_panic] fn from_unknown_linear() { - let _ = ethereum_builtin("foo").unwrap(); + let _ = EthereumBuiltin::from_str("foo").unwrap(); } #[test] fn is_active() { - let pricer = Box::new(Linear { base: 10, word: 20} ); + let pricer = Pricing::Linear(Linear { base: 10, word: 20 }); let b = Builtin { - pricer: pricer as Box, - native: ethereum_builtin("identity").expect("known builtin"), - activate_at: 100_000, + pricer: map![100_000 => pricer], + native: EthereumBuiltin::from_str("identity").unwrap(), }; assert!(!b.is_active(99_999)); @@ -1268,11 +1319,10 @@ mod tests { #[test] fn from_named_linear() { - let pricer = Box::new(Linear { base: 10, word: 20 }); + let pricer = Pricing::Linear(Linear { base: 10, word: 20 }); let b = Builtin { - pricer: pricer as Box, - native: ethereum_builtin("identity").expect("known builtin"), - activate_at: 1, + pricer: map![0 => pricer], + native: EthereumBuiltin::from_str("identity").unwrap(), }; assert_eq!(b.cost(&[0; 0], 0), U256::from(10)); @@ -1290,12 +1340,12 @@ mod tests { fn from_json() { let b = Builtin::try_from(ethjson::spec::Builtin { name: "identity".to_owned(), - pricing: ethjson::spec::Pricing::Linear(ethjson::spec::Linear { - base: 10, - word: 20, - }), - activate_at: None, - eip1108_transition: None, + pricing: map![ + 0 => PricingAt { + info: None, + price: JsonPricing::Linear(JsonLinearPricing { base: 10, word: 20 }) + } + ] }).expect("known builtin"); assert_eq!(b.cost(&[0; 0], 0), U256::from(10)); @@ -1311,17 +1361,25 @@ mod tests { #[test] fn bn128_pairing_eip1108_transition() { - let b = Builtin::try_from(ethjson::spec::Builtin { + let b = Builtin::try_from(JsonBuiltin { name: "alt_bn128_pairing".to_owned(), - pricing: ethjson::spec::Pricing::AltBn128Pairing(ethjson::spec::builtin::AltBn128Pairing { - base: 100_000, - pair: 80_000, - eip1108_transition_base: 45_000, - eip1108_transition_pair: 34_000, - }), - activate_at: Some(Uint(U256::from(10))), - eip1108_transition: Some(Uint(U256::from(20))), - }).expect("known builtin"); + pricing: map![ + 10 => PricingAt { + info: None, + price: JsonPricing::AltBn128Pairing(JsonAltBn128PairingPricing { + base: 100_000, + pair: 80_000, + }), + }, + 20 => PricingAt { + info: None, + price: JsonPricing::AltBn128Pairing(JsonAltBn128PairingPricing { + base: 45_000, + pair: 34_000, + }), + } + ], + }).unwrap(); assert_eq!(b.cost(&[0; 192 * 3], 10), U256::from(340_000), "80 000 * 3 + 100 000 == 340 000"); assert_eq!(b.cost(&[0; 192 * 7], 20), U256::from(283_000), "34 000 * 7 + 45 000 == 283 000"); @@ -1329,15 +1387,25 @@ mod tests { #[test] fn bn128_add_eip1108_transition() { - let b = Builtin::try_from(ethjson::spec::Builtin { + let b = Builtin::try_from(JsonBuiltin { name: "alt_bn128_add".to_owned(), - pricing: ethjson::spec::Pricing::AltBn128ConstOperations(ethjson::spec::builtin::AltBn128ConstOperations { - price: 500, - eip1108_transition_price: 150, - }), - activate_at: Some(Uint(U256::from(10))), - eip1108_transition: Some(Uint(U256::from(20))), - }).expect("known builtin"); + pricing: map![ + 10 => PricingAt { + info: None, + price: JsonPricing::Linear(JsonLinearPricing { + base: 500, + word: 0, + }), + }, + 20 => PricingAt { + info: None, + price: JsonPricing::Linear(JsonLinearPricing { + base: 150, + word: 0, + }), + } + ], + }).unwrap(); assert_eq!(b.cost(&[0; 192], 10), U256::from(500)); assert_eq!(b.cost(&[0; 10], 20), U256::from(150), "after istanbul hardfork gas cost for add should be 150"); @@ -1345,17 +1413,99 @@ mod tests { #[test] fn bn128_mul_eip1108_transition() { - let b = Builtin::try_from(ethjson::spec::Builtin { + let b = Builtin::try_from(JsonBuiltin { name: "alt_bn128_mul".to_owned(), - pricing: ethjson::spec::Pricing::AltBn128ConstOperations(ethjson::spec::builtin::AltBn128ConstOperations { - price: 40_000, - eip1108_transition_price: 6000, - }), - activate_at: Some(Uint(U256::from(10))), - eip1108_transition: Some(Uint(U256::from(20))), - }).expect("known builtin"); + pricing: map![ + 10 => PricingAt { + info: None, + price: JsonPricing::Linear(JsonLinearPricing { + base: 40_000, + word: 0, + }), + }, + 20 => PricingAt { + info: None, + price: JsonPricing::Linear(JsonLinearPricing { + base: 6_000, + word: 0, + }), + } + ], + }).unwrap(); assert_eq!(b.cost(&[0; 192], 10), U256::from(40_000)); assert_eq!(b.cost(&[0; 10], 20), U256::from(6_000), "after istanbul hardfork gas cost for mul should be 6 000"); } + + + #[test] + fn multimap_use_most_recent_on_activate() { + let b = Builtin::try_from(JsonBuiltin { + name: "alt_bn128_mul".to_owned(), + pricing: map![ + 10 => PricingAt { + info: None, + price: JsonPricing::Linear(JsonLinearPricing { + base: 40_000, + word: 0, + }), + }, + 20 => PricingAt { + info: None, + price: JsonPricing::Linear(JsonLinearPricing { + base: 6_000, + word: 0, + }) + }, + 100 => PricingAt { + info: None, + price: JsonPricing::Linear(JsonLinearPricing { + base: 1_337, + word: 0, + }) + } + ] + }).unwrap(); + + assert_eq!(b.cost(&[0; 2], 0), U256::zero(), "not activated yet; should be zero"); + assert_eq!(b.cost(&[0; 3], 10), U256::from(40_000), "use price #1"); + assert_eq!(b.cost(&[0; 4], 20), U256::from(6_000), "use price #2"); + assert_eq!(b.cost(&[0; 1], 99), U256::from(6_000), "use price #2"); + assert_eq!(b.cost(&[0; 1], 100), U256::from(1_337), "use price #3"); + assert_eq!(b.cost(&[0; 1], u64::max_value()), U256::from(1_337), "use price #3 indefinitely"); + } + + + #[test] + fn multimap_use_last_with_same_activate_at() { + let b = Builtin::try_from(JsonBuiltin { + name: "alt_bn128_mul".to_owned(), + pricing: map![ + 1 => PricingAt { + info: None, + price: JsonPricing::Linear(JsonLinearPricing { + base: 40_000, + word: 0, + }), + }, + 1 => PricingAt { + info: None, + price: JsonPricing::Linear(JsonLinearPricing { + base: 6_000, + word: 0, + }), + }, + 1 => PricingAt { + info: None, + price: JsonPricing::Linear(JsonLinearPricing { + base: 1_337, + word: 0, + }), + } + ], + }).unwrap(); + + assert_eq!(b.cost(&[0; 1], 0), U256::from(0), "not activated yet"); + assert_eq!(b.cost(&[0; 1], 1), U256::from(1_337), "use price #3"); + } } diff --git a/ethcore/engines/basic-authority/res/basic_authority.json b/ethcore/engines/basic-authority/res/basic_authority.json index 2d92355e3af..463b14afca8 100644 --- a/ethcore/engines/basic-authority/res/basic_authority.json +++ b/ethcore/engines/basic-authority/res/basic_authority.json @@ -42,12 +42,12 @@ "balance": "1", "builtin": { "name": "alt_bn128_add", - "activate_at": "0x0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0x0": { + "price": { "linear": { "base": 500, "word": 0 }} + }, + "0x7fffffffffffff": { + "price": { "linear": { "base": 150, "word": 0 }} } } } @@ -56,12 +56,12 @@ "balance": "1", "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0x0": { + "price": { "linear": { "base": 40000, "word": 0 }} + }, + "0x7fffffffffffff": { + "price": { "linear": { "base": 6000, "word": 0 }} } } } @@ -70,14 +70,12 @@ "balance": "1", "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0x0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/engines/basic-authority/src/lib.rs b/ethcore/engines/basic-authority/src/lib.rs index 2587d598697..99cb55ee648 100644 --- a/ethcore/engines/basic-authority/src/lib.rs +++ b/ethcore/engines/basic-authority/src/lib.rs @@ -35,7 +35,6 @@ use ethereum_types::{H256, H520}; use parking_lot::RwLock; use engine::{Engine, ConstructedVerifier, signer::EngineSigner}; use parity_crypto::publickey::Signature; -use ethjson; use log::trace; use machine::{Machine, executed_block::ExecutedBlock}; use rlp::Rlp; diff --git a/ethcore/machine/Cargo.toml b/ethcore/machine/Cargo.toml index dc33e75a968..f4db91a6f52 100644 --- a/ethcore/machine/Cargo.toml +++ b/ethcore/machine/Cargo.toml @@ -6,6 +6,11 @@ authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" +[[bench]] +name = "builtin_contract" +harness = false +required-features = ["test-helpers"] + [dependencies] account-state = { path = "../account-state" } client-traits = { path = "../client-traits" } @@ -34,6 +39,7 @@ vm = { path = "../vm" } [dev-dependencies] common-types = { path = "../types", features = ["test-helpers"] } +criterion = "0.3" ethcore = { path = "../", features = ["test-helpers"] } ethcore-io = { path = "../../util/io" } ethjson = { path = "../../json" } diff --git a/ethcore/machine/benches/builtin_contract.rs b/ethcore/machine/benches/builtin_contract.rs new file mode 100644 index 00000000000..626c249d34a --- /dev/null +++ b/ethcore/machine/benches/builtin_contract.rs @@ -0,0 +1,149 @@ +// Copyright 2015-2019 Parity Technologies (UK) Ltd. +// This file is part of Parity Ethereum. + +// Parity Ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity Ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity Ethereum. If not, see . + +//! Benchmarking of calling builtin contract + +use std::str::FromStr; + +use account_state::State; +use parity_bytes::Bytes; +use ethcore::test_helpers::get_temp_state_db; +use ethereum_types::{H160, U256}; +use criterion::{black_box, criterion_main, criterion_group, Criterion}; +use machine::{test_helpers, Machine}; +use machine::executive::CallCreateExecutive; +use machine::substate::Substate; +use trace::{NoopTracer, NoopVMTracer}; +use trie_vm_factories::VmFactory; +use vm::{ActionParams, EnvInfo, Schedule}; + +const ECRECOVER: &str = "0000000000000000000000000000000000000001"; +const SHA256: &str = "0000000000000000000000000000000000000002"; +const SIGNED_DATA: &str = "hash000000000001v000000000000002r000000000000003s000000000000004"; + +fn single_builtin_pricing() -> Machine { + test_helpers::load_machine(include_bytes!("../../res/ethereum/builtin_one_activation_bench.json")) +} + +fn multiple_builtin_pricing() -> Machine { + test_helpers::load_machine(include_bytes!("../../res/ethereum/builtin_multi_bench.json")) +} + +fn builtin_params(address: H160, execute: bool) -> ActionParams { + let mut params = ActionParams::default(); + params.code_address = address; + params.gas = u64::max_value().into(); + if execute { + params.data = Some(SIGNED_DATA.bytes().collect::()); + } + params +} + +fn single_activation(c: &mut Criterion) { + let contract = H160::from_str(ECRECOVER).unwrap(); + let params = builtin_params(contract, false); + + let env_info = EnvInfo::default(); + let machine = single_builtin_pricing(); + let schedule = Schedule::default(); + let factory = VmFactory::default(); + let depth = 0; + let stack_depth = 0; + let parent_static_flag = false; + + let db = get_temp_state_db(); + let mut state = State::new(db, U256::from(0), Default::default()); + let mut substate = Substate::new(); + + c.bench_function("single activation", move |b| { + b.iter(|| black_box(CallCreateExecutive::new_call_raw( + params.clone(), + &env_info, + &machine, + &schedule, + &factory, + depth, + stack_depth, + parent_static_flag, + ).exec(&mut state, &mut substate, &mut NoopTracer, &mut NoopVMTracer)) + ) + }); +} + +fn ten_multiple_activations(c: &mut Criterion) { + let contract = H160::from_str(ECRECOVER).unwrap(); + let params = builtin_params(contract, false); + + let env_info = EnvInfo::default(); + let machine = multiple_builtin_pricing(); + let schedule = Schedule::default(); + let factory = VmFactory::default(); + let depth = 0; + let stack_depth = 0; + let parent_static_flag = false; + + let db = get_temp_state_db(); + let mut state = State::new(db, U256::from(0), Default::default()); + let mut substate = Substate::new(); + + c.bench_function("ten activations", move |b| { + b.iter(|| black_box(CallCreateExecutive::new_call_raw( + params.clone(), + &env_info, + &machine, + &schedule, + &factory, + depth, + stack_depth, + parent_static_flag, + ).exec(&mut state, &mut substate, &mut NoopTracer, &mut NoopVMTracer)) + ) + }); +} + +fn fourty_multiple_activations(c: &mut Criterion) { + let contract = H160::from_str(SHA256).unwrap(); + let params = builtin_params(contract, false); + + let env_info = EnvInfo::default(); + let machine = multiple_builtin_pricing(); + let schedule = Schedule::default(); + let factory = VmFactory::default(); + let depth = 0; + let stack_depth = 0; + let parent_static_flag = false; + + let db = get_temp_state_db(); + let mut state = State::new(db, U256::from(0), Default::default()); + let mut substate = Substate::new(); + + c.bench_function("fourty activations", move |b| { + b.iter(|| black_box(CallCreateExecutive::new_call_raw( + params.clone(), + &env_info, + &machine, + &schedule, + &factory, + depth, + stack_depth, + parent_static_flag, + ).exec(&mut state, &mut substate, &mut NoopTracer, &mut NoopVMTracer)) + ) + }); +} + +criterion_group!(benches, single_activation, ten_multiple_activations, fourty_multiple_activations); +criterion_main!(benches); diff --git a/ethcore/machine/src/test_helpers.rs b/ethcore/machine/src/test_helpers.rs index aac33b9a92d..8f534b2f293 100644 --- a/ethcore/machine/src/test_helpers.rs +++ b/ethcore/machine/src/test_helpers.rs @@ -19,7 +19,6 @@ use std::convert::TryFrom; use common_types::engines::params::CommonParams; use ethcore_builtin::Builtin; -use ethjson; use crate::Machine; pub fn load_machine(reader: &[u8]) -> Machine { @@ -35,7 +34,6 @@ pub fn load_machine(reader: &[u8]) -> Machine { } } - /// Create a new Foundation Frontier-era chain spec as though it never changes to Homestead. pub fn new_frontier_test_machine() -> Machine { load_machine(include_bytes!("../../res/ethereum/frontier_test.json")) } diff --git a/ethcore/res/authority_round.json b/ethcore/res/authority_round.json index 33afa45871c..292760444d6 100644 --- a/ethcore/res/authority_round.json +++ b/ethcore/res/authority_round.json @@ -50,12 +50,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_add", - "activate_at": 0, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -64,12 +65,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_mul", - "activate_at": 0, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -78,14 +80,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_pairing", - "activate_at": 0, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/authority_round_block_reward_contract.json b/ethcore/res/authority_round_block_reward_contract.json index 73893d44d1d..4adb9a8d43c 100644 --- a/ethcore/res/authority_round_block_reward_contract.json +++ b/ethcore/res/authority_round_block_reward_contract.json @@ -53,12 +53,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_add", - "activate_at": 0, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -67,12 +68,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_mul", - "activate_at": 0, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -81,14 +83,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_pairing", - "activate_at": 0, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/constructor.json b/ethcore/res/constructor.json index 1383337351a..2e64335b58a 100644 --- a/ethcore/res/constructor.json +++ b/ethcore/res/constructor.json @@ -38,12 +38,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_add", - "activate_at": 0, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0": { + "price": { "linear": { "base": 500, "word": 0 }} + }, + "0x7fffffffffffff": { + "info": "EIP1108 transition", + "price": { "linear": { "base": 150, "word": 0 }} } } } @@ -52,12 +53,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_mul", - "activate_at": 0, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "linear": {"base": 40000, "word": 0 }} + }, + "0x7fffffffffffff": { + "info": "EIP1108 transition", + "price": { "linear": { "base": 6000, "word": 0 }} } } } @@ -66,14 +68,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_pairing", - "activate_at": 0, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/builtin_multi_bench.json b/ethcore/res/ethereum/builtin_multi_bench.json new file mode 100644 index 00000000000..a37273936fb --- /dev/null +++ b/ethcore/res/ethereum/builtin_multi_bench.json @@ -0,0 +1,112 @@ +{ + "name": "ecrecover legacy", + "engine": { + "Ethash": { + "params": { + "minimumDifficulty": "0x020000", + "difficultyBoundDivisor": "0x0800", + "durationLimit": "0x0d", + "blockReward": "0x4563918244F40000", + "homesteadTransition": "0x0" + } + } + }, + "params": { + "gasLimitBoundDivisor": "0x0400", + "registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b", + "accountStartNonce": "0x00", + "maximumExtraDataSize": "0x20", + "minGasLimit": "0x1388", + "networkID" : "0x1", + "eip150Transition": "0x0", + "eip160Transition": "0x7fffffffffffffff", + "eip161abcTransition": "0x7fffffffffffffff", + "eip161dTransition": "0x7fffffffffffffff", + "eip155Transition": "0x7fffffffffffffff", + "maxCodeSize": 24576, + "maxCodeSizeTransition": "0x7fffffffffffffff" + }, + "genesis": { + "seal": { + "ethereum": { + "nonce": "0x0000000000000042", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000" + } + }, + "difficulty": "0x400000000", + "author": "0x0000000000000000000000000000000000000000", + "timestamp": "0x00", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", + "gasLimit": "0x1388" + }, + "accounts": { + "0000000000000000000000000000000000000001": { + "balance": "1", + "builtin": { + "name": "ecrecover", + "pricing": { + "0": {"price": {"linear": { "base": 1, "word": 0 }}}, + "1": {"price": {"linear": { "base": 2, "word": 0 }}}, + "2": {"price": {"linear": { "base": 3, "word": 0 }}}, + "3": {"price": {"linear": { "base": 4, "word": 0 }}}, + "4": {"price": {"linear": { "base": 5, "word": 0 }}}, + "5": {"price": {"linear": { "base": 6, "word": 0 }}}, + "6": {"price": {"linear": { "base": 7, "word": 0 }}}, + "7": {"price": {"linear": { "base": 8, "word": 0 }}}, + "8": {"price": {"linear": { "base": 9, "word": 0 }}}, + "9": {"price": {"linear": { "base": 1, "word": 0 }}}, + "10": {"price": {"linear": { "base": 2, "word": 0 }}} + } + } + }, + "0000000000000000000000000000000000000002": { + "balance": "1", + "builtin": { + "name": "sha256", + "pricing": { + "0": {"price": {"linear": { "base": 1, "word": 0 }}}, + "1": {"price": {"linear": { "base": 2, "word": 0 }}}, + "2": {"price": {"linear": { "base": 3, "word": 0 }}}, + "3": {"price": {"linear": { "base": 4, "word": 0 }}}, + "4": {"price": {"linear": { "base": 5, "word": 0 }}}, + "5": {"price": {"linear": { "base": 6, "word": 0 }}}, + "6": {"price": {"linear": { "base": 7, "word": 0 }}}, + "7": {"price": {"linear": { "base": 8, "word": 0 }}}, + "8": {"price": {"linear": { "base": 9, "word": 0 }}}, + "9": {"price": {"linear": { "base": 1, "word": 0 }}}, + "10": {"price": {"linear": { "base": 2, "word": 0 }}}, + "11": {"price": {"linear": { "base": 3, "word": 0 }}}, + "12": {"price": {"linear": { "base": 4, "word": 0 }}}, + "13": {"price": {"linear": { "base": 5, "word": 0 }}}, + "14": {"price": {"linear": { "base": 6, "word": 0 }}}, + "15": {"price": {"linear": { "base": 7, "word": 0 }}}, + "16": {"price": {"linear": { "base": 8, "word": 0 }}}, + "17": {"price": {"linear": { "base": 9, "word": 0 }}}, + "18": {"price": {"linear": { "base": 1, "word": 0 }}}, + "19": {"price": {"linear": { "base": 2, "word": 0 }}}, + "20": {"price": {"linear": { "base": 3, "word": 0 }}}, + "21": {"price": {"linear": { "base": 4, "word": 0 }}}, + "22": {"price": {"linear": { "base": 5, "word": 0 }}}, + "23": {"price": {"linear": { "base": 6, "word": 0 }}}, + "24": {"price": {"linear": { "base": 7, "word": 0 }}}, + "25": {"price": {"linear": { "base": 8, "word": 0 }}}, + "26": {"price": {"linear": { "base": 9, "word": 0 }}}, + "27": {"price": {"linear": { "base": 1, "word": 0 }}}, + "28": {"price": {"linear": { "base": 2, "word": 0 }}}, + "29": {"price": {"linear": { "base": 3, "word": 0 }}}, + "30": {"price": {"linear": { "base": 4, "word": 0 }}}, + "31": {"price": {"linear": { "base": 5, "word": 0 }}}, + "32": {"price": {"linear": { "base": 6, "word": 0 }}}, + "33": {"price": {"linear": { "base": 7, "word": 0 }}}, + "34": {"price": {"linear": { "base": 8, "word": 0 }}}, + "35": {"price": {"linear": { "base": 9, "word": 0 }}}, + "36": {"price": {"linear": { "base": 10, "word": 0 }}}, + "37": {"price": {"linear": { "base": 10, "word": 0 }}}, + "38": {"price": {"linear": { "base": 10, "word": 0 }}}, + "39": {"price": {"linear": { "base": 10, "word": 0 }}} + } + } + } + } +} diff --git a/ethcore/res/ethereum/builtin_one_activation_bench.json b/ethcore/res/ethereum/builtin_one_activation_bench.json new file mode 100644 index 00000000000..e746d7b2a12 --- /dev/null +++ b/ethcore/res/ethereum/builtin_one_activation_bench.json @@ -0,0 +1,54 @@ +{ + "name": "ecrecover legacy chain spec for benchmarking", + "engine": { + "Ethash": { + "params": { + "minimumDifficulty": "0x020000", + "difficultyBoundDivisor": "0x0800", + "durationLimit": "0x0d", + "blockReward": "0x4563918244F40000", + "homesteadTransition": "0x0" + } + } + }, + "params": { + "gasLimitBoundDivisor": "0x0400", + "registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b", + "accountStartNonce": "0x00", + "maximumExtraDataSize": "0x20", + "minGasLimit": "0x1388", + "networkID" : "0x1", + "eip150Transition": "0x0", + "eip160Transition": "0x7fffffffffffffff", + "eip161abcTransition": "0x7fffffffffffffff", + "eip161dTransition": "0x7fffffffffffffff", + "eip155Transition": "0x7fffffffffffffff", + "maxCodeSize": 24576, + "maxCodeSizeTransition": "0x7fffffffffffffff" + }, + "genesis": { + "seal": { + "ethereum": { + "nonce": "0x0000000000000042", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000" + } + }, + "difficulty": "0x400000000", + "author": "0x0000000000000000000000000000000000000000", + "timestamp": "0x00", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", + "gasLimit": "0x1388" + }, + "accounts": { + "0000000000000000000000000000000000000001": { + "balance": "1", + "builtin": { + "name": "ecrecover", + "pricing": { + "linear": { "base": 3000, "word": 0 } + } + } + } + } +} diff --git a/ethcore/res/ethereum/byzantium_test.json b/ethcore/res/ethereum/byzantium_test.json index b4df953739b..bc5ac30207e 100644 --- a/ethcore/res/ethereum/byzantium_test.json +++ b/ethcore/res/ethereum/byzantium_test.json @@ -57,12 +57,13 @@ "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": "0x00", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -70,12 +71,13 @@ "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x00", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -83,14 +85,13 @@ "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x00", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/callisto.json b/ethcore/res/ethereum/callisto.json index 02dc3d27638..a1cae6f3c5a 100644 --- a/ethcore/res/ethereum/callisto.json +++ b/ethcore/res/ethereum/callisto.json @@ -76,12 +76,12 @@ "balance": "1", "builtin": { "name": "alt_bn128_add", - "activate_at": 20, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "20": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -90,12 +90,12 @@ "balance": "1", "builtin": { "name": "alt_bn128_mul", - "activate_at": 20, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "20": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -104,14 +104,12 @@ "balance": "1", "builtin": { "name": "alt_bn128_pairing", - "activate_at": 20, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "20": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/classic.json b/ethcore/res/ethereum/classic.json index 24cf47769b7..413fcabec79 100644 --- a/ethcore/res/ethereum/classic.json +++ b/ethcore/res/ethereum/classic.json @@ -4418,12 +4418,12 @@ "0x0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": "0x85d9a0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0x85d9a0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -4431,12 +4431,12 @@ "0x0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x85d9a0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0x85d9a0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -4444,14 +4444,12 @@ "0x0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x85d9a0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0x85d9a0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/constantinople_test.json b/ethcore/res/ethereum/constantinople_test.json index c61711e7a7f..cc5690e0d3d 100644 --- a/ethcore/res/ethereum/constantinople_test.json +++ b/ethcore/res/ethereum/constantinople_test.json @@ -61,12 +61,13 @@ "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": "0x00", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -74,12 +75,13 @@ "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x00", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -87,14 +89,13 @@ "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x00", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/eip210_test.json b/ethcore/res/ethereum/eip210_test.json index 782e99e5e9e..2cfeb7c61c2 100644 --- a/ethcore/res/ethereum/eip210_test.json +++ b/ethcore/res/ethereum/eip210_test.json @@ -49,12 +49,13 @@ "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": "0x00", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -62,12 +63,13 @@ "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x00", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -75,14 +77,13 @@ "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x00", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/ellaism.json b/ethcore/res/ethereum/ellaism.json index d1333fb7f3a..77fa6e347d0 100644 --- a/ethcore/res/ethereum/ellaism.json +++ b/ethcore/res/ethereum/ellaism.json @@ -69,12 +69,13 @@ "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": 2000000, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "2000000": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -82,12 +83,13 @@ "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": 2000000, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "2000000": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -95,14 +97,13 @@ "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": 2000000, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "2000000": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/ewc.json b/ethcore/res/ethereum/ewc.json index 53ceedd1744..f281e6533d4 100644 --- a/ethcore/res/ethereum/ewc.json +++ b/ethcore/res/ethereum/ewc.json @@ -849,13 +849,14 @@ "balance": "1", "builtin": { "name": "alt_bn128_add", - "activate_at": "0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 - } + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} + } } } }, @@ -863,12 +864,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_mul", - "activate_at": "0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -877,16 +879,15 @@ "balance": "1", "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } - } + } } }, "0x1204700000000000000000000000000000000005": { diff --git a/ethcore/res/ethereum/expanse.json b/ethcore/res/ethereum/expanse.json index 5b950e28b02..bbaa4275d2e 100644 --- a/ethcore/res/ethereum/expanse.json +++ b/ethcore/res/ethereum/expanse.json @@ -79,12 +79,13 @@ "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": "0xC3500", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0xC3500": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -92,12 +93,13 @@ "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": "0xC3500", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0xC3500": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -105,14 +107,13 @@ "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0xC3500", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0xC3500": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/foundation.json b/ethcore/res/ethereum/foundation.json index 13c0e81793f..0549568d9c9 100644 --- a/ethcore/res/ethereum/foundation.json +++ b/ethcore/res/ethereum/foundation.json @@ -4446,12 +4446,13 @@ "0x0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": "0x42ae50", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0x42ae50": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -4459,12 +4460,13 @@ "0x0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x42ae50", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0x42ae50": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -4472,14 +4474,13 @@ "0x0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x42ae50", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0x42ae50": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/goerli.json b/ethcore/res/ethereum/goerli.json index e7aaa4c485a..92b77b55c85 100644 --- a/ethcore/res/ethereum/goerli.json +++ b/ethcore/res/ethereum/goerli.json @@ -130,12 +130,13 @@ "balance": "0x1", "builtin": { "name": "alt_bn128_add", - "activate_at": "0x00", - "eip1108_transition": "0x17d433", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x17d433": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -144,12 +145,13 @@ "balance": "0x1", "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x00", - "eip1108_transition": "0x17d433", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x17d433": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -158,14 +160,13 @@ "balance": "0x1", "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x00", - "eip1108_transition": "0x17d433", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x17d433": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/istanbul_test.json b/ethcore/res/ethereum/istanbul_test.json index 1276dc4c53c..0139d10c2da 100644 --- a/ethcore/res/ethereum/istanbul_test.json +++ b/ethcore/res/ethereum/istanbul_test.json @@ -67,12 +67,13 @@ "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": "0x00", - "eip1108_transition": "0x0", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -80,12 +81,13 @@ "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x00", - "eip1108_transition": "0x0", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -93,14 +95,13 @@ "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x00", - "eip1108_transition": "0x0", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/kotti.json b/ethcore/res/ethereum/kotti.json index bc696a7db5a..81bd2c29608 100644 --- a/ethcore/res/ethereum/kotti.json +++ b/ethcore/res/ethereum/kotti.json @@ -116,12 +116,13 @@ "balance": "0x1", "builtin": { "name": "alt_bn128_add", - "activate_at": "0xaef49", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0xaef49": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -130,12 +131,13 @@ "balance": "0x1", "builtin": { "name": "alt_bn128_mul", - "activate_at": "0xaef49", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0xaef49": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -144,14 +146,13 @@ "balance": "0x1", "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0xaef49", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0xaef49": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/kovan.json b/ethcore/res/ethereum/kovan.json index cba31899bd4..dd5c3f65710 100644 --- a/ethcore/res/ethereum/kovan.json +++ b/ethcore/res/ethereum/kovan.json @@ -6726,12 +6726,13 @@ "0x0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": "0x4d50f8", - "eip1108_transition": "0xd751a5", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0x4d50f8": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0xd751a5": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -6739,12 +6740,13 @@ "0x0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x4d50f8", - "eip1108_transition": "0xd751a5", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0x4d50f8": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0xd751a5": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -6752,14 +6754,13 @@ "0x0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x4d50f8", - "eip1108_transition": "0xd751a5", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0x4d50f8": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0xd751a5": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/kovan_wasm_test.json b/ethcore/res/ethereum/kovan_wasm_test.json index 54c4a1b83f1..70143d8a8de 100644 --- a/ethcore/res/ethereum/kovan_wasm_test.json +++ b/ethcore/res/ethereum/kovan_wasm_test.json @@ -63,12 +63,13 @@ "0x0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": 5067000, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "5067000": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -76,12 +77,13 @@ "0x0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": 5067000, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "5067000": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -89,14 +91,13 @@ "0x0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": 5067000, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "5067000": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/mcip3_test.json b/ethcore/res/ethereum/mcip3_test.json index 8f1426b992a..aee04b36574 100644 --- a/ethcore/res/ethereum/mcip3_test.json +++ b/ethcore/res/ethereum/mcip3_test.json @@ -123,12 +123,13 @@ "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at":"0x7fffffffffffff", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0x7fffffffffffff": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -136,12 +137,13 @@ "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at":"0x7fffffffffffff", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0x7fffffffffffff": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -149,14 +151,13 @@ "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at":"0x7fffffffffffff", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0x7fffffffffffff": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/mix.json b/ethcore/res/ethereum/mix.json index 4be009ada2f..ae247a92f83 100644 --- a/ethcore/res/ethereum/mix.json +++ b/ethcore/res/ethereum/mix.json @@ -75,12 +75,13 @@ "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": 3000000, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "3000000": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -88,12 +89,13 @@ "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": 3000000, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "3000000": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -101,14 +103,13 @@ "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": 3000000, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "3000000": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/morden.json b/ethcore/res/ethereum/morden.json index a4be222c16c..442baea4bfb 100644 --- a/ethcore/res/ethereum/morden.json +++ b/ethcore/res/ethereum/morden.json @@ -75,7 +75,7 @@ "0000000000000000000000000000000000000002": { "balance": "1", "nonce": "1048576", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } }, "0000000000000000000000000000000000000003": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } }, "0000000000000000000000000000000000000004": { "balance": "1", "nonce": "1048576", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }, - "0x0000000000000000000000000000000000000005": { + "0000000000000000000000000000000000000005": { "builtin": { "name": "modexp", "activate_at": "0x4829ba", @@ -86,43 +86,44 @@ } } }, - "0x0000000000000000000000000000000000000006": { + "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": "0x4829ba", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0x4829ba": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } }, - "0x0000000000000000000000000000000000000007": { + "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x4829ba", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0x4829ba": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } }, - "0x0000000000000000000000000000000000000008": { + "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x4829ba", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0x4829ba": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/musicoin.json b/ethcore/res/ethereum/musicoin.json index a7cc956b47d..cc60dc1bd5b 100644 --- a/ethcore/res/ethereum/musicoin.json +++ b/ethcore/res/ethereum/musicoin.json @@ -131,12 +131,13 @@ "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at":"0x21e88e", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0x21e88e": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -144,12 +145,13 @@ "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at":"0x21e88e", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0x21e88e": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -157,14 +159,13 @@ "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at":"0x21e88e", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0x21e88e": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/poacore.json b/ethcore/res/ethereum/poacore.json index 4372f51f464..36c26fc1d47 100644 --- a/ethcore/res/ethereum/poacore.json +++ b/ethcore/res/ethereum/poacore.json @@ -5410,12 +5410,13 @@ "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": "0x0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -5423,12 +5424,13 @@ "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -5436,14 +5438,13 @@ "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/poasokol.json b/ethcore/res/ethereum/poasokol.json index 11dc67d3559..c8f1f03e5ed 100644 --- a/ethcore/res/ethereum/poasokol.json +++ b/ethcore/res/ethereum/poasokol.json @@ -5316,12 +5316,13 @@ "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": "0x0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -5329,12 +5330,13 @@ "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -5342,19 +5344,17 @@ "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } }, - "0x0000000000000000000000000000000000000001": { "balance": "1", "builtin": { diff --git a/ethcore/res/ethereum/rinkeby.json b/ethcore/res/ethereum/rinkeby.json index 790d6d33eaf..bcc96a80129 100644 --- a/ethcore/res/ethereum/rinkeby.json +++ b/ethcore/res/ethereum/rinkeby.json @@ -125,12 +125,13 @@ "balance": "0x1", "builtin": { "name": "alt_bn128_add", - "activate_at": "0xfcc25", - "eip1108_transition": "0x52efd1", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0xfcc25": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x52efd1": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -139,12 +140,13 @@ "balance": "0x1", "builtin": { "name": "alt_bn128_mul", - "activate_at": "0xfcc25", - "eip1108_transition": "0x52efd1", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0xfcc25": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x52efd1": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -153,14 +155,13 @@ "balance": "0x1", "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0xfcc25", - "eip1108_transition": "0x52efd1", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0xfcc25": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x52efd1": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/ropsten.json b/ethcore/res/ethereum/ropsten.json index aefca8682cc..f65a77ac750 100644 --- a/ethcore/res/ethereum/ropsten.json +++ b/ethcore/res/ethereum/ropsten.json @@ -2739,12 +2739,13 @@ "nonce": "0x0", "builtin": { "name": "alt_bn128_add", - "activate_at": "0x19f0a0", - "eip1108_transition": "0x62f756", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0x19f0a0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x62f756": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -2754,12 +2755,13 @@ "nonce": "0x0", "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x19f0a0", - "eip1108_transition": "0x62f756", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0x19f0a0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x62f756": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -2769,14 +2771,13 @@ "nonce": "0x0", "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x19f0a0", - "eip1108_transition": "0x62f756", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0x19f0a0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x62f756": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/st_peters_test.json b/ethcore/res/ethereum/st_peters_test.json index 768e6057fd2..ac404c7dca1 100644 --- a/ethcore/res/ethereum/st_peters_test.json +++ b/ethcore/res/ethereum/st_peters_test.json @@ -62,12 +62,13 @@ "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": "0x0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -75,12 +76,13 @@ "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -88,14 +90,13 @@ "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/transition_test.json b/ethcore/res/ethereum/transition_test.json index bc28ebd509b..901f4dfded3 100644 --- a/ethcore/res/ethereum/transition_test.json +++ b/ethcore/res/ethereum/transition_test.json @@ -60,12 +60,13 @@ "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": "5", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "5": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -73,12 +74,13 @@ "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": "5", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "5": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -86,14 +88,13 @@ "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": "5", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "5": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/volta.json b/ethcore/res/ethereum/volta.json index 62745086b67..55cc39d9997 100644 --- a/ethcore/res/ethereum/volta.json +++ b/ethcore/res/ethereum/volta.json @@ -1207,46 +1207,47 @@ "balance": "1", "builtin": { "name": "alt_bn128_add", - "activate_at": "0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } - }, - "0x0000000000000000000000000000000000000007": { + }, + "0x0000000000000000000000000000000000000007": { "balance": "1", "builtin": { "name": "alt_bn128_mul", - "activate_at": "0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } - } + } }, "0x0000000000000000000000000000000000000008": { "balance": "1", "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } - }, + }, "0x1204700000000000000000000000000000000005": { "constructor": "0x606060405234156200001057600080fd5b6040516200240138038062002401833981016040528080518201919060200180519060200190919050505b600082518260328211158015620000525750818111155b801562000060575060008114155b80156200006e575060008214155b15156200007a57600080fd5b600092505b8451831015620001b6576002600086858151811015156200009c57fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156200012b5750600085848151811015156200010857fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1614155b15156200013757600080fd5b60016002600087868151811015156200014c57fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b82806001019350506200007f565b8460039080519060200190620001ce929190620001e3565b50836004819055505b5b5050505050620002b8565b8280548282559060005260206000209081019282156200025f579160200282015b828111156200025e5782518260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509160200191906001019062000204565b5b5090506200026e919062000272565b5090565b620002b591905b80821115620002b157600081816101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690555060010162000279565b5090565b90565b61213980620002c86000396000f3006060604052361561011b576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063025e7c2714610177578063173825d9146101da57806320ea8d86146102135780632f54bf6e146102365780633411c81c1461028757806354741525146102e15780637065cb4814610325578063784547a71461035e5780638b51d13f146103995780639ace38c2146103d0578063a0e67e2b146104ce578063a8abe69a14610539578063b5dc40c3146105d1578063b77bf6001461064a578063ba51a6df14610673578063c01a8c8414610696578063c6427474146106b9578063d74f8edd14610752578063dc8452cd1461077b578063e20056e6146107a4578063ee22610b146107fc575b5b6000341115610174573373ffffffffffffffffffffffffffffffffffffffff167fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c346040518082815260200191505060405180910390a25b5b005b341561018257600080fd5b610198600480803590602001909190505061081f565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156101e557600080fd5b610211600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061085f565b005b341561021e57600080fd5b6102346004808035906020019091905050610b02565b005b341561024157600080fd5b61026d600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610cae565b604051808215151515815260200191505060405180910390f35b341561029257600080fd5b6102c7600480803590602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610cce565b604051808215151515815260200191505060405180910390f35b34156102ec57600080fd5b61030f600480803515159060200190919080351515906020019091905050610cfd565b6040518082815260200191505060405180910390f35b341561033057600080fd5b61035c600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610d91565b005b341561036957600080fd5b61037f6004808035906020019091905050610f99565b604051808215151515815260200191505060405180910390f35b34156103a457600080fd5b6103ba6004808035906020019091905050611081565b6040518082815260200191505060405180910390f35b34156103db57600080fd5b6103f16004808035906020019091905050611150565b604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200184815260200180602001831515151581526020018281038252848181546001816001161561010002031660029004815260200191508054600181600116156101000203166002900480156104bc5780601f10610491576101008083540402835291602001916104bc565b820191906000526020600020905b81548152906001019060200180831161049f57829003601f168201915b50509550505050505060405180910390f35b34156104d957600080fd5b6104e16111ac565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156105255780820151818401525b602081019050610509565b505050509050019250505060405180910390f35b341561054457600080fd5b610579600480803590602001909190803590602001909190803515159060200190919080351515906020019091905050611241565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156105bd5780820151818401525b6020810190506105a1565b505050509050019250505060405180910390f35b34156105dc57600080fd5b6105f260048080359060200190919050506113a2565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156106365780820151818401525b60208101905061061a565b505050509050019250505060405180910390f35b341561065557600080fd5b61065d6115d3565b6040518082815260200191505060405180910390f35b341561067e57600080fd5b61069460048080359060200190919050506115d9565b005b34156106a157600080fd5b6106b76004808035906020019091905050611696565b005b34156106c457600080fd5b61073c600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050611877565b6040518082815260200191505060405180910390f35b341561075d57600080fd5b610765611897565b6040518082815260200191505060405180910390f35b341561078657600080fd5b61078e61189c565b6040518082815260200191505060405180910390f35b34156107af57600080fd5b6107fa600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506118a2565b005b341561080757600080fd5b61081d6004808035906020019091905050611bc0565b005b60038181548110151561082e57fe5b906000526020600020900160005b915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561089b57600080fd5b81600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615156108f457600080fd5b6000600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550600091505b600160038054905003821015610a80578273ffffffffffffffffffffffffffffffffffffffff1660038381548110151561098757fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415610a725760036001600380549050038154811015156109e757fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600383815481101515610a2357fe5b906000526020600020900160005b6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610a80565b5b8180600101925050610951565b6001600381818054905003915081610a989190611fe8565b506003805490506004541115610ab757610ab66003805490506115d9565b5b8273ffffffffffffffffffffffffffffffffffffffff167f8001553a916ef2f495d26a907cc54d96ed840d7bda71e73194bf5a9df7a76b9060405160405180910390a25b5b505b5050565b33600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515610b5b57600080fd5b81336001600083815260200190815260200160002060008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515610bc657600080fd5b8360008082815260200190815260200160002060030160009054906101000a900460ff16151515610bf657600080fd5b60006001600087815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550843373ffffffffffffffffffffffffffffffffffffffff167ff6a317157440607f36269043eb55f1287a5a19ba2216afeab88cd46cbcfb88e960405160405180910390a35b5b505b50505b5050565b60026020528060005260406000206000915054906101000a900460ff1681565b60016020528160005260406000206020528060005260406000206000915091509054906101000a900460ff1681565b600080600090505b600554811015610d8957838015610d3c575060008082815260200190815260200160002060030160009054906101000a900460ff16155b80610d6f5750828015610d6e575060008082815260200190815260200160002060030160009054906101000a900460ff165b5b15610d7b576001820191505b5b8080600101915050610d05565b5b5092915050565b3073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610dcb57600080fd5b80600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151515610e2557600080fd5b8160008173ffffffffffffffffffffffffffffffffffffffff1614151515610e4c57600080fd5b60016003805490500160045460328211158015610e695750818111155b8015610e76575060008114155b8015610e83575060008214155b1515610e8e57600080fd5b6001600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060038054806001018281610efa9190612014565b916000526020600020900160005b87909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550508473ffffffffffffffffffffffffffffffffffffffff167ff39e6e1eb0edcf53c221607b54b00cd28f3196fed0a24994dc308b8f611b682d60405160405180910390a25b5b50505b505b505b50565b6000806000809150600090505b60038054905081101561107957600160008581526020019081526020016000206000600383815481101515610fd757fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611058576001820191505b60045482141561106b576001925061107a565b5b8080600101915050610fa6565b5b5050919050565b600080600090505b600380549050811015611149576001600084815260200190815260200160002060006003838154811015156110ba57fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561113b576001820191505b5b8080600101915050611089565b5b50919050565b60006020528060005260406000206000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169080600101549080600201908060030160009054906101000a900460ff16905084565b6111b4612040565b600380548060200260200160405190810160405280929190818152602001828054801561123657602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190600101908083116111ec575b505050505090505b90565b611249612054565b611251612054565b6000806005546040518059106112645750595b908082528060200260200182016040525b50925060009150600090505b600554811015611322578580156112b8575060008082815260200190815260200160002060030160009054906101000a900460ff16155b806112eb57508480156112ea575060008082815260200190815260200160002060030160009054906101000a900460ff165b5b15611314578083838151811015156112ff57fe5b90602001906020020181815250506001820191505b5b8080600101915050611281565b8787036040518059106113325750595b908082528060200260200182016040525b5093508790505b8681101561139657828181518110151561136057fe5b906020019060200201518489830381518110151561137a57fe5b90602001906020020181815250505b808060010191505061134a565b5b505050949350505050565b6113aa612040565b6113b2612040565b6000806003805490506040518059106113c85750595b908082528060200260200182016040525b50925060009150600090505b60038054905081101561152b5760016000868152602001908152602001600020600060038381548110151561141657fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561151d5760038181548110151561149f57fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1683838151811015156114da57fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506001820191505b5b80806001019150506113e5565b816040518059106115395750595b908082528060200260200182016040525b509350600090505b818110156115ca57828181518110151561156857fe5b90602001906020020151848281518110151561158057fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250505b8080600101915050611552565b5b505050919050565b60055481565b3073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561161357600080fd5b600380549050816032821115801561162b5750818111155b8015611638575060008114155b8015611645575060008214155b151561165057600080fd5b826004819055507fa3f1ee9126a074d9326c682f561767f710e927faa811f7a99829d49dc421797a836040518082815260200191505060405180910390a15b5b50505b50565b33600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615156116ef57600080fd5b81600080600083815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415151561174b57600080fd5b82336001600083815260200190815260200160002060008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515156117b757600080fd5b600180600087815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550843373ffffffffffffffffffffffffffffffffffffffff167f4a504a94899432a9846e1aa406dceb1bcfd538bb839071d49d1e5e23f5be30ef60405160405180910390a361186c85611bc0565b5b5b50505b505b5050565b6000611884848484611e6c565b905061188f81611696565b5b9392505050565b603281565b60045481565b60003073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156118de57600080fd5b82600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151561193757600080fd5b82600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151561199157600080fd5b600092505b600380549050831015611a7f578473ffffffffffffffffffffffffffffffffffffffff166003848154811015156119c957fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611a715783600384815481101515611a2257fe5b906000526020600020900160005b6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550611a7f565b5b8280600101935050611996565b6000600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508473ffffffffffffffffffffffffffffffffffffffff167f8001553a916ef2f495d26a907cc54d96ed840d7bda71e73194bf5a9df7a76b9060405160405180910390a28373ffffffffffffffffffffffffffffffffffffffff167ff39e6e1eb0edcf53c221607b54b00cd28f3196fed0a24994dc308b8f611b682d60405160405180910390a25b5b505b505b505050565b600033600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515611c1b57600080fd5b82336001600083815260200190815260200160002060008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515611c8657600080fd5b8460008082815260200190815260200160002060030160009054906101000a900460ff16151515611cb657600080fd5b611cbf86610f99565b15611e6057600080878152602001908152602001600020945060018560030160006101000a81548160ff021916908315150217905550611ddd8560000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16866001015487600201805460018160011615610100020316600290049050886002018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611dd35780601f10611da857610100808354040283529160200191611dd3565b820191906000526020600020905b815481529060010190602001808311611db657829003601f168201915b5050505050611fc0565b15611e1457857f33e13ecb54c3076d8e8bb8c2881800a4d972b792045ffae98fdf46df365fed7560405160405180910390a2611e5f565b857f526441bb6c1aba3c9a4a6ca1d6545da9c2333c8c48343ef398eb858d72b7923660405160405180910390a260008560030160006101000a81548160ff0219169083151502179055505b5b5b5b505b50505b505050565b60008360008173ffffffffffffffffffffffffffffffffffffffff1614151515611e9557600080fd5b60055491506080604051908101604052808673ffffffffffffffffffffffffffffffffffffffff1681526020018581526020018481526020016000151581525060008084815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550602082015181600101556040820151816002019080519060200190611f54929190612068565b5060608201518160030160006101000a81548160ff0219169083151502179055509050506001600560008282540192505081905550817fc0ba8fe4b176c1714197d43b9cc6bcf797a4a7461c5fe8d0ef6e184ae7601e5160405160405180910390a25b5b509392505050565b6000806040516020840160008287838a8c6187965a03f1925050508091505b50949350505050565b81548183558181151161200f5781836000526020600020918201910161200e91906120e8565b5b505050565b81548183558181151161203b5781836000526020600020918201910161203a91906120e8565b5b505050565b602060405190810160405280600081525090565b602060405190810160405280600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106120a957805160ff19168380011785556120d7565b828001600101855582156120d7579182015b828111156120d65782518255916020019190600101906120bb565b5b5090506120e491906120e8565b5090565b61210a91905b808211156121065760008160009055506001016120ee565b5090565b905600a165627a7a72305820f1129b699b3017535535a920e15503cd06af1f5c77637c0637cc29355b1dad3400290000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000040000000000000000000000000cb1437200aea736788f1fc56f327c0456c3598d00000000000000000000000074dd76e24b2cfb43c1b1a4498295d553d0843746000000000000000000000000eeb4ceee443f9e0d17bdbd6daa241681ee5e51c2000000000000000000000000a005caea55375ae20e3aaef746113535503abc19" }, diff --git a/ethcore/res/ethereum/xdai.json b/ethcore/res/ethereum/xdai.json index f83ae524ff0..f57c982e07b 100644 --- a/ethcore/res/ethereum/xdai.json +++ b/ethcore/res/ethereum/xdai.json @@ -2862,7 +2862,7 @@ ] }, "accounts": { - "0000000000000000000000000000000000000005": { + "0x0000000000000000000000000000000000000005": { "builtin": { "name": "modexp", "activate_at": "0x0", @@ -2873,43 +2873,44 @@ } } }, - "0000000000000000000000000000000000000006": { + "0x0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": "0x0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } }, - "0000000000000000000000000000000000000007": { + "0x0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } }, - "0000000000000000000000000000000000000008": { + "0x0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/instant_seal.json b/ethcore/res/instant_seal.json index 0bd79204fb9..b2199ebc35a 100644 --- a/ethcore/res/instant_seal.json +++ b/ethcore/res/instant_seal.json @@ -50,12 +50,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_add", - "activate_at": 0, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -64,12 +65,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_mul", - "activate_at": 0, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -78,14 +80,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_pairing", - "activate_at": 0, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/null.json b/ethcore/res/null.json index 5128f26c59c..82062366d8d 100644 --- a/ethcore/res/null.json +++ b/ethcore/res/null.json @@ -40,12 +40,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_add", - "activate_at": 0, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -54,12 +55,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_mul", - "activate_at": 0, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -68,14 +70,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_pairing", - "activate_at": 0, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/spec_backward_compability.json b/ethcore/res/spec_backward_compability.json new file mode 100644 index 00000000000..e8ce98a6ec4 --- /dev/null +++ b/ethcore/res/spec_backward_compability.json @@ -0,0 +1,155 @@ +{ + "name": "Volta", + "engine": { + "authorityRound": { + "params": { + "stepDuration": "5", + "validators": { + "contract": "0x1204700000000000000000000000000000000000" + }, + "maximumUncleCountTransition": "0", + "maximumUncleCount": "0", + "blockRewardContractAddress": "0x1204700000000000000000000000000000000002", + "blockRewardContractTransition": "0" + } + } + }, + "params": { + "networkID": "0x12047", + "maximumExtraDataSize": "0x20", + "gasLimitBoundDivisor": "0x400", + "minGasLimit": "0x1388", + "maxCodeSize": "0x6000", + "eip140Transition": "0x0", + "eip211Transition": "0x0", + "eip214Transition": "0x0", + "eip658Transition": "0x0", + "eip145Transition": "0x0", + "eip1014Transition": "0x0", + "eip1052Transition": "0x0", + "registrar": "0x1204700000000000000000000000000000000006" + }, + "genesis": { + "seal": { + "authorityRound": { + "step": "0x0", + "signature": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + } + }, + "difficulty": "0x20000", + "gasLimit": "0x5B8D80" + }, + "accounts": { + "0x0000000000000000000000000000000000000001": { + "balance": "1", + "builtin": { + "name": "ecrecover", + "activate_at": "0", + "pricing": { + "linear": { + "base": 3000, + "word": 0 + } + } + } + }, + "0x0000000000000000000000000000000000000002": { + "balance": "1", + "builtin": { + "name": "sha256", + "activate_at": "0", + "pricing": { + "linear": { + "base": 60, + "word": 12 + } + } + } + }, + "0x0000000000000000000000000000000000000003": { + "balance": "1", + "builtin": { + "name": "ripemd160", + "activate_at": "0", + "pricing": { + "linear": { + "base": 600, + "word": 120 + } + } + } + }, + "0x0000000000000000000000000000000000000004": { + "balance": "1", + "builtin": { + "name": "identity", + "activate_at": "0", + "pricing": { + "linear": { + "base": 15, + "word": 3 + } + } + } + }, + "0x0000000000000000000000000000000000000005": { + "balance": "1", + "builtin": { + "name": "modexp", + "activate_at": "0", + "pricing": { + "modexp": { + "divisor": 20 + } + } + } + }, + "0x0000000000000000000000000000000000000006": { + "balance": "1", + "builtin": { + "name": "alt_bn128_add", + "activate_at": "0", + "pricing": { + "linear": { + "base": 500, + "word": 0 + } + } + } + }, + "0x0000000000000000000000000000000000000007": { + "balance": "1", + "builtin": { + "name": "alt_bn128_mul", + "activate_at": "0", + "pricing": { + "linear": { + "base": 40000, + "word": 0 + } + } + } + }, + "0x0000000000000000000000000000000000000008": { + "balance": "1", + "builtin": { + "name": "alt_bn128_pairing", + "activate_at": "0", + "pricing": { + "alt_bn128_pairing": { + "base": 100000, + "pair": 80000 + } + } + } + } + }, + "nodes": [ + "enode://59c9250cb805409e84c9cd0038e97d8e5e4605b928663675869ebdfd4c251d80ccad76267a5eb2f4362ddceb5ec671f7595463adfc0a12e9f68dbf233072db41@54.70.158.106:30303", + "enode://e487ebacbdad3418905d2ed7f009fa5dbd17d73880854884acc604c0afc1a60a396aa90cb2741278c555a4e30ffc6ffc1c29e83840aa22009ec92fe53f81ec04@99.81.92.124:30303", + "enode://563f12602a117201b39ebeea108185abb15d9286830c074640c9fccbaaaabcc7fe2c95682cc43f95b95059f6d0dc4c9becbc1b2bd78e0c5ef5fddff07d85ba0e@54.201.62.74:30303", + "enode://5903b3acebdc4a34800f6923e5f3aec3ca7e5d1285bec4adb9f20ebb0f87a3bebdd748b1849ca1108a9f1e37ff9ced0b475292b8effc29e95d49ec438f244b02@3.121.165.10:30303", + "enode://8f8e35a6dcacfee946f46447b4703c84f4e485e478143997f86b1834e1b0bb78dab363d700dff3147442b9d3e2a1c521f79340c436eb7245a97c7fe385b89a5d@54.93.159.98:30303", + "enode://bd228aa03cf4a88491c81c5f3ab4a1437df3b463081cc93943c4d3ab37f1e4f8081c6995eca076f717d4fdf9a277c750bd0289477ac151f1e2b024747dcd1747@52.31.129.130:30303" + ] +} diff --git a/ethcore/spec/src/spec.rs b/ethcore/spec/src/spec.rs index 093e6905dbe..017d21bb81f 100644 --- a/ethcore/spec/src/spec.rs +++ b/ethcore/spec/src/spec.rs @@ -258,10 +258,10 @@ impl fmt::Display for SpecHardcodedSync { } fn convert_json_to_spec( - pair: (ethjson::hash::Address, ethjson::spec::Builtin), + (address, builtin): (ethjson::hash::Address, ethjson::spec::builtin::Builtin), ) -> Result<(Address, Builtin), Error> { - let builtin = Builtin::try_from(pair.1)?; - Ok((pair.0.into(), builtin)) + let builtin = Builtin::try_from(builtin)?; + Ok((address.into(), builtin)) } /// Load from JSON object. diff --git a/json/src/spec/account.rs b/json/src/spec/account.rs index 6d722ea2385..72cdb3607fd 100644 --- a/json/src/spec/account.rs +++ b/json/src/spec/account.rs @@ -18,16 +18,17 @@ use std::collections::BTreeMap; -use crate::{bytes::Bytes, spec::builtin::Builtin, uint::Uint}; +use crate::{bytes::Bytes, spec::builtin::BuiltinCompat, uint::Uint}; use serde::Deserialize; /// Spec account. #[cfg_attr(any(test, feature = "test-helpers"), derive(Clone))] #[derive(Debug, PartialEq, Deserialize)] #[serde(deny_unknown_fields)] +#[serde(rename_all = "camelCase")] pub struct Account { /// Builtin contract. - pub builtin: Option, + pub builtin: Option, /// Balance. pub balance: Option, /// Nonce. @@ -101,7 +102,15 @@ mod tests { #[test] fn account_empty() { let s = r#"{ - "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } + "builtin": { + "name": "ecrecover", + "pricing": { + "linear": { + "base": 3000, + "word": 0 + } + } + } }"#; let deserialized: Account = serde_json::from_str(s).unwrap(); assert!(deserialized.is_empty()); @@ -112,8 +121,16 @@ mod tests { let s = r#"{ "balance": "1", "nonce": "0", - "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } }, - "code": "1234" + "code": "1234", + "builtin": { + "name": "ecrecover", + "pricing": { + "linear": { + "base": 3000, + "word": 0 + } + } + } }"#; let deserialized: Account = serde_json::from_str(s).unwrap(); assert!(!deserialized.is_empty()); diff --git a/json/src/spec/builtin.rs b/json/src/spec/builtin.rs index f751750dd25..471b738573f 100644 --- a/json/src/spec/builtin.rs +++ b/json/src/spec/builtin.rs @@ -16,18 +16,19 @@ //! Spec builtin deserialization. +use std::collections::BTreeMap; + use crate::uint::Uint; use serde::Deserialize; - /// Linear pricing. #[derive(Debug, PartialEq, Deserialize, Clone)] #[serde(deny_unknown_fields)] pub struct Linear { /// Base price. - pub base: usize, + pub base: u64, /// Price for word. - pub word: usize, + pub word: u64, } /// Pricing for modular exponentiation. @@ -35,7 +36,7 @@ pub struct Linear { #[serde(deny_unknown_fields)] pub struct Modexp { /// Price divisor. - pub divisor: usize, + pub divisor: u64, } /// Pricing for constant alt_bn128 operations (ECADD and ECMUL) @@ -43,9 +44,7 @@ pub struct Modexp { #[serde(deny_unknown_fields)] pub struct AltBn128ConstOperations { /// price - pub price: usize, - /// EIP 1108 transition price - pub eip1108_transition_price: usize, + pub price: u64, } /// Pricing for alt_bn128_pairing. @@ -53,13 +52,9 @@ pub struct AltBn128ConstOperations { #[serde(deny_unknown_fields)] pub struct AltBn128Pairing { /// Base price. - pub base: usize, + pub base: u64, /// Price per point pair. - pub pair: usize, - /// EIP 1108 transition base price - pub eip1108_transition_base: usize, - /// EIP 1108 transition price per point pair - pub eip1108_transition_pair: usize, + pub pair: u64, } /// Pricing variants. @@ -82,23 +77,70 @@ pub enum Pricing { AltBn128ConstOperations(AltBn128ConstOperations), } -/// Spec builtin. +/// Builtin compability layer #[derive(Debug, PartialEq, Deserialize, Clone)] #[serde(deny_unknown_fields)] +pub struct BuiltinCompat { + /// Builtin name. + name: String, + /// Builtin pricing. + pricing: PricingCompat, + /// Activation block. + activate_at: Option, +} + +/// Spec builtin. +#[derive(Debug, PartialEq, Clone)] pub struct Builtin { /// Builtin name. pub name: String, /// Builtin pricing. - pub pricing: Pricing, - /// Activation block. - pub activate_at: Option, - /// EIP 1108 - pub eip1108_transition: Option, + pub pricing: BTreeMap, +} + +impl From for Builtin { + fn from(legacy: BuiltinCompat) -> Self { + let pricing = match legacy.pricing { + PricingCompat::Single(pricing) => { + let mut map = BTreeMap::new(); + let activate_at: u64 = legacy.activate_at.map_or(0, Into::into); + map.insert(activate_at, PricingAt { info: None, price: pricing }); + map + } + PricingCompat::Multi(pricings) => { + pricings.into_iter().map(|(a, p)| (a.into(), p)).collect() + } + }; + Self { name: legacy.name, pricing } + } +} + +/// Compability layer for different pricings +#[derive(Debug, PartialEq, Deserialize, Clone)] +#[serde(rename_all = "snake_case")] +#[serde(deny_unknown_fields)] +#[serde(untagged)] +enum PricingCompat { + /// Single builtin + Single(Pricing), + /// Multiple builtins + Multi(BTreeMap), +} + +/// Price for a builtin, with the block number to activate it on +#[derive(Debug, PartialEq, Deserialize, Clone)] +#[serde(deny_unknown_fields)] +pub struct PricingAt { + /// Description of the activation, e.g. "PunyPony HF, March 12, 2025". + pub info: Option, + /// Builtin pricing. + pub price: Pricing, } #[cfg(test)] mod tests { - use super::{Builtin, Modexp, Linear, Pricing, Uint}; + use super::{Builtin, BuiltinCompat, BTreeMap, Pricing, PricingAt, Linear, Modexp, AltBn128ConstOperations}; + use macros::map; #[test] fn builtin_deserialization() { @@ -106,10 +148,42 @@ mod tests { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } }"#; - let deserialized: Builtin = serde_json::from_str(s).unwrap(); - assert_eq!(deserialized.name, "ecrecover"); - assert_eq!(deserialized.pricing, Pricing::Linear(Linear { base: 3000, word: 0 })); - assert!(deserialized.activate_at.is_none()); + let builtin: Builtin = serde_json::from_str::(s).unwrap().into(); + assert_eq!(builtin.name, "ecrecover"); + assert_eq!(builtin.pricing, map![ + 0 => PricingAt { + info: None, + price: Pricing::Linear(Linear { base: 3000, word: 0 }) + } + ]); + } + + #[test] + fn deserialize_multiple_pricings() { + let s = r#"{ + "name": "ecrecover", + "pricing": { + "0": { + "price": {"linear": { "base": 3000, "word": 0 }} + }, + "500": { + "info": "enable fake EIP at block 500", + "price": {"linear": { "base": 10, "word": 0 }} + } + } + }"#; + let builtin: Builtin = serde_json::from_str::(s).unwrap().into(); + assert_eq!(builtin.name, "ecrecover"); + assert_eq!(builtin.pricing, map![ + 0 => PricingAt { + info: None, + price: Pricing::Linear(Linear { base: 3000, word: 0 }) + }, + 500 => PricingAt { + info: Some(String::from("enable fake EIP at block 500")), + price: Pricing::Linear(Linear { base: 10, word: 0 }) + } + ]); } #[test] @@ -119,10 +193,14 @@ mod tests { "activate_at": "0xffffff", "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 { gas_per_round: 123 }); - assert!(deserialized.activate_at.is_some()); + let builtin: Builtin = serde_json::from_str::(s).unwrap().into(); + assert_eq!(builtin.name, "blake2_f"); + assert_eq!(builtin.pricing, map![ + 0xffffff => PricingAt { + info: None, + price: Pricing::Blake2F { gas_per_round: 123 } + } + ]); } #[test] @@ -133,9 +211,13 @@ mod tests { "pricing": { "modexp": { "divisor": 5 } } }"#; - let deserialized: Builtin = serde_json::from_str(s).unwrap(); - assert_eq!(deserialized.name, "late_start"); - assert_eq!(deserialized.pricing, Pricing::Modexp(Modexp { divisor: 5 })); - assert_eq!(deserialized.activate_at, Some(Uint(100000.into()))); + let builtin: Builtin = serde_json::from_str::(s).unwrap().into(); + assert_eq!(builtin.name, "late_start"); + assert_eq!(builtin.pricing, map![ + 100_000 => PricingAt { + info: None, + price: Pricing::Modexp(Modexp { divisor: 5 }) + } + ]); } } diff --git a/json/src/spec/spec.rs b/json/src/spec/spec.rs index b8597987a7c..2e42737e81c 100644 --- a/json/src/spec/spec.rs +++ b/json/src/spec/spec.rs @@ -87,63 +87,63 @@ mod tests { #[test] fn should_error_on_unknown_fields() { let s = r#"{ - "name": "Morden", - "dataDir": "morden", - "engine": { - "Ethash": { - "params": { - "minimumDifficulty": "0x020000", - "difficultyBoundDivisor": "0x0800", - "durationLimit": "0x0d", - "homesteadTransition" : "0x", - "daoHardforkTransition": "0xffffffffffffffff", - "daoHardforkBeneficiary": "0x0000000000000000000000000000000000000000", - "daoHardforkAccounts": [] - } - } - }, - "params": { - "accountStartNonce": "0x0100000", - "maximumExtraDataSize": "0x20", - "minGasLimit": "0x1388", - "networkID" : "0x2", - "forkBlock": "0xffffffffffffffff", - "forkCanonHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "gasLimitBoundDivisor": "0x20", - "unknownField": "0x0" - }, - "genesis": { - "seal": { - "ethereum": { - "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "nonce": "0x00006d6f7264656e" + "name": "Morden", + "dataDir": "morden", + "engine": { + "Ethash": { + "params": { + "minimumDifficulty": "0x020000", + "difficultyBoundDivisor": "0x0800", + "durationLimit": "0x0d", + "homesteadTransition" : "0x", + "daoHardforkTransition": "0xffffffffffffffff", + "daoHardforkBeneficiary": "0x0000000000000000000000000000000000000000", + "daoHardforkAccounts": [] + } } }, - "difficulty": "0x20000", - "author": "0x0000000000000000000000000000000000000000", - "timestamp": "0x00", - "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "extraData": "0x", - "gasLimit": "0x2fefd8" - }, - "nodes": [ - "enode://b1217cbaa440e35ed471157123fe468e19e8b5ad5bedb4b1fdbcbdab6fb2f5ed3e95dd9c24a22a79fdb2352204cea207df27d92bfd21bfd41545e8b16f637499@104.44.138.37:30303" - ], - "accounts": { - "0000000000000000000000000000000000000001": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } }, - "0000000000000000000000000000000000000002": { "balance": "1", "nonce": "1048576", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } }, - "0000000000000000000000000000000000000003": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } }, - "0000000000000000000000000000000000000004": { "balance": "1", "nonce": "1048576", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }, - "102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "1048576" } - }, - "hardcodedSync": { - "header": "f901f9a0d405da4e66f1445d455195229624e133f5baafe72b5cf7b3c36c12c8146e98b7a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a05fb2b4bfdef7b314451cb138a534d225c922fc0e5fbe25e451142732c3e25c25a088d2ec6b9860aae1a2c3b299f72b6a5d70d7f7ba4722c78f2c49ba96273c2158a007c6fdfa8eea7e86b81f5b0fc0f78f90cc19f4aa60d323151e0cac660199e9a1b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302008003832fefba82524d84568e932a80a0a0349d8c3df71f1a48a9df7d03fd5f14aeee7d91332c009ecaff0a71ead405bd88ab4e252a7e8c2a23", - "totalDifficulty": "0x400000000", - "CHTs": [ + "params": { + "accountStartNonce": "0x0100000", + "maximumExtraDataSize": "0x20", + "minGasLimit": "0x1388", + "networkID" : "0x2", + "forkBlock": "0xffffffffffffffff", + "forkCanonHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "gasLimitBoundDivisor": "0x20", + "unknownField": "0x0" + }, + "genesis": { + "seal": { + "ethereum": { + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "nonce": "0x00006d6f7264656e" + } + }, + "difficulty": "0x20000", + "author": "0x0000000000000000000000000000000000000000", + "timestamp": "0x00", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "extraData": "0x", + "gasLimit": "0x2fefd8" + }, + "nodes": [ + "enode://b1217cbaa440e35ed471157123fe468e19e8b5ad5bedb4b1fdbcbdab6fb2f5ed3e95dd9c24a22a79fdb2352204cea207df27d92bfd21bfd41545e8b16f637499@104.44.138.37:30303" + ], + "accounts": { + "0000000000000000000000000000000000000001": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } }, + "0000000000000000000000000000000000000002": { "balance": "1", "nonce": "1048576", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } }, + "0000000000000000000000000000000000000003": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } }, + "0000000000000000000000000000000000000004": { "balance": "1", "nonce": "1048576", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }, + "102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "1048576" } + }, + "hardcodedSync": { + "header": "f901f9a0d405da4e66f1445d455195229624e133f5baafe72b5cf7b3c36c12c8146e98b7a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a05fb2b4bfdef7b314451cb138a534d225c922fc0e5fbe25e451142732c3e25c25a088d2ec6b9860aae1a2c3b299f72b6a5d70d7f7ba4722c78f2c49ba96273c2158a007c6fdfa8eea7e86b81f5b0fc0f78f90cc19f4aa60d323151e0cac660199e9a1b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302008003832fefba82524d84568e932a80a0a0349d8c3df71f1a48a9df7d03fd5f14aeee7d91332c009ecaff0a71ead405bd88ab4e252a7e8c2a23", + "totalDifficulty": "0x400000000", + "CHTs": [ "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", "0xd7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544" - ] - } + ] + } }"#; let result: Result = serde_json::from_str(s); assert!(result.is_err()); @@ -152,62 +152,110 @@ mod tests { #[test] fn spec_deserialization() { let s = r#"{ - "name": "Morden", - "dataDir": "morden", - "engine": { - "Ethash": { - "params": { - "minimumDifficulty": "0x020000", - "difficultyBoundDivisor": "0x0800", - "durationLimit": "0x0d", - "homesteadTransition" : "0x", - "daoHardforkTransition": "0xffffffffffffffff", - "daoHardforkBeneficiary": "0x0000000000000000000000000000000000000000", - "daoHardforkAccounts": [] - } - } - }, - "params": { - "accountStartNonce": "0x0100000", - "maximumExtraDataSize": "0x20", - "minGasLimit": "0x1388", - "networkID" : "0x2", - "forkBlock": "0xffffffffffffffff", - "forkCanonHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "gasLimitBoundDivisor": "0x20" - }, - "genesis": { - "seal": { - "ethereum": { - "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "nonce": "0x00006d6f7264656e" + "name": "Morden", + "dataDir": "morden", + "engine": { + "Ethash": { + "params": { + "minimumDifficulty": "0x020000", + "difficultyBoundDivisor": "0x0800", + "durationLimit": "0x0d", + "homesteadTransition" : "0x", + "daoHardforkTransition": "0xffffffffffffffff", + "daoHardforkBeneficiary": "0x0000000000000000000000000000000000000000", + "daoHardforkAccounts": [] + } } }, - "difficulty": "0x20000", - "author": "0x0000000000000000000000000000000000000000", - "timestamp": "0x00", - "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "extraData": "0x", - "gasLimit": "0x2fefd8" - }, - "nodes": [ - "enode://b1217cbaa440e35ed471157123fe468e19e8b5ad5bedb4b1fdbcbdab6fb2f5ed3e95dd9c24a22a79fdb2352204cea207df27d92bfd21bfd41545e8b16f637499@104.44.138.37:30303" - ], - "accounts": { - "0000000000000000000000000000000000000001": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } }, - "0000000000000000000000000000000000000002": { "balance": "1", "nonce": "1048576", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } }, - "0000000000000000000000000000000000000003": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } }, - "0000000000000000000000000000000000000004": { "balance": "1", "nonce": "1048576", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }, - "102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "1048576" } - }, - "hardcodedSync": { - "header": "f901f9a0d405da4e66f1445d455195229624e133f5baafe72b5cf7b3c36c12c8146e98b7a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a05fb2b4bfdef7b314451cb138a534d225c922fc0e5fbe25e451142732c3e25c25a088d2ec6b9860aae1a2c3b299f72b6a5d70d7f7ba4722c78f2c49ba96273c2158a007c6fdfa8eea7e86b81f5b0fc0f78f90cc19f4aa60d323151e0cac660199e9a1b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302008003832fefba82524d84568e932a80a0a0349d8c3df71f1a48a9df7d03fd5f14aeee7d91332c009ecaff0a71ead405bd88ab4e252a7e8c2a23", - "totalDifficulty": "0x400000000", - "CHTs": [ - "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", - "0xd7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544" - ] - } + "params": { + "accountStartNonce": "0x0100000", + "maximumExtraDataSize": "0x20", + "minGasLimit": "0x1388", + "networkID" : "0x2", + "forkBlock": "0xffffffffffffffff", + "forkCanonHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "gasLimitBoundDivisor": "0x20" + }, + "genesis": { + "seal": { + "ethereum": { + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "nonce": "0x00006d6f7264656e" + } + }, + "difficulty": "0x20000", + "author": "0x0000000000000000000000000000000000000000", + "timestamp": "0x00", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "extraData": "0x", + "gasLimit": "0x2fefd8" + }, + "nodes": [ + "enode://b1217cbaa440e35ed471157123fe468e19e8b5ad5bedb4b1fdbcbdab6fb2f5ed3e95dd9c24a22a79fdb2352204cea207df27d92bfd21bfd41545e8b16f637499@104.44.138.37:30303" + ], + "accounts": { + "0000000000000000000000000000000000000001": { + "balance": "1", + "nonce": "1048576", + "builtin": { + "name": "ecrecover", + "pricing": { + "linear": { + "base": 3000, + "word": 0 + } + } + } + }, + "0000000000000000000000000000000000000002": { + "balance": "1", + "nonce": "1048576", + "builtin": { + "name": "sha256", + "pricing": { + "linear": { + "base": 60, + "word": 12 + } + } + } + }, + "0000000000000000000000000000000000000003": { + "balance": "1", + "nonce": "1048576", + "builtin": { + "name": "ripemd160", + "pricing": { + "linear": { + "base": 600, + "word": 120 + } + } + } + }, + "0000000000000000000000000000000000000004": { + "balance": "1", + "nonce": "1048576", + "builtin": { + "name": "identity", + "pricing": { + "linear": { + "base": 15, + "word": 3 + } + } + } + }, + "102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "1048576" } + }, + "hardcodedSync": { + "header": "f901f9a0d405da4e66f1445d455195229624e133f5baafe72b5cf7b3c36c12c8146e98b7a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a05fb2b4bfdef7b314451cb138a534d225c922fc0e5fbe25e451142732c3e25c25a088d2ec6b9860aae1a2c3b299f72b6a5d70d7f7ba4722c78f2c49ba96273c2158a007c6fdfa8eea7e86b81f5b0fc0f78f90cc19f4aa60d323151e0cac660199e9a1b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302008003832fefba82524d84568e932a80a0a0349d8c3df71f1a48a9df7d03fd5f14aeee7d91332c009ecaff0a71ead405bd88ab4e252a7e8c2a23", + "totalDifficulty": "0x400000000", + "CHTs": [ + "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", + "0xd7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544" + ] + } }"#; let _deserialized: Spec = serde_json::from_str(s).unwrap(); // TODO: validate all fields diff --git a/json/src/spec/state.rs b/json/src/spec/state.rs index 642d9b6eb2a..458c5e55997 100644 --- a/json/src/spec/state.rs +++ b/json/src/spec/state.rs @@ -50,7 +50,7 @@ impl State { HashOrMap::Hash(_) => BTreeMap::default(), HashOrMap::Map(map) => { map.iter().filter_map(|(add, ref acc)| { - acc.builtin.clone().map(|b| (add.clone(), b)) + acc.builtin.clone().map(|b| (add.clone(), b.into())) }).collect() }