diff --git a/parity/cli/args.rs b/parity/cli/args.rs index 1ea7ef04dce..82cb44b4af3 100644 --- a/parity/cli/args.rs +++ b/parity/cli/args.rs @@ -7,1282 +7,1282 @@ use structopt::StructOpt; #[derive(Debug, PartialEq)] pub enum ArgsError { - ConfigParseError(String), - ConfigReadError(String), - ConfigWriteError(String), - PeerConfigurationError(String), + ConfigParseError(String), + ConfigReadError(String), + ConfigWriteError(String), + PeerConfigurationError(String), } #[derive(Default, Debug, PartialEq, Clone)] pub struct Args { - pub cmd_daemon: bool, - pub arg_daemon_pid_file: Option, - - pub cmd_account: bool, - pub cmd_account_new: bool, - pub cmd_account_list: bool, - pub cmd_account_import: bool, - pub arg_account_import_path: Option>, - - pub cmd_wallet: bool, - pub cmd_wallet_import: bool, - pub arg_wallet_import_path: Option, - - pub cmd_import: bool, - pub arg_import_format: Option, - pub arg_import_file: Option, - - pub cmd_export: bool, - pub cmd_export_blocks: bool, - pub arg_export_blocks_format: Option, - pub arg_export_blocks_from: String, - pub arg_export_blocks_to: String, - pub arg_export_blocks_file: Option, - - pub cmd_export_state: bool, - pub flag_export_state_no_storage: bool, - pub flag_export_state_no_code: bool, - pub arg_export_state_min_balance: Option, - pub arg_export_state_max_balance: Option, - pub arg_export_state_at: String, - pub arg_export_state_format: Option, - pub arg_export_state_file: Option, - - pub cmd_signer: bool, - pub cmd_signer_new_token: bool, - pub cmd_signer_list: bool, - pub cmd_signer_sign: bool, - pub arg_signer_sign_id: Option, - pub cmd_signer_reject: bool, - pub arg_signer_reject_id: Option, - - pub cmd_snapshot: bool, - pub arg_snapshot_at: String, - pub arg_snapshot_file: Option, - - pub cmd_restore: bool, - pub arg_restore_file: Option, - - pub cmd_tools: bool, - pub cmd_tools_hash: bool, - pub arg_tools_hash_file: Option, - - pub cmd_db: bool, - pub cmd_db_kill: bool, - pub cmd_db_reset: bool, - pub arg_db_reset_num: u32, - - pub cmd_export_hardcoded_sync: bool, - - pub cmd_dapp: bool, - pub arg_dapp_path: Option, - - pub flag_no_download: bool, - pub flag_no_consensus: bool, - pub flag_light: bool, - pub flag_no_hardcoded_sync: bool, - pub flag_force_direct: bool, - pub arg_mode: String, - pub arg_mode_timeout: u64, - pub arg_mode_alarm: u64, - pub arg_auto_update: String, - pub arg_auto_update_delay: u16, - pub arg_auto_update_check_frequency: u16, - pub arg_release_track: String, - pub arg_chain: String, - pub arg_keys_path: String, - pub arg_identity: String, - pub arg_base_path: Option, - pub arg_db_path: Option, - pub flag_unsafe_expose: bool, - pub arg_config: String, - pub arg_ports_shift: u16, - pub flag_fast_unlock: bool, - pub arg_keys_iterations: u32, - pub arg_accounts_refresh: u64, - pub arg_unlock: Option, - pub arg_enable_signing_queue: bool, - pub arg_password: Vec, - pub flag_private_enabled: bool, - pub flag_private_state_offchain: bool, - pub arg_private_signer: Option, - pub arg_private_validators: Option, - pub arg_private_account: Option, - pub arg_private_sstore_url: Option, - pub arg_private_sstore_threshold: Option, - pub arg_private_passwords: Option, - pub arg_ui_path: String, - pub flag_no_warp: bool, - pub flag_no_discovery: bool, - pub flag_reserved_only: bool, - pub flag_no_ancient_blocks: bool, - pub flag_no_serve_light: bool, - pub arg_warp_barrier: Option, - pub arg_port: u16, - pub arg_interface: String, - pub arg_min_peers: Option, - pub arg_max_peers: Option, - pub arg_snapshot_peers: u16, - pub arg_nat: String, - pub arg_allow_ips: String, - pub arg_max_pending_peers: u16, - pub arg_network_id: Option, - pub arg_bootnodes: Option, - pub arg_node_key: Option, - pub arg_reserved_peers: Option, - pub flag_jsonrpc_allow_missing_blocks: bool, - pub flag_no_jsonrpc: bool, - pub flag_jsonrpc_no_keep_alive: bool, - pub flag_jsonrpc_experimental: bool, - pub arg_jsonrpc_port: u16, - pub arg_jsonrpc_interface: String, - pub arg_jsonrpc_apis: String, - pub arg_jsonrpc_hosts: String, - pub arg_jsonrpc_threads: Option, - pub arg_jsonrpc_server_threads: Option, - pub arg_jsonrpc_cors: String, - pub arg_jsonrpc_max_payload: Option, - pub arg_poll_lifetime: u32, - pub flag_no_ws: bool, - pub arg_ws_port: u16, - pub arg_ws_interface: String, - pub arg_ws_apis: String, - pub arg_ws_origins: String, - pub arg_ws_hosts: String, - pub arg_ws_max_connections: usize, - pub flag_no_ipc: bool, - pub arg_ipc_path: String, - pub arg_ipc_chmod: String, - pub arg_ipc_apis: String, - pub arg_on_demand_response_time_window: Option, - pub arg_on_demand_request_backoff_start: Option, - pub arg_on_demand_request_backoff_max: Option, - pub arg_on_demand_request_backoff_rounds_max: Option, - pub arg_on_demand_request_consecutive_failures: Option, - pub flag_no_secretstore: bool, - pub flag_no_secretstore_http: bool, - pub flag_no_secretstore_auto_migrate: bool, - pub arg_secretstore_http_cors: String, - pub arg_secretstore_acl_contract: Option, - pub arg_secretstore_contract: Option, - pub arg_secretstore_srv_gen_contract: Option, - pub arg_secretstore_srv_retr_contract: Option, - pub arg_secretstore_doc_store_contract: Option, - pub arg_secretstore_doc_sretr_contract: Option, - pub arg_secretstore_nodes: String, - pub arg_secretstore_server_set_contract: Option, - pub arg_secretstore_interface: String, - pub arg_secretstore_port: u16, - pub arg_secretstore_http_interface: String, - pub arg_secretstore_http_port: u16, - pub arg_secretstore_path: String, - pub arg_secretstore_secret: Option, - pub arg_secretstore_admin_public: Option, - pub flag_force_sealing: bool, - pub flag_reseal_on_uncle: bool, - pub flag_remove_solved: bool, - pub flag_tx_queue_no_unfamiliar_locals: bool, - pub flag_tx_queue_no_early_reject: bool, - pub flag_refuse_service_transactions: bool, - pub flag_infinite_pending_block: bool, - pub flag_no_persistent_txqueue: bool, - pub flag_stratum: bool, - pub arg_reseal_on_txs: String, - pub arg_reseal_min_period: u64, - pub arg_reseal_max_period: u64, - pub arg_work_queue_size: usize, - pub arg_relay_set: String, - pub arg_usd_per_tx: String, - pub arg_usd_per_eth: String, - pub arg_price_update_period: String, - pub arg_gas_floor_target: String, - pub arg_gas_cap: String, - pub arg_tx_queue_mem_limit: u32, - pub arg_tx_queue_size: usize, - pub arg_tx_queue_per_sender: Option, - pub arg_tx_queue_locals: Option, - pub arg_tx_queue_strategy: String, - pub arg_stratum_interface: String, - pub arg_stratum_port: u16, - pub arg_min_gas_price: Option, - pub arg_gas_price_percentile: usize, - pub arg_author: Option, - pub arg_engine_signer: Option, - pub arg_tx_gas_limit: Option, - pub arg_tx_time_limit: Option, - pub arg_extra_data: Option, - pub arg_notify_work: Option, - pub arg_stratum_secret: Option, - pub arg_max_round_blocks_to_import: usize, - pub flag_can_restart: bool, - pub flag_no_color: bool, - // NOTE: This is auto handled by structopt - // pub flag_version: bool, - pub flag_no_config: bool, - pub arg_logging: Option, - pub arg_log_file: Option, - pub flag_scale_verifiers: bool, - pub arg_tracing: String, - pub arg_pruning: String, - pub arg_pruning_history: u64, - pub arg_pruning_memory: usize, - pub arg_cache_size_db: u32, - pub arg_cache_size_blocks: u32, - pub arg_cache_size_queue: u32, - pub arg_cache_size_state: u32, - pub arg_db_compaction: String, - pub arg_fat_db: String, - pub arg_cache_size: Option, - pub arg_num_verifiers: Option, - pub flag_no_seal_check: bool, - pub flag_no_periodic_snapshot: bool, - pub arg_snapshot_threads: Option, - pub flag_whisper: bool, - pub arg_whisper_pool_size: Option, - pub flag_geth: bool, - pub flag_import_geth_keys: bool, + pub cmd_daemon: bool, + pub arg_daemon_pid_file: Option, + + pub cmd_account: bool, + pub cmd_account_new: bool, + pub cmd_account_list: bool, + pub cmd_account_import: bool, + pub arg_account_import_path: Option>, + + pub cmd_wallet: bool, + pub cmd_wallet_import: bool, + pub arg_wallet_import_path: Option, + + pub cmd_import: bool, + pub arg_import_format: Option, + pub arg_import_file: Option, + + pub cmd_export: bool, + pub cmd_export_blocks: bool, + pub arg_export_blocks_format: Option, + pub arg_export_blocks_from: String, + pub arg_export_blocks_to: String, + pub arg_export_blocks_file: Option, + + pub cmd_export_state: bool, + pub flag_export_state_no_storage: bool, + pub flag_export_state_no_code: bool, + pub arg_export_state_min_balance: Option, + pub arg_export_state_max_balance: Option, + pub arg_export_state_at: String, + pub arg_export_state_format: Option, + pub arg_export_state_file: Option, + + pub cmd_signer: bool, + pub cmd_signer_new_token: bool, + pub cmd_signer_list: bool, + pub cmd_signer_sign: bool, + pub arg_signer_sign_id: Option, + pub cmd_signer_reject: bool, + pub arg_signer_reject_id: Option, + + pub cmd_snapshot: bool, + pub arg_snapshot_at: String, + pub arg_snapshot_file: Option, + + pub cmd_restore: bool, + pub arg_restore_file: Option, + + pub cmd_tools: bool, + pub cmd_tools_hash: bool, + pub arg_tools_hash_file: Option, + + pub cmd_db: bool, + pub cmd_db_kill: bool, + pub cmd_db_reset: bool, + pub arg_db_reset_num: u32, + + pub cmd_export_hardcoded_sync: bool, + + pub cmd_dapp: bool, + pub arg_dapp_path: Option, + + pub flag_no_download: bool, + pub flag_no_consensus: bool, + pub flag_light: bool, + pub flag_no_hardcoded_sync: bool, + pub flag_force_direct: bool, + pub arg_mode: String, + pub arg_mode_timeout: u64, + pub arg_mode_alarm: u64, + pub arg_auto_update: String, + pub arg_auto_update_delay: u16, + pub arg_auto_update_check_frequency: u16, + pub arg_release_track: String, + pub arg_chain: String, + pub arg_keys_path: String, + pub arg_identity: String, + pub arg_base_path: Option, + pub arg_db_path: Option, + pub flag_unsafe_expose: bool, + pub arg_config: String, + pub arg_ports_shift: u16, + pub flag_fast_unlock: bool, + pub arg_keys_iterations: u32, + pub arg_accounts_refresh: u64, + pub arg_unlock: Option, + pub arg_enable_signing_queue: bool, + pub arg_password: Vec, + pub flag_private_enabled: bool, + pub flag_private_state_offchain: bool, + pub arg_private_signer: Option, + pub arg_private_validators: Option, + pub arg_private_account: Option, + pub arg_private_sstore_url: Option, + pub arg_private_sstore_threshold: Option, + pub arg_private_passwords: Option, + pub arg_ui_path: String, + pub flag_no_warp: bool, + pub flag_no_discovery: bool, + pub flag_reserved_only: bool, + pub flag_no_ancient_blocks: bool, + pub flag_no_serve_light: bool, + pub arg_warp_barrier: Option, + pub arg_port: u16, + pub arg_interface: String, + pub arg_min_peers: Option, + pub arg_max_peers: Option, + pub arg_snapshot_peers: u16, + pub arg_nat: String, + pub arg_allow_ips: String, + pub arg_max_pending_peers: u16, + pub arg_network_id: Option, + pub arg_bootnodes: Option, + pub arg_node_key: Option, + pub arg_reserved_peers: Option, + pub flag_jsonrpc_allow_missing_blocks: bool, + pub flag_no_jsonrpc: bool, + pub flag_jsonrpc_no_keep_alive: bool, + pub flag_jsonrpc_experimental: bool, + pub arg_jsonrpc_port: u16, + pub arg_jsonrpc_interface: String, + pub arg_jsonrpc_apis: String, + pub arg_jsonrpc_hosts: String, + pub arg_jsonrpc_threads: Option, + pub arg_jsonrpc_server_threads: Option, + pub arg_jsonrpc_cors: String, + pub arg_jsonrpc_max_payload: Option, + pub arg_poll_lifetime: u32, + pub flag_no_ws: bool, + pub arg_ws_port: u16, + pub arg_ws_interface: String, + pub arg_ws_apis: String, + pub arg_ws_origins: String, + pub arg_ws_hosts: String, + pub arg_ws_max_connections: usize, + pub flag_no_ipc: bool, + pub arg_ipc_path: String, + pub arg_ipc_chmod: String, + pub arg_ipc_apis: String, + pub arg_on_demand_response_time_window: Option, + pub arg_on_demand_request_backoff_start: Option, + pub arg_on_demand_request_backoff_max: Option, + pub arg_on_demand_request_backoff_rounds_max: Option, + pub arg_on_demand_request_consecutive_failures: Option, + pub flag_no_secretstore: bool, + pub flag_no_secretstore_http: bool, + pub flag_no_secretstore_auto_migrate: bool, + pub arg_secretstore_http_cors: String, + pub arg_secretstore_acl_contract: Option, + pub arg_secretstore_contract: Option, + pub arg_secretstore_srv_gen_contract: Option, + pub arg_secretstore_srv_retr_contract: Option, + pub arg_secretstore_doc_store_contract: Option, + pub arg_secretstore_doc_sretr_contract: Option, + pub arg_secretstore_nodes: String, + pub arg_secretstore_server_set_contract: Option, + pub arg_secretstore_interface: String, + pub arg_secretstore_port: u16, + pub arg_secretstore_http_interface: String, + pub arg_secretstore_http_port: u16, + pub arg_secretstore_path: String, + pub arg_secretstore_secret: Option, + pub arg_secretstore_admin_public: Option, + pub flag_force_sealing: bool, + pub flag_reseal_on_uncle: bool, + pub flag_remove_solved: bool, + pub flag_tx_queue_no_unfamiliar_locals: bool, + pub flag_tx_queue_no_early_reject: bool, + pub flag_refuse_service_transactions: bool, + pub flag_infinite_pending_block: bool, + pub flag_no_persistent_txqueue: bool, + pub flag_stratum: bool, + pub arg_reseal_on_txs: String, + pub arg_reseal_min_period: u64, + pub arg_reseal_max_period: u64, + pub arg_work_queue_size: usize, + pub arg_relay_set: String, + pub arg_usd_per_tx: String, + pub arg_usd_per_eth: String, + pub arg_price_update_period: String, + pub arg_gas_floor_target: String, + pub arg_gas_cap: String, + pub arg_tx_queue_mem_limit: u32, + pub arg_tx_queue_size: usize, + pub arg_tx_queue_per_sender: Option, + pub arg_tx_queue_locals: Option, + pub arg_tx_queue_strategy: String, + pub arg_stratum_interface: String, + pub arg_stratum_port: u16, + pub arg_min_gas_price: Option, + pub arg_gas_price_percentile: usize, + pub arg_author: Option, + pub arg_engine_signer: Option, + pub arg_tx_gas_limit: Option, + pub arg_tx_time_limit: Option, + pub arg_extra_data: Option, + pub arg_notify_work: Option, + pub arg_stratum_secret: Option, + pub arg_max_round_blocks_to_import: usize, + pub flag_can_restart: bool, + pub flag_no_color: bool, + // NOTE: This is auto handled by structopt + // pub flag_version: bool, + pub flag_no_config: bool, + pub arg_logging: Option, + pub arg_log_file: Option, + pub flag_scale_verifiers: bool, + pub arg_tracing: String, + pub arg_pruning: String, + pub arg_pruning_history: u64, + pub arg_pruning_memory: usize, + pub arg_cache_size_db: u32, + pub arg_cache_size_blocks: u32, + pub arg_cache_size_queue: u32, + pub arg_cache_size_state: u32, + pub arg_db_compaction: String, + pub arg_fat_db: String, + pub arg_cache_size: Option, + pub arg_num_verifiers: Option, + pub flag_no_seal_check: bool, + pub flag_no_periodic_snapshot: bool, + pub arg_snapshot_threads: Option, + pub flag_whisper: bool, + pub arg_whisper_pool_size: Option, + pub flag_geth: bool, + pub flag_import_geth_keys: bool, } impl Args { - pub fn parse() -> Result { - let mut args: Args = Default::default(); - - let mut raw_input = ArgsInput::from_args(); - - Args::save_current_config(&mut raw_input.globals)?; - - // This is the hardcoded config provided by openethereum, with - // no special presets - // FIXME: convert this to relative pathing - let fallback_config_path = "config_default.toml"; - - let default_config_path = match &raw_input.globals.convenience.config { - // the has given a custom configuration - Some(x) => { - match x.as_str() { - // presets - "dev" => "config_dev.toml", - "dev-insecure" => "config_dev_insecure.toml", - "insecure" => "config_insecure.toml", - "mining" => "config_mining.toml", - "non-standard-ports" => "config_non_standard_ports.toml", - - // user given config path - _ => x, - } - } - - // no input options for configuration - None => { - // We can make the default and the fallback the same - "config_default.toml" - } - }; - - let (default_config, fallback_config) = - Args::generate_default_configuration(default_config_path, fallback_config_path)?; - - args.from_cli(raw_input, default_config, fallback_config)?; - - Ok(args) - } - - pub fn save_current_config(globals: &mut Globals) -> Result<(), ArgsError> { - // We don't want to print the config generate option on the generated toml, so we - // reset it - let config_generate = globals.convenience.config_generate.clone(); - globals.convenience.config_generate = None; - - if let Some(path) = &config_generate { - let current_flags = match toml::to_string(globals) { - Ok(x) => x, - Err(_) => return Err(ArgsError::ConfigWriteError("Failed to generate valid config toml from current flags. Please report a bug if this error persists.".to_owned())), - }; - - if let Err(_) = fs::write(&path, current_flags) { - return Err(ArgsError::ConfigParseError(format!("Failed to write config to given file path: {}. Please try again with a valid path and config name.", &path))); - }; - } - Ok(()) - } - - pub fn generate_default_configuration( - default_config_path: &str, - fallback_config_path: &str, - ) -> Result<(Globals, Globals), ArgsError> { - // FIXME: throw an error when file is not found - let default_config_file:String = get_config(default_config_path)?; - let fallback_config_file:String = get_config(fallback_config_path)?; - - let default_config: Globals = match toml::from_str(&default_config_file) { - Ok(x) => x, - Err(e) => { - return Err(ArgsError::ConfigParseError(format!( - "Failure to parse config file: {}, error: {}", - default_config_path, e - ))) - } - }; - let fallback_config: Globals = match toml::from_str(&fallback_config_file) { - Ok(x) => x, - Err(_) => { - return Err(ArgsError::ConfigParseError(format!( - "Failure to parse config file: {}", - fallback_config_path - ))) - } - }; - - Ok((default_config, fallback_config)) - } - - pub fn from_cli( - &mut self, - cli_args: ArgsInput, - default_globals: Globals, - fallback_globals: Globals, - ) -> Result<(), ArgsError> { - self.from_subcommands(&cli_args)?; - self.from_globals(cli_args, default_globals, fallback_globals)?; - Ok(()) - } - - fn from_subcommands(&mut self, cli_args: &ArgsInput) -> Result<(), ArgsError> { - match &cli_args.subcommands { - None => {} - Some(subcommand) => match &subcommand { - SubCommands::Daemon(d) => { - self.cmd_daemon = true; - - self.arg_daemon_pid_file = d.pid_file.clone(); - } - SubCommands::Wallet { wallet } => { - self.cmd_wallet = true; - - let Wallet::Import { path } = wallet; - self.cmd_wallet_import = true; - self.arg_wallet_import_path = (*path).clone(); - } - SubCommands::Account { account } => { - self.cmd_account = true; - - match account { - Account::New => { - self.cmd_account_new = true; - } - Account::Import { path } => { - self.cmd_account_import = true; - self.arg_account_import_path = Some((*path).clone()); - } - Account::List => { - self.cmd_account_list = true; - } - } - } - SubCommands::Import(i) => { - self.cmd_import = true; - self.arg_import_format = i.format.clone(); - self.arg_import_file = i.file.clone(); - } - SubCommands::Export { export } => { - self.cmd_export = true; - match export { - Export::Blocks(eb) => { - self.cmd_export_blocks = true; - self.arg_export_blocks_format = eb.format.clone(); - self.arg_export_blocks_from = eb.from.clone(); - self.arg_export_blocks_to = eb.to.clone(); - self.arg_export_blocks_file = eb.file.clone(); - } - Export::State(es) => { - self.cmd_export_state = true; - self.flag_export_state_no_storage = es.no_storage; - self.flag_export_state_no_code = es.no_code; - self.arg_export_state_min_balance = es.min_balance.clone(); - self.arg_export_state_max_balance = es.max_balance.clone(); - self.arg_export_state_at = es.at.clone(); - self.arg_export_state_format = es.format.clone(); - self.arg_export_state_file = es.file.clone(); - } - } - } - SubCommands::Signer(s) => { - self.cmd_signer = true; - match s { - Signer::NewToken => { - self.cmd_signer_new_token = true; - } - Signer::List => { - self.cmd_signer_list = true; - } - Signer::Sign { id } => { - self.cmd_signer_sign = true; - self.arg_signer_sign_id = *id; - } - Signer::Reject { id } => { - self.cmd_signer_reject = true; - self.arg_signer_reject_id = *id; - } - } - } - SubCommands::Tools(t) => { - self.cmd_tools = true; - self.cmd_tools_hash = true; - - let Tools::Hash { file } = t; - self.arg_tools_hash_file = (*file).clone(); - } - SubCommands::Restore(r) => { - self.cmd_restore = true; - self.arg_restore_file = r.file.clone(); - } - SubCommands::Snapshots(s) => { - self.cmd_snapshot = true; - self.arg_snapshot_at = s.at.clone(); - self.arg_snapshot_file = s.file.clone(); - } - SubCommands::Db(db) => { - self.cmd_db = true; - match db { - Db::Kill => { - self.cmd_db_kill = true; - } - Db::Reset { num } => { - self.cmd_db_reset = true; - self.arg_db_reset_num = *num; - } - } - } - SubCommands::ExportHardcodedSync => { - self.cmd_export_hardcoded_sync = true; - } - SubCommands::Dapp(dapp) => { - self.cmd_dapp = true; - self.arg_dapp_path = dapp.path.clone(); - } - }, - } - Ok(()) - } - - fn select_value(raw: Option, default: Option, fallback: Option) -> T { - match (raw, default, fallback) { - (Some(x), _, _) => x, - (None, Some(x), _) => x, - (None, None, Some(x)) => x, - _ => todo!(), // FIXME: this case should never arise, but we need to fail gracefully if it does - } - } - - fn select_option(raw: Option, default: Option, fallback: Option) -> Option { - match (&raw, &default, &fallback) { - (None, None, Some(_)) => fallback, - (None, Some(_), _) => default, - // Handles the cases where there was a raw value, so we can ignore everything else - _ => raw, - } - } - - fn from_globals( - &mut self, - cli_args: ArgsInput, - defaults: Globals, - fallback: Globals, - ) -> Result<(), ArgsError> { - self.flags_from_globals(&cli_args, &defaults, &fallback); - self.options_from_globals(cli_args, defaults, fallback); - - if let (Some(min_peers), Some(max_peers)) = (self.arg_min_peers, self.arg_max_peers) { - if (max_peers >= min_peers).not() { - return Err(ArgsError::PeerConfigurationError( - "max-peers need to be greater than or equal to min-peers".to_owned(), - )); - } - } - Ok(()) - } - - fn options_from_globals(&mut self, cli_args: ArgsInput, defaults: Globals, fallback: Globals) { - // Unnatural cases - - self.arg_ipc_path = Args::select_value( - cli_args.globals.ipc.ipc_path, - IPCOptions::ipc_path_default(), - None, // We don't care about fallback in this case, since the previous operation is infallible - ); - self.arg_password = cli_args.globals.account.password; - - self.arg_config = Args::select_value( - cli_args.globals.convenience.config, - defaults.convenience.config, - fallback.convenience.config, - ); - self.arg_ports_shift = Args::select_value( - cli_args.globals.convenience.ports_shift, - defaults.convenience.ports_shift, - fallback.convenience.ports_shift, - ); - self.arg_keys_iterations = Args::select_value( - cli_args.globals.account.keys_iterations, - defaults.account.keys_iterations, - fallback.account.keys_iterations, - ); - self.arg_accounts_refresh = Args::select_value( - cli_args.globals.account.accounts_refresh, - defaults.account.accounts_refresh, - fallback.account.accounts_refresh, - ); - self.arg_unlock = Args::select_option( - cli_args.globals.account.unlock, - defaults.account.unlock, - fallback.account.unlock, - ); - self.arg_db_path = Args::select_option( - cli_args.globals.operating.db_path, - defaults.operating.db_path, - fallback.operating.db_path, - ); - self.arg_mode = Args::select_value( - cli_args.globals.operating.mode, - defaults.operating.mode, - fallback.operating.mode, - ); - self.arg_mode_timeout = Args::select_value( - cli_args.globals.operating.mode_timeout, - defaults.operating.mode_timeout, - fallback.operating.mode_timeout, - ); - self.arg_mode_alarm = Args::select_value( - cli_args.globals.operating.mode_alarm, - defaults.operating.mode_alarm, - fallback.operating.mode_alarm, - ); - self.arg_auto_update = Args::select_value( - cli_args.globals.operating.auto_update, - defaults.operating.auto_update, - fallback.operating.auto_update, - ); - self.arg_auto_update_delay = Args::select_value( - cli_args.globals.operating.auto_update_delay, - defaults.operating.auto_update_delay, - fallback.operating.auto_update_delay, - ); - self.arg_auto_update_check_frequency = Args::select_value( - cli_args.globals.operating.auto_update_check_frequency, - defaults.operating.auto_update_check_frequency, - fallback.operating.auto_update_check_frequency, - ); - self.arg_release_track = Args::select_value( - cli_args.globals.operating.release_track, - defaults.operating.release_track, - fallback.operating.release_track, - ); - self.arg_chain = Args::select_value( - cli_args.globals.operating.chain, - defaults.operating.chain, - fallback.operating.chain, - ); - self.arg_keys_path = Args::select_value( - cli_args.globals.operating.keys_path, - defaults.operating.keys_path, - fallback.operating.keys_path, - ); - self.arg_identity = Args::select_value( - cli_args.globals.operating.identity, - defaults.operating.identity, - fallback.operating.identity, - ); - self.arg_base_path = Args::select_option( - cli_args.globals.operating.base_path, - defaults.operating.base_path, - fallback.operating.base_path, - ); - self.arg_private_validators = Args::select_option( - cli_args.globals.private_transactions.private_validators, - defaults.private_transactions.private_validators, - fallback.private_transactions.private_validators, - ); - self.arg_private_account = Args::select_option( - cli_args.globals.private_transactions.private_account, - defaults.private_transactions.private_account, - fallback.private_transactions.private_account, - ); - self.arg_private_sstore_url = Args::select_option( - cli_args.globals.private_transactions.private_sstore_url, - defaults.private_transactions.private_sstore_url, - fallback.private_transactions.private_sstore_url, - ); - self.arg_private_sstore_threshold = Args::select_option( - cli_args - .globals - .private_transactions - .private_sstore_threshold, - defaults.private_transactions.private_sstore_threshold, - fallback.private_transactions.private_sstore_threshold, - ); - self.arg_private_passwords = Args::select_option( - cli_args.globals.private_transactions.private_passwords, - defaults.private_transactions.private_passwords, - fallback.private_transactions.private_passwords, - ); - self.arg_ui_path = Args::select_value( - cli_args.globals.ui_options.ui_path, - defaults.ui_options.ui_path, - fallback.ui_options.ui_path, - ); - self.arg_warp_barrier = Args::select_option( - cli_args.globals.networking.warp_barrier, - defaults.networking.warp_barrier, - fallback.networking.warp_barrier, - ); - self.arg_port = Args::select_value( - cli_args.globals.networking.port, - defaults.networking.port, - fallback.networking.port, - ); - self.arg_interface = Args::select_value( - cli_args.globals.networking.interface, - defaults.networking.interface, - fallback.networking.interface, - ); - self.arg_min_peers = Args::select_option( - cli_args.globals.networking.min_peers, - defaults.networking.min_peers, - fallback.networking.min_peers, - ); - self.arg_max_peers = Args::select_option( - cli_args.globals.networking.max_peers, - defaults.networking.max_peers, - fallback.networking.max_peers, - ); - self.arg_snapshot_peers = Args::select_value( - cli_args.globals.networking.snapshot_peers, - defaults.networking.snapshot_peers, - fallback.networking.snapshot_peers, - ); - self.arg_nat = Args::select_value( - cli_args.globals.networking.nat, - defaults.networking.nat, - fallback.networking.nat, - ); - self.arg_allow_ips = Args::select_value( - cli_args.globals.networking.allow_ips, - defaults.networking.allow_ips, - fallback.networking.allow_ips, - ); - self.arg_max_pending_peers = Args::select_value( - cli_args.globals.networking.max_pending_peers, - defaults.networking.max_pending_peers, - fallback.networking.max_pending_peers, - ); - self.arg_network_id = Args::select_option( - cli_args.globals.networking.network_id, - defaults.networking.network_id, - fallback.networking.network_id, - ); - self.arg_bootnodes = Args::select_option( - cli_args.globals.networking.bootnodes, - defaults.networking.bootnodes, - fallback.networking.bootnodes, - ); - self.arg_node_key = Args::select_option( - cli_args.globals.networking.node_key, - defaults.networking.node_key, - fallback.networking.node_key, - ); - self.arg_reserved_peers = Args::select_option( - cli_args.globals.networking.reserved_peers, - defaults.networking.reserved_peers, - fallback.networking.reserved_peers, - ); - self.arg_jsonrpc_port = Args::select_value( - cli_args.globals.http_json_rpc.jsonrpc_port, - defaults.http_json_rpc.jsonrpc_port, - fallback.http_json_rpc.jsonrpc_port, - ); - self.arg_jsonrpc_interface = Args::select_value( - cli_args.globals.http_json_rpc.jsonrpc_interface, - defaults.http_json_rpc.jsonrpc_interface, - fallback.http_json_rpc.jsonrpc_interface, - ); - self.arg_jsonrpc_apis = Args::select_value( - cli_args.globals.http_json_rpc.jsonrpc_apis, - defaults.http_json_rpc.jsonrpc_apis, - fallback.http_json_rpc.jsonrpc_apis, - ); - self.arg_jsonrpc_hosts = Args::select_value( - cli_args.globals.http_json_rpc.jsonrpc_hosts, - defaults.http_json_rpc.jsonrpc_hosts, - fallback.http_json_rpc.jsonrpc_hosts, - ); - self.arg_jsonrpc_threads = Args::select_option( - cli_args.globals.http_json_rpc.jsonrpc_threads, - defaults.http_json_rpc.jsonrpc_threads, - fallback.http_json_rpc.jsonrpc_threads, - ); - self.arg_jsonrpc_server_threads = Args::select_option( - cli_args.globals.http_json_rpc.jsonrpc_server_threads, - defaults.http_json_rpc.jsonrpc_server_threads, - fallback.http_json_rpc.jsonrpc_server_threads, - ); - self.arg_jsonrpc_cors = Args::select_value( - cli_args.globals.http_json_rpc.jsonrpc_cors, - defaults.http_json_rpc.jsonrpc_cors, - fallback.http_json_rpc.jsonrpc_cors, - ); - self.arg_jsonrpc_max_payload = Args::select_option( - cli_args.globals.http_json_rpc.jsonrpc_max_payload, - defaults.http_json_rpc.jsonrpc_max_payload, - fallback.http_json_rpc.jsonrpc_max_payload, - ); - self.arg_poll_lifetime = Args::select_value( - cli_args.globals.http_json_rpc.poll_lifetime, - defaults.http_json_rpc.poll_lifetime, - fallback.http_json_rpc.poll_lifetime, - ); - self.arg_ws_port = Args::select_value( - cli_args.globals.websockets.ws_port, - defaults.websockets.ws_port, - fallback.websockets.ws_port, - ); - self.arg_ws_interface = Args::select_value( - cli_args.globals.websockets.ws_interface, - defaults.websockets.ws_interface, - fallback.websockets.ws_interface, - ); - self.arg_ws_apis = Args::select_value( - cli_args.globals.websockets.ws_apis, - defaults.websockets.ws_apis, - fallback.websockets.ws_apis, - ); - self.arg_ws_origins = Args::select_value( - cli_args.globals.websockets.ws_origins, - defaults.websockets.ws_origins, - fallback.websockets.ws_origins, - ); - self.arg_ws_hosts = Args::select_value( - cli_args.globals.websockets.ws_hosts, - defaults.websockets.ws_hosts, - fallback.websockets.ws_hosts, - ); - self.arg_ws_max_connections = Args::select_value( - cli_args.globals.websockets.ws_max_connections, - defaults.websockets.ws_max_connections, - fallback.websockets.ws_max_connections, - ); - self.arg_ipc_chmod = Args::select_value( - cli_args.globals.ipc.ipc_chmod, - defaults.ipc.ipc_chmod, - fallback.ipc.ipc_chmod, - ); - self.arg_ipc_apis = Args::select_value( - cli_args.globals.ipc.ipc_apis, - defaults.ipc.ipc_apis, - fallback.ipc.ipc_apis, - ); - self.arg_on_demand_response_time_window = Args::select_option( - cli_args.globals.light_client.on_demand_response_time_window, - defaults.light_client.on_demand_response_time_window, - fallback.light_client.on_demand_response_time_window, - ); - self.arg_secretstore_http_cors = Args::select_value( - cli_args.globals.secret_store.secretstore_http_cors, - defaults.secret_store.secretstore_http_cors, - fallback.secret_store.secretstore_http_cors, - ); - self.arg_secretstore_acl_contract = Args::select_option( - cli_args.globals.secret_store.secretstore_acl_contract, - defaults.secret_store.secretstore_acl_contract, - fallback.secret_store.secretstore_acl_contract, - ); - self.arg_secretstore_contract = Args::select_option( - cli_args.globals.secret_store.secretstore_contract, - defaults.secret_store.secretstore_contract, - fallback.secret_store.secretstore_contract, - ); - self.arg_secretstore_interface = Args::select_value( - cli_args.globals.secret_store.secretstore_interface, - defaults.secret_store.secretstore_interface, - fallback.secret_store.secretstore_interface, - ); - self.arg_secretstore_port = Args::select_value( - cli_args.globals.secret_store.secretstore_port, - defaults.secret_store.secretstore_port, - fallback.secret_store.secretstore_port, - ); - self.arg_secretstore_http_port = Args::select_value( - cli_args.globals.secret_store.secretstore_http_port, - defaults.secret_store.secretstore_http_port, - fallback.secret_store.secretstore_http_port, - ); - self.arg_secretstore_path = Args::select_value( - cli_args.globals.secret_store.secretstore_path, - defaults.secret_store.secretstore_path, - fallback.secret_store.secretstore_path, - ); - self.arg_secretstore_secret = Args::select_option( - cli_args.globals.secret_store.secretstore_secret, - defaults.secret_store.secretstore_secret, - fallback.secret_store.secretstore_secret, - ); - self.arg_secretstore_admin_public = Args::select_option( - cli_args.globals.secret_store.secretstore_admin_public, - defaults.secret_store.secretstore_admin_public, - fallback.secret_store.secretstore_admin_public, - ); - self.arg_reseal_on_txs = Args::select_value( - cli_args.globals.sealing_mining.reseal_on_txs, - defaults.sealing_mining.reseal_on_txs, - fallback.sealing_mining.reseal_on_txs, - ); - self.arg_reseal_min_period = Args::select_value( - cli_args.globals.sealing_mining.reseal_min_period, - defaults.sealing_mining.reseal_min_period, - fallback.sealing_mining.reseal_min_period, - ); - self.arg_reseal_max_period = Args::select_value( - cli_args.globals.sealing_mining.reseal_max_period, - defaults.sealing_mining.reseal_max_period, - fallback.sealing_mining.reseal_max_period, - ); - self.arg_work_queue_size = Args::select_value( - cli_args.globals.sealing_mining.work_queue_size, - defaults.sealing_mining.work_queue_size, - fallback.sealing_mining.work_queue_size, - ); - self.arg_relay_set = Args::select_value( - cli_args.globals.sealing_mining.relay_set, - defaults.sealing_mining.relay_set, - fallback.sealing_mining.relay_set, - ); - self.arg_usd_per_tx = Args::select_value( - cli_args.globals.sealing_mining.usd_per_tx, - defaults.sealing_mining.usd_per_tx, - fallback.sealing_mining.usd_per_tx, - ); - self.arg_usd_per_eth = Args::select_value( - cli_args.globals.sealing_mining.usd_per_eth, - defaults.sealing_mining.usd_per_eth, - fallback.sealing_mining.usd_per_eth, - ); - self.arg_price_update_period = Args::select_value( - cli_args.globals.sealing_mining.price_update_period, - defaults.sealing_mining.price_update_period, - fallback.sealing_mining.price_update_period, - ); - self.arg_gas_floor_target = Args::select_value( - cli_args.globals.sealing_mining.gas_floor_target, - defaults.sealing_mining.gas_floor_target, - fallback.sealing_mining.gas_floor_target, - ); - self.arg_gas_cap = Args::select_value( - cli_args.globals.sealing_mining.gas_cap, - defaults.sealing_mining.gas_cap, - fallback.sealing_mining.gas_cap, - ); - self.arg_tx_queue_mem_limit = Args::select_value( - cli_args.globals.sealing_mining.tx_queue_mem_limit, - defaults.sealing_mining.tx_queue_mem_limit, - fallback.sealing_mining.tx_queue_mem_limit, - ); - self.arg_tx_queue_size = Args::select_value( - cli_args.globals.sealing_mining.tx_queue_size, - defaults.sealing_mining.tx_queue_size, - fallback.sealing_mining.tx_queue_size, - ); - self.arg_tx_queue_per_sender = Args::select_option( - cli_args.globals.sealing_mining.tx_queue_per_sender, - defaults.sealing_mining.tx_queue_per_sender, - fallback.sealing_mining.tx_queue_per_sender, - ); - self.arg_tx_queue_locals = Args::select_option( - cli_args.globals.sealing_mining.tx_queue_locals, - defaults.sealing_mining.tx_queue_locals, - fallback.sealing_mining.tx_queue_locals, - ); - self.arg_tx_queue_strategy = Args::select_value( - cli_args.globals.sealing_mining.tx_queue_strategy, - defaults.sealing_mining.tx_queue_strategy, - fallback.sealing_mining.tx_queue_strategy, - ); - self.arg_stratum_interface = Args::select_value( - cli_args.globals.sealing_mining.stratum_interface, - defaults.sealing_mining.stratum_interface, - fallback.sealing_mining.stratum_interface, - ); - self.arg_stratum_port = Args::select_value( - cli_args.globals.sealing_mining.stratum_port, - defaults.sealing_mining.stratum_port, - fallback.sealing_mining.stratum_port, - ); - self.arg_min_gas_price = Args::select_option( - cli_args.globals.sealing_mining.min_gas_price, - defaults.sealing_mining.min_gas_price, - fallback.sealing_mining.min_gas_price, - ); - self.arg_gas_price_percentile = Args::select_value( - cli_args.globals.sealing_mining.gas_price_percentile, - defaults.sealing_mining.gas_price_percentile, - fallback.sealing_mining.gas_price_percentile, - ); - self.arg_author = Args::select_option( - cli_args.globals.sealing_mining.author, - defaults.sealing_mining.author, - fallback.sealing_mining.author, - ); - self.arg_engine_signer = Args::select_option( - cli_args.globals.sealing_mining.engine_signer, - defaults.sealing_mining.engine_signer, - fallback.sealing_mining.engine_signer, - ); - self.arg_tx_gas_limit = Args::select_option( - cli_args.globals.sealing_mining.tx_gas_limit, - defaults.sealing_mining.tx_gas_limit, - fallback.sealing_mining.tx_gas_limit, - ); - self.arg_tx_time_limit = Args::select_option( - cli_args.globals.sealing_mining.tx_time_limit, - defaults.sealing_mining.tx_time_limit, - fallback.sealing_mining.tx_time_limit, - ); - self.arg_extra_data = Args::select_option( - cli_args.globals.sealing_mining.extra_data, - defaults.sealing_mining.extra_data, - fallback.sealing_mining.extra_data, - ); - self.arg_notify_work = Args::select_option( - cli_args.globals.sealing_mining.notify_work, - defaults.sealing_mining.notify_work, - fallback.sealing_mining.notify_work, - ); - self.arg_stratum_secret = Args::select_option( - cli_args.globals.sealing_mining.stratum_secret, - defaults.sealing_mining.stratum_secret, - fallback.sealing_mining.stratum_secret, - ); - self.arg_logging = Args::select_option( - cli_args.globals.miscellaneous.logging, - defaults.miscellaneous.logging, - fallback.miscellaneous.logging, - ); - self.arg_log_file = Args::select_option( - cli_args.globals.miscellaneous.log_file, - defaults.miscellaneous.log_file, - fallback.miscellaneous.log_file, - ); - self.arg_tracing = Args::select_value( - cli_args.globals.footprint.tracing, - defaults.footprint.tracing, - fallback.footprint.tracing, - ); - self.arg_pruning = Args::select_value( - cli_args.globals.footprint.pruning, - defaults.footprint.pruning, - fallback.footprint.pruning, - ); - self.arg_pruning_history = Args::select_value( - cli_args.globals.footprint.pruning_history, - defaults.footprint.pruning_history, - fallback.footprint.pruning_history, - ); - self.arg_pruning_memory = Args::select_value( - cli_args.globals.footprint.pruning_memory, - defaults.footprint.pruning_memory, - fallback.footprint.pruning_memory, - ); - self.arg_cache_size_db = Args::select_value( - cli_args.globals.footprint.cache_size_db, - defaults.footprint.cache_size_db, - fallback.footprint.cache_size_db, - ); - self.arg_cache_size_blocks = Args::select_value( - cli_args.globals.footprint.cache_size_blocks, - defaults.footprint.cache_size_blocks, - fallback.footprint.cache_size_blocks, - ); - self.arg_cache_size_queue = Args::select_value( - cli_args.globals.footprint.cache_size_queue, - defaults.footprint.cache_size_queue, - fallback.footprint.cache_size_queue, - ); - self.arg_cache_size_state = Args::select_value( - cli_args.globals.footprint.cache_size_state, - defaults.footprint.cache_size_state, - fallback.footprint.cache_size_state, - ); - self.arg_db_compaction = Args::select_value( - cli_args.globals.footprint.db_compaction, - defaults.footprint.db_compaction, - fallback.footprint.db_compaction, - ); - self.arg_fat_db = Args::select_value( - cli_args.globals.footprint.fat_db, - defaults.footprint.fat_db, - fallback.footprint.fat_db, - ); - self.arg_cache_size = Args::select_option( - cli_args.globals.footprint.cache_size, - defaults.footprint.cache_size, - fallback.footprint.cache_size, - ); - self.arg_num_verifiers = Args::select_option( - cli_args.globals.footprint.num_verifiers, - defaults.footprint.num_verifiers, - fallback.footprint.num_verifiers, - ); - self.arg_snapshot_threads = Args::select_option( - cli_args.globals.snapshot.snapshot_threads, - defaults.snapshot.snapshot_threads, - fallback.snapshot.snapshot_threads, - ); - self.arg_secretstore_http_interface = Args::select_value( - cli_args.globals.secret_store.secretstore_http_interface, - defaults.secret_store.secretstore_http_interface, - fallback.secret_store.secretstore_http_interface, - ); - self.arg_max_round_blocks_to_import = Args::select_value( - cli_args.globals.sealing_mining.max_round_blocks_to_import, - defaults.sealing_mining.max_round_blocks_to_import, - fallback.sealing_mining.max_round_blocks_to_import, - ); - self.arg_on_demand_request_backoff_start = Args::select_option( - cli_args - .globals - .light_client - .on_demand_request_backoff_start, - defaults.light_client.on_demand_request_backoff_start, - fallback.light_client.on_demand_request_backoff_start, - ); - self.arg_on_demand_request_backoff_max = Args::select_option( - cli_args.globals.light_client.on_demand_request_backoff_max, - defaults.light_client.on_demand_request_backoff_max, - fallback.light_client.on_demand_request_backoff_max, - ); - self.arg_on_demand_request_backoff_rounds_max = Args::select_option( - cli_args - .globals - .light_client - .on_demand_request_backoff_rounds_max, - defaults.light_client.on_demand_request_backoff_rounds_max, - fallback.light_client.on_demand_request_backoff_rounds_max, - ); - self.arg_on_demand_request_consecutive_failures = Args::select_option( - cli_args - .globals - .light_client - .on_demand_request_consecutive_failures, - defaults.light_client.on_demand_request_consecutive_failures, - fallback.light_client.on_demand_request_consecutive_failures, - ); - self.arg_secretstore_srv_gen_contract = Args::select_option( - cli_args.globals.secret_store.secretstore_srv_gen_contract, - defaults.secret_store.secretstore_srv_gen_contract, - fallback.secret_store.secretstore_srv_gen_contract, - ); - self.arg_secretstore_srv_retr_contract = Args::select_option( - cli_args.globals.secret_store.secretstore_srv_retr_contract, - defaults.secret_store.secretstore_srv_retr_contract, - fallback.secret_store.secretstore_srv_retr_contract, - ); - self.arg_secretstore_doc_store_contract = Args::select_option( - cli_args.globals.secret_store.secretstore_doc_store_contract, - defaults.secret_store.secretstore_doc_store_contract, - fallback.secret_store.secretstore_doc_store_contract, - ); - self.arg_secretstore_doc_sretr_contract = Args::select_option( - cli_args.globals.secret_store.secretstore_doc_sretr_contract, - defaults.secret_store.secretstore_doc_sretr_contract, - fallback.secret_store.secretstore_doc_sretr_contract, - ); - self.arg_secretstore_nodes = Args::select_value( - cli_args.globals.secret_store.secretstore_nodes, - defaults.secret_store.secretstore_nodes, - fallback.secret_store.secretstore_nodes, - ); - self.arg_secretstore_server_set_contract = Args::select_option( - cli_args - .globals - .secret_store - .secretstore_server_set_contract, - defaults.secret_store.secretstore_server_set_contract, - fallback.secret_store.secretstore_server_set_contract, - ); - self.arg_private_signer = Args::select_option( - cli_args.globals.private_transactions.private_signer, - defaults.private_transactions.private_signer, - fallback.private_transactions.private_signer, - ); - } - - fn flags_from_globals(&mut self, cli_args: &ArgsInput, defaults: &Globals, fallback: &Globals) { - self.arg_enable_signing_queue = cli_args.globals.account.enable_signing_queue - || defaults.account.enable_signing_queue - || fallback.account.enable_signing_queue; - - self.flag_fast_unlock = cli_args.globals.account.fast_unlock - || defaults.account.fast_unlock - || fallback.account.fast_unlock; - - self.flag_no_serve_light = cli_args.globals.networking.no_serve_light - || defaults.networking.no_serve_light - || fallback.networking.no_serve_light; - - self.flag_no_secretstore = cli_args.globals.secret_store.no_secretstore - || defaults.secret_store.no_secretstore - || fallback.secret_store.no_secretstore; - - self.flag_no_secretstore_http = cli_args.globals.secret_store.no_secretstore_http - || defaults.secret_store.no_secretstore_http - || fallback.secret_store.no_secretstore_http; - - self.flag_no_secretstore_auto_migrate = - cli_args.globals.secret_store.no_secretstore_auto_migrate - || defaults.secret_store.no_secretstore_auto_migrate - || fallback.secret_store.no_secretstore_auto_migrate; - - self.flag_no_ws = cli_args.globals.websockets.no_ws - || defaults.websockets.no_ws - || fallback.websockets.no_ws; - - self.flag_no_ipc = - cli_args.globals.ipc.no_ipc || defaults.ipc.no_ipc || fallback.ipc.no_ipc; - - self.flag_force_sealing = cli_args.globals.sealing_mining.force_sealing - || defaults.sealing_mining.force_sealing - || fallback.sealing_mining.force_sealing; - - self.flag_reseal_on_uncle = cli_args.globals.sealing_mining.reseal_on_uncle - || defaults.sealing_mining.reseal_on_uncle - || fallback.sealing_mining.reseal_on_uncle; - - self.flag_remove_solved = cli_args.globals.sealing_mining.remove_solved - || defaults.sealing_mining.remove_solved - || fallback.sealing_mining.remove_solved; - - self.flag_tx_queue_no_unfamiliar_locals = cli_args - .globals - .sealing_mining - .tx_queue_no_unfamiliar_locals - || defaults.sealing_mining.tx_queue_no_unfamiliar_locals - || fallback.sealing_mining.tx_queue_no_unfamiliar_locals; - - self.flag_tx_queue_no_early_reject = - cli_args.globals.sealing_mining.tx_queue_no_early_reject - || defaults.sealing_mining.tx_queue_no_early_reject - || fallback.sealing_mining.tx_queue_no_early_reject; - - self.flag_refuse_service_transactions = - cli_args.globals.sealing_mining.refuse_service_transactions - || defaults.sealing_mining.refuse_service_transactions - || fallback.sealing_mining.refuse_service_transactions; - - self.flag_infinite_pending_block = cli_args.globals.sealing_mining.infinite_pending_block - || defaults.sealing_mining.infinite_pending_block - || fallback.sealing_mining.infinite_pending_block; - - self.flag_no_persistent_txqueue = cli_args.globals.sealing_mining.no_persistent_txqueue - || defaults.sealing_mining.no_persistent_txqueue - || fallback.sealing_mining.no_persistent_txqueue; - - self.flag_stratum = cli_args.globals.sealing_mining.stratum - || defaults.sealing_mining.stratum - || fallback.sealing_mining.stratum; - - self.flag_no_seal_check = cli_args.globals.import_export.no_seal_check - || defaults.import_export.no_seal_check - || fallback.import_export.no_seal_check; - - self.flag_can_restart = cli_args.globals.internal.can_restart - || defaults.internal.can_restart - || fallback.internal.can_restart; - - self.flag_no_color = cli_args.globals.miscellaneous.no_color - || defaults.miscellaneous.no_color - || fallback.miscellaneous.no_color; - - self.flag_no_config = cli_args.globals.miscellaneous.no_config - || defaults.miscellaneous.no_config - || fallback.miscellaneous.no_config; - - self.flag_scale_verifiers = cli_args.globals.footprint.scale_verifiers - || defaults.footprint.scale_verifiers - || fallback.footprint.scale_verifiers; - - self.flag_no_periodic_snapshot = cli_args.globals.snapshot.no_periodic_snapshot - || defaults.snapshot.no_periodic_snapshot - || fallback.snapshot.no_periodic_snapshot; - - self.flag_no_download = cli_args.globals.operating.no_download - || defaults.operating.no_download - || fallback.operating.no_download; - - self.flag_no_consensus = cli_args.globals.operating.no_consensus - || defaults.operating.no_consensus - || fallback.operating.no_consensus; - - self.flag_light = cli_args.globals.operating.light - || defaults.operating.light - || fallback.operating.light; - - self.flag_no_hardcoded_sync = cli_args.globals.operating.light - || defaults.operating.light - || fallback.operating.light; - - self.flag_force_direct = cli_args.globals.operating.force_direct - || defaults.operating.force_direct - || fallback.operating.force_direct; - - self.flag_unsafe_expose = cli_args.globals.convenience.unsafe_expose - || defaults.convenience.unsafe_expose - || fallback.convenience.unsafe_expose; - - self.flag_private_enabled = cli_args.globals.private_transactions.private_enabled - || defaults.private_transactions.private_enabled - || fallback.private_transactions.private_enabled; - - self.flag_private_state_offchain = - cli_args.globals.private_transactions.private_state_offchain - || defaults.private_transactions.private_state_offchain - || fallback.private_transactions.private_state_offchain; - - self.flag_jsonrpc_allow_missing_blocks = - cli_args.globals.http_json_rpc.jsonrpc_allow_missing_blocks - || defaults.http_json_rpc.jsonrpc_allow_missing_blocks - || fallback.http_json_rpc.jsonrpc_allow_missing_blocks; - - self.flag_no_jsonrpc = cli_args.globals.http_json_rpc.no_jsonrpc - || defaults.http_json_rpc.no_jsonrpc - || fallback.http_json_rpc.no_jsonrpc; - - self.flag_jsonrpc_no_keep_alive = cli_args.globals.http_json_rpc.jsonrpc_no_keep_alive - || defaults.http_json_rpc.jsonrpc_no_keep_alive - || fallback.http_json_rpc.jsonrpc_no_keep_alive; - - self.flag_jsonrpc_experimental = cli_args.globals.http_json_rpc.jsonrpc_experimental - || defaults.http_json_rpc.jsonrpc_experimental - || fallback.http_json_rpc.jsonrpc_experimental; - - self.flag_no_warp = cli_args.globals.networking.no_warp - || defaults.networking.no_warp - || fallback.networking.no_warp; - - self.flag_no_discovery = cli_args.globals.networking.no_discovery - || defaults.networking.no_discovery - || fallback.networking.no_discovery; - - self.flag_reserved_only = cli_args.globals.networking.reserved_only - || defaults.networking.reserved_only - || fallback.networking.reserved_only; - - self.flag_no_ancient_blocks = cli_args.globals.networking.no_ancient_blocks - || defaults.networking.no_ancient_blocks - || fallback.networking.no_ancient_blocks; - - self.flag_geth = - cli_args.globals.legacy.geth || defaults.legacy.geth || fallback.legacy.geth; - - self.flag_import_geth_keys = cli_args.globals.legacy.import_geth_keys - || defaults.legacy.import_geth_keys - || fallback.legacy.import_geth_keys; - } + pub fn parse() -> Result { + let mut args: Args = Default::default(); + + let mut raw_input = ArgsInput::from_args(); + + Args::save_current_config(&mut raw_input.globals)?; + + // This is the hardcoded config provided by openethereum, with + // no special presets + // FIXME: convert this to relative pathing + let fallback_config_path = "config_default.toml"; + + let default_config_path = match &raw_input.globals.convenience.config { + // the has given a custom configuration + Some(x) => { + match x.as_str() { + // presets + "dev" => "config_dev.toml", + "dev-insecure" => "config_dev_insecure.toml", + "insecure" => "config_insecure.toml", + "mining" => "config_mining.toml", + "non-standard-ports" => "config_non_standard_ports.toml", + + // user given config path + _ => x, + } + } + + // no input options for configuration + None => { + // We can make the default and the fallback the same + "config_default.toml" + } + }; + + let (default_config, fallback_config) = + Args::generate_default_configuration(default_config_path, fallback_config_path)?; + + args.from_cli(raw_input, default_config, fallback_config)?; + + Ok(args) + } + + pub fn save_current_config(globals: &mut Globals) -> Result<(), ArgsError> { + // We don't want to print the config generate option on the generated toml, so we + // reset it + let config_generate = globals.convenience.config_generate.clone(); + globals.convenience.config_generate = None; + + if let Some(path) = &config_generate { + let current_flags = match toml::to_string(globals) { + Ok(x) => x, + Err(_) => return Err(ArgsError::ConfigWriteError("Failed to generate valid config toml from current flags. Please report a bug if this error persists.".to_owned())), + }; + + if let Err(_) = fs::write(&path, current_flags) { + return Err(ArgsError::ConfigParseError(format!("Failed to write config to given file path: {}. Please try again with a valid path and config name.", &path))); + }; + } + Ok(()) + } + + pub fn generate_default_configuration( + default_config_path: &str, + fallback_config_path: &str, + ) -> Result<(Globals, Globals), ArgsError> { + // FIXME: throw an error when file is not found + let default_config_file:String = get_config(default_config_path)?; + let fallback_config_file:String = get_config(fallback_config_path)?; + + let default_config: Globals = match toml::from_str(&default_config_file) { + Ok(x) => x, + Err(e) => { + return Err(ArgsError::ConfigParseError(format!( + "Failure to parse config file: {}, error: {}", + default_config_path, e + ))) + } + }; + let fallback_config: Globals = match toml::from_str(&fallback_config_file) { + Ok(x) => x, + Err(_) => { + return Err(ArgsError::ConfigParseError(format!( + "Failure to parse config file: {}", + fallback_config_path + ))) + } + }; + + Ok((default_config, fallback_config)) + } + + pub fn from_cli( + &mut self, + cli_args: ArgsInput, + default_globals: Globals, + fallback_globals: Globals, + ) -> Result<(), ArgsError> { + self.from_subcommands(&cli_args)?; + self.from_globals(cli_args, default_globals, fallback_globals)?; + Ok(()) + } + + fn from_subcommands(&mut self, cli_args: &ArgsInput) -> Result<(), ArgsError> { + match &cli_args.subcommands { + None => {} + Some(subcommand) => match &subcommand { + SubCommands::Daemon(d) => { + self.cmd_daemon = true; + + self.arg_daemon_pid_file = d.pid_file.clone(); + } + SubCommands::Wallet { wallet } => { + self.cmd_wallet = true; + + let Wallet::Import { path } = wallet; + self.cmd_wallet_import = true; + self.arg_wallet_import_path = (*path).clone(); + } + SubCommands::Account { account } => { + self.cmd_account = true; + + match account { + Account::New => { + self.cmd_account_new = true; + } + Account::Import { path } => { + self.cmd_account_import = true; + self.arg_account_import_path = Some((*path).clone()); + } + Account::List => { + self.cmd_account_list = true; + } + } + } + SubCommands::Import(i) => { + self.cmd_import = true; + self.arg_import_format = i.format.clone(); + self.arg_import_file = i.file.clone(); + } + SubCommands::Export { export } => { + self.cmd_export = true; + match export { + Export::Blocks(eb) => { + self.cmd_export_blocks = true; + self.arg_export_blocks_format = eb.format.clone(); + self.arg_export_blocks_from = eb.from.clone(); + self.arg_export_blocks_to = eb.to.clone(); + self.arg_export_blocks_file = eb.file.clone(); + } + Export::State(es) => { + self.cmd_export_state = true; + self.flag_export_state_no_storage = es.no_storage; + self.flag_export_state_no_code = es.no_code; + self.arg_export_state_min_balance = es.min_balance.clone(); + self.arg_export_state_max_balance = es.max_balance.clone(); + self.arg_export_state_at = es.at.clone(); + self.arg_export_state_format = es.format.clone(); + self.arg_export_state_file = es.file.clone(); + } + } + } + SubCommands::Signer(s) => { + self.cmd_signer = true; + match s { + Signer::NewToken => { + self.cmd_signer_new_token = true; + } + Signer::List => { + self.cmd_signer_list = true; + } + Signer::Sign { id } => { + self.cmd_signer_sign = true; + self.arg_signer_sign_id = *id; + } + Signer::Reject { id } => { + self.cmd_signer_reject = true; + self.arg_signer_reject_id = *id; + } + } + } + SubCommands::Tools(t) => { + self.cmd_tools = true; + self.cmd_tools_hash = true; + + let Tools::Hash { file } = t; + self.arg_tools_hash_file = (*file).clone(); + } + SubCommands::Restore(r) => { + self.cmd_restore = true; + self.arg_restore_file = r.file.clone(); + } + SubCommands::Snapshots(s) => { + self.cmd_snapshot = true; + self.arg_snapshot_at = s.at.clone(); + self.arg_snapshot_file = s.file.clone(); + } + SubCommands::Db(db) => { + self.cmd_db = true; + match db { + Db::Kill => { + self.cmd_db_kill = true; + } + Db::Reset { num } => { + self.cmd_db_reset = true; + self.arg_db_reset_num = *num; + } + } + } + SubCommands::ExportHardcodedSync => { + self.cmd_export_hardcoded_sync = true; + } + SubCommands::Dapp(dapp) => { + self.cmd_dapp = true; + self.arg_dapp_path = dapp.path.clone(); + } + }, + } + Ok(()) + } + + fn select_value(raw: Option, default: Option, fallback: Option) -> T { + match (raw, default, fallback) { + (Some(x), _, _) => x, + (None, Some(x), _) => x, + (None, None, Some(x)) => x, + _ => todo!(), // FIXME: this case should never arise, but we need to fail gracefully if it does + } + } + + fn select_option(raw: Option, default: Option, fallback: Option) -> Option { + match (&raw, &default, &fallback) { + (None, None, Some(_)) => fallback, + (None, Some(_), _) => default, + // Handles the cases where there was a raw value, so we can ignore everything else + _ => raw, + } + } + + fn from_globals( + &mut self, + cli_args: ArgsInput, + defaults: Globals, + fallback: Globals, + ) -> Result<(), ArgsError> { + self.flags_from_globals(&cli_args, &defaults, &fallback); + self.options_from_globals(cli_args, defaults, fallback); + + if let (Some(min_peers), Some(max_peers)) = (self.arg_min_peers, self.arg_max_peers) { + if (max_peers >= min_peers).not() { + return Err(ArgsError::PeerConfigurationError( + "max-peers need to be greater than or equal to min-peers".to_owned(), + )); + } + } + Ok(()) + } + + fn options_from_globals(&mut self, cli_args: ArgsInput, defaults: Globals, fallback: Globals) { + // Unnatural cases + + self.arg_ipc_path = Args::select_value( + cli_args.globals.ipc.ipc_path, + IPCOptions::ipc_path_default(), + None, // We don't care about fallback in this case, since the previous operation is infallible + ); + self.arg_password = cli_args.globals.account.password; + + self.arg_config = Args::select_value( + cli_args.globals.convenience.config, + defaults.convenience.config, + fallback.convenience.config, + ); + self.arg_ports_shift = Args::select_value( + cli_args.globals.convenience.ports_shift, + defaults.convenience.ports_shift, + fallback.convenience.ports_shift, + ); + self.arg_keys_iterations = Args::select_value( + cli_args.globals.account.keys_iterations, + defaults.account.keys_iterations, + fallback.account.keys_iterations, + ); + self.arg_accounts_refresh = Args::select_value( + cli_args.globals.account.accounts_refresh, + defaults.account.accounts_refresh, + fallback.account.accounts_refresh, + ); + self.arg_unlock = Args::select_option( + cli_args.globals.account.unlock, + defaults.account.unlock, + fallback.account.unlock, + ); + self.arg_db_path = Args::select_option( + cli_args.globals.operating.db_path, + defaults.operating.db_path, + fallback.operating.db_path, + ); + self.arg_mode = Args::select_value( + cli_args.globals.operating.mode, + defaults.operating.mode, + fallback.operating.mode, + ); + self.arg_mode_timeout = Args::select_value( + cli_args.globals.operating.mode_timeout, + defaults.operating.mode_timeout, + fallback.operating.mode_timeout, + ); + self.arg_mode_alarm = Args::select_value( + cli_args.globals.operating.mode_alarm, + defaults.operating.mode_alarm, + fallback.operating.mode_alarm, + ); + self.arg_auto_update = Args::select_value( + cli_args.globals.operating.auto_update, + defaults.operating.auto_update, + fallback.operating.auto_update, + ); + self.arg_auto_update_delay = Args::select_value( + cli_args.globals.operating.auto_update_delay, + defaults.operating.auto_update_delay, + fallback.operating.auto_update_delay, + ); + self.arg_auto_update_check_frequency = Args::select_value( + cli_args.globals.operating.auto_update_check_frequency, + defaults.operating.auto_update_check_frequency, + fallback.operating.auto_update_check_frequency, + ); + self.arg_release_track = Args::select_value( + cli_args.globals.operating.release_track, + defaults.operating.release_track, + fallback.operating.release_track, + ); + self.arg_chain = Args::select_value( + cli_args.globals.operating.chain, + defaults.operating.chain, + fallback.operating.chain, + ); + self.arg_keys_path = Args::select_value( + cli_args.globals.operating.keys_path, + defaults.operating.keys_path, + fallback.operating.keys_path, + ); + self.arg_identity = Args::select_value( + cli_args.globals.operating.identity, + defaults.operating.identity, + fallback.operating.identity, + ); + self.arg_base_path = Args::select_option( + cli_args.globals.operating.base_path, + defaults.operating.base_path, + fallback.operating.base_path, + ); + self.arg_private_validators = Args::select_option( + cli_args.globals.private_transactions.private_validators, + defaults.private_transactions.private_validators, + fallback.private_transactions.private_validators, + ); + self.arg_private_account = Args::select_option( + cli_args.globals.private_transactions.private_account, + defaults.private_transactions.private_account, + fallback.private_transactions.private_account, + ); + self.arg_private_sstore_url = Args::select_option( + cli_args.globals.private_transactions.private_sstore_url, + defaults.private_transactions.private_sstore_url, + fallback.private_transactions.private_sstore_url, + ); + self.arg_private_sstore_threshold = Args::select_option( + cli_args + .globals + .private_transactions + .private_sstore_threshold, + defaults.private_transactions.private_sstore_threshold, + fallback.private_transactions.private_sstore_threshold, + ); + self.arg_private_passwords = Args::select_option( + cli_args.globals.private_transactions.private_passwords, + defaults.private_transactions.private_passwords, + fallback.private_transactions.private_passwords, + ); + self.arg_ui_path = Args::select_value( + cli_args.globals.ui_options.ui_path, + defaults.ui_options.ui_path, + fallback.ui_options.ui_path, + ); + self.arg_warp_barrier = Args::select_option( + cli_args.globals.networking.warp_barrier, + defaults.networking.warp_barrier, + fallback.networking.warp_barrier, + ); + self.arg_port = Args::select_value( + cli_args.globals.networking.port, + defaults.networking.port, + fallback.networking.port, + ); + self.arg_interface = Args::select_value( + cli_args.globals.networking.interface, + defaults.networking.interface, + fallback.networking.interface, + ); + self.arg_min_peers = Args::select_option( + cli_args.globals.networking.min_peers, + defaults.networking.min_peers, + fallback.networking.min_peers, + ); + self.arg_max_peers = Args::select_option( + cli_args.globals.networking.max_peers, + defaults.networking.max_peers, + fallback.networking.max_peers, + ); + self.arg_snapshot_peers = Args::select_value( + cli_args.globals.networking.snapshot_peers, + defaults.networking.snapshot_peers, + fallback.networking.snapshot_peers, + ); + self.arg_nat = Args::select_value( + cli_args.globals.networking.nat, + defaults.networking.nat, + fallback.networking.nat, + ); + self.arg_allow_ips = Args::select_value( + cli_args.globals.networking.allow_ips, + defaults.networking.allow_ips, + fallback.networking.allow_ips, + ); + self.arg_max_pending_peers = Args::select_value( + cli_args.globals.networking.max_pending_peers, + defaults.networking.max_pending_peers, + fallback.networking.max_pending_peers, + ); + self.arg_network_id = Args::select_option( + cli_args.globals.networking.network_id, + defaults.networking.network_id, + fallback.networking.network_id, + ); + self.arg_bootnodes = Args::select_option( + cli_args.globals.networking.bootnodes, + defaults.networking.bootnodes, + fallback.networking.bootnodes, + ); + self.arg_node_key = Args::select_option( + cli_args.globals.networking.node_key, + defaults.networking.node_key, + fallback.networking.node_key, + ); + self.arg_reserved_peers = Args::select_option( + cli_args.globals.networking.reserved_peers, + defaults.networking.reserved_peers, + fallback.networking.reserved_peers, + ); + self.arg_jsonrpc_port = Args::select_value( + cli_args.globals.http_json_rpc.jsonrpc_port, + defaults.http_json_rpc.jsonrpc_port, + fallback.http_json_rpc.jsonrpc_port, + ); + self.arg_jsonrpc_interface = Args::select_value( + cli_args.globals.http_json_rpc.jsonrpc_interface, + defaults.http_json_rpc.jsonrpc_interface, + fallback.http_json_rpc.jsonrpc_interface, + ); + self.arg_jsonrpc_apis = Args::select_value( + cli_args.globals.http_json_rpc.jsonrpc_apis, + defaults.http_json_rpc.jsonrpc_apis, + fallback.http_json_rpc.jsonrpc_apis, + ); + self.arg_jsonrpc_hosts = Args::select_value( + cli_args.globals.http_json_rpc.jsonrpc_hosts, + defaults.http_json_rpc.jsonrpc_hosts, + fallback.http_json_rpc.jsonrpc_hosts, + ); + self.arg_jsonrpc_threads = Args::select_option( + cli_args.globals.http_json_rpc.jsonrpc_threads, + defaults.http_json_rpc.jsonrpc_threads, + fallback.http_json_rpc.jsonrpc_threads, + ); + self.arg_jsonrpc_server_threads = Args::select_option( + cli_args.globals.http_json_rpc.jsonrpc_server_threads, + defaults.http_json_rpc.jsonrpc_server_threads, + fallback.http_json_rpc.jsonrpc_server_threads, + ); + self.arg_jsonrpc_cors = Args::select_value( + cli_args.globals.http_json_rpc.jsonrpc_cors, + defaults.http_json_rpc.jsonrpc_cors, + fallback.http_json_rpc.jsonrpc_cors, + ); + self.arg_jsonrpc_max_payload = Args::select_option( + cli_args.globals.http_json_rpc.jsonrpc_max_payload, + defaults.http_json_rpc.jsonrpc_max_payload, + fallback.http_json_rpc.jsonrpc_max_payload, + ); + self.arg_poll_lifetime = Args::select_value( + cli_args.globals.http_json_rpc.poll_lifetime, + defaults.http_json_rpc.poll_lifetime, + fallback.http_json_rpc.poll_lifetime, + ); + self.arg_ws_port = Args::select_value( + cli_args.globals.websockets.ws_port, + defaults.websockets.ws_port, + fallback.websockets.ws_port, + ); + self.arg_ws_interface = Args::select_value( + cli_args.globals.websockets.ws_interface, + defaults.websockets.ws_interface, + fallback.websockets.ws_interface, + ); + self.arg_ws_apis = Args::select_value( + cli_args.globals.websockets.ws_apis, + defaults.websockets.ws_apis, + fallback.websockets.ws_apis, + ); + self.arg_ws_origins = Args::select_value( + cli_args.globals.websockets.ws_origins, + defaults.websockets.ws_origins, + fallback.websockets.ws_origins, + ); + self.arg_ws_hosts = Args::select_value( + cli_args.globals.websockets.ws_hosts, + defaults.websockets.ws_hosts, + fallback.websockets.ws_hosts, + ); + self.arg_ws_max_connections = Args::select_value( + cli_args.globals.websockets.ws_max_connections, + defaults.websockets.ws_max_connections, + fallback.websockets.ws_max_connections, + ); + self.arg_ipc_chmod = Args::select_value( + cli_args.globals.ipc.ipc_chmod, + defaults.ipc.ipc_chmod, + fallback.ipc.ipc_chmod, + ); + self.arg_ipc_apis = Args::select_value( + cli_args.globals.ipc.ipc_apis, + defaults.ipc.ipc_apis, + fallback.ipc.ipc_apis, + ); + self.arg_on_demand_response_time_window = Args::select_option( + cli_args.globals.light_client.on_demand_response_time_window, + defaults.light_client.on_demand_response_time_window, + fallback.light_client.on_demand_response_time_window, + ); + self.arg_secretstore_http_cors = Args::select_value( + cli_args.globals.secret_store.secretstore_http_cors, + defaults.secret_store.secretstore_http_cors, + fallback.secret_store.secretstore_http_cors, + ); + self.arg_secretstore_acl_contract = Args::select_option( + cli_args.globals.secret_store.secretstore_acl_contract, + defaults.secret_store.secretstore_acl_contract, + fallback.secret_store.secretstore_acl_contract, + ); + self.arg_secretstore_contract = Args::select_option( + cli_args.globals.secret_store.secretstore_contract, + defaults.secret_store.secretstore_contract, + fallback.secret_store.secretstore_contract, + ); + self.arg_secretstore_interface = Args::select_value( + cli_args.globals.secret_store.secretstore_interface, + defaults.secret_store.secretstore_interface, + fallback.secret_store.secretstore_interface, + ); + self.arg_secretstore_port = Args::select_value( + cli_args.globals.secret_store.secretstore_port, + defaults.secret_store.secretstore_port, + fallback.secret_store.secretstore_port, + ); + self.arg_secretstore_http_port = Args::select_value( + cli_args.globals.secret_store.secretstore_http_port, + defaults.secret_store.secretstore_http_port, + fallback.secret_store.secretstore_http_port, + ); + self.arg_secretstore_path = Args::select_value( + cli_args.globals.secret_store.secretstore_path, + defaults.secret_store.secretstore_path, + fallback.secret_store.secretstore_path, + ); + self.arg_secretstore_secret = Args::select_option( + cli_args.globals.secret_store.secretstore_secret, + defaults.secret_store.secretstore_secret, + fallback.secret_store.secretstore_secret, + ); + self.arg_secretstore_admin_public = Args::select_option( + cli_args.globals.secret_store.secretstore_admin_public, + defaults.secret_store.secretstore_admin_public, + fallback.secret_store.secretstore_admin_public, + ); + self.arg_reseal_on_txs = Args::select_value( + cli_args.globals.sealing_mining.reseal_on_txs, + defaults.sealing_mining.reseal_on_txs, + fallback.sealing_mining.reseal_on_txs, + ); + self.arg_reseal_min_period = Args::select_value( + cli_args.globals.sealing_mining.reseal_min_period, + defaults.sealing_mining.reseal_min_period, + fallback.sealing_mining.reseal_min_period, + ); + self.arg_reseal_max_period = Args::select_value( + cli_args.globals.sealing_mining.reseal_max_period, + defaults.sealing_mining.reseal_max_period, + fallback.sealing_mining.reseal_max_period, + ); + self.arg_work_queue_size = Args::select_value( + cli_args.globals.sealing_mining.work_queue_size, + defaults.sealing_mining.work_queue_size, + fallback.sealing_mining.work_queue_size, + ); + self.arg_relay_set = Args::select_value( + cli_args.globals.sealing_mining.relay_set, + defaults.sealing_mining.relay_set, + fallback.sealing_mining.relay_set, + ); + self.arg_usd_per_tx = Args::select_value( + cli_args.globals.sealing_mining.usd_per_tx, + defaults.sealing_mining.usd_per_tx, + fallback.sealing_mining.usd_per_tx, + ); + self.arg_usd_per_eth = Args::select_value( + cli_args.globals.sealing_mining.usd_per_eth, + defaults.sealing_mining.usd_per_eth, + fallback.sealing_mining.usd_per_eth, + ); + self.arg_price_update_period = Args::select_value( + cli_args.globals.sealing_mining.price_update_period, + defaults.sealing_mining.price_update_period, + fallback.sealing_mining.price_update_period, + ); + self.arg_gas_floor_target = Args::select_value( + cli_args.globals.sealing_mining.gas_floor_target, + defaults.sealing_mining.gas_floor_target, + fallback.sealing_mining.gas_floor_target, + ); + self.arg_gas_cap = Args::select_value( + cli_args.globals.sealing_mining.gas_cap, + defaults.sealing_mining.gas_cap, + fallback.sealing_mining.gas_cap, + ); + self.arg_tx_queue_mem_limit = Args::select_value( + cli_args.globals.sealing_mining.tx_queue_mem_limit, + defaults.sealing_mining.tx_queue_mem_limit, + fallback.sealing_mining.tx_queue_mem_limit, + ); + self.arg_tx_queue_size = Args::select_value( + cli_args.globals.sealing_mining.tx_queue_size, + defaults.sealing_mining.tx_queue_size, + fallback.sealing_mining.tx_queue_size, + ); + self.arg_tx_queue_per_sender = Args::select_option( + cli_args.globals.sealing_mining.tx_queue_per_sender, + defaults.sealing_mining.tx_queue_per_sender, + fallback.sealing_mining.tx_queue_per_sender, + ); + self.arg_tx_queue_locals = Args::select_option( + cli_args.globals.sealing_mining.tx_queue_locals, + defaults.sealing_mining.tx_queue_locals, + fallback.sealing_mining.tx_queue_locals, + ); + self.arg_tx_queue_strategy = Args::select_value( + cli_args.globals.sealing_mining.tx_queue_strategy, + defaults.sealing_mining.tx_queue_strategy, + fallback.sealing_mining.tx_queue_strategy, + ); + self.arg_stratum_interface = Args::select_value( + cli_args.globals.sealing_mining.stratum_interface, + defaults.sealing_mining.stratum_interface, + fallback.sealing_mining.stratum_interface, + ); + self.arg_stratum_port = Args::select_value( + cli_args.globals.sealing_mining.stratum_port, + defaults.sealing_mining.stratum_port, + fallback.sealing_mining.stratum_port, + ); + self.arg_min_gas_price = Args::select_option( + cli_args.globals.sealing_mining.min_gas_price, + defaults.sealing_mining.min_gas_price, + fallback.sealing_mining.min_gas_price, + ); + self.arg_gas_price_percentile = Args::select_value( + cli_args.globals.sealing_mining.gas_price_percentile, + defaults.sealing_mining.gas_price_percentile, + fallback.sealing_mining.gas_price_percentile, + ); + self.arg_author = Args::select_option( + cli_args.globals.sealing_mining.author, + defaults.sealing_mining.author, + fallback.sealing_mining.author, + ); + self.arg_engine_signer = Args::select_option( + cli_args.globals.sealing_mining.engine_signer, + defaults.sealing_mining.engine_signer, + fallback.sealing_mining.engine_signer, + ); + self.arg_tx_gas_limit = Args::select_option( + cli_args.globals.sealing_mining.tx_gas_limit, + defaults.sealing_mining.tx_gas_limit, + fallback.sealing_mining.tx_gas_limit, + ); + self.arg_tx_time_limit = Args::select_option( + cli_args.globals.sealing_mining.tx_time_limit, + defaults.sealing_mining.tx_time_limit, + fallback.sealing_mining.tx_time_limit, + ); + self.arg_extra_data = Args::select_option( + cli_args.globals.sealing_mining.extra_data, + defaults.sealing_mining.extra_data, + fallback.sealing_mining.extra_data, + ); + self.arg_notify_work = Args::select_option( + cli_args.globals.sealing_mining.notify_work, + defaults.sealing_mining.notify_work, + fallback.sealing_mining.notify_work, + ); + self.arg_stratum_secret = Args::select_option( + cli_args.globals.sealing_mining.stratum_secret, + defaults.sealing_mining.stratum_secret, + fallback.sealing_mining.stratum_secret, + ); + self.arg_logging = Args::select_option( + cli_args.globals.miscellaneous.logging, + defaults.miscellaneous.logging, + fallback.miscellaneous.logging, + ); + self.arg_log_file = Args::select_option( + cli_args.globals.miscellaneous.log_file, + defaults.miscellaneous.log_file, + fallback.miscellaneous.log_file, + ); + self.arg_tracing = Args::select_value( + cli_args.globals.footprint.tracing, + defaults.footprint.tracing, + fallback.footprint.tracing, + ); + self.arg_pruning = Args::select_value( + cli_args.globals.footprint.pruning, + defaults.footprint.pruning, + fallback.footprint.pruning, + ); + self.arg_pruning_history = Args::select_value( + cli_args.globals.footprint.pruning_history, + defaults.footprint.pruning_history, + fallback.footprint.pruning_history, + ); + self.arg_pruning_memory = Args::select_value( + cli_args.globals.footprint.pruning_memory, + defaults.footprint.pruning_memory, + fallback.footprint.pruning_memory, + ); + self.arg_cache_size_db = Args::select_value( + cli_args.globals.footprint.cache_size_db, + defaults.footprint.cache_size_db, + fallback.footprint.cache_size_db, + ); + self.arg_cache_size_blocks = Args::select_value( + cli_args.globals.footprint.cache_size_blocks, + defaults.footprint.cache_size_blocks, + fallback.footprint.cache_size_blocks, + ); + self.arg_cache_size_queue = Args::select_value( + cli_args.globals.footprint.cache_size_queue, + defaults.footprint.cache_size_queue, + fallback.footprint.cache_size_queue, + ); + self.arg_cache_size_state = Args::select_value( + cli_args.globals.footprint.cache_size_state, + defaults.footprint.cache_size_state, + fallback.footprint.cache_size_state, + ); + self.arg_db_compaction = Args::select_value( + cli_args.globals.footprint.db_compaction, + defaults.footprint.db_compaction, + fallback.footprint.db_compaction, + ); + self.arg_fat_db = Args::select_value( + cli_args.globals.footprint.fat_db, + defaults.footprint.fat_db, + fallback.footprint.fat_db, + ); + self.arg_cache_size = Args::select_option( + cli_args.globals.footprint.cache_size, + defaults.footprint.cache_size, + fallback.footprint.cache_size, + ); + self.arg_num_verifiers = Args::select_option( + cli_args.globals.footprint.num_verifiers, + defaults.footprint.num_verifiers, + fallback.footprint.num_verifiers, + ); + self.arg_snapshot_threads = Args::select_option( + cli_args.globals.snapshot.snapshot_threads, + defaults.snapshot.snapshot_threads, + fallback.snapshot.snapshot_threads, + ); + self.arg_secretstore_http_interface = Args::select_value( + cli_args.globals.secret_store.secretstore_http_interface, + defaults.secret_store.secretstore_http_interface, + fallback.secret_store.secretstore_http_interface, + ); + self.arg_max_round_blocks_to_import = Args::select_value( + cli_args.globals.sealing_mining.max_round_blocks_to_import, + defaults.sealing_mining.max_round_blocks_to_import, + fallback.sealing_mining.max_round_blocks_to_import, + ); + self.arg_on_demand_request_backoff_start = Args::select_option( + cli_args + .globals + .light_client + .on_demand_request_backoff_start, + defaults.light_client.on_demand_request_backoff_start, + fallback.light_client.on_demand_request_backoff_start, + ); + self.arg_on_demand_request_backoff_max = Args::select_option( + cli_args.globals.light_client.on_demand_request_backoff_max, + defaults.light_client.on_demand_request_backoff_max, + fallback.light_client.on_demand_request_backoff_max, + ); + self.arg_on_demand_request_backoff_rounds_max = Args::select_option( + cli_args + .globals + .light_client + .on_demand_request_backoff_rounds_max, + defaults.light_client.on_demand_request_backoff_rounds_max, + fallback.light_client.on_demand_request_backoff_rounds_max, + ); + self.arg_on_demand_request_consecutive_failures = Args::select_option( + cli_args + .globals + .light_client + .on_demand_request_consecutive_failures, + defaults.light_client.on_demand_request_consecutive_failures, + fallback.light_client.on_demand_request_consecutive_failures, + ); + self.arg_secretstore_srv_gen_contract = Args::select_option( + cli_args.globals.secret_store.secretstore_srv_gen_contract, + defaults.secret_store.secretstore_srv_gen_contract, + fallback.secret_store.secretstore_srv_gen_contract, + ); + self.arg_secretstore_srv_retr_contract = Args::select_option( + cli_args.globals.secret_store.secretstore_srv_retr_contract, + defaults.secret_store.secretstore_srv_retr_contract, + fallback.secret_store.secretstore_srv_retr_contract, + ); + self.arg_secretstore_doc_store_contract = Args::select_option( + cli_args.globals.secret_store.secretstore_doc_store_contract, + defaults.secret_store.secretstore_doc_store_contract, + fallback.secret_store.secretstore_doc_store_contract, + ); + self.arg_secretstore_doc_sretr_contract = Args::select_option( + cli_args.globals.secret_store.secretstore_doc_sretr_contract, + defaults.secret_store.secretstore_doc_sretr_contract, + fallback.secret_store.secretstore_doc_sretr_contract, + ); + self.arg_secretstore_nodes = Args::select_value( + cli_args.globals.secret_store.secretstore_nodes, + defaults.secret_store.secretstore_nodes, + fallback.secret_store.secretstore_nodes, + ); + self.arg_secretstore_server_set_contract = Args::select_option( + cli_args + .globals + .secret_store + .secretstore_server_set_contract, + defaults.secret_store.secretstore_server_set_contract, + fallback.secret_store.secretstore_server_set_contract, + ); + self.arg_private_signer = Args::select_option( + cli_args.globals.private_transactions.private_signer, + defaults.private_transactions.private_signer, + fallback.private_transactions.private_signer, + ); + } + + fn flags_from_globals(&mut self, cli_args: &ArgsInput, defaults: &Globals, fallback: &Globals) { + self.arg_enable_signing_queue = cli_args.globals.account.enable_signing_queue + || defaults.account.enable_signing_queue + || fallback.account.enable_signing_queue; + + self.flag_fast_unlock = cli_args.globals.account.fast_unlock + || defaults.account.fast_unlock + || fallback.account.fast_unlock; + + self.flag_no_serve_light = cli_args.globals.networking.no_serve_light + || defaults.networking.no_serve_light + || fallback.networking.no_serve_light; + + self.flag_no_secretstore = cli_args.globals.secret_store.no_secretstore + || defaults.secret_store.no_secretstore + || fallback.secret_store.no_secretstore; + + self.flag_no_secretstore_http = cli_args.globals.secret_store.no_secretstore_http + || defaults.secret_store.no_secretstore_http + || fallback.secret_store.no_secretstore_http; + + self.flag_no_secretstore_auto_migrate = + cli_args.globals.secret_store.no_secretstore_auto_migrate + || defaults.secret_store.no_secretstore_auto_migrate + || fallback.secret_store.no_secretstore_auto_migrate; + + self.flag_no_ws = cli_args.globals.websockets.no_ws + || defaults.websockets.no_ws + || fallback.websockets.no_ws; + + self.flag_no_ipc = + cli_args.globals.ipc.no_ipc || defaults.ipc.no_ipc || fallback.ipc.no_ipc; + + self.flag_force_sealing = cli_args.globals.sealing_mining.force_sealing + || defaults.sealing_mining.force_sealing + || fallback.sealing_mining.force_sealing; + + self.flag_reseal_on_uncle = cli_args.globals.sealing_mining.reseal_on_uncle + || defaults.sealing_mining.reseal_on_uncle + || fallback.sealing_mining.reseal_on_uncle; + + self.flag_remove_solved = cli_args.globals.sealing_mining.remove_solved + || defaults.sealing_mining.remove_solved + || fallback.sealing_mining.remove_solved; + + self.flag_tx_queue_no_unfamiliar_locals = cli_args + .globals + .sealing_mining + .tx_queue_no_unfamiliar_locals + || defaults.sealing_mining.tx_queue_no_unfamiliar_locals + || fallback.sealing_mining.tx_queue_no_unfamiliar_locals; + + self.flag_tx_queue_no_early_reject = + cli_args.globals.sealing_mining.tx_queue_no_early_reject + || defaults.sealing_mining.tx_queue_no_early_reject + || fallback.sealing_mining.tx_queue_no_early_reject; + + self.flag_refuse_service_transactions = + cli_args.globals.sealing_mining.refuse_service_transactions + || defaults.sealing_mining.refuse_service_transactions + || fallback.sealing_mining.refuse_service_transactions; + + self.flag_infinite_pending_block = cli_args.globals.sealing_mining.infinite_pending_block + || defaults.sealing_mining.infinite_pending_block + || fallback.sealing_mining.infinite_pending_block; + + self.flag_no_persistent_txqueue = cli_args.globals.sealing_mining.no_persistent_txqueue + || defaults.sealing_mining.no_persistent_txqueue + || fallback.sealing_mining.no_persistent_txqueue; + + self.flag_stratum = cli_args.globals.sealing_mining.stratum + || defaults.sealing_mining.stratum + || fallback.sealing_mining.stratum; + + self.flag_no_seal_check = cli_args.globals.import_export.no_seal_check + || defaults.import_export.no_seal_check + || fallback.import_export.no_seal_check; + + self.flag_can_restart = cli_args.globals.internal.can_restart + || defaults.internal.can_restart + || fallback.internal.can_restart; + + self.flag_no_color = cli_args.globals.miscellaneous.no_color + || defaults.miscellaneous.no_color + || fallback.miscellaneous.no_color; + + self.flag_no_config = cli_args.globals.miscellaneous.no_config + || defaults.miscellaneous.no_config + || fallback.miscellaneous.no_config; + + self.flag_scale_verifiers = cli_args.globals.footprint.scale_verifiers + || defaults.footprint.scale_verifiers + || fallback.footprint.scale_verifiers; + + self.flag_no_periodic_snapshot = cli_args.globals.snapshot.no_periodic_snapshot + || defaults.snapshot.no_periodic_snapshot + || fallback.snapshot.no_periodic_snapshot; + + self.flag_no_download = cli_args.globals.operating.no_download + || defaults.operating.no_download + || fallback.operating.no_download; + + self.flag_no_consensus = cli_args.globals.operating.no_consensus + || defaults.operating.no_consensus + || fallback.operating.no_consensus; + + self.flag_light = cli_args.globals.operating.light + || defaults.operating.light + || fallback.operating.light; + + self.flag_no_hardcoded_sync = cli_args.globals.operating.light + || defaults.operating.light + || fallback.operating.light; + + self.flag_force_direct = cli_args.globals.operating.force_direct + || defaults.operating.force_direct + || fallback.operating.force_direct; + + self.flag_unsafe_expose = cli_args.globals.convenience.unsafe_expose + || defaults.convenience.unsafe_expose + || fallback.convenience.unsafe_expose; + + self.flag_private_enabled = cli_args.globals.private_transactions.private_enabled + || defaults.private_transactions.private_enabled + || fallback.private_transactions.private_enabled; + + self.flag_private_state_offchain = + cli_args.globals.private_transactions.private_state_offchain + || defaults.private_transactions.private_state_offchain + || fallback.private_transactions.private_state_offchain; + + self.flag_jsonrpc_allow_missing_blocks = + cli_args.globals.http_json_rpc.jsonrpc_allow_missing_blocks + || defaults.http_json_rpc.jsonrpc_allow_missing_blocks + || fallback.http_json_rpc.jsonrpc_allow_missing_blocks; + + self.flag_no_jsonrpc = cli_args.globals.http_json_rpc.no_jsonrpc + || defaults.http_json_rpc.no_jsonrpc + || fallback.http_json_rpc.no_jsonrpc; + + self.flag_jsonrpc_no_keep_alive = cli_args.globals.http_json_rpc.jsonrpc_no_keep_alive + || defaults.http_json_rpc.jsonrpc_no_keep_alive + || fallback.http_json_rpc.jsonrpc_no_keep_alive; + + self.flag_jsonrpc_experimental = cli_args.globals.http_json_rpc.jsonrpc_experimental + || defaults.http_json_rpc.jsonrpc_experimental + || fallback.http_json_rpc.jsonrpc_experimental; + + self.flag_no_warp = cli_args.globals.networking.no_warp + || defaults.networking.no_warp + || fallback.networking.no_warp; + + self.flag_no_discovery = cli_args.globals.networking.no_discovery + || defaults.networking.no_discovery + || fallback.networking.no_discovery; + + self.flag_reserved_only = cli_args.globals.networking.reserved_only + || defaults.networking.reserved_only + || fallback.networking.reserved_only; + + self.flag_no_ancient_blocks = cli_args.globals.networking.no_ancient_blocks + || defaults.networking.no_ancient_blocks + || fallback.networking.no_ancient_blocks; + + self.flag_geth = + cli_args.globals.legacy.geth || defaults.legacy.geth || fallback.legacy.geth; + + self.flag_import_geth_keys = cli_args.globals.legacy.import_geth_keys + || defaults.legacy.import_geth_keys + || fallback.legacy.import_geth_keys; + } } diff --git a/parity/cli/config.rs b/parity/cli/config.rs index 5d085616f96..d63f8e5296e 100644 --- a/parity/cli/config.rs +++ b/parity/cli/config.rs @@ -6,11 +6,11 @@ use rust_embed::RustEmbed; struct Config; pub fn get_config(config_name: &str) -> Result { - match Config::get(config_name) { - Some(x) => Ok((std::str::from_utf8(x.as_ref()).unwrap()).to_owned()), - None => Err(ArgsError::ConfigReadError(format!( - "Failure to read config file: {}", - config_name - ))), - } + match Config::get(config_name) { + Some(x) => Ok((std::str::from_utf8(x.as_ref()).unwrap()).to_owned()), + None => Err(ArgsError::ConfigReadError(format!( + "Failure to read config file: {}", + config_name + ))), + } } diff --git a/parity/cli/globals.rs b/parity/cli/globals.rs index d8709e82756..1c4c5c9732c 100644 --- a/parity/cli/globals.rs +++ b/parity/cli/globals.rs @@ -3,1174 +3,1174 @@ use structopt::StructOpt; #[derive(PartialEq, Default, StructOpt, Serialize, Deserialize, Debug, Clone)] pub struct Globals { - #[structopt(flatten)] - pub operating: OperatingOptions, + #[structopt(flatten)] + pub operating: OperatingOptions, - #[structopt(flatten)] - pub convenience: ConvenienceOptions, + #[structopt(flatten)] + pub convenience: ConvenienceOptions, - #[structopt(flatten)] - pub account: AccountOptions, + #[structopt(flatten)] + pub account: AccountOptions, - #[structopt(flatten)] - pub private_transactions: PrivateTransactions, + #[structopt(flatten)] + pub private_transactions: PrivateTransactions, - #[structopt(flatten)] - pub ui_options: UIOptons, + #[structopt(flatten)] + pub ui_options: UIOptons, - #[structopt(flatten)] - pub networking: NetworkingOptions, + #[structopt(flatten)] + pub networking: NetworkingOptions, - #[structopt(flatten)] - pub ipc: IPCOptions, + #[structopt(flatten)] + pub ipc: IPCOptions, - #[structopt(flatten)] - pub http_json_rpc: HTTP_JSON_RPC_Options, + #[structopt(flatten)] + pub http_json_rpc: HTTP_JSON_RPC_Options, - #[structopt(flatten)] - pub light_client: LightClientOptions, + #[structopt(flatten)] + pub light_client: LightClientOptions, - #[structopt(flatten)] - pub websockets: WebsocketsOptions, + #[structopt(flatten)] + pub websockets: WebsocketsOptions, - #[structopt(flatten)] - pub secret_store: SecretStoreOptions, + #[structopt(flatten)] + pub secret_store: SecretStoreOptions, - #[structopt(flatten)] - pub sealing_mining: SealingMiningOptions, + #[structopt(flatten)] + pub sealing_mining: SealingMiningOptions, - #[structopt(flatten)] - pub internal: InternalOptions, + #[structopt(flatten)] + pub internal: InternalOptions, - #[structopt(flatten)] - pub miscellaneous: MiscellaneousOptions, + #[structopt(flatten)] + pub miscellaneous: MiscellaneousOptions, - #[structopt(flatten)] - pub footprint: FootPrintOptions, + #[structopt(flatten)] + pub footprint: FootPrintOptions, - #[structopt(flatten)] - pub import_export: ImportExportOptions, + #[structopt(flatten)] + pub import_export: ImportExportOptions, - #[structopt(flatten)] - pub snapshot: SnapshotOptions, + #[structopt(flatten)] + pub snapshot: SnapshotOptions, - #[structopt(flatten)] - pub legacy: LegacyOptions, + #[structopt(flatten)] + pub legacy: LegacyOptions, } #[derive(StructOpt, Serialize, Deserialize, Debug, Clone, PartialEq, Default)] pub struct OperatingOptions { - #[structopt( - long = "no-download", - help = "Normally new releases will be downloaded ready for updating. This disables it. Not recommended." - )] - pub no_download: bool, - - #[structopt( - long = "no-consensus", - help = "Force the binary to run even if there are known issues regarding consensus. Not recommended." - )] - pub no_consensus: bool, - - #[structopt( - long, - help = "Experimental: run in light client mode. Light clients synchronize a bare minimum of data and fetch necessary data on-demand from the network. Much lower in storage, potentially higher in bandwidth. Has no effect with subcommands." - )] - pub light: bool, - - #[structopt( - long = "no-hardcoded-sync", - help = "By default, if there is no existing database the light client will automatically jump to a block hardcoded in the chain's specifications. This disables this feature." - )] - pub no_hardcoded_sync: bool, - - #[structopt( - long = "force-direct", - help = "Run the originally installed version of Parity, ignoring any updates that have since been installed." - )] - pub force_direct: bool, - - #[structopt( - name = "MODE", - long, - help = "Set the operating mode. MODE can be one of: last - Uses the last-used mode, active if none; active - Parity continuously syncs the chain; passive - Parity syncs initially, then sleeps and wakes regularly to resync; dark - Parity syncs only when the JSON-RPC is active; offline - Parity doesn't sync." - )] - pub mode: Option, - - #[structopt( - long = "mode-timeout", - name = "TIMEOUT_IN_SECS", - help = "Specify the number of seconds before inactivity timeout occurs when mode is dark or passive" - )] - pub mode_timeout: Option, - - #[structopt( - long = "mode-alarm", - name = "ALARM_IN_SECS", - help = "Specify the number of seconds before auto sleep reawake timeout occurs when mode is passive" - )] - pub mode_alarm: Option, - - #[structopt( - long = "auto-update", - name = "SET", - help = "Set a releases set to automatically update and install. SET can be one of: all - All updates in the our release track; critical - Only consensus/security updates; none - No updates will be auto-installed." - )] - pub auto_update: Option, - - #[structopt( - long = "auto-update-delay", - name = "DELAY_NUM", - help = "Specify the maximum number of blocks used for randomly delaying updates." - )] - pub auto_update_delay: Option, - - #[structopt( - long = "auto-update-check-frequency", - name = "FREQUENCY_NUM", - help = "Specify the number of blocks between each auto-update check." - )] - pub auto_update_check_frequency: Option, - - #[structopt( - long = "release-track", - name = "TRACK", - help = "Set which release track we should use for updates. TRACK can be one of: stable - Stable releases; nightly - Nightly releases (unstable); testing - Testing releases (do not use); current - Whatever track this executable was released on." - )] - pub release_track: Option, - - #[structopt( - long, - name = "CHAIN", - help = "Specify the blockchain type. CHAIN may be either a JSON chain specification file or ethereum, classic, classic-no-phoenix, poacore, xdai, volta, ewc, musicoin, ellaism, mix, callisto, ethercore, mordor, ropsten, kovan, rinkeby, goerli, kotti, poasokol, testnet, evantestcore, evancore or dev." - )] - pub chain: Option, - - #[structopt( - long = "keys-path", - name = "KEYS_PATH", - help = "Specify the path for JSON key files to be found" - )] - pub keys_path: Option, - - #[structopt(name = "NAME", long, help = "Specify your node's name.")] - pub identity: Option, - - #[structopt( - short = "d", - long = "base-path", - name = "BASE_PATH", - help = "Specify the base data storage path." - )] - pub base_path: Option, - - #[structopt( - name = "DB_PATH", - long = "db-path", - help = "Specify the database directory path" - )] - pub db_path: Option, + #[structopt( + long = "no-download", + help = "Normally new releases will be downloaded ready for updating. This disables it. Not recommended." + )] + pub no_download: bool, + + #[structopt( + long = "no-consensus", + help = "Force the binary to run even if there are known issues regarding consensus. Not recommended." + )] + pub no_consensus: bool, + + #[structopt( + long, + help = "Experimental: run in light client mode. Light clients synchronize a bare minimum of data and fetch necessary data on-demand from the network. Much lower in storage, potentially higher in bandwidth. Has no effect with subcommands." + )] + pub light: bool, + + #[structopt( + long = "no-hardcoded-sync", + help = "By default, if there is no existing database the light client will automatically jump to a block hardcoded in the chain's specifications. This disables this feature." + )] + pub no_hardcoded_sync: bool, + + #[structopt( + long = "force-direct", + help = "Run the originally installed version of Parity, ignoring any updates that have since been installed." + )] + pub force_direct: bool, + + #[structopt( + name = "MODE", + long, + help = "Set the operating mode. MODE can be one of: last - Uses the last-used mode, active if none; active - Parity continuously syncs the chain; passive - Parity syncs initially, then sleeps and wakes regularly to resync; dark - Parity syncs only when the JSON-RPC is active; offline - Parity doesn't sync." + )] + pub mode: Option, + + #[structopt( + long = "mode-timeout", + name = "TIMEOUT_IN_SECS", + help = "Specify the number of seconds before inactivity timeout occurs when mode is dark or passive" + )] + pub mode_timeout: Option, + + #[structopt( + long = "mode-alarm", + name = "ALARM_IN_SECS", + help = "Specify the number of seconds before auto sleep reawake timeout occurs when mode is passive" + )] + pub mode_alarm: Option, + + #[structopt( + long = "auto-update", + name = "SET", + help = "Set a releases set to automatically update and install. SET can be one of: all - All updates in the our release track; critical - Only consensus/security updates; none - No updates will be auto-installed." + )] + pub auto_update: Option, + + #[structopt( + long = "auto-update-delay", + name = "DELAY_NUM", + help = "Specify the maximum number of blocks used for randomly delaying updates." + )] + pub auto_update_delay: Option, + + #[structopt( + long = "auto-update-check-frequency", + name = "FREQUENCY_NUM", + help = "Specify the number of blocks between each auto-update check." + )] + pub auto_update_check_frequency: Option, + + #[structopt( + long = "release-track", + name = "TRACK", + help = "Set which release track we should use for updates. TRACK can be one of: stable - Stable releases; nightly - Nightly releases (unstable); testing - Testing releases (do not use); current - Whatever track this executable was released on." + )] + pub release_track: Option, + + #[structopt( + long, + name = "CHAIN", + help = "Specify the blockchain type. CHAIN may be either a JSON chain specification file or ethereum, classic, classic-no-phoenix, poacore, xdai, volta, ewc, musicoin, ellaism, mix, callisto, ethercore, mordor, ropsten, kovan, rinkeby, goerli, kotti, poasokol, testnet, evantestcore, evancore or dev." + )] + pub chain: Option, + + #[structopt( + long = "keys-path", + name = "KEYS_PATH", + help = "Specify the path for JSON key files to be found" + )] + pub keys_path: Option, + + #[structopt(name = "NAME", long, help = "Specify your node's name.")] + pub identity: Option, + + #[structopt( + short = "d", + long = "base-path", + name = "BASE_PATH", + help = "Specify the base data storage path." + )] + pub base_path: Option, + + #[structopt( + name = "DB_PATH", + long = "db-path", + help = "Specify the database directory path" + )] + pub db_path: Option, } #[derive(StructOpt, Serialize, Deserialize, Debug, Clone, PartialEq, Default)] pub struct ConvenienceOptions { - #[structopt( - long = "unsafe-expose", - help = "All servers will listen on external interfaces and will be remotely accessible. It's equivalent with setting the following: --[ws,jsonrpc,secretstore,stratum,dapps,secretstore-http]-interface=all --*-hosts=all This option is UNSAFE and should be used with great care!" - )] - pub unsafe_expose: bool, - - #[structopt( - short, - long, - name = "CONFIG", - help = "Specify a configuration. CONFIG may be either a configuration file or a preset: dev, insecure, dev-insecure, mining, or non-standard-ports." - )] - pub config: Option, - - #[structopt( - long = "config-generate", - name = "PATH_TO_GENERATE_CONFIG_IN", - help = "Save the current flags and their values into a configuration for future use" - )] - pub config_generate: Option, - - #[structopt( - long = "ports-shift", - name = "SHIFT", - help = "Add SHIFT to all port numbers Parity is listening on. Includes network port and all servers (HTTP JSON-RPC, WebSockets JSON-RPC, SecretStore)." - )] - pub ports_shift: Option, + #[structopt( + long = "unsafe-expose", + help = "All servers will listen on external interfaces and will be remotely accessible. It's equivalent with setting the following: --[ws,jsonrpc,secretstore,stratum,dapps,secretstore-http]-interface=all --*-hosts=all This option is UNSAFE and should be used with great care!" + )] + pub unsafe_expose: bool, + + #[structopt( + short, + long, + name = "CONFIG", + help = "Specify a configuration. CONFIG may be either a configuration file or a preset: dev, insecure, dev-insecure, mining, or non-standard-ports." + )] + pub config: Option, + + #[structopt( + long = "config-generate", + name = "PATH_TO_GENERATE_CONFIG_IN", + help = "Save the current flags and their values into a configuration for future use" + )] + pub config_generate: Option, + + #[structopt( + long = "ports-shift", + name = "SHIFT", + help = "Add SHIFT to all port numbers Parity is listening on. Includes network port and all servers (HTTP JSON-RPC, WebSockets JSON-RPC, SecretStore)." + )] + pub ports_shift: Option, } #[derive(StructOpt, Serialize, Deserialize, Debug, Clone, PartialEq, Default)] pub struct AccountOptions { - #[structopt( - long = "fast-unlock", - name = "FAST_UNLOCK_BOOL", - help = "Use drastically faster unlocking mode. This setting causes raw secrets to be stored unprotected in memory, so use with care." - )] - pub fast_unlock: bool, - - #[structopt( - long = "keys-iterations", - help = "Specify the number of iterations to use when deriving key from the password (bigger is more secure)", - name = "NUM" - )] - pub keys_iterations: Option, - - #[structopt( - long = "accounts-refresh", - help = "Specify the cache time of accounts read from disk. If you manage thousands of accounts set this to 0 to disable refresh.", - name = "TIME" - )] - pub accounts_refresh: Option, - - #[structopt( - long, - help = "Unlock UNLOCK_ACCOUNTS for the duration of the execution. UNLOCK_ACCOUNTS is a comma-delimited list of addresses.", - name = "UNLOCK_ACCOUNTS" - )] - pub unlock: Option, - - #[structopt( - long = "enable-signing-queue", - name = "BOOLEAN", - help = "Enables the signing queue for external transaction signing either via CLI or personal_unlockAccount, turned off by default." - )] - pub enable_signing_queue: bool, - - #[structopt( - long, - name = "FILE", - help = "Provide a file containing a password for unlocking an account. Leading and trailing whitespace is trimmed." - )] - pub password: Vec, // FIXME: Why is this a Vec? + #[structopt( + long = "fast-unlock", + name = "FAST_UNLOCK_BOOL", + help = "Use drastically faster unlocking mode. This setting causes raw secrets to be stored unprotected in memory, so use with care." + )] + pub fast_unlock: bool, + + #[structopt( + long = "keys-iterations", + help = "Specify the number of iterations to use when deriving key from the password (bigger is more secure)", + name = "NUM" + )] + pub keys_iterations: Option, + + #[structopt( + long = "accounts-refresh", + help = "Specify the cache time of accounts read from disk. If you manage thousands of accounts set this to 0 to disable refresh.", + name = "TIME" + )] + pub accounts_refresh: Option, + + #[structopt( + long, + help = "Unlock UNLOCK_ACCOUNTS for the duration of the execution. UNLOCK_ACCOUNTS is a comma-delimited list of addresses.", + name = "UNLOCK_ACCOUNTS" + )] + pub unlock: Option, + + #[structopt( + long = "enable-signing-queue", + name = "BOOLEAN", + help = "Enables the signing queue for external transaction signing either via CLI or personal_unlockAccount, turned off by default." + )] + pub enable_signing_queue: bool, + + #[structopt( + long, + name = "FILE", + help = "Provide a file containing a password for unlocking an account. Leading and trailing whitespace is trimmed." + )] + pub password: Vec, // FIXME: Why is this a Vec? } #[derive(StructOpt, Serialize, Deserialize, Debug, Clone, PartialEq, Default)] pub struct PrivateTransactions { - #[structopt(long = "private-tx-enabled", help = "Enable private transactions.")] - pub private_enabled: bool, - - #[structopt( - long = "private-state-offchain", - help = "Store private state offchain (in the local DB)." - )] - pub private_state_offchain: bool, - - #[structopt( - long = "private-signer", - long = "ACCOUNT", - help = "Specify the account for signing public transaction created upon verified private transaction." - )] - pub private_signer: Option, - - #[structopt( - long = "private-validators", - name = "ACCOUNTS", - help = "Specify the accounts for validating private transactions. ACCOUNTS is a comma-delimited list of addresses." - )] - pub private_validators: Option, - - #[structopt( - long = "private-account", - name = "PRIVATE_ACCOUNT", - help = "Specify the account for signing requests to secret store." - )] - pub private_account: Option, - - #[structopt( - long = "private-sstore-url", - name = "URL", - help = "Specify secret store URL used for encrypting private transactions." - )] - pub private_sstore_url: Option, - - #[structopt( - long = "private-sstore-threshold", - name = "THRESHOLD_NUM", - help = "Specify secret store threshold used for encrypting private transactions." - )] - pub private_sstore_threshold: Option, - - #[structopt( - long = "private-passwords", - name = "PASS_FILE", - help = "Provide a file containing passwords for unlocking accounts (signer, private account, validators)." - )] - pub private_passwords: Option, + #[structopt(long = "private-tx-enabled", help = "Enable private transactions.")] + pub private_enabled: bool, + + #[structopt( + long = "private-state-offchain", + help = "Store private state offchain (in the local DB)." + )] + pub private_state_offchain: bool, + + #[structopt( + long = "private-signer", + long = "ACCOUNT", + help = "Specify the account for signing public transaction created upon verified private transaction." + )] + pub private_signer: Option, + + #[structopt( + long = "private-validators", + name = "ACCOUNTS", + help = "Specify the accounts for validating private transactions. ACCOUNTS is a comma-delimited list of addresses." + )] + pub private_validators: Option, + + #[structopt( + long = "private-account", + name = "PRIVATE_ACCOUNT", + help = "Specify the account for signing requests to secret store." + )] + pub private_account: Option, + + #[structopt( + long = "private-sstore-url", + name = "URL", + help = "Specify secret store URL used for encrypting private transactions." + )] + pub private_sstore_url: Option, + + #[structopt( + long = "private-sstore-threshold", + name = "THRESHOLD_NUM", + help = "Specify secret store threshold used for encrypting private transactions." + )] + pub private_sstore_threshold: Option, + + #[structopt( + long = "private-passwords", + name = "PASS_FILE", + help = "Provide a file containing passwords for unlocking accounts (signer, private account, validators)." + )] + pub private_passwords: Option, } #[derive(StructOpt, Serialize, Deserialize, Debug, Clone, PartialEq, Default)] pub struct UIOptons { - #[structopt( - long = "ui-path", - help = "Specify directory where Trusted UIs tokens should be stored." - )] - pub ui_path: Option, + #[structopt( + long = "ui-path", + help = "Specify directory where Trusted UIs tokens should be stored." + )] + pub ui_path: Option, } #[derive(StructOpt, Serialize, Deserialize, Debug, Clone, PartialEq, Default)] pub struct NetworkingOptions { - #[structopt( - long = "no-warp", - help = "Disable syncing from the snapshot over the network." - )] - pub no_warp: bool, - - #[structopt(long = "no-discovery", help = "Disable new peer discovery.")] - pub no_discovery: bool, - - #[structopt(long = "reserved-only", help = "Connect only to reserved nodes.")] - pub reserved_only: bool, - - #[structopt( - long = "no-ancient-blocks", - help = "Disable downloading old blocks after snapshot restoration or warp sync. Not recommended." - )] - pub no_ancient_blocks: bool, - - #[structopt(long = "no-serve-light", help = "Disable serving of light peers.")] - pub no_serve_light: bool, - - #[structopt( - long = "warp-barrier", - name = "WARP_BARRIER_NUM", - help = "When warp enabled never attempt regular sync before warping to block WARP_BARRIER_NUM." - )] - pub warp_barrier: Option, - - #[structopt( - long, - name = "PORT", - help = "Override the port on which the node should listen." - )] - pub port: Option, - - #[structopt( - long, - name = "IP", - help = "Network interfaces. Valid values are 'all', 'local' or the ip of the interface you want parity to listen to." - )] - pub interface: Option, - - #[structopt( - long = "min-peers", - name = "MIN_NUM", - help = "Try to maintain at least MIN_NUM peers." - )] - pub min_peers: Option, - - #[structopt( - long = "max-peers", - name = "MAX_NUM", - help = "Try to maintain at least MAX_NUM peers." - )] - pub max_peers: Option, - - #[structopt( - long = "snapshot-peers", - name = "SNAPSHOT_NUM", - help = "Allow additional SNAPSHOT_NUM peers for a snapshot sync." - )] - pub snapshot_peers: Option, - - #[structopt( - long, - help = "Specify method to use for determining public address. Must be one of: any, none, upnp, extip:.", - name = "METHOD" - )] - pub nat: Option, - - #[structopt( - long = "allow-ips", - help = "Filter outbound connections. Must be one of: private - connect to private network IP addresses only; public - connect to public network IP addresses only; all - connect to any IP address.", - name = "FILTER" - )] - pub allow_ips: Option, - - #[structopt( - long = "max-pending-peers", - help = "Allow up to PENDING_NUM pending connections.", - name = "PENDING_NUM" - )] - pub max_pending_peers: Option, - - #[structopt( - long = "network-id", - help = "Override the network identifier from the chain we are on.", - name = "INDEX" - )] - pub network_id: Option, - - #[structopt( - long, - name = "BOOTNODES", - help = "Override the bootnodes from our chain. NODES should be comma-delimited enodes." - )] - pub bootnodes: Option, - - #[structopt( - long = "node-key", - name = "NODE_KEY", - help = "Specify node secret key, either as 64-character hex string or input to SHA3 operation." - )] - pub node_key: Option, - - #[structopt( - long = "reserved-peers", - name = "RESERVED_PEERS_FILE", - help = "Provide a file containing enodes, one per line. These nodes will always have a reserved slot on top of the normal maximum peers." - )] - pub reserved_peers: Option, + #[structopt( + long = "no-warp", + help = "Disable syncing from the snapshot over the network." + )] + pub no_warp: bool, + + #[structopt(long = "no-discovery", help = "Disable new peer discovery.")] + pub no_discovery: bool, + + #[structopt(long = "reserved-only", help = "Connect only to reserved nodes.")] + pub reserved_only: bool, + + #[structopt( + long = "no-ancient-blocks", + help = "Disable downloading old blocks after snapshot restoration or warp sync. Not recommended." + )] + pub no_ancient_blocks: bool, + + #[structopt(long = "no-serve-light", help = "Disable serving of light peers.")] + pub no_serve_light: bool, + + #[structopt( + long = "warp-barrier", + name = "WARP_BARRIER_NUM", + help = "When warp enabled never attempt regular sync before warping to block WARP_BARRIER_NUM." + )] + pub warp_barrier: Option, + + #[structopt( + long, + name = "PORT", + help = "Override the port on which the node should listen." + )] + pub port: Option, + + #[structopt( + long, + name = "IP", + help = "Network interfaces. Valid values are 'all', 'local' or the ip of the interface you want parity to listen to." + )] + pub interface: Option, + + #[structopt( + long = "min-peers", + name = "MIN_NUM", + help = "Try to maintain at least MIN_NUM peers." + )] + pub min_peers: Option, + + #[structopt( + long = "max-peers", + name = "MAX_NUM", + help = "Try to maintain at least MAX_NUM peers." + )] + pub max_peers: Option, + + #[structopt( + long = "snapshot-peers", + name = "SNAPSHOT_NUM", + help = "Allow additional SNAPSHOT_NUM peers for a snapshot sync." + )] + pub snapshot_peers: Option, + + #[structopt( + long, + help = "Specify method to use for determining public address. Must be one of: any, none, upnp, extip:.", + name = "METHOD" + )] + pub nat: Option, + + #[structopt( + long = "allow-ips", + help = "Filter outbound connections. Must be one of: private - connect to private network IP addresses only; public - connect to public network IP addresses only; all - connect to any IP address.", + name = "FILTER" + )] + pub allow_ips: Option, + + #[structopt( + long = "max-pending-peers", + help = "Allow up to PENDING_NUM pending connections.", + name = "PENDING_NUM" + )] + pub max_pending_peers: Option, + + #[structopt( + long = "network-id", + help = "Override the network identifier from the chain we are on.", + name = "INDEX" + )] + pub network_id: Option, + + #[structopt( + long, + name = "BOOTNODES", + help = "Override the bootnodes from our chain. NODES should be comma-delimited enodes." + )] + pub bootnodes: Option, + + #[structopt( + long = "node-key", + name = "NODE_KEY", + help = "Specify node secret key, either as 64-character hex string or input to SHA3 operation." + )] + pub node_key: Option, + + #[structopt( + long = "reserved-peers", + name = "RESERVED_PEERS_FILE", + help = "Provide a file containing enodes, one per line. These nodes will always have a reserved slot on top of the normal maximum peers." + )] + pub reserved_peers: Option, } #[derive(StructOpt, Serialize, Deserialize, Debug, Clone, PartialEq, Default)] pub struct IPCOptions { - #[structopt( - help = "Provide a file containing enodes, one per line. These nodes will always have a reserved slot on top of the normal maximum peers.", - long = "no-ipc" - )] - pub no_ipc: bool, - - #[structopt( - help = "Provide a file containing enodes, one per line. These nodes will always have a reserved slot on top of the normal maximum peers.", - long = "ipc-path", - name = "IPC_PATH" - )] - pub ipc_path: Option, - - #[structopt( - long = "ipc-chmod", - name = "IPC_CHMOD_NUM", - help = "Specify octal value for ipc socket permissions (unix/bsd only)" - )] - pub ipc_chmod: Option, - - #[structopt( - long = "ipc-apis", - name = "IPC_APIS", - help = "Specify custom API set available via JSON-RPC over IPC using a comma-delimited list of API names. Possible names are: all, safe, web3, net, eth, pubsub, personal, signer, parity, parity_pubsub, parity_accounts, parity_set, traces, rpc, secretstore. You can also disable a specific API by putting '-' in the front, example: all,-personal. 'safe' enables the following APIs: web3, net, eth, pubsub, parity, parity_pubsub, traces, rpc" - )] - pub ipc_apis: Option, + #[structopt( + help = "Provide a file containing enodes, one per line. These nodes will always have a reserved slot on top of the normal maximum peers.", + long = "no-ipc" + )] + pub no_ipc: bool, + + #[structopt( + help = "Provide a file containing enodes, one per line. These nodes will always have a reserved slot on top of the normal maximum peers.", + long = "ipc-path", + name = "IPC_PATH" + )] + pub ipc_path: Option, + + #[structopt( + long = "ipc-chmod", + name = "IPC_CHMOD_NUM", + help = "Specify octal value for ipc socket permissions (unix/bsd only)" + )] + pub ipc_chmod: Option, + + #[structopt( + long = "ipc-apis", + name = "IPC_APIS", + help = "Specify custom API set available via JSON-RPC over IPC using a comma-delimited list of API names. Possible names are: all, safe, web3, net, eth, pubsub, personal, signer, parity, parity_pubsub, parity_accounts, parity_set, traces, rpc, secretstore. You can also disable a specific API by putting '-' in the front, example: all,-personal. 'safe' enables the following APIs: web3, net, eth, pubsub, parity, parity_pubsub, traces, rpc" + )] + pub ipc_apis: Option, } impl IPCOptions { - pub fn ipc_path_default() -> Option { - if cfg!(windows) { - Some(r"\\.\pipe\jsonrpc.ipc".to_string()) - } else { - Some("$BASE/jsonrpc.ipc".to_string()) - } - } + pub fn ipc_path_default() -> Option { + if cfg!(windows) { + Some(r"\\.\pipe\jsonrpc.ipc".to_string()) + } else { + Some("$BASE/jsonrpc.ipc".to_string()) + } + } } #[derive(StructOpt, Serialize, Deserialize, Debug, Clone, PartialEq, Default)] pub struct HTTP_JSON_RPC_Options { - #[structopt( - long = "json-rpc-allow-missing-blocks", - help = "RPC calls will return 'null' instead of an error if ancient block sync is still in progress and the block information requested could not be found" - )] - pub jsonrpc_allow_missing_blocks: bool, - - #[structopt(long = "no-jsonrpc", help = "Disable the HTTP JSON-RPC API server.")] - pub no_jsonrpc: bool, - - #[structopt( - long = "jsonrpc-no-keep-alive", - help = "Disable HTTP/1.1 keep alive header. Disabling keep alive will prevent re-using the same TCP connection to fire multiple requests, recommended when using one request per connection." - )] - pub jsonrpc_no_keep_alive: bool, - - #[structopt( - long = "jsonrpc-experimental", - help = "Enable experimental RPCs. Enable to have access to methods from unfinalised EIPs in all namespaces" - )] - pub jsonrpc_experimental: bool, - - #[structopt( - long = "jsonrpc-port", - name = "JSONRPC_PORT", - help = "Specify the port portion of the HTTP JSON-RPC API server." - )] - pub jsonrpc_port: Option, - - #[structopt( - long = "jsonrpc-interface", - name = "JSONRPC_IP", - help = "Specify the hostname portion of the HTTP JSON-RPC API server, JSONRPC_IP should be an interface's IP address, or all (all interfaces) or local." - )] - pub jsonrpc_interface: Option, - - #[structopt( - long = "jsonrpc-apis", - name = "JSONRPC_APIS", - help = "Specify the APIs available through the HTTP JSON-RPC interface using a comma-delimited list of API names. Possible names are: all, safe, debug, web3, net, eth, pubsub, personal, signer, parity, parity_pubsub, parity_accounts, parity_set, traces, rpc, secretstore. You can also disable a specific API by putting '-' in the front, example: all,-personal. 'safe' enables the following APIs: web3, net, eth, pubsub, parity, parity_pubsub, traces, rpc" - )] - pub jsonrpc_apis: Option, - - #[structopt( - long = "jsonrpc-hosts", - name = "JSONRPC_HOSTS", - help = "List of allowed Host header values. This option will validate the Host header sent by the browser, it is additional security against some attack vectors. Special options: \"all\", \"none\",." - )] - pub jsonrpc_hosts: Option, - - #[structopt( - long = "jsonrpc-threads", - name = "JSONRPC_THREADS_NUM", - help = "DEPRECATED, DOES NOTHING" - )] - pub jsonrpc_threads: Option, - - #[structopt( - long = "jsonrpc-server-threads", - name = "JSONRPC_SERVER_THREADS", - help = "Enables multiple threads handling incoming connections for HTTP JSON-RPC server." - )] - pub jsonrpc_server_threads: Option, - - #[structopt( - name = "JSONRPC_CORS_URL", - long = "jsonrpc-cors", - help = "Specify CORS header for HTTP JSON-RPC API responses. Special options: \"all\", \"none\"." - )] - pub jsonrpc_cors: Option, - - #[structopt( - long = "jsonrpc-max-payload", - name = "JSONRPC_MAX_MB", - help = "Specify maximum size for HTTP JSON-RPC requests in megabytes." - )] - pub jsonrpc_max_payload: Option, - - #[structopt( - name = "POLL_LIFETIME_SECS", - long = "poll-lifetime", - help = "Set the RPC filter lifetime to S seconds. The filter has to be polled at least every S seconds , otherwise it is removed." - )] - pub poll_lifetime: Option, + #[structopt( + long = "json-rpc-allow-missing-blocks", + help = "RPC calls will return 'null' instead of an error if ancient block sync is still in progress and the block information requested could not be found" + )] + pub jsonrpc_allow_missing_blocks: bool, + + #[structopt(long = "no-jsonrpc", help = "Disable the HTTP JSON-RPC API server.")] + pub no_jsonrpc: bool, + + #[structopt( + long = "jsonrpc-no-keep-alive", + help = "Disable HTTP/1.1 keep alive header. Disabling keep alive will prevent re-using the same TCP connection to fire multiple requests, recommended when using one request per connection." + )] + pub jsonrpc_no_keep_alive: bool, + + #[structopt( + long = "jsonrpc-experimental", + help = "Enable experimental RPCs. Enable to have access to methods from unfinalised EIPs in all namespaces" + )] + pub jsonrpc_experimental: bool, + + #[structopt( + long = "jsonrpc-port", + name = "JSONRPC_PORT", + help = "Specify the port portion of the HTTP JSON-RPC API server." + )] + pub jsonrpc_port: Option, + + #[structopt( + long = "jsonrpc-interface", + name = "JSONRPC_IP", + help = "Specify the hostname portion of the HTTP JSON-RPC API server, JSONRPC_IP should be an interface's IP address, or all (all interfaces) or local." + )] + pub jsonrpc_interface: Option, + + #[structopt( + long = "jsonrpc-apis", + name = "JSONRPC_APIS", + help = "Specify the APIs available through the HTTP JSON-RPC interface using a comma-delimited list of API names. Possible names are: all, safe, debug, web3, net, eth, pubsub, personal, signer, parity, parity_pubsub, parity_accounts, parity_set, traces, rpc, secretstore. You can also disable a specific API by putting '-' in the front, example: all,-personal. 'safe' enables the following APIs: web3, net, eth, pubsub, parity, parity_pubsub, traces, rpc" + )] + pub jsonrpc_apis: Option, + + #[structopt( + long = "jsonrpc-hosts", + name = "JSONRPC_HOSTS", + help = "List of allowed Host header values. This option will validate the Host header sent by the browser, it is additional security against some attack vectors. Special options: \"all\", \"none\",." + )] + pub jsonrpc_hosts: Option, + + #[structopt( + long = "jsonrpc-threads", + name = "JSONRPC_THREADS_NUM", + help = "DEPRECATED, DOES NOTHING" + )] + pub jsonrpc_threads: Option, + + #[structopt( + long = "jsonrpc-server-threads", + name = "JSONRPC_SERVER_THREADS", + help = "Enables multiple threads handling incoming connections for HTTP JSON-RPC server." + )] + pub jsonrpc_server_threads: Option, + + #[structopt( + name = "JSONRPC_CORS_URL", + long = "jsonrpc-cors", + help = "Specify CORS header for HTTP JSON-RPC API responses. Special options: \"all\", \"none\"." + )] + pub jsonrpc_cors: Option, + + #[structopt( + long = "jsonrpc-max-payload", + name = "JSONRPC_MAX_MB", + help = "Specify maximum size for HTTP JSON-RPC requests in megabytes." + )] + pub jsonrpc_max_payload: Option, + + #[structopt( + name = "POLL_LIFETIME_SECS", + long = "poll-lifetime", + help = "Set the RPC filter lifetime to S seconds. The filter has to be polled at least every S seconds , otherwise it is removed." + )] + pub poll_lifetime: Option, } #[derive(StructOpt, Serialize, Deserialize, Debug, Clone, PartialEq, Default)] pub struct LightClientOptions { - #[structopt( - long = "on-demand-time-window", - help = "Specify the maximum time to wait for a successful response", - name = "RESPONSE_SECS" - )] - pub on_demand_response_time_window: Option, - - #[structopt( - long = "on-demand-start-backoff", - name = "BACKOFF_START_SECS", - help = "Specify light client initial backoff time for a request" - )] - pub on_demand_request_backoff_start: Option, - - #[structopt( - long = "on-demand-end-backoff", - name = "BACKOFF_END_SECS", - help = "Specify light client maximam backoff time for a request" - )] - pub on_demand_request_backoff_max: Option, - - #[structopt( - long = "on-demand-max-backoff-rounds", - name = "BACKOFF_MAX_ROUNDS_TIMES", - help = "Specify light client maximam number of backoff iterations for a request" - )] - pub on_demand_request_backoff_rounds_max: Option, - - #[structopt( - long = "on-demand-consecutive-failures", - name = "MAX_CONSECUTIVE_FAILURE_TIMES", - help = "Specify light client the number of failures for a request until it gets exponentially backed off" - )] - pub on_demand_request_consecutive_failures: Option, + #[structopt( + long = "on-demand-time-window", + help = "Specify the maximum time to wait for a successful response", + name = "RESPONSE_SECS" + )] + pub on_demand_response_time_window: Option, + + #[structopt( + long = "on-demand-start-backoff", + name = "BACKOFF_START_SECS", + help = "Specify light client initial backoff time for a request" + )] + pub on_demand_request_backoff_start: Option, + + #[structopt( + long = "on-demand-end-backoff", + name = "BACKOFF_END_SECS", + help = "Specify light client maximam backoff time for a request" + )] + pub on_demand_request_backoff_max: Option, + + #[structopt( + long = "on-demand-max-backoff-rounds", + name = "BACKOFF_MAX_ROUNDS_TIMES", + help = "Specify light client maximam number of backoff iterations for a request" + )] + pub on_demand_request_backoff_rounds_max: Option, + + #[structopt( + long = "on-demand-consecutive-failures", + name = "MAX_CONSECUTIVE_FAILURE_TIMES", + help = "Specify light client the number of failures for a request until it gets exponentially backed off" + )] + pub on_demand_request_consecutive_failures: Option, } #[derive(StructOpt, Serialize, Deserialize, Debug, Clone, PartialEq, Default)] pub struct WebsocketsOptions { - #[structopt(help = "Disable the WebSockets JSON-RPC server.", long = "no-ws")] - pub no_ws: bool, - - #[structopt( - long = "ws-port", - name = "WS_PORT", - help = "Specify the port portion of the WebSockets JSON-RPC server." - )] - pub ws_port: Option, - - #[structopt( - long = "ws-interface", - name = "WS_INTERFACE_IP", - help = "Specify the hostname portion of the WebSockets JSON-RPC server, IP should be an interface's IP address, or all (all interfaces) or local." - )] - pub ws_interface: Option, - - #[structopt( - help = "Specify the JSON-RPC APIs available through the WebSockets interface using a comma-delimited list of API names. Possible names are: all, safe, web3, net, eth, pubsub, personal, signer, parity, parity_pubsub, parity_accounts, parity_set, traces, rpc, secretstore. You can also disable a specific API by putting '-' in the front, example: all,-personal. 'safe' enables the following APIs: web3, net, eth, pubsub, parity, parity_pubsub, traces, rpc", - long = "ws-apis", - name = "WS_APIS" - )] - pub ws_apis: Option, - - #[structopt( - help = "Specify Origin header values allowed to connect. Special options: \"all\", \"none\".", - long = "ws-origins", - name = "WS_ORIGINS_URL" - )] - pub ws_origins: Option, - - #[structopt( - help = "List of allowed Host header values. This option will validate the Host header sent by the browser, it is additional security against some attack vectors. Special options: \"all\", \"none\".", - long = "ws-hosts", - name = "WS_HOSTS" - )] - pub ws_hosts: Option, - - #[structopt( - help = "Maximum number of allowed concurrent WebSockets JSON-RPC connections.", - long = "ws=-connections", - name = "WS_MAX_CONN" - )] - pub ws_max_connections: Option, + #[structopt(help = "Disable the WebSockets JSON-RPC server.", long = "no-ws")] + pub no_ws: bool, + + #[structopt( + long = "ws-port", + name = "WS_PORT", + help = "Specify the port portion of the WebSockets JSON-RPC server." + )] + pub ws_port: Option, + + #[structopt( + long = "ws-interface", + name = "WS_INTERFACE_IP", + help = "Specify the hostname portion of the WebSockets JSON-RPC server, IP should be an interface's IP address, or all (all interfaces) or local." + )] + pub ws_interface: Option, + + #[structopt( + help = "Specify the JSON-RPC APIs available through the WebSockets interface using a comma-delimited list of API names. Possible names are: all, safe, web3, net, eth, pubsub, personal, signer, parity, parity_pubsub, parity_accounts, parity_set, traces, rpc, secretstore. You can also disable a specific API by putting '-' in the front, example: all,-personal. 'safe' enables the following APIs: web3, net, eth, pubsub, parity, parity_pubsub, traces, rpc", + long = "ws-apis", + name = "WS_APIS" + )] + pub ws_apis: Option, + + #[structopt( + help = "Specify Origin header values allowed to connect. Special options: \"all\", \"none\".", + long = "ws-origins", + name = "WS_ORIGINS_URL" + )] + pub ws_origins: Option, + + #[structopt( + help = "List of allowed Host header values. This option will validate the Host header sent by the browser, it is additional security against some attack vectors. Special options: \"all\", \"none\".", + long = "ws-hosts", + name = "WS_HOSTS" + )] + pub ws_hosts: Option, + + #[structopt( + help = "Maximum number of allowed concurrent WebSockets JSON-RPC connections.", + long = "ws=-connections", + name = "WS_MAX_CONN" + )] + pub ws_max_connections: Option, } #[derive(StructOpt, Serialize, Deserialize, Debug, Clone, PartialEq, Default)] pub struct SecretStoreOptions { - #[structopt(help = "Disable Secret Store functionality.", long = "no-secretstore")] - pub no_secretstore: bool, - - #[structopt(help = "Disable Secret Store HTTP API.", long = "no-secretstore-http")] - pub no_secretstore_http: bool, - - #[structopt( - help = "Do not run servers set change session automatically when servers set changes. This option has no effect when servers set is read from configuration file.", - long = "no-secretstore-auto-migrate" - )] - pub no_secretstore_auto_migrate: bool, - - #[structopt( - name = "HTTP_CORS_URLS", - help = "Specify CORS header for Secret Store HTTP API responses. Special options: \"all\", \"none\".", - long = "secretstore-http-cors" - )] - pub secretstore_http_cors: Option, - - #[structopt( - help = "Secret Store permissioning contract address source: none, registry (contract address is read from 'secretstore_acl_checker' entry in registry) or address.", - long = "secretstore-acl-contract" - )] - pub secretstore_acl_contract: Option, - - #[structopt( - long = "secrestore-contract", - name = "SECRETSTORE_SOURCE", - help = "Secret Store Service contract address source: none, registry (contract address is read from 'secretstore_service' entry in registry) or address." - )] - pub secretstore_contract: Option, - - #[structopt( - long = "secretstore-srv-gen-contract", - name = "GEN_SOURCE", - help = "Secret Store Service server key generation contract address source: none, registry (contract address is read from 'secretstore_service_srv_gen' entry in registry) or address." - )] - pub secretstore_srv_gen_contract: Option, - - #[structopt( - help = "Secret Store Service server key retrieval contract address source: none, registry (contract address is read from 'secretstore_service_srv_retr' entry in registry) or address.", - name = "RETR_SOURCE", - long = "secretstore-srv-retr-contract" - )] - pub secretstore_srv_retr_contract: Option, - - #[structopt( - help = "Secret Store Service document key store contract address source: none, registry (contract address is read from 'secretstore_service_doc_store' entry in registry) or address.", - name = "DOC_STORE_SOURCE", - long = "secretstore-doc-store-contract" - )] - pub secretstore_doc_store_contract: Option, - - #[structopt( - help = "Secret Store Service document key shadow retrieval contract address source: none, registry (contract address is read from 'secretstore_service_doc_sretr' entry in registry) or address.", - name = "DOC_SRETR_SOURCE", - long = "secretstore-doc-sretr-contract" - )] - pub secretstore_doc_sretr_contract: Option, - - #[structopt( - help = "Comma-separated list of other secret store cluster nodes in form NODE_PUBLIC_KEY_IN_HEX@NODE_IP_ADDR:NODE_PORT.", - name = "SECRETSTORE_NODES", - long = "secretstore-nodes" - )] - pub secretstore_nodes: Option, - - #[structopt( - name = "SET_CONTRACT_SOURCE", - long = "secretstore-server-set-contract", - help = "Secret Store server set contract address source: none, registry (contract address is read from 'secretstore_server_set' entry in registry) or address." - )] - pub secretstore_server_set_contract: Option, - - #[structopt( - help = "Specify the hostname portion for listening to Secret Store Key Server internal requests, IP should be an interface's IP address, or local.", - name = "SECRETSTORE_IP", - long = "secretstore-interface-ip" - )] - pub secretstore_interface: Option, - - #[structopt( - long = "secretstore-port", - name = "SECRETSTORE_PORT", - help = "Specify the port portion for listening to Secret Store Key Server internal requests." - )] - pub secretstore_port: Option, - - #[structopt( - long = "secretstore-http-interface", - help = "Specify the hostname portion for listening to Secret Store Key Server HTTP requests, IP should be an interface's IP address, or local.", - name = "SECRETSTORE_HTTP_INTERFACE" - )] - pub secretstore_http_interface: Option, - - #[structopt( - long = "secretstore-http-port", - name = "SECRETSTORE_HTTP_PORT", - help = "Specify the port portion for listening to Secret Store Key Server HTTP requests." - )] - pub secretstore_http_port: Option, - - #[structopt( - name = "SECRETSTORE_PATH", - long = "secretstore-path", - help = "Specify directory where Secret Store should save its data." - )] - pub secretstore_path: Option, - - #[structopt( - long = "secretstore-secret", - name = "SECRETSTORE_SECRET", - help = "Hex-encoded secret key of this node." - )] - pub secretstore_secret: Option, - - #[structopt( - long = "secretstore-admin-public", - name = "SECRETSTORE_ADMIN_PUBLIC", - help = "Hex-encoded public key of secret store administrator." - )] - pub secretstore_admin_public: Option, + #[structopt(help = "Disable Secret Store functionality.", long = "no-secretstore")] + pub no_secretstore: bool, + + #[structopt(help = "Disable Secret Store HTTP API.", long = "no-secretstore-http")] + pub no_secretstore_http: bool, + + #[structopt( + help = "Do not run servers set change session automatically when servers set changes. This option has no effect when servers set is read from configuration file.", + long = "no-secretstore-auto-migrate" + )] + pub no_secretstore_auto_migrate: bool, + + #[structopt( + name = "HTTP_CORS_URLS", + help = "Specify CORS header for Secret Store HTTP API responses. Special options: \"all\", \"none\".", + long = "secretstore-http-cors" + )] + pub secretstore_http_cors: Option, + + #[structopt( + help = "Secret Store permissioning contract address source: none, registry (contract address is read from 'secretstore_acl_checker' entry in registry) or address.", + long = "secretstore-acl-contract" + )] + pub secretstore_acl_contract: Option, + + #[structopt( + long = "secrestore-contract", + name = "SECRETSTORE_SOURCE", + help = "Secret Store Service contract address source: none, registry (contract address is read from 'secretstore_service' entry in registry) or address." + )] + pub secretstore_contract: Option, + + #[structopt( + long = "secretstore-srv-gen-contract", + name = "GEN_SOURCE", + help = "Secret Store Service server key generation contract address source: none, registry (contract address is read from 'secretstore_service_srv_gen' entry in registry) or address." + )] + pub secretstore_srv_gen_contract: Option, + + #[structopt( + help = "Secret Store Service server key retrieval contract address source: none, registry (contract address is read from 'secretstore_service_srv_retr' entry in registry) or address.", + name = "RETR_SOURCE", + long = "secretstore-srv-retr-contract" + )] + pub secretstore_srv_retr_contract: Option, + + #[structopt( + help = "Secret Store Service document key store contract address source: none, registry (contract address is read from 'secretstore_service_doc_store' entry in registry) or address.", + name = "DOC_STORE_SOURCE", + long = "secretstore-doc-store-contract" + )] + pub secretstore_doc_store_contract: Option, + + #[structopt( + help = "Secret Store Service document key shadow retrieval contract address source: none, registry (contract address is read from 'secretstore_service_doc_sretr' entry in registry) or address.", + name = "DOC_SRETR_SOURCE", + long = "secretstore-doc-sretr-contract" + )] + pub secretstore_doc_sretr_contract: Option, + + #[structopt( + help = "Comma-separated list of other secret store cluster nodes in form NODE_PUBLIC_KEY_IN_HEX@NODE_IP_ADDR:NODE_PORT.", + name = "SECRETSTORE_NODES", + long = "secretstore-nodes" + )] + pub secretstore_nodes: Option, + + #[structopt( + name = "SET_CONTRACT_SOURCE", + long = "secretstore-server-set-contract", + help = "Secret Store server set contract address source: none, registry (contract address is read from 'secretstore_server_set' entry in registry) or address." + )] + pub secretstore_server_set_contract: Option, + + #[structopt( + help = "Specify the hostname portion for listening to Secret Store Key Server internal requests, IP should be an interface's IP address, or local.", + name = "SECRETSTORE_IP", + long = "secretstore-interface-ip" + )] + pub secretstore_interface: Option, + + #[structopt( + long = "secretstore-port", + name = "SECRETSTORE_PORT", + help = "Specify the port portion for listening to Secret Store Key Server internal requests." + )] + pub secretstore_port: Option, + + #[structopt( + long = "secretstore-http-interface", + help = "Specify the hostname portion for listening to Secret Store Key Server HTTP requests, IP should be an interface's IP address, or local.", + name = "SECRETSTORE_HTTP_INTERFACE" + )] + pub secretstore_http_interface: Option, + + #[structopt( + long = "secretstore-http-port", + name = "SECRETSTORE_HTTP_PORT", + help = "Specify the port portion for listening to Secret Store Key Server HTTP requests." + )] + pub secretstore_http_port: Option, + + #[structopt( + name = "SECRETSTORE_PATH", + long = "secretstore-path", + help = "Specify directory where Secret Store should save its data." + )] + pub secretstore_path: Option, + + #[structopt( + long = "secretstore-secret", + name = "SECRETSTORE_SECRET", + help = "Hex-encoded secret key of this node." + )] + pub secretstore_secret: Option, + + #[structopt( + long = "secretstore-admin-public", + name = "SECRETSTORE_ADMIN_PUBLIC", + help = "Hex-encoded public key of secret store administrator." + )] + pub secretstore_admin_public: Option, } #[derive(StructOpt, Serialize, Deserialize, Debug, Clone, PartialEq, Default)] pub struct SealingMiningOptions { - #[structopt( - help = "Force the node to author new blocks as if it were always sealing/mining.", - long = "force-sealing" - )] - pub force_sealing: bool, - - #[structopt( - help = "Force the node to author new blocks when a new uncle block is imported.", - long = "reseal-on-uncle" - )] - pub reseal_on_uncle: bool, - - #[structopt( - help = "Move solved blocks from the work package queue instead of cloning them. This gives a slightly faster import speed, but means that extra solutions submitted for the same work package will go unused.", - long = "remove-solved" - )] - pub remove_solved: bool, - - #[structopt( - help = "Local transactions sent through JSON-RPC (HTTP, WebSockets, etc) will be treated as 'external' if the sending account is unknown.", - long = "tx-queue-no-unfamiliar-locals" - )] - pub tx_queue_no_unfamiliar_locals: bool, - - #[structopt( - help = "Disables transaction queue optimization to early reject transactions below minimal effective gas price. This allows local transactions to always enter the pool, despite it being full, but requires additional ecrecover on every transaction.", - long = "tx-queue-no-early-reject" - )] - pub tx_queue_no_early_reject: bool, - - #[structopt( - help = "Always refuse service transactions.", - long = "refuse-service-transactions" - )] - pub refuse_service_transactions: bool, - - #[structopt( - help = "Pending block will be created with maximal possible gas limit and will execute all transactions in the queue. Note that such block is invalid and should never be attempted to be mined.", - long = "infinite-pending-block" - )] - pub infinite_pending_block: bool, - - #[structopt( - help = "Don't save pending local transactions to disk to be restored whenever the node restarts.", - long = "no-persistent-txqueue" - )] - pub no_persistent_txqueue: bool, - - // For backward compatibility; Stratum should be enabled if the config file - // contains a `[stratum]` section and it is not explicitly disabled (disable = true) - #[structopt(help = "Run Stratum server for miner push notification.", long)] - pub stratum: bool, - - #[structopt( - long = "reseal-on-txs", - name = "RESEAL_TXS_SET", - help = "Specify which transactions should force the node to reseal a block. SET is one of: none - never reseal on new transactions; own - reseal only on a new local transaction; ext - reseal only on a new external transaction; all - reseal on all new transactions." - )] - pub reseal_on_txs: Option, - - #[structopt( - help = "Specify the minimum time between reseals from incoming transactions. MS is time measured in milliseconds.", - long = "reseal-min-period", - name = "RESEAL_MIN_MS" - )] - pub reseal_min_period: Option, - - #[structopt( - long = "reseal-max-period", - name = "RESEAL_MAX_MS", - help = "Specify the maximum time between reseals from incoming transactions. MS is time measured in milliseconds." - )] - pub reseal_max_period: Option, - - #[structopt( - name = "WORK_QUEUE_SIZE_ITEMS", - long = "work-queue-size", - help = "Specify the number of historical work packages which are kept cached lest a solution is found for them later. High values take more memory but result in fewer unusable solutions." - )] - pub work_queue_size: Option, - - #[structopt( - long = "relay-set", - name = "RELAY_SET", - help = "Set of transactions to relay. SET may be: cheap - Relay any transaction in the queue (this may include invalid transactions); strict - Relay only executed transactions (this guarantees we don't relay invalid transactions, but means we relay nothing if not mining); lenient - Same as strict when mining, and cheap when not." - )] - pub relay_set: Option, - - #[structopt( - long = "usd-per-tx", - name = "USD_PER_TX", - help = "Amount of USD to be paid for a basic transaction. The minimum gas price is set accordingly." - )] - pub usd_per_tx: Option, - - #[structopt( - help = "USD value of a single ETH. SOURCE may be either an amount in USD, a web service or 'auto' to use each web service in turn and fallback on the last known good value.", - name = "USD_PER_ETH_SOURCE", - long = "usd-per-eth" - )] - pub usd_per_eth: Option, - - #[structopt( - long = "price-update-period", - name = "PRICE_UPDATE_T", - help = "PRICE_UPDATE_T will be allowed to pass between each gas price update. PRICE_UPDATE_T may be daily, hourly, a number of seconds, or a time string of the form \"2 days\", \"30 minutes\" etc.." - )] - pub price_update_period: Option, - - #[structopt( - help = "Amount of gas per block to target when sealing a new block.", - long = "gas-floor-target", - name = "GAS_FLOOR" - )] - pub gas_floor_target: Option, - - #[structopt( - help = "A cap on how large we will raise the gas limit per block due to transaction volume.", - long = "gas-cap", - name = "GAS_CAP" - )] - pub gas_cap: Option, - - #[structopt( - help = "Maximum amount of memory that can be used by the transaction queue. Setting this parameter to 0 disables limiting.", - long = "tx-queue-mem-limit", - name = "TX_QUEUE_LIMIT_MB" - )] - pub tx_queue_mem_limit: Option, - - #[structopt( - help = "Maximum amount of transactions in the queue (waiting to be included in next block).", - long = "tx-queue-size", - name = "TX_QUEUE_SIZE_LIMIT" - )] - pub tx_queue_size: Option, - - #[structopt( - help = "Maximum number of transactions per sender in the queue. By default it's 1% of the entire queue, but not less than 16.", - long = "tx-queue-per-sender", - name = "TX_QUEUE_PER_SENDER_LIMIT" - )] - pub tx_queue_per_sender: Option, - - #[structopt( - help = "Specify local accounts for which transactions are prioritized in the queue. ACCOUNTS is a comma-delimited list of addresses.", - long = "tx-queue-locals", - name = "TX_QUEUE_LOCAL_ACCOUNTS" - )] - pub tx_queue_locals: Option, - - #[structopt( - help = "Prioritization strategy used to order transactions in the queue. S may be: gas_price - Prioritize txs with high gas price", - long = "tx-queue-strategy", - name = "TX_QUEUE_S" - )] - pub tx_queue_strategy: Option, - - #[structopt( - help = "Interface address for Stratum server.", - long = "stratum-interface", - name = "STRATUM_IP" - )] - pub stratum_interface: Option, - - #[structopt( - help = "Port for Stratum server to listen on.", - long = "stratum-port", - name = "STRATUM_PORT" - )] - pub stratum_port: Option, - - #[structopt( - help = "Minimum amount of Wei per GAS to be paid for a transaction to be accepted for mining. Overrides --usd-per-tx.", - long = "min-gas-price", - name = "MIN_GAS_PRICE_STRING" - )] - pub min_gas_price: Option, - - #[structopt( - help = "Set PCT percentile gas price value from last 100 blocks as default gas price when sending transactions.", - long = "gas-price-percentile", - name = "PCT" - )] - pub gas_price_percentile: Option, - - #[structopt( - help = "Specify the block author (aka \"coinbase\") address for sending block rewards from sealed blocks. NOTE: MINING WILL NOT WORK WITHOUT THIS OPTION.", - long, - name = "ADDRESS" - )] - pub author: Option, // Sealing / Mining Option - - #[structopt( - help = "Specify the address which should be used to sign consensus messages and issue blocks. Relevant only to non-PoW chains.", - long = "engine-signer", - name = "ENGINE_SIGNER_ADDRESS" - )] - pub engine_signer: Option, - - #[structopt( - help = "Apply a limit of GAS as the maximum amount of gas a single transaction may have for it to be mined.", - long = "tx-gas-limit", - name = "TX_GAS_LIMIT" - )] - pub tx_gas_limit: Option, - - #[structopt( - help = "Maximal time for processing single transaction. If enabled senders of transactions offending the limit will get other transactions penalized.", - long = "tx-time-limit", - name = "TX_TIME_LIMIT_MS" - )] - pub tx_time_limit: Option, - - #[structopt( - long = "extra-data", - help = "Specify a custom extra-data for authored blocks, no more than 32 characters.", - name = "EXTRA_DATA_STRING" - )] - pub extra_data: Option, - - #[structopt( - name = "NOTIFY_WORK_URLS", - help = "URLs to which work package notifications are pushed. URLS should be a comma-delimited list of HTTP URLs.", - long = "notify-work" - )] - pub notify_work: Option, - - #[structopt( - name = "STARTUM_SECRET_STRING", - long = "stratum-secret", - help = "Secret for authorizing Stratum server for peers." - )] - pub stratum_secret: Option, - - #[structopt( - long = "max-round-blocks-to-import", - name = "MAX_ROUND_BLOCKS_S", - help = "Maximal number of blocks to import for each import round." - )] - pub max_round_blocks_to_import: Option, + #[structopt( + help = "Force the node to author new blocks as if it were always sealing/mining.", + long = "force-sealing" + )] + pub force_sealing: bool, + + #[structopt( + help = "Force the node to author new blocks when a new uncle block is imported.", + long = "reseal-on-uncle" + )] + pub reseal_on_uncle: bool, + + #[structopt( + help = "Move solved blocks from the work package queue instead of cloning them. This gives a slightly faster import speed, but means that extra solutions submitted for the same work package will go unused.", + long = "remove-solved" + )] + pub remove_solved: bool, + + #[structopt( + help = "Local transactions sent through JSON-RPC (HTTP, WebSockets, etc) will be treated as 'external' if the sending account is unknown.", + long = "tx-queue-no-unfamiliar-locals" + )] + pub tx_queue_no_unfamiliar_locals: bool, + + #[structopt( + help = "Disables transaction queue optimization to early reject transactions below minimal effective gas price. This allows local transactions to always enter the pool, despite it being full, but requires additional ecrecover on every transaction.", + long = "tx-queue-no-early-reject" + )] + pub tx_queue_no_early_reject: bool, + + #[structopt( + help = "Always refuse service transactions.", + long = "refuse-service-transactions" + )] + pub refuse_service_transactions: bool, + + #[structopt( + help = "Pending block will be created with maximal possible gas limit and will execute all transactions in the queue. Note that such block is invalid and should never be attempted to be mined.", + long = "infinite-pending-block" + )] + pub infinite_pending_block: bool, + + #[structopt( + help = "Don't save pending local transactions to disk to be restored whenever the node restarts.", + long = "no-persistent-txqueue" + )] + pub no_persistent_txqueue: bool, + + // For backward compatibility; Stratum should be enabled if the config file + // contains a `[stratum]` section and it is not explicitly disabled (disable = true) + #[structopt(help = "Run Stratum server for miner push notification.", long)] + pub stratum: bool, + + #[structopt( + long = "reseal-on-txs", + name = "RESEAL_TXS_SET", + help = "Specify which transactions should force the node to reseal a block. SET is one of: none - never reseal on new transactions; own - reseal only on a new local transaction; ext - reseal only on a new external transaction; all - reseal on all new transactions." + )] + pub reseal_on_txs: Option, + + #[structopt( + help = "Specify the minimum time between reseals from incoming transactions. MS is time measured in milliseconds.", + long = "reseal-min-period", + name = "RESEAL_MIN_MS" + )] + pub reseal_min_period: Option, + + #[structopt( + long = "reseal-max-period", + name = "RESEAL_MAX_MS", + help = "Specify the maximum time between reseals from incoming transactions. MS is time measured in milliseconds." + )] + pub reseal_max_period: Option, + + #[structopt( + name = "WORK_QUEUE_SIZE_ITEMS", + long = "work-queue-size", + help = "Specify the number of historical work packages which are kept cached lest a solution is found for them later. High values take more memory but result in fewer unusable solutions." + )] + pub work_queue_size: Option, + + #[structopt( + long = "relay-set", + name = "RELAY_SET", + help = "Set of transactions to relay. SET may be: cheap - Relay any transaction in the queue (this may include invalid transactions); strict - Relay only executed transactions (this guarantees we don't relay invalid transactions, but means we relay nothing if not mining); lenient - Same as strict when mining, and cheap when not." + )] + pub relay_set: Option, + + #[structopt( + long = "usd-per-tx", + name = "USD_PER_TX", + help = "Amount of USD to be paid for a basic transaction. The minimum gas price is set accordingly." + )] + pub usd_per_tx: Option, + + #[structopt( + help = "USD value of a single ETH. SOURCE may be either an amount in USD, a web service or 'auto' to use each web service in turn and fallback on the last known good value.", + name = "USD_PER_ETH_SOURCE", + long = "usd-per-eth" + )] + pub usd_per_eth: Option, + + #[structopt( + long = "price-update-period", + name = "PRICE_UPDATE_T", + help = "PRICE_UPDATE_T will be allowed to pass between each gas price update. PRICE_UPDATE_T may be daily, hourly, a number of seconds, or a time string of the form \"2 days\", \"30 minutes\" etc.." + )] + pub price_update_period: Option, + + #[structopt( + help = "Amount of gas per block to target when sealing a new block.", + long = "gas-floor-target", + name = "GAS_FLOOR" + )] + pub gas_floor_target: Option, + + #[structopt( + help = "A cap on how large we will raise the gas limit per block due to transaction volume.", + long = "gas-cap", + name = "GAS_CAP" + )] + pub gas_cap: Option, + + #[structopt( + help = "Maximum amount of memory that can be used by the transaction queue. Setting this parameter to 0 disables limiting.", + long = "tx-queue-mem-limit", + name = "TX_QUEUE_LIMIT_MB" + )] + pub tx_queue_mem_limit: Option, + + #[structopt( + help = "Maximum amount of transactions in the queue (waiting to be included in next block).", + long = "tx-queue-size", + name = "TX_QUEUE_SIZE_LIMIT" + )] + pub tx_queue_size: Option, + + #[structopt( + help = "Maximum number of transactions per sender in the queue. By default it's 1% of the entire queue, but not less than 16.", + long = "tx-queue-per-sender", + name = "TX_QUEUE_PER_SENDER_LIMIT" + )] + pub tx_queue_per_sender: Option, + + #[structopt( + help = "Specify local accounts for which transactions are prioritized in the queue. ACCOUNTS is a comma-delimited list of addresses.", + long = "tx-queue-locals", + name = "TX_QUEUE_LOCAL_ACCOUNTS" + )] + pub tx_queue_locals: Option, + + #[structopt( + help = "Prioritization strategy used to order transactions in the queue. S may be: gas_price - Prioritize txs with high gas price", + long = "tx-queue-strategy", + name = "TX_QUEUE_S" + )] + pub tx_queue_strategy: Option, + + #[structopt( + help = "Interface address for Stratum server.", + long = "stratum-interface", + name = "STRATUM_IP" + )] + pub stratum_interface: Option, + + #[structopt( + help = "Port for Stratum server to listen on.", + long = "stratum-port", + name = "STRATUM_PORT" + )] + pub stratum_port: Option, + + #[structopt( + help = "Minimum amount of Wei per GAS to be paid for a transaction to be accepted for mining. Overrides --usd-per-tx.", + long = "min-gas-price", + name = "MIN_GAS_PRICE_STRING" + )] + pub min_gas_price: Option, + + #[structopt( + help = "Set PCT percentile gas price value from last 100 blocks as default gas price when sending transactions.", + long = "gas-price-percentile", + name = "PCT" + )] + pub gas_price_percentile: Option, + + #[structopt( + help = "Specify the block author (aka \"coinbase\") address for sending block rewards from sealed blocks. NOTE: MINING WILL NOT WORK WITHOUT THIS OPTION.", + long, + name = "ADDRESS" + )] + pub author: Option, // Sealing / Mining Option + + #[structopt( + help = "Specify the address which should be used to sign consensus messages and issue blocks. Relevant only to non-PoW chains.", + long = "engine-signer", + name = "ENGINE_SIGNER_ADDRESS" + )] + pub engine_signer: Option, + + #[structopt( + help = "Apply a limit of GAS as the maximum amount of gas a single transaction may have for it to be mined.", + long = "tx-gas-limit", + name = "TX_GAS_LIMIT" + )] + pub tx_gas_limit: Option, + + #[structopt( + help = "Maximal time for processing single transaction. If enabled senders of transactions offending the limit will get other transactions penalized.", + long = "tx-time-limit", + name = "TX_TIME_LIMIT_MS" + )] + pub tx_time_limit: Option, + + #[structopt( + long = "extra-data", + help = "Specify a custom extra-data for authored blocks, no more than 32 characters.", + name = "EXTRA_DATA_STRING" + )] + pub extra_data: Option, + + #[structopt( + name = "NOTIFY_WORK_URLS", + help = "URLs to which work package notifications are pushed. URLS should be a comma-delimited list of HTTP URLs.", + long = "notify-work" + )] + pub notify_work: Option, + + #[structopt( + name = "STARTUM_SECRET_STRING", + long = "stratum-secret", + help = "Secret for authorizing Stratum server for peers." + )] + pub stratum_secret: Option, + + #[structopt( + long = "max-round-blocks-to-import", + name = "MAX_ROUND_BLOCKS_S", + help = "Maximal number of blocks to import for each import round." + )] + pub max_round_blocks_to_import: Option, } #[derive(StructOpt, Serialize, Deserialize, Debug, Clone, PartialEq, Default)] pub struct InternalOptions { - #[structopt( - long = "can-restart", - help = "Executable will auto-restart if exiting with 69" - )] - pub can_restart: bool, + #[structopt( + long = "can-restart", + help = "Executable will auto-restart if exiting with 69" + )] + pub can_restart: bool, } #[derive(StructOpt, Serialize, Deserialize, Debug, Clone, PartialEq, Default)] pub struct MiscellaneousOptions { - #[structopt(help = "Don't use terminal color codes in output.", long = "no-color")] - pub no_color: bool, - - // version flag is automatically provided by structopt - #[structopt(long = "no-config", help = "Don't load a configuration file.")] - pub no_config: bool, - - #[structopt( - short = "l", - long, - name = "LOGGING", - help = "Specify the general logging level (error, warn, info, debug or trace). It can also be set for a specific module, example: '-l sync=debug,rpc=trace'" - )] - pub logging: Option, - - #[structopt( - long = "log-file", - name = "LOG_FILENAME", - help = "Specify a filename into which logging should be appended" - )] - pub log_file: Option, + #[structopt(help = "Don't use terminal color codes in output.", long = "no-color")] + pub no_color: bool, + + // version flag is automatically provided by structopt + #[structopt(long = "no-config", help = "Don't load a configuration file.")] + pub no_config: bool, + + #[structopt( + short = "l", + long, + name = "LOGGING", + help = "Specify the general logging level (error, warn, info, debug or trace). It can also be set for a specific module, example: '-l sync=debug,rpc=trace'" + )] + pub logging: Option, + + #[structopt( + long = "log-file", + name = "LOG_FILENAME", + help = "Specify a filename into which logging should be appended" + )] + pub log_file: Option, } #[derive(StructOpt, Serialize, Deserialize, Debug, Clone, PartialEq, Default)] pub struct FootPrintOptions { - #[structopt( - help = "Automatically scale amount of verifier threads based on workload. Not guaranteed to be faster.", - long = "scale-verifiers" - )] - pub scale_verifiers: bool, - - #[structopt( - help = "Indicates if full transaction tracing should be enabled. Works only if client had been fully synced with tracing enabled. BOOL may be one of auto, on, off. auto uses last used value of this option (off if it does not exist).", - long, - name = "TRACING_BOOL" - )] - pub tracing: Option, - - #[structopt( - long, - name = "PRUNING_METHOD", - help = "Configure pruning of the state/storage trie. PRUNING_METHOD may be one of auto, archive, fast: archive - keep all state trie data. No pruning. fast - maintain journal overlay. Fast but 50MB used. auto - use the method most recently synced or default to fast if none synced." - )] - pub pruning: Option, - - #[structopt( - long = "pruning-history", - help = "Set a minimum number of recent states to keep in memory when pruning is active.", - name = "PRUNING_HISTORY_NUM" - )] - pub pruning_history: Option, - - #[structopt( - long = "pruning-memory", - name = "PRUNING_MEMORY_MB", - help = "The ideal amount of memory in megabytes to use to store recent states. As many states as possible will be kept within this limit, and at least --pruning-history states will always be kept." - )] - pub pruning_memory: Option, - - #[structopt( - help = "Override database cache size.", - long = "cache-size-db", - name = "CACHE_SIZE_DB_MB" - )] - pub cache_size_db: Option, - - #[structopt( - help = "Specify the preferred size of the blockchain cache in megabytes.", - long = "cache-size-blocks", - name = "CACHE_SIZE_BLOCKS_MB" - )] - pub cache_size_blocks: Option, - - #[structopt( - help = "Specify the maximum size of memory to use for block queue.", - long = "cache-size-queue", - name = "CACHE_SIZE_QUEUE_MB" - )] - pub cache_size_queue: Option, - - #[structopt( - help = "Specify the maximum size of memory to use for the state cache.", - long = "cache-size-state", - name = "CACHE_SIZE_STATE" - )] - pub cache_size_state: Option, - - #[structopt( - help = "Database compaction type. TYPE may be one of: ssd - suitable for SSDs and fast HDDs; hdd - suitable for slow HDDs; auto - determine automatically.", - long = "db-compaction", - name = "DB_COMPACTION_TYPE" - )] - pub db_compaction: Option, - - #[structopt( - help = "Build appropriate information to allow enumeration of all accounts and storage keys. Doubles the size of the state database. BOOL may be one of on, off or auto.", - long = "fat-db", - name = "FAT_DB_BOOL" - )] - pub fat_db: Option, - - #[structopt( - help = "Set total amount of discretionary memory to use for the entire system, overrides other cache and queue options.", - long = "cache-size", - name = "CACHE_SIZE_MB" - )] - pub cache_size: Option, - - #[structopt( - help = "Amount of verifier threads to use or to begin with, if verifier auto-scaling is enabled.", - name = "NUM_VERIFIERS_INT", - long = "num-verifiers" - )] - pub num_verifiers: Option, + #[structopt( + help = "Automatically scale amount of verifier threads based on workload. Not guaranteed to be faster.", + long = "scale-verifiers" + )] + pub scale_verifiers: bool, + + #[structopt( + help = "Indicates if full transaction tracing should be enabled. Works only if client had been fully synced with tracing enabled. BOOL may be one of auto, on, off. auto uses last used value of this option (off if it does not exist).", + long, + name = "TRACING_BOOL" + )] + pub tracing: Option, + + #[structopt( + long, + name = "PRUNING_METHOD", + help = "Configure pruning of the state/storage trie. PRUNING_METHOD may be one of auto, archive, fast: archive - keep all state trie data. No pruning. fast - maintain journal overlay. Fast but 50MB used. auto - use the method most recently synced or default to fast if none synced." + )] + pub pruning: Option, + + #[structopt( + long = "pruning-history", + help = "Set a minimum number of recent states to keep in memory when pruning is active.", + name = "PRUNING_HISTORY_NUM" + )] + pub pruning_history: Option, + + #[structopt( + long = "pruning-memory", + name = "PRUNING_MEMORY_MB", + help = "The ideal amount of memory in megabytes to use to store recent states. As many states as possible will be kept within this limit, and at least --pruning-history states will always be kept." + )] + pub pruning_memory: Option, + + #[structopt( + help = "Override database cache size.", + long = "cache-size-db", + name = "CACHE_SIZE_DB_MB" + )] + pub cache_size_db: Option, + + #[structopt( + help = "Specify the preferred size of the blockchain cache in megabytes.", + long = "cache-size-blocks", + name = "CACHE_SIZE_BLOCKS_MB" + )] + pub cache_size_blocks: Option, + + #[structopt( + help = "Specify the maximum size of memory to use for block queue.", + long = "cache-size-queue", + name = "CACHE_SIZE_QUEUE_MB" + )] + pub cache_size_queue: Option, + + #[structopt( + help = "Specify the maximum size of memory to use for the state cache.", + long = "cache-size-state", + name = "CACHE_SIZE_STATE" + )] + pub cache_size_state: Option, + + #[structopt( + help = "Database compaction type. TYPE may be one of: ssd - suitable for SSDs and fast HDDs; hdd - suitable for slow HDDs; auto - determine automatically.", + long = "db-compaction", + name = "DB_COMPACTION_TYPE" + )] + pub db_compaction: Option, + + #[structopt( + help = "Build appropriate information to allow enumeration of all accounts and storage keys. Doubles the size of the state database. BOOL may be one of on, off or auto.", + long = "fat-db", + name = "FAT_DB_BOOL" + )] + pub fat_db: Option, + + #[structopt( + help = "Set total amount of discretionary memory to use for the entire system, overrides other cache and queue options.", + long = "cache-size", + name = "CACHE_SIZE_MB" + )] + pub cache_size: Option, + + #[structopt( + help = "Amount of verifier threads to use or to begin with, if verifier auto-scaling is enabled.", + name = "NUM_VERIFIERS_INT", + long = "num-verifiers" + )] + pub num_verifiers: Option, } #[derive(StructOpt, Serialize, Deserialize, Debug, Clone, PartialEq, Default)] pub struct ImportExportOptions { - #[structopt(long = "no-seal-check", help = "Skip block seal check.")] - pub no_seal_check: bool, + #[structopt(long = "no-seal-check", help = "Skip block seal check.")] + pub no_seal_check: bool, } #[derive(StructOpt, Serialize, Deserialize, Debug, Clone, PartialEq, Default)] pub struct SnapshotOptions { - #[structopt( - help = "Disable automated snapshots which usually occur once every 5000 blocks.", - long = "no-periodic-snapshots" - )] - pub no_periodic_snapshot: bool, - - #[structopt( - help = "Enables multiple threads for snapshots creation.", - long = "snapshot-threads", - name = "SNAPSHOT_THREADS_NUM" - )] - pub snapshot_threads: Option, + #[structopt( + help = "Disable automated snapshots which usually occur once every 5000 blocks.", + long = "no-periodic-snapshots" + )] + pub no_periodic_snapshot: bool, + + #[structopt( + help = "Enables multiple threads for snapshots creation.", + long = "snapshot-threads", + name = "SNAPSHOT_THREADS_NUM" + )] + pub snapshot_threads: Option, } #[derive(StructOpt, Serialize, Deserialize, Debug, Clone, PartialEq, Default)] pub struct LegacyOptions { - // TODO: These options were hidden from config, so should we not include them? - #[structopt( - long, - help = "Run in Geth-compatibility mode. Sets the IPC path to be the same as Geth's. Overrides the --ipc-path and --ipcpath options. Alters RPCs to reflect Geth bugs. Includes the personal_ RPC by default." - )] - pub geth: bool, - - #[structopt( - help = "Attempt to import keys from Geth client.", - long = "import-geth-keys" - )] - pub import_geth_keys: bool, -} \ No newline at end of file + // TODO: These options were hidden from config, so should we not include them? + #[structopt( + long, + help = "Run in Geth-compatibility mode. Sets the IPC path to be the same as Geth's. Overrides the --ipc-path and --ipcpath options. Alters RPCs to reflect Geth bugs. Includes the personal_ RPC by default." + )] + pub geth: bool, + + #[structopt( + help = "Attempt to import keys from Geth client.", + long = "import-geth-keys" + )] + pub import_geth_keys: bool, +} diff --git a/parity/cli/parse_cli.rs b/parity/cli/parse_cli.rs index 22ff1dcee28..182b45c19ea 100644 --- a/parity/cli/parse_cli.rs +++ b/parity/cli/parse_cli.rs @@ -5,8 +5,8 @@ use cli::subcommands::SubCommands; #[derive(StructOpt, Debug, Clone, Default)] pub struct ArgsInput { - #[structopt(subcommand)] - pub subcommands: Option, - #[structopt(flatten)] - pub globals: Globals, + #[structopt(subcommand)] + pub subcommands: Option, + #[structopt(flatten)] + pub globals: Globals, } diff --git a/parity/cli/subcommands.rs b/parity/cli/subcommands.rs index de5473d3a44..bcb509009f2 100644 --- a/parity/cli/subcommands.rs +++ b/parity/cli/subcommands.rs @@ -3,240 +3,240 @@ use structopt::StructOpt; #[derive(StructOpt, Deserialize, Debug, Clone)] pub enum SubCommands { - Daemon(Daemon), - Wallet { - #[structopt(subcommand)] - wallet: Wallet, - }, - Account { - #[structopt(subcommand)] - account: Account, - }, - Import(Import), - Export { - #[structopt(subcommand)] - export: Export, - }, - Signer(Signer), - Snapshots(Snapshots), - Restore(Restore), - Tools(Tools), - Db(Db), - #[structopt( - about = "Print the hashed light clients headers of the given --chain (default: mainnet) in a JSON format. To be used as hardcoded headers in a genesis file." - )] - ExportHardcodedSync, - Dapp(Dapp), + Daemon(Daemon), + Wallet { + #[structopt(subcommand)] + wallet: Wallet, + }, + Account { + #[structopt(subcommand)] + account: Account, + }, + Import(Import), + Export { + #[structopt(subcommand)] + export: Export, + }, + Signer(Signer), + Snapshots(Snapshots), + Restore(Restore), + Tools(Tools), + Db(Db), + #[structopt( + about = "Print the hashed light clients headers of the given --chain (default: mainnet) in a JSON format. To be used as hardcoded headers in a genesis file." + )] + ExportHardcodedSync, + Dapp(Dapp), } #[derive(StructOpt, Deserialize, Debug, Clone)] #[structopt(about = "Use parity as a daemon")] pub struct Daemon { - #[structopt(long = "pid-file", name = "PID-FILE", help = "Path to the pid file")] - pub pid_file: Option, + #[structopt(long = "pid-file", name = "PID-FILE", help = "Path to the pid file")] + pub pid_file: Option, } #[derive(StructOpt, Deserialize, Debug, Clone)] #[structopt(about = "Manage accounts")] pub enum Account { - #[structopt( - about = "Create a new account (and its associated key) for the given --chain [default: mainnet]" - )] - New, - #[structopt(about = "List existing accounts of the given --chain [default: mainnet]")] - List, - #[structopt( - about = "Import accounts from JSON UTC keystore files to the specified --chain [default: mainnet]" - )] - // FIXME: The original parser implementation had this as `Option>` but this is not - // supported by structopt yet, referring to issue - // [#364](https://github.com/TeXitoi/structopt/issues/364) - Import { path: Vec }, + #[structopt( + about = "Create a new account (and its associated key) for the given --chain [default: mainnet]" + )] + New, + #[structopt(about = "List existing accounts of the given --chain [default: mainnet]")] + List, + #[structopt( + about = "Import accounts from JSON UTC keystore files to the specified --chain [default: mainnet]" + )] + // FIXME: The original parser implementation had this as `Option>` but this is not + // supported by structopt yet, referring to issue + // [#364](https://github.com/TeXitoi/structopt/issues/364) + Import { path: Vec }, } #[derive(StructOpt, Deserialize, Debug, Clone)] #[structopt(about = "Manage wallet")] pub enum Wallet { - #[structopt(help = "Import wallet into the given chain (default: mainnet)")] - Import { - #[structopt(name = "PATH", help = "Path to the wallet")] - path: Option, - }, + #[structopt(help = "Import wallet into the given chain (default: mainnet)")] + Import { + #[structopt(name = "PATH", help = "Path to the wallet")] + path: Option, + }, } #[derive(StructOpt, Deserialize, Debug, Clone)] #[structopt( - about = "Import blockchain data from a file to the given chain database (default: mainnet)" + about = "Import blockchain data from a file to the given chain database (default: mainnet)" )] pub struct Import { - #[structopt( - long, - name = "FORMAT", - help = "Import in a given format, FORMAT must be either 'hex' or 'binary'. (default: auto)" - )] - pub format: Option, - - #[structopt(name = "FILE", long, help = "Path to the file to import from")] - pub file: Option, + #[structopt( + long, + name = "FORMAT", + help = "Import in a given format, FORMAT must be either 'hex' or 'binary'. (default: auto)" + )] + pub format: Option, + + #[structopt(name = "FILE", long, help = "Path to the file to import from")] + pub file: Option, } #[derive(StructOpt, Deserialize, Debug, Clone)] #[structopt(about = "Export blockchain")] pub enum Export { - Blocks(ExportBlocks), - State(ExportState), + Blocks(ExportBlocks), + State(ExportState), } #[derive(StructOpt, Deserialize, Debug, Clone)] #[structopt( - about = "Export the blockchain blocks from the given chain database [default: mainnet] into a file. The command requires the chain to be synced with --fat-db on." + about = "Export the blockchain blocks from the given chain database [default: mainnet] into a file. The command requires the chain to be synced with --fat-db on." )] pub struct ExportBlocks { - #[structopt( - long, - name = "FORMAT", - help = "Export in a given format. FORMAT must be 'hex' or 'binary'. [default: binary]" - )] - pub format: Option, - - #[structopt( - long, - name = "FROM_BLOCK", - help = "Export from block FROM_BLOCK, which may be an index or hash ", - default_value = "1" - )] - pub from: String, - - #[structopt( - long, - name = "TO_BLOCK", - help = "Export to (including TO_BLOCK) block TO_BLOCK, which may be an index, hash or 'latest'", - default_value = "latest" - )] - pub to: String, - #[structopt(help = "Path to the exported file", name = "FILE")] - pub file: Option, + #[structopt( + long, + name = "FORMAT", + help = "Export in a given format. FORMAT must be 'hex' or 'binary'. [default: binary]" + )] + pub format: Option, + + #[structopt( + long, + name = "FROM_BLOCK", + help = "Export from block FROM_BLOCK, which may be an index or hash ", + default_value = "1" + )] + pub from: String, + + #[structopt( + long, + name = "TO_BLOCK", + help = "Export to (including TO_BLOCK) block TO_BLOCK, which may be an index, hash or 'latest'", + default_value = "latest" + )] + pub to: String, + #[structopt(help = "Path to the exported file", name = "FILE")] + pub file: Option, } #[derive(StructOpt, Deserialize, Debug, Clone)] #[structopt( - about = "Export the blockchain state from the given chain [default: mainnet] into a file. The command requires the chain to be synced with --fat-db on." + about = "Export the blockchain state from the given chain [default: mainnet] into a file. The command requires the chain to be synced with --fat-db on." )] pub struct ExportState { - #[structopt(long = "no-storage", help = "Don't export account storage.")] - pub no_storage: bool, - - #[structopt(long = "no-code", help = "Don't export account code.")] - pub no_code: bool, - - #[structopt( - long = "max-balance", - name = "MAX_WEI", - help = "Don't export accounts with balance greater than specified." - )] - pub max_balance: Option, - - #[structopt( - long = "min-balance", - name = "MIN_WEI", - help = "Don't export accounts with balance less than specified." - )] - pub min_balance: Option, - - #[structopt( - default_value = "latest", - long, - name = "BLOCK", - help = "Take a snapshot at the given block, which may be an index, hash, or latest. Note that taking snapshots at non-recent blocks will only work with --pruning archive" - )] - pub at: String, - - #[structopt( - long, - name = "FORMAT", - help = "Export in a given format. FORMAT must be either 'hex' or 'binary'. [default: binary]" - )] - pub format: Option, - - #[structopt(long = "file", name = "FILE", help = "Path to the exported file")] - pub file: Option, + #[structopt(long = "no-storage", help = "Don't export account storage.")] + pub no_storage: bool, + + #[structopt(long = "no-code", help = "Don't export account code.")] + pub no_code: bool, + + #[structopt( + long = "max-balance", + name = "MAX_WEI", + help = "Don't export accounts with balance greater than specified." + )] + pub max_balance: Option, + + #[structopt( + long = "min-balance", + name = "MIN_WEI", + help = "Don't export accounts with balance less than specified." + )] + pub min_balance: Option, + + #[structopt( + default_value = "latest", + long, + name = "BLOCK", + help = "Take a snapshot at the given block, which may be an index, hash, or latest. Note that taking snapshots at non-recent blocks will only work with --pruning archive" + )] + pub at: String, + + #[structopt( + long, + name = "FORMAT", + help = "Export in a given format. FORMAT must be either 'hex' or 'binary'. [default: binary]" + )] + pub format: Option, + + #[structopt(long = "file", name = "FILE", help = "Path to the exported file")] + pub file: Option, } #[derive(StructOpt, Deserialize, Debug, Clone)] #[structopt(about = "Manage Signer")] pub enum Signer { - #[structopt( - about = "Generate a new signer-authentication token for the given --chain (default: mainnet)" - )] - NewToken, - #[structopt( - about = "List the signer-authentication tokens from given --chain (default: mainnet)" - )] - List, - #[structopt(about = "Sign")] - Sign { - #[structopt(name = "ID")] - id: Option, - }, - #[structopt(about = "Reject")] - Reject { - #[structopt(name = "ID")] - id: Option, - }, + #[structopt( + about = "Generate a new signer-authentication token for the given --chain (default: mainnet)" + )] + NewToken, + #[structopt( + about = "List the signer-authentication tokens from given --chain (default: mainnet)" + )] + List, + #[structopt(about = "Sign")] + Sign { + #[structopt(name = "ID")] + id: Option, + }, + #[structopt(about = "Reject")] + Reject { + #[structopt(name = "ID")] + id: Option, + }, } #[derive(StructOpt, Deserialize, Debug, Clone)] #[structopt(about = "Make a snapshot of the database of the given chain (default: mainnet)")] pub struct Snapshots { - #[structopt( - default_value = "latest", - name = "BLOCK", - help = "Take a snapshot at the given block, which may be an index, hash, or latest. Note that taking snapshots at non-recent blocks will only work with --pruning archive" - )] - pub at: String, - - #[structopt(name = "FILE", help = "Path to the file to export to")] - pub file: Option, + #[structopt( + default_value = "latest", + name = "BLOCK", + help = "Take a snapshot at the given block, which may be an index, hash, or latest. Note that taking snapshots at non-recent blocks will only work with --pruning archive" + )] + pub at: String, + + #[structopt(name = "FILE", help = "Path to the file to export to")] + pub file: Option, } #[derive(StructOpt, Deserialize, Debug, Clone)] #[structopt( - about = "Restore the databse of the given chain (default: mainnet) from a snapshot file" + about = "Restore the databse of the given chain (default: mainnet) from a snapshot file" )] pub struct Restore { - #[structopt(name = "FILE", help = "Path to the file to restore from")] - pub file: Option, + #[structopt(name = "FILE", help = "Path to the file to restore from")] + pub file: Option, } #[derive(StructOpt, Deserialize, Debug, Clone)] #[structopt(about = "Tools")] pub enum Tools { - #[structopt(about = "Hash a file using the Keccak-256 algorithm")] - Hash { - #[structopt(name = "FILE")] - file: Option, - }, + #[structopt(about = "Hash a file using the Keccak-256 algorithm")] + Hash { + #[structopt(name = "FILE")] + file: Option, + }, } #[derive(StructOpt, Deserialize, Debug, Clone)] #[structopt(about = "Manage the Database representing the state of the blockchain on this system")] pub enum Db { - #[structopt(about = "Clean the database of the given --chain (default: mainnet)")] - Kill, - #[structopt(about = "Removes NUM latests blocks from the db")] - Reset { - #[structopt( - default_value = "10", - name = "NUM", - help = "Number of blocks to revert" - )] - num: u32, - }, + #[structopt(about = "Clean the database of the given --chain (default: mainnet)")] + Kill, + #[structopt(about = "Removes NUM latests blocks from the db")] + Reset { + #[structopt( + default_value = "10", + name = "NUM", + help = "Number of blocks to revert" + )] + num: u32, + }, } #[derive(StructOpt, Deserialize, Debug, Clone)] #[structopt(about = "Manage Dapps")] pub struct Dapp { - #[structopt(help = "Path to the dapps", name = "PATH")] - pub path: Option, + #[structopt(help = "Path to the dapps", name = "PATH")] + pub path: Option, } diff --git a/parity/cli/tests/test_cli.rs b/parity/cli/tests/test_cli.rs index 04e733d5cd2..4fc4f4079f0 100644 --- a/parity/cli/tests/test_cli.rs +++ b/parity/cli/tests/test_cli.rs @@ -5,57 +5,57 @@ use cli::parse_cli::ArgsInput; #[test] fn test_override_defaults_with_custom_config() { - let test_config = - Args::generate_default_configuration("test_config.toml", "config_default.toml").unwrap(); - - assert_eq!(test_config.0.sealing_mining.stratum, true); - assert_eq!( - test_config.0.sealing_mining.stratum_interface, - Some("some interface".to_owned()) - ); - assert_eq!(test_config.0.sealing_mining.stratum_port, Some(8007)); - assert_eq!( - test_config.0.sealing_mining.stratum_secret, - Some("Yellow".to_owned()) - ); + let test_config = + Args::generate_default_configuration("test_config.toml", "config_default.toml").unwrap(); + + assert_eq!(test_config.0.sealing_mining.stratum, true); + assert_eq!( + test_config.0.sealing_mining.stratum_interface, + Some("some interface".to_owned()) + ); + assert_eq!(test_config.0.sealing_mining.stratum_port, Some(8007)); + assert_eq!( + test_config.0.sealing_mining.stratum_secret, + Some("Yellow".to_owned()) + ); } #[test] fn test_overwrite_custom_config_with_raw_flags() { - let mut raw: ArgsInput = Default::default(); - let mut resolved: Args = Default::default(); + let mut raw: ArgsInput = Default::default(); + let mut resolved: Args = Default::default(); - // These are equivalent to the raw arguments that are going to be accepted - raw.globals.sealing_mining.stratum_secret = Some("Changed".to_owned()); + // These are equivalent to the raw arguments that are going to be accepted + raw.globals.sealing_mining.stratum_secret = Some("Changed".to_owned()); - // In the default config file, there is a config value "Yellow" for the - // same field, which it should ignore because of the presence of the raw - // argument - let (user_defaults, fallback) = - Args::generate_default_configuration("test_config.toml", "config_default.toml").unwrap(); + // In the default config file, there is a config value "Yellow" for the + // same field, which it should ignore because of the presence of the raw + // argument + let (user_defaults, fallback) = + Args::generate_default_configuration("test_config.toml", "config_default.toml").unwrap(); - resolved.from_cli(raw, user_defaults, fallback); + resolved.from_cli(raw, user_defaults, fallback); - assert_eq!(resolved.arg_stratum_secret, Some("Changed".to_owned())); + assert_eq!(resolved.arg_stratum_secret, Some("Changed".to_owned())); } #[test] fn test_not_accepting_min_peers_bigger_than_max_peers() { - // Setting up defaults - let mut raw: ArgsInput = Default::default(); - let mut resolved: Args = Default::default(); - let (user_defaults, fallback) = - Args::generate_default_configuration("test_config.toml", "config_default.toml").unwrap(); - - raw.globals.networking.min_peers = Some(50); - raw.globals.networking.max_peers = Some(40); - - let output = resolved.from_cli(raw, user_defaults, fallback); - - assert_eq!( - output, - Err(ArgsError::PeerConfigurationError( - "max-peers need to be greater than or equal to min-peers".to_owned() - )) - ); + // Setting up defaults + let mut raw: ArgsInput = Default::default(); + let mut resolved: Args = Default::default(); + let (user_defaults, fallback) = + Args::generate_default_configuration("test_config.toml", "config_default.toml").unwrap(); + + raw.globals.networking.min_peers = Some(50); + raw.globals.networking.max_peers = Some(40); + + let output = resolved.from_cli(raw, user_defaults, fallback); + + assert_eq!( + output, + Err(ArgsError::PeerConfigurationError( + "max-peers need to be greater than or equal to min-peers".to_owned() + )) + ); } diff --git a/parity/configuration.rs b/parity/configuration.rs index cabb20b6d3d..0ae67ffcaf7 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -529,7 +529,7 @@ impl Configuration { })) } else { Ok(None) } } - + pub fn miner_options(&self) -> Result { let is_dev_chain = self.is_dev_chain()?; @@ -831,8 +831,8 @@ impl Configuration { let mut apis = self.args.arg_ipc_apis.clone(); if self.args.flag_geth { if !apis.is_empty() { - apis.push_str(","); - } + apis.push_str(","); + } apis.push_str("personal"); } apis.parse()? diff --git a/parity/test_configuration.rs b/parity/test_configuration.rs index 3974124467b..46ee57a757e 100644 --- a/parity/test_configuration.rs +++ b/parity/test_configuration.rs @@ -1,172 +1,172 @@ #[cfg(test)] mod test_configuration{ - use cli::args::Args; - use cli::parse_cli::ArgsInput; - use cli::globals::Globals; - use ethcore_logger::Config as LogConfig; - use configuration::{Configuration, Cmd}; - use std::time::Duration; - use params::{GasPricerConfig}; - use cache::CacheConfig; - - use std::io::Write; - use std::fs::File; - use std::str::FromStr; - - use tempfile::TempDir; - use ethcore::miner::MinerOptions; - use miner::pool::PrioritizationStrategy; - use parity_rpc::NetworkSettings; - use updater::{UpdatePolicy, UpdateFilter, ReleaseTrack}; - use types::ids::BlockId; - use types::data_format::DataFormat; - use account::{AccountCmd, NewAccount, ImportAccounts, ListAccounts}; - use blockchain::{BlockchainCmd, ImportBlockchain, ExportBlockchain, ExportState}; - use dir::{Directories, default_hypervisor_path}; - use helpers::{default_network_config}; - use params::SpecType; - use presale::ImportWallet; - use rpc::WsConfiguration; - use rpc_apis::ApiSet; - use run::RunCmd; - - use network::{AllowIP, IpFilter}; - - extern crate ipnetwork; - use self::ipnetwork::IpNetwork; - - use super::*; - - - fn intialize_with_out_of_the_box_defaults() -> (Args, ArgsInput, Globals, Globals) { - let raw: ArgsInput = Default::default(); - let resolved: Args = Default::default(); - let (user_defaults, fallback) = Args::generate_default_configuration( - "config_default.toml", - "config_default.toml" - ).unwrap(); - - (resolved, raw, user_defaults, fallback) - } - - #[test] - fn test_subcommand_account_new() { - let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); - - conf.cmd_account = true; - conf.cmd_account_new = true; - - let conf = Configuration { - args: conf, - }; - - let conf: Cmd = conf.into_command().unwrap().cmd; - - let cmd_arg: Cmd = Cmd::Account( - AccountCmd::New(NewAccount{ - iterations: 10240, - path: Directories::default().keys, - password_file: None, - spec: SpecType::default(), - })); - - assert_eq!(conf, cmd_arg); - - } - - #[test] - fn test_command_account_list() { - let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - - conf.cmd_account = true; - conf.cmd_account_list = true; - conf.from_cli(raw, user_defaults, fallback).unwrap(); - - let conf = Configuration { - args: conf, - }; - - let conf: Cmd = conf.into_command().unwrap().cmd; - - let cmd_arg: Cmd = Cmd::Account( - AccountCmd::List(ListAccounts { - path: Directories::default().keys, - spec: SpecType::default(), - })); - - assert_eq!(conf, cmd_arg); - - } + use cli::args::Args; + use cli::parse_cli::ArgsInput; + use cli::globals::Globals; + use ethcore_logger::Config as LogConfig; + use configuration::{Configuration, Cmd}; + use std::time::Duration; + use params::{GasPricerConfig}; + use cache::CacheConfig; + + use std::io::Write; + use std::fs::File; + use std::str::FromStr; + + use tempfile::TempDir; + use ethcore::miner::MinerOptions; + use miner::pool::PrioritizationStrategy; + use parity_rpc::NetworkSettings; + use updater::{UpdatePolicy, UpdateFilter, ReleaseTrack}; + use types::ids::BlockId; + use types::data_format::DataFormat; + use account::{AccountCmd, NewAccount, ImportAccounts, ListAccounts}; + use blockchain::{BlockchainCmd, ImportBlockchain, ExportBlockchain, ExportState}; + use dir::{Directories, default_hypervisor_path}; + use helpers::{default_network_config}; + use params::SpecType; + use presale::ImportWallet; + use rpc::WsConfiguration; + use rpc_apis::ApiSet; + use run::RunCmd; + + use network::{AllowIP, IpFilter}; + + extern crate ipnetwork; + use self::ipnetwork::IpNetwork; + + use super::*; + + + fn intialize_with_out_of_the_box_defaults() -> (Args, ArgsInput, Globals, Globals) { + let raw: ArgsInput = Default::default(); + let resolved: Args = Default::default(); + let (user_defaults, fallback) = Args::generate_default_configuration( + "config_default.toml", + "config_default.toml" + ).unwrap(); + + (resolved, raw, user_defaults, fallback) + } + + #[test] + fn test_subcommand_account_new() { + let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); + conf.from_cli(raw, user_defaults, fallback).unwrap(); + + conf.cmd_account = true; + conf.cmd_account_new = true; + + let conf = Configuration { + args: conf, + }; + + let conf: Cmd = conf.into_command().unwrap().cmd; + + let cmd_arg: Cmd = Cmd::Account( + AccountCmd::New(NewAccount{ + iterations: 10240, + path: Directories::default().keys, + password_file: None, + spec: SpecType::default(), + })); + + assert_eq!(conf, cmd_arg); + + } + + #[test] + fn test_command_account_list() { + let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); + + conf.cmd_account = true; + conf.cmd_account_list = true; + conf.from_cli(raw, user_defaults, fallback).unwrap(); + + let conf = Configuration { + args: conf, + }; + + let conf: Cmd = conf.into_command().unwrap().cmd; + + let cmd_arg: Cmd = Cmd::Account( + AccountCmd::List(ListAccounts { + path: Directories::default().keys, + spec: SpecType::default(), + })); + + assert_eq!(conf, cmd_arg); + + } #[test] fn test_command_account_import() { - let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); + conf.from_cli(raw, user_defaults, fallback).unwrap(); - conf.cmd_account = true; - conf.cmd_account_import = true; - conf.arg_account_import_path = Some(vec!["my_dir".into(), "another_dir".into()]); + conf.cmd_account = true; + conf.cmd_account_import = true; + conf.arg_account_import_path = Some(vec!["my_dir".into(), "another_dir".into()]); - let conf = Configuration { - args: conf, - }; + let conf = Configuration { + args: conf, + }; - let conf: Cmd = conf.into_command().unwrap().cmd; + let conf: Cmd = conf.into_command().unwrap().cmd; - let cmd_arg: Cmd = Cmd::Account(AccountCmd::Import(ImportAccounts { + let cmd_arg: Cmd = Cmd::Account(AccountCmd::Import(ImportAccounts { from: vec!["my_dir".into(), "another_dir".into()], to: Directories::default().keys, spec: SpecType::default(), })); - assert_eq!(conf, cmd_arg); - } - - #[test] - fn test_command_wallet_import() { - let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); - - conf.cmd_wallet = true; - conf.cmd_wallet_import = true; - conf.arg_wallet_import_path = Some("my_wallet.json".to_owned()); - conf.arg_password = vec!["pwd".into()]; - - let conf = Configuration { - args: conf, - }; - - let conf: Cmd = conf.into_command().unwrap().cmd; + assert_eq!(conf, cmd_arg); + } - let cmd_arg = Cmd::ImportPresaleWallet(ImportWallet { - iterations: 10240, - path: Directories::default().keys, - wallet_path: "my_wallet.json".into(), - password_file: Some("pwd".into()), - spec: SpecType::default(), - }); + #[test] + fn test_command_wallet_import() { + let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); + conf.from_cli(raw, user_defaults, fallback).unwrap(); + + conf.cmd_wallet = true; + conf.cmd_wallet_import = true; + conf.arg_wallet_import_path = Some("my_wallet.json".to_owned()); + conf.arg_password = vec!["pwd".into()]; + + let conf = Configuration { + args: conf, + }; + + let conf: Cmd = conf.into_command().unwrap().cmd; + + let cmd_arg = Cmd::ImportPresaleWallet(ImportWallet { + iterations: 10240, + path: Directories::default().keys, + wallet_path: "my_wallet.json".into(), + password_file: Some("pwd".into()), + spec: SpecType::default(), + }); - assert_eq!(conf, cmd_arg); - } + assert_eq!(conf, cmd_arg); + } #[test] fn test_command_blockchain_import() { - let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); + conf.from_cli(raw, user_defaults, fallback).unwrap(); - conf.cmd_import = true; - conf.arg_import_file = Some("blockchain.json".to_owned()); + conf.cmd_import = true; + conf.arg_import_file = Some("blockchain.json".to_owned()); - let conf = Configuration { - args: conf, - }; + let conf = Configuration { + args: conf, + }; - let conf: Cmd = conf.into_command().unwrap().cmd; - - let cmd_arg = Cmd::Blockchain(BlockchainCmd::Import(ImportBlockchain { + let conf: Cmd = conf.into_command().unwrap().cmd; + + let cmd_arg = Cmd::Blockchain(BlockchainCmd::Import(ImportBlockchain { spec: Default::default(), cache_config: Default::default(), dirs: Default::default(), @@ -186,24 +186,24 @@ mod test_configuration{ })); assert_eq!(conf, cmd_arg); - } - + } + #[test] fn test_command_blockchain_export() { - let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); + conf.from_cli(raw, user_defaults, fallback).unwrap(); - conf.cmd_export = true; - conf.cmd_export_blocks = true; - conf.arg_export_blocks_from = "1".to_owned(); - conf.arg_export_blocks_to = "latest".to_owned(); - conf.arg_export_blocks_file = Some("blockchain.json".to_owned()); + conf.cmd_export = true; + conf.cmd_export_blocks = true; + conf.arg_export_blocks_from = "1".to_owned(); + conf.arg_export_blocks_to = "latest".to_owned(); + conf.arg_export_blocks_file = Some("blockchain.json".to_owned()); - let conf = Configuration { - args: conf, - }; + let conf = Configuration { + args: conf, + }; - let conf: Cmd = conf.into_command().unwrap().cmd; + let conf: Cmd = conf.into_command().unwrap().cmd; let cmd_arg = Cmd::Blockchain(BlockchainCmd::Export(ExportBlockchain { spec: Default::default(), @@ -222,26 +222,26 @@ mod test_configuration{ check_seal: true, max_round_blocks_to_import: 12, })); - assert_eq!(conf, cmd_arg); - } + assert_eq!(conf, cmd_arg); + } #[test] fn test_command_state_export() { - let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); - - conf.cmd_export = true; - conf.cmd_export_state = true; - conf.arg_export_state_at = "latest".to_owned(); - conf.arg_export_state_min_balance = None; - conf.arg_export_state_max_balance = None; - conf.arg_export_state_file = Some("state.json".to_owned()); - - let conf = Configuration { - args: conf, - }; - - let conf: Cmd = conf.into_command().unwrap().cmd; - + let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); + conf.from_cli(raw, user_defaults, fallback).unwrap(); + + conf.cmd_export = true; + conf.cmd_export_state = true; + conf.arg_export_state_at = "latest".to_owned(); + conf.arg_export_state_min_balance = None; + conf.arg_export_state_max_balance = None; + conf.arg_export_state_file = Some("state.json".to_owned()); + + let conf = Configuration { + args: conf, + }; + + let conf: Cmd = conf.into_command().unwrap().cmd; + let cmd_arg = Cmd::Blockchain(BlockchainCmd::ExportState(ExportState { spec: Default::default(), cache_config: Default::default(), @@ -260,29 +260,29 @@ mod test_configuration{ min_balance: None, max_balance: None, max_round_blocks_to_import: 12, - })); - - assert_eq!(conf, cmd_arg); + })); + + assert_eq!(conf, cmd_arg); } #[test] fn test_command_blockchain_export_with_custom_format() { - - let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); - conf.cmd_export = true; - conf.cmd_export_blocks = true; - conf.arg_export_blocks_from = "1".to_owned(); - conf.arg_export_blocks_to = "latest".to_owned(); - conf.arg_export_blocks_format = Some("hex".to_owned()); - conf.arg_export_blocks_file = Some("blockchain.json".to_owned()); + let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); + conf.from_cli(raw, user_defaults, fallback).unwrap(); - let conf = Configuration { - args: conf, - }; + conf.cmd_export = true; + conf.cmd_export_blocks = true; + conf.arg_export_blocks_from = "1".to_owned(); + conf.arg_export_blocks_to = "latest".to_owned(); + conf.arg_export_blocks_format = Some("hex".to_owned()); + conf.arg_export_blocks_file = Some("blockchain.json".to_owned()); - let conf: Cmd = conf.into_command().unwrap().cmd; + let conf = Configuration { + args: conf, + }; + + let conf: Cmd = conf.into_command().unwrap().cmd; let cmd_arg = Cmd::Blockchain(BlockchainCmd::Export(ExportBlockchain { spec: Default::default(), @@ -301,25 +301,25 @@ mod test_configuration{ check_seal: true, max_round_blocks_to_import: 12, })); - assert_eq!(conf, cmd_arg); - } + assert_eq!(conf, cmd_arg); + } #[test] fn test_command_signer_new_token() { - let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); + conf.from_cli(raw, user_defaults, fallback).unwrap(); - conf.cmd_signer = true; - conf.cmd_signer_new_token = true; + conf.cmd_signer = true; + conf.cmd_signer_new_token = true; - let conf = Configuration { - args: conf, - }; + let conf = Configuration { + args: conf, + }; - let conf: Cmd = conf.into_command().unwrap().cmd; + let conf: Cmd = conf.into_command().unwrap().cmd; let expected = Directories::default().signer; - let cmd_arg = Cmd::SignerToken(WsConfiguration { + let cmd_arg = Cmd::SignerToken(WsConfiguration { enabled: true, interface: "127.0.0.1".into(), port: 8546, @@ -333,126 +333,126 @@ mod test_configuration{ color: !cfg!(windows), mode: None, file: None, - } ); - - assert_eq!(conf, cmd_arg); - } - - #[test] + } ); + + assert_eq!(conf, cmd_arg); + } + + #[test] fn test_ws_max_connections() { - let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); + conf.from_cli(raw, user_defaults, fallback).unwrap(); - conf.arg_ws_max_connections = 1; + conf.arg_ws_max_connections = 1; - let conf = Configuration { - args: conf, - }; + let conf = Configuration { + args: conf, + }; assert_eq!(conf.ws_config().unwrap(), WsConfiguration { max_connections: 1, ..Default::default() }); - } - - #[test] - fn test_run_cmd() { - let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); - - let conf = Configuration { - args: conf, - }; - - let conf = conf.into_command().unwrap().cmd; - - let mut expected = RunCmd { - allow_missing_blocks: false, - cache_config: Default::default(), - dirs: Default::default(), - spec: Default::default(), - pruning: Default::default(), - pruning_history: 128, - pruning_memory: 64, - daemon: None, - logger_config: Default::default(), - miner_options: Default::default(), - gas_price_percentile: 50, - poll_lifetime: 60, - ws_conf: Default::default(), - http_conf: Default::default(), - ipc_conf: Default::default(), - net_conf: default_network_config(), - network_id: None, - warp_sync: true, - warp_barrier: None, - acc_conf: Default::default(), - gas_pricer_conf: Default::default(), - miner_extras: Default::default(), - update_policy: UpdatePolicy { - enable_downloading: true, - require_consensus: true, - filter: UpdateFilter::Critical, - track: ReleaseTrack::Unknown, - path: default_hypervisor_path(), - max_size: 128 * 1024 * 1024, - max_delay: 100, - frequency: 20, - }, - mode: Default::default(), - tracing: Default::default(), - compaction: Default::default(), - geth_compatibility: false, - experimental_rpcs: false, - net_settings: Default::default(), - secretstore_conf: Default::default(), - private_provider_conf: Default::default(), - private_encryptor_conf: Default::default(), - private_tx_enabled: false, - name: "".into(), - custom_bootnodes: false, - fat_db: Default::default(), - snapshot_conf: Default::default(), - stratum: None, - check_seal: true, - download_old_blocks: true, - verifier_settings: Default::default(), - serve_light: true, - light: false, - no_hardcoded_sync: false, - no_persistent_txqueue: false, - max_round_blocks_to_import: 12, - on_demand_response_time_window: None, - on_demand_request_backoff_start: None, - on_demand_request_backoff_max: None, - on_demand_request_backoff_rounds_max: None, - on_demand_request_consecutive_failures: None, - }; - expected.secretstore_conf.enabled = cfg!(feature = "secretstore"); - expected.secretstore_conf.http_enabled = cfg!(feature = "secretstore"); - - assert_eq!(conf, Cmd::Run(expected)); - } + } + + #[test] + fn test_run_cmd() { + let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); + conf.from_cli(raw, user_defaults, fallback).unwrap(); + + let conf = Configuration { + args: conf, + }; + + let conf = conf.into_command().unwrap().cmd; + + let mut expected = RunCmd { + allow_missing_blocks: false, + cache_config: Default::default(), + dirs: Default::default(), + spec: Default::default(), + pruning: Default::default(), + pruning_history: 128, + pruning_memory: 64, + daemon: None, + logger_config: Default::default(), + miner_options: Default::default(), + gas_price_percentile: 50, + poll_lifetime: 60, + ws_conf: Default::default(), + http_conf: Default::default(), + ipc_conf: Default::default(), + net_conf: default_network_config(), + network_id: None, + warp_sync: true, + warp_barrier: None, + acc_conf: Default::default(), + gas_pricer_conf: Default::default(), + miner_extras: Default::default(), + update_policy: UpdatePolicy { + enable_downloading: true, + require_consensus: true, + filter: UpdateFilter::Critical, + track: ReleaseTrack::Unknown, + path: default_hypervisor_path(), + max_size: 128 * 1024 * 1024, + max_delay: 100, + frequency: 20, + }, + mode: Default::default(), + tracing: Default::default(), + compaction: Default::default(), + geth_compatibility: false, + experimental_rpcs: false, + net_settings: Default::default(), + secretstore_conf: Default::default(), + private_provider_conf: Default::default(), + private_encryptor_conf: Default::default(), + private_tx_enabled: false, + name: "".into(), + custom_bootnodes: false, + fat_db: Default::default(), + snapshot_conf: Default::default(), + stratum: None, + check_seal: true, + download_old_blocks: true, + verifier_settings: Default::default(), + serve_light: true, + light: false, + no_hardcoded_sync: false, + no_persistent_txqueue: false, + max_round_blocks_to_import: 12, + on_demand_response_time_window: None, + on_demand_request_backoff_start: None, + on_demand_request_backoff_max: None, + on_demand_request_backoff_rounds_max: None, + on_demand_request_consecutive_failures: None, + }; + expected.secretstore_conf.enabled = cfg!(feature = "secretstore"); + expected.secretstore_conf.http_enabled = cfg!(feature = "secretstore"); + + assert_eq!(conf, Cmd::Run(expected)); + } #[test] fn should_parse_mining_options() { // given let mut mining_options = MinerOptions::default(); - // setting up 2 separate configs - let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf0.from_cli(raw, user_defaults, fallback).unwrap(); // default config + // setting up 2 separate configs + let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); + conf0.from_cli(raw, user_defaults, fallback).unwrap(); // default config - let mut conf2 = conf0.clone(); - conf2.arg_tx_queue_strategy = "gas_price".to_owned(); // modified config + let mut conf2 = conf0.clone(); + conf2.arg_tx_queue_strategy = "gas_price".to_owned(); // modified config - let conf0 = Configuration { - args: conf0, - }; + let conf0 = Configuration { + args: conf0, + }; - let conf2 = Configuration { - args: conf2, - }; + let conf2 = Configuration { + args: conf2, + }; // then assert_eq!(conf0.miner_options().unwrap(), mining_options); @@ -462,32 +462,32 @@ mod test_configuration{ #[test] fn should_fail_on_force_reseal_and_reseal_min_period() { - let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); + conf.from_cli(raw, user_defaults, fallback).unwrap(); - conf.arg_chain = "dev".to_owned(); - conf.flag_force_sealing = true; - conf.arg_reseal_min_period = 0; + conf.arg_chain = "dev".to_owned(); + conf.flag_force_sealing = true; + conf.arg_reseal_min_period = 0; - let conf = Configuration { - args: conf, - }; + let conf = Configuration { + args: conf, + }; assert!(conf.miner_options().is_err()); } - #[test] + #[test] fn should_parse_updater_options() { - let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf0.from_cli(raw, user_defaults, fallback).unwrap(); - - conf0.arg_auto_update = "all".to_owned(); - conf0.arg_auto_update_delay = 300; - conf0.flag_no_consensus = true; - - let conf0 = Configuration { - args: conf0, - }; + let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); + conf0.from_cli(raw, user_defaults, fallback).unwrap(); + + conf0.arg_auto_update = "all".to_owned(); + conf0.arg_auto_update_delay = 300; + conf0.flag_no_consensus = true; + + let conf0 = Configuration { + args: conf0, + }; assert_eq!(conf0.update_policy().unwrap(), UpdatePolicy { enable_downloading: true, @@ -504,14 +504,14 @@ mod test_configuration{ #[test] fn should_parse_network_settings() { let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf0.from_cli(raw, user_defaults, fallback).unwrap(); - - conf0.arg_identity = "testname".to_owned(); - conf0.arg_chain = "goerli".to_owned(); - - let conf0 = Configuration { - args: conf0, - }; + conf0.from_cli(raw, user_defaults, fallback).unwrap(); + + conf0.arg_identity = "testname".to_owned(); + conf0.arg_chain = "goerli".to_owned(); + + let conf0 = Configuration { + args: conf0, + }; // then assert_eq!(conf0.network_settings(), Ok(NetworkSettings { @@ -535,68 +535,68 @@ mod test_configuration{ assert_eq!(net.rpc_port, 8000); assert_eq!(conf.rpc_cors(), None); assert_eq!(conf.rpc_apis(), "web3,eth".to_owned()); - } - - let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf0.from_cli(raw, user_defaults, fallback).unwrap(); - - let conf2 = conf0.clone(); - - conf0.arg_jsonrpc_port = 8000; - conf0.arg_jsonrpc_interface = "all".to_owned(); - conf0.arg_jsonrpc_cors = "*".to_owned(); - conf0.arg_jsonrpc_apis = "web3,eth".to_owned(); - - let conf0 = Configuration { - args: conf0, - }; + } + + let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); + conf0.from_cli(raw, user_defaults, fallback).unwrap(); + + let conf2 = conf0.clone(); + + conf0.arg_jsonrpc_port = 8000; + conf0.arg_jsonrpc_interface = "all".to_owned(); + conf0.arg_jsonrpc_cors = "*".to_owned(); + conf0.arg_jsonrpc_apis = "web3,eth".to_owned(); + + let conf0 = Configuration { + args: conf0, + }; assert(conf0); } #[test] fn should_parse_rpc_hosts() { - // given - let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf0.from_cli(raw, user_defaults, fallback).unwrap(); - - let mut conf1 = conf0.clone(); - let mut conf2 = conf0.clone(); - let mut conf3 = conf0.clone(); - - conf1.arg_jsonrpc_hosts = "none".to_owned(); - conf2.arg_jsonrpc_hosts = "all".to_owned(); - conf3.arg_jsonrpc_hosts = "parity.io,something.io".to_owned(); - - let conf0 = Configuration { - args: conf0, - }; - - let conf1 = Configuration { - args: conf1, - }; - let conf2 = Configuration { - args: conf2, - }; - let conf3 = Configuration { - args: conf3, - }; + // given + let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); + conf0.from_cli(raw, user_defaults, fallback).unwrap(); + + let mut conf1 = conf0.clone(); + let mut conf2 = conf0.clone(); + let mut conf3 = conf0.clone(); + + conf1.arg_jsonrpc_hosts = "none".to_owned(); + conf2.arg_jsonrpc_hosts = "all".to_owned(); + conf3.arg_jsonrpc_hosts = "parity.io,something.io".to_owned(); + + let conf0 = Configuration { + args: conf0, + }; + + let conf1 = Configuration { + args: conf1, + }; + let conf2 = Configuration { + args: conf2, + }; + let conf3 = Configuration { + args: conf3, + }; // then assert_eq!(conf0.rpc_hosts(), Some(Vec::new())); assert_eq!(conf1.rpc_hosts(), Some(Vec::new())); assert_eq!(conf2.rpc_hosts(), None); assert_eq!(conf3.rpc_hosts(), Some(vec!["parity.io".into(), "something.io".into()])); - } + } #[test] fn should_respect_only_min_peers_and_default() { - let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); + conf.from_cli(raw, user_defaults, fallback).unwrap(); - conf.arg_min_peers = Some(5); + conf.arg_min_peers = Some(5); - let conf = Configuration{ - args: conf, - }; + let conf = Configuration{ + args: conf, + }; match conf.into_command().unwrap().cmd { Cmd::Run(c) => { @@ -609,14 +609,14 @@ mod test_configuration{ #[test] fn should_respect_only_min_peers_and_greater_than_default() { - let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); + conf.from_cli(raw, user_defaults, fallback).unwrap(); - conf.arg_min_peers = Some(500); + conf.arg_min_peers = Some(500); - let conf = Configuration{ - args: conf, - }; + let conf = Configuration{ + args: conf, + }; match conf.into_command().unwrap().cmd { Cmd::Run(c) => { @@ -629,44 +629,44 @@ mod test_configuration{ #[test] fn should_parse_secretstore_cors() { - let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf0.from_cli(raw, user_defaults, fallback).unwrap(); + let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); + conf0.from_cli(raw, user_defaults, fallback).unwrap(); - let mut conf1 = conf0.clone(); - let mut conf2 = conf0.clone(); + let mut conf1 = conf0.clone(); + let mut conf2 = conf0.clone(); - conf1.arg_secretstore_http_cors = "*".to_owned(); - conf2.arg_secretstore_http_cors = "http://parity.io,http://something.io".to_owned(); + conf1.arg_secretstore_http_cors = "*".to_owned(); + conf2.arg_secretstore_http_cors = "http://parity.io,http://something.io".to_owned(); - let conf0 = Configuration{ - args: conf0, - }; + let conf0 = Configuration{ + args: conf0, + }; - let conf1 = Configuration{ - args: conf1, - }; + let conf1 = Configuration{ + args: conf1, + }; - let conf2 = Configuration{ - args: conf2, - }; + let conf2 = Configuration{ + args: conf2, + }; // then assert_eq!(conf0.secretstore_cors(), Some(vec![])); assert_eq!(conf1.secretstore_cors(), None); assert_eq!(conf2.secretstore_cors(), Some(vec!["http://parity.io".into(),"http://something.io".into()])); - } + } #[test] fn ensures_sane_http_settings() { - let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf0.from_cli(raw, user_defaults, fallback).unwrap(); + let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); + conf0.from_cli(raw, user_defaults, fallback).unwrap(); - conf0.arg_jsonrpc_server_threads = Some(0); - conf0.arg_jsonrpc_max_payload = Some(0); + conf0.arg_jsonrpc_server_threads = Some(0); + conf0.arg_jsonrpc_max_payload = Some(0); - let conf0 = Configuration { - args: conf0, - }; + let conf0 = Configuration { + args: conf0, + }; // then things are adjusted to Just Work. let http_conf = conf0.http_config().unwrap(); @@ -677,28 +677,28 @@ mod test_configuration{ #[test] fn jsonrpc_threading_defaults() { - let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); - + let (mut conf, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); + conf.from_cli(raw, user_defaults, fallback).unwrap(); + assert_eq!(conf.arg_jsonrpc_server_threads, Some(4)); - } + } #[test] fn test_dev_preset() { - let raw: ArgsInput = Default::default(); - let mut conf: Args = Default::default(); + let raw: ArgsInput = Default::default(); + let mut conf: Args = Default::default(); - let (user_defaults, fallback) = Args::generate_default_configuration( - "config_dev.toml", - "config_default.toml" - ).unwrap(); + let (user_defaults, fallback) = Args::generate_default_configuration( + "config_dev.toml", + "config_default.toml" + ).unwrap(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + conf.from_cli(raw, user_defaults, fallback).unwrap(); - let conf = Configuration { - args: conf, - }; + let conf = Configuration { + args: conf, + }; match conf.into_command().unwrap().cmd { Cmd::Run(c) => { @@ -713,19 +713,19 @@ mod test_configuration{ #[test] fn test_mining_preset() { - let raw: ArgsInput = Default::default(); - let mut conf: Args = Default::default(); + let raw: ArgsInput = Default::default(); + let mut conf: Args = Default::default(); - let (user_defaults, fallback) = Args::generate_default_configuration( - "config_mining.toml", - "config_default.toml" - ).unwrap(); + let (user_defaults, fallback) = Args::generate_default_configuration( + "config_mining.toml", + "config_default.toml" + ).unwrap(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + conf.from_cli(raw, user_defaults, fallback).unwrap(); - let conf = Configuration { - args: conf, - }; + let conf = Configuration { + args: conf, + }; match conf.into_command().unwrap().cmd { Cmd::Run(c) => { @@ -746,19 +746,19 @@ mod test_configuration{ #[test] fn test_non_standard_ports_preset() { - let raw: ArgsInput = Default::default(); - let mut conf: Args = Default::default(); + let raw: ArgsInput = Default::default(); + let mut conf: Args = Default::default(); - let (user_defaults, fallback) = Args::generate_default_configuration( - "config_non_standard_ports.toml", - "config_default.toml" - ).unwrap(); + let (user_defaults, fallback) = Args::generate_default_configuration( + "config_non_standard_ports.toml", + "config_default.toml" + ).unwrap(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + conf.from_cli(raw, user_defaults, fallback).unwrap(); - let conf = Configuration { - args: conf, - }; + let conf = Configuration { + args: conf, + }; match conf.into_command().unwrap().cmd { Cmd::Run(c) => { @@ -772,19 +772,19 @@ mod test_configuration{ #[test] fn test_insecure_preset() { - let raw: ArgsInput = Default::default(); - let mut conf: Args = Default::default(); + let raw: ArgsInput = Default::default(); + let mut conf: Args = Default::default(); - let (user_defaults, fallback) = Args::generate_default_configuration( - "config_insecure.toml", - "config_default.toml" - ).unwrap(); + let (user_defaults, fallback) = Args::generate_default_configuration( + "config_insecure.toml", + "config_default.toml" + ).unwrap(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + conf.from_cli(raw, user_defaults, fallback).unwrap(); - let conf = Configuration { - args: conf, - }; + let conf = Configuration { + args: conf, + }; match conf.into_command().unwrap().cmd { Cmd::Run(c) => { @@ -804,19 +804,19 @@ mod test_configuration{ #[test] fn test_dev_insecure_preset() { - let raw: ArgsInput = Default::default(); - let mut conf: Args = Default::default(); + let raw: ArgsInput = Default::default(); + let mut conf: Args = Default::default(); - let (user_defaults, fallback) = Args::generate_default_configuration( - "config_dev_insecure.toml", - "config_default.toml" - ).unwrap(); + let (user_defaults, fallback) = Args::generate_default_configuration( + "config_dev_insecure.toml", + "config_default.toml" + ).unwrap(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + conf.from_cli(raw, user_defaults, fallback).unwrap(); - let conf = Configuration { - args: conf, - }; + let conf = Configuration { + args: conf, + }; match conf.into_command().unwrap().cmd { Cmd::Run(c) => { @@ -838,22 +838,22 @@ mod test_configuration{ #[test] fn test_override_preset() { - - let mut raw: ArgsInput = Default::default(); - let mut conf: Args = Default::default(); - raw.globals.networking.min_peers = Some(99); + let mut raw: ArgsInput = Default::default(); + let mut conf: Args = Default::default(); + + raw.globals.networking.min_peers = Some(99); - let (user_defaults, fallback) = Args::generate_default_configuration( - "config_mining.toml", - "config_default.toml" - ).unwrap(); + let (user_defaults, fallback) = Args::generate_default_configuration( + "config_mining.toml", + "config_default.toml" + ).unwrap(); - conf.from_cli(raw, user_defaults, fallback).unwrap(); + conf.from_cli(raw, user_defaults, fallback).unwrap(); - let conf = Configuration { - args: conf, - }; + let conf = Configuration { + args: conf, + }; match conf.into_command().unwrap().cmd { Cmd::Run(c) => { @@ -865,14 +865,14 @@ mod test_configuration{ #[test] fn test_identity_arg() { - let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf0.from_cli(raw, user_defaults, fallback).unwrap(); + let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); + conf0.from_cli(raw, user_defaults, fallback).unwrap(); - conf0.arg_identity = "Somebody".to_owned(); + conf0.arg_identity = "Somebody".to_owned(); - let conf0 = Configuration { - args: conf0 - }; + let conf0 = Configuration { + args: conf0 + }; match conf0.into_command().unwrap().cmd { Cmd::Run(c) => { @@ -885,25 +885,25 @@ mod test_configuration{ #[test] fn should_apply_ports_shift() { - // give - let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf0.from_cli(raw, user_defaults, fallback).unwrap(); + // give + let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); + conf0.from_cli(raw, user_defaults, fallback).unwrap(); - let mut conf1 = conf0.clone(); + let mut conf1 = conf0.clone(); - conf0.arg_ports_shift = 1; - conf0.flag_stratum = true; + conf0.arg_ports_shift = 1; + conf0.flag_stratum = true; - conf1.arg_ports_shift = 1; - conf1.arg_jsonrpc_port = 8544; + conf1.arg_ports_shift = 1; + conf1.arg_jsonrpc_port = 8544; - let conf0 = Configuration { - args: conf0 - }; + let conf0 = Configuration { + args: conf0 + }; - let conf1 = Configuration { - args: conf1 - }; + let conf1 = Configuration { + args: conf1 + }; assert_eq!(conf0.net_addresses().unwrap().0.port(), 30304); assert_eq!(conf0.network_settings().unwrap().network_port, 30304); @@ -926,39 +926,39 @@ mod test_configuration{ #[test] fn should_resolve_external_nat_hosts() { - let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf0.from_cli(raw, user_defaults, fallback).unwrap(); - - let mut conf1 = conf0.clone(); - let mut conf2 = conf0.clone(); - let mut conf3 = conf0.clone(); - let mut conf4 = conf0.clone(); - - conf0.arg_nat = "extip:1.1.1.1".to_owned(); - - let conf0 = Configuration { - args: conf0 - }; - - conf1.arg_nat = "extip:192.168.1.1:123".to_owned(); - let conf1 = Configuration { - args: conf1 - }; - - conf2.arg_nat = "extip:ethereum.org".to_owned(); - let conf2 = Configuration { - args: conf2 - }; - - conf3.arg_nat = "extip:ethereum.org:whatever bla bla 123".to_owned(); - let conf3 = Configuration { - args: conf3 - }; - - conf4.arg_nat = "extip:blabla".to_owned(); - let conf4 = Configuration { - args: conf4 - }; + let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); + conf0.from_cli(raw, user_defaults, fallback).unwrap(); + + let mut conf1 = conf0.clone(); + let mut conf2 = conf0.clone(); + let mut conf3 = conf0.clone(); + let mut conf4 = conf0.clone(); + + conf0.arg_nat = "extip:1.1.1.1".to_owned(); + + let conf0 = Configuration { + args: conf0 + }; + + conf1.arg_nat = "extip:192.168.1.1:123".to_owned(); + let conf1 = Configuration { + args: conf1 + }; + + conf2.arg_nat = "extip:ethereum.org".to_owned(); + let conf2 = Configuration { + args: conf2 + }; + + conf3.arg_nat = "extip:ethereum.org:whatever bla bla 123".to_owned(); + let conf3 = Configuration { + args: conf3 + }; + + conf4.arg_nat = "extip:blabla".to_owned(); + let conf4 = Configuration { + args: conf4 + }; // Ip works assert_eq!(conf0.net_addresses().unwrap().1.unwrap().ip().to_string(), "1.1.1.1"); assert_eq!(conf0.net_addresses().unwrap().1.unwrap().port(), 30303); @@ -981,14 +981,14 @@ mod test_configuration{ #[test] fn should_expose_all_servers() { - let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf0.from_cli(raw, user_defaults, fallback).unwrap(); + let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); + conf0.from_cli(raw, user_defaults, fallback).unwrap(); - conf0.flag_unsafe_expose = true; + conf0.flag_unsafe_expose = true; - let conf0 = Configuration { - args: conf0 - }; + let conf0 = Configuration { + args: conf0 + }; assert_eq!(&conf0.network_settings().unwrap().rpc_interface, "0.0.0.0"); assert_eq!(&conf0.http_config().unwrap().interface, "0.0.0.0"); @@ -1003,44 +1003,44 @@ mod test_configuration{ #[test] fn allow_ips() { - let (mut all, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - all.from_cli(raw, user_defaults, fallback).unwrap(); - - let mut private = all.clone(); - let mut block_custom = all.clone(); - let mut combo = all.clone(); - let mut ipv6_custom_public = all.clone(); - let mut ipv6_custom_private = all.clone(); - - all.arg_allow_ips = "all".to_owned(); - let all = Configuration { - args: all - }; - - private.arg_allow_ips = "private".to_owned(); - let private = Configuration { - args: private - }; - - block_custom.arg_allow_ips = "-10.0.0.0/8".to_owned(); - let block_custom = Configuration { - args: block_custom - }; - - combo.arg_allow_ips = "public 10.0.0.0/8 -1.0.0.0/8".to_owned(); - let combo = Configuration { - args: combo - }; - - ipv6_custom_public.arg_allow_ips = "public fc00::/7".to_owned(); - let ipv6_custom_public = Configuration { - args: ipv6_custom_public - }; - - ipv6_custom_private.arg_allow_ips = "private -fc00::/7".to_owned(); - let ipv6_custom_private = Configuration { - args: ipv6_custom_private - }; + let (mut all, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); + all.from_cli(raw, user_defaults, fallback).unwrap(); + + let mut private = all.clone(); + let mut block_custom = all.clone(); + let mut combo = all.clone(); + let mut ipv6_custom_public = all.clone(); + let mut ipv6_custom_private = all.clone(); + + all.arg_allow_ips = "all".to_owned(); + let all = Configuration { + args: all + }; + + private.arg_allow_ips = "private".to_owned(); + let private = Configuration { + args: private + }; + + block_custom.arg_allow_ips = "-10.0.0.0/8".to_owned(); + let block_custom = Configuration { + args: block_custom + }; + + combo.arg_allow_ips = "public 10.0.0.0/8 -1.0.0.0/8".to_owned(); + let combo = Configuration { + args: combo + }; + + ipv6_custom_public.arg_allow_ips = "public fc00::/7".to_owned(); + let ipv6_custom_public = Configuration { + args: ipv6_custom_public + }; + + ipv6_custom_private.arg_allow_ips = "private -fc00::/7".to_owned(); + let ipv6_custom_private = Configuration { + args: ipv6_custom_private + }; assert_eq!(all.ip_filter().unwrap(), IpFilter { predefined: AllowIP::All, @@ -1081,21 +1081,21 @@ mod test_configuration{ #[test] fn should_use_correct_cache_path_if_base_is_set() { - use std::path; - - let (mut std, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - std.from_cli(raw, user_defaults, fallback).unwrap(); + use std::path; - let mut base = std.clone(); - base.arg_base_path = Some("/test".to_owned()); + let (mut std, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); + std.from_cli(raw, user_defaults, fallback).unwrap(); - let std = Configuration { - args: std - }; + let mut base = std.clone(); + base.arg_base_path = Some("/test".to_owned()); - let base = Configuration { - args: base - }; + let std = Configuration { + args: std + }; + + let base = Configuration { + args: base + }; let base_path = ::dir::default_data_path(); let local_path = ::dir::default_local_path(); @@ -1106,14 +1106,14 @@ mod test_configuration{ #[test] fn should_respect_only_max_peers_and_default() { - let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf0.from_cli(raw, user_defaults, fallback).unwrap(); + let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); + conf0.from_cli(raw, user_defaults, fallback).unwrap(); - conf0.arg_max_peers = Some(50); + conf0.arg_max_peers = Some(50); - let conf0 = Configuration { - args: conf0 - }; + let conf0 = Configuration { + args: conf0 + }; match conf0.into_command().unwrap().cmd { Cmd::Run(c) => { @@ -1126,14 +1126,14 @@ mod test_configuration{ #[test] fn should_respect_only_max_peers_less_than_default() { - let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); - conf0.from_cli(raw, user_defaults, fallback).unwrap(); + let (mut conf0, raw, user_defaults, fallback) = intialize_with_out_of_the_box_defaults(); + conf0.from_cli(raw, user_defaults, fallback).unwrap(); - conf0.arg_max_peers = Some(5); + conf0.arg_max_peers = Some(5); - let conf0 = Configuration { - args: conf0 - }; + let conf0 = Configuration { + args: conf0 + }; match conf0.into_command().unwrap().cmd { Cmd::Run(c) => {