diff --git a/Cargo.lock b/Cargo.lock
index bca236813..9ce1c4372 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -44,6 +44,18 @@ dependencies = [
"syntex_syntax 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "bigint"
+version = "0.1.0"
+dependencies = [
+ "arrayvec 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapsize 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
[[package]]
name = "bitflags"
version = "0.3.3"
@@ -220,6 +232,7 @@ name = "ethcore-util"
version = "0.9.99"
dependencies = [
"arrayvec 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bigint 0.1.0",
"clippy 0.0.44 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"elastic-array 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/ethcore/src/account.rs b/ethcore/src/account.rs
index c36c35232..6901996bc 100644
--- a/ethcore/src/account.rs
+++ b/ethcore/src/account.rs
@@ -92,10 +92,10 @@ impl Account {
/// Create a new contract account.
/// NOTE: make sure you use `init_code` on this before `commit`ing.
- pub fn new_contract(balance: U256) -> Account {
+ pub fn new_contract(balance: U256, nonce: U256) -> Account {
Account {
balance: balance,
- nonce: U256::from(0u8),
+ nonce: nonce,
storage_root: SHA3_NULL_RLP,
storage_overlay: RefCell::new(HashMap::new()),
code_hash: None,
@@ -261,7 +261,7 @@ mod tests {
let mut db = MemoryDB::new();
let mut db = AccountDBMut::new(&mut db, &Address::new());
let rlp = {
- let mut a = Account::new_contract(U256::from(69u8));
+ let mut a = Account::new_contract(x!(69), x!(0));
a.set_storage(H256::from(&U256::from(0x00u64)), H256::from(&U256::from(0x1234u64)));
a.commit_storage(&mut db);
a.init_code(vec![]);
@@ -281,7 +281,7 @@ mod tests {
let mut db = AccountDBMut::new(&mut db, &Address::new());
let rlp = {
- let mut a = Account::new_contract(U256::from(69u8));
+ let mut a = Account::new_contract(x!(69), x!(0));
a.init_code(vec![0x55, 0x44, 0xffu8]);
a.commit_code(&mut db);
a.rlp()
@@ -296,7 +296,7 @@ mod tests {
#[test]
fn commit_storage() {
- let mut a = Account::new_contract(U256::from(69u8));
+ let mut a = Account::new_contract(x!(69), x!(0));
let mut db = MemoryDB::new();
let mut db = AccountDBMut::new(&mut db, &Address::new());
a.set_storage(x!(0), x!(0x1234));
@@ -307,7 +307,7 @@ mod tests {
#[test]
fn commit_remove_commit_storage() {
- let mut a = Account::new_contract(U256::from(69u8));
+ let mut a = Account::new_contract(x!(69), x!(0));
let mut db = MemoryDB::new();
let mut db = AccountDBMut::new(&mut db, &Address::new());
a.set_storage(x!(0), x!(0x1234));
@@ -321,7 +321,7 @@ mod tests {
#[test]
fn commit_code() {
- let mut a = Account::new_contract(U256::from(69u8));
+ let mut a = Account::new_contract(x!(69), x!(0));
let mut db = MemoryDB::new();
let mut db = AccountDBMut::new(&mut db, &Address::new());
a.init_code(vec![0x55, 0x44, 0xffu8]);
diff --git a/ethcore/src/action_params.rs b/ethcore/src/action_params.rs
index 9e2d72c73..fa40d30a0 100644
--- a/ethcore/src/action_params.rs
+++ b/ethcore/src/action_params.rs
@@ -15,9 +15,7 @@
// along with Parity. If not, see .
//! Evm input params.
-use util::hash::*;
-use util::uint::*;
-use util::bytes::*;
+use common::*;
/// Transaction value
#[derive(Clone, Debug)]
diff --git a/ethcore/src/blockchain/best_block.rs b/ethcore/src/blockchain/best_block.rs
index cbb219617..00c092713 100644
--- a/ethcore/src/blockchain/best_block.rs
+++ b/ethcore/src/blockchain/best_block.rs
@@ -14,8 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see .
-use util::hash::H256;
-use util::uint::U256;
+use util::numbers::{U256,H256};
use header::BlockNumber;
/// Best block info.
diff --git a/ethcore/src/blockchain/block_info.rs b/ethcore/src/blockchain/block_info.rs
index 98dac648d..ce639bfed 100644
--- a/ethcore/src/blockchain/block_info.rs
+++ b/ethcore/src/blockchain/block_info.rs
@@ -14,8 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see .
-use util::hash::H256;
-use util::uint::U256;
+use util::numbers::{U256,H256};
use header::BlockNumber;
/// Brief info about inserted block.
diff --git a/ethcore/src/blockchain/bloom_indexer.rs b/ethcore/src/blockchain/bloom_indexer.rs
index 74c679ba8..a672a5445 100644
--- a/ethcore/src/blockchain/bloom_indexer.rs
+++ b/ethcore/src/blockchain/bloom_indexer.rs
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see .
-use util::hash::H256;
+use util::numbers::H256;
use chainfilter::BloomIndex;
/// Represents location of block bloom in extras database.
@@ -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);
diff --git a/ethcore/src/blockchain/tree_route.rs b/ethcore/src/blockchain/tree_route.rs
index 1bd0e6f75..3c4906449 100644
--- a/ethcore/src/blockchain/tree_route.rs
+++ b/ethcore/src/blockchain/tree_route.rs
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see .
-use util::hash::H256;
+use util::numbers::H256;
/// Represents a tree route between `from` block and `to` block:
#[derive(Debug)]
diff --git a/ethcore/src/blockchain/update.rs b/ethcore/src/blockchain/update.rs
index f8ca06e66..6be2647d3 100644
--- a/ethcore/src/blockchain/update.rs
+++ b/ethcore/src/blockchain/update.rs
@@ -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};
diff --git a/ethcore/src/evm/ext.rs b/ethcore/src/evm/ext.rs
index ae4cff3be..f4172f10a 100644
--- a/ethcore/src/evm/ext.rs
+++ b/ethcore/src/evm/ext.rs
@@ -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::*;
@@ -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,
- data: &[u8],
- code_address: &Address,
+ data: &[u8],
+ code_address: &Address,
output: &mut [u8]) -> MessageCallResult;
/// Returns code at given address
@@ -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;
diff --git a/ethcore/src/state.rs b/ethcore/src/state.rs
index 8bbf317c1..c13678c38 100644
--- a/ethcore/src/state.rs
+++ b/ethcore/src/state.rs
@@ -138,7 +138,7 @@ impl State {
/// Create a new contract at address `contract`. If there is already an account at the address
/// it will have its code reset, ready for `init_code()`.
pub fn new_contract(&mut self, contract: &Address, balance: U256) {
- self.insert_cache(&contract, Some(Account::new_contract(balance)));
+ self.insert_cache(&contract, Some(Account::new_contract(balance, self.account_start_nonce)));
}
/// Remove an existing account.
@@ -204,7 +204,7 @@ impl State {
/// Initialise the code of account `a` so that it is `value` for `key`.
/// NOTE: Account should have been created with `new_contract`.
pub fn init_code(&mut self, a: &Address, code: Bytes) {
- self.require_or_from(a, true, || Account::new_contract(U256::from(0u8)), |_|{}).init_code(code);
+ self.require_or_from(a, true, || Account::new_contract(x!(0), self.account_start_nonce), |_|{}).init_code(code);
}
/// Execute a given transaction.
@@ -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::*;
@@ -349,7 +348,7 @@ fn code_from_database() {
let temp = RandomTempPath::new();
let (root, db) = {
let mut state = get_temp_state_in(temp.as_path());
- state.require_or_from(&a, false, ||Account::new_contract(U256::from(42u32)), |_|{});
+ state.require_or_from(&a, false, ||Account::new_contract(x!(42), x!(0)), |_|{});
state.init_code(&a, vec![1, 2, 3]);
assert_eq!(state.code(&a), Some([1u8, 2, 3].to_vec()));
state.commit();
diff --git a/ethcore/src/transaction.rs b/ethcore/src/transaction.rs
index fc9886a4d..a51824494 100644
--- a/ethcore/src/transaction.rs
+++ b/ethcore/src/transaction.rs
@@ -100,10 +100,10 @@ impl FromJson for SignedTransaction {
v: match json.find("v") { Some(ref j) => u16::from_json(j) as u8, None => 0 },
r: match json.find("r") { Some(j) => xjson!(j), None => x!(0) },
s: match json.find("s") { Some(j) => xjson!(j), None => x!(0) },
- hash: RefCell::new(None),
+ hash: Cell::new(None),
sender: match json.find("sender") {
- Some(&Json::String(ref sender)) => RefCell::new(Some(address_from_hex(clean(sender)))),
- _ => RefCell::new(None),
+ Some(&Json::String(ref sender)) => Cell::new(Some(address_from_hex(clean(sender)))),
+ _ => Cell::new(None),
}
}
}
@@ -127,8 +127,8 @@ impl Transaction {
r: r,
s: s,
v: v + 27,
- hash: RefCell::new(None),
- sender: RefCell::new(None)
+ hash: Cell::new(None),
+ sender: Cell::new(None),
}
}
@@ -140,8 +140,8 @@ impl Transaction {
r: U256::zero(),
s: U256::zero(),
v: 0,
- hash: RefCell::new(None),
- sender: RefCell::new(None)
+ hash: Cell::new(None),
+ sender: Cell::new(None),
}
}
@@ -171,9 +171,9 @@ pub struct SignedTransaction {
/// The S field of the signature; helps describe the point on the curve.
s: U256,
/// Cached hash.
- hash: RefCell