[builtin]: support multiple prices and activations in chain spec (#11039)

* [builtin]: impl new builtin type

Have an enum to deserialize either a builtin of a single price or several prices

* [builtin]: style cleanup

* [builtin]: fix tests

* [builtin]: replace boxing with wrapper enum

* cleanup

* fix: make it backward compatible with old builtin

* fix: update chain specs

* fix: revert use of `type alias` on enum

The CI doesn't use the latest rust.

This commit reverts that change

* fix: builtin tests

* fix: revert use of `type alias` on enum

* [basic-authority]: update test-chainspec

* fix failing tests

* [builtin]: multi-prices add `info field`

It might be hard to read chain specs with several activations points.
This commit introduces a `info` field which may be used to write some
information about the current activation such as:

`Istanbul hardfork EIP-1108` or something similar.

* fix: bad rebase

Co-Authored-By: David <dvdplm@gmail.com>

* fix(grumbles): make it backward compatible

* grumbles: resolve `NOTE`

* revert chain specs changes

* rename test

Co-Authored-By: David <dvdplm@gmail.com>

* [builtin docs]: price -> Fixed price

Co-Authored-By: Andronik Ordian <write@reusable.software>

* [json]: address naming grumbles

InnerPricing -> PricingInner
PriceWithActivationAt -> PricingAt

* docs: revert changes for `AltBn128ConstOperations`

* [json]: usize -> u64

Use explicit types to cope with platform dependent issues for `usize`

* grumble: simplify `spec_backward_compability.json`

* docs: add issue link to `TODO`

* [builtin]: replace `match` with `map`

* [builtin]: add deprecation message `eip1108` params

* nits

* [json spec tests]: fix json indentation

* [json docs]: fix typos

* [json]: `compability layer` + deser to BTreeMap

Previously we had to match `Pricing::Single` and `PricingMulti` which this fixes.
It does by introducing a compability layer and into() implemenentation.

In addition, I switched the deserialization to `BTreeMap` instead of `Vec`.
That changes the format of the chain spec again

* [json]: rename `BuiltinCombat` -> `BuiltinCompat`

* Update ethcore/builtin/src/lib.rs

Co-Authored-By: David <dvdplm@gmail.com>

* [json builtin]: improve docs

Co-Authored-By: David <dvdplm@gmail.com>

* [json builtin]: improve docs

Co-Authored-By: David <dvdplm@gmail.com>

* chore(builtin): sort dependencies

* [json builtin]: deprecate `eip1108` params

* [machine]: add bench for calling builtin contract

* [machine]: reduce calls to `Builtin::is_active`

* [builtin]: fix nits

* [json]: revert breakage of chain specs

* [json builtin]: remove `eip1108` params

* [chain specs]: update to new format

* [machine]: revert changes

* [devp2p]: revert change

* [builtin]: doc nits
This commit is contained in:
Niklas Adolfsson 2019-10-31 17:09:08 +01:00 committed by Andronik Ordian
parent 80754c3426
commit 13729a0f7f
47 changed files with 1703 additions and 908 deletions

2
Cargo.lock generated
View File

@ -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)",
@ -2565,6 +2566,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)",

View File

@ -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"

View File

