From b9af3f926064f723f9e9f34808174d5041a98a33 Mon Sep 17 00:00:00 2001 From: arkpar Date: Wed, 3 Feb 2016 19:34:51 +0100 Subject: [PATCH 01/23] State copy optimization --- ethcore/src/block.rs | 24 +++++----- ethcore/src/client.rs | 8 ++-- ethcore/src/ethereum/ethash.rs | 12 ++--- ethcore/src/ethereum/mod.rs | 6 +-- ethcore/src/executive.rs | 21 +++++---- ethcore/src/state.rs | 83 ++++++++++++++++++++++++++++------ ethcore/src/tests/helpers.rs | 24 ++++++---- util/src/journaldb.rs | 7 --- util/src/overlaydb.rs | 1 - 9 files changed, 121 insertions(+), 65 deletions(-) diff --git a/ethcore/src/block.rs b/ethcore/src/block.rs index a2de89d13..8d1c9caa8 100644 --- a/ethcore/src/block.rs +++ b/ethcore/src/block.rs @@ -62,7 +62,7 @@ impl Decodable for Block { /// Internal type for a block's common elements. // TODO: rename to ExecutedBlock // TODO: use BareBlock -#[derive(Debug, Clone)] +#[derive(Debug)] pub struct ExecutedBlock { base: Block, @@ -318,8 +318,8 @@ impl IsBlock for SealedBlock { /// Enact the block given by block header, transactions and uncles pub fn enact<'x, 'y>(header: &Header, transactions: &[Transaction], uncles: &[Header], engine: &'x Engine, db: JournalDB, parent: &Header, last_hashes: &'y LastHashes) -> Result, Error> { { - let s = State::from_existing(db.clone(), parent.state_root().clone(), engine.account_start_nonce()); - trace!("enact(): root={}, author={}, author_balance={}\n", s.root(), header.author(), s.balance(&header.author())); + //let s = State::from_existing(db.clone(), parent.state_root().clone(), engine.account_start_nonce()); + //trace!("enact(): root={}, author={}, author_balance={}\n", s.root(), header.author(), s.balance(&header.author())); } let mut b = OpenBlock::new(engine, db, parent, last_hashes, header.author().clone(), header.extra_data().clone()); @@ -363,10 +363,10 @@ mod tests { let engine = Spec::new_test().to_engine().unwrap(); let genesis_header = engine.spec().genesis_header(); let mut db_result = get_temp_journal_db(); - let db = db_result.reference_mut(); - engine.spec().ensure_db_good(db); + let mut db = db_result.take(); + engine.spec().ensure_db_good(&mut db); let last_hashes = vec![genesis_header.hash()]; - let b = OpenBlock::new(engine.deref(), db.clone(), &genesis_header, &last_hashes, Address::zero(), vec![]); + let b = OpenBlock::new(engine.deref(), db, &genesis_header, &last_hashes, Address::zero(), vec![]); let b = b.close(); let _ = b.seal(vec![]); } @@ -378,16 +378,16 @@ mod tests { let genesis_header = engine.spec().genesis_header(); let mut db_result = get_temp_journal_db(); - let db = db_result.reference_mut(); - engine.spec().ensure_db_good(db); - let b = OpenBlock::new(engine.deref(), db.clone(), &genesis_header, &vec![genesis_header.hash()], Address::zero(), vec![]).close().seal(vec![]).unwrap(); + let mut db = db_result.take(); + engine.spec().ensure_db_good(&mut db); + let b = OpenBlock::new(engine.deref(), db, &genesis_header, &vec![genesis_header.hash()], Address::zero(), vec![]).close().seal(vec![]).unwrap(); let orig_bytes = b.rlp_bytes(); let orig_db = b.drain(); let mut db_result = get_temp_journal_db(); - let db = db_result.reference_mut(); - engine.spec().ensure_db_good(db); - let e = enact_and_seal(&orig_bytes, engine.deref(), db.clone(), &genesis_header, &vec![genesis_header.hash()]).unwrap(); + let mut db = db_result.take(); + engine.spec().ensure_db_good(&mut db); + let e = enact_and_seal(&orig_bytes, engine.deref(), db, &genesis_header, &vec![genesis_header.hash()]).unwrap(); assert_eq!(e.rlp_bytes(), orig_bytes); diff --git a/ethcore/src/client.rs b/ethcore/src/client.rs index 03c03ab49..f5fd0f8f5 100644 --- a/ethcore/src/client.rs +++ b/ethcore/src/client.rs @@ -139,7 +139,7 @@ impl ClientReport { pub struct Client { chain: Arc>, engine: Arc>, - state_db: JournalDB, + state_db: Arc, block_queue: RwLock, report: RwLock, uncommited_states: RwLock>, @@ -186,7 +186,7 @@ impl Client { Ok(Arc::new(Client { chain: chain, engine: engine.clone(), - state_db: state_db, + state_db: db, block_queue: RwLock::new(BlockQueue::new(engine, message_channel)), report: RwLock::new(Default::default()), uncommited_states: RwLock::new(HashMap::new()), @@ -242,7 +242,7 @@ impl Client { } } - let db = self.state_db.clone(); + let db = JournalDB::new_with_arc(self.state_db.clone()); let result = match enact_verified(&block, self.engine.deref().deref(), db, &parent, &last_hashes) { Ok(b) => b, Err(e) => { @@ -284,7 +284,7 @@ impl Client { /// Get a copy of the best block's state. pub fn state(&self) -> State { - State::from_existing(self.state_db.clone(), HeaderView::new(&self.best_block_header()).state_root(), self.engine.account_start_nonce()) + State::from_existing(JournalDB::new_with_arc(self.state_db.clone()), HeaderView::new(&self.best_block_header()).state_root(), self.engine.account_start_nonce()) } /// Get info on the cache. diff --git a/ethcore/src/ethereum/ethash.rs b/ethcore/src/ethereum/ethash.rs index e9aedc128..9cd287654 100644 --- a/ethcore/src/ethereum/ethash.rs +++ b/ethcore/src/ethereum/ethash.rs @@ -232,10 +232,10 @@ fn on_close_block() { let engine = new_morden().to_engine().unwrap(); let genesis_header = engine.spec().genesis_header(); let mut db_result = get_temp_journal_db(); - let mut db = db_result.reference_mut(); - engine.spec().ensure_db_good(db); + let mut db = db_result.take(); + engine.spec().ensure_db_good(&mut db); let last_hashes = vec![genesis_header.hash()]; - let b = OpenBlock::new(engine.deref(), db.clone(), &genesis_header, &last_hashes, Address::zero(), vec![]); + let b = OpenBlock::new(engine.deref(), db, &genesis_header, &last_hashes, Address::zero(), vec![]); let b = b.close(); assert_eq!(b.state().balance(&Address::zero()), U256::from_str("4563918244f40000").unwrap()); } @@ -246,10 +246,10 @@ fn on_close_block_with_uncle() { let engine = new_morden().to_engine().unwrap(); let genesis_header = engine.spec().genesis_header(); let mut db_result = get_temp_journal_db(); - let mut db = db_result.reference_mut(); - engine.spec().ensure_db_good(db); + let mut db = db_result.take(); + engine.spec().ensure_db_good(&mut db); let last_hashes = vec![genesis_header.hash()]; - let mut b = OpenBlock::new(engine.deref(), db.clone(), &genesis_header, &last_hashes, Address::zero(), vec![]); + let mut b = OpenBlock::new(engine.deref(), db, &genesis_header, &last_hashes, Address::zero(), vec![]); let mut uncle = Header::new(); let uncle_author = address_from_hex("ef2d6d194084c2de36e0dabfce45d046b37d1106"); uncle.author = uncle_author.clone(); diff --git a/ethcore/src/ethereum/mod.rs b/ethcore/src/ethereum/mod.rs index ec6cfe103..1e8cc2c9c 100644 --- a/ethcore/src/ethereum/mod.rs +++ b/ethcore/src/ethereum/mod.rs @@ -44,9 +44,9 @@ mod tests { let engine = new_morden().to_engine().unwrap(); let genesis_header = engine.spec().genesis_header(); let mut db_result = get_temp_journal_db(); - let mut db = db_result.reference_mut(); - engine.spec().ensure_db_good(db); - let s = State::from_existing(db.clone(), genesis_header.state_root.clone(), engine.account_start_nonce()); + let mut db = db_result.take(); + engine.spec().ensure_db_good(&mut db); + let s = State::from_existing(db, genesis_header.state_root.clone(), engine.account_start_nonce()); assert_eq!(s.balance(&address_from_hex("0000000000000000000000000000000000000001")), U256::from(1u64)); assert_eq!(s.balance(&address_from_hex("0000000000000000000000000000000000000002")), U256::from(1u64)); assert_eq!(s.balance(&address_from_hex("0000000000000000000000000000000000000003")), U256::from(1u64)); diff --git a/ethcore/src/executive.rs b/ethcore/src/executive.rs index b67b71306..0a9cc37a3 100644 --- a/ethcore/src/executive.rs +++ b/ethcore/src/executive.rs @@ -194,7 +194,7 @@ impl<'a> Executive<'a> { /// Returns either gas_left or `evm::Error`. pub fn call(&mut self, params: ActionParams, substate: &mut Substate, mut output: BytesRef) -> evm::Result { // backup used in case of running out of gas - let backup = self.state.clone(); + self.state.snapshot(); // at first, transfer value to destination if let ActionValue::Transfer(val) = params.value { @@ -212,11 +212,12 @@ impl<'a> Executive<'a> { match cost <= params.gas { true => { self.engine.execute_builtin(¶ms.code_address, data, &mut output); + self.state.clear_snapshot(); Ok(params.gas - cost) }, // just drain the whole gas false => { - self.state.revert(backup); + self.state.revert_snapshot(); Err(evm::Error::OutOfGas) } } @@ -232,11 +233,12 @@ impl<'a> Executive<'a> { trace!("exec: sstore-clears={}\n", unconfirmed_substate.sstore_clears_count); trace!("exec: substate={:?}; unconfirmed_substate={:?}\n", substate, unconfirmed_substate); - self.enact_result(&res, substate, unconfirmed_substate, backup); + self.enact_result(&res, substate, unconfirmed_substate); trace!("exec: new substate={:?}\n", substate); res } else { // otherwise, nothing + self.state.clear_snapshot(); Ok(params.gas) } } @@ -246,7 +248,7 @@ impl<'a> Executive<'a> { /// Modifies the substate. pub fn create(&mut self, params: ActionParams, substate: &mut Substate) -> evm::Result { // backup used in case of running out of gas - let backup = self.state.clone(); + self.state.snapshot(); // part of substate that may be reverted let mut unconfirmed_substate = Substate::new(); @@ -263,7 +265,7 @@ impl<'a> Executive<'a> { let res = { self.exec_vm(params, &mut unconfirmed_substate, OutputPolicy::InitContract) }; - self.enact_result(&res, substate, unconfirmed_substate, backup); + self.enact_result(&res, substate, unconfirmed_substate); res } @@ -324,16 +326,19 @@ impl<'a> Executive<'a> { } } - fn enact_result(&mut self, result: &evm::Result, substate: &mut Substate, un_substate: Substate, backup: State) { + fn enact_result(&mut self, result: &evm::Result, substate: &mut Substate, un_substate: Substate) { match *result { Err(evm::Error::OutOfGas) | Err(evm::Error::BadJumpDestination {..}) | Err(evm::Error::BadInstruction {.. }) | Err(evm::Error::StackUnderflow {..}) | Err(evm::Error::OutOfStack {..}) => { - self.state.revert(backup); + self.state.revert_snapshot(); }, - Ok(_) | Err(evm::Error::Internal) => substate.accrue(un_substate) + Ok(_) | Err(evm::Error::Internal) => { + self.state.clear_snapshot(); + substate.accrue(un_substate) + } } } } diff --git a/ethcore/src/state.rs b/ethcore/src/state.rs index ed7d29813..3573897ca 100644 --- a/ethcore/src/state.rs +++ b/ethcore/src/state.rs @@ -13,12 +13,11 @@ use pod_state::PodState; pub type ApplyResult = Result; /// Representation of the entire state of all accounts in the system. -#[derive(Clone)] pub struct State { db: JournalDB, root: H256, cache: RefCell>>, - + snapshots: RefCell>>>>, account_start_nonce: U256, } @@ -36,6 +35,7 @@ impl State { db: db, root: root, cache: RefCell::new(HashMap::new()), + snapshots: RefCell::new(Vec::new()), account_start_nonce: account_start_nonce, } } @@ -51,10 +51,62 @@ impl State { db: db, root: root, cache: RefCell::new(HashMap::new()), + snapshots: RefCell::new(Vec::new()), account_start_nonce: account_start_nonce, } } + /// Create a recoverable snaphot of this state + pub fn snapshot(&mut self) { + self.snapshots.borrow_mut().push(HashMap::new()); + } + + pub fn clear_snapshot(&mut self) { + // merge with previous snapshot + let last = self.snapshots.borrow_mut().pop(); + if let Some(mut snapshot) = last { + if let Some(ref mut prev) = self.snapshots.borrow_mut().last_mut() { + for (k, v) in snapshot.drain() { + prev.entry(k).or_insert(v); + } + } + } + } + + pub fn revert_snapshot(&mut self) { + if let Some(mut snapshot) = self.snapshots.borrow_mut().pop() { + for (k, v) in snapshot.drain() { + match v { + Some(v) => { + self.cache.borrow_mut().insert(k, v); + }, + None => { + self.cache.borrow_mut().remove(&k); + } + } + } + } + } + + + fn insert_cache(&self, address: &Address, account: Option) { + if let Some(ref mut snapshot) = self.snapshots.borrow_mut().last_mut() { + if !snapshot.contains_key(&address) { + snapshot.insert(address.clone(), self.cache.borrow_mut().insert(address.clone(), account)); + return; + } + } + self.cache.borrow_mut().insert(address.clone(), account); + } + + fn note_cache(&self, address: &Address) { + if let Some(ref mut snapshot) = self.snapshots.borrow_mut().last_mut() { + if !snapshot.contains_key(&address) { + snapshot.insert(address.clone(), self.cache.borrow().get(address).cloned()); + } + } + } + /// Destroy the current object and return root and database. pub fn drop(self) -> (H256, JournalDB) { (self.root, self.db) @@ -68,12 +120,12 @@ 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.cache.borrow_mut().insert(contract.clone(), Some(Account::new_contract(balance))); + self.insert_cache(&contract, Some(Account::new_contract(balance))); } /// Remove an existing account. pub fn kill_account(&mut self, account: &Address) { - self.cache.borrow_mut().insert(account.clone(), None); + self.insert_cache(account, None); } /// Determine whether an account exists. @@ -152,11 +204,6 @@ impl State { Ok(receipt) } - /// Reverts uncommited changed. - pub fn revert(&mut self, backup: State) { - self.cache = backup.cache; - } - /// Commit accounts to SecTrieDBMut. This is similar to cpp-ethereum's dev::eth::commit. /// `accounts` is mutable because we may need to commit the code or storage and record that. #[allow(match_ref_pats)] @@ -186,6 +233,7 @@ impl State { /// Commits our cached account changes into the trie. pub fn commit(&mut self) { + assert!(self.snapshots.borrow().is_empty()); Self::commit_into(&mut self.db, &mut self.root, self.cache.borrow_mut().deref_mut()); } @@ -193,6 +241,7 @@ impl State { #[cfg(feature = "json-tests")] /// Populate the state from `accounts`. pub fn populate_from(&mut self, accounts: PodState) { + assert!(self.snapshots.borrow().is_empty()); for (add, acc) in accounts.drain().into_iter() { self.cache.borrow_mut().insert(add, Some(Account::from_pod(acc))); } @@ -202,6 +251,7 @@ impl State { #[cfg(feature = "json-tests")] /// Populate a PodAccount map from this state. pub fn to_pod(&self) -> PodState { + assert!(self.snapshots.borrow().is_empty()); // TODO: handle database rather than just the cache. PodState::from(self.cache.borrow().iter().fold(BTreeMap::new(), |mut m, (add, opt)| { if let Some(ref acc) = *opt { @@ -214,9 +264,10 @@ impl State { /// Pull account `a` in our cache from the trie DB and return it. /// `require_code` requires that the code be cached, too. fn get(&self, a: &Address, require_code: bool) -> Ref> { - self.cache.borrow_mut().entry(a.clone()).or_insert_with(|| { - SecTrieDB::new(&self.db, &self.root).get(&a).map(|rlp| Account::from_rlp(rlp)) - }); + let have_key = self.cache.borrow().contains_key(a); + if !have_key { + self.insert_cache(a, SecTrieDB::new(&self.db, &self.root).get(&a).map(|rlp| Account::from_rlp(rlp))) + } if require_code { if let Some(ref mut account) = self.cache.borrow_mut().get_mut(a).unwrap().as_mut() { account.cache_code(&self.db); @@ -233,8 +284,12 @@ impl State { /// Pull account `a` in our cache from the trie DB. `require_code` requires that the code be cached, too. /// If it doesn't exist, make account equal the evaluation of `default`. fn require_or_from Account, G: FnOnce(&mut Account)>(&self, a: &Address, require_code: bool, default: F, not_default: G) -> RefMut { - self.cache.borrow_mut().entry(a.clone()).or_insert_with(|| - SecTrieDB::new(&self.db, &self.root).get(&a).map(|rlp| Account::from_rlp(rlp))); + let have_key = self.cache.borrow().contains_key(a); + if !have_key { + self.insert_cache(a, SecTrieDB::new(&self.db, &self.root).get(&a).map(|rlp| Account::from_rlp(rlp))) + } else { + self.note_cache(a); + } let preexists = self.cache.borrow().get(a).unwrap().is_none(); if preexists { self.cache.borrow_mut().insert(a.clone(), Some(default())); diff --git a/ethcore/src/tests/helpers.rs b/ethcore/src/tests/helpers.rs index 04d47cbd3..a1d27442f 100644 --- a/ethcore/src/tests/helpers.rs +++ b/ethcore/src/tests/helpers.rs @@ -48,18 +48,22 @@ impl Drop for RandomTempPath { #[cfg(test)] pub struct GuardedTempResult { - result: T, + result: Option, _temp: RandomTempPath } impl GuardedTempResult { pub fn reference(&self) -> &T { - &self.result + self.result.as_ref().unwrap() } pub fn reference_mut(&mut self) -> &mut T { - &mut self.result + self.result.as_mut().unwrap() } + + pub fn take(&mut self) -> T { + self.result.take().unwrap() + } } pub fn get_test_spec() -> Spec { @@ -150,7 +154,7 @@ pub fn generate_dummy_client(block_number: u32) -> GuardedTempResult GuardedTempResult::> { _temp: dir, - result: client + result: Some(client) } } @@ -168,7 +172,7 @@ pub fn get_test_client_with_blocks(blocks: Vec) -> GuardedTempResult> { _temp: dir, - result: client + result: Some(client) } } @@ -181,7 +185,7 @@ pub fn generate_dummy_blockchain(block_number: u32) -> GuardedTempResult { _temp: temp, - result: bc + result: Some(bc) } } @@ -194,7 +198,7 @@ pub fn generate_dummy_blockchain_with_extra(block_number: u32) -> GuardedTempRes GuardedTempResult:: { _temp: temp, - result: bc + result: Some(bc) } } @@ -204,7 +208,7 @@ pub fn generate_dummy_empty_blockchain() -> GuardedTempResult { GuardedTempResult:: { _temp: temp, - result: bc + result: Some(bc) } } @@ -214,7 +218,7 @@ pub fn get_temp_journal_db() -> GuardedTempResult { let journal_db = JournalDB::new(db); GuardedTempResult { _temp: temp, - result: journal_db + result: Some(journal_db) } } @@ -223,7 +227,7 @@ pub fn get_temp_state() -> GuardedTempResult { let journal_db = get_temp_journal_db_in(temp.as_path()); GuardedTempResult { _temp: temp, - result: State::new(journal_db, U256::from(0u8)) + result: Some(State::new(journal_db, U256::from(0u8))) } } diff --git a/util/src/journaldb.rs b/util/src/journaldb.rs index e30b8947c..a8de1f71f 100644 --- a/util/src/journaldb.rs +++ b/util/src/journaldb.rs @@ -8,7 +8,6 @@ use rocksdb::{DB, Writable}; #[cfg(test)] use std::env; -#[derive(Clone)] /// Implementation of the HashDB trait for a disk-backed database with a memory overlay /// and latent-removal semantics. /// @@ -53,8 +52,6 @@ impl JournalDB { Self::new(DB::open_default(dir.to_str().unwrap()).unwrap()) } - /// Get a clone of the overlay db portion of this. - pub fn to_overlaydb(&self) -> OverlayDB { self.forward.clone() } /// Commit all recent insert operations and historical removals from the old era /// to the backing database. @@ -119,10 +116,6 @@ impl JournalDB { self.forward.commit() } - - /// Revert all operations on this object (i.e. `insert()`s and `removes()`s) since the - /// last `commit()`. - pub fn revert(&mut self) { self.forward.revert(); self.removes.clear(); } } impl HashDB for JournalDB { diff --git a/util/src/overlaydb.rs b/util/src/overlaydb.rs index 7ef0c3309..4a16a5717 100644 --- a/util/src/overlaydb.rs +++ b/util/src/overlaydb.rs @@ -12,7 +12,6 @@ use std::env; use std::collections::HashMap; use rocksdb::{DB, Writable, IteratorMode}; -#[derive(Clone)] /// Implementation of the HashDB trait for a disk-backed database with a memory overlay. /// /// The operations `insert()` and `remove()` take place on the memory overlay; batches of From 6b3390f03473e6ad21f9c14a4822f02d3c58519c Mon Sep 17 00:00:00 2001 From: arkpar Date: Thu, 4 Feb 2016 02:40:35 +0100 Subject: [PATCH 02/23] Refactored JournalDB --- ethcore/src/account.rs | 126 ++++++++++++++++++++++++++++++++++--- ethcore/src/client.rs | 5 +- ethcore/src/pod_account.rs | 2 +- ethcore/src/spec.rs | 4 +- ethcore/src/state.rs | 15 ++--- util/src/journaldb.rs | 111 +++++++++++++++++++++++++------- util/src/trie/triedb.rs | 2 +- 7 files changed, 221 insertions(+), 44 deletions(-) diff --git a/ethcore/src/account.rs b/ethcore/src/account.rs index 63f86b171..bde8eb8b7 100644 --- a/ethcore/src/account.rs +++ b/ethcore/src/account.rs @@ -3,6 +3,113 @@ use util::*; use pod_account::*; + +pub struct AccountDB<'db> { + db: &'db HashDB, + address: H256, +} + +impl<'db> AccountDB<'db> { + + pub fn new(db: &'db HashDB, address: &Address) -> AccountDB<'db> { + AccountDB { + db: db, + address: x!(address.clone()), + } + } + + #[inline] + fn key(&self, k: &H256) -> H256 { + k.clone() ^ self.address.clone() + } +} + +impl<'db> HashDB for AccountDB<'db>{ + fn keys(&self) -> HashMap { + unimplemented!() + } + fn lookup(&self, key: &H256) -> Option<&[u8]> { + if key == &SHA3_NULL_RLP { + return self.db.lookup(key); + } + self.db.lookup(&self.key(key)) + } + fn exists(&self, key: &H256) -> bool { + if key == &SHA3_NULL_RLP { + return true; + } + self.db.exists(&self.key(key)) + } + fn insert(&mut self, _value: &[u8]) -> H256 { + unimplemented!() + } + + fn emplace(&mut self, _key: H256, _value: Bytes) { + unimplemented!() + } + fn kill(&mut self, _key: &H256) { + unimplemented!() + } +} + +pub struct AccountDBMut<'db> { + db: &'db mut HashDB, + address: H256, +} + +impl<'db> AccountDBMut<'db> { + + pub fn new(db: &'db mut HashDB, address: &Address) -> AccountDBMut<'db> { + AccountDBMut { + db: db, + address: x!(address.clone()), + } + } + + #[allow(dead_code)] + pub fn immutable(&'db self) -> AccountDB<'db> { + AccountDB { db: self.db, address: self.address.clone() } + } + + #[inline] + fn key(&self, k: &H256) -> H256 { + k.clone() ^ self.address.clone() + } +} + +impl<'db> HashDB for AccountDBMut<'db>{ + fn keys(&self) -> HashMap { + unimplemented!() + } + fn lookup(&self, key: &H256) -> Option<&[u8]> { + if key == &SHA3_NULL_RLP { + return self.db.lookup(key); + } + self.db.lookup(&self.key(key)) + } + fn exists(&self, key: &H256) -> bool { + if key == &SHA3_NULL_RLP { + return true; + } + self.db.exists(&self.key(key)) + } + fn insert(&mut self, value: &[u8]) -> H256 { + let k = value.sha3(); + let ak = self.key(&k); + self.db.emplace(ak, value.to_vec()); + k + } + + fn emplace(&mut self, key: H256, value: Bytes) { + let key = self.key(&key); + self.db.emplace(key, value.to_vec()) + } + fn kill(&mut self, key: &H256) { + let key = self.key(&key); + self.db.kill(&key) + } +} + /// Single account in the system. #[derive(Clone)] pub struct Account { @@ -99,7 +206,7 @@ impl Account { } /// Get (and cache) the contents of the trie's storage at `key`. - pub fn storage_at(&self, db: &HashDB, key: &H256) -> H256 { + pub fn storage_at(&self, db: &AccountDB, key: &H256) -> H256 { self.storage_overlay.borrow_mut().entry(key.clone()).or_insert_with(||{ (Filth::Clean, H256::from(SecTrieDB::new(db, &self.storage_root).get(key.bytes()).map_or(U256::zero(), |v| -> U256 {decode(v)}))) }).1.clone() @@ -147,7 +254,7 @@ impl Account { } /// Provide a database to lookup `code_hash`. Should not be called if it is a contract without code. - pub fn cache_code(&mut self, db: &HashDB) -> bool { + pub fn cache_code(&mut self, db: &AccountDB) -> bool { // TODO: fill out self.code_cache; trace!("Account::cache_code: ic={}; self.code_hash={:?}, self.code_cache={}", self.is_cached(), self.code_hash, self.code_cache.pretty()); self.is_cached() || @@ -184,7 +291,7 @@ impl Account { pub fn sub_balance(&mut self, x: &U256) { self.balance = self.balance - *x; } /// Commit the `storage_overlay` to the backing DB and update `storage_root`. - pub fn commit_storage(&mut self, db: &mut HashDB) { + pub fn commit_storage(&mut self, db: &mut AccountDBMut) { let mut t = SecTrieDBMut::from_existing(db, &mut self.storage_root); for (k, &mut (ref mut f, ref mut v)) in self.storage_overlay.borrow_mut().iter_mut() { if f == &Filth::Dirty { @@ -200,7 +307,7 @@ impl Account { } /// Commit any unsaved code. `code_hash` will always return the hash of the `code_cache` after this. - pub fn commit_code(&mut self, db: &mut HashDB) { + pub fn commit_code(&mut self, db: &mut AccountDBMut) { trace!("Commiting code of {:?} - {:?}, {:?}", self, self.code_hash.is_none(), self.code_cache.is_empty()); match (self.code_hash.is_none(), self.code_cache.is_empty()) { (true, true) => self.code_hash = Some(SHA3_EMPTY), @@ -237,6 +344,7 @@ mod tests { #[test] fn storage_at() { 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)); a.set_storage(H256::from(&U256::from(0x00u64)), H256::from(&U256::from(0x1234u64))); @@ -248,13 +356,14 @@ mod tests { let a = Account::from_rlp(&rlp); assert_eq!(a.storage_root().unwrap().hex(), "c57e1afb758b07f8d2c8f13a3b6e44fa5ff94ab266facc5a4fd3f062426e50b2"); - assert_eq!(a.storage_at(&db, &H256::from(&U256::from(0x00u64))), H256::from(&U256::from(0x1234u64))); - assert_eq!(a.storage_at(&db, &H256::from(&U256::from(0x01u64))), H256::new()); + assert_eq!(a.storage_at(&db.immutable(), &H256::from(&U256::from(0x00u64))), H256::from(&U256::from(0x1234u64))); + assert_eq!(a.storage_at(&db.immutable(), &H256::from(&U256::from(0x01u64))), H256::new()); } #[test] fn note_code() { 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)); @@ -264,7 +373,7 @@ mod tests { }; let mut a = Account::from_rlp(&rlp); - assert!(a.cache_code(&db)); + assert!(a.cache_code(&db.immutable())); let mut a = Account::from_rlp(&rlp); assert_eq!(a.note_code(vec![0x55, 0x44, 0xffu8]), Ok(())); @@ -274,6 +383,7 @@ mod tests { fn commit_storage() { let mut a = Account::new_contract(U256::from(69u8)); let mut db = MemoryDB::new(); + let mut db = AccountDBMut::new(&mut db, &Address::new()); a.set_storage(x!(0), x!(0x1234)); assert_eq!(a.storage_root(), None); a.commit_storage(&mut db); @@ -284,6 +394,7 @@ mod tests { fn commit_remove_commit_storage() { let mut a = Account::new_contract(U256::from(69u8)); let mut db = MemoryDB::new(); + let mut db = AccountDBMut::new(&mut db, &Address::new()); a.set_storage(x!(0), x!(0x1234)); a.commit_storage(&mut db); a.set_storage(x!(1), x!(0x1234)); @@ -297,6 +408,7 @@ mod tests { fn commit_code() { let mut a = Account::new_contract(U256::from(69u8)); let mut db = MemoryDB::new(); + let mut db = AccountDBMut::new(&mut db, &Address::new()); a.init_code(vec![0x55, 0x44, 0xffu8]); assert_eq!(a.code_hash(), SHA3_EMPTY); a.commit_code(&mut db); diff --git a/ethcore/src/client.rs b/ethcore/src/client.rs index f5fd0f8f5..71c27502b 100644 --- a/ethcore/src/client.rs +++ b/ethcore/src/client.rs @@ -146,7 +146,7 @@ pub struct Client { import_lock: Mutex<()> } -const HISTORY: u64 = 1000; +const HISTORY: u64 = 1; impl Client { /// Create a new client with given spec and DB path. @@ -180,8 +180,7 @@ impl Client { let engine = Arc::new(try!(spec.to_engine())); let mut state_db = JournalDB::new_with_arc(db.clone()); - if engine.spec().ensure_db_good(&mut state_db) { - state_db.commit(0, &engine.spec().genesis_header().hash(), None).expect("Error commiting genesis state to state DB"); + if engine.spec().ensure_db_good(&mut state_db) { state_db.commit(0, &engine.spec().genesis_header().hash(), None).expect("Error commiting genesis state to state DB"); } Ok(Arc::new(Client { chain: chain, diff --git a/ethcore/src/pod_account.rs b/ethcore/src/pod_account.rs index 7bc886617..1c6142610 100644 --- a/ethcore/src/pod_account.rs +++ b/ethcore/src/pod_account.rs @@ -44,7 +44,7 @@ impl PodAccount { } /// Place additional data into given hash DB. - pub fn insert_additional(&self, db: &mut HashDB) { + pub fn insert_additional(&self, db: &mut AccountDBMut) { if !self.code.is_empty() { db.insert(&self.code); } diff --git a/ethcore/src/spec.rs b/ethcore/src/spec.rs index 50bbbb633..2b291249e 100644 --- a/ethcore/src/spec.rs +++ b/ethcore/src/spec.rs @@ -262,8 +262,8 @@ impl Spec { t.insert(address.as_slice(), &account.rlp()); } } - for (_, account) in self.genesis_state.get().iter() { - account.insert_additional(db); + for (address, account) in self.genesis_state.get().iter() { + account.insert_additional(&mut AccountDBMut::new(db, address)); } assert!(db.contains(&self.state_root())); true diff --git a/ethcore/src/state.rs b/ethcore/src/state.rs index 3573897ca..d80eed1f3 100644 --- a/ethcore/src/state.rs +++ b/ethcore/src/state.rs @@ -144,8 +144,8 @@ impl State { } /// Mutate storage of account `a` so that it is `value` for `key`. - pub fn storage_at(&self, a: &Address, key: &H256) -> H256 { - self.get(a, false).as_ref().map_or(H256::new(), |a|a.storage_at(&self.db, key)) + pub fn storage_at(&self, address: &Address, key: &H256) -> H256 { + self.get(address, false).as_ref().map_or(H256::new(), |a|a.storage_at(&AccountDB::new(&self.db, address), key)) } /// Mutate storage of account `a` so that it is `value` for `key`. @@ -210,11 +210,12 @@ impl State { pub fn commit_into(db: &mut HashDB, root: &mut H256, accounts: &mut HashMap>) { // first, commit the sub trees. // TODO: is this necessary or can we dispense with the `ref mut a` for just `a`? - for (_, ref mut a) in accounts.iter_mut() { + for (address, ref mut a) in accounts.iter_mut() { match a { &mut&mut Some(ref mut account) => { - account.commit_storage(db); - account.commit_code(db); + let mut account_db = AccountDBMut::new(db, address); + account.commit_storage(&mut account_db); + account.commit_code(&mut account_db); } &mut&mut None => {} } @@ -270,7 +271,7 @@ impl State { } if require_code { if let Some(ref mut account) = self.cache.borrow_mut().get_mut(a).unwrap().as_mut() { - account.cache_code(&self.db); + account.cache_code(&AccountDB::new(&self.db, a)); } } Ref::map(self.cache.borrow(), |m| m.get(a).unwrap()) @@ -300,7 +301,7 @@ impl State { let b = self.cache.borrow_mut(); RefMut::map(b, |m| m.get_mut(a).unwrap().as_mut().map(|account| { if require_code { - account.cache_code(&self.db); + account.cache_code(&AccountDB::new(&self.db, a)); } account }).unwrap()) diff --git a/util/src/journaldb.rs b/util/src/journaldb.rs index a8de1f71f..a07a9537d 100644 --- a/util/src/journaldb.rs +++ b/util/src/journaldb.rs @@ -3,8 +3,8 @@ use common::*; use rlp::*; use hashdb::*; -use overlaydb::*; -use rocksdb::{DB, Writable}; +use memorydb::*; +use rocksdb::{DB, Writable, IteratorMode}; #[cfg(test)] use std::env; @@ -16,10 +16,8 @@ use std::env; /// immediately. Rather some age (based on a linear but arbitrary metric) must pass before /// the removals actually take effect. pub struct JournalDB { - forward: OverlayDB, + overlay: MemoryDB, backing: Arc, - inserts: Vec, - removes: Vec, } impl JournalDB { @@ -27,20 +25,16 @@ impl JournalDB { pub fn new(backing: DB) -> JournalDB { let db = Arc::new(backing); JournalDB { - forward: OverlayDB::new_with_arc(db.clone()), + overlay: MemoryDB::new(), backing: db, - inserts: vec![], - removes: vec![], } } /// Create a new instance given a shared `backing` database. pub fn new_with_arc(backing: Arc) -> JournalDB { JournalDB { - forward: OverlayDB::new_with_arc(backing.clone()), + overlay: MemoryDB::new(), backing: backing, - inserts: vec![], - removes: vec![], } } @@ -84,12 +78,12 @@ impl JournalDB { } let mut r = RlpStream::new_list(3); + let inserts: Vec = self.overlay.keys().iter().filter(|&(_, &c)| c > 0).map(|(key, _)| key.clone()).collect(); + let removes: Vec = self.overlay.keys().iter().filter(|&(_, &c)| c < 0).map(|(key, _)| key.clone()).collect(); r.append(id); - r.append(&self.inserts); - r.append(&self.removes); + r.append(&inserts); + r.append(&removes); try!(self.backing.put(&last, r.as_raw())); - self.inserts.clear(); - self.removes.clear(); } // apply old commits' details @@ -106,7 +100,7 @@ impl JournalDB { let rlp = Rlp::new(&rlp_data); let to_remove: Vec = rlp.val_at(if canon_id == rlp.val_at(0) {2} else {1}); for i in &to_remove { - self.forward.remove(i); + self.backing.delete(&i).expect("Low-level database error. Some issue with your hard disk?"); } try!(self.backing.delete(&last)); trace!("JournalDB: delete journal for time #{}.{}, (canon was {}): {} entries", end_era, index, canon_id, to_remove.len()); @@ -114,17 +108,88 @@ impl JournalDB { } } - self.forward.commit() + let mut ret = 0u32; + let mut deletes = 0usize; + for i in self.overlay.drain().into_iter() { + let (key, (value, rc)) = i; + if rc > 0 { + assert!(rc == 1); + if !self.backing.get(&key.bytes()).unwrap().is_none() { + info!("Exist: {:?}", key); + key.clone(); + } + self.backing.put(&key.bytes(), &value).expect("Low-level database error. Some issue with your hard disk?"); + ret += 1; + } + if rc < 0 { + assert!(rc == -1); + ret += 1; + deletes += 1; + } + } + trace!("JournalDB::commit() deleted {} nodes", deletes); + Ok(ret) + } + + fn payload(&self, key: &H256) -> Option { + self.backing.get(&key.bytes()).expect("Low-level database error. Some issue with your hard disk?").map(|v| v.to_vec()) } } impl HashDB for JournalDB { - fn keys(&self) -> HashMap { self.forward.keys() } - fn lookup(&self, key: &H256) -> Option<&[u8]> { self.forward.lookup(key) } - fn exists(&self, key: &H256) -> bool { self.forward.exists(key) } - fn insert(&mut self, value: &[u8]) -> H256 { let r = self.forward.insert(value); self.inserts.push(r.clone()); r } - fn emplace(&mut self, key: H256, value: Bytes) { self.inserts.push(key.clone()); self.forward.emplace(key, value); } - fn kill(&mut self, key: &H256) { self.removes.push(key.clone()); } + fn keys(&self) -> HashMap { + let mut ret: HashMap = HashMap::new(); + for (key, _) in self.backing.iterator(IteratorMode::Start) { + let h = H256::from_slice(key.deref()); + ret.insert(h, 1); + } + + for (key, refs) in self.overlay.keys().into_iter() { + let refs = *ret.get(&key).unwrap_or(&0) + refs; + ret.insert(key, refs); + } + ret + } + + fn lookup(&self, key: &H256) -> Option<&[u8]> { + let k = self.overlay.raw(key); + match k { + Some(&(ref d, rc)) if rc > 0 => Some(d), + _ => { + if let Some(x) = self.payload(key) { + Some(&self.overlay.denote(key, x).0) + } + else { + None + } + } + } + } + + fn exists(&self, key: &H256) -> bool { + self.lookup(key).is_some() + } + + fn insert(&mut self, value: &[u8]) -> H256 { + if value.sha3() == h256_from_hex("3567da57862169b0dc409933ec10da8113ef3810fd225ad81d4fc23c36ffa5d4") { + info!("GOTCHA"); + value.to_vec(); + } + self.overlay.insert(value) + } + fn emplace(&mut self, key: H256, value: Bytes) { + if key == h256_from_hex("3567da57862169b0dc409933ec10da8113ef3810fd225ad81d4fc23c36ffa5d4") { + info!("GOTCHA"); + value.to_vec(); + } + self.overlay.emplace(key, value); + } + fn kill(&mut self, key: &H256) { + if key == &h256_from_hex("3567da57862169b0dc409933ec10da8113ef3810fd225ad81d4fc23c36ffa5d4") { + info!("DELETING"); + key.clone(); + } + self.overlay.kill(key); } } #[cfg(test)] diff --git a/util/src/trie/triedb.rs b/util/src/trie/triedb.rs index 9909c05a4..14b927149 100644 --- a/util/src/trie/triedb.rs +++ b/util/src/trie/triedb.rs @@ -196,7 +196,7 @@ impl<'db> TrieDB<'db> { // check if its sha3 + len let r = Rlp::new(node); match r.is_data() && r.size() == 32 { - true => self.db.lookup(&r.as_val::()).expect("Not found!"), + true => self.db.lookup(&r.as_val::()).unwrap_or_else(|| panic!("Not found! {:?}", r.as_val::())), false => node } } From e92c6ee7198db4f55fc0c2ad9cd836953ed65659 Mon Sep 17 00:00:00 2001 From: debris Date: Thu, 4 Feb 2016 17:23:53 +0100 Subject: [PATCH 03/23] Signed transaciton split in progress --- ethcore/src/block.rs | 10 +- ethcore/src/blockchain.rs | 2 +- ethcore/src/engine.rs | 2 +- ethcore/src/ethereum/ethash.rs | 2 +- ethcore/src/transaction.rs | 342 ++++++++++++++++++++++----------- ethcore/src/verification.rs | 2 +- ethcore/src/views.rs | 2 +- 7 files changed, 235 insertions(+), 127 deletions(-) diff --git a/ethcore/src/block.rs b/ethcore/src/block.rs index a2de89d13..2e6b84d2a 100644 --- a/ethcore/src/block.rs +++ b/ethcore/src/block.rs @@ -14,7 +14,7 @@ pub struct Block { /// The header of this block. pub header: Header, /// The transactions in this block. - pub transactions: Vec, + pub transactions: Vec, /// The uncles of this block. pub uncles: Vec
, } @@ -76,7 +76,7 @@ pub struct BlockRefMut<'a> { /// Block header. pub header: &'a Header, /// Block transactions. - pub transactions: &'a Vec, + pub transactions: &'a Vec, /// Block uncles. pub uncles: &'a Vec
, /// Transaction receipts. @@ -113,7 +113,7 @@ pub trait IsBlock { fn state(&self) -> &State { &self.block().state } /// Get all information on transactions in this block. - fn transactions(&self) -> &Vec { &self.block().base.transactions } + fn transactions(&self) -> &Vec { &self.block().base.transactions } /// Get all information on receipts in this block. fn receipts(&self) -> &Vec { &self.block().receipts } @@ -228,7 +228,7 @@ impl<'x, 'y> OpenBlock<'x, 'y> { /// Push a transaction into the block. /// /// If valid, it will be executed, and archived together with the receipt. - pub fn push_transaction(&mut self, t: Transaction, h: Option) -> Result<&Receipt, Error> { + pub fn push_transaction(&mut self, t: SignedTransaction, h: Option) -> Result<&Receipt, Error> { let env_info = self.env_info(); // info!("env_info says gas_used={}", env_info.gas_used); match self.block.state.apply(&env_info, self.engine, &t) { @@ -316,7 +316,7 @@ impl IsBlock for SealedBlock { } /// Enact the block given by block header, transactions and uncles -pub fn enact<'x, 'y>(header: &Header, transactions: &[Transaction], uncles: &[Header], engine: &'x Engine, db: JournalDB, parent: &Header, last_hashes: &'y LastHashes) -> Result, Error> { +pub fn enact<'x, 'y>(header: &Header, transactions: &[SignedTransaction], uncles: &[Header], engine: &'x Engine, db: JournalDB, parent: &Header, last_hashes: &'y LastHashes) -> Result, Error> { { let s = State::from_existing(db.clone(), parent.state_root().clone(), engine.account_start_nonce()); trace!("enact(): root={}, author={}, author_balance={}\n", s.root(), header.author(), s.balance(&header.author())); diff --git a/ethcore/src/blockchain.rs b/ethcore/src/blockchain.rs index e2ed54c19..cc684df67 100644 --- a/ethcore/src/blockchain.rs +++ b/ethcore/src/blockchain.rs @@ -93,7 +93,7 @@ pub trait BlockProvider { /// Get a list of transactions for a given block. /// Returns None if block deos not exist. - fn transactions(&self, hash: &H256) -> Option> { + fn transactions(&self, hash: &H256) -> Option> { self.block(hash).map(|bytes| BlockView::new(&bytes).transactions()) } diff --git a/ethcore/src/engine.rs b/ethcore/src/engine.rs index 7017989e7..27e50bb84 100644 --- a/ethcore/src/engine.rs +++ b/ethcore/src/engine.rs @@ -58,7 +58,7 @@ pub trait Engine : Sync + Send { // TODO: consider including State in the params. fn verify_transaction_basic(&self, _t: &Transaction, _header: &Header) -> Result<(), Error> { Ok(()) } /// Verify a particular transaction is valid. - fn verify_transaction(&self, _t: &Transaction, _header: &Header) -> Result<(), Error> { Ok(()) } + fn verify_transaction(&self, _t: &SignedTransaction, _header: &Header) -> Result<(), Error> { Ok(()) } /// Don't forget to call Super::populateFromParent when subclassing & overriding. // TODO: consider including State in the params. diff --git a/ethcore/src/ethereum/ethash.rs b/ethcore/src/ethereum/ethash.rs index e9aedc128..a8cc92484 100644 --- a/ethcore/src/ethereum/ethash.rs +++ b/ethcore/src/ethereum/ethash.rs @@ -161,7 +161,7 @@ impl Engine for Ethash { Ok(()) } - fn verify_transaction(&self, t: &Transaction, _header: &Header) -> Result<(), Error> { + fn verify_transaction(&self, t: &SignedTransaction, _header: &Header) -> Result<(), Error> { t.sender().map(|_|()) // Perform EC recovery and cache sender } } diff --git a/ethcore/src/transaction.rs b/ethcore/src/transaction.rs index a5e70b0d6..0eed2dedd 100644 --- a/ethcore/src/transaction.rs +++ b/ethcore/src/transaction.rs @@ -35,19 +35,34 @@ pub struct Transaction { /// Transaction data. pub data: Bytes, - // signature - /// The V field of the signature, either 27 or 28; helps describe the point on the curve. - pub v: u8, - /// The R field of the signature; helps describe the point on the curve. - pub r: U256, - /// The S field of the signature; helps describe the point on the curve. - pub s: U256, - hash: RefCell>, - sender: RefCell>, + //// signature + ///// The V field of the signature, either 27 or 28; helps describe the point on the curve. + //pub v: u8, + ///// The R field of the signature; helps describe the point on the curve. + //pub r: U256, + ///// The S field of the signature; helps describe the point on the curve. + //pub s: U256, + + //hash: RefCell>, + //sender: RefCell>, } impl Transaction { + /// Append object with a without signature into RLP stream + pub fn rlp_append_unsigned_transaction(&self, s: &mut RlpStream) { + s.begin_list(6); + s.append(&self.nonce); + s.append(&self.gas_price); + s.append(&self.gas); + match self.action { + Action::Create => s.append_empty_data(), + Action::Call(ref to) => s.append(to) + }; + s.append(&self.value); + s.append(&self.data); + } + /// Create a new transaction. #[cfg(test)] #[cfg(feature = "json-tests")] @@ -59,11 +74,11 @@ impl Transaction { action: Action::Create, value: x!(0), data: vec![], - v: 0, - r: x!(0), - s: x!(0), - hash: RefCell::new(None), - sender: RefCell::new(None), + //v: 0, + //r: x!(0), + //s: x!(0), + //hash: RefCell::new(None), + //sender: RefCell::new(None), } } @@ -77,11 +92,11 @@ impl Transaction { action: Action::Call(to), value: value, data: data, - v: 0, - r: x!(0), - s: x!(0), - hash: RefCell::new(None), - sender: RefCell::new(None), + //v: 0, + //r: x!(0), + //s: x!(0), + //hash: RefCell::new(None), + //sender: RefCell::new(None), } } @@ -95,37 +110,37 @@ impl Transaction { action: Action::Create, value: value, data: data, - v: 0, - r: x!(0), - s: x!(0), - hash: RefCell::new(None), - sender: RefCell::new(None), + //v: 0, + //r: x!(0), + //s: x!(0), + //hash: RefCell::new(None), + //sender: RefCell::new(None), } } - /// Append object into RLP stream, optionally with or without the signature. - pub fn rlp_append_opt(&self, s: &mut RlpStream, with_seal: Seal) { - s.begin_list(6 + match with_seal { Seal::With => 3, _ => 0 }); - s.append(&self.nonce); - s.append(&self.gas_price); - s.append(&self.gas); - match self.action { - Action::Create => s.append_empty_data(), - Action::Call(ref to) => s.append(to), - }; - s.append(&self.value); - s.append(&self.data); - if let Seal::With = with_seal { - s.append(&(self.v as u16)).append(&self.r).append(&self.s); - } - } + ///// Append object into RLP stream, optionally with or without the signature. + //pub fn rlp_append_opt(&self, s: &mut RlpStream, with_seal: Seal) { + //s.begin_list(6 + match with_seal { Seal::With => 3, _ => 0 }); + //s.append(&self.nonce); + //s.append(&self.gas_price); + //s.append(&self.gas); + //match self.action { + //Action::Create => s.append_empty_data(), + //Action::Call(ref to) => s.append(to), + //}; + //s.append(&self.value); + //s.append(&self.data); + //if let Seal::With = with_seal { + //s.append(&(self.v as u16)).append(&self.r).append(&self.s); + //} + //} - /// Get the RLP serialisation of the object, optionally with or without the signature. - pub fn rlp_bytes_opt(&self, with_seal: Seal) -> Bytes { - let mut s = RlpStream::new(); - self.rlp_append_opt(&mut s, with_seal); - s.out() - } + ///// Get the RLP serialisation of the object, optionally with or without the signature. + //pub fn rlp_bytes_opt(&self, with_seal: Seal) -> Bytes { + //let mut s = RlpStream::new(); + //self.rlp_append_opt(&mut s, with_seal); + //s.out() + //} } impl FromJson for Transaction { @@ -140,73 +155,41 @@ impl FromJson for Transaction { }, value: xjson!(&json["value"]), data: xjson!(&json["data"]), - 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), - sender: match json.find("sender") { - Some(&Json::String(ref sender)) => RefCell::new(Some(address_from_hex(clean(sender)))), - _ => RefCell::new(None), - }, + //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), + //sender: match json.find("sender") { + //Some(&Json::String(ref sender)) => RefCell::new(Some(address_from_hex(clean(sender)))), + //_ => RefCell::new(None), + //}, }; - if let Some(&Json::String(ref secret_key)) = json.find("secretKey") { - r.sign(&h256_from_hex(clean(secret_key))); - } + //if let Some(&Json::String(ref secret_key)) = json.find("secretKey") { + //r.sign(&h256_from_hex(clean(secret_key))); + //} r } } -impl Encodable for Transaction { - fn rlp_append(&self, s: &mut RlpStream) { self.rlp_append_opt(s, Seal::With) } -} +//impl Encodable for Transaction { + //fn rlp_append(&self, s: &mut RlpStream) { self.rlp_append_opt(s, Seal::With) } +//} impl Transaction { - /// Get the hash of this header (sha3 of the RLP). - pub fn hash(&self) -> H256 { - let mut hash = self.hash.borrow_mut(); - match &mut *hash { - &mut Some(ref h) => h.clone(), - hash @ &mut None => { - *hash = Some(self.rlp_sha3()); - hash.as_ref().unwrap().clone() - } - } - } - - /// 0 is `v` is 27, 1 if 28, and 4 otherwise. - pub fn standard_v(&self) -> u8 { match self.v { 27 => 0, 28 => 1, _ => 4 } } - - /// Construct a signature object from the sig. - pub fn signature(&self) -> Signature { Signature::from_rsv(&From::from(&self.r), &From::from(&self.s), self.standard_v()) } - - /// The message hash of the transaction. - pub fn message_hash(&self) -> H256 { self.rlp_bytes_opt(Seal::Without).sha3() } - - /// Returns transaction sender. - pub fn sender(&self) -> Result { - let mut sender = self.sender.borrow_mut(); - match &mut *sender { - &mut Some(ref h) => Ok(h.clone()), - sender @ &mut None => { - *sender = Some(From::from(try!(ec::recover(&self.signature(), &self.message_hash())).sha3())); - Ok(sender.as_ref().unwrap().clone()) - } - } - } /// Signs the transaction as coming from `sender`. - pub fn sign(&mut self, secret: &Secret) { + //pub fn sign(&mut self, secret: &Secret) { // TODO: make always low. - let sig = ec::sign(secret, &self.message_hash()); - let (r, s, v) = sig.unwrap().to_rsv(); - self.r = r; - self.s = s; - self.v = v + 27; - } + //let sig = ec::sign(secret, &self.message_hash()); + //let (r, s, v) = sig.unwrap().to_rsv(); + //self.r = r; + //self.s = s; + //self.v = v + 27; + //} /// Signs the transaction as coming from `sender`. - #[cfg(test)] - pub fn signed(self, secret: &Secret) -> Transaction { let mut r = self; r.sign(secret); r } + //#[cfg(test)] + //pub fn signed(self, secret: &Secret) -> Transaction { let mut r = self; r.sign(secret); r } /// Get the transaction cost in gas for the given params. pub fn gas_required_for(is_create: bool, data: &[u8], schedule: &Schedule) -> u64 { @@ -216,19 +199,32 @@ impl Transaction { ) } + /// The message hash of the transaction. + pub fn message_hash(&self) -> H256 { + let mut stream = RlpStream::new(); + self.rlp_append_unsigned_transaction(&mut stream); + stream.out().sha3() + } + + pub fn sign(self, secret: &Secret) -> SignedTransaction { + let sig = ec::sign(secret, &self.message_hash()); + let (r, s, v) = sig.unwrap().to_rsv(); + SignedTransaction { + transaction: self, + r: r, + s: s, + v: v, + hash: RefCell::new(None), + sender: RefCell::new(None) + } + } + /// Get the transaction cost in gas for this transaction. pub fn gas_required(&self, schedule: &Schedule) -> u64 { Self::gas_required_for(match self.action{Action::Create=>true, Action::Call(_)=>false}, &self.data, schedule) } - /// Checks whether the signature has a low 's' value. - pub fn check_low_s(&self) -> Result<(), Error> { - if !ec::is_low_s(&self.s) { - Err(Error::Util(UtilError::Crypto(CryptoError::InvalidSignature))) - } else { - Ok(()) - } - } + /// Do basic validation, checking for valid signature and minimum gas, // TODO: consider use in block validation. @@ -258,19 +254,69 @@ impl Decodable for Action { } } -impl Decodable for Transaction { +//impl Decodable for Transaction { + //fn decode(decoder: &D) -> Result where D: Decoder { + //let d = decoder.as_rlp(); + //if d.item_count() != 9 { + //return Err(DecoderError::RlpIncorrectListLen); + //} + //Ok(Transaction { + //nonce: try!(d.val_at(0)), + //gas_price: try!(d.val_at(1)), + //gas: try!(d.val_at(2)), + //action: try!(d.val_at(3)), + //value: try!(d.val_at(4)), + //data: try!(d.val_at(5)), + //v: try!(d.val_at(6)), + //r: try!(d.val_at(7)), + //s: try!(d.val_at(8)), + //hash: RefCell::new(None), + //sender: RefCell::new(None), + //}) + //} +//} + +#[derive(Debug, Clone)] +pub struct SignedTransaction { + transaction: Transaction, + v: u8, + r: U256, + s: U256, + + hash: RefCell>, + sender: RefCell> +} + +impl Deref for SignedTransaction { + type Target = Transaction; + + fn deref(&self) -> &Self::Target { + &self.transaction + } +} + +impl Decodable for SignedTransaction { fn decode(decoder: &D) -> Result where D: Decoder { let d = decoder.as_rlp(); if d.item_count() != 9 { return Err(DecoderError::RlpIncorrectListLen); } - Ok(Transaction { - nonce: try!(d.val_at(0)), - gas_price: try!(d.val_at(1)), - gas: try!(d.val_at(2)), - action: try!(d.val_at(3)), - value: try!(d.val_at(4)), - data: try!(d.val_at(5)), + Ok(SignedTransaction { + transaction: Transaction { + nonce: try!(d.val_at(0)), + gas_price: try!(d.val_at(1)), + gas: try!(d.val_at(2)), + action: try!(d.val_at(3)), + value: try!(d.val_at(4)), + data: try!(d.val_at(5)), + + // to remove + v: 0, + r: From::from(0), + s: From::from(0), + hash: RefCell::new(None), + sender: RefCell::new(None) + }, v: try!(d.val_at(6)), r: try!(d.val_at(7)), s: try!(d.val_at(8)), @@ -280,6 +326,68 @@ impl Decodable for Transaction { } } +impl Encodable for SignedTransaction { + fn rlp_append(&self, s: &mut RlpStream) { self.rlp_append_sealed_transaction(s) } +} + +impl SignedTransaction { + /// Append object with a signature into RLP stream + pub fn rlp_append_sealed_transaction(&self, s: &mut RlpStream) { + s.begin_list(9); + s.append(&self.nonce); + s.appned(&self.gas_price); + s.append(&self.gas); + match self.action { + Action::Create => s.append_empty_data(), + Action::Call(ref to) => s.append(to) + }; + s.append(&self.value); + s.append(&self.data); + s.append(&self.v); + s.append(&self.r); + s.append(&self.s); + } + + /// Get the hash of this header (sha3 of the RLP). + pub fn hash(&self) -> H256 { + let mut hash = self.hash.borrow_mut(); + match &mut *hash { + &mut Some(ref h) => h.clone(), + hash @ &mut None => { + *hash = Some(self.rlp_sha3()); + hash.as_ref().unwrap().clone() + } + } + } + + /// 0 is `v` is 27, 1 if 28, and 4 otherwise. + pub fn standard_v(&self) -> u8 { match self.v { 27 => 0, 28 => 1, _ => 4 } } + + /// Construct a signature object from the sig. + pub fn signature(&self) -> Signature { Signature::from_rsv(&From::from(&self.r), &From::from(&self.s), self.standard_v()) } + + /// Checks whether the signature has a low 's' value. + pub fn check_low_s(&self) -> Result<(), Error> { + if !ec::is_low_s(&self.s) { + Err(Error::Util(UtilError::Crypto(CryptoError::InvalidSignature))) + } else { + Ok(()) + } + } + + /// Returns transaction sender. + pub fn sender(&self) -> Result { + let mut sender = self.sender.borrow_mut(); + match &mut *sender { + &mut Some(ref h) => Ok(h.clone()), + sender @ &mut None => { + *sender = Some(From::from(try!(ec::recover(&self.signature(), &self.message_hash())).sha3())); + Ok(sender.as_ref().unwrap().clone()) + } + } + } +} + #[test] fn sender_test() { let t: Transaction = decode(&FromHex::from_hex("f85f800182520894095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804").unwrap()); diff --git a/ethcore/src/verification.rs b/ethcore/src/verification.rs index efed43b84..db7faa074 100644 --- a/ethcore/src/verification.rs +++ b/ethcore/src/verification.rs @@ -14,7 +14,7 @@ pub struct PreVerifiedBlock { /// Populated block header pub header: Header, /// Populated block transactions - pub transactions: Vec, + pub transactions: Vec, /// Block bytes pub bytes: Bytes, } diff --git a/ethcore/src/views.rs b/ethcore/src/views.rs index e1c704625..334dcef65 100644 --- a/ethcore/src/views.rs +++ b/ethcore/src/views.rs @@ -135,7 +135,7 @@ impl<'a> BlockView<'a> { } /// Return List of transactions in given block. - pub fn transactions(&self) -> Vec { + pub fn transactions(&self) -> Vec { self.rlp.val_at(1) } From 048c27237a5a8d733b3d0d51fc0b73906991efdb Mon Sep 17 00:00:00 2001 From: arkpar Date: Thu, 4 Feb 2016 21:33:30 +0100 Subject: [PATCH 04/23] Counters in JournalDB --- ethcore/res/ethereum/tests | 2 +- ethcore/src/client.rs | 15 ++--- util/src/journaldb.rs | 128 +++++++++++++++++++++++++++++-------- 3 files changed, 107 insertions(+), 38 deletions(-) diff --git a/ethcore/res/ethereum/tests b/ethcore/res/ethereum/tests index c670b1d8c..3116f85a4 160000 --- a/ethcore/res/ethereum/tests +++ b/ethcore/res/ethereum/tests @@ -1 +1 @@ -Subproject commit c670b1d8c9f09593a6758ab2c099360e16c7c25b +Subproject commit 3116f85a499ceaf4dfdc46726060fc056e2d7829 diff --git a/ethcore/src/client.rs b/ethcore/src/client.rs index 71c27502b..088db8cd3 100644 --- a/ethcore/src/client.rs +++ b/ethcore/src/client.rs @@ -140,13 +140,13 @@ pub struct Client { chain: Arc>, engine: Arc>, state_db: Arc, + state_journal: Mutex, block_queue: RwLock, report: RwLock, - uncommited_states: RwLock>, import_lock: Mutex<()> } -const HISTORY: u64 = 1; +const HISTORY: u64 = 1000; impl Client { /// Create a new client with given spec and DB path. @@ -185,10 +185,10 @@ impl Client { Ok(Arc::new(Client { chain: chain, engine: engine.clone(), - state_db: db, + state_db: db.clone(), + state_journal: Mutex::new(JournalDB::new_with_arc(db)), block_queue: RwLock::new(BlockQueue::new(engine, message_channel)), report: RwLock::new(Default::default()), - uncommited_states: RwLock::new(HashMap::new()), import_lock: Mutex::new(()), })) } @@ -241,7 +241,7 @@ impl Client { } } - let db = JournalDB::new_with_arc(self.state_db.clone()); + let db = self.state_journal.lock().unwrap().clone(); let result = match enact_verified(&block, self.engine.deref().deref(), db, &parent, &last_hashes) { Ok(b) => b, Err(e) => { @@ -276,11 +276,6 @@ impl Client { ret } - /// Clear cached state overlay - pub fn clear_state(&self, hash: &H256) { - self.uncommited_states.write().unwrap().remove(hash); - } - /// Get a copy of the best block's state. pub fn state(&self) -> State { State::from_existing(JournalDB::new_with_arc(self.state_db.clone()), HeaderView::new(&self.best_block_header()).state_root(), self.engine.account_start_nonce()) diff --git a/util/src/journaldb.rs b/util/src/journaldb.rs index a07a9537d..d4dfc0d6c 100644 --- a/util/src/journaldb.rs +++ b/util/src/journaldb.rs @@ -4,7 +4,7 @@ use common::*; use rlp::*; use hashdb::*; use memorydb::*; -use rocksdb::{DB, Writable, IteratorMode}; +use rocksdb::{DB, Writable, IteratorMode, WriteBatch}; #[cfg(test)] use std::env; @@ -18,23 +18,35 @@ use std::env; pub struct JournalDB { overlay: MemoryDB, backing: Arc, + counters: Arc>>, } +impl Clone for JournalDB { + fn clone(&self) -> JournalDB { + JournalDB { + overlay: MemoryDB::new(), + backing: self.backing.clone(), + counters: self.counters.clone(), + } + } +} + +const LAST_ERA_KEY : [u8; 4] = [ b'l', b'a', b's', b't' ]; + impl JournalDB { /// Create a new instance given a `backing` database. pub fn new(backing: DB) -> JournalDB { let db = Arc::new(backing); - JournalDB { - overlay: MemoryDB::new(), - backing: db, - } + JournalDB::new_with_arc(db) } /// Create a new instance given a shared `backing` database. pub fn new_with_arc(backing: Arc) -> JournalDB { + let counters = JournalDB::read_counters(&backing); JournalDB { overlay: MemoryDB::new(), backing: backing, + counters: Arc::new(RwLock::new(counters)), } } @@ -49,6 +61,7 @@ impl JournalDB { /// Commit all recent insert operations and historical removals from the old era /// to the backing database. + #[allow(cyclomatic_complexity)] pub fn commit(&mut self, now: u64, id: &H256, end: Option<(u64, H256)>) -> Result { // journal format: // [era, 0] => [ id, [insert_0, ...], [remove_0, ...] ] @@ -63,6 +76,8 @@ impl JournalDB { // of its inserts otherwise. // record new commit's details. + let batch = WriteBatch::new(); + let mut counters = self.counters.write().unwrap(); { let mut index = 0usize; let mut last; @@ -79,11 +94,14 @@ impl JournalDB { let mut r = RlpStream::new_list(3); let inserts: Vec = self.overlay.keys().iter().filter(|&(_, &c)| c > 0).map(|(key, _)| key.clone()).collect(); + for i in &inserts { + *counters.entry(i.clone()).or_insert(0) += 1; + } let removes: Vec = self.overlay.keys().iter().filter(|&(_, &c)| c < 0).map(|(key, _)| key.clone()).collect(); r.append(id); r.append(&inserts); r.append(&removes); - try!(self.backing.put(&last, r.as_raw())); + try!(batch.put(&last, r.as_raw())); } // apply old commits' details @@ -98,14 +116,35 @@ impl JournalDB { &last })) { let rlp = Rlp::new(&rlp_data); + { + let to_add: Vec = rlp.val_at(1); + for i in &to_add { + let delete_counter = { + if let Some(mut cnt) = counters.get_mut(i) { + *cnt -= 1; + *cnt == 0 + } + else { false } + + }; + if delete_counter { + counters.remove(i); + } + } + } let to_remove: Vec = rlp.val_at(if canon_id == rlp.val_at(0) {2} else {1}); for i in &to_remove { - self.backing.delete(&i).expect("Low-level database error. Some issue with your hard disk?"); + if !counters.contains_key(i) { + batch.delete(&i).expect("Low-level database error. Some issue with your hard disk?"); + } } - try!(self.backing.delete(&last)); + + try!(batch.delete(&last)); trace!("JournalDB: delete journal for time #{}.{}, (canon was {}): {} entries", end_era, index, canon_id, to_remove.len()); index += 1; } + + try!(batch.put(&LAST_ERA_KEY, &encode(&end_era))); } let mut ret = 0u32; @@ -114,11 +153,7 @@ impl JournalDB { let (key, (value, rc)) = i; if rc > 0 { assert!(rc == 1); - if !self.backing.get(&key.bytes()).unwrap().is_none() { - info!("Exist: {:?}", key); - key.clone(); - } - self.backing.put(&key.bytes(), &value).expect("Low-level database error. Some issue with your hard disk?"); + batch.put(&key.bytes(), &value).expect("Low-level database error. Some issue with your hard disk?"); ret += 1; } if rc < 0 { @@ -127,6 +162,8 @@ impl JournalDB { deletes += 1; } } + + try!(self.backing.write(batch)); trace!("JournalDB::commit() deleted {} nodes", deletes); Ok(ret) } @@ -134,6 +171,35 @@ impl JournalDB { fn payload(&self, key: &H256) -> Option { self.backing.get(&key.bytes()).expect("Low-level database error. Some issue with your hard disk?").map(|v| v.to_vec()) } + + fn read_counters(db: &DB) -> HashMap { + let mut res = HashMap::new(); + if let Some(val) = db.get(&LAST_ERA_KEY).expect("Low-level database error.") { + let mut era = decode::(&val) + 1; + loop { + let mut index = 0usize; + while let Some(rlp_data) = db.get({ + let mut r = RlpStream::new_list(2); + r.append(&era); + r.append(&index); + &r.drain() + }).expect("Low-level database error.") { + let rlp = Rlp::new(&rlp_data); + let to_add: Vec = rlp.val_at(1); + for h in to_add { + *res.entry(h).or_insert(0) += 1; + } + index += 1; + }; + if index == 0 { + break; + } + era += 1; + } + } + info!("Recovered {} counters", res.len()); + res + } } impl HashDB for JournalDB { @@ -171,25 +237,14 @@ impl HashDB for JournalDB { } fn insert(&mut self, value: &[u8]) -> H256 { - if value.sha3() == h256_from_hex("3567da57862169b0dc409933ec10da8113ef3810fd225ad81d4fc23c36ffa5d4") { - info!("GOTCHA"); - value.to_vec(); - } - self.overlay.insert(value) + self.overlay.insert(value) } fn emplace(&mut self, key: H256, value: Bytes) { - if key == h256_from_hex("3567da57862169b0dc409933ec10da8113ef3810fd225ad81d4fc23c36ffa5d4") { - info!("GOTCHA"); - value.to_vec(); - } self.overlay.emplace(key, value); } fn kill(&mut self, key: &H256) { - if key == &h256_from_hex("3567da57862169b0dc409933ec10da8113ef3810fd225ad81d4fc23c36ffa5d4") { - info!("DELETING"); - key.clone(); - } - self.overlay.kill(key); } + self.overlay.kill(key); + } } #[cfg(test)] @@ -281,4 +336,23 @@ mod tests { assert!(!jdb.exists(&baz)); assert!(!jdb.exists(&bar)); } + + #[test] + fn overwrite() { + // history is 1 + let mut jdb = JournalDB::new_temp(); + + let foo = jdb.insert(b"foo"); + jdb.commit(0, &b"0".sha3(), None).unwrap(); + assert!(jdb.exists(&foo)); + + jdb.remove(&foo); + jdb.commit(1, &b"1".sha3(), Some((0, b"0".sha3()))).unwrap(); + jdb.insert(b"foo"); + assert!(jdb.exists(&foo)); + jdb.commit(2, &b"2".sha3(), Some((1, b"1".sha3()))).unwrap(); + assert!(jdb.exists(&foo)); + jdb.commit(3, &b"2".sha3(), Some((0, b"2".sha3()))).unwrap(); + assert!(jdb.exists(&foo)); + } } From eab8410402a1e307d24aa4e13aeb6d447c07c25d Mon Sep 17 00:00:00 2001 From: debris Date: Thu, 4 Feb 2016 23:48:29 +0100 Subject: [PATCH 05/23] finishe signed transactions --- ethcore/src/engine.rs | 2 +- ethcore/src/ethereum/ethash.rs | 2 +- ethcore/src/executive.rs | 57 +++-- ethcore/src/json_tests/state.rs | 2 +- ethcore/src/json_tests/transaction.rs | 8 +- ethcore/src/state.rs | 2 +- ethcore/src/tests/helpers.rs | 4 +- ethcore/src/transaction.rs | 291 ++++++++------------------ ethcore/src/verification.rs | 25 ++- 9 files changed, 164 insertions(+), 229 deletions(-) diff --git a/ethcore/src/engine.rs b/ethcore/src/engine.rs index 27e50bb84..a5a83c9cf 100644 --- a/ethcore/src/engine.rs +++ b/ethcore/src/engine.rs @@ -56,7 +56,7 @@ pub trait Engine : Sync + Send { /// Additional verification for transactions in blocks. // TODO: Add flags for which bits of the transaction to check. // TODO: consider including State in the params. - fn verify_transaction_basic(&self, _t: &Transaction, _header: &Header) -> Result<(), Error> { Ok(()) } + fn verify_transaction_basic(&self, _t: &SignedTransaction, _header: &Header) -> Result<(), Error> { Ok(()) } /// Verify a particular transaction is valid. fn verify_transaction(&self, _t: &SignedTransaction, _header: &Header) -> Result<(), Error> { Ok(()) } diff --git a/ethcore/src/ethereum/ethash.rs b/ethcore/src/ethereum/ethash.rs index a8cc92484..7645a9458 100644 --- a/ethcore/src/ethereum/ethash.rs +++ b/ethcore/src/ethereum/ethash.rs @@ -154,7 +154,7 @@ impl Engine for Ethash { Ok(()) } - fn verify_transaction_basic(&self, t: &Transaction, header: &Header) -> result::Result<(), Error> { + fn verify_transaction_basic(&self, t: &SignedTransaction, header: &Header) -> result::Result<(), Error> { if header.number() >= self.u64_param("frontierCompatibilityModeLimit") { try!(t.check_low_s()); } diff --git a/ethcore/src/executive.rs b/ethcore/src/executive.rs index b67b71306..3a16ea8c7 100644 --- a/ethcore/src/executive.rs +++ b/ethcore/src/executive.rs @@ -86,7 +86,7 @@ impl<'a> Executive<'a> { } /// This funtion should be used to execute transaction. - pub fn transact(&'a mut self, t: &Transaction) -> Result { + pub fn transact(&'a mut self, t: &SignedTransaction) -> Result { let sender = try!(t.sender()); let nonce = self.state.nonce(&sender); @@ -268,7 +268,7 @@ impl<'a> Executive<'a> { } /// Finalizes the transaction (does refunds and suicides). - fn finalize(&mut self, t: &Transaction, substate: Substate, result: evm::Result) -> ExecutionResult { + fn finalize(&mut self, t: &SignedTransaction, substate: Substate, result: evm::Result) -> ExecutionResult { let schedule = self.engine.schedule(self.info); // refunds from SSTORE nonzero -> zero @@ -685,9 +685,15 @@ mod tests { // test is incorrect, mk evm_test_ignore!{test_transact_simple: test_transact_simple_jit, test_transact_simple_int} fn test_transact_simple(factory: Factory) { - let mut t = Transaction::new_create(U256::from(17), "3331600055".from_hex().unwrap(), U256::from(100_000), U256::zero(), U256::zero()); let keypair = KeyPair::create().unwrap(); - t.sign(&keypair.secret()); + let t = Transaction { + action: Action::Create, + value: U256::from(17), + data: "3331600055".from_hex().unwrap(), + gas: U256::from(100_000), + gas_price: U256::zero(), + nonce: U256::zero() + }.sign(&keypair.secret()); let sender = t.sender().unwrap(); let contract = contract_address(&sender, &U256::zero()); @@ -717,8 +723,14 @@ mod tests { evm_test!{test_transact_invalid_sender: test_transact_invalid_sender_jit, test_transact_invalid_sender_int} fn test_transact_invalid_sender(factory: Factory) { - let t = Transaction::new_create(U256::from(17), "3331600055".from_hex().unwrap(), U256::from(100_000), U256::zero(), U256::zero()); - + let t = Transaction { + action: Action::Create, + value: U256::from(17), + data: "3331600055".from_hex().unwrap(), + gas: U256::from(100_000), + gas_price: U256::zero(), + nonce: U256::zero() + }.fake_sign(); let mut state_result = get_temp_state(); let mut state = state_result.reference_mut(); let mut info = EnvInfo::default(); @@ -738,11 +750,17 @@ mod tests { evm_test!{test_transact_invalid_nonce: test_transact_invalid_nonce_jit, test_transact_invalid_nonce_int} fn test_transact_invalid_nonce(factory: Factory) { - let mut t = Transaction::new_create(U256::from(17), "3331600055".from_hex().unwrap(), U256::from(100_000), U256::zero(), U256::one()); let keypair = KeyPair::create().unwrap(); - t.sign(&keypair.secret()); + let t = Transaction { + action: Action::Create, + value: U256::from(17), + data: "3331600055".from_hex().unwrap(), + gas: U256::from(100_000), + gas_price: U256::zero(), + nonce: U256::one() + }.sign(&keypair.secret()); let sender = t.sender().unwrap(); - + let mut state_result = get_temp_state(); let mut state = state_result.reference_mut(); state.add_balance(&sender, &U256::from(17)); @@ -764,9 +782,15 @@ mod tests { evm_test!{test_transact_gas_limit_reached: test_transact_gas_limit_reached_jit, test_transact_gas_limit_reached_int} fn test_transact_gas_limit_reached(factory: Factory) { - let mut t = Transaction::new_create(U256::from(17), "3331600055".from_hex().unwrap(), U256::from(80_001), U256::zero(), U256::zero()); let keypair = KeyPair::create().unwrap(); - t.sign(&keypair.secret()); + let t = Transaction { + action: Action::Create, + value: U256::from(17), + data: "3331600055".from_hex().unwrap(), + gas: U256::from(80_001), + gas_price: U256::zero(), + nonce: U256::zero() + }.sign(&keypair.secret()); let sender = t.sender().unwrap(); let mut state_result = get_temp_state(); @@ -791,9 +815,16 @@ mod tests { evm_test!{test_not_enough_cash: test_not_enough_cash_jit, test_not_enough_cash_int} fn test_not_enough_cash(factory: Factory) { - let mut t = Transaction::new_create(U256::from(18), "3331600055".from_hex().unwrap(), U256::from(100_000), U256::one(), U256::zero()); + let keypair = KeyPair::create().unwrap(); - t.sign(&keypair.secret()); + let t = Transaction { + action: Action::Create, + value: U256::from(18), + data: "3331600055".from_hex().unwrap(), + gas: U256::from(100_000), + gas_price: U256::one(), + nonce: U256::zero() + }.sign(&keypair.secret()); let sender = t.sender().unwrap(); let mut state_result = get_temp_state(); diff --git a/ethcore/src/json_tests/state.rs b/ethcore/src/json_tests/state.rs index fa8da9329..304d423dd 100644 --- a/ethcore/src/json_tests/state.rs +++ b/ethcore/src/json_tests/state.rs @@ -33,7 +33,7 @@ pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec { flush!(" - {}...", name); - let t = Transaction::from_json(&test["transaction"]); + let t = SignedTransaction::from_json(&test["transaction"]); let env = EnvInfo::from_json(&test["env"]); let _out = Bytes::from_json(&test["out"]); let post_state_root = xjson!(&test["postStateRoot"]); diff --git a/ethcore/src/json_tests/transaction.rs b/ethcore/src/json_tests/transaction.rs index 91f7d96e5..99e5e07c9 100644 --- a/ethcore/src/json_tests/transaction.rs +++ b/ethcore/src/json_tests/transaction.rs @@ -6,7 +6,7 @@ fn do_json_test(json_data: &[u8]) -> Vec { let mut failed = Vec::new(); let old_schedule = evm::Schedule::new_frontier(); let new_schedule = evm::Schedule::new_homestead(); - let ot = RefCell::new(Transaction::new()); + let ot = RefCell::new(None); for (name, test) in json.as_object().unwrap() { let mut fail = false; let mut fail_unless = |cond: bool| if !cond && !fail { failed.push(name.clone()); println!("Transaction: {:?}", ot.borrow()); fail = true }; @@ -15,7 +15,7 @@ fn do_json_test(json_data: &[u8]) -> Vec { .and_then(|s| BlockNumber::from_str(s).ok()) .unwrap_or(0) { x if x < 1_000_000 => &old_schedule, _ => &new_schedule }; let rlp = Bytes::from_json(&test["rlp"]); - let res = UntrustedRlp::new(&rlp).as_val().map_err(From::from).and_then(|t: Transaction| t.validate(schedule, schedule.have_delegate_call)); + let res = UntrustedRlp::new(&rlp).as_val().map_err(From::from).and_then(|t: SignedTransaction| t.validate(schedule, schedule.have_delegate_call)); fail_unless(test.find("transaction").is_none() == res.is_err()); if let (Some(&Json::Object(ref tx)), Some(&Json::String(ref expect_sender))) = (test.find("transaction"), test.find("sender")) { let t = res.unwrap(); @@ -26,10 +26,10 @@ fn do_json_test(json_data: &[u8]) -> Vec { fail_unless(t.nonce == xjson!(&tx["nonce"])); fail_unless(t.value == xjson!(&tx["value"])); if let Action::Call(ref to) = t.action { - *ot.borrow_mut() = t.clone(); + *ot.borrow_mut() = Some(t.clone()); fail_unless(to == &xjson!(&tx["to"])); } else { - *ot.borrow_mut() = t.clone(); + *ot.borrow_mut() = Some(t.clone()); fail_unless(Bytes::from_json(&tx["to"]).is_empty()); } } diff --git a/ethcore/src/state.rs b/ethcore/src/state.rs index ed7d29813..6f723952a 100644 --- a/ethcore/src/state.rs +++ b/ethcore/src/state.rs @@ -139,7 +139,7 @@ impl State { /// Execute a given transaction. /// This will change the state accordingly. - pub fn apply(&mut self, env_info: &EnvInfo, engine: &Engine, t: &Transaction) -> ApplyResult { + pub fn apply(&mut self, env_info: &EnvInfo, engine: &Engine, t: &SignedTransaction) -> ApplyResult { // let old = self.to_pod(); let e = try!(Executive::new(self, env_info, engine).transact(t)); diff --git a/ethcore/src/tests/helpers.rs b/ethcore/src/tests/helpers.rs index 04d47cbd3..c69f62617 100644 --- a/ethcore/src/tests/helpers.rs +++ b/ethcore/src/tests/helpers.rs @@ -103,12 +103,12 @@ fn create_unverifiable_block(order: u32, parent_hash: H256) -> Bytes { create_test_block(&create_unverifiable_block_header(order, parent_hash)) } -pub fn create_test_block_with_data(header: &Header, transactions: &[&Transaction], uncles: &[Header]) -> Bytes { +pub fn create_test_block_with_data(header: &Header, transactions: &[&SignedTransaction], uncles: &[Header]) -> Bytes { let mut rlp = RlpStream::new_list(3); rlp.append(header); rlp.begin_list(transactions.len()); for t in transactions { - rlp.append_raw(&t.rlp_bytes_opt(Seal::With), 1); + rlp.append_raw(&encode::(t).to_vec(), 1); } rlp.append(&uncles); rlp.out() diff --git a/ethcore/src/transaction.rs b/ethcore/src/transaction.rs index 0eed2dedd..355d01e0a 100644 --- a/ethcore/src/transaction.rs +++ b/ethcore/src/transaction.rs @@ -1,7 +1,6 @@ //! Transaction data structure. use util::*; -use basic_types::*; use error::*; use evm::Schedule; @@ -18,6 +17,16 @@ impl Default for Action { fn default() -> Action { Action::Create } } +impl Decodable for Action { + fn decode(decoder: &D) -> Result where D: Decoder { + let rlp = decoder.as_rlp(); + match rlp.is_empty() { + true => Ok(Action::Create), + false => Ok(Action::Call(try!(rlp.as_val()))) + } + } +} + /// A set of information describing an externally-originating message call /// or contract creation operation. #[derive(Default, Debug, Clone)] @@ -34,18 +43,6 @@ pub struct Transaction { pub value: U256, /// Transaction data. pub data: Bytes, - - - //// signature - ///// The V field of the signature, either 27 or 28; helps describe the point on the curve. - //pub v: u8, - ///// The R field of the signature; helps describe the point on the curve. - //pub r: U256, - ///// The S field of the signature; helps describe the point on the curve. - //pub s: U256, - - //hash: RefCell>, - //sender: RefCell>, } impl Transaction { @@ -62,90 +59,11 @@ impl Transaction { s.append(&self.value); s.append(&self.data); } - - /// Create a new transaction. - #[cfg(test)] - #[cfg(feature = "json-tests")] - pub fn new() -> Self { - Transaction { - nonce: x!(0), - gas_price: x!(0), - gas: x!(0), - action: Action::Create, - value: x!(0), - data: vec![], - //v: 0, - //r: x!(0), - //s: x!(0), - //hash: RefCell::new(None), - //sender: RefCell::new(None), - } - } - - /// Create a new message-call transaction. - #[allow(dead_code)] - pub fn new_call(to: Address, value: U256, data: Bytes, gas: U256, gas_price: U256, nonce: U256) -> Transaction { - Transaction { - nonce: nonce, - gas_price: gas_price, - gas: gas, - action: Action::Call(to), - value: value, - data: data, - //v: 0, - //r: x!(0), - //s: x!(0), - //hash: RefCell::new(None), - //sender: RefCell::new(None), - } - } - - /// Create a new contract-creation transaction. - #[cfg(test)] - pub fn new_create(value: U256, data: Bytes, gas: U256, gas_price: U256, nonce: U256) -> Transaction { - Transaction { - nonce: nonce, - gas_price: gas_price, - gas: gas, - action: Action::Create, - value: value, - data: data, - //v: 0, - //r: x!(0), - //s: x!(0), - //hash: RefCell::new(None), - //sender: RefCell::new(None), - } - } - - ///// Append object into RLP stream, optionally with or without the signature. - //pub fn rlp_append_opt(&self, s: &mut RlpStream, with_seal: Seal) { - //s.begin_list(6 + match with_seal { Seal::With => 3, _ => 0 }); - //s.append(&self.nonce); - //s.append(&self.gas_price); - //s.append(&self.gas); - //match self.action { - //Action::Create => s.append_empty_data(), - //Action::Call(ref to) => s.append(to), - //}; - //s.append(&self.value); - //s.append(&self.data); - //if let Seal::With = with_seal { - //s.append(&(self.v as u16)).append(&self.r).append(&self.s); - //} - //} - - ///// Get the RLP serialisation of the object, optionally with or without the signature. - //pub fn rlp_bytes_opt(&self, with_seal: Seal) -> Bytes { - //let mut s = RlpStream::new(); - //self.rlp_append_opt(&mut s, with_seal); - //s.out() - //} } -impl FromJson for Transaction { - fn from_json(json: &Json) -> Transaction { - let mut r = Transaction { +impl FromJson for SignedTransaction { + fn from_json(json: &Json) -> SignedTransaction { + let t = Transaction { nonce: xjson!(&json["nonce"]), gas_price: xjson!(&json["gasPrice"]), gas: xjson!(&json["gasLimit"]), @@ -155,41 +73,58 @@ impl FromJson for Transaction { }, value: xjson!(&json["value"]), data: xjson!(&json["data"]), - //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), - //sender: match json.find("sender") { - //Some(&Json::String(ref sender)) => RefCell::new(Some(address_from_hex(clean(sender)))), - //_ => RefCell::new(None), - //}, }; - //if let Some(&Json::String(ref secret_key)) = json.find("secretKey") { - //r.sign(&h256_from_hex(clean(secret_key))); - //} - r + match json.find("secretKey") { + Some(&Json::String(ref secret_key)) => t.sign(&h256_from_hex(clean(secret_key))), + _ => SignedTransaction { + transaction: t, + 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), + sender: match json.find("sender") { + Some(&Json::String(ref sender)) => RefCell::new(Some(address_from_hex(clean(sender)))), + _ => RefCell::new(None), + } + } + } } } -//impl Encodable for Transaction { - //fn rlp_append(&self, s: &mut RlpStream) { self.rlp_append_opt(s, Seal::With) } -//} - impl Transaction { + /// The message hash of the transaction. + pub fn message_hash(&self) -> H256 { + let mut stream = RlpStream::new(); + self.rlp_append_unsigned_transaction(&mut stream); + stream.out().sha3() + } /// Signs the transaction as coming from `sender`. - //pub fn sign(&mut self, secret: &Secret) { - // TODO: make always low. - //let sig = ec::sign(secret, &self.message_hash()); - //let (r, s, v) = sig.unwrap().to_rsv(); - //self.r = r; - //self.s = s; - //self.v = v + 27; - //} + pub fn sign(self, secret: &Secret) -> SignedTransaction { + let sig = ec::sign(secret, &self.message_hash()); + let (r, s, v) = sig.unwrap().to_rsv(); + SignedTransaction { + transaction: self, + r: r, + s: s, + v: v + 27, + hash: RefCell::new(None), + sender: RefCell::new(None) + } + } - /// Signs the transaction as coming from `sender`. - //#[cfg(test)] - //pub fn signed(self, secret: &Secret) -> Transaction { let mut r = self; r.sign(secret); r } + /// Useful for test incorrectly signed transactions. + #[cfg(test)] + pub fn fake_sign(self) -> SignedTransaction { + SignedTransaction { + transaction: self, + r: U256::zero(), + s: U256::zero(), + v: 0, + hash: RefCell::new(None), + sender: RefCell::new(None) + } + } /// Get the transaction cost in gas for the given params. pub fn gas_required_for(is_create: bool, data: &[u8], schedule: &Schedule) -> u64 { @@ -199,91 +134,27 @@ impl Transaction { ) } - /// The message hash of the transaction. - pub fn message_hash(&self) -> H256 { - let mut stream = RlpStream::new(); - self.rlp_append_unsigned_transaction(&mut stream); - stream.out().sha3() - } - - pub fn sign(self, secret: &Secret) -> SignedTransaction { - let sig = ec::sign(secret, &self.message_hash()); - let (r, s, v) = sig.unwrap().to_rsv(); - SignedTransaction { - transaction: self, - r: r, - s: s, - v: v, - hash: RefCell::new(None), - sender: RefCell::new(None) - } - } - /// Get the transaction cost in gas for this transaction. pub fn gas_required(&self, schedule: &Schedule) -> u64 { Self::gas_required_for(match self.action{Action::Create=>true, Action::Call(_)=>false}, &self.data, schedule) } - - - - /// Do basic validation, checking for valid signature and minimum gas, - // TODO: consider use in block validation. - #[cfg(test)] - #[cfg(feature = "json-tests")] - pub fn validate(self, schedule: &Schedule, require_low: bool) -> Result { - if require_low && !ec::is_low_s(&self.s) { - return Err(Error::Util(UtilError::Crypto(CryptoError::InvalidSignature))); - } - try!(self.sender()); - if self.gas < U256::from(self.gas_required(&schedule)) { - Err(From::from(TransactionError::InvalidGasLimit(OutOfBounds{min: Some(U256::from(self.gas_required(&schedule))), max: None, found: self.gas}))) - } else { - Ok(self) - } - } } -impl Decodable for Action { - fn decode(decoder: &D) -> Result where D: Decoder { - let rlp = decoder.as_rlp(); - if rlp.is_empty() { - Ok(Action::Create) - } else { - Ok(Action::Call(try!(rlp.as_val()))) - } - } -} -//impl Decodable for Transaction { - //fn decode(decoder: &D) -> Result where D: Decoder { - //let d = decoder.as_rlp(); - //if d.item_count() != 9 { - //return Err(DecoderError::RlpIncorrectListLen); - //} - //Ok(Transaction { - //nonce: try!(d.val_at(0)), - //gas_price: try!(d.val_at(1)), - //gas: try!(d.val_at(2)), - //action: try!(d.val_at(3)), - //value: try!(d.val_at(4)), - //data: try!(d.val_at(5)), - //v: try!(d.val_at(6)), - //r: try!(d.val_at(7)), - //s: try!(d.val_at(8)), - //hash: RefCell::new(None), - //sender: RefCell::new(None), - //}) - //} -//} #[derive(Debug, Clone)] pub struct SignedTransaction { + /// Plain Transaction. transaction: Transaction, + /// The V field of the signature, either 27 or 28; helps describe the point on the curve. v: u8, + /// The R field of the signature; helps describe the point on the curve. r: U256, + /// The S field of the signature; helps describe the point on the curve. s: U256, - + /// Cached hash. hash: RefCell>, + /// Cached sender. sender: RefCell> } @@ -309,13 +180,6 @@ impl Decodable for SignedTransaction { action: try!(d.val_at(3)), value: try!(d.val_at(4)), data: try!(d.val_at(5)), - - // to remove - v: 0, - r: From::from(0), - s: From::from(0), - hash: RefCell::new(None), - sender: RefCell::new(None) }, v: try!(d.val_at(6)), r: try!(d.val_at(7)), @@ -335,7 +199,7 @@ impl SignedTransaction { pub fn rlp_append_sealed_transaction(&self, s: &mut RlpStream) { s.begin_list(9); s.append(&self.nonce); - s.appned(&self.gas_price); + s.append(&self.gas_price); s.append(&self.gas); match self.action { Action::Create => s.append_empty_data(), @@ -386,11 +250,27 @@ impl SignedTransaction { } } } + + /// Do basic validation, checking for valid signature and minimum gas, + // TODO: consider use in block validation. + #[cfg(test)] + #[cfg(feature = "json-tests")] + pub fn validate(self, schedule: &Schedule, require_low: bool) -> Result { + if require_low && !ec::is_low_s(&self.s) { + return Err(Error::Util(UtilError::Crypto(CryptoError::InvalidSignature))); + } + try!(self.sender()); + if self.gas < U256::from(self.gas_required(&schedule)) { + Err(From::from(TransactionError::InvalidGasLimit(OutOfBounds{min: Some(U256::from(self.gas_required(&schedule))), max: None, found: self.gas}))) + } else { + Ok(self) + } + } } #[test] fn sender_test() { - let t: Transaction = decode(&FromHex::from_hex("f85f800182520894095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804").unwrap()); + let t: SignedTransaction = decode(&FromHex::from_hex("f85f800182520894095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804").unwrap()); assert_eq!(t.data, b""); assert_eq!(t.gas, U256::from(0x5208u64)); assert_eq!(t.gas_price, U256::from(0x01u64)); @@ -405,6 +285,13 @@ fn sender_test() { #[test] fn signing() { let key = KeyPair::create().unwrap(); - let t = Transaction::new_create(U256::from(42u64), b"Hello!".to_vec(), U256::from(3000u64), U256::from(50_000u64), U256::from(1u64)).signed(&key.secret()); + let t = Transaction { + action: Action::Create, + nonce: U256::from(42), + gas_price: U256::from(3000), + gas: U256::from(50_000), + value: U256::from(1), + data: b"Hello!".to_vec() + }.sign(&key.secret()); assert_eq!(Address::from(key.public().sha3()), t.sender().unwrap()); } diff --git a/ethcore/src/verification.rs b/ethcore/src/verification.rs index db7faa074..51f81dd81 100644 --- a/ethcore/src/verification.rs +++ b/ethcore/src/verification.rs @@ -220,7 +220,6 @@ mod tests { use engine::*; use spec::*; use transaction::*; - use basic_types::*; use tests::helpers::*; fn check_ok(result: Result<(), Error>) { @@ -309,8 +308,26 @@ mod tests { good.timestamp = 40; good.number = 10; - let tr1 = Transaction::new_create(x!(0), Bytes::new(), x!(30000), x!(40000), x!(1)); - let tr2 = Transaction::new_create(x!(0), Bytes::new(), x!(30000), x!(40000), x!(2)); + let keypair = KeyPair::create().unwrap(); + + let tr1 = Transaction { + action: Action::Create, + value: U256::from(0), + data: Bytes::new(), + gas: U256::from(30_000), + gas_price: U256::from(40_000), + nonce: U256::one() + }.sign(&keypair.secret()); + + let tr2 = Transaction { + action: Action::Create, + value: U256::from(0), + data: Bytes::new(), + gas: U256::from(30_000), + gas_price: U256::from(40_000), + nonce: U256::from(2) + }.sign(&keypair.secret()); + let good_transactions = [ &tr1, &tr2 ]; let diff_inc = U256::from(0x40); @@ -346,7 +363,7 @@ mod tests { let mut uncles_rlp = RlpStream::new(); uncles_rlp.append(&good_uncles); let good_uncles_hash = uncles_rlp.as_raw().sha3(); - let good_transactions_root = ordered_trie_root(good_transactions.iter().map(|t| t.rlp_bytes_opt(Seal::With)).collect()); + let good_transactions_root = ordered_trie_root(good_transactions.iter().map(|t| encode::(t).to_vec()).collect()); let mut parent = good.clone(); parent.number = 9; From 75ebac36a33db7d258cfb4d01f89977db2105e76 Mon Sep 17 00:00:00 2001 From: arkpar Date: Fri, 5 Feb 2016 01:49:06 +0100 Subject: [PATCH 06/23] Cleanup --- ethcore/src/account.rs | 109 +------------------------------------ ethcore/src/block.rs | 6 +- ethcore/src/client.rs | 3 +- ethcore/src/lib.rs | 1 + ethcore/src/pod_account.rs | 1 + ethcore/src/spec.rs | 1 + ethcore/src/state.rs | 1 + util/src/journaldb.rs | 21 ++++++- 8 files changed, 30 insertions(+), 113 deletions(-) diff --git a/ethcore/src/account.rs b/ethcore/src/account.rs index bde8eb8b7..a7013a70e 100644 --- a/ethcore/src/account.rs +++ b/ethcore/src/account.rs @@ -2,113 +2,7 @@ use util::*; use pod_account::*; - - -pub struct AccountDB<'db> { - db: &'db HashDB, - address: H256, -} - -impl<'db> AccountDB<'db> { - - pub fn new(db: &'db HashDB, address: &Address) -> AccountDB<'db> { - AccountDB { - db: db, - address: x!(address.clone()), - } - } - - #[inline] - fn key(&self, k: &H256) -> H256 { - k.clone() ^ self.address.clone() - } -} - -impl<'db> HashDB for AccountDB<'db>{ - fn keys(&self) -> HashMap { - unimplemented!() - } - fn lookup(&self, key: &H256) -> Option<&[u8]> { - if key == &SHA3_NULL_RLP { - return self.db.lookup(key); - } - self.db.lookup(&self.key(key)) - } - fn exists(&self, key: &H256) -> bool { - if key == &SHA3_NULL_RLP { - return true; - } - self.db.exists(&self.key(key)) - } - fn insert(&mut self, _value: &[u8]) -> H256 { - unimplemented!() - } - - fn emplace(&mut self, _key: H256, _value: Bytes) { - unimplemented!() - } - fn kill(&mut self, _key: &H256) { - unimplemented!() - } -} - -pub struct AccountDBMut<'db> { - db: &'db mut HashDB, - address: H256, -} - -impl<'db> AccountDBMut<'db> { - - pub fn new(db: &'db mut HashDB, address: &Address) -> AccountDBMut<'db> { - AccountDBMut { - db: db, - address: x!(address.clone()), - } - } - - #[allow(dead_code)] - pub fn immutable(&'db self) -> AccountDB<'db> { - AccountDB { db: self.db, address: self.address.clone() } - } - - #[inline] - fn key(&self, k: &H256) -> H256 { - k.clone() ^ self.address.clone() - } -} - -impl<'db> HashDB for AccountDBMut<'db>{ - fn keys(&self) -> HashMap { - unimplemented!() - } - fn lookup(&self, key: &H256) -> Option<&[u8]> { - if key == &SHA3_NULL_RLP { - return self.db.lookup(key); - } - self.db.lookup(&self.key(key)) - } - fn exists(&self, key: &H256) -> bool { - if key == &SHA3_NULL_RLP { - return true; - } - self.db.exists(&self.key(key)) - } - fn insert(&mut self, value: &[u8]) -> H256 { - let k = value.sha3(); - let ak = self.key(&k); - self.db.emplace(ak, value.to_vec()); - k - } - - fn emplace(&mut self, key: H256, value: Bytes) { - let key = self.key(&key); - self.db.emplace(key, value.to_vec()) - } - fn kill(&mut self, key: &H256) { - let key = self.key(&key); - self.db.kill(&key) - } -} +use account_db::*; /// Single account in the system. #[derive(Clone)] @@ -340,6 +234,7 @@ mod tests { use util::*; use super::*; + use account_db::*; #[test] fn storage_at() { diff --git a/ethcore/src/block.rs b/ethcore/src/block.rs index 8d1c9caa8..2a8874bb3 100644 --- a/ethcore/src/block.rs +++ b/ethcore/src/block.rs @@ -318,8 +318,10 @@ impl IsBlock for SealedBlock { /// Enact the block given by block header, transactions and uncles pub fn enact<'x, 'y>(header: &Header, transactions: &[Transaction], uncles: &[Header], engine: &'x Engine, db: JournalDB, parent: &Header, last_hashes: &'y LastHashes) -> Result, Error> { { - //let s = State::from_existing(db.clone(), parent.state_root().clone(), engine.account_start_nonce()); - //trace!("enact(): root={}, author={}, author_balance={}\n", s.root(), header.author(), s.balance(&header.author())); + if ::log::max_log_level() >= ::log::LogLevel::Trace { + let s = State::from_existing(db.clone(), parent.state_root().clone(), engine.account_start_nonce()); + trace!("enact(): root={}, author={}, author_balance={}\n", s.root(), header.author(), s.balance(&header.author())); + } } let mut b = OpenBlock::new(engine, db, parent, last_hashes, header.author().clone(), header.extra_data().clone()); diff --git a/ethcore/src/client.rs b/ethcore/src/client.rs index 088db8cd3..0016c51e6 100644 --- a/ethcore/src/client.rs +++ b/ethcore/src/client.rs @@ -180,7 +180,8 @@ impl Client { let engine = Arc::new(try!(spec.to_engine())); let mut state_db = JournalDB::new_with_arc(db.clone()); - if engine.spec().ensure_db_good(&mut state_db) { state_db.commit(0, &engine.spec().genesis_header().hash(), None).expect("Error commiting genesis state to state DB"); + if state_db.is_empty() && engine.spec().ensure_db_good(&mut state_db) { + state_db.commit(0, &engine.spec().genesis_header().hash(), None).expect("Error commiting genesis state to state DB"); } Ok(Arc::new(Client { chain: chain, diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs index 3df01d898..0cbe4a2d9 100644 --- a/ethcore/src/lib.rs +++ b/ethcore/src/lib.rs @@ -96,6 +96,7 @@ mod state_diff; mod engine; mod state; mod account; +mod account_db; mod action_params; mod transaction; mod receipt; diff --git a/ethcore/src/pod_account.rs b/ethcore/src/pod_account.rs index 1c6142610..95ac7dd4f 100644 --- a/ethcore/src/pod_account.rs +++ b/ethcore/src/pod_account.rs @@ -1,5 +1,6 @@ use util::*; use account::*; +use account_db::*; #[derive(Debug,Clone,PartialEq,Eq)] /// An account, expressed as Plain-Old-Data (hence the name). diff --git a/ethcore/src/spec.rs b/ethcore/src/spec.rs index 2b291249e..05fcfba99 100644 --- a/ethcore/src/spec.rs +++ b/ethcore/src/spec.rs @@ -4,6 +4,7 @@ use common::*; use engine::*; use pod_state::*; use null_engine::*; +use account_db::*; /// Convert JSON value to equivalent RLP representation. // TODO: handle container types. diff --git a/ethcore/src/state.rs b/ethcore/src/state.rs index d80eed1f3..19cc1f898 100644 --- a/ethcore/src/state.rs +++ b/ethcore/src/state.rs @@ -1,6 +1,7 @@ use common::*; use engine::Engine; use executive::Executive; +use account_db::*; #[cfg(test)] #[cfg(feature = "json-tests")] use pod_account::*; diff --git a/util/src/journaldb.rs b/util/src/journaldb.rs index d4dfc0d6c..18524f0fd 100644 --- a/util/src/journaldb.rs +++ b/util/src/journaldb.rs @@ -4,7 +4,7 @@ use common::*; use rlp::*; use hashdb::*; use memorydb::*; -use rocksdb::{DB, Writable, IteratorMode, WriteBatch}; +use rocksdb::{DB, Writable, WriteBatch, IteratorMode}; #[cfg(test)] use std::env; @@ -32,6 +32,9 @@ impl Clone for JournalDB { } const LAST_ERA_KEY : [u8; 4] = [ b'l', b'a', b's', b't' ]; +const VERSION_KEY : [u8; 4] = [ b'j', b'v', b'e', b'r' ]; + +const DB_VERSION: u32 = 1; impl JournalDB { /// Create a new instance given a `backing` database. @@ -42,6 +45,14 @@ impl JournalDB { /// Create a new instance given a shared `backing` database. pub fn new_with_arc(backing: Arc) -> JournalDB { + if backing.iterator(IteratorMode::Start).next().is_some() { + match backing.get(&VERSION_KEY).map(|d| d.map(|v| decode::(&v))) { + Ok(Some(DB_VERSION)) => {}, + v => panic!("Incompatible DB version, expected {}, got {:?}", DB_VERSION, v) + } + } else { + backing.put(&VERSION_KEY, &encode(&DB_VERSION)).expect("Error writing version to database"); + } let counters = JournalDB::read_counters(&backing); JournalDB { overlay: MemoryDB::new(), @@ -58,6 +69,10 @@ impl JournalDB { Self::new(DB::open_default(dir.to_str().unwrap()).unwrap()) } + /// Check if this database has any commits + pub fn is_empty(&self) -> bool { + self.backing.get(&LAST_ERA_KEY).expect("Low level database error").is_none() + } /// Commit all recent insert operations and historical removals from the old era /// to the backing database. @@ -68,7 +83,7 @@ impl JournalDB { // [era, 1] => [ id, [insert_0, ...], [remove_0, ...] ] // [era, n] => [ ... ] - // TODO: store last_era, reclaim_period. + // TODO: store reclaim_period. // when we make a new commit, we journal the inserts and removes. // for each end_era that we journaled that we are no passing by, @@ -197,7 +212,7 @@ impl JournalDB { era += 1; } } - info!("Recovered {} counters", res.len()); + trace!("Recovered {} counters", res.len()); res } } From 755ee95326945443cf342e3380261a1a98d8bd30 Mon Sep 17 00:00:00 2001 From: arkpar Date: Fri, 5 Feb 2016 01:49:17 +0100 Subject: [PATCH 07/23] Cleanup --- ethcore/src/account_db.rs | 117 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 ethcore/src/account_db.rs diff --git a/ethcore/src/account_db.rs b/ethcore/src/account_db.rs new file mode 100644 index 000000000..7a07778f0 --- /dev/null +++ b/ethcore/src/account_db.rs @@ -0,0 +1,117 @@ +//! DB backend wrapper for Account trie +use util::*; + +static NULL_RLP_STATIC: [u8; 1] = [0x80; 1]; + +// TODO: introduce HashDBMut? +/// DB backend wrapper for Account trie +/// Transforms trie node keys for the database +pub struct AccountDB<'db> { + db: &'db HashDB, + address: H256, +} + +#[inline] +fn combine_key<'a>(address: &'a H256, key: &'a H256) -> H256 { + address ^ key +} + +impl<'db> AccountDB<'db> { + pub fn new(db: &'db HashDB, address: &Address) -> AccountDB<'db> { + AccountDB { + db: db, + address: x!(address.clone()), + } + } +} + +impl<'db> HashDB for AccountDB<'db>{ + fn keys(&self) -> HashMap { + unimplemented!() + } + + fn lookup(&self, key: &H256) -> Option<&[u8]> { + if key == &SHA3_NULL_RLP { + return Some(&NULL_RLP_STATIC); + } + self.db.lookup(&combine_key(&self.address, key)) + } + + fn exists(&self, key: &H256) -> bool { + if key == &SHA3_NULL_RLP { + return true; + } + self.db.exists(&combine_key(&self.address, key)) + } + + fn insert(&mut self, _value: &[u8]) -> H256 { + unimplemented!() + } + + fn emplace(&mut self, _key: H256, _value: Bytes) { + unimplemented!() + } + + fn kill(&mut self, _key: &H256) { + unimplemented!() + } +} + +/// DB backend wrapper for Account trie +pub struct AccountDBMut<'db> { + db: &'db mut HashDB, + address: H256, +} + +impl<'db> AccountDBMut<'db> { + pub fn new(db: &'db mut HashDB, address: &Address) -> AccountDBMut<'db> { + AccountDBMut { + db: db, + address: x!(address.clone()), + } + } + + #[allow(dead_code)] + pub fn immutable(&'db self) -> AccountDB<'db> { + AccountDB { db: self.db, address: self.address.clone() } + } +} + +impl<'db> HashDB for AccountDBMut<'db>{ + fn keys(&self) -> HashMap { + unimplemented!() + } + + fn lookup(&self, key: &H256) -> Option<&[u8]> { + if key == &SHA3_NULL_RLP { + return Some(&NULL_RLP_STATIC); + } + self.db.lookup(&combine_key(&self.address, key)) + } + + fn exists(&self, key: &H256) -> bool { + if key == &SHA3_NULL_RLP { + return true; + } + self.db.exists(&combine_key(&self.address, key)) + } + + fn insert(&mut self, value: &[u8]) -> H256 { + let k = value.sha3(); + let ak = combine_key(&self.address, &k); + self.db.emplace(ak, value.to_vec()); + k + } + + fn emplace(&mut self, key: H256, value: Bytes) { + let key = combine_key(&self.address, &key); + self.db.emplace(key, value.to_vec()) + } + + fn kill(&mut self, key: &H256) { + let key = combine_key(&self.address, key); + self.db.kill(&key) + } +} + + From a87edc25575cdc160d4dde97f830002867910d4e Mon Sep 17 00:00:00 2001 From: arkpar Date: Fri, 5 Feb 2016 02:08:17 +0100 Subject: [PATCH 08/23] Style --- ethcore/src/state.rs | 3 ++- util/src/journaldb.rs | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ethcore/src/state.rs b/ethcore/src/state.rs index 19cc1f898..4db171d77 100644 --- a/ethcore/src/state.rs +++ b/ethcore/src/state.rs @@ -62,6 +62,7 @@ impl State { self.snapshots.borrow_mut().push(HashMap::new()); } + /// Merge last snapshot with previous pub fn clear_snapshot(&mut self) { // merge with previous snapshot let last = self.snapshots.borrow_mut().pop(); @@ -74,6 +75,7 @@ impl State { } } + /// Revert to snapshot pub fn revert_snapshot(&mut self) { if let Some(mut snapshot) = self.snapshots.borrow_mut().pop() { for (k, v) in snapshot.drain() { @@ -89,7 +91,6 @@ impl State { } } - fn insert_cache(&self, address: &Address, account: Option) { if let Some(ref mut snapshot) = self.snapshots.borrow_mut().last_mut() { if !snapshot.contains_key(&address) { diff --git a/util/src/journaldb.rs b/util/src/journaldb.rs index 18524f0fd..393154b48 100644 --- a/util/src/journaldb.rs +++ b/util/src/journaldb.rs @@ -130,9 +130,10 @@ impl JournalDB { last = r.drain(); &last })) { + let to_add; let rlp = Rlp::new(&rlp_data); { - let to_add: Vec = rlp.val_at(1); + to_add = rlp.val_at(1); for i in &to_add { let delete_counter = { if let Some(mut cnt) = counters.get_mut(i) { @@ -147,7 +148,7 @@ impl JournalDB { } } } - let to_remove: Vec = rlp.val_at(if canon_id == rlp.val_at(0) {2} else {1}); + let to_remove: Vec = if canon_id == rlp.val_at(0) {rlp.val_at(2)} else {to_add}; for i in &to_remove { if !counters.contains_key(i) { batch.delete(&i).expect("Low-level database error. Some issue with your hard disk?"); From 97082ca8079533ee82991340751323c4b2d430f4 Mon Sep 17 00:00:00 2001 From: arkpar Date: Fri, 5 Feb 2016 02:15:26 +0100 Subject: [PATCH 09/23] Reduced allocations in interpreter --- ethcore/src/evm/interpreter.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/ethcore/src/evm/interpreter.rs b/ethcore/src/evm/interpreter.rs index 6516d9946..6bec042cb 100644 --- a/ethcore/src/evm/interpreter.rs +++ b/ethcore/src/evm/interpreter.rs @@ -263,7 +263,7 @@ pub struct Interpreter; impl evm::Evm for Interpreter { fn exec(&self, params: ActionParams, ext: &mut evm::Ext) -> evm::Result { - let code = ¶ms.code.clone().unwrap(); + let code = ¶ms.code.as_ref().unwrap(); let valid_jump_destinations = self.find_jump_destinations(&code); let mut current_gas = params.gas.clone(); @@ -728,12 +728,15 @@ impl Interpreter { let big_id = stack.pop_back(); let id = big_id.low_u64() as usize; let max = id.wrapping_add(32); - let data = params.data.clone().unwrap_or_else(|| vec![]); - let bound = cmp::min(data.len(), max); - if id < bound && big_id < U256::from(data.len()) { - let mut v = data[id..bound].to_vec(); - v.resize(32, 0); - stack.push(U256::from(&v[..])) + if let Some(data) = params.data.as_ref() { + let bound = cmp::min(data.len(), max); + if id < bound && big_id < U256::from(data.len()) { + let mut v = [0u8; 32]; + v[0..bound-id].clone_from_slice(&data[id..bound]); + stack.push(U256::from(&v[..])) + } else { + stack.push(U256::zero()) + } } else { stack.push(U256::zero()) } From 0506a978e9adad5136f9d1a37b0f77fb25778aa1 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 5 Feb 2016 11:26:05 +0100 Subject: [PATCH 10/23] Remove docker. --- install-deps.sh | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/install-deps.sh b/install-deps.sh index 5c42bcf2a..bae8fc9a6 100755 --- a/install-deps.sh +++ b/install-deps.sh @@ -385,7 +385,6 @@ function run_installer() find_gcc find_apt - find_docker } function find_rocksdb() @@ -519,23 +518,6 @@ function run_installer() fi } - function find_docker() - { - depCount=$((depCount+1)) - DOCKER_PATH=`which docker 2>/dev/null` - - if [[ -f $DOCKER_PATH ]] - then - depFound=$((depFound+1)) - check "docker" - echo "$($DOCKER_PATH -v)" - isDocker=true - else - isDocker=false - uncheck "docker is missing" - fi - } - function ubuntu1404_rocksdb_installer() { sudo apt-get update -qq From cd24ffa723832e627c39add1cc9bff282e69a09b Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 5 Feb 2016 11:51:12 +0100 Subject: [PATCH 11/23] Additional info on parity build. --- install-deps.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/install-deps.sh b/install-deps.sh index bae8fc9a6..d03098c42 100755 --- a/install-deps.sh +++ b/install-deps.sh @@ -626,15 +626,23 @@ function run_installer() git submodule init git submodule update - info "Building & testing Parity..." - cargo test --release -p ethcore-util + info "Building..." + cargo build --release - info "Running consensus tests..." - cargo test --release --features ethcore/json-tests -p ethcore + cd .. echo - info "Parity source code is in $(pwd)/parity" - info "Run a client with: ${b}cargo run --release${reset}" + head "Parity is built!" + info "Parity source code is in ${b}$(pwd)/parity${reset}. From that path, you can:" + info "- Run a client & sync the chain with:" + info " ${b}cargo run --release${reset}" + info "- Run a JSONRPC-capable client (for use with netstats) with:" + info " ${b}cargo run --release -- -j --jsonrpc-url 127.0.0.1:8545${reset}" + info "- Run tests with:" + info " ${b}cargo test --release --features ethcore/json-tests -p ethcore${reset}" + info "- Install the client with:" + info " ${b}sudo cp target/release/parity /usr/bin${reset}" + echo } function install_netstats() From 31cf20ffa2a195c17cf7d4ed4d6a881b6f1ac6cd Mon Sep 17 00:00:00 2001 From: arkpar Date: Fri, 5 Feb 2016 12:58:18 +0100 Subject: [PATCH 12/23] New account_db key scheme; snapshot tests --- ethcore/src/account_db.rs | 5 ++++- ethcore/src/state.rs | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/ethcore/src/account_db.rs b/ethcore/src/account_db.rs index 7a07778f0..e7f1b2bad 100644 --- a/ethcore/src/account_db.rs +++ b/ethcore/src/account_db.rs @@ -13,7 +13,10 @@ pub struct AccountDB<'db> { #[inline] fn combine_key<'a>(address: &'a H256, key: &'a H256) -> H256 { - address ^ key + let mut addr_hash = address.sha3(); + // preserve 96 bits of original key for db lookup + addr_hash[0..12].clone_from_slice(&[0u8; 12]); + &addr_hash ^ key } impl<'db> AccountDB<'db> { diff --git a/ethcore/src/state.rs b/ethcore/src/state.rs index 4db171d77..947326e56 100644 --- a/ethcore/src/state.rs +++ b/ethcore/src/state.rs @@ -482,6 +482,38 @@ fn ensure_cached() { assert_eq!(state.root().hex(), "0ce23f3c809de377b008a4a3ee94a0834aac8bec1f86e28ffe4fdb5a15b0c785"); } +#[test] +fn snapshot_basic() { + let mut state_result = get_temp_state(); + let mut state = state_result.reference_mut(); + let a = Address::zero(); + state.snapshot(); + state.add_balance(&a, &U256::from(69u64)); + assert_eq!(state.balance(&a), U256::from(69u64)); + state.clear_snapshot(); + assert_eq!(state.balance(&a), U256::from(69u64)); + state.snapshot(); + state.add_balance(&a, &U256::from(1u64)); + assert_eq!(state.balance(&a), U256::from(70u64)); + state.revert_snapshot(); + assert_eq!(state.balance(&a), U256::from(69u64)); +} + +#[test] +fn snapshot_nested() { + let mut state_result = get_temp_state(); + let mut state = state_result.reference_mut(); + let a = Address::zero(); + state.snapshot(); + state.snapshot(); + state.add_balance(&a, &U256::from(69u64)); + assert_eq!(state.balance(&a), U256::from(69u64)); + state.clear_snapshot(); + assert_eq!(state.balance(&a), U256::from(69u64)); + state.revert_snapshot(); + assert_eq!(state.balance(&a), U256::from(0)); +} + #[test] fn create_empty() { let mut state_result = get_temp_state(); From bfb7d378b382a1a91164d5e5a1a0fe7a6d1d5c1c Mon Sep 17 00:00:00 2001 From: arkpar Date: Fri, 5 Feb 2016 13:06:40 +0100 Subject: [PATCH 13/23] Style --- ethcore/src/state.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ethcore/src/state.rs b/ethcore/src/state.rs index 947326e56..ca170ba91 100644 --- a/ethcore/src/state.rs +++ b/ethcore/src/state.rs @@ -145,7 +145,7 @@ impl State { self.get(a, false).as_ref().map_or(U256::zero(), |account| account.nonce().clone()) } - /// Mutate storage of account `a` so that it is `value` for `key`. + /// Mutate storage of account `address` so that it is `value` for `key`. pub fn storage_at(&self, address: &Address, key: &H256) -> H256 { self.get(address, false).as_ref().map_or(H256::new(), |a|a.storage_at(&AccountDB::new(&self.db, address), key)) } @@ -269,7 +269,7 @@ impl State { fn get(&self, a: &Address, require_code: bool) -> Ref> { let have_key = self.cache.borrow().contains_key(a); if !have_key { - self.insert_cache(a, SecTrieDB::new(&self.db, &self.root).get(&a).map(|rlp| Account::from_rlp(rlp))) + self.insert_cache(a, SecTrieDB::new(&self.db, &self.root).get(&a).map(Account::from_rlp)) } if require_code { if let Some(ref mut account) = self.cache.borrow_mut().get_mut(a).unwrap().as_mut() { @@ -289,7 +289,7 @@ impl State { fn require_or_from Account, G: FnOnce(&mut Account)>(&self, a: &Address, require_code: bool, default: F, not_default: G) -> RefMut { let have_key = self.cache.borrow().contains_key(a); if !have_key { - self.insert_cache(a, SecTrieDB::new(&self.db, &self.root).get(&a).map(|rlp| Account::from_rlp(rlp))) + self.insert_cache(a, SecTrieDB::new(&self.db, &self.root).get(&a).map(Account::from_rlp)) } else { self.note_cache(a); } From 7db500c38d2b0dfb684b5e39432b2e1acf9565e8 Mon Sep 17 00:00:00 2001 From: debris Date: Fri, 5 Feb 2016 13:29:07 +0100 Subject: [PATCH 14/23] rename transactions message_hash -> hash --- ethcore/src/transaction.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ethcore/src/transaction.rs b/ethcore/src/transaction.rs index 355d01e0a..02f1ae879 100644 --- a/ethcore/src/transaction.rs +++ b/ethcore/src/transaction.rs @@ -93,7 +93,7 @@ impl FromJson for SignedTransaction { impl Transaction { /// The message hash of the transaction. - pub fn message_hash(&self) -> H256 { + pub fn hash(&self) -> H256 { let mut stream = RlpStream::new(); self.rlp_append_unsigned_transaction(&mut stream); stream.out().sha3() @@ -101,7 +101,7 @@ impl Transaction { /// Signs the transaction as coming from `sender`. pub fn sign(self, secret: &Secret) -> SignedTransaction { - let sig = ec::sign(secret, &self.message_hash()); + let sig = ec::sign(secret, &self.hash()); let (r, s, v) = sig.unwrap().to_rsv(); SignedTransaction { transaction: self, @@ -245,7 +245,7 @@ impl SignedTransaction { match &mut *sender { &mut Some(ref h) => Ok(h.clone()), sender @ &mut None => { - *sender = Some(From::from(try!(ec::recover(&self.signature(), &self.message_hash())).sha3())); + *sender = Some(From::from(try!(ec::recover(&self.signature(), &self.transaction.hash())).sha3())); Ok(sender.as_ref().unwrap().clone()) } } From bc267f8412ab2c078116de38e1633aac73616c0b Mon Sep 17 00:00:00 2001 From: debris Date: Fri, 5 Feb 2016 13:36:30 +0100 Subject: [PATCH 15/23] prepare for adding licenses --- add_license.sh | 6 ++++++ license_header | 16 ++++++++++++++++ util/src/uint.rs | 11 +++++------ 3 files changed, 27 insertions(+), 6 deletions(-) create mode 100755 add_license.sh create mode 100644 license_header diff --git a/add_license.sh b/add_license.sh new file mode 100755 index 000000000..449633eb4 --- /dev/null +++ b/add_license.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +for f in **/*.rs; do + cat license_header $f > $f.new + mv $f.new $f +done diff --git a/license_header b/license_header new file mode 100644 index 000000000..d4ebdc448 --- /dev/null +++ b/license_header @@ -0,0 +1,16 @@ +// 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 . + diff --git a/util/src/uint.rs b/util/src/uint.rs index 568885c82..4b1fba5e7 100644 --- a/util/src/uint.rs +++ b/util/src/uint.rs @@ -1,5 +1,4 @@ -// taken from Rust Bitcoin Library (https://github.com/apoelstra/rust-bitcoin) -// original author: Andrew Poelstra +// Code derived from original work by Andrew Poelstra // Rust Bitcoin Library // Written in 2014 by @@ -16,10 +15,10 @@ // //! Big unsigned integer types -///! -///! Implementation of a various large-but-fixed sized unsigned integer types. -///! The functions here are designed to be fast. -///! +//! +//! Implementation of a various large-but-fixed sized unsigned integer types. +//! The functions here are designed to be fast. +//! use standard::*; use from_json::*; From c90d64662ac2496fa1f5350faf65837d96ca6b09 Mon Sep 17 00:00:00 2001 From: debris Date: Fri, 5 Feb 2016 13:40:41 +0100 Subject: [PATCH 16/23] added license in every *.rs file --- add_license.sh | 2 +- ethash/src/compute.rs | 16 ++++++++++++++++ ethash/src/lib.rs | 16 ++++++++++++++++ ethash/src/sizes.rs | 16 ++++++++++++++++ ethcore/src/account.rs | 16 ++++++++++++++++ ethcore/src/account_diff.rs | 16 ++++++++++++++++ ethcore/src/action_params.rs | 16 ++++++++++++++++ ethcore/src/basic_types.rs | 16 ++++++++++++++++ ethcore/src/block.rs | 16 ++++++++++++++++ ethcore/src/block_queue.rs | 16 ++++++++++++++++ ethcore/src/blockchain.rs | 16 ++++++++++++++++ ethcore/src/builtin.rs | 16 ++++++++++++++++ ethcore/src/client.rs | 16 ++++++++++++++++ ethcore/src/common.rs | 16 ++++++++++++++++ ethcore/src/engine.rs | 16 ++++++++++++++++ ethcore/src/env_info.rs | 16 ++++++++++++++++ ethcore/src/error.rs | 16 ++++++++++++++++ ethcore/src/ethereum/denominations.rs | 16 ++++++++++++++++ ethcore/src/ethereum/ethash.rs | 16 ++++++++++++++++ ethcore/src/ethereum/mod.rs | 16 ++++++++++++++++ ethcore/src/evm/evm.rs | 16 ++++++++++++++++ ethcore/src/evm/ext.rs | 16 ++++++++++++++++ ethcore/src/evm/factory.rs | 16 ++++++++++++++++ ethcore/src/evm/instructions.rs | 16 ++++++++++++++++ ethcore/src/evm/interpreter.rs | 16 ++++++++++++++++ ethcore/src/evm/jit.rs | 16 ++++++++++++++++ ethcore/src/evm/mod.rs | 16 ++++++++++++++++ ethcore/src/evm/schedule.rs | 16 ++++++++++++++++ ethcore/src/evm/tests.rs | 16 ++++++++++++++++ ethcore/src/executive.rs | 16 ++++++++++++++++ ethcore/src/externalities.rs | 16 ++++++++++++++++ ethcore/src/extras.rs | 16 ++++++++++++++++ ethcore/src/header.rs | 16 ++++++++++++++++ ethcore/src/json_tests/chain.rs | 16 ++++++++++++++++ ethcore/src/json_tests/client.rs | 16 ++++++++++++++++ ethcore/src/json_tests/executive.rs | 16 ++++++++++++++++ ethcore/src/json_tests/homestead_chain.rs | 16 ++++++++++++++++ ethcore/src/json_tests/homestead_state.rs | 16 ++++++++++++++++ ethcore/src/json_tests/mod.rs | 16 ++++++++++++++++ ethcore/src/json_tests/state.rs | 16 ++++++++++++++++ ethcore/src/json_tests/test_common.rs | 16 ++++++++++++++++ ethcore/src/json_tests/transaction.rs | 16 ++++++++++++++++ ethcore/src/lib.rs | 16 ++++++++++++++++ ethcore/src/log_entry.rs | 16 ++++++++++++++++ ethcore/src/null_engine.rs | 16 ++++++++++++++++ ethcore/src/pod_account.rs | 16 ++++++++++++++++ ethcore/src/pod_state.rs | 16 ++++++++++++++++ ethcore/src/receipt.rs | 16 ++++++++++++++++ ethcore/src/service.rs | 16 ++++++++++++++++ ethcore/src/spec.rs | 16 ++++++++++++++++ ethcore/src/state.rs | 16 ++++++++++++++++ ethcore/src/state_diff.rs | 16 ++++++++++++++++ ethcore/src/substate.rs | 16 ++++++++++++++++ ethcore/src/tests/helpers.rs | 16 ++++++++++++++++ ethcore/src/tests/mod.rs | 16 ++++++++++++++++ ethcore/src/transaction.rs | 16 ++++++++++++++++ ethcore/src/verification.rs | 16 ++++++++++++++++ ethcore/src/views.rs | 16 ++++++++++++++++ evmjit/src/lib.rs | 16 ++++++++++++++++ parity/main.rs | 16 ++++++++++++++++ rpc/src/lib.rs | 16 ++++++++++++++++ rpc/src/v1/impls/eth.rs | 16 ++++++++++++++++ rpc/src/v1/impls/mod.rs | 16 ++++++++++++++++ rpc/src/v1/impls/net.rs | 16 ++++++++++++++++ rpc/src/v1/impls/web3.rs | 16 ++++++++++++++++ rpc/src/v1/mod.rs | 16 ++++++++++++++++ rpc/src/v1/traits/eth.rs | 16 ++++++++++++++++ rpc/src/v1/traits/mod.rs | 16 ++++++++++++++++ rpc/src/v1/traits/net.rs | 16 ++++++++++++++++ rpc/src/v1/traits/web3.rs | 16 ++++++++++++++++ rpc/src/v1/types/block.rs | 16 ++++++++++++++++ rpc/src/v1/types/mod.rs | 16 ++++++++++++++++ sync/src/chain.rs | 16 ++++++++++++++++ sync/src/io.rs | 16 ++++++++++++++++ sync/src/lib.rs | 16 ++++++++++++++++ sync/src/range_collection.rs | 16 ++++++++++++++++ sync/src/tests/chain.rs | 16 ++++++++++++++++ sync/src/tests/helpers.rs | 16 ++++++++++++++++ sync/src/tests/mod.rs | 16 ++++++++++++++++ util/benches/rlp.rs | 16 ++++++++++++++++ util/benches/trie.rs | 16 ++++++++++++++++ util/json-tests/src/lib.rs | 16 ++++++++++++++++ util/json-tests/src/rlp.rs | 16 ++++++++++++++++ util/json-tests/src/trie.rs | 16 ++++++++++++++++ util/json-tests/src/util.rs | 16 ++++++++++++++++ util/sha3/build.rs | 16 ++++++++++++++++ util/sha3/src/lib.rs | 16 ++++++++++++++++ util/src/bytes.rs | 16 ++++++++++++++++ util/src/chainfilter.rs | 16 ++++++++++++++++ util/src/common.rs | 16 ++++++++++++++++ util/src/crypto.rs | 16 ++++++++++++++++ util/src/error.rs | 16 ++++++++++++++++ util/src/from_json.rs | 16 ++++++++++++++++ util/src/hash.rs | 16 ++++++++++++++++ util/src/hashdb.rs | 16 ++++++++++++++++ util/src/heapsizeof.rs | 16 ++++++++++++++++ util/src/io/mod.rs | 16 ++++++++++++++++ util/src/io/service.rs | 16 ++++++++++++++++ util/src/io/worker.rs | 16 ++++++++++++++++ util/src/journaldb.rs | 16 ++++++++++++++++ util/src/json_aid.rs | 16 ++++++++++++++++ util/src/lib.rs | 16 ++++++++++++++++ util/src/log.rs | 16 ++++++++++++++++ util/src/math.rs | 16 ++++++++++++++++ util/src/memorydb.rs | 16 ++++++++++++++++ util/src/misc.rs | 16 ++++++++++++++++ util/src/network/connection.rs | 16 ++++++++++++++++ util/src/network/discovery.rs | 16 ++++++++++++++++ util/src/network/error.rs | 16 ++++++++++++++++ util/src/network/handshake.rs | 16 ++++++++++++++++ util/src/network/host.rs | 16 ++++++++++++++++ util/src/network/mod.rs | 16 ++++++++++++++++ util/src/network/node.rs | 16 ++++++++++++++++ util/src/network/service.rs | 16 ++++++++++++++++ util/src/network/session.rs | 16 ++++++++++++++++ util/src/network/stats.rs | 16 ++++++++++++++++ util/src/network/tests.rs | 16 ++++++++++++++++ util/src/nibbleslice.rs | 16 ++++++++++++++++ util/src/overlaydb.rs | 16 ++++++++++++++++ util/src/rlp/bytes.rs | 16 ++++++++++++++++ util/src/rlp/mod.rs | 16 ++++++++++++++++ util/src/rlp/rlperrors.rs | 16 ++++++++++++++++ util/src/rlp/rlpin.rs | 16 ++++++++++++++++ util/src/rlp/rlpstream.rs | 16 ++++++++++++++++ util/src/rlp/rlptraits.rs | 16 ++++++++++++++++ util/src/rlp/tests.rs | 16 ++++++++++++++++ util/src/rlp/untrusted_rlp.rs | 16 ++++++++++++++++ util/src/semantic_version.rs | 16 ++++++++++++++++ util/src/sha3.rs | 16 ++++++++++++++++ util/src/squeeze.rs | 16 ++++++++++++++++ util/src/standard.rs | 16 ++++++++++++++++ util/src/trie/journal.rs | 16 ++++++++++++++++ util/src/trie/mod.rs | 16 ++++++++++++++++ util/src/trie/node.rs | 16 ++++++++++++++++ util/src/trie/sectriedb.rs | 16 ++++++++++++++++ util/src/trie/sectriedbmut.rs | 16 ++++++++++++++++ util/src/trie/standardmap.rs | 16 ++++++++++++++++ util/src/trie/triedb.rs | 16 ++++++++++++++++ util/src/trie/triedbmut.rs | 16 ++++++++++++++++ util/src/trie/trietraits.rs | 16 ++++++++++++++++ util/src/triehash.rs | 16 ++++++++++++++++ util/src/uint.rs | 16 ++++++++++++++++ util/src/vector.rs | 16 ++++++++++++++++ 143 files changed, 2273 insertions(+), 1 deletion(-) diff --git a/add_license.sh b/add_license.sh index 449633eb4..1d916f427 100755 --- a/add_license.sh +++ b/add_license.sh @@ -1,6 +1,6 @@ #!/bin/sh -for f in **/*.rs; do +for f in $(find . -name '*.rs'); do cat license_header $f > $f.new mv $f.new $f done diff --git a/ethash/src/compute.rs b/ethash/src/compute.rs index 56b120d1d..8dc2456c0 100644 --- a/ethash/src/compute.rs +++ b/ethash/src/compute.rs @@ -1,3 +1,19 @@ +// 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 . + //! Ethash implementation //! See https://github.com/ethereum/wiki/wiki/Ethash diff --git a/ethash/src/lib.rs b/ethash/src/lib.rs index 17853c985..4c6b8639f 100644 --- a/ethash/src/lib.rs +++ b/ethash/src/lib.rs @@ -1,3 +1,19 @@ +// 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 . + //! Ethash implementation //! See https://github.com/ethereum/wiki/wiki/Ethash extern crate sha3; diff --git a/ethash/src/sizes.rs b/ethash/src/sizes.rs index 40840eb84..b3a3c0d22 100644 --- a/ethash/src/sizes.rs +++ b/ethash/src/sizes.rs @@ -1,3 +1,19 @@ +// 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 . + // 2048 Epochs (~20 years) worth of tabulated DAG sizes // Generated with the following Mathematica Code: diff --git a/ethcore/src/account.rs b/ethcore/src/account.rs index 63f86b171..7355646a9 100644 --- a/ethcore/src/account.rs +++ b/ethcore/src/account.rs @@ -1,3 +1,19 @@ +// 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 . + //! Single account in the system. use util::*; diff --git a/ethcore/src/account_diff.rs b/ethcore/src/account_diff.rs index 86faf40de..6c7e6573e 100644 --- a/ethcore/src/account_diff.rs +++ b/ethcore/src/account_diff.rs @@ -1,3 +1,19 @@ +// 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 . + //! Diff between two accounts. use util::*; diff --git a/ethcore/src/action_params.rs b/ethcore/src/action_params.rs index a56e64f4d..9e2d72c73 100644 --- a/ethcore/src/action_params.rs +++ b/ethcore/src/action_params.rs @@ -1,3 +1,19 @@ +// 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 . + //! Evm input params. use util::hash::*; use util::uint::*; diff --git a/ethcore/src/basic_types.rs b/ethcore/src/basic_types.rs index 49a5c9556..51e05500c 100644 --- a/ethcore/src/basic_types.rs +++ b/ethcore/src/basic_types.rs @@ -1,3 +1,19 @@ +// 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 . + //! Ethcore basic typenames. use util::*; diff --git a/ethcore/src/block.rs b/ethcore/src/block.rs index a2de89d13..95a7b29af 100644 --- a/ethcore/src/block.rs +++ b/ethcore/src/block.rs @@ -1,3 +1,19 @@ +// 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 . + //! Blockchain block. #![allow(ptr_arg)] // Because of &LastHashes -> &Vec<_> diff --git a/ethcore/src/block_queue.rs b/ethcore/src/block_queue.rs index e14f2a06a..2e3728aee 100644 --- a/ethcore/src/block_queue.rs +++ b/ethcore/src/block_queue.rs @@ -1,3 +1,19 @@ +// 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 . + //! A queue of blocks. Sits between network or other I/O and the BlockChain. //! Sorts them ready for blockchain insertion. use std::thread::{JoinHandle, self}; diff --git a/ethcore/src/blockchain.rs b/ethcore/src/blockchain.rs index e2ed54c19..2b8e955a4 100644 --- a/ethcore/src/blockchain.rs +++ b/ethcore/src/blockchain.rs @@ -1,3 +1,19 @@ +// 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 . + //! Blockchain database. use util::*; diff --git a/ethcore/src/builtin.rs b/ethcore/src/builtin.rs index 297f734b5..5589a2525 100644 --- a/ethcore/src/builtin.rs +++ b/ethcore/src/builtin.rs @@ -1,3 +1,19 @@ +// 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 . + use util::*; use crypto::sha2::Sha256; use crypto::ripemd160::Ripemd160; diff --git a/ethcore/src/client.rs b/ethcore/src/client.rs index 03c03ab49..6feb9a2e4 100644 --- a/ethcore/src/client.rs +++ b/ethcore/src/client.rs @@ -1,3 +1,19 @@ +// 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 . + //! Blockchain database client. use util::*; diff --git a/ethcore/src/common.rs b/ethcore/src/common.rs index b699bd4c6..5235e9f58 100644 --- a/ethcore/src/common.rs +++ b/ethcore/src/common.rs @@ -1,3 +1,19 @@ +// 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 . + pub use util::*; pub use basic_types::*; pub use error::*; diff --git a/ethcore/src/engine.rs b/ethcore/src/engine.rs index 7017989e7..4653fcd9b 100644 --- a/ethcore/src/engine.rs +++ b/ethcore/src/engine.rs @@ -1,3 +1,19 @@ +// 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 . + use common::*; use block::ExecutedBlock; use spec::Spec; diff --git a/ethcore/src/env_info.rs b/ethcore/src/env_info.rs index 7c0516d2a..02fc5188c 100644 --- a/ethcore/src/env_info.rs +++ b/ethcore/src/env_info.rs @@ -1,3 +1,19 @@ +// 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 . + use util::*; use header::BlockNumber; diff --git a/ethcore/src/error.rs b/ethcore/src/error.rs index 2d6753e95..d441929c5 100644 --- a/ethcore/src/error.rs +++ b/ethcore/src/error.rs @@ -1,3 +1,19 @@ +// 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 . + //! General error types for use in ethcore. use util::*; diff --git a/ethcore/src/ethereum/denominations.rs b/ethcore/src/ethereum/denominations.rs index 2ab66431d..a8ac2c44c 100644 --- a/ethcore/src/ethereum/denominations.rs +++ b/ethcore/src/ethereum/denominations.rs @@ -1,3 +1,19 @@ +// 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 . + use util::*; #[inline] diff --git a/ethcore/src/ethereum/ethash.rs b/ethcore/src/ethereum/ethash.rs index e9aedc128..30e85f75c 100644 --- a/ethcore/src/ethereum/ethash.rs +++ b/ethcore/src/ethereum/ethash.rs @@ -1,3 +1,19 @@ +// 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 . + extern crate ethash; use self::ethash::{quick_get_difficulty, EthashManager, H256 as EH256}; diff --git a/ethcore/src/ethereum/mod.rs b/ethcore/src/ethereum/mod.rs index ec6cfe103..8c7787dbf 100644 --- a/ethcore/src/ethereum/mod.rs +++ b/ethcore/src/ethereum/mod.rs @@ -1,3 +1,19 @@ +// 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 . + //! Ethereum protocol module. //! //! Contains all Ethereum network specific stuff, such as denominations and diff --git a/ethcore/src/evm/evm.rs b/ethcore/src/evm/evm.rs index f011f67a4..28eb96f44 100644 --- a/ethcore/src/evm/evm.rs +++ b/ethcore/src/evm/evm.rs @@ -1,3 +1,19 @@ +// 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 . + //! Evm interface. use common::*; diff --git a/ethcore/src/evm/ext.rs b/ethcore/src/evm/ext.rs index 83f093bcf..ae4cff3be 100644 --- a/ethcore/src/evm/ext.rs +++ b/ethcore/src/evm/ext.rs @@ -1,3 +1,19 @@ +// 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 . + //! Interface for Evm externalities. use common::Bytes; diff --git a/ethcore/src/evm/factory.rs b/ethcore/src/evm/factory.rs index bd9315e7f..f1be0e427 100644 --- a/ethcore/src/evm/factory.rs +++ b/ethcore/src/evm/factory.rs @@ -1,3 +1,19 @@ +// 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 . + //! Evm factory. //! //! TODO: consider spliting it into two separate files. diff --git a/ethcore/src/evm/instructions.rs b/ethcore/src/evm/instructions.rs index 976c3c603..623868618 100644 --- a/ethcore/src/evm/instructions.rs +++ b/ethcore/src/evm/instructions.rs @@ -1,3 +1,19 @@ +// 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 . + //! VM Instructions list and utility functions pub type Instruction = u8; diff --git a/ethcore/src/evm/interpreter.rs b/ethcore/src/evm/interpreter.rs index 6516d9946..4a6dc3314 100644 --- a/ethcore/src/evm/interpreter.rs +++ b/ethcore/src/evm/interpreter.rs @@ -1,3 +1,19 @@ +// 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 . + ///! Rust VM implementation use common::*; diff --git a/ethcore/src/evm/jit.rs b/ethcore/src/evm/jit.rs index 6a6d7e5ff..dc407d0c1 100644 --- a/ethcore/src/evm/jit.rs +++ b/ethcore/src/evm/jit.rs @@ -1,3 +1,19 @@ +// 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 . + //! Just in time compiler execution environment. use common::*; use evmjit; diff --git a/ethcore/src/evm/mod.rs b/ethcore/src/evm/mod.rs index 2ed9a1146..3e1dc5ed7 100644 --- a/ethcore/src/evm/mod.rs +++ b/ethcore/src/evm/mod.rs @@ -1,3 +1,19 @@ +// 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 . + //! Ethereum virtual machine. pub mod ext; diff --git a/ethcore/src/evm/schedule.rs b/ethcore/src/evm/schedule.rs index d46b7ff11..f82157239 100644 --- a/ethcore/src/evm/schedule.rs +++ b/ethcore/src/evm/schedule.rs @@ -1,3 +1,19 @@ +// 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 . + //! Cost schedule and other parameterisations for the EVM. /// Definition of the cost schedule and other parameterisations for the EVM. diff --git a/ethcore/src/evm/tests.rs b/ethcore/src/evm/tests.rs index 7b8e29d23..d0daf33e7 100644 --- a/ethcore/src/evm/tests.rs +++ b/ethcore/src/evm/tests.rs @@ -1,3 +1,19 @@ +// 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 . + use common::*; use evm; use evm::{Ext, Schedule, Factory, VMType, ContractCreateResult, MessageCallResult}; diff --git a/ethcore/src/executive.rs b/ethcore/src/executive.rs index b67b71306..ad1ab06ac 100644 --- a/ethcore/src/executive.rs +++ b/ethcore/src/executive.rs @@ -1,3 +1,19 @@ +// 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 . + //! Transaction Execution environment. use common::*; use state::*; diff --git a/ethcore/src/externalities.rs b/ethcore/src/externalities.rs index 6a874330c..ad2f18f11 100644 --- a/ethcore/src/externalities.rs +++ b/ethcore/src/externalities.rs @@ -1,3 +1,19 @@ +// 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 . + //! Transaction Execution environment. use common::*; use state::*; diff --git a/ethcore/src/extras.rs b/ethcore/src/extras.rs index 4c54c6b27..f29925483 100644 --- a/ethcore/src/extras.rs +++ b/ethcore/src/extras.rs @@ -1,3 +1,19 @@ +// 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 . + //! Blockchain DB extras. use util::*; diff --git a/ethcore/src/header.rs b/ethcore/src/header.rs index b188a6bcf..6ee682544 100644 --- a/ethcore/src/header.rs +++ b/ethcore/src/header.rs @@ -1,3 +1,19 @@ +// 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 . + //! Block header. use util::*; diff --git a/ethcore/src/json_tests/chain.rs b/ethcore/src/json_tests/chain.rs index 6ee7e9f9e..6a9f84073 100644 --- a/ethcore/src/json_tests/chain.rs +++ b/ethcore/src/json_tests/chain.rs @@ -1,3 +1,19 @@ +// 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 . + use super::test_common::*; use client::{BlockChainClient,Client}; use pod_state::*; diff --git a/ethcore/src/json_tests/client.rs b/ethcore/src/json_tests/client.rs index 1d09ed079..2d3166c74 100644 --- a/ethcore/src/json_tests/client.rs +++ b/ethcore/src/json_tests/client.rs @@ -1,3 +1,19 @@ +// 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 . + use client::{BlockChainClient,Client}; use super::test_common::*; use tests::helpers::*; diff --git a/ethcore/src/json_tests/executive.rs b/ethcore/src/json_tests/executive.rs index 4a56007ad..7ac60e6b4 100644 --- a/ethcore/src/json_tests/executive.rs +++ b/ethcore/src/json_tests/executive.rs @@ -1,3 +1,19 @@ +// 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 . + use super::test_common::*; use state::*; use executive::*; diff --git a/ethcore/src/json_tests/homestead_chain.rs b/ethcore/src/json_tests/homestead_chain.rs index 1962da1bc..7756840bc 100644 --- a/ethcore/src/json_tests/homestead_chain.rs +++ b/ethcore/src/json_tests/homestead_chain.rs @@ -1,3 +1,19 @@ +// 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 . + use super::test_common::*; use super::chain::json_chain_test; use tests::helpers::*; diff --git a/ethcore/src/json_tests/homestead_state.rs b/ethcore/src/json_tests/homestead_state.rs index 474d56f8a..0b611dad7 100644 --- a/ethcore/src/json_tests/homestead_state.rs +++ b/ethcore/src/json_tests/homestead_state.rs @@ -1,3 +1,19 @@ +// 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 . + use super::test_common::*; use tests::helpers::*; use super::state::json_chain_test; diff --git a/ethcore/src/json_tests/mod.rs b/ethcore/src/json_tests/mod.rs index b5d6779bc..1cae0fa1d 100644 --- a/ethcore/src/json_tests/mod.rs +++ b/ethcore/src/json_tests/mod.rs @@ -1,3 +1,19 @@ +// 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 . + #[macro_use] mod test_common; diff --git a/ethcore/src/json_tests/state.rs b/ethcore/src/json_tests/state.rs index fa8da9329..0b439c93d 100644 --- a/ethcore/src/json_tests/state.rs +++ b/ethcore/src/json_tests/state.rs @@ -1,3 +1,19 @@ +// 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 . + use super::test_common::*; use tests::helpers::*; use pod_state::*; diff --git a/ethcore/src/json_tests/test_common.rs b/ethcore/src/json_tests/test_common.rs index 87e7b979e..7f7051bf0 100644 --- a/ethcore/src/json_tests/test_common.rs +++ b/ethcore/src/json_tests/test_common.rs @@ -1,3 +1,19 @@ +// 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 . + pub use common::*; macro_rules! test { diff --git a/ethcore/src/json_tests/transaction.rs b/ethcore/src/json_tests/transaction.rs index 91f7d96e5..78d579fc6 100644 --- a/ethcore/src/json_tests/transaction.rs +++ b/ethcore/src/json_tests/transaction.rs @@ -1,3 +1,19 @@ +// 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 . + use super::test_common::*; use evm; diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs index 540b5ea40..521c80157 100644 --- a/ethcore/src/lib.rs +++ b/ethcore/src/lib.rs @@ -1,3 +1,19 @@ +// 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 . + #![warn(missing_docs)] #![feature(cell_extras)] #![feature(augmented_assignments)] diff --git a/ethcore/src/log_entry.rs b/ethcore/src/log_entry.rs index 46faad797..ee73b1ad1 100644 --- a/ethcore/src/log_entry.rs +++ b/ethcore/src/log_entry.rs @@ -1,3 +1,19 @@ +// 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 . + use util::*; use basic_types::LogBloom; diff --git a/ethcore/src/null_engine.rs b/ethcore/src/null_engine.rs index 3c829606c..af7255617 100644 --- a/ethcore/src/null_engine.rs +++ b/ethcore/src/null_engine.rs @@ -1,3 +1,19 @@ +// 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 . + use engine::Engine; use spec::Spec; use evm::Schedule; diff --git a/ethcore/src/pod_account.rs b/ethcore/src/pod_account.rs index 7bc886617..503790444 100644 --- a/ethcore/src/pod_account.rs +++ b/ethcore/src/pod_account.rs @@ -1,3 +1,19 @@ +// 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 . + use util::*; use account::*; diff --git a/ethcore/src/pod_state.rs b/ethcore/src/pod_state.rs index 69eca17b6..b873249ac 100644 --- a/ethcore/src/pod_state.rs +++ b/ethcore/src/pod_state.rs @@ -1,3 +1,19 @@ +// 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 . + use util::*; use pod_account::*; diff --git a/ethcore/src/receipt.rs b/ethcore/src/receipt.rs index 3888a6abc..5fc1a318b 100644 --- a/ethcore/src/receipt.rs +++ b/ethcore/src/receipt.rs @@ -1,3 +1,19 @@ +// 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 . + //! Receipt use util::*; diff --git a/ethcore/src/service.rs b/ethcore/src/service.rs index fa530df70..90fe0a6b5 100644 --- a/ethcore/src/service.rs +++ b/ethcore/src/service.rs @@ -1,3 +1,19 @@ +// 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 . + //! Creates and registers client and network services. use util::*; diff --git a/ethcore/src/spec.rs b/ethcore/src/spec.rs index 50bbbb633..dc4521ced 100644 --- a/ethcore/src/spec.rs +++ b/ethcore/src/spec.rs @@ -1,3 +1,19 @@ +// 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 . + //! Parameters for a block chain. use common::*; diff --git a/ethcore/src/state.rs b/ethcore/src/state.rs index ed7d29813..1e8fd6eb3 100644 --- a/ethcore/src/state.rs +++ b/ethcore/src/state.rs @@ -1,3 +1,19 @@ +// 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 . + use common::*; use engine::Engine; use executive::Executive; diff --git a/ethcore/src/state_diff.rs b/ethcore/src/state_diff.rs index ba9e6e816..2f3a0c8c8 100644 --- a/ethcore/src/state_diff.rs +++ b/ethcore/src/state_diff.rs @@ -1,3 +1,19 @@ +// 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 . + use util::*; #[cfg(test)] use pod_state::*; diff --git a/ethcore/src/substate.rs b/ethcore/src/substate.rs index a5c353351..f42ea38fd 100644 --- a/ethcore/src/substate.rs +++ b/ethcore/src/substate.rs @@ -1,3 +1,19 @@ +// 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 . + //! Execution environment substate. use common::*; diff --git a/ethcore/src/tests/helpers.rs b/ethcore/src/tests/helpers.rs index 04d47cbd3..f47865b83 100644 --- a/ethcore/src/tests/helpers.rs +++ b/ethcore/src/tests/helpers.rs @@ -1,3 +1,19 @@ +// 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 . + #[cfg(feature = "json-tests")] use client::{BlockChainClient, Client}; use std::env; diff --git a/ethcore/src/tests/mod.rs b/ethcore/src/tests/mod.rs index 1630fabcd..a4e13730a 100644 --- a/ethcore/src/tests/mod.rs +++ b/ethcore/src/tests/mod.rs @@ -1 +1,17 @@ +// 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 . + pub mod helpers; diff --git a/ethcore/src/transaction.rs b/ethcore/src/transaction.rs index a5e70b0d6..294a7cdff 100644 --- a/ethcore/src/transaction.rs +++ b/ethcore/src/transaction.rs @@ -1,3 +1,19 @@ +// 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 . + //! Transaction data structure. use util::*; diff --git a/ethcore/src/verification.rs b/ethcore/src/verification.rs index efed43b84..d6426f49b 100644 --- a/ethcore/src/verification.rs +++ b/ethcore/src/verification.rs @@ -1,3 +1,19 @@ +// 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 . + /// Block and transaction verification functions /// /// Block verification is done in 3 steps diff --git a/ethcore/src/views.rs b/ethcore/src/views.rs index e1c704625..26b52e5c5 100644 --- a/ethcore/src/views.rs +++ b/ethcore/src/views.rs @@ -1,3 +1,19 @@ +// 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 . + //! Block oriented views onto rlp. use util::*; use header::*; diff --git a/evmjit/src/lib.rs b/evmjit/src/lib.rs index 9ee62863d..d916906b6 100644 --- a/evmjit/src/lib.rs +++ b/evmjit/src/lib.rs @@ -1,3 +1,19 @@ +// 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 . + //! Bare rust wrapper around evmjit. //! //! Requires latest version of Ethereum EVM JIT. https://github.com/debris/evmjit diff --git a/parity/main.rs b/parity/main.rs index bc492277a..7d0a08855 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -1,3 +1,19 @@ +// 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 . + //! Ethcore client application. #![warn(missing_docs)] diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index 985ba4674..bf82a64a0 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -1,3 +1,19 @@ +// 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 . + //! Ethcore rpc. #![warn(missing_docs)] #![feature(custom_derive, custom_attribute, plugin)] diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 46718601b..59d6c4d0e 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -1,3 +1,19 @@ +// 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 . + //! Eth rpc implementation. use std::sync::Arc; use jsonrpc_core::*; diff --git a/rpc/src/v1/impls/mod.rs b/rpc/src/v1/impls/mod.rs index f10d613d0..bc8b436fd 100644 --- a/rpc/src/v1/impls/mod.rs +++ b/rpc/src/v1/impls/mod.rs @@ -1,3 +1,19 @@ +// 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 . + //! Ethereum rpc interface implementation. mod web3; mod eth; diff --git a/rpc/src/v1/impls/net.rs b/rpc/src/v1/impls/net.rs index fe4f22f63..b36042dba 100644 --- a/rpc/src/v1/impls/net.rs +++ b/rpc/src/v1/impls/net.rs @@ -1,3 +1,19 @@ +// 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 . + //! Net rpc implementation. use std::sync::Arc; use jsonrpc_core::*; diff --git a/rpc/src/v1/impls/web3.rs b/rpc/src/v1/impls/web3.rs index c4f16fe9d..f10150a30 100644 --- a/rpc/src/v1/impls/web3.rs +++ b/rpc/src/v1/impls/web3.rs @@ -1,3 +1,19 @@ +// 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 . + //! Web3 rpc implementation. use target_info::Target; use jsonrpc_core::*; diff --git a/rpc/src/v1/mod.rs b/rpc/src/v1/mod.rs index a7da1a441..11a5291b5 100644 --- a/rpc/src/v1/mod.rs +++ b/rpc/src/v1/mod.rs @@ -1,3 +1,19 @@ +// 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 . + //! Ethcore rpc v1. //! //! Compliant with ethereum rpc. diff --git a/rpc/src/v1/traits/eth.rs b/rpc/src/v1/traits/eth.rs index 3dcdfdf05..9ee3926da 100644 --- a/rpc/src/v1/traits/eth.rs +++ b/rpc/src/v1/traits/eth.rs @@ -1,3 +1,19 @@ +// 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 . + //! Eth rpc interface. use std::sync::Arc; use jsonrpc_core::*; diff --git a/rpc/src/v1/traits/mod.rs b/rpc/src/v1/traits/mod.rs index 70c825175..c9af6dac3 100644 --- a/rpc/src/v1/traits/mod.rs +++ b/rpc/src/v1/traits/mod.rs @@ -1,3 +1,19 @@ +// 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 . + //! Ethereum rpc interfaces. macro_rules! rpc_unimplemented { diff --git a/rpc/src/v1/traits/net.rs b/rpc/src/v1/traits/net.rs index 84877cab7..732d6efb2 100644 --- a/rpc/src/v1/traits/net.rs +++ b/rpc/src/v1/traits/net.rs @@ -1,3 +1,19 @@ +// 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 . + //! Net rpc interface. use std::sync::Arc; use jsonrpc_core::*; diff --git a/rpc/src/v1/traits/web3.rs b/rpc/src/v1/traits/web3.rs index 118316155..bb8653504 100644 --- a/rpc/src/v1/traits/web3.rs +++ b/rpc/src/v1/traits/web3.rs @@ -1,3 +1,19 @@ +// 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 . + //! Web3 rpc interface. use std::sync::Arc; use jsonrpc_core::*; diff --git a/rpc/src/v1/types/block.rs b/rpc/src/v1/types/block.rs index 740cf3e09..92ff5c8a6 100644 --- a/rpc/src/v1/types/block.rs +++ b/rpc/src/v1/types/block.rs @@ -1,3 +1,19 @@ +// 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 . + use util::hash::*; use util::uint::*; diff --git a/rpc/src/v1/types/mod.rs b/rpc/src/v1/types/mod.rs index 7be32e84d..ba8e456ad 100644 --- a/rpc/src/v1/types/mod.rs +++ b/rpc/src/v1/types/mod.rs @@ -1,3 +1,19 @@ +// 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 . + mod block; pub use self::block::Block; diff --git a/sync/src/chain.rs b/sync/src/chain.rs index e143f20b1..3d5ff91e9 100644 --- a/sync/src/chain.rs +++ b/sync/src/chain.rs @@ -1,3 +1,19 @@ +// 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 . + /// /// BlockChain synchronization strategy. /// Syncs to peers and keeps up to date. diff --git a/sync/src/io.rs b/sync/src/io.rs index 8f415f582..00ee49be4 100644 --- a/sync/src/io.rs +++ b/sync/src/io.rs @@ -1,3 +1,19 @@ +// 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 . + use ethcore::client::BlockChainClient; use util::{NetworkContext, PeerId, PacketId,}; use util::error::UtilError; diff --git a/sync/src/lib.rs b/sync/src/lib.rs index 1523a8a9f..f8ccf0635 100644 --- a/sync/src/lib.rs +++ b/sync/src/lib.rs @@ -1,3 +1,19 @@ +// 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 . + #![warn(missing_docs)] #![feature(plugin)] #![plugin(clippy)] diff --git a/sync/src/range_collection.rs b/sync/src/range_collection.rs index b8186e5a5..c70bac4ca 100644 --- a/sync/src/range_collection.rs +++ b/sync/src/range_collection.rs @@ -1,3 +1,19 @@ +// 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 . + /// This module defines a trait for a collection of ranged values and an implementation /// for this trait over sorted vector. diff --git a/sync/src/tests/chain.rs b/sync/src/tests/chain.rs index fcd9b6a7b..21922851c 100644 --- a/sync/src/tests/chain.rs +++ b/sync/src/tests/chain.rs @@ -1,3 +1,19 @@ +// 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 . + use util::*; use ethcore::client::{BlockChainClient}; use io::SyncIo; diff --git a/sync/src/tests/helpers.rs b/sync/src/tests/helpers.rs index c4a4d80cb..a5a60d62d 100644 --- a/sync/src/tests/helpers.rs +++ b/sync/src/tests/helpers.rs @@ -1,3 +1,19 @@ +// 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 . + use util::*; use ethcore::client::{BlockChainClient, BlockStatus, TreeRoute, BlockChainInfo}; use ethcore::block_queue::BlockQueueInfo; diff --git a/sync/src/tests/mod.rs b/sync/src/tests/mod.rs index a5fa44b04..496c6ab33 100644 --- a/sync/src/tests/mod.rs +++ b/sync/src/tests/mod.rs @@ -1,2 +1,18 @@ +// 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 . + pub mod helpers; mod chain; \ No newline at end of file diff --git a/util/benches/rlp.rs b/util/benches/rlp.rs index e322143f7..e94cb3635 100644 --- a/util/benches/rlp.rs +++ b/util/benches/rlp.rs @@ -1,3 +1,19 @@ +// 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 . + //! benchmarking for rlp //! should be started with: //! ```bash diff --git a/util/benches/trie.rs b/util/benches/trie.rs index 663663fe3..2c07dbc08 100644 --- a/util/benches/trie.rs +++ b/util/benches/trie.rs @@ -1,3 +1,19 @@ +// 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 . + #![feature(test)] extern crate test; diff --git a/util/json-tests/src/lib.rs b/util/json-tests/src/lib.rs index 0fb1b091a..e250d5dfe 100644 --- a/util/json-tests/src/lib.rs +++ b/util/json-tests/src/lib.rs @@ -1,3 +1,19 @@ +// 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 . + extern crate rustc_serialize; extern crate glob; diff --git a/util/json-tests/src/rlp.rs b/util/json-tests/src/rlp.rs index bf6131b5b..0b8e4c904 100644 --- a/util/json-tests/src/rlp.rs +++ b/util/json-tests/src/rlp.rs @@ -1,3 +1,19 @@ +// 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 . + //! json rlp tests use rustc_serialize::*; use super::{JsonTest, JsonLoader}; diff --git a/util/json-tests/src/trie.rs b/util/json-tests/src/trie.rs index bc65e9db9..a060167af 100644 --- a/util/json-tests/src/trie.rs +++ b/util/json-tests/src/trie.rs @@ -1,3 +1,19 @@ +// 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 . + //! json trie tests use std::collections::HashMap; use rustc_serialize::*; diff --git a/util/json-tests/src/util.rs b/util/json-tests/src/util.rs index f9d1e4eab..f8beb269a 100644 --- a/util/json-tests/src/util.rs +++ b/util/json-tests/src/util.rs @@ -1,3 +1,19 @@ +// 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 . + use rustc_serialize::hex::FromHex; pub fn hex_or_string(s: &str) -> Vec { diff --git a/util/sha3/build.rs b/util/sha3/build.rs index 706da0907..bbe16d720 100644 --- a/util/sha3/build.rs +++ b/util/sha3/build.rs @@ -1,3 +1,19 @@ +// 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 . + // build.rs // Bring in a dependency on an externally maintained `gcc` package which manages diff --git a/util/sha3/src/lib.rs b/util/sha3/src/lib.rs index de2bf6e3e..cd1d2125e 100644 --- a/util/sha3/src/lib.rs +++ b/util/sha3/src/lib.rs @@ -1,3 +1,19 @@ +// 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 . + extern { pub fn sha3_256(out: *mut u8, outlen: usize, input: *const u8, inputlen: usize) -> i32; pub fn sha3_512(out: *mut u8, outlen: usize, input: *const u8, inputlen: usize) -> i32; diff --git a/util/src/bytes.rs b/util/src/bytes.rs index f6c83081d..5ad2660e8 100644 --- a/util/src/bytes.rs +++ b/util/src/bytes.rs @@ -1,3 +1,19 @@ +// 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 . + //! Unified interfaces for bytes operations on basic types //! //! # Examples diff --git a/util/src/chainfilter.rs b/util/src/chainfilter.rs index ad7f965dc..20462c698 100644 --- a/util/src/chainfilter.rs +++ b/util/src/chainfilter.rs @@ -1,3 +1,19 @@ +// 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 . + //! Multilevel blockchain bloom filter. //! //! ``` diff --git a/util/src/common.rs b/util/src/common.rs index bfc883a6b..0816b72e4 100644 --- a/util/src/common.rs +++ b/util/src/common.rs @@ -1,3 +1,19 @@ +// 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 . + //! Utils common types and macros global reexport. pub use standard::*; diff --git a/util/src/crypto.rs b/util/src/crypto.rs index 0f147da1f..405646887 100644 --- a/util/src/crypto.rs +++ b/util/src/crypto.rs @@ -1,3 +1,19 @@ +// 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 . + //! Ethcore crypto. use hash::*; diff --git a/util/src/error.rs b/util/src/error.rs index 4d2e0943b..465174b4e 100644 --- a/util/src/error.rs +++ b/util/src/error.rs @@ -1,3 +1,19 @@ +// 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 . + //! General error types for use in ethcore. use rustc_serialize::hex::FromHexError; diff --git a/util/src/from_json.rs b/util/src/from_json.rs index 63469ea61..7d977afc9 100644 --- a/util/src/from_json.rs +++ b/util/src/from_json.rs @@ -1,3 +1,19 @@ +// 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 . + //! Coversion from json. use standard::*; diff --git a/util/src/hash.rs b/util/src/hash.rs index 68611f7b4..75c39720e 100644 --- a/util/src/hash.rs +++ b/util/src/hash.rs @@ -1,3 +1,19 @@ +// 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 . + //! General hash types, a fixed-size raw-data type used as the output of hash functions. use standard::*; diff --git a/util/src/hashdb.rs b/util/src/hashdb.rs index 0eebe9d9e..4d8cbaba1 100644 --- a/util/src/hashdb.rs +++ b/util/src/hashdb.rs @@ -1,3 +1,19 @@ +// 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 . + //! Database of byte-slices keyed to their Keccak hash. use hash::*; use bytes::*; diff --git a/util/src/heapsizeof.rs b/util/src/heapsizeof.rs index 8dcc53728..d7c8124cd 100644 --- a/util/src/heapsizeof.rs +++ b/util/src/heapsizeof.rs @@ -1,3 +1,19 @@ +// 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 . + //! Calculates heapsize of util types. use uint::*; diff --git a/util/src/io/mod.rs b/util/src/io/mod.rs index e421416ee..4f16efd30 100644 --- a/util/src/io/mod.rs +++ b/util/src/io/mod.rs @@ -1,3 +1,19 @@ +// 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 . + //! General IO module. //! //! Example usage for creating a network service and adding an IO handler: diff --git a/util/src/io/service.rs b/util/src/io/service.rs index 9a3187f8e..71b2520ed 100644 --- a/util/src/io/service.rs +++ b/util/src/io/service.rs @@ -1,3 +1,19 @@ +// 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 . + use std::sync::*; use std::thread::{self, JoinHandle}; use std::collections::HashMap; diff --git a/util/src/io/worker.rs b/util/src/io/worker.rs index 33eff42c5..fa8a0fa2c 100644 --- a/util/src/io/worker.rs +++ b/util/src/io/worker.rs @@ -1,3 +1,19 @@ +// 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 . + use std::sync::*; use std::mem; use std::thread::{JoinHandle, self}; diff --git a/util/src/journaldb.rs b/util/src/journaldb.rs index e30b8947c..df747bfd8 100644 --- a/util/src/journaldb.rs +++ b/util/src/journaldb.rs @@ -1,3 +1,19 @@ +// 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 . + //! Disk-backed HashDB implementation. use common::*; diff --git a/util/src/json_aid.rs b/util/src/json_aid.rs index 7ca75a34f..6aed7f09c 100644 --- a/util/src/json_aid.rs +++ b/util/src/json_aid.rs @@ -1,3 +1,19 @@ +// 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 . + use common::*; /// Remove the `"0x"`, if present, from the left of `s`, returning the remaining slice. diff --git a/util/src/lib.rs b/util/src/lib.rs index c8b7f77b9..16a25f538 100644 --- a/util/src/lib.rs +++ b/util/src/lib.rs @@ -1,3 +1,19 @@ +// 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 . + #![warn(missing_docs)] #![feature(op_assign_traits)] #![feature(augmented_assignments)] diff --git a/util/src/log.rs b/util/src/log.rs index 619d4af3a..72b97caf5 100644 --- a/util/src/log.rs +++ b/util/src/log.rs @@ -1,3 +1,19 @@ +// 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 . + //! Common log helper functions use std::env; diff --git a/util/src/math.rs b/util/src/math.rs index 71533ec26..afb7611e7 100644 --- a/util/src/math.rs +++ b/util/src/math.rs @@ -1,3 +1,19 @@ +// 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 . + //! Common math functions. /// Returns log2. diff --git a/util/src/memorydb.rs b/util/src/memorydb.rs index 71addda3c..680a6e1d0 100644 --- a/util/src/memorydb.rs +++ b/util/src/memorydb.rs @@ -1,3 +1,19 @@ +// 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 . + //! Reference-counted memory-based HashDB implementation. use hash::*; diff --git a/util/src/misc.rs b/util/src/misc.rs index 2c98179f3..43027015e 100644 --- a/util/src/misc.rs +++ b/util/src/misc.rs @@ -1,3 +1,19 @@ +// 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 . + //! Diff misc. use common::*; diff --git a/util/src/network/connection.rs b/util/src/network/connection.rs index de1ca185a..746c745c4 100644 --- a/util/src/network/connection.rs +++ b/util/src/network/connection.rs @@ -1,3 +1,19 @@ +// 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 . + use std::sync::Arc; use std::collections::VecDeque; use mio::{Handler, Token, EventSet, EventLoop, PollOpt, TryRead, TryWrite}; diff --git a/util/src/network/discovery.rs b/util/src/network/discovery.rs index 36fc500ee..32370b88d 100644 --- a/util/src/network/discovery.rs +++ b/util/src/network/discovery.rs @@ -1,3 +1,19 @@ +// 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 . + // This module is a work in progress #![allow(dead_code)] //TODO: remove this after everything is done diff --git a/util/src/network/error.rs b/util/src/network/error.rs index 78f015c37..4d7fb483e 100644 --- a/util/src/network/error.rs +++ b/util/src/network/error.rs @@ -1,3 +1,19 @@ +// 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 . + use io::IoError; use rlp::*; diff --git a/util/src/network/handshake.rs b/util/src/network/handshake.rs index 9b835d5bd..4b23c4e16 100644 --- a/util/src/network/handshake.rs +++ b/util/src/network/handshake.rs @@ -1,3 +1,19 @@ +// 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 . + use std::sync::Arc; use mio::*; use mio::tcp::*; diff --git a/util/src/network/host.rs b/util/src/network/host.rs index 5a572dcae..24c3460db 100644 --- a/util/src/network/host.rs +++ b/util/src/network/host.rs @@ -1,3 +1,19 @@ +// 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 . + use std::net::{SocketAddr}; use std::collections::{HashMap}; use std::hash::{Hasher}; diff --git a/util/src/network/mod.rs b/util/src/network/mod.rs index 52f6ba382..6b58c87eb 100644 --- a/util/src/network/mod.rs +++ b/util/src/network/mod.rs @@ -1,3 +1,19 @@ +// 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 . + //! Network and general IO module. //! //! Example usage for craeting a network service and adding an IO handler: diff --git a/util/src/network/node.rs b/util/src/network/node.rs index d99754cff..e23dee9f5 100644 --- a/util/src/network/node.rs +++ b/util/src/network/node.rs @@ -1,3 +1,19 @@ +// 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 . + use std::net::{SocketAddr, ToSocketAddrs}; use std::hash::{Hash, Hasher}; use std::str::{FromStr}; diff --git a/util/src/network/service.rs b/util/src/network/service.rs index 41a23cda6..d63836daf 100644 --- a/util/src/network/service.rs +++ b/util/src/network/service.rs @@ -1,3 +1,19 @@ +// 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 . + use std::sync::*; use error::*; use network::{NetworkProtocolHandler, NetworkConfiguration}; diff --git a/util/src/network/session.rs b/util/src/network/session.rs index 41e8e9c5d..8e9a3a9ff 100644 --- a/util/src/network/session.rs +++ b/util/src/network/session.rs @@ -1,3 +1,19 @@ +// 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 . + use mio::*; use hash::*; use rlp::*; diff --git a/util/src/network/stats.rs b/util/src/network/stats.rs index 39ad4e079..30e751a81 100644 --- a/util/src/network/stats.rs +++ b/util/src/network/stats.rs @@ -1,3 +1,19 @@ +// 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 . + //! Network Statistics use std::sync::atomic::*; diff --git a/util/src/network/tests.rs b/util/src/network/tests.rs index bccd4c27d..c1b59df9b 100644 --- a/util/src/network/tests.rs +++ b/util/src/network/tests.rs @@ -1,3 +1,19 @@ +// 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 . + use std::sync::atomic::{AtomicBool, Ordering as AtomicOrdering}; use std::thread; use std::time::*; diff --git a/util/src/nibbleslice.rs b/util/src/nibbleslice.rs index ac87b808f..047990368 100644 --- a/util/src/nibbleslice.rs +++ b/util/src/nibbleslice.rs @@ -1,3 +1,19 @@ +// 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 . + //! Nibble-orientated view onto byte-slice, allowing nibble-precision offsets. use std::cmp::*; use std::fmt; diff --git a/util/src/overlaydb.rs b/util/src/overlaydb.rs index 7ef0c3309..46c37411f 100644 --- a/util/src/overlaydb.rs +++ b/util/src/overlaydb.rs @@ -1,3 +1,19 @@ +// 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 . + //! Disk-backed HashDB implementation. use error::*; diff --git a/util/src/rlp/bytes.rs b/util/src/rlp/bytes.rs index aa7287462..3b25c09ae 100644 --- a/util/src/rlp/bytes.rs +++ b/util/src/rlp/bytes.rs @@ -1,3 +1,19 @@ +// 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 . + //! Unified interfaces for RLP bytes operations on basic types //! diff --git a/util/src/rlp/mod.rs b/util/src/rlp/mod.rs index fb2ee3d5a..4be76dd3d 100644 --- a/util/src/rlp/mod.rs +++ b/util/src/rlp/mod.rs @@ -1,3 +1,19 @@ +// 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 . + //! Rlp serialization module //! //! Allows encoding, decoding, and view onto rlp-slice diff --git a/util/src/rlp/rlperrors.rs b/util/src/rlp/rlperrors.rs index d032ab36a..2d821be5f 100644 --- a/util/src/rlp/rlperrors.rs +++ b/util/src/rlp/rlperrors.rs @@ -1,3 +1,19 @@ +// 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 . + use std::fmt; use std::error::Error as StdError; use rlp::bytes::FromBytesError; diff --git a/util/src/rlp/rlpin.rs b/util/src/rlp/rlpin.rs index 9b922ed43..d58fa95e8 100644 --- a/util/src/rlp/rlpin.rs +++ b/util/src/rlp/rlpin.rs @@ -1,3 +1,19 @@ +// 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 . + use std::fmt; use rlp::{View, DecoderError, UntrustedRlp, PayloadInfo, Prototype, RlpDecodable}; diff --git a/util/src/rlp/rlpstream.rs b/util/src/rlp/rlpstream.rs index 492d188f8..ba70e7b2b 100644 --- a/util/src/rlp/rlpstream.rs +++ b/util/src/rlp/rlpstream.rs @@ -1,3 +1,19 @@ +// 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 . + use std::ops::Deref; use elastic_array::*; use rlp::bytes::{ToBytes, VecLike}; diff --git a/util/src/rlp/rlptraits.rs b/util/src/rlp/rlptraits.rs index f6b39729a..f29511d87 100644 --- a/util/src/rlp/rlptraits.rs +++ b/util/src/rlp/rlptraits.rs @@ -1,3 +1,19 @@ +// 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 . + //! Common RLP traits use std::ops::Deref; use rlp::bytes::VecLike; diff --git a/util/src/rlp/tests.rs b/util/src/rlp/tests.rs index faadbe7d2..eb2039103 100644 --- a/util/src/rlp/tests.rs +++ b/util/src/rlp/tests.rs @@ -1,3 +1,19 @@ +// 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 . + extern crate json_tests; use self::json_tests::execute_tests_from_directory; use self::json_tests::rlp as rlptest; diff --git a/util/src/rlp/untrusted_rlp.rs b/util/src/rlp/untrusted_rlp.rs index ed288bbdd..7126e868d 100644 --- a/util/src/rlp/untrusted_rlp.rs +++ b/util/src/rlp/untrusted_rlp.rs @@ -1,3 +1,19 @@ +// 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 . + use std::cell::Cell; use std::fmt; use rustc_serialize::hex::ToHex; diff --git a/util/src/semantic_version.rs b/util/src/semantic_version.rs index 10cf47eac..496ff2318 100644 --- a/util/src/semantic_version.rs +++ b/util/src/semantic_version.rs @@ -1,3 +1,19 @@ +// 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 . + //! Semantic version formatting and comparing. /// A version value with strict meaning. Use `to_u32` to convert to a simple integer. diff --git a/util/src/sha3.rs b/util/src/sha3.rs index d00516000..7e8382250 100644 --- a/util/src/sha3.rs +++ b/util/src/sha3.rs @@ -1,3 +1,19 @@ +// 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 . + //! Wrapper around tiny-keccak crate. extern crate sha3 as sha3_ext; diff --git a/util/src/squeeze.rs b/util/src/squeeze.rs index 5cda39249..69aab9728 100644 --- a/util/src/squeeze.rs +++ b/util/src/squeeze.rs @@ -1,3 +1,19 @@ +// 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 . + //! Helper module that should be used to randomly squeeze //! caches to a given size in bytes //! diff --git a/util/src/standard.rs b/util/src/standard.rs index d1589d30a..c588e9d53 100644 --- a/util/src/standard.rs +++ b/util/src/standard.rs @@ -1,3 +1,19 @@ +// 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 . + //! Std lib global reexports. pub use std::io; diff --git a/util/src/trie/journal.rs b/util/src/trie/journal.rs index 948f07a06..db16a313d 100644 --- a/util/src/trie/journal.rs +++ b/util/src/trie/journal.rs @@ -1,3 +1,19 @@ +// 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 . + use sha3::*; use hash::H256; use bytes::*; diff --git a/util/src/trie/mod.rs b/util/src/trie/mod.rs index 74a525bb6..b8b98880d 100644 --- a/util/src/trie/mod.rs +++ b/util/src/trie/mod.rs @@ -1,3 +1,19 @@ +// 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 . + //! Trie interface and implementation. /// Export the trietraits module. diff --git a/util/src/trie/node.rs b/util/src/trie/node.rs index 626c4dd00..2ebcd0ef0 100644 --- a/util/src/trie/node.rs +++ b/util/src/trie/node.rs @@ -1,3 +1,19 @@ +// 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 . + use hash::*; use nibbleslice::*; use bytes::*; diff --git a/util/src/trie/sectriedb.rs b/util/src/trie/sectriedb.rs index 2a8c3b016..9f74e9917 100644 --- a/util/src/trie/sectriedb.rs +++ b/util/src/trie/sectriedb.rs @@ -1,3 +1,19 @@ +// 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 . + use hash::*; use sha3::*; use hashdb::*; diff --git a/util/src/trie/sectriedbmut.rs b/util/src/trie/sectriedbmut.rs index 7f8e292f0..662f6852a 100644 --- a/util/src/trie/sectriedbmut.rs +++ b/util/src/trie/sectriedbmut.rs @@ -1,3 +1,19 @@ +// 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 . + use hash::*; use sha3::*; use hashdb::*; diff --git a/util/src/trie/standardmap.rs b/util/src/trie/standardmap.rs index ce2062566..98a5ae0f0 100644 --- a/util/src/trie/standardmap.rs +++ b/util/src/trie/standardmap.rs @@ -1,3 +1,19 @@ +// 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 . + //! Key-value datastore with a modified Merkle tree. extern crate rand; diff --git a/util/src/trie/triedb.rs b/util/src/trie/triedb.rs index 9909c05a4..dbf01b6a9 100644 --- a/util/src/trie/triedb.rs +++ b/util/src/trie/triedb.rs @@ -1,3 +1,19 @@ +// 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 . + use common::*; use hashdb::*; use nibbleslice::*; diff --git a/util/src/trie/triedbmut.rs b/util/src/trie/triedbmut.rs index f65d196e4..8e92063aa 100644 --- a/util/src/trie/triedbmut.rs +++ b/util/src/trie/triedbmut.rs @@ -1,3 +1,19 @@ +// 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 . + use common::*; use hashdb::*; use nibbleslice::*; diff --git a/util/src/trie/trietraits.rs b/util/src/trie/trietraits.rs index 5b069fdd5..160f9466f 100644 --- a/util/src/trie/trietraits.rs +++ b/util/src/trie/trietraits.rs @@ -1,3 +1,19 @@ +// 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 . + use hash::H256; use rlp::SHA3_NULL_RLP; diff --git a/util/src/triehash.rs b/util/src/triehash.rs index 6ff6b790d..54ea6f702 100644 --- a/util/src/triehash.rs +++ b/util/src/triehash.rs @@ -1,3 +1,19 @@ +// 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 . + //! Generetes trie root. //! //! This module should be used to generate trie root hash. diff --git a/util/src/uint.rs b/util/src/uint.rs index 4b1fba5e7..4c0b533ef 100644 --- a/util/src/uint.rs +++ b/util/src/uint.rs @@ -1,3 +1,19 @@ +// 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 . + // Code derived from original work by Andrew Poelstra // Rust Bitcoin Library diff --git a/util/src/vector.rs b/util/src/vector.rs index ed844a5a4..51a167a48 100644 --- a/util/src/vector.rs +++ b/util/src/vector.rs @@ -1,3 +1,19 @@ +// 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 . + //! Vector extensions. /// Returns len of prefix shared with elem From 29be2899e301e881b6adb1396ec989f0bd806a33 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 5 Feb 2016 13:48:53 +0100 Subject: [PATCH 17/23] Gitter in README. Fix installation guide. --- README.md | 4 +++- install-deps.sh | 7 +++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c223921f1..dc0498d26 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,13 @@ # ethcore -[![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] +[![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Join the chat at https://gitter.im/trogdoro/xiki][gitter-image]][gitter-url] [travis-image]: https://travis-ci.com/ethcore/parity.svg?token=DMFvZu71iaTbUYx9UypX&branch=master [travis-url]: https://travis-ci.com/ethcore/parity [coveralls-image]: https://coveralls.io/repos/github/ethcore/parity/badge.svg?branch=master&t=Fk0OuQ [coveralls-url]: https://coveralls.io/r/ethcore/parity?branch=master +[gitter-image]: https://badges.gitter.im/Join%20Chat.svg +[gitter-url]: https://gitter.im/ethcore/parity?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge ### Building from source diff --git a/install-deps.sh b/install-deps.sh index d03098c42..15fdc838c 100755 --- a/install-deps.sh +++ b/install-deps.sh @@ -628,12 +628,11 @@ function run_installer() info "Building..." cargo build --release - cd .. echo - head "Parity is built!" - info "Parity source code is in ${b}$(pwd)/parity${reset}. From that path, you can:" + successHeading "Parity is built!" + info "Parity source code is in ${b}$(pwd)/parity${reset}. From there, you can:" info "- Run a client & sync the chain with:" info " ${b}cargo run --release${reset}" info "- Run a JSONRPC-capable client (for use with netstats) with:" @@ -641,7 +640,7 @@ function run_installer() info "- Run tests with:" info " ${b}cargo test --release --features ethcore/json-tests -p ethcore${reset}" info "- Install the client with:" - info " ${b}sudo cp target/release/parity /usr/bin${reset}" + info " ${b}sudo cp parity/target/release/parity${reset}" echo } From f06e444737519361c84b40dacb9e947c65fc01ff Mon Sep 17 00:00:00 2001 From: arkpar Date: Fri, 5 Feb 2016 13:49:36 +0100 Subject: [PATCH 18/23] Raise FD limit for macos --- Cargo.toml | 1 + parity/main.rs | 2 + util/fdlimit/Cargo.toml | 10 +++++ util/fdlimit/src/lib.rs | 18 +++++++++ util/fdlimit/src/raise_fd_limit.rs | 62 ++++++++++++++++++++++++++++++ 5 files changed, 93 insertions(+) create mode 100644 util/fdlimit/Cargo.toml create mode 100644 util/fdlimit/src/lib.rs create mode 100644 util/fdlimit/src/raise_fd_limit.rs diff --git a/Cargo.toml b/Cargo.toml index 6766a5b2c..1eac83ac3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,7 @@ ethcore-util = { path = "util" } ethcore = { path = "ethcore" } ethsync = { path = "sync" } ethcore-rpc = { path = "rpc", optional = true } +fdlimit = { path = "util/fdlimit" } [features] default = ["rpc"] diff --git a/parity/main.rs b/parity/main.rs index bc492277a..3370645be 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -12,6 +12,7 @@ extern crate ethsync; extern crate log as rlog; extern crate env_logger; extern crate ctrlc; +extern crate fdlimit; #[cfg(feature = "rpc")] extern crate ethcore_rpc as rpc; @@ -79,6 +80,7 @@ fn main() { let args: Args = Args::docopt().decode().unwrap_or_else(|e| e.exit()); setup_log(&args.flag_logging); + unsafe { ::fdlimit::raise_fd_limit(); } let spec = ethereum::new_frontier(); let init_nodes = match args.arg_enode.len() { diff --git a/util/fdlimit/Cargo.toml b/util/fdlimit/Cargo.toml new file mode 100644 index 000000000..42aa582fe --- /dev/null +++ b/util/fdlimit/Cargo.toml @@ -0,0 +1,10 @@ +[package] +description = "Utility function to raise file descriptor limit on OS X" +homepage = "http://ethcore.io" +license = "GPL-3.0" +name = "fdlimit" +version = "0.1.0" +authors = ["Ethcore "] + +[dependencies] +libc = "0.2" diff --git a/util/fdlimit/src/lib.rs b/util/fdlimit/src/lib.rs new file mode 100644 index 000000000..e659bb8c9 --- /dev/null +++ b/util/fdlimit/src/lib.rs @@ -0,0 +1,18 @@ +// 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 .extern crate libc; +extern crate libc; +pub mod raise_fd_limit; +pub use raise_fd_limit::raise_fd_limit; diff --git a/util/fdlimit/src/raise_fd_limit.rs b/util/fdlimit/src/raise_fd_limit.rs new file mode 100644 index 000000000..0cf90ec95 --- /dev/null +++ b/util/fdlimit/src/raise_fd_limit.rs @@ -0,0 +1,62 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +/// darwin_fd_limit exists to work around an issue where launchctl on Mac OS X +/// defaults the rlimit maxfiles to 256/unlimited. The default soft limit of 256 +/// ends up being far too low for our multithreaded scheduler testing, depending +/// on the number of cores available. +/// +/// This fixes issue #7772. +#[cfg(any(target_os = "macos", target_os = "ios"))] +#[allow(non_camel_case_types)] +pub unsafe fn raise_fd_limit() { + use libc; + use std::cmp; + use std::io; + use std::mem::size_of_val; + use std::ptr::null_mut; + + static CTL_KERN: libc::c_int = 1; + static KERN_MAXFILESPERPROC: libc::c_int = 29; + + // The strategy here is to fetch the current resource limits, read the + // kern.maxfilesperproc sysctl value, and bump the soft resource limit for + // maxfiles up to the sysctl value. + + // Fetch the kern.maxfilesperproc value + let mut mib: [libc::c_int; 2] = [CTL_KERN, KERN_MAXFILESPERPROC]; + let mut maxfiles: libc::c_int = 0; + let mut size: libc::size_t = size_of_val(&maxfiles) as libc::size_t; + if libc::sysctl(&mut mib[0], 2, &mut maxfiles as *mut _ as *mut _, &mut size, + null_mut(), 0) != 0 { + let err = io::Error::last_os_error(); + panic!("raise_fd_limit: error calling sysctl: {}", err); + } + + // Fetch the current resource limits + let mut rlim = libc::rlimit{rlim_cur: 0, rlim_max: 0}; + if libc::getrlimit(libc::RLIMIT_NOFILE, &mut rlim) != 0 { + let err = io::Error::last_os_error(); + panic!("raise_fd_limit: error calling getrlimit: {}", err); + } + + // Bump the soft limit to the smaller of kern.maxfilesperproc and the hard + // limit + rlim.rlim_cur = cmp::min(maxfiles as libc::rlim_t, rlim.rlim_max); + + // Set our newly-increased resource limit + if libc::setrlimit(libc::RLIMIT_NOFILE, &rlim) != 0 { + let err = io::Error::last_os_error(); + panic!("raise_fd_limit: error calling setrlimit: {}", err); + } +} + +#[cfg(not(any(target_os = "macos", target_os = "ios")))] +pub unsafe fn raise_fd_limit() {} From 0ddd113429f9252f1e0c007c69b60ca3040550de Mon Sep 17 00:00:00 2001 From: debris Date: Fri, 5 Feb 2016 13:50:35 +0100 Subject: [PATCH 19/23] changed SignedTransaction transaction property name to unsigned --- ethcore/src/transaction.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ethcore/src/transaction.rs b/ethcore/src/transaction.rs index 02f1ae879..cd686bf7d 100644 --- a/ethcore/src/transaction.rs +++ b/ethcore/src/transaction.rs @@ -77,7 +77,7 @@ impl FromJson for SignedTransaction { match json.find("secretKey") { Some(&Json::String(ref secret_key)) => t.sign(&h256_from_hex(clean(secret_key))), _ => SignedTransaction { - transaction: t, + unsigned: t, 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) }, @@ -104,7 +104,7 @@ impl Transaction { let sig = ec::sign(secret, &self.hash()); let (r, s, v) = sig.unwrap().to_rsv(); SignedTransaction { - transaction: self, + unsigned: self, r: r, s: s, v: v + 27, @@ -117,7 +117,7 @@ impl Transaction { #[cfg(test)] pub fn fake_sign(self) -> SignedTransaction { SignedTransaction { - transaction: self, + unsigned: self, r: U256::zero(), s: U256::zero(), v: 0, @@ -145,7 +145,7 @@ impl Transaction { #[derive(Debug, Clone)] pub struct SignedTransaction { /// Plain Transaction. - transaction: Transaction, + unsigned: Transaction, /// The V field of the signature, either 27 or 28; helps describe the point on the curve. v: u8, /// The R field of the signature; helps describe the point on the curve. @@ -162,7 +162,7 @@ impl Deref for SignedTransaction { type Target = Transaction; fn deref(&self) -> &Self::Target { - &self.transaction + &self.unsigned } } @@ -173,7 +173,7 @@ impl Decodable for SignedTransaction { return Err(DecoderError::RlpIncorrectListLen); } Ok(SignedTransaction { - transaction: Transaction { + unsigned: Transaction { nonce: try!(d.val_at(0)), gas_price: try!(d.val_at(1)), gas: try!(d.val_at(2)), @@ -245,7 +245,7 @@ impl SignedTransaction { match &mut *sender { &mut Some(ref h) => Ok(h.clone()), sender @ &mut None => { - *sender = Some(From::from(try!(ec::recover(&self.signature(), &self.transaction.hash())).sha3())); + *sender = Some(From::from(try!(ec::recover(&self.signature(), &self.unsigned.hash())).sha3())); Ok(sender.as_ref().unwrap().clone()) } } From 7dcb1b7b3346686ad583d01c4533ac2a7a189d93 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 5 Feb 2016 13:51:35 +0100 Subject: [PATCH 20/23] Travis slack integration. --- .travis.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index 7589697af..fceed1a75 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,3 +64,11 @@ deploy: file: parity${ARCHIVE_SUFFIX}.tar.gz on: tags: true + +notifications: + webhooks: + urls: + - https://hooks.slack.com/services/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 + on_success: always + on_failure: always + on_start: never \ No newline at end of file From 0504bc17ce1e50595a995eb6e3152689816c8cd5 Mon Sep 17 00:00:00 2001 From: arkpar Date: Fri, 5 Feb 2016 13:55:29 +0100 Subject: [PATCH 21/23] Removed issue comment --- util/fdlimit/src/raise_fd_limit.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/util/fdlimit/src/raise_fd_limit.rs b/util/fdlimit/src/raise_fd_limit.rs index 0cf90ec95..f57ac2785 100644 --- a/util/fdlimit/src/raise_fd_limit.rs +++ b/util/fdlimit/src/raise_fd_limit.rs @@ -13,7 +13,6 @@ /// ends up being far too low for our multithreaded scheduler testing, depending /// on the number of cores available. /// -/// This fixes issue #7772. #[cfg(any(target_os = "macos", target_os = "ios"))] #[allow(non_camel_case_types)] pub unsafe fn raise_fd_limit() { From ff9f044ecea9e5edcfdb9bb38e2fb793f58ffbb3 Mon Sep 17 00:00:00 2001 From: debris Date: Fri, 5 Feb 2016 14:03:10 +0100 Subject: [PATCH 22/23] make slackwebhook secure --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index fceed1a75..816e6d883 100644 --- a/.travis.yml +++ b/.travis.yml @@ -55,6 +55,7 @@ env: global: - secure: 3sUjNi9mhdL5h1GTm8LONnDN/SYvUHT+WSkMl93h3nYiLCQXk8eZaPS98AS7oOaTsfW4UvnwckVFCFl49ttInsv4cd/TkAxmrJHe6kPyS9/4NWUdmP8BjicbBvL/ioSdXMECMEYzPDLV+I3KhtC2LcB6ceDEl/XwMOJlzbGf7RbtcXGVQgMLqSYY1YKjQA4vbT5nFgIS/sZu3Z9yFgN0GafnihKcizqoHhdJjs/zxmX+qJepnC6o3V6KcFnS7QHhM1JOr85twE6S422UlvNaEb5ovwLPqmOl5+fA+6shbx4AxFTY6E9Iors+OVY/JliFhrqOdCt0i2P1FUHN4kbGZQkf0rphN/ZOI2uKNFTOyXiPvppfo/ZemKmcqkwkqP9+lf5QqYmtE6hsAYagxn49xJZILl8tAYbdqxF5gxa+TEVrfsBFtz/Sv3q8QhKQNPAmjEcKyMatyEreLUIFEpFTGIco8jN4eXeSoLRdJ+Z75ihttfQWhNfUDgNL30iQLy0AgFSsh/cyb5M8y9lxrGDzDTogvaiKGwr/V45sPkcXWCkmOgMdINqBB6ZtdL3bGHdyjmYj+y3btjf3aP11k++BL0fXIaKn25aS/p/9iyGb1FyGCM03o4ZRQ3YhTOvfMRfRGf6nWbaMx9upv8o5ShSdysewhrnh3082r7u896ny1Ho= - secure: 0/FeVvFl3AhBW0TCPoujY9zOAYoUNMlAz3XjC04vlc4Ksfx0lGU3KFi97LlALxMWV0lfwQc7ixSe2vTgQVQuLVSU9XEW40fQgEjJlmLca2RcRx1kfzJDypuWSiCME7MWmLPH0ac4COdTDS1z5WGggv5YB7GQPCzFvcmOOaPYtF29ngCtkyB2HmNkY/W3omHFEk7Si6bsmOSHZiOAhivPl6ixnGpFyTEKPyraMMqPIj5rbEGkzgeLTiXf2ur143n/tnSr8tmP1MfQi9yS8/ONidMqnxUeuLkeNnb82zj9pVJhVXq0xF44WXJ8Za1jm0ByiTakgqpm8Juk822qjvtNulJ1XZW/fyZQZaN1dy3uq5Ud3W8wS9M7VIVl8CoXozzDpIsdPeUAtkAxeHBsZqL1vAH2yC1YJA7HPySMYzCjYqkJ2r62xYk0gXmNXphfU+F/X/rHzHsTMJPONJ54HQwu12m7zVlKIYBGHgEXg/HAM/g4ljUzl6WWR/nHH/tQM8ND/8FpHluJSZJWacq/1QNhVdTq2x6cqws2fs5A7nVpccR9+6RRgYgv6+YS2LxvFzByuZveGGoKif+uMECXN876j40araUqU528Yz9i8bHJlnM3coRBndaLNWByLcUyXCB9r9IUosUu41rr+L2mVzkSDm0GicuNCzqvzYQ9Q6QY4uQ= + - secure: DglvLR27MrBKQO/8s7ZfGqfimXk1Iq5MreCTc+ZkWMkZ0sDP76YBUPq5j25hcg0Z09z09O2Q5OUOyYkhVD4AnRjoRLUplHdpDE9CBSz2vUGpMpzhgAqzBc6SDsEmWU2JlAPBraIODXQdP/Qo6tYY4zn3vwd/VFKo27GTb5b60WAkTVvT/0YPWycEXFIa7sNMgjNI0EnT+Se5USDYwb6MM1T9JxJot0q3WtOnsVyroCHJp4QDicpS8eQIu3Tl+SLE4d0EoJ4YYLOI+jWOybipuO1xM1xlHq/gpWfjKqbJh24xtAds524dN7ujfjAhyO2zQbuTOfi7QVOj/Go0tGYxNxobR4pYG783Aiq3Quj0GzSrLEAatkk5tGOcuVJ98EYIg3WPJuC93waTTXcS0xDyy09XHxWxZ/5PiXorRZjpHvnZfRF0X4Mus6jUJ7hqDuOUiF5BI1RHomHvJQQHUrLdmh7OHyrer3YUpKRs65tww6H+VM+lKNa3MnMkB5+or/co14svs7I4pni9S+aZg//bwuxGVXchK6bjLCP1X99Ar4fA5EGsTVdjp3PRqutM/P3RqNGkwTczat/PNZ8fFAD9y7pDs2L6YkqpflTC9d6vKTSl6gORGw6ltLUJs23ON6xRNIBMw1cXp67wN57vF46TPt1i3ZlIQsYn0pAVNKavbZE= deploy: provider: releases @@ -68,7 +69,7 @@ deploy: notifications: webhooks: urls: - - https://hooks.slack.com/services/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 + - https://hooks.slack.com/services/${SLACK_WEBHOOK} on_success: always on_failure: always - on_start: never \ No newline at end of file + on_start: never From 499637606d52013922056874f642f91f6f6941d7 Mon Sep 17 00:00:00 2001 From: arkpar Date: Fri, 5 Feb 2016 15:08:18 +0100 Subject: [PATCH 23/23] DB directory versioning --- ethcore/src/client.rs | 9 ++++++++- ethcore/src/service.rs | 1 - 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ethcore/src/client.rs b/ethcore/src/client.rs index 6f688bd57..3a0309c1c 100644 --- a/ethcore/src/client.rs +++ b/ethcore/src/client.rs @@ -17,7 +17,7 @@ //! Blockchain database client. use util::*; -use rocksdb::{Options, DB}; +use rocksdb::{Options, DB, DBCompactionStyle}; use blockchain::{BlockChain, BlockProvider, CacheSize}; use views::BlockView; use error::*; @@ -163,16 +163,23 @@ pub struct Client { } const HISTORY: u64 = 1000; +const CLIENT_DB_VER_STR: &'static str = "1.0"; impl Client { /// Create a new client with given spec and DB path. pub fn new(spec: Spec, path: &Path, message_channel: IoChannel ) -> Result, Error> { + let mut dir = path.to_path_buf(); + dir.push(H64::from(spec.genesis_header().hash()).hex()); + //TODO: sec/fat: pruned/full versioning + dir.push(format!("v{}-sec-pruned", CLIENT_DB_VER_STR)); + let path = dir.as_path(); let gb = spec.genesis_block(); let chain = Arc::new(RwLock::new(BlockChain::new(&gb, path))); let mut opts = Options::new(); opts.set_max_open_files(256); opts.create_if_missing(true); opts.set_use_fsync(false); + opts.set_compaction_style(DBCompactionStyle::DBUniversalCompaction); /* opts.set_bytes_per_sync(8388608); opts.set_disable_data_sync(false); diff --git a/ethcore/src/service.rs b/ethcore/src/service.rs index 90fe0a6b5..92f483507 100644 --- a/ethcore/src/service.rs +++ b/ethcore/src/service.rs @@ -48,7 +48,6 @@ impl ClientService { info!("Configured for {} using {} engine", spec.name, spec.engine_name); let mut dir = env::home_dir().unwrap(); dir.push(".parity"); - dir.push(H64::from(spec.genesis_header().hash()).hex()); let client = try!(Client::new(spec, &dir, net_service.io().channel())); let client_io = Arc::new(ClientIoHandler { client: client.clone()