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

Commit

Permalink
Merge branch 'master' into refactor/hashdb-generic
Browse files Browse the repository at this point in the history
* master:
  Fix PoW blockchains sealing notifications in chain_new_blocks (#8656)
  Remove -k/--insecure option from curl installer (#8719)
  ease tiny-keccak version requirements (1.4.1 -> 1.4) (#8726)
  bump tinykeccak to 1.4 (#8728)
  Remove a couple of unnecessary `transmute()` (#8736)
  Fix some nits using clippy (#8731)
  Add 'interface' option to cli (#8699)
  Remove unused function new_pow_test_spec (#8735)
  Add a deadlock detection thread (#8727)
  • Loading branch information
dvdplm committed Jun 1, 2018
2 parents 56af2c4 + 00b209a commit cb61a01
Show file tree
Hide file tree
Showing 26 changed files with 171 additions and 103 deletions.
36 changes: 36 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ evm-debug-tests = ["ethcore/evm-debug-tests"]
slow-blocks = ["ethcore/slow-blocks"]
secretstore = ["ethcore-secretstore"]
final = ["parity-version/final"]
deadlock_detection = ["parking_lot/deadlock_detection"]

[lib]
path = "parity/lib.rs"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ first.
## Simple one-line installer for Mac and Ubuntu
```bash
bash <(curl https://get.parity.io -Lk)
bash <(curl https://get.parity.io -L)
```
The one-line installer always defaults to the latest beta release. To install a stable release, run:
```bash
bash <(curl https://get.parity.io -Lk) -r stable
bash <(curl https://get.parity.io -L) -r stable
```
## Start Parity
Expand Down
5 changes: 2 additions & 3 deletions ethash/src/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ use seed_compute::SeedHashCompute;
use shared::*;
use std::io;

use std::mem;
use std::{mem, ptr};
use std::path::Path;
use std::ptr;

const MIX_WORDS: usize = ETHASH_MIX_BYTES / 4;
const MIX_NODES: usize = MIX_WORDS / NODE_WORDS;
Expand Down Expand Up @@ -111,7 +110,7 @@ pub fn quick_get_difficulty(header_hash: &H256, nonce: u64, mix_hash: &H256) ->
let mut buf: [u8; 64 + 32] = mem::uninitialized();

ptr::copy_nonoverlapping(header_hash.as_ptr(), buf.as_mut_ptr(), 32);
ptr::copy_nonoverlapping(mem::transmute(&nonce), buf[32..].as_mut_ptr(), 8);
ptr::copy_nonoverlapping(&nonce as *const u64 as *const u8, buf[32..].as_mut_ptr(), 8);

keccak_512::unchecked(buf.as_mut_ptr(), 64, buf.as_ptr(), 40);
ptr::copy_nonoverlapping(mix_hash.as_ptr(), buf[64..].as_mut_ptr(), 32);
Expand Down
2 changes: 1 addition & 1 deletion ethcore/crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ ethereum-types = "0.3"
quick-error = "1.2"
ring = "0.12"
rust-crypto = "0.2.36"
tiny-keccak = "1.3"
tiny-keccak = "1.4"

2 changes: 1 addition & 1 deletion ethcore/private-tx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ rustc-hex = "1.0"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
tiny-keccak = "1.3"
tiny-keccak = "1.4"
url = "1"
2 changes: 1 addition & 1 deletion ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2181,7 +2181,7 @@ impl ImportSealedBlock for Client {
route
};
let route = ChainRoute::from([route].as_ref());
self.importer.miner.chain_new_blocks(self, &[h.clone()], &[], route.enacted(), route.retracted(), true);
self.importer.miner.chain_new_blocks(self, &[h.clone()], &[], route.enacted(), route.retracted(), self.engine.seals_internally().is_some());
self.notify(|notify| {
notify.new_blocks(
vec![h.clone()],
Expand Down
5 changes: 0 additions & 5 deletions ethcore/src/spec/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -923,11 +923,6 @@ impl Spec {
pub fn new_validator_multi() -> Self {
load_bundled!("validator_multi")
}

/// Create a new spec for a PoW chain
pub fn new_pow_test_spec() -> Self {
load_bundled!("ethereum/olympic")
}
}

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion ethkey/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ parity-wordlist = "1.2"
quick-error = "1.2"
rand = "0.4"
rustc-hex = "1.0"
tiny-keccak = "1.3"
tiny-keccak = "1.4"
2 changes: 1 addition & 1 deletion ethstore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ serde = "1.0"
serde_json = "1.0"
serde_derive = "1.0"
rustc-hex = "1.0"
tiny-keccak = "1.3"
tiny-keccak = "1.4"
time = "0.1.34"
itertools = "0.5"
parking_lot = "0.5"
Expand Down
7 changes: 7 additions & 0 deletions parity/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,10 @@ usage! {
"--port=[PORT]",
"Override the port on which the node should listen.",

ARG arg_interface: (String) = "all", or |c: &Config| c.network.as_ref()?.interface.clone(),
"--interface=[IP]",
"Network interfaces. Valid values are 'all', 'local' or the ip of the interface you want parity to listen to.",

ARG arg_min_peers: (Option<u16>) = None, or |c: &Config| c.network.as_ref()?.min_peers.clone(),
"--min-peers=[NUM]",
"Try to maintain at least NUM peers.",
Expand Down Expand Up @@ -1119,6 +1123,7 @@ struct Network {
warp: Option<bool>,
warp_barrier: Option<u64>,
port: Option<u16>,
interface: Option<String>,
min_peers: Option<u16>,
max_peers: Option<u16>,
snapshot_peers: Option<u16>,
Expand Down Expand Up @@ -1567,6 +1572,7 @@ mod tests {
// -- Networking Options
flag_no_warp: false,
arg_port: 30303u16,
arg_interface: "all".into(),
arg_min_peers: Some(25u16),
arg_max_peers: Some(50u16),
arg_max_pending_peers: 64u16,
Expand Down Expand Up @@ -1823,6 +1829,7 @@ mod tests {
warp: Some(false),
warp_barrier: None,
port: None,
interface: None,
min_peers: Some(10),
max_peers: Some(20),
max_pending_peers: Some(30),
Expand Down
2 changes: 1 addition & 1 deletion parity/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ impl Configuration {

fn net_addresses(&self) -> Result<(SocketAddr, Option<SocketAddr>), String> {
let port = self.args.arg_ports_shift + self.args.arg_port;
let listen_address = SocketAddr::new("0.0.0.0".parse().unwrap(), port);
let listen_address = SocketAddr::new(self.interface(&self.args.arg_interface).parse().unwrap(), port);
let public_address = if self.args.arg_nat.starts_with("extip:") {
let host = &self.args.arg_nat[6..];
let host = host.parse().map_err(|_| format!("Invalid host given with `--nat extip:{}`", host))?;
Expand Down
32 changes: 32 additions & 0 deletions parity/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,35 @@ fn print_hash_of(maybe_file: Option<String>) -> Result<String, String> {
}
}

#[cfg(feature = "deadlock_detection")]
fn run_deadlock_detection_thread() {
use std::thread;
use std::time::Duration;
use parking_lot::deadlock;

info!("Starting deadlock detection thread.");
// Create a background thread which checks for deadlocks every 10s
thread::spawn(move || {
loop {
thread::sleep(Duration::from_secs(10));
let deadlocks = deadlock::check_deadlock();
if deadlocks.is_empty() {
continue;
}

warn!("{} {} detected", deadlocks.len(), Style::new().bold().paint("deadlock(s)"));
for (i, threads) in deadlocks.iter().enumerate() {
warn!("{} #{}", Style::new().bold().paint("Deadlock"), i);
for t in threads {
warn!("Thread Id {:#?}", t.thread_id());
warn!("{:#?}", t.backtrace());
}
}
}
});
}


/// Action that Parity performed when running `start`.
pub enum ExecutionAction {
/// The execution didn't require starting a node, and thus has finished.
Expand All @@ -161,6 +190,9 @@ fn execute<Cr, Rr>(command: Execute, on_client_rq: Cr, on_updater_rq: Rr) -> Res
// they want
let logger = setup_log(&command.logger).expect("Logger is initialized only once; qed");

#[cfg(feature = "deadlock_detection")]
run_deadlock_detection_thread();

match command.cmd {
Cmd::Run(run_cmd) => {
if run_cmd.ui_conf.enabled && !run_cmd.ui_conf.info_page_only {
Expand Down
2 changes: 1 addition & 1 deletion rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
tempdir = "0.3"
tiny-keccak = "1.3"
tiny-keccak = "1.4"
tokio-timer = "0.1"
transient-hashmap = "0.4"
itertools = "0.5"
Expand Down
2 changes: 1 addition & 1 deletion secret_store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ serde_derive = "1.0"
futures = "0.1"
futures-cpupool = "0.1"
rustc-hex = "1.0"
tiny-keccak = "1.3"
tiny-keccak = "1.4"
tokio = "0.1"
tokio-core = "0.1"
tokio-io = "0.1"
Expand Down
2 changes: 1 addition & 1 deletion util/hash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ authors = ["Parity Technologies <admin@parity.io>"]

[dependencies]
ethereum-types = "0.3"
tiny-keccak = "1.4.1"
tiny-keccak = "1.4"

[dev-dependencies]
tempdir = "0.3"
2 changes: 1 addition & 1 deletion util/network-devp2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ log = "0.3"
mio = "0.6.8"
bytes = "0.4"
rand = "0.4"
tiny-keccak = "1.3"
tiny-keccak = "1.4"
rust-crypto = "0.2.34"
slab = "0.2"
igd = "0.7"
Expand Down
10 changes: 5 additions & 5 deletions util/network-devp2p/src/handshake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ impl Handshake {
/// Create a new handshake object
pub fn new(token: StreamToken, id: Option<&NodeId>, socket: TcpStream, nonce: &H256) -> Result<Handshake, Error> {
Ok(Handshake {
id: if let Some(id) = id { id.clone()} else { NodeId::new() },
id: if let Some(id) = id { *id } else { NodeId::new() },
connection: Connection::new(token, socket),
originated: false,
state: HandshakeState::New,
ecdhe: Random.generate()?,
nonce: nonce.clone(),
nonce: *nonce,
remote_ephemeral: Public::new(),
remote_nonce: H256::new(),
remote_version: PROTOCOL_VERSION,
Expand Down Expand Up @@ -166,7 +166,7 @@ impl Handshake {
self.remote_version = remote_version;
let shared = *ecdh::agree(host_secret, &self.id)?;
let signature = H520::from_slice(sig);
self.remote_ephemeral = recover(&signature.into(), &(&shared ^ &self.remote_nonce))?;
self.remote_ephemeral = recover(&signature.into(), &(shared ^ self.remote_nonce))?;
Ok(())
}

Expand All @@ -189,7 +189,7 @@ impl Handshake {
}
Err(_) => {
// Try to interpret as EIP-8 packet
let total = (((data[0] as u16) << 8 | (data[1] as u16)) as usize) + 2;
let total = ((u16::from(data[0]) << 8 | (u16::from(data[1]))) as usize) + 2;
if total < V4_AUTH_PACKET_SIZE {
debug!(target: "network", "Wrong EIP8 auth packet size");
return Err(ErrorKind::BadProtocol.into());
Expand Down Expand Up @@ -232,7 +232,7 @@ impl Handshake {
}
Err(_) => {
// Try to interpret as EIP-8 packet
let total = (((data[0] as u16) << 8 | (data[1] as u16)) as usize) + 2;
let total = (((u16::from(data[0])) << 8 | (u16::from(data[1]))) as usize) + 2;
if total < V4_ACK_PACKET_SIZE {
debug!(target: "network", "Wrong EIP8 ack packet size");
return Err(ErrorKind::BadProtocol.into());
Expand Down
Loading

0 comments on commit cb61a01

Please sign in to comment.