Merge branch 'master' into coverage-effort

Conflicts:
	ethcore/src/receipt.rs
This commit is contained in:
Nikolay Volf 2016-02-01 16:37:08 +04:00
commit 77fdef4fb0
16 changed files with 203 additions and 39 deletions

View File

@ -8,6 +8,8 @@ matrix:
cache:
apt: true
directories:
- target/debug/deps
- target/debug/build
- target/release/deps
- target/release/build
addons:
@ -25,13 +27,22 @@ script:
- cargo test --release -p ethash --verbose
- cargo test --release -p ethcore-util --verbose
- cargo test --release -p ethcore --verbose
- cargo test --release -p ethcore-rpc --verbose --features rpc
- cargo test --release --verbose
- cargo bench --no-run
after_success: |
wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz &&
tar xzf master.tar.gz && mkdir kcov-master/build && cd kcov-master/build && cmake .. && make && make install DESTDIR=../tmp && cd ../.. &&
ls target/release &&
./kcov-master/tmp/usr/local/bin/kcov --coveralls-id=${COVERALLS_TOKEN} --exclude-pattern=/.cargo --include-pattern=ethcore/src target/kcov target/release/deps/ethcore-* &&
cargo test --no-run -p ethcore-util &&
./kcov-master/tmp/usr/local/bin/kcov --exclude-pattern /.cargo,/root/.multirust target/kcov target/debug/deps/ethcore_util-* &&
cargo test --no-run -p ethash &&
./kcov-master/tmp/usr/local/bin/kcov --exclude-pattern /.cargo,/root/.multirust target/kcov target/debug/deps/ethash-* &&
cargo test --no-run -p ethcore --no-default-features &&
./kcov-master/tmp/usr/local/bin/kcov --exclude-pattern /.cargo,/root/.multirust target/kcov target/debug/deps/ethcore-* &&
cargo test --no-run -p ethcore-rpc --features rpc
./kcov-master/tmp/usr/local/bin/kcov --exclude-pattern /.cargo,/root/.multirust target/kcov target/debug/deps/ethcore_rpc-* &&
cargo test --no-run &&
./kcov-master/tmp/usr/local/bin/kcov --coveralls-id=${COVERALLS_TOKEN} --exclude-pattern /.cargo,/root/.multirust target/kcov target/debug/parity-*
[ $TRAVIS_BRANCH = master ] &&
[ $TRAVIS_PULL_REQUEST = false ] &&
[ $TRAVIS_RUST_VERSION = nightly ] &&

View File

