Merge branch 'master' into miner-no-default

Conflicts:
	ethcore/src/miner/miner.rs
	parity/main.rs
This commit is contained in:
Tomasz Drwięga
2016-06-26 22:44:34 +02:00
50 changed files with 380 additions and 215 deletions

View File

@@ -117,7 +117,9 @@ API and Console Options:
[default: $HOME/.parity/dapps]
--signer Enable Trusted Signer WebSocket endpoint used by
Signer UIs.
Signer UIs. Default if run with ui command.
--no-signer Disable Trusted Signer WebSocket endpoint used by
Signer UIs. Default if no command is specified.
--signer-port PORT Specify the port of Trusted Signer server
[default: 8180].
--signer-path PATH Specify directory where Signer UIs tokens should
@@ -126,6 +128,9 @@ API and Console Options:
output on start up. This will prevent it.
Sealing/Mining Options:
--author ADDRESS Specify the block author (aka "coinbase") address
for sending block rewards from sealed blocks.
NOTE: MINING WILL NOT WORK WITHOUT THIS OPTION.
--force-sealing Force the node to author new blocks as if it were
always sealing/mining.
--usd-per-tx USD Amount of USD to be paid for a basic transaction
@@ -137,9 +142,8 @@ Sealing/Mining Options:
good value [default: auto].
--gas-floor-target GAS Amount of gas per block to target when sealing a new
block [default: 3141592].
--author ADDRESS Specify the block author (aka "coinbase") address
for sending block rewards from sealed blocks
[default: 0037a6b811ffeb6e072da21179d11b1406371c63].
--gas-cap GAS A cap on how large we will raise the gas limit per
block due to transaction volume [default: 3141592].
--extra-data STRING Specify a custom extra-data for authored blocks, no
more than 32 characters.
--tx-limit LIMIT Limit of transactions kept in the queue (waiting to
@@ -152,13 +156,9 @@ Footprint Options:
off. auto uses last used value of this option (off
if it does not exist) [default: auto].
--pruning METHOD Configure pruning of the state/storage trie. METHOD
may be one of auto, archive, fast, basic, light:
may be one of auto, archive, fast:
archive - keep all state trie data. No pruning.
fast - maintain journal overlay. Fast but 50MB used.
basic - reference count in disk DB. Slow, light, and
experimental!
light - early merges with partial tracking. Fast,
light, and experimental!
auto - use the method most recently synced or
default to fast if none synced [default: auto].
--cache-pref-size BYTES Specify the prefered size of the blockchain cache in
@@ -278,14 +278,16 @@ pub struct Args {
pub flag_dapps_pass: Option<String>,
pub flag_dapps_path: String,
pub flag_signer: bool,
pub flag_no_signer: bool,
pub flag_signer_port: u16,
pub flag_signer_path: String,
pub flag_no_token: bool,
pub flag_force_sealing: bool,
pub flag_author: String,
pub flag_author: Option<String>,
pub flag_usd_per_tx: String,
pub flag_usd_per_eth: String,
pub flag_gas_floor_target: String,
pub flag_gas_cap: String,
pub flag_extra_data: Option<String>,
pub flag_tx_limit: usize,
pub flag_logging: Option<String>,

View File

@@ -67,11 +67,12 @@ impl Configuration {
self.args.flag_maxpeers.unwrap_or(self.args.flag_peers) as u32
}
pub fn author(&self) -> Address {
let d = self.args.flag_etherbase.as_ref().unwrap_or(&self.args.flag_author);
Address::from_str(clean_0x(d)).unwrap_or_else(|_| {
die!("{}: Invalid address for --author. Must be 40 hex characters, with or without the 0x at the beginning.", d)
})
pub fn author(&self) -> Option<Address> {
self.args.flag_etherbase.as_ref()
.or(self.args.flag_author.as_ref())
.map(|d| Address::from_str(clean_0x(d)).unwrap_or_else(|_| {
die!("{}: Invalid address for --author. Must be 40 hex characters, with or without the 0x at the beginning.", d)
}))
}
pub fn gas_floor_target(&self) -> U256 {
@@ -85,7 +86,16 @@ impl Configuration {
}
}
pub fn gas_ceil_target(&self) -> U256 {
if self.args.flag_dont_help_rescue_dao || self.args.flag_dogmatic {
10_000_000.into()
} else {
let d = &self.args.flag_gas_cap;
U256::from_dec_str(d).unwrap_or_else(|_| {
die!("{}: Invalid target gas ceiling given. Must be a decimal unsigned 256-bit number.", d)
})
}
}
pub fn gas_price(&self) -> U256 {
match self.args.flag_gasprice.as_ref() {
@@ -121,14 +131,10 @@ impl Configuration {
}
pub fn extra_data(&self) -> Bytes {
if !self.args.flag_dont_help_rescue_dao {
(b"rescuedao"[..]).to_owned()
} else {
match self.args.flag_extradata.as_ref().or(self.args.flag_extra_data.as_ref()) {
Some(ref x) if x.len() <= 32 => x.as_bytes().to_owned(),
None => version_data(),
Some(ref x) => { die!("{}: Extra data must be at most 32 characters.", x); }
}
match self.args.flag_extradata.as_ref().or(self.args.flag_extra_data.as_ref()) {
Some(ref x) if x.len() <= 32 => x.as_bytes().to_owned(),
None => version_data(),
Some(ref x) => { die!("{}: Extra data must be at most 32 characters.", x); }
}
}
@@ -432,12 +438,37 @@ impl Configuration {
}
pub fn signer_port(&self) -> Option<u16> {
if !self.args.flag_signer {
if !self.signer_enabled() {
None
} else {
Some(self.args.flag_signer_port)
}
}
pub fn rpc_interface(&self) -> String {
match self.network_settings().rpc_interface.as_str() {
"all" => "0.0.0.0",
"local" => "127.0.0.1",
x => x,
}.into()
}
pub fn dapps_interface(&self) -> String {
match self.args.flag_dapps_interface.as_str() {
"all" => "0.0.0.0",
"local" => "127.0.0.1",
x => x,
}.into()
}
pub fn dapps_enabled(&self) -> bool {
!self.args.flag_dapps_off && !self.args.flag_no_dapps
}
pub fn signer_enabled(&self) -> bool {
(self.args.cmd_ui && !self.args.flag_no_signer) ||
(!self.args.cmd_ui && self.args.flag_signer)
}
}
#[cfg(test)]

View File

@@ -45,12 +45,7 @@ pub fn new(configuration: Configuration, deps: Dependencies) -> Option<WebappSer
return None;
}
let interface = match configuration.interface.as_str() {
"all" => "0.0.0.0",
"local" => "127.0.0.1",
x => x,
};
let url = format!("{}:{}", interface, configuration.port);
let url = format!("{}:{}", configuration.interface, configuration.port);
let addr = SocketAddr::from_str(&url).unwrap_or_else(|_| die!("{}: Invalid Webapps listen host/port given.", url));
let auth = configuration.user.as_ref().map(|username| {

View File

@@ -192,14 +192,14 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig)
let sync_config = conf.sync_config(&spec);
// Create and display a new token for UIs.
if conf.args.flag_signer && !conf.args.flag_no_token {
if conf.signer_enabled() && !conf.args.flag_no_token {
new_token(conf.directories().signer).unwrap_or_else(|e| {
die!("Error generating token: {:?}", e)
});
}
// Display warning about using unlock with signer
if conf.args.flag_signer && conf.args.flag_unlock.is_some() {
if conf.signer_enabled() && conf.args.flag_unlock.is_some() {
warn!("Using Trusted Signer and --unlock is not recommended!");
warn!("NOTE that Signer will not ask you to confirm transactions from unlocked account.");
}
@@ -209,8 +209,9 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig)
// Miner
let miner = Miner::new(conf.args.flag_force_sealing, conf.spec(), Some(account_service.clone()));
miner.set_author(conf.author());
miner.set_author(conf.author().unwrap_or(Default::default()));
miner.set_gas_floor_target(conf.gas_floor_target());
miner.set_gas_ceil_target(conf.gas_ceil_target());
miner.set_extra_data(conf.extra_data());
miner.set_minimal_gas_price(conf.gas_price());
miner.set_transactions_limit(conf.args.flag_tx_limit);
@@ -252,7 +253,7 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig)
// Setup http rpc
let rpc_server = rpc::new_http(rpc::HttpConfiguration {
enabled: network_settings.rpc_enabled,
interface: network_settings.rpc_interface.clone(),
interface: conf.rpc_interface(),
port: network_settings.rpc_port,
apis: conf.rpc_apis(),
cors: conf.rpc_cors(),
@@ -264,8 +265,8 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig)
if conf.args.flag_webapp { println!("WARNING: Flag -w/--webapp is deprecated. Dapps server is now on by default. Ignoring."); }
let dapps_server = dapps::new(dapps::Configuration {
enabled: !conf.args.flag_dapps_off && !conf.args.flag_no_dapps,
interface: conf.args.flag_dapps_interface.clone(),
enabled: conf.dapps_enabled(),
interface: conf.dapps_interface(),
port: conf.args.flag_dapps_port,
user: conf.args.flag_dapps_user.clone(),
pass: conf.args.flag_dapps_pass.clone(),
@@ -277,7 +278,7 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig)
// Set up a signer
let signer_server = signer::start(signer::Configuration {
enabled: deps_for_rpc_apis.signer_port.is_some(),
enabled: conf.signer_enabled(),
port: conf.args.flag_signer_port,
signer_path: conf.directories().signer,
}, signer::Dependencies {
@@ -296,7 +297,10 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig)
service.register_io_handler(io_handler).expect("Error registering IO handler");
if conf.args.cmd_ui {
url::open("http://localhost:8080/")
if !conf.dapps_enabled() {
die_with_message("Cannot use UI command with Dapps turned off.");
}
url::open(&format!("http://{}:{}/", conf.dapps_interface(), conf.args.flag_dapps_port));
}
// Handle exit

View File

@@ -66,13 +66,8 @@ pub fn new_http(conf: HttpConfiguration, deps: &Dependencies) -> Option<RpcServe
return None;
}
let interface = match conf.interface.as_str() {
"all" => "0.0.0.0",
"local" => "127.0.0.1",
x => x,
};
let apis = conf.apis.split(',').collect();
let url = format!("{}:{}", interface, conf.port);
let url = format!("{}:{}", conf.interface, conf.port);
let addr = SocketAddr::from_str(&url).unwrap_or_else(|_| die!("{}: Invalid JSONRPC listen host/port given.", url));
Some(setup_http_rpc_server(deps, &addr, conf.cors, apis))

View File

@@ -49,11 +49,11 @@ pub fn open(url: &str) {
#[cfg(target_os="macos")]
pub fn open(url: &str) {
use std;
let _ = std::process::Command::new("open").arg(url).output();
let _ = std::process::Command::new("open").arg(url).spawn();
}
#[cfg(target_os="linux")]
pub fn open(url: &str) {
use std;
let _ = std::process::Command::new("xdg-open").arg(url).output();
let _ = std::process::Command::new("xdg-open").arg(url).spawn();
}