Merge branch 'master' into simplified_block_opening

This commit is contained in:
debris 2016-06-13 15:11:14 +02:00
commit 12a76597d4
20 changed files with 157 additions and 156 deletions

43
Cargo.lock generated
View File

@ -3,7 +3,7 @@ name = "parity"
version = "1.2.0" version = "1.2.0"
dependencies = [ dependencies = [
"ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.76 (registry+https://github.com/rust-lang/crates.io-index)",
"ctrlc 1.1.1 (git+https://github.com/ethcore/rust-ctrlc.git)", "ctrlc 1.1.1 (git+https://github.com/ethcore/rust-ctrlc.git)",
"daemonize 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "daemonize 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"docopt 0.6.80 (registry+https://github.com/rust-lang/crates.io-index)", "docopt 0.6.80 (registry+https://github.com/rust-lang/crates.io-index)",
@ -130,23 +130,18 @@ dependencies = [
[[package]] [[package]]
name = "clippy" name = "clippy"
version = "0.0.71" version = "0.0.76"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"clippy_lints 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)", "clippy_lints 0.0.76 (registry+https://github.com/rust-lang/crates.io-index)",
"quine-mc_cluskey 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"regex-syntax 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
"semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "clippy_lints" name = "clippy_lints"
version = "0.0.71" version = "0.0.76"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"quine-mc_cluskey 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "quine-mc_cluskey 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"regex-syntax 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
@ -256,7 +251,7 @@ name = "ethcore"
version = "1.2.0" version = "1.2.0"
dependencies = [ dependencies = [
"bloomchain 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bloomchain 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.76 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ethash 1.2.0", "ethash 1.2.0",
@ -280,7 +275,7 @@ dependencies = [
name = "ethcore-dapps" name = "ethcore-dapps"
version = "1.2.0" version = "1.2.0"
dependencies = [ dependencies = [
"clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.76 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore-rpc 1.2.0", "ethcore-rpc 1.2.0",
"ethcore-util 1.2.0", "ethcore-util 1.2.0",
"hyper 0.9.3 (git+https://github.com/ethcore/hyper)", "hyper 0.9.3 (git+https://github.com/ethcore/hyper)",
@ -293,7 +288,7 @@ dependencies = [
"parity-dapps-dao 0.4.0 (git+https://github.com/ethcore/parity-dapps-dao-rs.git)", "parity-dapps-dao 0.4.0 (git+https://github.com/ethcore/parity-dapps-dao-rs.git)",
"parity-dapps-makerotc 0.3.0 (git+https://github.com/ethcore/parity-dapps-makerotc-rs.git)", "parity-dapps-makerotc 0.3.0 (git+https://github.com/ethcore/parity-dapps-makerotc-rs.git)",
"parity-dapps-status 0.5.0 (git+https://github.com/ethcore/parity-dapps-status-rs.git)", "parity-dapps-status 0.5.0 (git+https://github.com/ethcore/parity-dapps-status-rs.git)",
"parity-dapps-wallet 0.6.0 (git+https://github.com/ethcore/parity-dapps-wallet-rs.git)", "parity-dapps-wallet 0.6.1 (git+https://github.com/ethcore/parity-dapps-wallet-rs.git)",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_codegen 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", "serde_codegen 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)",
@ -344,7 +339,7 @@ dependencies = [
name = "ethcore-rpc" name = "ethcore-rpc"
version = "1.2.0" version = "1.2.0"
dependencies = [ dependencies = [
"clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.76 (registry+https://github.com/rust-lang/crates.io-index)",
"ethash 1.2.0", "ethash 1.2.0",
"ethcore 1.2.0", "ethcore 1.2.0",
"ethcore-devtools 1.2.0", "ethcore-devtools 1.2.0",
@ -367,7 +362,7 @@ dependencies = [
name = "ethcore-signer" name = "ethcore-signer"
version = "1.2.0" version = "1.2.0"
dependencies = [ dependencies = [
"clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.76 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore-rpc 1.2.0", "ethcore-rpc 1.2.0",
"ethcore-util 1.2.0", "ethcore-util 1.2.0",
@ -386,7 +381,7 @@ dependencies = [
"arrayvec 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "arrayvec 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"bigint 0.1.0", "bigint 0.1.0",
"chrono 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
"clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.76 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"elastic-array 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "elastic-array 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
@ -431,7 +426,7 @@ dependencies = [
name = "ethsync" name = "ethsync"
version = "1.2.0" version = "1.2.0"
dependencies = [ dependencies = [
"clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.76 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore 1.2.0", "ethcore 1.2.0",
"ethcore-util 1.2.0", "ethcore-util 1.2.0",
@ -606,7 +601,7 @@ dependencies = [
[[package]] [[package]]
name = "jsonrpc-http-server" name = "jsonrpc-http-server"
version = "5.1.0" version = "5.1.0"
source = "git+https://github.com/ethcore/jsonrpc-http-server.git#77dcac785c02c3a7622d36aa635ee80d63d0b20c" source = "git+https://github.com/ethcore/jsonrpc-http-server.git#6117b1d77b5a60d6fa2dc884f12aa7f5fd4585ca"
dependencies = [ dependencies = [
"hyper 0.9.3 (git+https://github.com/ethcore/hyper)", "hyper 0.9.3 (git+https://github.com/ethcore/hyper)",
"jsonrpc-core 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
@ -901,7 +896,7 @@ dependencies = [
[[package]] [[package]]
name = "parity-dapps-builtins" name = "parity-dapps-builtins"
version = "0.5.1" version = "0.5.1"
source = "git+https://github.com/ethcore/parity-dapps-builtins-rs.git#d3c95d62ffaa57016b162a9a9f0e6dd629dab423" source = "git+https://github.com/ethcore/parity-dapps-builtins-rs.git#b3970ff4686a12321365cfafba6552bfaa2e7874"
dependencies = [ dependencies = [
"parity-dapps 0.3.0 (git+https://github.com/ethcore/parity-dapps-rs.git)", "parity-dapps 0.3.0 (git+https://github.com/ethcore/parity-dapps-rs.git)",
] ]
@ -909,7 +904,7 @@ dependencies = [
[[package]] [[package]]
name = "parity-dapps-dao" name = "parity-dapps-dao"
version = "0.4.0" version = "0.4.0"
source = "git+https://github.com/ethcore/parity-dapps-dao-rs.git#18f4b839b20fbdf8e0d163e14d25aafee603ac4b" source = "git+https://github.com/ethcore/parity-dapps-dao-rs.git#dd6b9ca7c18fbfa714183a4f570bd75b8391c13d"
dependencies = [ dependencies = [
"parity-dapps 0.3.0 (git+https://github.com/ethcore/parity-dapps-rs.git)", "parity-dapps 0.3.0 (git+https://github.com/ethcore/parity-dapps-rs.git)",
] ]
@ -917,7 +912,7 @@ dependencies = [
[[package]] [[package]]
name = "parity-dapps-makerotc" name = "parity-dapps-makerotc"
version = "0.3.0" version = "0.3.0"
source = "git+https://github.com/ethcore/parity-dapps-makerotc-rs.git#7b771f217a3eefeb9a976c7ed470ca49fd9a9daa" source = "git+https://github.com/ethcore/parity-dapps-makerotc-rs.git#33568ac7209aa765c498bb2322e848f552656303"
dependencies = [ dependencies = [
"parity-dapps 0.3.0 (git+https://github.com/ethcore/parity-dapps-rs.git)", "parity-dapps 0.3.0 (git+https://github.com/ethcore/parity-dapps-rs.git)",
] ]
@ -932,8 +927,8 @@ dependencies = [
[[package]] [[package]]
name = "parity-dapps-wallet" name = "parity-dapps-wallet"
version = "0.6.0" version = "0.6.1"
source = "git+https://github.com/ethcore/parity-dapps-wallet-rs.git#ad23b093d47527333a262c95e6fb20a97d15d6e6" source = "git+https://github.com/ethcore/parity-dapps-wallet-rs.git#8923d4c73359c75ce04f0639bbcde46adb846b81"
dependencies = [ dependencies = [
"parity-dapps 0.3.0 (git+https://github.com/ethcore/parity-dapps-rs.git)", "parity-dapps 0.3.0 (git+https://github.com/ethcore/parity-dapps-rs.git)",
] ]
@ -941,7 +936,7 @@ dependencies = [
[[package]] [[package]]
name = "parity-minimal-sysui" name = "parity-minimal-sysui"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/ethcore/parity-dapps-minimal-sysui-rs.git#cb27ae09ee18773ccca6ba2ac74fa3128047a652" source = "git+https://github.com/ethcore/parity-dapps-minimal-sysui-rs.git#4c704913f671060bb0e43b5ce4a68d02281115d5"
[[package]] [[package]]
name = "phf" name = "phf"

View File

@ -23,7 +23,7 @@ daemonize = "0.2"
num_cpus = "0.2" num_cpus = "0.2"
number_prefix = "0.2" number_prefix = "0.2"
rpassword = "0.2.1" rpassword = "0.2.1"
clippy = { version = "0.0.71", optional = true} clippy = { version = "0.0.76", optional = true}
ethcore = { path = "ethcore" } ethcore = { path = "ethcore" }
ethcore-util = { path = "util" } ethcore-util = { path = "util" }
ethsync = { path = "sync" } ethsync = { path = "sync" }

View File

@ -28,7 +28,7 @@ parity-dapps-wallet = { git = "https://github.com/ethcore/parity-dapps-wallet-rs
parity-dapps-dao = { git = "https://github.com/ethcore/parity-dapps-dao-rs.git", version = "0.4.0", optional = true } parity-dapps-dao = { git = "https://github.com/ethcore/parity-dapps-dao-rs.git", version = "0.4.0", optional = true }
parity-dapps-makerotc = { git = "https://github.com/ethcore/parity-dapps-makerotc-rs.git", version = "0.3.0", optional = true } parity-dapps-makerotc = { git = "https://github.com/ethcore/parity-dapps-makerotc-rs.git", version = "0.3.0", optional = true }
mime_guess = { version = "1.6.1" } mime_guess = { version = "1.6.1" }
clippy = { version = "0.0.71", optional = true} clippy = { version = "0.0.76", optional = true}
[build-dependencies] [build-dependencies]
serde_codegen = { version = "0.7.0", optional = true } serde_codegen = { version = "0.7.0", optional = true }

View File

@ -22,7 +22,7 @@ ethcore-util = { path = "../util" }
evmjit = { path = "../evmjit", optional = true } evmjit = { path = "../evmjit", optional = true }
ethash = { path = "../ethash" } ethash = { path = "../ethash" }
num_cpus = "0.2" num_cpus = "0.2"
clippy = { version = "0.0.71", optional = true} clippy = { version = "0.0.76", optional = true}
crossbeam = "0.2.9" crossbeam = "0.2.9"
lazy_static = "0.1" lazy_static = "0.1"
ethcore-devtools = { path = "../devtools" } ethcore-devtools = { path = "../devtools" }

View File

@ -15,7 +15,7 @@ with-syntex = ["quasi/with-syntex", "quasi_codegen", "quasi_codegen/with-syntex"
[build-dependencies] [build-dependencies]
quasi_codegen = { version = "0.11", optional = true } quasi_codegen = { version = "0.11", optional = true }
syntex = { version = "*", optional = true } syntex = { version = "0.33", optional = true }
[dependencies] [dependencies]
aster = { version = "0.17", default-features = false } aster = { version = "0.17", default-features = false }

View File

@ -89,7 +89,7 @@ fn serialize_item(
let (size_expr, read_expr, write_expr) = let (size_expr, read_expr, write_expr) =
(binary_expressions.size, binary_expressions.read, binary_expressions.write); (binary_expressions.size, binary_expressions.read, binary_expressions.write);
Ok(quote_item!(cx, match quote_item!(cx,
impl $generics ::ipc::BinaryConvertable for $ty $where_clause { impl $generics ::ipc::BinaryConvertable for $ty $where_clause {
fn size(&self) -> usize { fn size(&self) -> usize {
$size_expr $size_expr
@ -106,8 +106,16 @@ fn serialize_item(
fn len_params() -> usize { fn len_params() -> usize {
1 1
} }
})
{
Some(item) => Ok(item),
None => {
cx.span_err(
item.span,
"syntax error expanding serialization implementation");
Err(Error)
}
} }
).unwrap())
} }
#[allow(unreachable_code)] #[allow(unreachable_code)]

View File

@ -19,20 +19,20 @@ extern crate ethcore_ipc_codegen as codegen;
use std::env; use std::env;
use std::path::Path; use std::path::Path;
use std::process::exit;
pub fn main() { pub fn main() {
let out_dir = env::var_os("OUT_DIR").unwrap(); let out_dir = env::var_os("OUT_DIR").unwrap();
// ipc pass // rpc pass
{ if {
let src = Path::new("nested.rs.in"); let src = Path::new("nested.rs.in");
let dst = Path::new(&out_dir).join("nested_ipc.rs"); let dst = Path::new(&out_dir).join("nested_ipc.rs");
let mut registry = syntex::Registry::new(); let mut registry = syntex::Registry::new();
codegen::register(&mut registry); codegen::register(&mut registry);
registry.expand("", &src, &dst).unwrap(); registry.expand("", &src, &dst).is_ok()
} }
// serialization pass
// serde pass
{ {
let src = Path::new(&out_dir).join("nested_ipc.rs"); let src = Path::new(&out_dir).join("nested_ipc.rs");
let dst = Path::new(&out_dir).join("nested_cg.rs"); let dst = Path::new(&out_dir).join("nested_cg.rs");
@ -41,16 +41,15 @@ pub fn main() {
registry.expand("", &src, &dst).unwrap(); registry.expand("", &src, &dst).unwrap();
} }
// ipc pass // rpc pass
{ if {
let src = Path::new("service.rs.in"); let src = Path::new("service.rs.in");
let dst = Path::new(&out_dir).join("service_ipc.rs"); let dst = Path::new(&out_dir).join("service_ipc.rs");
let mut registry = syntex::Registry::new(); let mut registry = syntex::Registry::new();
codegen::register(&mut registry); codegen::register(&mut registry);
registry.expand("", &src, &dst).unwrap(); registry.expand("", &src, &dst).is_ok()
} }
// serialization pass
// serde pass
{ {
let src = Path::new(&out_dir).join("service_ipc.rs"); let src = Path::new(&out_dir).join("service_ipc.rs");
let dst = Path::new(&out_dir).join("service_cg.rs"); let dst = Path::new(&out_dir).join("service_cg.rs");
@ -59,13 +58,15 @@ pub fn main() {
registry.expand("", &src, &dst).unwrap(); registry.expand("", &src, &dst).unwrap();
} }
// rpc pass
// ipc pass
{ {
let src = Path::new("binary.rs.in"); let src = Path::new("binary.rs.in");
let dst = Path::new(&out_dir).join("binary.rs"); let dst = Path::new(&out_dir).join("binary.rs");
let mut registry = syntex::Registry::new(); let mut registry = syntex::Registry::new();
codegen::register(&mut registry); codegen::register(&mut registry);
registry.expand("", &src, &dst).unwrap(); if let Err(err_msg) = registry.expand("", &src, &dst) {
println!("error: {}", err_msg);
exit(1);
}
} }
} }

View File

@ -10,7 +10,7 @@ rustc-serialize = "0.3"
serde = "0.7.0" serde = "0.7.0"
serde_json = "0.7.0" serde_json = "0.7.0"
serde_macros = { version = "0.7.0", optional = true } serde_macros = { version = "0.7.0", optional = true }
clippy = { version = "0.0.71", optional = true} clippy = { version = "0.0.76", optional = true}
[build-dependencies] [build-dependencies]
serde_codegen = { version = "0.7.0", optional = true } serde_codegen = { version = "0.7.0", optional = true }

View File

@ -360,6 +360,14 @@ impl Configuration {
if self.args.flag_geth { self.geth_ipc_path() } if self.args.flag_geth { self.geth_ipc_path() }
else { Configuration::replace_home(&self.args.flag_ipcpath.clone().unwrap_or(self.args.flag_ipc_path.clone())) } else { Configuration::replace_home(&self.args.flag_ipcpath.clone().unwrap_or(self.args.flag_ipc_path.clone())) }
} }
pub fn signer_port(&self) -> Option<u16> {
if self.args.flag_signer {
Some(self.args.flag_signer_port)
} else {
None
}
}
} }
#[cfg(test)] #[cfg(test)]

View File

@ -201,7 +201,7 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig)
let sync = EthSync::register(service.network(), sync_config, client.clone()); let sync = EthSync::register(service.network(), sync_config, client.clone());
let deps_for_rpc_apis = Arc::new(rpc_apis::Dependencies { let deps_for_rpc_apis = Arc::new(rpc_apis::Dependencies {
signer_enabled: conf.args.flag_signer, signer_port: conf.signer_port(),
signer_queue: Arc::new(rpc_apis::ConfirmationsQueue::default()), signer_queue: Arc::new(rpc_apis::ConfirmationsQueue::default()),
client: client.clone(), client: client.clone(),
sync: sync.clone(), sync: sync.clone(),
@ -244,7 +244,7 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig)
// Set up a signer // Set up a signer
let signer_server = signer::start(signer::Configuration { let signer_server = signer::start(signer::Configuration {
enabled: deps_for_rpc_apis.signer_enabled, enabled: deps_for_rpc_apis.signer_port.is_some(),
port: conf.args.flag_signer_port, port: conf.args.flag_signer_port,
signer_path: conf.directories().signer, signer_path: conf.directories().signer,
}, signer::Dependencies { }, signer::Dependencies {

View File

@ -79,7 +79,7 @@ impl FromStr for Api {
} }
pub struct Dependencies { pub struct Dependencies {
pub signer_enabled: bool, pub signer_port: Option<u16>,
pub signer_queue: Arc<ConfirmationsQueue>, pub signer_queue: Arc<ConfirmationsQueue>,
pub client: Arc<Client>, pub client: Arc<Client>,
pub sync: Arc<EthSync>, pub sync: Arc<EthSync>,
@ -146,14 +146,14 @@ pub fn setup_rpc<T: Extendable>(server: T, deps: Arc<Dependencies>, apis: ApiSet
server.add_delegate(EthClient::new(&deps.client, &deps.sync, &deps.secret_store, &deps.miner, &deps.external_miner).to_delegate()); server.add_delegate(EthClient::new(&deps.client, &deps.sync, &deps.secret_store, &deps.miner, &deps.external_miner).to_delegate());
server.add_delegate(EthFilterClient::new(&deps.client, &deps.miner).to_delegate()); server.add_delegate(EthFilterClient::new(&deps.client, &deps.miner).to_delegate());
if deps.signer_enabled { if deps.signer_port.is_some() {
server.add_delegate(EthSigningQueueClient::new(&deps.signer_queue).to_delegate()); server.add_delegate(EthSigningQueueClient::new(&deps.signer_queue).to_delegate());
} else { } else {
server.add_delegate(EthSigningUnsafeClient::new(&deps.client, &deps.secret_store, &deps.miner).to_delegate()); server.add_delegate(EthSigningUnsafeClient::new(&deps.client, &deps.secret_store, &deps.miner).to_delegate());
} }
}, },
Api::Personal => { Api::Personal => {
server.add_delegate(PersonalClient::new(&deps.secret_store, &deps.client, &deps.miner, deps.signer_enabled).to_delegate()); server.add_delegate(PersonalClient::new(&deps.secret_store, &deps.client, &deps.miner, deps.signer_port).to_delegate());
}, },
Api::Signer => { Api::Signer => {
server.add_delegate(SignerClient::new(&deps.secret_store, &deps.client, &deps.miner, &deps.signer_queue).to_delegate()); server.add_delegate(SignerClient::new(&deps.secret_store, &deps.client, &deps.miner, &deps.signer_queue).to_delegate());

View File

@ -23,7 +23,7 @@ ethcore-devtools = { path = "../devtools" }
rustc-serialize = "0.3" rustc-serialize = "0.3"
transient-hashmap = "0.1" transient-hashmap = "0.1"
serde_macros = { version = "0.7.0", optional = true } serde_macros = { version = "0.7.0", optional = true }
clippy = { version = "0.0.71", optional = true} clippy = { version = "0.0.76", optional = true}
json-ipc-server = { git = "https://github.com/ethcore/json-ipc-server.git" } json-ipc-server = { git = "https://github.com/ethcore/json-ipc-server.git" }
[build-dependencies] [build-dependencies]

View File

@ -75,7 +75,11 @@ impl RpcServer {
/// Start http server asynchronously and returns result with `Server` handle on success or an error. /// Start http server asynchronously and returns result with `Server` handle on success or an error.
pub fn start_http(&self, addr: &SocketAddr, cors_domains: Vec<String>) -> Result<Server, RpcServerError> { pub fn start_http(&self, addr: &SocketAddr, cors_domains: Vec<String>) -> Result<Server, RpcServerError> {
let cors_domains = cors_domains.into_iter() let cors_domains = cors_domains.into_iter()
.map(jsonrpc_http_server::AccessControlAllowOrigin::Value) .map(|v| match v.as_str() {
"*" => jsonrpc_http_server::AccessControlAllowOrigin::Any,
"null" => jsonrpc_http_server::AccessControlAllowOrigin::Null,
v => jsonrpc_http_server::AccessControlAllowOrigin::Value(v.into()),
})
.collect(); .collect();
Server::start(addr, self.handler.clone(), cors_domains) Server::start(addr, self.handler.clone(), cors_domains)
} }

View File

@ -31,18 +31,18 @@ pub struct PersonalClient<A, C, M>
accounts: Weak<A>, accounts: Weak<A>,
client: Weak<C>, client: Weak<C>,
miner: Weak<M>, miner: Weak<M>,
signer_enabled: bool, signer_port: Option<u16>,
} }
impl<A, C, M> PersonalClient<A, C, M> impl<A, C, M> PersonalClient<A, C, M>
where A: AccountProvider, C: MiningBlockChainClient, M: MinerService { where A: AccountProvider, C: MiningBlockChainClient, M: MinerService {
/// Creates new PersonalClient /// Creates new PersonalClient
pub fn new(store: &Arc<A>, client: &Arc<C>, miner: &Arc<M>, signer_enabled: bool) -> Self { pub fn new(store: &Arc<A>, client: &Arc<C>, miner: &Arc<M>, signer_port: Option<u16>) -> Self {
PersonalClient { PersonalClient {
accounts: Arc::downgrade(store), accounts: Arc::downgrade(store),
client: Arc::downgrade(client), client: Arc::downgrade(client),
miner: Arc::downgrade(miner), miner: Arc::downgrade(miner),
signer_enabled: signer_enabled, signer_port: signer_port,
} }
} }
} }
@ -51,7 +51,9 @@ impl<A: 'static, C: 'static, M: 'static> Personal for PersonalClient<A, C, M>
where A: AccountProvider, C: MiningBlockChainClient, M: MinerService { where A: AccountProvider, C: MiningBlockChainClient, M: MinerService {
fn signer_enabled(&self, _: Params) -> Result<Value, Error> { fn signer_enabled(&self, _: Params) -> Result<Value, Error> {
to_value(&self.signer_enabled) self.signer_port
.map(|v| to_value(&v))
.unwrap_or_else(|| to_value(&false))
} }
fn accounts(&self, _: Params) -> Result<Value, Error> { fn accounts(&self, _: Params) -> Result<Value, Error> {

View File

@ -49,11 +49,11 @@ fn miner_service() -> Arc<TestMinerService> {
Arc::new(TestMinerService::default()) Arc::new(TestMinerService::default())
} }
fn setup() -> PersonalTester { fn setup(signer: Option<u16>) -> PersonalTester {
let accounts = accounts_provider(); let accounts = accounts_provider();
let client = blockchain_client(); let client = blockchain_client();
let miner = miner_service(); let miner = miner_service();
let personal = PersonalClient::new(&accounts, &client, &miner, false); let personal = PersonalClient::new(&accounts, &client, &miner, signer);
let io = IoHandler::new(); let io = IoHandler::new();
io.add_delegate(personal.to_delegate()); io.add_delegate(personal.to_delegate());
@ -71,7 +71,7 @@ fn setup() -> PersonalTester {
#[test] #[test]
fn should_return_false_if_signer_is_disabled() { fn should_return_false_if_signer_is_disabled() {
// given // given
let tester = setup(); let tester = setup(None);
// when // when
let request = r#"{"jsonrpc": "2.0", "method": "personal_signerEnabled", "params": [], "id": 1}"#; let request = r#"{"jsonrpc": "2.0", "method": "personal_signerEnabled", "params": [], "id": 1}"#;
@ -82,9 +82,23 @@ fn should_return_false_if_signer_is_disabled() {
assert_eq!(tester.io.handle_request(request), Some(response.to_owned())); assert_eq!(tester.io.handle_request(request), Some(response.to_owned()));
} }
#[test]
fn should_return_port_number_if_signer_is_enabled() {
// given
let tester = setup(Some(8180));
// when
let request = r#"{"jsonrpc": "2.0", "method": "personal_signerEnabled", "params": [], "id": 1}"#;
let response = r#"{"jsonrpc":"2.0","result":8180,"id":1}"#;
// then
assert_eq!(tester.io.handle_request(request), Some(response.to_owned()));
}
#[test] #[test]
fn accounts() { fn accounts() {
let tester = setup(); let tester = setup(None);
tester.accounts.accounts tester.accounts.accounts
.write() .write()
.unwrap() .unwrap()
@ -98,7 +112,7 @@ fn accounts() {
#[test] #[test]
fn new_account() { fn new_account() {
let tester = setup(); let tester = setup(None);
let request = r#"{"jsonrpc": "2.0", "method": "personal_newAccount", "params": ["pass"], "id": 1}"#; let request = r#"{"jsonrpc": "2.0", "method": "personal_newAccount", "params": ["pass"], "id": 1}"#;
let res = tester.io.handle_request(request); let res = tester.io.handle_request(request);
@ -122,7 +136,7 @@ fn sign_and_send_transaction_with_invalid_password() {
let account = TestAccount::new("password123"); let account = TestAccount::new("password123");
let address = account.address(); let address = account.address();
let tester = setup(); let tester = setup(None);
tester.accounts.accounts.write().unwrap().insert(address.clone(), account); tester.accounts.accounts.write().unwrap().insert(address.clone(), account);
let request = r#"{ let request = r#"{
"jsonrpc": "2.0", "jsonrpc": "2.0",
@ -148,7 +162,7 @@ fn sign_and_send_transaction() {
let address = account.address(); let address = account.address();
let secret = account.secret.clone(); let secret = account.secret.clone();
let tester = setup(); let tester = setup(None);
tester.accounts.accounts.write().unwrap().insert(address.clone(), account); tester.accounts.accounts.write().unwrap().insert(address.clone(), account);
let request = r#"{ let request = r#"{
"jsonrpc": "2.0", "jsonrpc": "2.0",

View File

@ -20,7 +20,7 @@ ethcore-util = { path = "../util" }
ethcore-rpc = { path = "../rpc" } ethcore-rpc = { path = "../rpc" }
parity-minimal-sysui = { git = "https://github.com/ethcore/parity-dapps-minimal-sysui-rs.git" } parity-minimal-sysui = { git = "https://github.com/ethcore/parity-dapps-minimal-sysui-rs.git" }
clippy = { version = "0.0.71", optional = true} clippy = { version = "0.0.76", optional = true}
[features] [features]
dev = ["clippy"] dev = ["clippy"]

View File

@ -10,7 +10,7 @@ authors = ["Ethcore <admin@ethcore.io"]
[dependencies] [dependencies]
ethcore-util = { path = "../util" } ethcore-util = { path = "../util" }
ethcore = { path = "../ethcore" } ethcore = { path = "../ethcore" }
clippy = { version = "0.0.71", optional = true} clippy = { version = "0.0.76", optional = true}
log = "0.3" log = "0.3"
env_logger = "0.3" env_logger = "0.3"
time = "0.1.34" time = "0.1.34"

View File

@ -28,7 +28,7 @@ crossbeam = "0.2"
slab = "0.2" slab = "0.2"
sha3 = { path = "sha3" } sha3 = { path = "sha3" }
serde = "0.7.0" serde = "0.7.0"
clippy = { version = "0.0.71", optional = true} clippy = { version = "0.0.76", optional = true}
json-tests = { path = "json-tests" } json-tests = { path = "json-tests" }
igd = "0.4.2" igd = "0.4.2"
ethcore-devtools = { path = "../devtools" } ethcore-devtools = { path = "../devtools" }

View File

@ -91,9 +91,9 @@ macro_rules! uint_overflowing_add_reg {
#[cfg(all(asm_available, target_arch="x86_64"))] #[cfg(all(asm_available, target_arch="x86_64"))]
macro_rules! uint_overflowing_add { macro_rules! uint_overflowing_add {
(U256, $n_words: expr, $self_expr: expr, $other: expr) => ({ (U256, $n_words: expr, $self_expr: expr, $other: expr) => ({
let mut result: [u64; 4] = unsafe { mem::uninitialized() }; let mut result: [u64; $n_words] = unsafe { mem::uninitialized() };
let self_t: &[u64; 4] = unsafe { &mem::transmute($self_expr) }; let self_t: &[u64; $n_words] = &$self_expr.0;
let other_t: &[u64; 4] = unsafe { &mem::transmute($other) }; let other_t: &[u64; $n_words] = &$other.0;
let overflow: u8; let overflow: u8;
unsafe { unsafe {
@ -114,9 +114,9 @@ macro_rules! uint_overflowing_add {
(U256(result), overflow != 0) (U256(result), overflow != 0)
}); });
(U512, $n_words: expr, $self_expr: expr, $other: expr) => ({ (U512, $n_words: expr, $self_expr: expr, $other: expr) => ({
let mut result: [u64; 8] = unsafe { mem::uninitialized() }; let mut result: [u64; $n_words] = unsafe { mem::uninitialized() };
let self_t: &[u64; 8] = unsafe { &mem::transmute($self_expr) }; let self_t: &[u64; $n_words] = &$self_expr.0;
let other_t: &[u64; 8] = unsafe { &mem::transmute($other) }; let other_t: &[u64; $n_words] = &$other.0;
let overflow: u8; let overflow: u8;
@ -195,9 +195,9 @@ macro_rules! uint_overflowing_sub_reg {
#[cfg(all(asm_available, target_arch="x86_64"))] #[cfg(all(asm_available, target_arch="x86_64"))]
macro_rules! uint_overflowing_sub { macro_rules! uint_overflowing_sub {
(U256, $n_words: expr, $self_expr: expr, $other: expr) => ({ (U256, $n_words: expr, $self_expr: expr, $other: expr) => ({
let mut result: [u64; 4] = unsafe { mem::uninitialized() }; let mut result: [u64; $n_words] = unsafe { mem::uninitialized() };
let self_t: &[u64; 4] = unsafe { &mem::transmute($self_expr) }; let self_t: &[u64; $n_words] = &$self_expr.0;
let other_t: &[u64; 4] = unsafe { &mem::transmute($other) }; let other_t: &[u64; $n_words] = &$other.0;
let overflow: u8; let overflow: u8;
unsafe { unsafe {
@ -217,9 +217,9 @@ macro_rules! uint_overflowing_sub {
(U256(result), overflow != 0) (U256(result), overflow != 0)
}); });
(U512, $n_words: expr, $self_expr: expr, $other: expr) => ({ (U512, $n_words: expr, $self_expr: expr, $other: expr) => ({
let mut result: [u64; 8] = unsafe { mem::uninitialized() }; let mut result: [u64; $n_words] = unsafe { mem::uninitialized() };
let self_t: &[u64; 8] = unsafe { &mem::transmute($self_expr) }; let self_t: &[u64; $n_words] = &$self_expr.0;
let other_t: &[u64; 8] = unsafe { &mem::transmute($other) }; let other_t: &[u64; $n_words] = &$other.0;
let overflow: u8; let overflow: u8;
@ -269,9 +269,9 @@ macro_rules! uint_overflowing_sub {
#[cfg(all(asm_available, target_arch="x86_64"))] #[cfg(all(asm_available, target_arch="x86_64"))]
macro_rules! uint_overflowing_mul { macro_rules! uint_overflowing_mul {
(U256, $n_words: expr, $self_expr: expr, $other: expr) => ({ (U256, $n_words: expr, $self_expr: expr, $other: expr) => ({
let mut result: [u64; 4] = unsafe { mem::uninitialized() }; let mut result: [u64; $n_words] = unsafe { mem::uninitialized() };
let self_t: &[u64; 4] = unsafe { &mem::transmute($self_expr) }; let self_t: &[u64; $n_words] = &$self_expr.0;
let other_t: &[u64; 4] = unsafe { &mem::transmute($other) }; let other_t: &[u64; $n_words] = &$other.0;
let overflow: u64; let overflow: u64;
unsafe { unsafe {
@ -548,6 +548,7 @@ pub trait Uint: Sized + Default + FromStr + From<u64> + fmt::Debug + fmt::Displa
macro_rules! construct_uint { macro_rules! construct_uint {
($name:ident, $n_words:expr) => ( ($name:ident, $n_words:expr) => (
/// Little-endian large integer type /// Little-endian large integer type
#[repr(C)]
#[derive(Copy, Clone, Eq, PartialEq)] #[derive(Copy, Clone, Eq, PartialEq)]
pub struct $name(pub [u64; $n_words]); pub struct $name(pub [u64; $n_words]);
@ -1132,8 +1133,8 @@ impl U256 {
/// No overflow possible /// No overflow possible
#[cfg(all(asm_available, target_arch="x86_64"))] #[cfg(all(asm_available, target_arch="x86_64"))]
pub fn full_mul(self, other: U256) -> U512 { pub fn full_mul(self, other: U256) -> U512 {
let self_t: &[u64; 4] = unsafe { &mem::transmute(self) }; let self_t: &[u64; 4] = &self.0;
let other_t: &[u64; 4] = unsafe { &mem::transmute(other) }; let other_t: &[u64; 4] = &other.0;
let mut result: [u64; 8] = unsafe { mem::uninitialized() }; let mut result: [u64; 8] = unsafe { mem::uninitialized() };
unsafe { unsafe {
asm!(" asm!("

View File

@ -143,6 +143,7 @@ macro_rules! impl_hash {
} }
min min
} }
fn from_slice(src: &[u8]) -> Self { fn from_slice(src: &[u8]) -> Self {
let mut r = Self::new(); let mut r = Self::new();
r.clone_from_slice(src); r.clone_from_slice(src);
@ -150,24 +151,15 @@ macro_rules! impl_hash {
} }
fn copy_to(&self, dest: &mut[u8]) { fn copy_to(&self, dest: &mut[u8]) {
unsafe {
let min = ::std::cmp::min($size, dest.len()); let min = ::std::cmp::min($size, dest.len());
::std::ptr::copy(self.0.as_ptr(), dest.as_mut_ptr(), min); dest[..min].copy_from_slice(&self.0[..min]);
}
} }
fn shift_bloomed<'a, T>(&'a mut self, b: &T) -> &'a mut Self where T: FixedHash { fn shift_bloomed<'a, T>(&'a mut self, b: &T) -> &'a mut Self where T: FixedHash {
let bp: Self = b.bloom_part($size); let bp: Self = b.bloom_part($size);
let new_self = &bp | self; let new_self = &bp | self;
// impl |= instead self.0 = new_self.0;
// TODO: that's done now!
unsafe {
use std::{mem, ptr};
ptr::copy(new_self.0.as_ptr(), self.0.as_mut_ptr(), mem::size_of::<Self>());
}
self self
} }
@ -179,7 +171,6 @@ macro_rules! impl_hash {
let bloom_bits = m * 8; let bloom_bits = m * 8;
let mask = bloom_bits - 1; let mask = bloom_bits - 1;
let bloom_bytes = (log2(bloom_bits) + 7) / 8; let bloom_bytes = (log2(bloom_bits) + 7) / 8;
//println!("bb: {}", bloom_bytes);
// must be a power of 2 // must be a power of 2
assert_eq!(m & (m - 1), 0); assert_eq!(m & (m - 1), 0);
@ -316,14 +307,11 @@ macro_rules! impl_hash {
#[cfg_attr(feature="dev", allow(expl_impl_clone_on_copy))] #[cfg_attr(feature="dev", allow(expl_impl_clone_on_copy))]
impl Clone for $from { impl Clone for $from {
fn clone(&self) -> $from { fn clone(&self) -> $from {
unsafe { let mut ret = $from::new();
use std::{mem, ptr}; ret.0.copy_from_slice(&self.0);
let mut ret: $from = mem::uninitialized();
ptr::copy(self.0.as_ptr(), ret.0.as_mut_ptr(), mem::size_of::<$from>());
ret ret
} }
} }
}
impl PartialEq for $from { impl PartialEq for $from {
fn eq(&self, other: &Self) -> bool { fn eq(&self, other: &Self) -> bool {
@ -404,16 +392,13 @@ macro_rules! impl_hash {
type Output = $from; type Output = $from;
fn bitor(self, rhs: Self) -> Self::Output { fn bitor(self, rhs: Self) -> Self::Output {
unsafe { let mut ret: $from = $from::default();
use std::mem;
let mut ret: $from = mem::uninitialized();
for i in 0..$size { for i in 0..$size {
ret.0[i] = self.0[i] | rhs.0[i]; ret.0[i] = self.0[i] | rhs.0[i];
} }
ret ret
} }
} }
}
/// Moving `BitOr` /// Moving `BitOr`
impl BitOr for $from { impl BitOr for $from {
@ -429,16 +414,13 @@ macro_rules! impl_hash {
type Output = $from; type Output = $from;
fn bitand(self, rhs: Self) -> Self::Output { fn bitand(self, rhs: Self) -> Self::Output {
unsafe { let mut ret: $from = $from::default();
use std::mem;
let mut ret: $from = mem::uninitialized();
for i in 0..$size { for i in 0..$size {
ret.0[i] = self.0[i] & rhs.0[i]; ret.0[i] = self.0[i] & rhs.0[i];
} }
ret ret
} }
} }
}
/// Moving `BitAnd` /// Moving `BitAnd`
impl BitAnd for $from { impl BitAnd for $from {
@ -454,16 +436,13 @@ macro_rules! impl_hash {
type Output = $from; type Output = $from;
fn bitxor(self, rhs: Self) -> Self::Output { fn bitxor(self, rhs: Self) -> Self::Output {
unsafe { let mut ret: $from = $from::default();
use std::mem;
let mut ret: $from = mem::uninitialized();
for i in 0..$size { for i in 0..$size {
ret.0[i] = self.0[i] ^ rhs.0[i]; ret.0[i] = self.0[i] ^ rhs.0[i];
} }
ret ret
} }
} }
}
/// Moving `BitXor` /// Moving `BitXor`
impl BitXor for $from { impl BitXor for $from {
@ -516,22 +495,18 @@ macro_rules! impl_hash {
impl From<U256> for H256 { impl From<U256> for H256 {
fn from(value: U256) -> H256 { fn from(value: U256) -> H256 {
unsafe { let mut ret = H256::new();
let mut ret: H256 = ::std::mem::uninitialized();
value.to_raw_bytes(&mut ret); value.to_raw_bytes(&mut ret);
ret ret
} }
}
} }
impl<'a> From<&'a U256> for H256 { impl<'a> From<&'a U256> for H256 {
fn from(value: &'a U256) -> H256 { fn from(value: &'a U256) -> H256 {
unsafe { let mut ret: H256 = H256::new();
let mut ret: H256 = ::std::mem::uninitialized();
value.to_raw_bytes(&mut ret); value.to_raw_bytes(&mut ret);
ret ret
} }
}
} }
impl From<H256> for U256 { impl From<H256> for U256 {
@ -548,52 +523,45 @@ impl<'a> From<&'a H256> for U256 {
impl From<H256> for Address { impl From<H256> for Address {
fn from(value: H256) -> Address { fn from(value: H256) -> Address {
unsafe { let mut ret = Address::new();
let mut ret: Address = ::std::mem::uninitialized(); ret.0.copy_from_slice(&value[12..32]);
::std::ptr::copy(value.as_ptr().offset(12), ret.as_mut_ptr(), 20);
ret ret
} }
}
} }
impl From<H256> for H64 { impl From<H256> for H64 {
fn from(value: H256) -> H64 { fn from(value: H256) -> H64 {
unsafe { let mut ret = H64::new();
let mut ret: H64 = ::std::mem::uninitialized(); ret.0.copy_from_slice(&value[20..28]);
::std::ptr::copy(value.as_ptr().offset(20), ret.as_mut_ptr(), 8);
ret ret
} }
}
} }
/* /*
impl<'a> From<&'a H256> for Address { impl<'a> From<&'a H256> for Address {
fn from(value: &'a H256) -> Address { fn from(value: &'a H256) -> Address {
unsafe { let mut ret = Address::new();
let mut ret: Address = ::std::mem::uninitialized(); ret.0.copy_from_slice(&value[12..32]);
::std::ptr::copy(value.as_ptr().offset(12), ret.as_mut_ptr(), 20);
ret ret
} }
} }
} }
*/ */
impl From<Address> for H256 { impl From<Address> for H256 {
fn from(value: Address) -> H256 { fn from(value: Address) -> H256 {
unsafe {
let mut ret = H256::new(); let mut ret = H256::new();
::std::ptr::copy(value.as_ptr(), ret.as_mut_ptr().offset(12), 20); ret.0[12..32].copy_from_slice(&value);
ret ret
} }
}
} }
impl<'a> From<&'a Address> for H256 { impl<'a> From<&'a Address> for H256 {
fn from(value: &'a Address) -> H256 { fn from(value: &'a Address) -> H256 {
unsafe {
let mut ret = H256::new(); let mut ret = H256::new();
::std::ptr::copy(value.as_ptr(), ret.as_mut_ptr().offset(12), 20); ret.0[12..32].copy_from_slice(value);
ret ret
} }
}
} }
/// Convert string `s` to an `H256`. Will panic if `s` is not 64 characters long or if any of /// Convert string `s` to an `H256`. Will panic if `s` is not 64 characters long or if any of