Enable --warp by default (#4719)

* Enable --warp by default

* Disable warp if non-standard chain options are selected

* Add warnings if warp is specified

* Fixed tests
This commit is contained in:
Arkadiy Paronyan 2017-03-02 20:04:17 +01:00 committed by Gav Wood
parent eb37d26154
commit 591eb76a93
3 changed files with 19 additions and 8 deletions

View File

@ -119,8 +119,8 @@ usage! {
flag_ui_no_validation: bool = false, or |_| None, flag_ui_no_validation: bool = false, or |_| None,
// -- Networking Options // -- Networking Options
flag_warp: bool = false, flag_no_warp: bool = false,
or |c: &Config| otry!(c.network).warp.clone(), or |c: &Config| otry!(c.network).warp.clone().map(|w| !w),
flag_port: u16 = 30303u16, flag_port: u16 = 30303u16,
or |c: &Config| otry!(c.network).port.clone(), or |c: &Config| otry!(c.network).port.clone(),
flag_min_peers: u16 = 25u16, flag_min_peers: u16 = 25u16,
@ -330,6 +330,7 @@ usage! {
// Values with optional default value. // Values with optional default value.
flag_base_path: Option<String>, display dir::default_data_path(), or |c: &Config| otry!(c.parity).base_path.clone().map(Some), flag_base_path: Option<String>, display dir::default_data_path(), or |c: &Config| otry!(c.parity).base_path.clone().map(Some),
flag_db_path: Option<String>, display dir::CHAINS_PATH, or |c: &Config| otry!(c.parity).db_path.clone().map(Some), flag_db_path: Option<String>, display dir::CHAINS_PATH, or |c: &Config| otry!(c.parity).db_path.clone().map(Some),
flag_warp: Option<bool>, display true, or |c: &Config| Some(otry!(c.network).warp.clone()),
} }
} }
@ -638,7 +639,7 @@ mod tests {
flag_ui_no_validation: false, flag_ui_no_validation: false,
// -- Networking Options // -- Networking Options
flag_warp: true, flag_no_warp: false,
flag_port: 30303u16, flag_port: 30303u16,
flag_min_peers: 25u16, flag_min_peers: 25u16,
flag_max_peers: 50u16, flag_max_peers: 50u16,
@ -779,6 +780,7 @@ mod tests {
flag_etherbase: None, flag_etherbase: None,
flag_extradata: None, flag_extradata: None,
flag_cache: None, flag_cache: None,
flag_warp: Some(true),
// -- Miscellaneous Options // -- Miscellaneous Options
flag_version: false, flag_version: false,

View File

@ -97,7 +97,7 @@ UI Options:
development. (default: {flag_ui_no_validation}) development. (default: {flag_ui_no_validation})
Networking Options: Networking Options:
--warp Enable syncing from the snapshot over the network. (default: {flag_warp}) --no-warp Disable syncing from the snapshot over the network. (default: {flag_no_warp})
--port PORT Override the port on which the node should listen --port PORT Override the port on which the node should listen
(default: {flag_port}). (default: {flag_port}).
--min-peers NUM Try to maintain at least NUM peers (default: {flag_min_peers}). --min-peers NUM Try to maintain at least NUM peers (default: {flag_min_peers}).
@ -386,6 +386,7 @@ Legacy Options:
-w --webapp Does nothing; dapps server is on by default now. -w --webapp Does nothing; dapps server is on by default now.
--dapps-off Equivalent to --no-dapps. --dapps-off Equivalent to --no-dapps.
--rpc Does nothing; JSON-RPC is on by default now. --rpc Does nothing; JSON-RPC is on by default now.
--warp Does nothing; Warp sync is on by default. (default: {flag_warp})
--rpcaddr IP Equivalent to --jsonrpc-interface IP. --rpcaddr IP Equivalent to --jsonrpc-interface IP.
--rpcport PORT Equivalent to --jsonrpc-port PORT. --rpcport PORT Equivalent to --jsonrpc-port PORT.
--rpcapi APIS Equivalent to --jsonrpc-apis APIS. --rpcapi APIS Equivalent to --jsonrpc-apis APIS.

View File

@ -15,12 +15,13 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
use std::time::Duration; use std::time::Duration;
use std::io::Read; use std::io::{Read, Write, stderr};
use std::net::SocketAddr; use std::net::SocketAddr;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::cmp::max; use std::cmp::max;
use cli::{Args, ArgsError}; use cli::{Args, ArgsError};
use util::{Hashable, H256, U256, Uint, Bytes, version_data, Address}; use util::{Hashable, H256, U256, Uint, Bytes, version_data, Address};
use util::journaldb::Algorithm;
use util::log::Colour; use util::log::Colour;
use ethsync::{NetworkConfiguration, is_valid_node_url, AllowIP}; use ethsync::{NetworkConfiguration, is_valid_node_url, AllowIP};
use ethcore::ethstore::ethkey::Secret; use ethcore::ethstore::ethkey::Secret;
@ -33,7 +34,7 @@ use ethcore_rpc::NetworkSettings;
use cache::CacheConfig; use cache::CacheConfig;
use helpers::{to_duration, to_mode, to_block_id, to_u256, to_pending_set, to_price, replace_home, replace_home_for_db, use helpers::{to_duration, to_mode, to_block_id, to_u256, to_pending_set, to_price, replace_home, replace_home_for_db,
geth_ipc_path, parity_ipc_path, to_bootnodes, to_addresses, to_address, to_gas_limit, to_queue_strategy}; geth_ipc_path, parity_ipc_path, to_bootnodes, to_addresses, to_address, to_gas_limit, to_queue_strategy};
use params::{SpecType, ResealPolicy, AccountsConfig, GasPricerConfig, MinerExtras}; use params::{SpecType, ResealPolicy, AccountsConfig, GasPricerConfig, MinerExtras, Pruning, Switch};
use ethcore_logger::Config as LogConfig; use ethcore_logger::Config as LogConfig;
use dir::{self, Directories, default_hypervisor_path, default_local_path, default_data_path}; use dir::{self, Directories, default_hypervisor_path, default_local_path, default_data_path};
use dapps::Configuration as DappsConfiguration; use dapps::Configuration as DappsConfiguration;
@ -115,7 +116,14 @@ impl Configuration {
let fat_db = self.args.flag_fat_db.parse()?; let fat_db = self.args.flag_fat_db.parse()?;
let compaction = self.args.flag_db_compaction.parse()?; let compaction = self.args.flag_db_compaction.parse()?;
let wal = !self.args.flag_fast_and_loose; let wal = !self.args.flag_fast_and_loose;
let warp_sync = self.args.flag_warp; match self.args.flag_warp {
// Logging is not initialized yet, so we print directly to stderr
Some(true) if fat_db == Switch::On => writeln!(&mut stderr(), "Warning: Warp Sync is disabled because Fat DB is turned on").expect("Error writing to stderr"),
Some(true) if tracing == Switch::On => writeln!(&mut stderr(), "Warning: Warp Sync is disabled because tracing is turned on").expect("Error writing to stderr"),
Some(true) if pruning == Pruning::Specific(Algorithm::Archive) => writeln!(&mut stderr(), "Warning: Warp Sync is disabled because pruning mode is set to archive").expect("Error writing to stderr"),
_ => {},
};
let warp_sync = !self.args.flag_no_warp && fat_db != Switch::On && tracing != Switch::On && pruning != Pruning::Specific(Algorithm::Archive);
let geth_compatibility = self.args.flag_geth; let geth_compatibility = self.args.flag_geth;
let ui_address = self.ui_port().map(|port| (self.ui_interface(), port)); let ui_address = self.ui_port().map(|port| (self.ui_interface(), port));
let dapps_conf = self.dapps_config(); let dapps_conf = self.dapps_config();
@ -1144,7 +1152,7 @@ mod tests {
ipc_conf: Default::default(), ipc_conf: Default::default(),
net_conf: default_network_config(), net_conf: default_network_config(),
network_id: None, network_id: None,
warp_sync: false, warp_sync: true,
acc_conf: Default::default(), acc_conf: Default::default(),
gas_pricer: Default::default(), gas_pricer: Default::default(),
miner_extras: Default::default(), miner_extras: Default::default(),