@ -1 +1,54 @@
# ethcore
[![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-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
### Building from source
##### Ubuntu 14.04 and later
```bash
# install rocksdb
add-apt-repository "deb http://ppa.launchpad.net/giskou/librocksdb/ubuntu trusty main"
apt-get update
apt-get install -y --force-yes librocksdb
# install multirust
curl -sf https://raw.githubusercontent.com/brson/multirust/master/blastoff.sh | sh -s -- --yes
# install nightly and make it default
multirust update nightly && multirust default nightly
# export rust LIBRARY_PATH
export LIBRARY_PATH=/usr/local/lib
# download and build parity
git clone https://github.com/ethcore/parity
cd parity
cargo build --release
```
##### OSX
```bash
# install rocksdb && multirust
brew update
brew install rocksdb
brew install multirust
# install nightly and make it default
multirust update nightly && multirust default nightly
# export rust LIBRARY_PATH
export LIBRARY_PATH=/usr/local/lib
# download and build parity
git clone https://github.com/ethcore/parity
cd parity
cargo build --release
```

View File

@ -0,0 +1,46 @@
FROM ubuntu:14.04
# install tools and dependencies
RUN apt-get update && \
apt-get install -y \
# make
build-essential \
# add-apt-repository
software-properties-common \
curl \
wget \
git \
# evmjit dependencies
zlib1g-dev \
libedit-dev
# cmake, llvm and rocksdb ppas. then update ppas
RUN add-apt-repository -y "ppa:george-edison55/cmake-3.x" && \
add-apt-repository "deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.7 main" && \
add-apt-repository "deb http://ppa.launchpad.net/giskou/librocksdb/ubuntu trusty main" && \
apt-get update && \
apt-get install -y --force-yes cmake llvm-3.7-dev librocksdb
# install evmjit
RUN git clone https://github.com/debris/evmjit && \
cd evmjit && \
mkdir build && cd build && \
cmake .. && make && make install && cd
# install multirust
RUN curl -sf https://raw.githubusercontent.com/brson/multirust/master/blastoff.sh | sh -s -- --yes
# install nightly and make it default
RUN multirust update nightly && multirust default nightly
# export rust LIBRARY_PATH
ENV LIBRARY_PATH /usr/local/lib
# show backtraces
ENV RUST_BACKTRACE 1
# build parity
# TODO: add jit feature
RUN git clone https://github.com/ethcore/parity && \
cd parity && \
cargo install --features rpc

31
docker/ubuntu/Dockerfile Normal file
View File

@ -0,0 +1,31 @@
FROM ubuntu:14.04
# install tools and dependencies
RUN apt-get update && \
apt-get install -y \
curl \
git \
# add-apt-repository
software-properties-common
# rocksdb ppas. then update ppas
RUN add-apt-repository "deb http://ppa.launchpad.net/giskou/librocksdb/ubuntu trusty main" && \
apt-get update && \
apt-get install -y --force-yes librocksdb
# install multirust
RUN curl -sf https://raw.githubusercontent.com/brson/multirust/master/blastoff.sh | sh -s -- --yes
# install nightly and make it default
RUN multirust update nightly && multirust default nightly
# export rust LIBRARY_PATH
ENV LIBRARY_PATH /usr/local/lib
# show backtraces
ENV RUST_BACKTRACE 1
# build parity
RUN git clone https://github.com/ethcore/parity && \
cd parity && \
cargo install --features rpc

View File

@ -25,6 +25,8 @@ crossbeam = "0.1.5"
lazy_static = "0.1"
[features]
default = ["json-tests"]
jit = ["evmjit"]
evm_debug = []
evm-debug = []
json-tests = []
test-heavy = []

View File

@ -791,23 +791,30 @@ impl Interpreter {
Ok(InstructionResult::Ok)
}
fn copy_data_to_memory(&self,
mem: &mut Memory,
stack: &mut Stack<U256>,
data: &[u8]) {
let offset = stack.pop_back();
let index = stack.pop_back();
fn copy_data_to_memory(&self, mem: &mut Memory, stack: &mut Stack<U256>, data: &[u8]) {
let dest_offset = stack.pop_back();
let source_offset = stack.pop_back();
let size = stack.pop_back();
let data_size = data.len();
let source_size = U256::from(data.len());
if index < U256::from(data_size) {
let u_index = index.low_u64() as usize;
let bound_size = match size + index > U256::from(data_size) {
true => data_size,
false => size.low_u64() as usize + u_index
};
let output_end = match source_offset > source_size || size > source_size || source_offset + size > source_size {
true => {
let zero_slice = if source_offset > source_size {
mem.writeable_slice(dest_offset, size)
} else {
mem.writeable_slice(dest_offset + source_size - source_offset, source_offset + size - source_size)
};
for i in zero_slice.iter_mut() {
*i = 0;
}
data.len()
},
false => (size.low_u64() + source_offset.low_u64()) as usize
};
mem.write_slice(offset, &data[u_index..bound_size]);
if source_offset < source_size {
let output_begin = source_offset.low_u64() as usize;
mem.write_slice(dest_offset, &data[output_begin..output_end]);
}
}

View File

@ -37,18 +37,18 @@ impl Encodable for Receipt {
}
}
#[cfg(test)]
mod tests {
use super::*;
use util::*;
#[test]
fn it_can_be_encoded() {
let mut rlp_stream = RlpStream::new();
let receipt = Receipt::new(H256::zero(), U256::zero(), vec![]);
rlp_stream.append(&receipt);
let out = rlp_stream.out();
assert_eq!(out.len(), 297);
}
#[test]
fn test_basic() {
let expected = FromHex::from_hex("f90162a02f697d671e9ae4ee24a43c4b0d7e15f1cb4ba6de1561120d43b9a4e8c4a8a6ee83040caeb9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000f838f794dcf421d093428b096ca501a7cd1a740855a7976fc0a00000000000000000000000000000000000000000000000000000000000000000").unwrap();
let r = Receipt::new(
x!("2f697d671e9ae4ee24a43c4b0d7e15f1cb4ba6de1561120d43b9a4e8c4a8a6ee"),
x!(0x40cae),
vec![LogEntry::new(
x!("dcf421d093428b096ca501a7cd1a740855a7976f"),
vec![],
vec![0u8; 32]
)]
);
assert_eq!(&encode(&r)[..], &expected[..]);
}

View File

@ -84,7 +84,7 @@ pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec<String> {
declare_test!{StateTests_stBlockHashTest, "StateTests/stBlockHashTest"}
declare_test!{StateTests_stCallCodes, "StateTests/stCallCodes"}
//declare_test!{StateTests_stCallCreateCallCodeTest, "StateTests/stCallCreateCallCodeTest"}
declare_test!{StateTests_stCallCreateCallCodeTest, "StateTests/stCallCreateCallCodeTest"}
declare_test!{StateTests_stDelegatecallTest, "StateTests/stDelegatecallTest"}
declare_test!{StateTests_stExample, "StateTests/stExample"}
declare_test!{StateTests_stInitCodeTest, "StateTests/stInitCodeTest"}
@ -297,7 +297,7 @@ declare_test!{StateTests_RandomTests_st201503181357CPPJIT, "StateTests/RandomTes
declare_test!{StateTests_RandomTests_st201503181358CPPJIT, "StateTests/RandomTests/st201503181358CPPJIT"}
declare_test!{StateTests_RandomTests_st201503181358GO, "StateTests/RandomTests/st201503181358GO"}
declare_test!{StateTests_RandomTests_st201503181359GO, "StateTests/RandomTests/st201503181359GO"}
//declare_test!{StateTests_RandomTests_st201503181402CPPJIT, "StateTests/RandomTests/st201503181402CPPJIT"}
declare_test!{StateTests_RandomTests_st201503181402CPPJIT, "StateTests/RandomTests/st201503181402CPPJIT"}
declare_test!{StateTests_RandomTests_st201503181403GO, "StateTests/RandomTests/st201503181403GO"}
declare_test!{StateTests_RandomTests_st201503181406CPPJIT, "StateTests/RandomTests/st201503181406CPPJIT"}
declare_test!{StateTests_RandomTests_st201503181406GO, "StateTests/RandomTests/st201503181406GO"}
@ -569,7 +569,7 @@ declare_test!{StateTests_RandomTests_st201503181929GO, "StateTests/RandomTests/s
declare_test!{StateTests_RandomTests_st201503181931CPPJIT, "StateTests/RandomTests/st201503181931CPPJIT"}
declare_test!{StateTests_RandomTests_st201503181931GO, "StateTests/RandomTests/st201503181931GO"}
declare_test!{StateTests_RandomTests_st201503181931PYTHON, "StateTests/RandomTests/st201503181931PYTHON"}
//declare_test!{StateTests_RandomTests_st201503191646GO, "StateTests/RandomTests/st201503191646GO"}
declare_test!{StateTests_RandomTests_st201503191646GO, "StateTests/RandomTests/st201503191646GO"}
declare_test!{StateTests_RandomTests_st201503200837JS, "StateTests/RandomTests/st201503200837JS"}
declare_test!{StateTests_RandomTests_st201503200838JS, "StateTests/RandomTests/st201503200838JS"}
declare_test!{StateTests_RandomTests_st201503200841JS, "StateTests/RandomTests/st201503200841JS"}

View File

@ -12,6 +12,7 @@ macro_rules! declare_test {
#[ignore]
#[test]
#[allow(non_snake_case)]
#[cfg(feature="json-tests")]
fn $id() {
test!($name);
}
@ -20,6 +21,7 @@ macro_rules! declare_test {
#[cfg(feature = "test-heavy")]
#[test]
#[allow(non_snake_case)]
#[cfg(feature="json-tests")]
fn $id() {
test!($name);
}
@ -27,6 +29,7 @@ macro_rules! declare_test {
($id: ident, $name: expr) => {
#[test]
#[allow(non_snake_case)]
#[cfg(feature="json-tests")]
fn $id() {
test!($name);
}

View File

@ -147,14 +147,14 @@ pub fn verify_block_final(expected: &Header, got: &Header) -> Result<(), Error>
if expected.gas_used != got.gas_used {
return Err(From::from(BlockError::InvalidGasUsed(Mismatch { expected: expected.gas_used, found: got.gas_used })))
}
if expected.receipts_root != got.receipts_root {
return Err(From::from(BlockError::InvalidReceiptsStateRoot(Mismatch { expected: expected.receipts_root.clone(), found: got.receipts_root.clone() })))
if expected.log_bloom != got.log_bloom {
return Err(From::from(BlockError::InvalidLogBloom(Mismatch { expected: expected.log_bloom.clone(), found: got.log_bloom.clone() })))
}
if expected.state_root != got.state_root {
return Err(From::from(BlockError::InvalidStateRoot(Mismatch { expected: expected.state_root.clone(), found: got.state_root.clone() })))
}
if expected.log_bloom != got.log_bloom {
return Err(From::from(BlockError::InvalidLogBloom(Mismatch { expected: expected.log_bloom.clone(), found: got.log_bloom.clone() })))
if expected.receipts_root != got.receipts_root {
return Err(From::from(BlockError::InvalidReceiptsStateRoot(Mismatch { expected: expected.receipts_root.clone(), found: got.receipts_root.clone() })))
}
Ok(())
}

View File

@ -14,6 +14,7 @@ serde_json = "0.6.0"
jsonrpc-core = "1.1"
jsonrpc-http-server = "1.1"
ethcore-util = { path = "../util" }
ethcore = { path = ".." }
ethcore = { path = "../ethcore" }
ethsync = { path = "../sync" }
clippy = "0.0.37"

View File

@ -10,6 +10,7 @@ extern crate jsonrpc_core;
extern crate jsonrpc_http_server;
extern crate ethcore_util as util;
extern crate ethcore;
extern crate ethsync;
use self::jsonrpc_core::{IoHandler, IoDelegate};

View File

@ -1,7 +1,7 @@
//! Net rpc implementation.
use std::sync::Arc;
use jsonrpc_core::*;
use ethcore::sync::EthSync;
use ethsync::EthSync;
use v1::traits::Net;
/// Net rpc implementation.

View File

@ -59,6 +59,7 @@ impl Stream for RlpStream {
// we may finish, if the appended list len is equal 0
self.encoder.bytes.push(0xc0u8);
self.note_appended(1);
self.finished_list = true;
},
_ => {
let position = self.encoder.bytes.len();

View File

@ -405,3 +405,11 @@ fn test_rlp_2bytes_data_length_check()
assert_eq!(Err(DecoderError::RlpInconsistentLengthAndData), as_val);
}
#[test]
fn test_rlp_nested_empty_list_encode() {
let mut stream = RlpStream::new_list(2);
stream.append(&(Vec::new() as Vec<u32>));
stream.append(&40u32);
assert_eq!(stream.drain()[..], [0xc2u8, 0xc0u8, 40u8][..]);
}