Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Remove ethcore::common re-export module #2792

Merged
merged 7 commits into from
Oct 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ethcore/src/action_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/basic_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 8 additions & 1 deletion ethcore/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))]
Expand Down
27 changes: 0 additions & 27 deletions ethcore/src/common.rs

This file was deleted.

13 changes: 11 additions & 2 deletions ethcore/src/engines/basic_authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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.
Expand Down
7 changes: 4 additions & 3 deletions ethcore/src/engines/instant_seal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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]
Expand Down
7 changes: 6 additions & 1 deletion ethcore/src/engines/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 12 additions & 4 deletions ethcore/src/ethereum/ethash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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> {
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion ethcore/src/ethereum/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
3 changes: 2 additions & 1 deletion ethcore/src/evm/benches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
18 changes: 9 additions & 9 deletions ethcore/src/evm/interpreter/gasometer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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)
Expand All @@ -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,
Expand Down Expand Up @@ -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));
Expand All @@ -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));
Expand All @@ -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));

Expand Down
6 changes: 4 additions & 2 deletions ethcore/src/evm/interpreter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/evm/jit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion ethcore/src/evm/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 11 additions & 2 deletions ethcore/src/executive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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]
Expand Down
9 changes: 7 additions & 2 deletions ethcore/src/externalities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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::*;
Expand Down
Loading