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

Commit

Permalink
Merge branch 'sync' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
arkpar committed Mar 15, 2016
2 parents b9fc5bd + e538b41 commit 570d2c2
Show file tree
Hide file tree
Showing 9 changed files with 294 additions and 172 deletions.
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ matrix:
include:
- rust: stable
env: FEATURES="--features travis-beta" KCOV_FEATURES="" TARGETS="-p ethash -p ethcore-util -p ethcore -p ethsync -p ethcore-rpc -p parity -p ethminer" ARCHIVE_SUFFIX="-${TRAVIS_OS_NAME}-${TRAVIS_TAG}"
- rust: beta
env: FEATURES="--features travis-beta" KCOV_FEATURES="" TARGETS="-p ethash -p ethcore-util -p ethcore -p ethsync -p ethcore-rpc -p parity -p ethminer" ARCHIVE_SUFFIX="-${TRAVIS_OS_NAME}-${TRAVIS_TAG}"
- rust: nightly
env: FEATURES="--features travis-nightly" KCOV_FEATURES="" TARGETS="-p ethash -p ethcore-util -p ethcore -p ethsync -p ethcore-rpc -p parity -p ethminer" ARCHIVE_SUFFIX="-${TRAVIS_OS_NAME}-${TRAVIS_TAG}"
cache:
apt: true
directories:
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

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

33 changes: 32 additions & 1 deletion ethcore/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,37 @@ mod tests {

#[test]
fn enact_block_with_uncle() {
// TODO: test for when there's an uncle.
use spec::*;
let engine = Spec::new_test().to_engine().unwrap();
let genesis_header = engine.spec().genesis_header();

let mut db_result = get_temp_journal_db();
let mut db = db_result.take();
engine.spec().ensure_db_good(db.as_hashdb_mut());
let mut open_block = OpenBlock::new(engine.deref(), db, &genesis_header, vec![genesis_header.hash()], Address::zero(), x!(3141562), vec![]);
let mut uncle1_header = Header::new();
uncle1_header.extra_data = b"uncle1".to_vec();
let mut uncle2_header = Header::new();
uncle2_header.extra_data = b"uncle2".to_vec();
open_block.push_uncle(uncle1_header).unwrap();
open_block.push_uncle(uncle2_header).unwrap();
let b = open_block.close().seal(engine.deref(), vec![]).unwrap();

let orig_bytes = b.rlp_bytes();
let orig_db = b.drain();

let mut db_result = get_temp_journal_db();
let mut db = db_result.take();
engine.spec().ensure_db_good(db.as_hashdb_mut());
let e = enact_and_seal(&orig_bytes, engine.deref(), db, &genesis_header, vec![genesis_header.hash()]).unwrap();

let bytes = e.rlp_bytes();
assert_eq!(bytes, orig_bytes);
let uncles = BlockView::new(&bytes).uncles();
assert_eq!(uncles[1].extra_data, b"uncle2");

let db = e.drain();
assert_eq!(orig_db.keys(), db.keys());
assert!(orig_db.keys().iter().filter(|k| orig_db.get(k.0) != db.get(k.0)).next() == None);
}
}
6 changes: 3 additions & 3 deletions ethcore/src/blockchain/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,10 +504,10 @@ impl BlockChain {
batch.put_extras(hash, tx_address);
write_txs.remove(hash);
}
}

// update extras database
self.extras_db.write(batch).unwrap();
// update extras database
self.extras_db.write(batch).unwrap();
}
}

/// Iterator that lists `first` and then all of `first`'s ancestors, by hash.
Expand Down
2 changes: 2 additions & 0 deletions sync/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ impl ChainSync {
trace!(target: "sync", "{} -> NewBlock ({})", peer_id, h);
if !self.have_common_block {
trace!(target: "sync", "NewBlock ignored while seeking");
return Ok(());
}
let header: BlockHeader = try!(header_rlp.as_val());
let mut unknown = false;
Expand Down Expand Up @@ -1497,6 +1498,7 @@ mod tests {

let mut queue = VecDeque::new();
let mut sync = dummy_sync_with_peer(client.block_hash_delta_minus(5));
sync.have_common_block = true;
let mut io = TestIo::new(&mut client, &mut queue, None);

let block = UntrustedRlp::new(&block_data);
Expand Down
10 changes: 9 additions & 1 deletion test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
#!/bin/sh
# Running Parity Full Test Sute

cargo test --features ethcore/json-tests $1 -p ethash -p ethcore-util -p ethcore -p ethsync -p ethcore-rpc -p parity -p ethminer
cargo test --features ethcore/json-tests $1 \
-p ethash \
-p ethcore-util \
-p ethcore \
-p ethsync \
-p ethcore-rpc \
-p parity \
-p ethminer \
-p bigint
15 changes: 11 additions & 4 deletions util/benches/bigint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,16 @@ fn u256_sub(b: &mut Bencher) {
fn u512_sub(b: &mut Bencher) {
b.iter(|| {
let n = black_box(10000);
(0..n).fold(U512([rand::random::<u64>(), rand::random::<u64>(), rand::random::<u64>(), rand::random::<u64>(),
rand::random::<u64>(), rand::random::<u64>(), rand::random::<u64>(), rand::random::<u64>()]),
|old, new| { old.overflowing_sub(U512([0, 0, 0, 0, 0, 0, 0, new])).0 })
(0..n).fold(
U512([
rand::random::<u64>(), rand::random::<u64>(), rand::random::<u64>(), rand::random::<u64>(),
rand::random::<u64>(), rand::random::<u64>(), rand::random::<u64>(), rand::random::<u64>()
]),
|old, new| {
let p = new % 2;
old.overflowing_sub(U512([p, p, p, p, p, p, p, new])).0
}
)
});
}

Expand All @@ -79,7 +86,7 @@ fn u256_full_mul(b: &mut Bencher) {
b.iter(|| {
let n = black_box(10000);
(0..n).fold(U256([rand::random::<u64>(), rand::random::<u64>(), rand::random::<u64>(), rand::random::<u64>()]),
|old, new| {
|old, _new| {
let U512(ref u512words) = old.full_mul(U256([rand::random::<u64>(), rand::random::<u64>(), rand::random::<u64>(), rand::random::<u64>()]));
U256([u512words[0], u512words[2], u512words[2], u512words[3]])
})
Expand Down
Loading

0 comments on commit 570d2c2

Please sign in to comment.