diff --git a/masq/src/commands/setup_command.rs b/masq/src/commands/setup_command.rs index eaeede3c8..c7e0d6ef6 100644 --- a/masq/src/commands/setup_command.rs +++ b/masq/src/commands/setup_command.rs @@ -227,7 +227,7 @@ mod tests { "zero-hop".to_string(), "--log-level".to_string(), "--chain".to_string(), - "polygon-mainnet".to_string(), + DEFAULT_CHAIN.rec().literal_identifier.to_string(), "--scan-intervals".to_string(), "123|111|228".to_string(), "--scans".to_string(), diff --git a/masq/tests/chain_specific_directory_test_integration.rs b/masq/tests/chain_specific_directory_test_integration.rs index 39d782cfc..f2d5dd2e9 100644 --- a/masq/tests/chain_specific_directory_test_integration.rs +++ b/masq/tests/chain_specific_directory_test_integration.rs @@ -20,7 +20,7 @@ fn ensure_data_directory_has_specific_chain_directory_within_integration() { let mut masq_handle2 = MasqProcess::new().start_interactive(port, true); let mut stdin_handle = masq_handle2.create_stdin_handle(); - stdin_handle.type_command("setup --data-directory /home/booga/masqhome/polygon-mainnet"); + stdin_handle.type_command("setup --data-directory /home/booga/masqhome/base-mainnet"); thread::sleep(Duration::from_millis(1000)); @@ -29,12 +29,12 @@ fn ensure_data_directory_has_specific_chain_directory_within_integration() { let (stdout2, _stderr2, _exit_code2) = masq_handle2.stop(); let expected = format!( "{:29} {:64} {}", - "data-directory", "/home/booga/masqhome/polygon-mainnet", "Set" + "data-directory", "/home/booga/masqhome/base-mainnet", "Set" ); assert!( - !stdout.contains("MASQ/polygon-mainnet/MASQ/polygon-mainnet Default"), - "Wrong directory: duplication of /MASQ/polygon-mainnet when Default" + !stdout.contains("MASQ/base-mainnet/MASQ/base-mainnet Default"), + "Wrong directory: duplication of /MASQ/base-mainnet when Default" ); assert!( stdout2.contains(&expected), diff --git a/masq_lib/src/constants.rs b/masq_lib/src/constants.rs index 6beea5748..a67f86128 100644 --- a/masq_lib/src/constants.rs +++ b/masq_lib/src/constants.rs @@ -4,7 +4,7 @@ use crate::blockchains::chains::Chain; use crate::data_version::DataVersion; use const_format::concatcp; -pub const DEFAULT_CHAIN: Chain = Chain::PolyMainnet; +pub const DEFAULT_CHAIN: Chain = Chain::BaseMainnet; pub const CURRENT_SCHEMA_VERSION: usize = 11; pub const HIGHEST_RANDOM_CLANDESTINE_PORT: u16 = 9999; @@ -113,7 +113,7 @@ mod tests { #[test] fn constants_have_correct_values() { - assert_eq!(DEFAULT_CHAIN, Chain::PolyMainnet); + assert_eq!(DEFAULT_CHAIN, Chain::BaseMainnet); assert_eq!(HIGHEST_RANDOM_CLANDESTINE_PORT, 9999); assert_eq!(HTTP_PORT, 80); assert_eq!(TLS_PORT, 443); diff --git a/masq_lib/src/multi_config.rs b/masq_lib/src/multi_config.rs index 418dbf240..b1ce7a50a 100644 --- a/masq_lib/src/multi_config.rs +++ b/masq_lib/src/multi_config.rs @@ -3,7 +3,7 @@ use crate::shared_schema::{ConfiguratorError, ParamError}; #[allow(unused_imports)] use clap::{value_t, values_t}; -use clap::{App, ArgMatches}; +use clap::{App, ArgMatches, Error}; use regex::Regex; use std::collections::HashSet; use std::fmt::{Debug, Display, Formatter}; @@ -102,7 +102,7 @@ impl<'a> MultiConfig<'a> { } } - pub fn make_configurator_error(e: clap::Error) -> ConfiguratorError { + pub fn make_configurator_error(e: Error) -> ConfiguratorError { let invalid_value_patterns = vec![ ("Invalid value for '--(.*?) <.*>': (.*)$", 1, 2), ("error: (.*) isn't a valid value for '--(.*?) <.*>'", 2, 1), diff --git a/masq_lib/src/shared_schema.rs b/masq_lib/src/shared_schema.rs index 11dfb865f..b2858f3d3 100644 --- a/masq_lib/src/shared_schema.rs +++ b/masq_lib/src/shared_schema.rs @@ -13,9 +13,13 @@ use lazy_static::lazy_static; pub const BLOCKCHAIN_SERVICE_HELP: &str = "The Ethereum client you wish to use to provide Blockchain \ exit services from your MASQ Node (e.g. http://localhost:8545, \ - https://ropsten.infura.io/v3/YOUR-PROJECT-ID, https://mainnet.infura.io/v3/YOUR-PROJECT-ID), \ - https://base-mainnet.g.alchemy.com/v2/d66UL0lPrltmweEqVsv3opBSVI3wkL8I, \ - https://polygon-mainnet.infura.io/v3/YOUR-PROJECT-ID"; + https://ropsten.infura.io/v3/, https://mainnet.infura.io/v3/), \ + https://base-mainnet.g.alchemy.com/, https://polygon-mainnet.infura.io/v3/ \n \ + This argument is mandatory, to ensure that you will not be deliquency banned due to being unable to \ + pay your debts to MASQ network. If you are in a region where you have no access to blockchain \ + services, to create your own app, use one of following the public endpoints for Base Mainnet \ + (you need to specify `--chain base-mainnet` as the chain argument): \n\ + https://mainnet.base.org \nhttps://base.llamarpc.com \nhttps://1rpc.io/base \nhttps://base-rpc.publicnode.com"; pub const CHAIN_HELP: &str = "The blockchain network MASQ Node will configure itself to use. You must ensure the \ Ethereum client specified by --blockchain-service-url communicates with the same blockchain network."; @@ -733,9 +737,13 @@ mod tests { BLOCKCHAIN_SERVICE_HELP, "The Ethereum client you wish to use to provide Blockchain \ exit services from your MASQ Node (e.g. http://localhost:8545, \ - https://ropsten.infura.io/v3/YOUR-PROJECT-ID, https://mainnet.infura.io/v3/YOUR-PROJECT-ID), \ - https://base-mainnet.g.alchemy.com/v2/d66UL0lPrltmweEqVsv3opBSVI3wkL8I, \ - https://polygon-mainnet.infura.io/v3/YOUR-PROJECT-ID" + https://ropsten.infura.io/v3/, https://mainnet.infura.io/v3/), \ + https://base-mainnet.g.alchemy.com/, https://polygon-mainnet.infura.io/v3/ \n \ + This argument is mandatory, to ensure that you will not be deliquency banned due to being unable to \ + pay your debts to MASQ network. If you are in a region where you have no access to blockchain \ + services, to create your own app, use one of following the public endpoints for Base Mainnet \ + (you need to specify `--chain base-mainnet` as the chain argument): \n\ + https://mainnet.base.org \nhttps://base.llamarpc.com \nhttps://1rpc.io/base \nhttps://base-rpc.publicnode.com" ); assert_eq!( CHAIN_HELP, diff --git a/multinode_integration_tests/tests/bookkeeping_test.rs b/multinode_integration_tests/tests/bookkeeping_test.rs index 36d07bad6..161487b1f 100644 --- a/multinode_integration_tests/tests/bookkeeping_test.rs +++ b/multinode_integration_tests/tests/bookkeeping_test.rs @@ -9,6 +9,7 @@ use multinode_integration_tests_lib::utils::{payable_dao, receivable_dao}; use node_lib::accountant::db_access_objects::payable_dao::PayableAccount; use node_lib::accountant::db_access_objects::receivable_dao::ReceivableAccount; use node_lib::accountant::db_access_objects::utils::CustomQuery; +use node_lib::sub_lib::neighborhood::RatePack; use node_lib::sub_lib::wallet::Wallet; use std::collections::HashMap; use std::thread; @@ -116,6 +117,15 @@ pub fn start_real_node(cluster: &mut MASQNodeCluster, neighbor: NodeReference) - .neighbor(neighbor) .earning_wallet_info(make_earning_wallet_info(&index.to_string())) .chain(cluster.chain) + .rate_pack(RatePack { + //TODO in case we are going to test more scenarios with need of higher RatePack: + // create method in RatePack to return Default RatePack increased by some value or factor + // make sure there is a test for this method + routing_byte_rate: 2000000000, + routing_service_rate: 2000000000, + exit_byte_rate: 2000000000, + exit_service_rate: 2000000000, + }) .build(), ) } diff --git a/node/src/accountant/db_access_objects/receivable_dao.rs b/node/src/accountant/db_access_objects/receivable_dao.rs index 9b71a3939..284fc2113 100644 --- a/node/src/accountant/db_access_objects/receivable_dao.rs +++ b/node/src/accountant/db_access_objects/receivable_dao.rs @@ -253,9 +253,10 @@ impl ReceivableDao for ReceivableDaoReal { } fn custom_query(&self, custom_query: CustomQuery) -> Option> { - let variant_top = TopStmConfig{ + let variant_top = TopStmConfig { limit_clause: "limit :limit_count", - gwei_min_resolution_clause: "where (balance_high_b > 0) or ((balance_high_b = 0) and (balance_low_b >= 1000000000))", + gwei_min_resolution_clause: + "where (balance_high_b > 0) or ((balance_high_b = 0) and (balance_low_b >= 1000000000))", age_ordering_clause: "last_received_timestamp asc", }; let variant_range = RangeStmConfig { diff --git a/node/src/blockchain/blockchain_interface/blockchain_interface_web3/utils.rs b/node/src/blockchain/blockchain_interface/blockchain_interface_web3/utils.rs index 03ed4150b..7b352f65f 100644 --- a/node/src/blockchain/blockchain_interface/blockchain_interface_web3/utils.rs +++ b/node/src/blockchain/blockchain_interface/blockchain_interface_web3/utils.rs @@ -406,7 +406,7 @@ mod tests { result, HashAndAmount { hash: H256::from_str( - "94881436a9c89f48b01651ff491c69e97089daf71ab8cfb240243d7ecf9b38b2" + "1931f78f7ce5b43ffae11a2c22f18765508a2b2d4810e84744f53b10f7072c7f" ) .unwrap(), amount: account.balance_wei @@ -453,14 +453,14 @@ mod tests { vec![ HashAndAmount { hash: H256::from_str( - "94881436a9c89f48b01651ff491c69e97089daf71ab8cfb240243d7ecf9b38b2" + "1931f78f7ce5b43ffae11a2c22f18765508a2b2d4810e84744f53b10f7072c7f" ) .unwrap(), amount: 1000000000 }, HashAndAmount { hash: H256::from_str( - "3811874d2b73cecd51234c94af46bcce918d0cb4de7d946c01d7da606fe761b5" + "0d6daf751e62b89e79cac26d6376cf259d58e996cfccd63f3f43bb6408d1bae8" ) .unwrap(), amount: 2000000000 @@ -648,14 +648,14 @@ mod tests { Correct(PendingPayable { recipient_wallet: accounts[0].wallet.clone(), hash: H256::from_str( - "35f42b260f090a559e8b456718d9c91a9da0f234ed0a129b9d5c4813b6615af4", + "7bff7fd8e627d317203742a40f77be1a4155b4c3a29dfd4f96088775f0237023", ) .unwrap(), }), Correct(PendingPayable { recipient_wallet: accounts[1].wallet.clone(), hash: H256::from_str( - "7f3221109e4f1de8ba1f7cd358aab340ecca872a1456cb1b4f59ca33d3e22ee3", + "5bc60cce367d9698b8dbdb340e2af3a3166bb4469e69db899f5074938ea0d61b", ) .unwrap(), }), @@ -678,8 +678,8 @@ mod tests { let expected_result = Err(Sending { msg: format!("Transport error: Error(Connect, Os {{ code: {}, kind: ConnectionRefused, message: {:?} }})", os_code, os_msg).to_string(), hashes: vec![ - H256::from_str("35f42b260f090a559e8b456718d9c91a9da0f234ed0a129b9d5c4813b6615af4").unwrap(), - H256::from_str("7f3221109e4f1de8ba1f7cd358aab340ecca872a1456cb1b4f59ca33d3e22ee3").unwrap() + H256::from_str("7bff7fd8e627d317203742a40f77be1a4155b4c3a29dfd4f96088775f0237023").unwrap(), + H256::from_str("5bc60cce367d9698b8dbdb340e2af3a3166bb4469e69db899f5074938ea0d61b").unwrap() ], }); @@ -719,7 +719,7 @@ mod tests { data: None, }), recipient_wallet: accounts[0].wallet.clone(), - hash: H256::from_str("35f42b260f090a559e8b456718d9c91a9da0f234ed0a129b9d5c4813b6615af4").unwrap(), + hash: H256::from_str("7bff7fd8e627d317203742a40f77be1a4155b4c3a29dfd4f96088775f0237023").unwrap(), }), Failed(RpcPayableFailure { rpc_error: Rpc(Error { @@ -728,7 +728,7 @@ mod tests { data: None, }), recipient_wallet: accounts[1].wallet.clone(), - hash: H256::from_str("7f3221109e4f1de8ba1f7cd358aab340ecca872a1456cb1b4f59ca33d3e22ee3").unwrap(), + hash: H256::from_str("5bc60cce367d9698b8dbdb340e2af3a3166bb4469e69db899f5074938ea0d61b").unwrap(), }), ]); @@ -758,7 +758,7 @@ mod tests { let expected_result = Ok(vec![ Correct(PendingPayable { recipient_wallet: accounts[0].wallet.clone(), - hash: H256::from_str("35f42b260f090a559e8b456718d9c91a9da0f234ed0a129b9d5c4813b6615af4").unwrap(), + hash: H256::from_str("7bff7fd8e627d317203742a40f77be1a4155b4c3a29dfd4f96088775f0237023").unwrap(), }), Failed(RpcPayableFailure { rpc_error: Rpc(Error { @@ -767,7 +767,7 @@ mod tests { data: None, }), recipient_wallet: accounts[1].wallet.clone(), - hash: H256::from_str("7f3221109e4f1de8ba1f7cd358aab340ecca872a1456cb1b4f59ca33d3e22ee3").unwrap(), + hash: H256::from_str("5bc60cce367d9698b8dbdb340e2af3a3166bb4469e69db899f5074938ea0d61b").unwrap(), }), ]); diff --git a/node/src/blockchain/blockchain_interface_initializer.rs b/node/src/blockchain/blockchain_interface_initializer.rs index ee87519a0..1527b5e9f 100644 --- a/node/src/blockchain/blockchain_interface_initializer.rs +++ b/node/src/blockchain/blockchain_interface_initializer.rs @@ -92,7 +92,7 @@ mod tests { #[test] #[should_panic(expected = "Invalid blockchain service URL \"http://λ:8545\". \ - Error: Transport(\"InvalidUri(InvalidUriChar)\"). Chain: polygon-mainnet")] + Error: Transport(\"InvalidUri(InvalidUriChar)\"). Chain: base-mainnet")] fn invalid_blockchain_url_for_produces_panic_for_web3_interface() { let blockchain_service_url = "http://λ:8545"; let subject = BlockchainInterfaceInitializer {}; diff --git a/node/src/bootstrapper.rs b/node/src/bootstrapper.rs index b70bc208c..688d14336 100644 --- a/node/src/bootstrapper.rs +++ b/node/src/bootstrapper.rs @@ -1155,6 +1155,8 @@ mod tests { subject .initialize_as_unprivileged( &make_simplified_multi_config([ + "--blockchain-service-url", + "https://booga.com", "--ip", "1.2.3.4", "--clandestine-port", @@ -1276,7 +1278,14 @@ mod tests { subject .initialize_as_unprivileged( - &make_simplified_multi_config(["--ip", "1.2.3.4", "--clandestine-port", "5123"]), + &make_simplified_multi_config([ + "--blockchain-service-url", + "https://booga.com", + "--ip", + "1.2.3.4", + "--clandestine-port", + "5123", + ]), &mut FakeStreamHolder::new().streams(), ) .unwrap(); @@ -1323,6 +1332,8 @@ mod tests { subject .initialize_as_unprivileged( &make_simplified_multi_config([ + "--blockchain-service-url", + "https://booga.com", "--data-directory", data_dir.to_str().unwrap(), "--clandestine-port", @@ -1361,7 +1372,14 @@ mod tests { subject .initialize_as_unprivileged( - &make_simplified_multi_config(["--ip", "1.2.3.4", "--gas-price", "11"]), + &make_simplified_multi_config([ + "--blockchain-service-url", + "https://booga.com", + "--ip", + "1.2.3.4", + "--gas-price", + "11", + ]), &mut FakeStreamHolder::new().streams(), ) .unwrap(); @@ -1436,6 +1454,8 @@ mod tests { "init_as_privileged_stores_dns_servers_and_passes_them_to_actor_system_factory_for_proxy_client_in_init_as_unprivileged", ); let args = [ + "--blockchain-service-url", + "https://booga.com", "--dns-servers", "1.2.3.4,2.3.4.5", "--ip", @@ -1495,7 +1515,12 @@ mod tests { .build(); subject - .initialize_as_privileged(&make_simplified_multi_config(["--ip", "111.111.111.111"])) + .initialize_as_privileged(&make_simplified_multi_config([ + "--blockchain-service-url", + "https://booga.com", + "--ip", + "111.111.111.111", + ])) .unwrap(); } @@ -1622,6 +1647,8 @@ mod tests { subject .initialize_as_unprivileged( &make_simplified_multi_config([ + "--blockchain-service-url", + "https://booga.com", "--clandestine-port", "1234", "--ip", @@ -1649,6 +1676,8 @@ mod tests { let data_dir = ensure_node_home_directory_exists("bootstrapper", "initialize_as_unprivileged_moves_streams_from_listener_handlers_to_stream_handler_pool"); init_test_logging(); let args = [ + "--blockchain-service-url", + "https://booga.com", "--ip", "111.111.111.111", "--data-directory", diff --git a/node/src/daemon/setup_reporter.rs b/node/src/daemon/setup_reporter.rs index e12713cda..a7448eba4 100644 --- a/node/src/daemon/setup_reporter.rs +++ b/node/src/daemon/setup_reporter.rs @@ -1900,6 +1900,7 @@ mod tests { ); vec![ ("MASQ_CHAIN", TEST_DEFAULT_CHAIN.rec().literal_identifier), + ("MASQ_BLOCKCHAIN_SERVICE_URL", "https://booga.com"), ("MASQ_CLANDESTINE_PORT", "1234"), ("MASQ_CONSUMING_PRIVATE_KEY", "0011223344556677001122334455667700112233445566770011223344556677"), ("MASQ_CRASH_POINT", "Panic"), @@ -1949,7 +1950,6 @@ mod tests { .collect_vec(); let existing_setup = setup_cluster_from(vec![ - ("blockchain-service-url", "https://booga.com", Set), ("clandestine-port", "4321", Set), ( "consuming-private-key", @@ -1989,7 +1989,7 @@ mod tests { let result = subject.get_modified_setup(existing_setup, params).unwrap(); let expected_result = vec![ - ("blockchain-service-url", "", Required), + ("blockchain-service-url", "https://booga.com", Configured), ("chain", TEST_DEFAULT_CHAIN.rec().literal_identifier, Configured), ("clandestine-port", "1234", Configured), ("config-file", "", Blank), @@ -2348,6 +2348,7 @@ mod tests { assert_eq!(schema_version_before, "0"); let existing_setup = setup_cluster_from(vec![ ("chain", DEFAULT_CHAIN.rec().literal_identifier, Default), + ("blockchain-service-url", "https://booga.com", Set), ( "data-directory", &data_dir.to_string_lossy().to_string(), @@ -2649,6 +2650,7 @@ mod tests { "data-directory", &home_dir.to_string_lossy().to_string(), ), + UiSetupRequestValue::new("blockchain-service-url", "https://booga.com"), UiSetupRequestValue::new("ip", "1.2.3.4"), UiSetupRequestValue::clear("chain"), ], @@ -2665,8 +2667,10 @@ mod tests { #[test] fn calculate_setup_with_chain_specific_dir_on_user_specified_directory() { let _guard = EnvironmentGuard::new(); - let existing_setup = - setup_cluster_from(vec![("real-user", "1111:1111:/home/booga", Default)]); + let existing_setup = setup_cluster_from(vec![ + ("real-user", "1111:1111:/home/booga", Default), + ("blockchain-service-url", "https://booga.com", Set), + ]); let masqhome = Path::new("/home/booga/masqhome"); let incoming_setup = vec![UiSetupRequestValue::new( "data-directory", @@ -2677,7 +2681,7 @@ mod tests { let result = subject.get_modified_setup(existing_setup, incoming_setup); - let expected = masqhome.join("polygon-mainnet"); + let expected = masqhome.join("base-mainnet"); assert_eq!( result.unwrap().get("data-directory").unwrap().value, expected.to_str().unwrap() @@ -2687,8 +2691,10 @@ mod tests { #[test] fn calculate_setup_with_chain_specific_dir_on_default_directory() { let _guard = EnvironmentGuard::new(); - let existing_setup = - setup_cluster_from(vec![("real-user", "1111:1111:/home/booga", Default)]); + let existing_setup = setup_cluster_from(vec![ + ("real-user", "1111:1111:/home/booga", Default), + ("blockchain-service-url", "https://booga.com", Set), + ]); let incoming_setup = vec![UiSetupRequestValue::new("chain", "polygon-amoy")]; let home_directory = Path::new("/home/booga"); let data_directory = home_directory.join("data"); diff --git a/node/src/database/config_dumper.rs b/node/src/database/config_dumper.rs index d191a8a70..90ecc119e 100644 --- a/node/src/database/config_dumper.rs +++ b/node/src/database/config_dumper.rs @@ -268,7 +268,7 @@ mod tests { .initialize( &database_path, DbInitializationConfig::create_or_migrate(ExternalData::new( - Chain::PolyMainnet, + DEFAULT_CHAIN, NeighborhoodModeLight::ZeroHop, None, )), @@ -307,7 +307,7 @@ mod tests { } let mut args_builder = ArgsBuilder::new() .param("--real-user", "123::") - .param("--chain", Chain::PolyMainnet.rec().literal_identifier) + .param("--chain", DEFAULT_CHAIN.rec().literal_identifier) .opt("--dump-config"); if let Some(data_dir) = non_default_data_directory_opt { args_builder = args_builder.param("--data-directory", data_dir.to_str().unwrap()); @@ -344,11 +344,7 @@ mod tests { "0x0123456789012345678901234567890123456789", &map, ); - assert_value( - "chainName", - Chain::PolyMainnet.rec().literal_identifier, - &map, - ); + assert_value("chainName", DEFAULT_CHAIN.rec().literal_identifier, &map); assert_value("gasPrice", "1", &map); assert_value( "pastNeighbors", diff --git a/node/src/database/db_initializer.rs b/node/src/database/db_initializer.rs index aea696d6c..cd5c5b1bb 100644 --- a/node/src/database/db_initializer.rs +++ b/node/src/database/db_initializer.rs @@ -1596,7 +1596,7 @@ mod tests { assert!( config_one_debug.contains( "DbInitializationConfig{init_config: CreationAndMigration { external_data: \ - ExternalData { chain: PolyMainnet, neighborhood_mode: Standard, db_password_opt: \ + ExternalData { chain: BaseMainnet, neighborhood_mode: Standard, db_password_opt: \ None } }, special_conn_setup: Addresses[" ), "instead, the first printed message contained: {}", diff --git a/node/src/node_configurator/node_configurator_standard.rs b/node/src/node_configurator/node_configurator_standard.rs index 3cad6c983..4e72a6716 100644 --- a/node/src/node_configurator/node_configurator_standard.rs +++ b/node/src/node_configurator/node_configurator_standard.rs @@ -463,6 +463,8 @@ mod tests { .unwrap(); } let multi_config = make_simplified_multi_config([ + "--blockchain-service-url", + "https://booga.com", "--chain", "eth-mainnet", "--db-password", @@ -505,6 +507,8 @@ mod tests { PersistentConfigurationReal::from(conn) }; let multi_config = make_simplified_multi_config([ + "--blockchain-service-url", + "https://booga.com", "--chain", "eth-mainnet", "--db-password", @@ -767,6 +771,7 @@ mod tests { ); } let args = ArgsBuilder::new() + .param("--blockchain-service-url", "https://booga.com") .param("--data-directory", home_dir.to_str().unwrap()) .param("--ip", "1.2.3.4"); let mut bootstrapper_config = BootstrapperConfig::new(); @@ -1079,7 +1084,7 @@ mod tests { #[cfg(target_os = "windows")] assert_eq!( value_m!(env_multiconfig, "data-directory", String).unwrap(), - "generated/test/node_configurator_standard/server_initializer_collected_params_handle_dot_config_file_path_and_reads_arguments_from_cf/home\\data_dir\\MASQ\\polygon-mainnet".to_string() + "generated/test/node_configurator_standard/server_initializer_collected_params_handle_dot_config_file_path_and_reads_arguments_from_cf/home\\data_dir\\MASQ\\base-mainnet".to_string() ); } @@ -1190,7 +1195,7 @@ mod tests { #[cfg(target_os = "windows")] assert_eq!( value_m!(env_multiconfig, "data-directory", String).unwrap(), - "/home/booga\\data_dir\\MASQ\\polygon-mainnet".to_string() + "/home/booga\\data_dir\\MASQ\\base-mainnet".to_string() ); } @@ -1251,7 +1256,7 @@ mod tests { #[cfg(target_os = "windows")] assert_eq!( value_m!(env_multiconfig, "data-directory", String).unwrap(), - "/home/booga\\data_dir\\MASQ\\polygon-mainnet".to_string() + "/home/booga\\data_dir\\MASQ\\base-mainnet".to_string() ); } @@ -1576,7 +1581,14 @@ mod tests { let mut subject = NodeConfiguratorStandardUnprivileged::new(&BootstrapperConfig::new()); subject.privileged_config = BootstrapperConfig::new(); subject.privileged_config.data_directory = data_dir; - let args = ["--ip", "1.2.3.4", "--gas-price", "57"]; + let args = [ + "--blockchain-service-url", + "https://booga.com", + "--ip", + "1.2.3.4", + "--gas-price", + "57", + ]; let config = subject .configure(&make_simplified_multi_config(args)) @@ -1597,7 +1609,12 @@ mod tests { let mut subject = NodeConfiguratorStandardUnprivileged::new(&BootstrapperConfig::new()); subject.privileged_config = BootstrapperConfig::new(); subject.privileged_config.data_directory = data_dir; - let args = ["--ip", "1.2.3.4"]; + let args = [ + "--blockchain-service-url", + "https://booga.com", + "--ip", + "1.2.3.4", + ]; let config = subject .configure(&make_simplified_multi_config(args)) @@ -1773,16 +1790,21 @@ mod tests { let args = match (chain_opt, data_directory_opt) { (Some(chain_opt), Some(data_directory_opt)) => ArgsBuilder::new() + .param("--blockchain-service-url", "https://booga.com") .param("--chain", chain_opt) .param("--real-user", "999:999:/home/cooga") .param("--data-directory", data_directory_opt), (None, Some(data_directory_opt)) => ArgsBuilder::new() + .param("--blockchain-service-url", "https://booga.com") .param("--data-directory", data_directory_opt) .param("--real-user", "999:999:/home/cooga"), (Some(chain_opt), None) => ArgsBuilder::new() + .param("--blockchain-service-url", "https://booga.com") .param("--chain", chain_opt) .param("--real-user", "999:999:/home/cooga"), - (None, None) => ArgsBuilder::new().param("--real-user", "999:999:/home/cooga"), + (None, None) => ArgsBuilder::new() + .param("--real-user", "999:999:/home/cooga") + .param("--blockchain-service-url", "https://booga.com"), }; let args_vec: Vec = args.into(); let dir_wrapper = match data_directory_opt { @@ -1810,7 +1832,7 @@ mod tests { let _clap_guard = ClapGuard::new(); running_test(); let home_dir = Path::new("/home/cooga"); - let home_dir_poly_main = home_dir.join(".local").join("MASQ").join("polygon-mainnet"); + let home_dir_poly_main = home_dir.join(".local").join("MASQ").join("base-mainnet"); let home_dir_poly_amoy = home_dir.join(".local").join("MASQ").join("polygon-amoy"); vec![ (None, None, Some(home_dir_poly_main.to_str().unwrap())), @@ -1828,8 +1850,8 @@ mod tests { ), ( None, - Some("/cooga/polygon-amoy/polygon-mainnet"), - Some("/cooga/polygon-amoy/polygon-mainnet"), + Some("/cooga/polygon-amoy/base-mainnet"), + Some("/cooga/polygon-amoy/base-mainnet"), ), ( Some("polygon-amoy"), diff --git a/node/src/node_configurator/unprivileged_parse_args_configuration.rs b/node/src/node_configurator/unprivileged_parse_args_configuration.rs index 41cd9a424..8ff2ed7c4 100644 --- a/node/src/node_configurator/unprivileged_parse_args_configuration.rs +++ b/node/src/node_configurator/unprivileged_parse_args_configuration.rs @@ -13,7 +13,7 @@ use crate::sub_lib::neighborhood::{ }; use crate::sub_lib::node_addr::NodeAddr; use crate::sub_lib::wallet::Wallet; -use clap::value_t; +use clap::{value_t, Error}; use itertools::Itertools; use masq_lib::blockchains::chains::Chain; use masq_lib::constants::{DEFAULT_CHAIN, MASQ_URL_PREFIX}; @@ -37,16 +37,28 @@ pub trait UnprivilegedParseArgsConfiguration { ) -> Result<(), ConfiguratorError> { unprivileged_config .blockchain_bridge_config - .blockchain_service_url_opt = - if is_user_specified(multi_config, "blockchain-service-url") { - value_m!(multi_config, "blockchain-service-url", String) - } else { - match persistent_config.blockchain_service_url() { - Ok(Some(price)) => Some(price), - Ok(None) => None, - Err(pce) => return Err(pce.into_configurator_error("gas-price")), + .blockchain_service_url_opt = if is_user_specified( + multi_config, + "blockchain-service-url", + ) { + value_m!(multi_config, "blockchain-service-url", String) + } else { + match persistent_config.blockchain_service_url() { + Ok(Some(blockchain_service_url)) => Some(blockchain_service_url), + Ok(None) => { + if self.blockchain_service_url_error(multi_config) { + return Err(MultiConfig::make_configurator_error(Error { + message: "The following required argument was not provided: --blockchain-service-url USAGE: --blockchain-service-url ".to_string(), + kind: clap::ErrorKind::ArgumentNotFound, + info: Some(vec!["".to_string()]), + })); + } else { + None + } } - }; + Err(pce) => return Err(pce.into_configurator_error("blockchain-service-url")), + } + }; unprivileged_config.clandestine_port_opt = value_m!(multi_config, "clandestine-port", u16); unprivileged_config.blockchain_bridge_config.gas_price = if is_user_specified(multi_config, "gas-price") { @@ -69,6 +81,14 @@ pub trait UnprivilegedParseArgsConfiguration { mnc_result.map(|config| unprivileged_config.neighborhood_config = config) } + fn blockchain_service_url_error(&self, multi_config: &MultiConfig) -> bool { + let no_zerohop = + value_m!(multi_config, "neighborhood-mode", String) != Some("zero-hop".to_string()); + let no_fake_public_key = value_m!(multi_config, "fake-public-key", String) == None; + let no_crash_point = value_m!(multi_config, "crash-point", String) == None; + no_zerohop && no_fake_public_key && no_crash_point + } + fn get_past_neighbors( &self, persistent_config: &mut dyn PersistentConfiguration, @@ -1201,6 +1221,95 @@ mod tests { assert_eq!(result,Err(ConfiguratorError::new(vec![ParamError::new("neighbors", "Neighbors supplied without ip addresses and ports are not valid: 'masq://eth-ropsten:abJ5XvhVbmVyGejkYUkmftF09pmGZGKg_PzRNnWQxFw@:")]))) } + #[test] + fn unprivileged_parse_args_without_blockchain_service_url_returns_error() { + running_test(); + let set_past_neighbors_params_arc = Arc::new(Mutex::new(vec![])); + let mut config = BootstrapperConfig::new(); + let mut persistent_config = configure_default_persistent_config( + RATE_PACK | ACCOUNTANT_CONFIG_PARAMS | MAPPING_PROTOCOL, + ) + .set_past_neighbors_params(&set_past_neighbors_params_arc) + .set_past_neighbors_result(Ok(())); + let multi_config = make_simplified_multi_config([ + "--chain", + "eth-ropsten", + "--neighbors", + "masq://eth-ropsten:UJNoZW5p-PDVqEjpr3b_8jZ_93yPG8i5dOAgE1bhK_A@2.3.4.5:2345", + "--db-password", + "password", + ]); + let subject = UnprivilegedParseArgsConfigurationDaoReal {}; + + let result = subject + .unprivileged_parse_args( + &multi_config, + &mut config, + &mut persistent_config, + &Logger::new("test"), + ) + .unwrap_err(); + + let expected = MultiConfig::make_configurator_error(Error { + message: "The following required argument was not provided: --blockchain-service-url USAGE: --blockchain-service-url ".to_string(), + kind: clap::ErrorKind::ArgumentNotFound, + info: Some(vec!["".to_string()]), + }); + + assert_eq!(result, expected); + } + + #[test] + fn unprivileged_parse_args_does_not_require_blockchain_service_url_under_these_circumstances() { + running_test(); + let set_past_neighbors_params_arc = Arc::new(Mutex::new(vec![])); + let config = BootstrapperConfig::new(); + let persistent_config = configure_default_persistent_config( + RATE_PACK | ACCOUNTANT_CONFIG_PARAMS | MAPPING_PROTOCOL, + ) + .set_past_neighbors_params(&set_past_neighbors_params_arc) + .set_past_neighbors_result(Ok(())); + let exception_params = vec![ + ("--fake-public-key", "booga"), + ("--crash-point", "Error"), + ("--neighborhood-mode", "zero-hop"), + ]; + + for exception_param in exception_params { + create_and_assert_multiconfig( + config.clone(), + persistent_config.clone(), + exception_param, + ); + } + } + + fn create_and_assert_multiconfig( + mut config: BootstrapperConfig, + mut persistent_config: PersistentConfigurationMock, + exception_param: (&str, &str), + ) { + let subject = UnprivilegedParseArgsConfigurationDaoReal {}; + let multi_config = make_simplified_multi_config([ + "--chain", + "eth-ropsten", + "--neighbors", + "masq://eth-ropsten:UJNoZW5p-PDVqEjpr3b_8jZ_93yPG8i5dOAgE1bhK_A@2.3.4.5:2345", + "--db-password", + "password", + exception_param.0, + exception_param.1, + ]); + let result = subject.unprivileged_parse_args( + &multi_config, + &mut config, + &mut persistent_config, + &Logger::new("test"), + ); + + assert_eq!(result, Ok(())); + } + #[test] fn configure_zero_hop_with_neighbors_supplied() { running_test(); @@ -1462,7 +1571,7 @@ mod tests { #[test] fn unprivileged_parse_args_creates_configuration_with_defaults() { running_test(); - let args = ArgsBuilder::new(); + let args = ArgsBuilder::new().param("--blockchain-service-url", "booga.com"); let mut config = BootstrapperConfig::new(); let vcls: Vec> = vec![Box::new(CommandLineVcl::new(args.into()))]; @@ -1601,7 +1710,9 @@ mod tests { #[test] fn unprivileged_parse_args_with_mapping_protocol_both_on_command_line_and_in_database() { running_test(); - let args = ArgsBuilder::new().param("--mapping-protocol", "pmp"); + let args = ArgsBuilder::new() + .param("--mapping-protocol", "pmp") + .param("--blockchain-service-url", "booga.com"); let mut config = BootstrapperConfig::new(); let vcls: Vec> = vec![Box::new(CommandLineVcl::new(args.into()))]; @@ -1639,6 +1750,7 @@ mod tests { ); let args = ArgsBuilder::new() + .param("--blockchain-service-url", "booga.com") .param("--ip", "1.2.3.4") .param("--data-directory", home_directory.to_str().unwrap()) .opt("--db-password"); @@ -1683,6 +1795,8 @@ mod tests { let set_scan_intervals_params_arc = Arc::new(Mutex::new(vec![])); let set_payment_thresholds_params_arc = Arc::new(Mutex::new(vec![])); let args = [ + "--blockchain-service-url", + "booga.com", "--ip", "1.2.3.4", "--scan-intervals", @@ -1759,6 +1873,8 @@ mod tests { ) { running_test(); let args = [ + "--blockchain-service-url", + "booga.com", "--ip", "1.2.3.4", "--scan-intervals", @@ -1830,6 +1946,8 @@ mod tests { running_test(); let set_rate_pack_params_arc = Arc::new(Mutex::new(vec![])); let args = [ + "--blockchain-service-url", + "booga.com", "--ip", "1.2.3.4", "--neighborhood-mode", @@ -1876,6 +1994,8 @@ mod tests { fn unprivileged_parse_args_rate_pack_with_values_from_cli_equal_to_database_standard_mode() { running_test(); let args = [ + "--blockchain-service-url", + "booga.com", "--ip", "1.2.3.4", "--neighborhood-mode", @@ -1921,6 +2041,8 @@ mod tests { ) { running_test(); let args = [ + "--blockchain-service-url", + "booga.com", "--ip", "1.2.3.4", "--chain", @@ -2432,7 +2554,14 @@ mod tests { fn unprivileged_configuration_handles_scans_off() { running_test(); let subject = UnprivilegedParseArgsConfigurationDaoReal {}; - let args = ["--ip", "1.2.3.4", "--scans", "off"]; + let args = [ + "--blockchain-service-url", + "booga.com", + "--ip", + "1.2.3.4", + "--scans", + "off", + ]; let mut bootstrapper_config = BootstrapperConfig::new(); subject @@ -2453,7 +2582,14 @@ mod tests { fn unprivileged_configuration_handles_scans_on() { running_test(); let subject = UnprivilegedParseArgsConfigurationDaoReal {}; - let args = ["--ip", "1.2.3.4", "--scans", "on"]; + let args = [ + "--blockchain-service-url", + "booga.com", + "--ip", + "1.2.3.4", + "--scans", + "on", + ]; let mut bootstrapper_config = BootstrapperConfig::new(); subject @@ -2474,7 +2610,7 @@ mod tests { fn unprivileged_configuration_defaults_scans() { running_test(); let subject = UnprivilegedParseArgsConfigurationDaoReal {}; - let args = ["--ip", "1.2.3.4"]; + let args = ["--blockchain-service-url", "booga.com", "--ip", "1.2.3.4"]; let mut bootstrapper_config = BootstrapperConfig::new(); subject diff --git a/node/src/sub_lib/neighborhood.rs b/node/src/sub_lib/neighborhood.rs index ba8ba7c6c..f26282aa6 100644 --- a/node/src/sub_lib/neighborhood.rs +++ b/node/src/sub_lib/neighborhood.rs @@ -35,10 +35,10 @@ use std::time::Duration; const ASK_ABOUT_GOSSIP_INTERVAL: Duration = Duration::from_secs(10); pub const DEFAULT_RATE_PACK: RatePack = RatePack { - routing_byte_rate: 172_300_000, - routing_service_rate: 1_723_000_000, - exit_byte_rate: 344_600_000, - exit_service_rate: 3_446_000_000, + routing_byte_rate: 53_844, + routing_service_rate: 53_844, + exit_byte_rate: 107_688, + exit_service_rate: 107_688, }; pub const ZERO_RATE_PACK: RatePack = RatePack { @@ -638,10 +638,10 @@ mod tests { assert_eq!( DEFAULT_RATE_PACK, RatePack { - routing_byte_rate: 172_300_000, - routing_service_rate: 1_723_000_000, - exit_byte_rate: 344_600_000, - exit_service_rate: 3_446_000_000, + routing_byte_rate: 53_844, + routing_service_rate: 53_844, + exit_byte_rate: 107_688, + exit_service_rate: 107_688, } ); assert_eq!( diff --git a/node/tests/financials_test.rs b/node/tests/financials_test.rs index 9847efa38..0237d002d 100644 --- a/node/tests/financials_test.rs +++ b/node/tests/financials_test.rs @@ -3,7 +3,7 @@ pub mod utils; use crate::utils::{make_conn, CommandConfig}; -use masq_lib::constants::POLYGON_MAINNET_FULL_IDENTIFIER; +use masq_lib::constants::DEFAULT_CHAIN; use masq_lib::messages::{ TopRecordsConfig, TopRecordsOrdering, UiFinancialsRequest, UiFinancialsResponse, UiShutdownRequest, NODE_UI_PROTOCOL, @@ -48,7 +48,7 @@ fn financials_command_retrieves_payable_and_receivable_records_integration() { config_dao .set( "chain_name", - Some(POLYGON_MAINNET_FULL_IDENTIFIER.to_string()), + Some(DEFAULT_CHAIN.rec().literal_identifier.to_string()), ) .unwrap(); } diff --git a/node/tests/initialization_test.rs b/node/tests/initialization_test.rs index 0a5e46ba8..a138092aa 100644 --- a/node/tests/initialization_test.rs +++ b/node/tests/initialization_test.rs @@ -152,7 +152,7 @@ fn wait_for_process_end(process_id: u32) { #[test] fn incomplete_node_descriptor_is_refused_integration() { - let chain_identifier = "polygon-mainnet"; + let chain_identifier = DEFAULT_CHAIN.rec().literal_identifier; let mut node = utils::MASQNode::start_standard( "incomplete_node_descriptor_is_refused_integration", Some( @@ -188,6 +188,7 @@ fn started_without_explicit_chain_parameter_runs_fine_integration() { //defaulted chain - chosen on the lack of user specified chain - corresponds with descriptors //believed to be for the default chain let config = CommandConfig::new() + .pair("--blockchain-service-url", "https://booga.com") .pair("--neighborhood-mode", "standard") .pair("--ip", "1.0.0.1") .pair("--log-level", "trace") diff --git a/node/tests/tls_through_node_test.rs b/node/tests/tls_through_node_test.rs index 6cb04cc91..4d82289bf 100644 --- a/node/tests/tls_through_node_test.rs +++ b/node/tests/tls_through_node_test.rs @@ -50,7 +50,6 @@ fn tls_through_node_integration() { } } }; - let request = "GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n".as_bytes(); tls_stream .write(request.clone()) diff --git a/node/tests/ui_gateway_test.rs b/node/tests/ui_gateway_test.rs index 07b603bff..403479f32 100644 --- a/node/tests/ui_gateway_test.rs +++ b/node/tests/ui_gateway_test.rs @@ -139,7 +139,7 @@ fn daemon_does_not_allow_node_to_keep_his_client_alive_integration() { let _: UiSetupResponse = daemon_client .transact(UiSetupRequest::new(vec![ ("ip", Some("100.80.1.1")), - ("chain", Some("polygon-mainnet")), + ("chain", Some("base-mainnet")), ("neighborhood-mode", Some("standard")), ("log-level", Some("trace")), ("blockchain-service-url", Some("https://www.example.com")),