Remove ethcore::common re-export module (#2792)

* no longer export action_params

* remove transaction, header, receipt re-rexports from common

* remove env_info and builtins re-exports from common

* remove everything but util export from common

* replace common usages with util, remove module

* add a prelude module for ethcore-bigint
This commit is contained in:
Robert Habermeier 2016-10-24 18:35:25 +02:00 committed by Gav Wood
parent edbd667696
commit 0fedc27332
30 changed files with 130 additions and 72 deletions

View File

@ -15,10 +15,14 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
//! Evm input params.
use common::*;
use util::{Address, Bytes, Uint, U256};
use util::hash::{H256, FixedHash};
use util::sha3::{Hashable, SHA3_EMPTY};
use ethjson;
use types::executed::CallType;
use std::sync::Arc;
/// Transaction value
#[derive(Clone, Debug)]
pub enum ActionValue {

View File

@ -16,7 +16,7 @@
//! Ethcore basic typenames.
use util::*;
use util::hash::H2048;
/// Type for a 2048-bit log-bloom, as used by our blocks.
pub type LogBloom = H2048;

View File

@ -587,10 +587,17 @@ pub fn enact_verified(
mod tests {
use tests::helpers::*;
use super::*;
use common::*;
use engines::Engine;
use env_info::LastHashes;
use error::Error;
use header::Header;
use factory::Factories;
use state_db::StateDB;
use views::BlockView;
use util::Address;
use util::hash::FixedHash;
use std::sync::Arc;
/// Enact the block given by `block_bytes` using `engine` on the database `db` with given `parent` block header
#[cfg_attr(feature="dev", allow(too_many_arguments))]

View File

@ -1,27 +0,0 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd.
// This file is part of Parity.
// Parity 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 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. If not, see <http://www.gnu.org/licenses/>.
pub use util::*;
pub use basic_types::*;
pub use error::*;
pub use env_info::*;
pub use views::*;
pub use builtin::*;
pub use header::*;
pub use transaction::*;
pub use log_entry::*;
pub use receipt::*;
pub use action_params::*;

View File

@ -16,14 +16,20 @@
//! A blockchain engine that supports a basic, non-BFT proof-of-authority.
use common::*;
use ethkey::{recover, public_to_address};
use account_provider::AccountProvider;
use block::*;
use builtin::Builtin;
use spec::CommonParams;
use engines::Engine;
use env_info::EnvInfo;
use error::{BlockError, Error};
use evm::Schedule;
use ethjson;
use header::Header;
use transaction::SignedTransaction;
use util::*;
/// `BasicAuthority` params.
#[derive(Debug, PartialEq)]
@ -184,10 +190,13 @@ impl Header {
#[cfg(test)]
mod tests {
use common::*;
use util::*;
use block::*;
use env_info::EnvInfo;
use error::{BlockError, Error};
use tests::helpers::*;
use account_provider::AccountProvider;
use header::Header;
use spec::Spec;
/// Create a new test chain spec with `BasicAuthority` consensus engine.

View File

@ -18,11 +18,11 @@ use std::collections::BTreeMap;
use util::Address;
use builtin::Builtin;
use engines::Engine;
use env_info::EnvInfo;
use spec::CommonParams;
use evm::Schedule;
use env_info::EnvInfo;
use block::ExecutedBlock;
use common::Bytes;
use util::Bytes;
use account_provider::AccountProvider;
/// An engine which does not provide any consensus mechanism, just seals blocks internally.
@ -67,10 +67,11 @@ impl Engine for InstantSeal {
#[cfg(test)]
mod tests {
use common::*;
use util::*;
use tests::helpers::*;
use account_provider::AccountProvider;
use spec::Spec;
use header::Header;
use block::*;
#[test]

View File

@ -24,11 +24,16 @@ pub use self::null_engine::NullEngine;
pub use self::instant_seal::InstantSeal;
pub use self::basic_authority::BasicAuthority;
use common::*;
use util::*;
use account_provider::AccountProvider;
use block::ExecutedBlock;
use builtin::Builtin;
use env_info::EnvInfo;
use error::Error;
use spec::CommonParams;
use evm::Schedule;
use header::Header;
use transaction::SignedTransaction;
/// A consensus mechanism for the chain. Generally either proof-of-work or proof-of-stake-based.
/// Provides hooks into each of the major parts of block import.

View File

@ -15,9 +15,14 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use ethash::{quick_get_difficulty, slow_get_seedhash, EthashManager, H256 as EH256};
use common::*;
use util::*;
use block::*;
use builtin::Builtin;
use env_info::EnvInfo;
use error::{BlockError, Error};
use header::Header;
use spec::CommonParams;
use transaction::SignedTransaction;
use engines::Engine;
use evm::Schedule;
use ethjson;
@ -187,8 +192,8 @@ impl Engine for Ethash {
// Commit state so that we can actually figure out the state root.
if let Err(e) = fields.state.commit() {
warn!("Encountered error on state commit: {}", e);
}
warn!("Encountered error on state commit: {}", e);
}
}
fn verify_block_basic(&self, header: &Header, _block: Option<&[u8]>) -> result::Result<(), Error> {
@ -371,9 +376,12 @@ impl Header {
#[cfg(test)]
mod tests {
use common::*;
use util::*;
use block::*;
use tests::helpers::*;
use env_info::EnvInfo;
use error::{BlockError, Error};
use header::Header;
use super::super::new_morden;
use super::Ethash;
use rlp;

View File

@ -65,10 +65,11 @@ pub fn new_morden() -> Spec { load(include_bytes!("../../res/ethereum/morden.jso
#[cfg(test)]
mod tests {
use common::*;
use util::*;
use state::*;
use super::*;
use tests::helpers::*;
use views::BlockView;
#[test]
fn ensure_db_good() {

View File

@ -24,7 +24,8 @@ extern crate test;
use self::test::{Bencher, black_box};
use common::*;
use util::*;
use action_params::ActionParams;
use evm::{self, Factory, VMType};
use evm::tests::FakeExt;

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use common::*;
use util::*;
use super::u256_to_address;
use evm::{self, CostType};
use evm::instructions::{self, Instruction, InstructionInfo};
@ -64,14 +64,14 @@ impl<Gas: CostType> Gasometer<Gas> {
Some(cap_divisor) if self.current_gas >= needed => {
let gas_remaining = self.current_gas - needed;
let max_gas_provided = gas_remaining - gas_remaining / Gas::from(cap_divisor);
if let Some(Ok(r)) = requested {
if let Some(Ok(r)) = requested {
Ok(min(r, max_gas_provided))
} else {
Ok(max_gas_provided)
}
},
_ => {
if let Some(r) = requested {
if let Some(r) = requested {
r
} else if self.current_gas >= needed {
Ok(self.current_gas - needed)
@ -84,10 +84,10 @@ impl<Gas: CostType> Gasometer<Gas> {
#[cfg_attr(feature="dev", allow(cyclomatic_complexity))]
/// Determine how much gas is used by the given instruction, given the machine's state.
///
///
/// We guarantee that the final element of the returned tuple (`provided`) will be `Some`
/// iff the `instruction` is one of `CREATE`, or any of the `CALL` variants. In this case,
/// it will be the amount of gas that the current context provides to the child context.
/// it will be the amount of gas that the current context provides to the child context.
pub fn get_gas_cost_mem(
&mut self,
ext: &evm::Ext,
@ -183,7 +183,7 @@ impl<Gas: CostType> Gasometer<Gas> {
gas = overflowing!(gas.overflow_add(schedule.call_value_transfer_gas.into()));
};
// TODO: refactor to avoid duplicate calculation here and later on.
// TODO: refactor to avoid duplicate calculation here and later on.
let (mem_gas_cost, _, _) = try!(self.mem_gas_cost(schedule, current_mem_size, &mem));
let cost_so_far = overflowing!(gas.overflow_add(mem_gas_cost.into()));
let requested = Gas::from_u256(*stack.peek(0));
@ -199,7 +199,7 @@ impl<Gas: CostType> Gasometer<Gas> {
try!(mem_needed(stack.peek(2), stack.peek(3)))
);
// TODO: refactor to avoid duplicate calculation here and later on.
// TODO: refactor to avoid duplicate calculation here and later on.
let (mem_gas_cost, _, _) = try!(self.mem_gas_cost(schedule, current_mem_size, &mem));
let cost_so_far = overflowing!(gas.overflow_add(mem_gas_cost.into()));
let requested = Gas::from_u256(*stack.peek(0));
@ -212,9 +212,9 @@ impl<Gas: CostType> Gasometer<Gas> {
let mut gas = Gas::from(schedule.create_gas);
let mem = try!(mem_needed(stack.peek(1), stack.peek(2)));
// TODO: refactor to avoid duplicate calculation here and later on.
// TODO: refactor to avoid duplicate calculation here and later on.
let (mem_gas_cost, _, _) = try!(self.mem_gas_cost(schedule, current_mem_size, &mem));
let cost_so_far = overflowing!(gas.overflow_add(mem_gas_cost.into()));
let cost_so_far = overflowing!(gas.overflow_add(mem_gas_cost.into()));
let provided = try!(self.gas_provided(schedule, cost_so_far, None));
gas = overflowing!(gas.overflow_add(provided));

View File

@ -29,12 +29,14 @@ use self::memory::Memory;
pub use self::shared_cache::SharedCache;
use std::marker::PhantomData;
use common::*;
use action_params::{ActionParams, ActionValue};
use types::executed::CallType;
use super::instructions::{self, Instruction, InstructionInfo};
use evm::instructions::{self, Instruction, InstructionInfo};
use evm::{self, MessageCallResult, ContractCreateResult, GasLeft, CostType};
use bit_set::BitSet;
use util::*;
type CodePosition = usize;
type ProgramCounter = usize;

View File

@ -15,7 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
//! Just in time compiler execution environment.
use common::*;
use util::*;
use evmjit;
use evm::{self, GasLeft};
use types::executed::CallType;

View File

@ -14,7 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use common::*;
use util::*;
use action_params::{ActionParams, ActionValue};
use env_info::EnvInfo;
use types::executed::CallType;
use evm::{self, Ext, Schedule, Factory, GasLeft, VMType, ContractCreateResult, MessageCallResult};
use std::fmt::Debug;

View File

@ -15,13 +15,17 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
//! Transaction Execution environment.
use common::*;
use util::*;
use action_params::{ActionParams, ActionValue};
use state::{State, Substate};
use engines::Engine;
use types::executed::CallType;
use env_info::EnvInfo;
use error::ExecutionError;
use evm::{self, Ext, Factory, Finalize};
use externalities::*;
use trace::{FlatTrace, Tracer, NoopTracer, ExecutiveTracer, VMTrace, VMTracer, ExecutiveVMTracer, NoopVMTracer};
use transaction::{Action, SignedTransaction};
use crossbeam;
pub use types::executed::{Executed, ExecutionResult};
@ -500,13 +504,18 @@ impl<'a> Executive<'a> {
mod tests {
use ethkey::{Generator, Random};
use super::*;
use common::*;
use util::*;
use action_params::{ActionParams, ActionValue};
use env_info::EnvInfo;
use evm::{Factory, VMType};
use error::ExecutionError;
use state::Substate;
use tests::helpers::*;
use trace::trace;
use trace::{FlatTrace, Tracer, NoopTracer, ExecutiveTracer};
use trace::{VMTrace, VMOperation, VMExecutedOperation, MemoryDiff, StorageDiff, VMTracer, NoopVMTracer, ExecutiveVMTracer};
use transaction::{Action, Transaction};
use types::executed::CallType;
#[test]

View File

@ -15,9 +15,11 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
//! Transaction Execution environment.
use common::*;
use util::*;
use action_params::{ActionParams, ActionValue};
use state::{State, Substate};
use engines::Engine;
use env_info::EnvInfo;
use executive::*;
use evm::{self, Schedule, Ext, ContractCreateResult, MessageCallResult, Factory};
use types::executed::CallType;
@ -253,6 +255,8 @@ impl<'a, T, V> Ext for Externalities<'a, T, V> where T: 'a + Tracer, V: 'a + VMT
}
fn log(&mut self, topics: Vec<H256>, data: &[u8]) {
use log_entry::LogEntry;
let address = self.origin_info.address.clone();
self.substate.logs.push(LogEntry {
address: address,
@ -303,8 +307,9 @@ impl<'a, T, V> Ext for Externalities<'a, T, V> where T: 'a + Tracer, V: 'a + VMT
#[cfg(test)]
mod tests {
use common::*;
use util::*;
use engines::Engine;
use env_info::EnvInfo;
use evm::Ext;
use state::{State, Substate};
use tests::helpers::*;

View File

@ -17,7 +17,7 @@
//! Block header.
use util::*;
use basic_types::*;
use basic_types::{LogBloom, Seal, ZERO_LOGBLOOM};
use time::get_time;
use rlp::*;

View File

@ -15,9 +15,11 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use super::test_common::*;
use action_params::ActionParams;
use state::{State, Substate};
use executive::*;
use engines::Engine;
use env_info::EnvInfo;
use evm;
use evm::{Schedule, Ext, Factory, Finalize, VMType, ContractCreateResult, MessageCallResult};
use externalities::*;

View File

@ -17,6 +17,7 @@
use super::test_common::*;
use tests::helpers::*;
use pod_state::{self, PodState};
use log_entry::LogEntry;
use ethereum;
use ethjson;

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
pub use common::*;
pub use util::*;
macro_rules! test {
($name: expr) => {

View File

@ -18,6 +18,7 @@ use super::test_common::*;
use evm;
use ethjson;
use rlp::{UntrustedRlp, View};
use transaction::{Action, SignedTransaction};
fn do_json_test(json_data: &[u8]) -> Vec<String> {
let tests = ethjson::transaction::Test::load(json_data).unwrap();

View File

@ -140,7 +140,6 @@ pub mod db;
mod cache_manager;
mod blooms;
mod common;
mod basic_types;
mod env_info;
mod pod_account;

View File

@ -163,7 +163,7 @@ pub fn diff_pod(pre: Option<&PodAccount>, post: Option<&PodAccount>) -> Option<A
#[cfg(test)]
mod test {
use common::*;
use util::*;
use types::account_diff::*;
use super::{PodAccount, diff_pod};

View File

@ -77,7 +77,7 @@ pub fn diff_pod(pre: &PodState, post: &PodState) -> StateDiff {
#[cfg(test)]
mod test {
use common::*;
use util::*;
use types::state_diff::*;
use types::account_diff::*;
use pod_account::PodAccount;

View File

@ -16,10 +16,12 @@
//! Parameters for a block chain.
use common::*;
use util::*;
use builtin::Builtin;
use engines::{Engine, NullEngine, InstantSeal, BasicAuthority};
use pod_state::*;
use account_db::*;
use header::{BlockNumber, Header};
use state_db::StateDB;
use super::genesis::Genesis;
use super::seal::Generic as GenericSeal;

View File

@ -16,14 +16,18 @@
use std::cell::{RefCell, RefMut};
use std::collections::hash_map::Entry;
use common::*;
use util::*;
use receipt::Receipt;
use engines::Engine;
use env_info::EnvInfo;
use error::Error;
use executive::{Executive, TransactOptions};
use factory::Factories;
use trace::FlatTrace;
use pod_account::*;
use pod_state::{self, PodState};
use types::state_diff::StateDiff;
use transaction::SignedTransaction;
use state_db::StateDB;
mod account;
@ -756,7 +760,7 @@ use super::*;
use util::{U256, H256, FixedHash, Address, Hashable};
use tests::helpers::*;
use devtools::*;
use env_info::*;
use env_info::EnvInfo;
use spec::*;
use transaction::*;
use util::log::init_log;

View File

@ -20,11 +20,12 @@ use ethereum;
use block::IsBlock;
use tests::helpers::*;
use types::filter::Filter;
use common::*;
use util::*;
use devtools::*;
use miner::Miner;
use rlp::{Rlp, View};
use spec::Spec;
use views::BlockView;
#[test]
fn imports_from_empty() {

View File

@ -17,19 +17,23 @@
use ethkey::KeyPair;
use io::*;
use client::{BlockChainClient, Client, ClientConfig};
use common::*;
use util::*;
use spec::*;
use state_db::StateDB;
use block::{OpenBlock, Drain};
use blockchain::{BlockChain, Config as BlockChainConfig};
use builtin::Builtin;
use state::*;
use evm::Schedule;
use engines::Engine;
use env_info::EnvInfo;
use ethereum;
use devtools::*;
use miner::Miner;
use header::Header;
use transaction::{Action, SignedTransaction, Transaction};
use rlp::{self, RlpStream, Stream};
use db::COL_STATE;
use views::BlockView;
#[cfg(feature = "json-tests")]
pub enum ChainEra {
@ -346,7 +350,7 @@ pub fn get_temp_state() -> GuardedTempResult<State> {
pub fn get_temp_state_db_in(path: &Path) -> StateDB {
let db = new_db(path.to_str().expect("Only valid utf8 paths for tests."));
let journal_db = journaldb::new(db.clone(), journaldb::Algorithm::EarlyMerge, COL_STATE);
let journal_db = journaldb::new(db.clone(), journaldb::Algorithm::EarlyMerge, ::db::COL_STATE);
StateDB::new(journal_db, 5 * 1024 * 1024)
}

View File

@ -21,10 +21,14 @@
/// 2. Signatures verification done in the queue.
/// 3. Final verification against the blockchain done before enactment.
use common::*;
use util::*;
use engines::Engine;
use error::{BlockError, Error};
use blockchain::*;
use header::{BlockNumber, Header};
use rlp::{UntrustedRlp, View};
use transaction::SignedTransaction;
use views::BlockView;
/// Preprocessed block data gathered in `verify_block_unordered` call
pub struct PreverifiedBlock {

View File

@ -24,3 +24,16 @@ extern crate rustc_serialize;
pub mod uint;
pub mod hash;
/// A prelude module for re-exporting all the types defined in this crate.
///
/// ```rust
/// use ethcore_bigint::prelude::*;
///
/// let x: U256 = U256::zero();
/// let y = x + 1.into();
/// ```
pub mod prelude {
pub use ::uint::*;
pub use ::hash::*;
}