3b9b1a8f14
* version: bump beta to 2.3.3 * import rpc transactions sequentially (#10051) * import rpc transactions sequentially * use impl trait in argument position, renamed ProspectiveDispatcher to WithPostSign * grouped imports * integrates PostSign with ProspectiveSigner * fix spaces, removed unnecessary type cast and duplicate polling * clean up code style * Apply suggestions from code review * Fix Windows build (#10284) * Don't run the CPP example on CI (#10285) * Don't run the CPP example on CI * Add comment * CI optimizations (#10297) * CI optimizations * fix stripping * new dockerfile * no need n submodule upd * review * moved dockerfile * it becomes large * onchain update depends on s3 * fix dependency * fix cache status * fix cache status * new cache status * fix publish job (#10317) * fix publish job * dashes and colonels * Add Statetest support for Constantinople Fix (#10323) * Update Ethereum tests repo to v6.0.0-beta.3 tag * Add spec for St.Peter's / ConstantinopleFix statetests * Properly handle check_epoch_end_signal errors (#10015) * Make check_epoch_end_signal to only use immutable data * Move check_epoch_end_signals out of commit_block * Make check_epoch_end_signals possible to fail * Actually return the error from check_epoch_end_signals * Remove a clone * Fix import error * cargo: fix compilation * fix(add helper for timestamp overflows) (#10330) * fix(add helper timestamp overflows) * fix(simplify code) * fix(make helper private) * Remove CallContract and RegistryInfo re-exports from `ethcore/client` (#10205) * Remove re-export of `CallContract` and `RegistryInfo` from `ethcore/client` * Remove CallContract and RegistryInfo re-exports again This was missed while fixing merge conflicts * fix(docker): fix not receives SIGINT (#10059) * fix(docker): fix not receives SIGINT * fix: update with reviews * update with review * update * update * snap: official image / test (#10168) * official image / test * fix / test * bit more necromancy * fix paths * add source bin/df /test * add source bin/df /test2 * something w paths /test * something w paths /test * add source-type /test * show paths /test * copy plugin /test * plugin -> nil * install rhash * no questions while installing rhash * publish snap only for release * Don't add discovery initiators to the node table (#10305) * Don't add discovery initiators to the node table * Use enums for tracking state of the nodes in discovery * Dont try to ping ourselves * Fix minor nits * Update timeouts when observing an outdated node * Extracted update_bucket_record from update_node * Fixed typo * Fix two final nits from @todr * Extract CallContract and RegistryInfo traits into their own crate (#10178) * Create call-contract crate * Add license * First attempt at using extracted CallContract trait * Remove unneeded `extern crate` calls * Move RegistryInfo trait into call-contract crate * Move service-transaction-checker from ethcore to ethcore-miner * Update Cargo.lock file * Re-export call_contract * Merge CallContract and RegistryInfo imports * Remove commented code * Add documentation to call_contract crate * Add TODO for removal of re-exports * Update call-contract crate description Co-Authored-By: HCastano <HCastano@users.noreply.github.com> * Rename call-contract crate to ethcore-call-contract * Remove CallContract and RegistryInfo re-exports from `ethcore/client` (#10205) * Remove re-export of `CallContract` and `RegistryInfo` from `ethcore/client` * Remove CallContract and RegistryInfo re-exports again This was missed while fixing merge conflicts * fixed: types::transaction::SignedTransaction; (#10229) * fix daemonize dependency * fix build * change docker image based on debian instead of ubuntu due to the chan… (#10336) * change docker image based on debian instead of ubuntu due to the changes of the build container * role back docker build image and docker deploy image to ubuntu:xenial based (#10338) * perform stripping during build (#10208) * perform stripping during build (#10208) * perform stripping during build * var RUSTFLAGS
235 lines
7.4 KiB
Rust
235 lines
7.4 KiB
Rust
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
|
|
// This file is part of Parity Ethereum.
|
|
|
|
// Parity Ethereum 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 Ethereum 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 Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
//! Ethcore client application.
|
|
|
|
#![warn(missing_docs)]
|
|
|
|
extern crate ansi_term;
|
|
extern crate docopt;
|
|
#[macro_use]
|
|
extern crate clap;
|
|
extern crate dir;
|
|
extern crate futures;
|
|
extern crate atty;
|
|
extern crate jsonrpc_core;
|
|
extern crate num_cpus;
|
|
extern crate number_prefix;
|
|
extern crate parking_lot;
|
|
extern crate regex;
|
|
extern crate rlp;
|
|
extern crate rpassword;
|
|
extern crate rustc_hex;
|
|
extern crate semver;
|
|
extern crate serde;
|
|
extern crate serde_json;
|
|
#[macro_use]
|
|
extern crate serde_derive;
|
|
extern crate toml;
|
|
|
|
extern crate blooms_db;
|
|
extern crate cli_signer;
|
|
extern crate common_types as types;
|
|
extern crate parity_bytes as bytes;
|
|
extern crate ethcore;
|
|
extern crate ethcore_call_contract as call_contract;
|
|
extern crate ethcore_db;
|
|
extern crate ethcore_io as io;
|
|
extern crate ethcore_light as light;
|
|
extern crate ethcore_logger;
|
|
extern crate ethcore_miner as miner;
|
|
extern crate ethcore_network as network;
|
|
extern crate ethcore_private_tx;
|
|
extern crate ethcore_service;
|
|
extern crate ethcore_sync as sync;
|
|
extern crate ethereum_types;
|
|
extern crate ethstore;
|
|
extern crate ethkey;
|
|
extern crate kvdb;
|
|
extern crate parity_hash_fetch as hash_fetch;
|
|
extern crate parity_ipfs_api;
|
|
extern crate parity_local_store as local_store;
|
|
extern crate parity_runtime;
|
|
extern crate parity_rpc;
|
|
extern crate parity_updater as updater;
|
|
extern crate parity_version;
|
|
extern crate parity_whisper;
|
|
extern crate parity_path as path;
|
|
extern crate node_filter;
|
|
extern crate keccak_hash as hash;
|
|
extern crate journaldb;
|
|
extern crate registrar;
|
|
|
|
#[macro_use]
|
|
extern crate log as rlog;
|
|
|
|
#[cfg(feature = "secretstore")]
|
|
extern crate ethcore_secretstore;
|
|
|
|
#[cfg(test)]
|
|
#[macro_use]
|
|
extern crate pretty_assertions;
|
|
|
|
#[cfg(test)]
|
|
extern crate tempdir;
|
|
|
|
mod account;
|
|
mod blockchain;
|
|
mod cache;
|
|
mod cli;
|
|
mod configuration;
|
|
mod export_hardcoded_sync;
|
|
mod ipfs;
|
|
mod deprecated;
|
|
mod helpers;
|
|
mod informant;
|
|
mod light_helpers;
|
|
mod modules;
|
|
mod params;
|
|
mod presale;
|
|
mod rpc;
|
|
mod rpc_apis;
|
|
mod run;
|
|
mod secretstore;
|
|
mod signer;
|
|
mod snapshot;
|
|
mod upgrade;
|
|
mod user_defaults;
|
|
mod whisper;
|
|
mod db;
|
|
|
|
use std::io::BufReader;
|
|
use std::fs::File;
|
|
use hash::keccak_buffer;
|
|
use cli::Args;
|
|
use configuration::{Cmd, Execute};
|
|
use deprecated::find_deprecated;
|
|
use ethcore_logger::setup_log;
|
|
#[cfg(feature = "memory_profiling")]
|
|
use std::alloc::System;
|
|
|
|
pub use self::configuration::Configuration;
|
|
pub use self::run::RunningClient;
|
|
pub use parity_rpc::PubSubSession;
|
|
|
|
#[cfg(feature = "memory_profiling")]
|
|
#[global_allocator]
|
|
static A: System = System;
|
|
|
|
fn print_hash_of(maybe_file: Option<String>) -> Result<String, String> {
|
|
if let Some(file) = maybe_file {
|
|
let mut f = BufReader::new(File::open(&file).map_err(|_| "Unable to open file".to_owned())?);
|
|
let hash = keccak_buffer(&mut f).map_err(|_| "Unable to read from file".to_owned())?;
|
|
Ok(format!("{:x}", hash))
|
|
} else {
|
|
Err("Streaming from standard input not yet supported. Specify a file.".to_owned())
|
|
}
|
|
}
|
|
|
|
#[cfg(feature = "deadlock_detection")]
|
|
fn run_deadlock_detection_thread() {
|
|
use std::thread;
|
|
use std::time::Duration;
|
|
use parking_lot::deadlock;
|
|
use ansi_term::Style;
|
|
|
|
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.
|
|
/// Contains the string to print on stdout, if any.
|
|
Instant(Option<String>),
|
|
|
|
/// The client has started running and must be shut down manually by calling `shutdown`.
|
|
///
|
|
/// If you don't call `shutdown()`, execution will continue in the background.
|
|
Running(RunningClient),
|
|
}
|
|
|
|
fn execute<Cr, Rr>(command: Execute, on_client_rq: Cr, on_updater_rq: Rr) -> Result<ExecutionAction, String>
|
|
where Cr: Fn(String) + 'static + Send,
|
|
Rr: Fn() + 'static + Send
|
|
{
|
|
// TODO: move this to `main()` and expose in the C API so that users can setup logging the way
|
|
// 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) => {
|
|
let outcome = run::execute(run_cmd, logger, on_client_rq, on_updater_rq)?;
|
|
Ok(ExecutionAction::Running(outcome))
|
|
},
|
|
Cmd::Version => Ok(ExecutionAction::Instant(Some(Args::print_version()))),
|
|
Cmd::Hash(maybe_file) => print_hash_of(maybe_file).map(|s| ExecutionAction::Instant(Some(s))),
|
|
Cmd::Account(account_cmd) => account::execute(account_cmd).map(|s| ExecutionAction::Instant(Some(s))),
|
|
Cmd::ImportPresaleWallet(presale_cmd) => presale::execute(presale_cmd).map(|s| ExecutionAction::Instant(Some(s))),
|
|
Cmd::Blockchain(blockchain_cmd) => blockchain::execute(blockchain_cmd).map(|_| ExecutionAction::Instant(None)),
|
|
Cmd::SignerToken(ws_conf, logger_config) => signer::execute(ws_conf, logger_config).map(|s| ExecutionAction::Instant(Some(s))),
|
|
Cmd::SignerSign { id, pwfile, port, authfile } => cli_signer::signer_sign(id, pwfile, port, authfile).map(|s| ExecutionAction::Instant(Some(s))),
|
|
Cmd::SignerList { port, authfile } => cli_signer::signer_list(port, authfile).map(|s| ExecutionAction::Instant(Some(s))),
|
|
Cmd::SignerReject { id, port, authfile } => cli_signer::signer_reject(id, port, authfile).map(|s| ExecutionAction::Instant(Some(s))),
|
|
Cmd::Snapshot(snapshot_cmd) => snapshot::execute(snapshot_cmd).map(|s| ExecutionAction::Instant(Some(s))),
|
|
Cmd::ExportHardcodedSync(export_hs_cmd) => export_hardcoded_sync::execute(export_hs_cmd).map(|s| ExecutionAction::Instant(Some(s))),
|
|
}
|
|
}
|
|
|
|
/// Starts the parity client.
|
|
///
|
|
/// `on_client_rq` is the action to perform when the client receives an RPC request to be restarted
|
|
/// with a different chain.
|
|
///
|
|
/// `on_updater_rq` is the action to perform when the updater has a new binary to execute.
|
|
///
|
|
/// The first parameter is the command line arguments that you would pass when running the parity
|
|
/// binary.
|
|
///
|
|
/// On error, returns what to print on stderr.
|
|
pub fn start<Cr, Rr>(conf: Configuration, on_client_rq: Cr, on_updater_rq: Rr) -> Result<ExecutionAction, String>
|
|
where Cr: Fn(String) + 'static + Send,
|
|
Rr: Fn() + 'static + Send
|
|
{
|
|
let deprecated = find_deprecated(&conf.args);
|
|
for d in deprecated {
|
|
println!("{}", d);
|
|
}
|
|
|
|
execute(conf.into_command()?, on_client_rq, on_updater_rq)
|
|
}
|