@ -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::<u32>();
// 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 {
}
}
/// A linear pricing model. This computes a price using a base cost and a cost per-word.
struct Linear {
base: usize,
word: usize,
/// Pricing model
#[derive(Debug)]
enum Pricing {
AltBn128Pairing(AltBn128PairingPricer),
AltBn128ConstOperations(AltBn128ConstOperations),
Blake2F(Blake2FPricer),
Linear(Linear),
Modexp(ModexpPricer),
}
/// A special pricing model for modular exponentiation.
struct ModexpPricer {
divisor: usize,
}
impl Pricer for Linear {
fn cost(&self, input: &[u8], _at: u64) -> U256 {
U256::from(self.base) + U256::from(self.word) * U256::from((input.len() + 31) / 32)
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),
}
}
}
/// alt_bn128 constant operations (add and mul) pricing model.
struct AltBn128ConstOperations {
price: usize,
eip1108_transition_at: u64,
eip1108_transition_price: usize,
/// A linear pricing model. This computes a price using a base cost and a cost per-word.
#[derive(Debug)]
struct Linear {
base: u64,
word: u64,
}
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()
}
/// A special pricing model for modular exponentiation.
#[derive(Debug)]
struct ModexpPricer {
divisor: u64,
}
impl Pricer for Linear {
fn cost(&self, input: &[u8]) -> U256 {
U256::from(self.base) + U256::from(self.word) * U256::from((input.len() + 31) / 32)
}
}
/// 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,
}
/// Pricing for constant alt_bn128 operations (ECADD and ECMUL)
#[derive(Debug, Copy, Clone)]
pub struct AltBn128ConstOperations {
/// Fixed price.
pub price: u64,
}
impl Pricer for AltBn128ConstOperations {
fn cost(&self, _input: &[u8]) -> U256 {
self.price.into()
}
}
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
};
U256::from(price.base) + U256::from(price.pair) * U256::from(input.len() / 192)
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<dyn Pricer>,
native: Box<dyn Implementation>,
activate_at: u64,
pricer: BTreeMap<u64, Pricing>,
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<ethjson::spec::Builtin> for Builtin {
impl TryFrom<ethjson::spec::builtin::Builtin> for Builtin {
type Error = EthcoreError;
fn try_from(b: ethjson::spec::Builtin) -> Result<Self, Self::Error> {
let pricer: Box<dyn Pricer> = 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<Self, Self::Error> {
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<ethjson::spec::builtin::Pricing> 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<Box<dyn Implementation>, EthcoreError> {
let implementation = match name {
"identity" => Box::new(Identity) as Box<dyn Implementation>,
"ecrecover" => Box::new(EcRecover) as Box<dyn Implementation>,
"sha256" => Box::new(Sha256) as Box<dyn Implementation>,
"ripemd160" => Box::new(Ripemd160) as Box<dyn Implementation>,
"modexp" => Box::new(Modexp) as Box<dyn Implementation>,
"alt_bn128_add" => Box::new(Bn128Add) as Box<dyn Implementation>,
"alt_bn128_mul" => Box::new(Bn128Mul) as Box<dyn Implementation>,
"alt_bn128_pairing" => Box::new(Bn128Pairing) as Box<dyn Implementation>,
"blake2_f" => Box::new(Blake2F) as Box<dyn Implementation>,
_ => 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<EthereumBuiltin, Self::Err> {
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::<LittleEndian>().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::<LittleEndian>().expect(PROOF);
}
@ -452,7 +506,7 @@ fn modexp(mut base: BigUint, exp: Vec<u8>, 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<u8>, 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<dyn Pricer>,
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<dyn Pricer>,
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");
}
}

View File

@ -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 }}
}
}
}

View File

@ -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;

View File

@ -6,6 +6,11 @@ authors = ["Parity Technologies <admin@parity.io>"]
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" }

View File

@ -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 <http://www.gnu.org/licenses/>.
//! 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::<Bytes>());
}
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);

View File

@ -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")) }

View File

@ -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 }}
}
}
}

View File

@ -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 }}
}
}
}

View File

@ -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 }}
}
}
}

View File

@ -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 }}}
}
}
}
}
}

View File

@ -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 }
}
}
}
}
}

View File

@ -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 }}
}
}
}

View File

@ -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 }}
}
}
}

View File

@ -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 }}
}
}
}

View File

@ -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 }}
}
}
}

View File

@ -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 }}
}
}
}

View File

@ -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 }}
}
}
}

View File

@ -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": {

View File

@ -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 }}
}
}
}

View File

@ -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 }}
}
}
}

View File

@ -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 }}
}
}
}

View File

@ -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 }}
}
}
}

View File

@ -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 }}
}
}
}

View File

@ -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 }}
}
}
}

View File

@ -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 }}
}
}
}

View File

@ -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 }}
}
}
}

View File

@ -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 }}
}
}
}

View File

@ -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 }}
}
}
}

View File

@ -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 }}
}
}
}

View File

@ -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 }}
}
}
}

View File

@ -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": {

View File

@ -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 }}
}
}
}

View File

@ -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 }}
}
}
}

View File

@ -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 }}
}
}
}

View File

@ -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 }}
}
}
}

File diff suppressed because one or more lines are too long

View File

@ -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 }}
}
}
}

View File

@ -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 }}
}
}
}

View File

@ -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 }}
}
}
}

View File

@ -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"
]
}

View File

@ -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.

View File

@ -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<Builtin>,
pub builtin: Option<BuiltinCompat>,
/// Balance.
pub balance: Option<Uint>,
/// 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());

View File

@ -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<Uint>,
}
/// 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<Uint>,
/// EIP 1108
pub eip1108_transition: Option<Uint>,
pub pricing: BTreeMap<u64, PricingAt>,
}
impl From<BuiltinCompat> 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<Uint, PricingAt>),
}
/// 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<String>,
/// 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::<BuiltinCompat>(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::<BuiltinCompat>(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::<BuiltinCompat>(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::<BuiltinCompat>(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 })
}
]);
}
}

View File

@ -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<Spec, _> = 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

View File

@ -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()
}