openethereum/ethcore/benches/builtin_contract.rs

150 lines
4.6 KiB
Rust
Raw Normal View History

v2.6.5 beta (#11240) * [CI] check evmbin build (#11096) * Correct EIP-712 encoding (#11092) * [client]: Fix for incorrectly dropped consensus messages (#11082) (#11086) * Update hardcoded headers (foundation, classic, kovan, xdai, ewc, ...) (#11053) * Add cargo-remote dir to .gitignore (?) * Update light client headers: ropsten 6631425 foundation 8798209 (#11201) * Update list of bootnodes for xDai chain (#11236) * ethcore/res: add mordor testnet configuration (#11200) * [chain specs]: activate Istanbul on mainnet (#11228) * [builtin]: support multiple prices and activations in chain spec (#11039) * [receipt]: add sender & receiver to RichReceipts (#11179) * [ethcore/builtin]: do not panic in blake2pricer on short input (#11180) * Made ecrecover implementation trait public (#11188) * Fix docker centos build (#11226) * Update MIX bootnodes. (#11203) * Insert explicit warning into the panic hook (#11225) * Use provided usd-per-eth value if an endpoint is specified (#11209) * Cleanup stratum a bit (#11161) * Add Constantinople EIPs to the dev (instant_seal) config (#10809) (already backported) * util Host: fix a double Read Lock bug in fn Host::session_readable() (#11175) * ethcore client: fix a double Read Lock bug in fn Client::logs() (#11172) * Type annotation for next_key() matching of json filter options (#11192) * Upgrade jsonrpc to latest (#11206) * [dependencies]: jsonrpc 14.0.1 (#11183) * Upgrade to jsonrpc v14 (#11151) * Switching sccache from local to Redis (#10971) * Snapshot restoration overhaul (#11219) * Add new line after writing block to hex file. (#10984) * Pause pruning while snapshotting (#11178) * Change how RPCs eth_call and eth_estimateGas handle "Pending" (#11127) * Fix block detail updating (#11015) * Make InstantSeal Instant again #11186 * Filter out some bad ropsten warp snapshots (#11247)
2019-11-11 23:55:19 +01:00
// 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);