diff --git a/applications/minotari_console_wallet/src/main.rs b/applications/minotari_console_wallet/src/main.rs index 3ee72ce7e4..2b84467eef 100644 --- a/applications/minotari_console_wallet/src/main.rs +++ b/applications/minotari_console_wallet/src/main.rs @@ -70,7 +70,7 @@ fn main() { fn main_inner() -> Result<(), ExitError> { let cli = Cli::parse(); - let cfg = load_configuration(cli.common.config_path(), true, &cli)?; + let cfg = load_configuration(cli.common.config_path(), true, cli.non_interactive_mode, &cli)?; initialize_logging( &cli.common.log_config_path("wallet"), &cli.common.get_base_path(), diff --git a/applications/minotari_merge_mining_proxy/src/cli.rs b/applications/minotari_merge_mining_proxy/src/cli.rs index cb3dc9bd3a..f2cf7faa04 100644 --- a/applications/minotari_merge_mining_proxy/src/cli.rs +++ b/applications/minotari_merge_mining_proxy/src/cli.rs @@ -30,6 +30,8 @@ use tari_common::configuration::{ConfigOverrideProvider, Network}; pub struct Cli { #[clap(flatten)] pub common: CommonCliArgs, + #[clap(short, long, alias = "non-interactive", env = "TARI_NON_INTERACTIVE")] + pub non_interactive_mode: bool, } impl ConfigOverrideProvider for Cli { diff --git a/applications/minotari_merge_mining_proxy/src/run_merge_miner.rs b/applications/minotari_merge_mining_proxy/src/run_merge_miner.rs index d310fe8621..676e96bf6a 100644 --- a/applications/minotari_merge_mining_proxy/src/run_merge_miner.rs +++ b/applications/minotari_merge_mining_proxy/src/run_merge_miner.rs @@ -52,7 +52,7 @@ const LOG_TARGET: &str = "minotari_mm_proxy::proxy"; pub async fn start_merge_miner(cli: Cli) -> Result<(), anyhow::Error> { let config_path = cli.common.config_path(); - let cfg = load_configuration(&config_path, true, &cli)?; + let cfg = load_configuration(&config_path, true, cli.non_interactive_mode, &cli)?; let mut config = MergeMiningProxyConfig::load_from(&cfg)?; config.set_base_path(cli.common.get_base_path()); diff --git a/applications/minotari_miner/src/cli.rs b/applications/minotari_miner/src/cli.rs index 9cffc3ef99..d1c976eff1 100644 --- a/applications/minotari_miner/src/cli.rs +++ b/applications/minotari_miner/src/cli.rs @@ -37,6 +37,8 @@ pub struct Cli { pub miner_min_diff: Option, #[clap(long, alias = "max-difficulty")] pub miner_max_diff: Option, + #[clap(short, long, alias = "non-interactive", env = "TARI_NON_INTERACTIVE")] + pub non_interactive_mode: bool, } impl ConfigOverrideProvider for Cli { diff --git a/applications/minotari_miner/src/run_miner.rs b/applications/minotari_miner/src/run_miner.rs index cb9abf9844..abe74eadca 100644 --- a/applications/minotari_miner/src/run_miner.rs +++ b/applications/minotari_miner/src/run_miner.rs @@ -72,7 +72,7 @@ pub const LOG_TARGET_FILE: &str = "minotari::logging::miner::main"; #[allow(clippy::too_many_lines)] pub async fn start_miner(cli: Cli) -> Result<(), ExitError> { let config_path = cli.common.config_path(); - let cfg = load_configuration(config_path.as_path(), true, &cli)?; + let cfg = load_configuration(config_path.as_path(), true, cli.non_interactive_mode, &cli)?; let mut config = MinerConfig::load_from(&cfg).expect("Failed to load config"); config.set_base_path(cli.common.get_base_path()); diff --git a/applications/minotari_node/src/main.rs b/applications/minotari_node/src/main.rs index 069e1bca1b..e02f2ac9aa 100644 --- a/applications/minotari_node/src/main.rs +++ b/applications/minotari_node/src/main.rs @@ -104,7 +104,7 @@ fn main() { fn main_inner() -> Result<(), ExitError> { let cli = Cli::parse(); let config_path = cli.common.config_path(); - let cfg = load_configuration(config_path, true, &cli)?; + let cfg = load_configuration(config_path, true, cli.non_interactive_mode, &cli)?; if cli.profile_with_tokio_console { console_subscriber::init(); diff --git a/common/config/presets/c_base_node_a.toml b/common/config/presets/c_base_node_a.toml index 3055064990..daa4fd5479 100644 --- a/common/config/presets/c_base_node_a.toml +++ b/common/config/presets/c_base_node_a.toml @@ -9,10 +9,6 @@ # help maintain the security of the Minotari token and are the surest way to preserve your privacy and be 100% sure that # no-one is cheating you out of your money. -[dibbler.base_node] -# A path to the file that stores your node identity and secret key (default = "config/base_node_id.json") -identity_file = "config/base_node_id_dibbler.json" - [igor.base_node] # A path to the file that stores your node identity and secret key (default = "config/base_node_id.json") identity_file = "config/base_node_id_igor.json" @@ -28,16 +24,3 @@ identity_file = "config/base_node_id_stagenet.json" [nextnet.base_node] # A path to the file that stores your node identity and secret key (default = "config/base_node_id.json") identity_file = "config/base_node_id_nextnet.json" - -[base_node] -# Set to false to disable the base node GRPC server (default = true) -#grpc_enabled = true - -# The socket to expose for the gRPC base node server (default = "/ip4/127.0.0.1/tcp/18142") -#grpc_address = "/ip4/127.0.0.1/tcp/18142" - -# gRPC authentication method (default = "none") -#grpc_authentication = { username = "admin", password = "xxxx" } - -# Use gRPC over TLS (default = false) -#grpc_tls_enabled = false diff --git a/common/config/presets/c_base_node_b_mining_deny_methods.toml b/common/config/presets/c_base_node_b_mining_deny_methods.toml index 3412254f97..f0f1d5fcf2 100644 --- a/common/config/presets/c_base_node_b_mining_deny_methods.toml +++ b/common/config/presets/c_base_node_b_mining_deny_methods.toml @@ -1,4 +1,17 @@ +[base_node] +# Set to false to disable the base node GRPC server (default = true) +grpc_enabled = true + +# The socket to expose for the gRPC base node server (default = "/ip4/127.0.0.1/tcp/18142") +#grpc_address = "/ip4/127.0.0.1/tcp/18142" + +# gRPC authentication method (default = "none") +#grpc_authentication = { username = "admin", password = "xxxx" } + +# Use gRPC over TLS (default = false) +#grpc_tls_enabled = false + # Uncomment all gRPC server methods that should be denied default (only active when `grpc_enabled = true`) grpc_server_deny_methods = [ "get_version", diff --git a/common/config/presets/c_base_node_b_non_mining_deny_methods.toml b/common/config/presets/c_base_node_b_non_mining_deny_methods.toml index 4da2d31402..0dfcc8d0f6 100644 --- a/common/config/presets/c_base_node_b_non_mining_deny_methods.toml +++ b/common/config/presets/c_base_node_b_non_mining_deny_methods.toml @@ -1,3 +1,17 @@ + +[base_node] +# Set to false to disable the base node GRPC server (default = true) +grpc_enabled = false + +# The socket to expose for the gRPC base node server (default = "/ip4/127.0.0.1/tcp/18142") +#grpc_address = "/ip4/127.0.0.1/tcp/18142" + +# gRPC authentication method (default = "none") +#grpc_authentication = { username = "admin", password = "xxxx" } + +# Use gRPC over TLS (default = false) +#grpc_tls_enabled = false + # Uncomment all gRPC server methods that should be denied default (only active when `grpc_enabled = true`) grpc_server_deny_methods = [ "get_version", @@ -7,31 +21,31 @@ grpc_server_deny_methods = [ "get_tip_info", "identify", "get_network_status", - #"list_headers", + "list_headers", "get_header_by_hash", "get_blocks", "get_block_timing", "get_constants", "get_block_size", "get_block_fees", - #"get_tokens_in_circulation", - #"get_network_difficulty", + "get_tokens_in_circulation", + "get_network_difficulty", "get_new_block_template", "get_new_block", "get_new_block_blob", - #"submit_block", - #"submit_block_blob", - #"submit_transaction", - #"search_kernels," - #"search_utxos", - #"fetch_matching_utxos", + "submit_block", + "submit_block_blob", + "submit_transaction", + "search_kernels", + "search_utxos", + "fetch_matching_utxos", "get_peers", "get_mempool_transactions", - #"transaction_state", - #"list_connected_peers", - #"get_mempool_stats", - #"get_active_validator_nodes", - #"get_shard_key", - #"get_template_registrations", - #"get_side_chain_utxos", + "transaction_state", + "list_connected_peers", + "get_mempool_stats", + "get_active_validator_nodes", + "get_shard_key", + "get_template_registrations", + "get_side_chain_utxos", ] diff --git a/common/src/configuration/utils.rs b/common/src/configuration/utils.rs index 64c0159f5c..e67d03ef7a 100644 --- a/common/src/configuration/utils.rs +++ b/common/src/configuration/utils.rs @@ -23,6 +23,7 @@ use crate::{ pub fn load_configuration, TOverride: ConfigOverrideProvider>( config_path: P, create_if_not_exists: bool, + non_interactive: bool, overrides: &TOverride, ) -> Result { debug!( @@ -31,7 +32,7 @@ pub fn load_configuration, TOverride: ConfigOverrideProvider>( config_path.as_ref().to_str().unwrap_or("[??]") ); if !config_path.as_ref().exists() && create_if_not_exists { - write_default_config_to(&config_path) + write_default_config_to(&config_path, non_interactive) .map_err(|io| ConfigError::new("Could not create default config", Some(io.to_string())))?; } let filename = config_path @@ -85,13 +86,17 @@ pub fn load_configuration, TOverride: ConfigOverrideProvider>( /// Installs a new configuration file template, copied from the application type's preset and written to the given path. /// Also includes the common configuration defined in `config/presets/common.toml`. -pub fn write_default_config_to>(path: P) -> Result<(), std::io::Error> { +pub fn write_default_config_to>(path: P, non_interactive: bool) -> Result<(), std::io::Error> { // Use the same config file so that all the settings are easier to find, and easier to // support users over chat channels - let mine = prompt( - "Node config does not exist.\nWould you like to mine (Y/n)?\nNOTE: this will enable gprc methods that can \ - leak private info on the node", - ); + let mine = if non_interactive { + false + } else { + prompt( + "Node config does not exist.\nWould you like to mine (Y/n)?\nNOTE: this will enable gprc methods that can \ + leak private info on the node", + ) + }; let base_node_deny_methods = if mine { include_str!("../../config/presets/c_base_node_b_mining_deny_methods.toml") } else { diff --git a/integration_tests/src/merge_mining_proxy.rs b/integration_tests/src/merge_mining_proxy.rs index a37f1c93b5..4beb8a8fb6 100644 --- a/integration_tests/src/merge_mining_proxy.rs +++ b/integration_tests/src/merge_mining_proxy.rs @@ -139,6 +139,7 @@ impl MergeMiningProxyProcess { ("merge_mining_proxy.stealth_payment".to_string(), stealth.to_string()), ], }, + non_interactive_mode: false, }; let rt = runtime::Builder::new_multi_thread().enable_all().build().unwrap(); if let Err(e) = rt.block_on(merge_miner(cli)) { diff --git a/integration_tests/src/miner.rs b/integration_tests/src/miner.rs index e973f567cb..8a13d94a23 100644 --- a/integration_tests/src/miner.rs +++ b/integration_tests/src/miner.rs @@ -138,6 +138,7 @@ impl MinerProcess { miner_max_blocks: blocks, miner_min_diff, miner_max_diff, + non_interactive_mode: false, }; run_miner(cli).await.unwrap(); }