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

Commit

Permalink
Merge pull request #544 from ethcore/uint-refact
Browse files Browse the repository at this point in the history
uint to separate crate
  • Loading branch information
Gav Wood committed Mar 1, 2016
2 parents 3ac14a6 + 82a5289 commit 0082d12
Show file tree
Hide file tree
Showing 30 changed files with 193 additions and 92 deletions.
13 changes: 13 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions ethcore/src/action_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

//! Evm input params.
use util::hash::*;
use util::uint::*;
use util::bytes::*;
use common::*;

/// Transaction value
#[derive(Clone, Debug)]
Expand Down
3 changes: 1 addition & 2 deletions ethcore/src/blockchain/best_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +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 util::hash::H256;
use util::uint::U256;
use util::numbers::{U256,H256};
use header::BlockNumber;

/// Best block info.
Expand Down
3 changes: 1 addition & 2 deletions ethcore/src/blockchain/block_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +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 util::hash::H256;
use util::uint::U256;
use util::numbers::{U256,H256};
use header::BlockNumber;

/// Brief info about inserted block.
Expand Down
4 changes: 2 additions & 2 deletions ethcore/src/blockchain/bloom_indexer.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 util::hash::H256;
use util::numbers::H256;
use chainfilter::BloomIndex;

/// Represents location of block bloom in extras database.
Expand Down Expand Up @@ -44,7 +44,7 @@ impl BloomIndexer {
/// Calculates bloom's position in database.
pub fn location(&self, bloom_index: &BloomIndex) -> BlocksBloomLocation {
use std::{mem, ptr};

let hash = unsafe {
let mut hash: H256 = mem::zeroed();
ptr::copy(&[bloom_index.index / self.index_size] as *const usize as *const u8, hash.as_mut_ptr(), 8);
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/blockchain/tree_route.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 util::hash::H256;
use util::numbers::H256;

/// Represents a tree route between `from` block and `to` block:
#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/blockchain/update.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::collections::HashMap;
use util::hash::H256;
use util::numbers::H256;
use header::BlockNumber;
use blockchain::block_info::BlockInfo;
use extras::{BlockDetails, BlockReceipts, TransactionAddress, BlocksBlooms};
Expand Down
24 changes: 11 additions & 13 deletions ethcore/src/evm/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@

//! Interface for Evm externalities.

use common::Bytes;
use util::hash::*;
use util::uint::*;
use util::common::*;
use evm::{Schedule, Error};
use env_info::*;

Expand Down Expand Up @@ -60,22 +58,22 @@ pub trait Ext {
fn blockhash(&self, number: &U256) -> H256;

/// Creates new contract.
///
///
/// Returns gas_left and contract address if contract creation was succesfull.
fn create(&mut self, gas: &U256, value: &U256, code: &[u8]) -> ContractCreateResult;

/// Message call.
///
///
/// Returns Err, if we run out of gas.
/// Otherwise returns call_result which contains gas left
/// Otherwise returns call_result which contains gas left
/// and true if subcall was successfull.
fn call(&mut self,
gas: &U256,
sender_address: &Address,
receive_address: &Address,
fn call(&mut self,
gas: &U256,
sender_address: &Address,
receive_address: &Address,
value: Option<U256>,
data: &[u8],
code_address: &Address,
data: &[u8],
code_address: &Address,
output: &mut [u8]) -> MessageCallResult;

/// Returns code at given address
Expand All @@ -99,7 +97,7 @@ pub trait Ext {
fn env_info(&self) -> &EnvInfo;

/// Returns current depth of execution.
///
///
/// If contract A calls contract B, and contract B calls C,
/// then A depth is 0, B is 1, C is 2 and so on.
fn depth(&self) -> usize;
Expand Down
3 changes: 1 addition & 2 deletions ethcore/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,9 @@ impl fmt::Debug for State {
mod tests {

use super::*;
use util::hash::*;
use util::common::*;
use util::trie::*;
use util::rlp::*;
use util::uint::*;
use account::*;
use tests::helpers::*;
use devtools::*;
Expand Down
3 changes: 1 addition & 2 deletions rpc/src/v1/impls/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
use std::sync::{Arc, Weak};
use ethsync::{EthSync, SyncState};
use jsonrpc_core::*;
use util::hash::*;
use util::uint::*;
use util::numbers::*;
use util::sha3::*;
use ethcore::client::*;
use ethcore::views::*;
Expand Down
6 changes: 2 additions & 4 deletions rpc/src/v1/types/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

use serde::{Serialize, Serializer};
use util::hash::*;
use util::uint::*;
use util::numbers::*;
use v1::types::{Bytes, Transaction, OptionalValue};

#[derive(Debug)]
Expand Down Expand Up @@ -71,8 +70,7 @@ pub struct Block {
#[cfg(test)]
mod tests {
use serde_json;
use util::hash::*;
use util::uint::*;
use util::numbers::*;
use v1::types::{Transaction, Bytes, OptionalValue};
use super::*;

Expand Down
2 changes: 1 addition & 1 deletion rpc/src/v1/types/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use serde::{Deserialize, Deserializer, Error};
use serde_json::value;
use jsonrpc_core::Value;
use util::hash::*;
use util::numbers::*;
use v1::types::BlockNumber;
use ethcore::filter::Filter as EthFilter;
use ethcore::client::BlockId;
Expand Down
8 changes: 3 additions & 5 deletions rpc/src/v1/types/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +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 util::hash::*;
use util::uint::*;
use util::numbers::*;
use ethcore::log_entry::LocalizedLogEntry;
use v1::types::Bytes;

Expand Down Expand Up @@ -55,8 +54,7 @@ impl From<LocalizedLogEntry> for Log {
mod tests {
use serde_json;
use std::str::FromStr;
use util::hash::*;
use util::uint::*;
use util::numbers::*;
use v1::types::{Bytes, Log};

#[test]
Expand All @@ -66,7 +64,7 @@ mod tests {
let log = Log {
address: Address::from_str("33990122638b9132ca29c723bdf037f1a891a70c").unwrap(),
topics: vec![
H256::from_str("a6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc").unwrap(),
H256::from_str("a6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc").unwrap(),
H256::from_str("4861736852656700000000000000000000000000000000000000000000000000").unwrap()
],
data: Bytes::new(vec![]),
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/v1/types/sync.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/>.

use serde::{Serialize, Serializer};
use util::uint::*;
use util::numbers::*;

#[derive(Default, Debug, Serialize, PartialEq)]
pub struct SyncInfo {
Expand Down
3 changes: 1 addition & 2 deletions rpc/src/v1/types/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +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 util::hash::*;
use util::uint::*;
use util::numbers::*;
use ethcore::transaction::{LocalizedTransaction, Action};
use v1::types::{Bytes, OptionalValue};

Expand Down
1 change: 1 addition & 0 deletions util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ ethcore-devtools = { path = "../devtools" }
libc = "0.2.7"
vergen = "0.1"
target_info = "0.1"
bigint = { path = "bigint" }

[features]
default = []
Expand Down
23 changes: 23 additions & 0 deletions util/bigint/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
description = "Rust-assembler implementation of big integers arithmetic"
homepage = "http://ethcore.io"
license = "GPL-3.0"
name = "bigint"
version = "0.1.0"
authors = ["Ethcore <admin@ethcore.io>"]
build = "build.rs"

[build-dependencies]
rustc_version = "0.1"

[dependencies]
rustc-serialize = "0.3"
arrayvec = "0.3"
rand = "0.3.12"
serde = "0.7.0"
clippy = { version = "0.0.44", optional = true }
heapsize = "0.3"

[features]
x64asm_arithmetic=[]
rust_arithmetic=[]
25 changes: 25 additions & 0 deletions util/bigint/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// 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/>.

extern crate rustc_version;

use rustc_version::{version_meta, Channel};

fn main() {
if let Channel::Nightly = version_meta().channel {
println!("cargo:rustc-cfg=asm_available");
}
}
23 changes: 23 additions & 0 deletions util/bigint/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// 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/>.

#![cfg_attr(asm_available, feature(asm))]

extern crate rustc_serialize;
extern crate serde;
#[macro_use] extern crate heapsize;

pub mod uint;

0 comments on commit 0082d12

Please sign in to comment.