Skip to content

Commit fb9718e

Browse files
authored
GH-685 New Defaults and Blockchain service URL check (#708)
* New default values for Base Mainnet, New default chain Base Mainnet, Configuration Error when blockchain-service-url is not provided, Help with links for public RPC endpoints * fixing the tests * fix for testing run without blockchain-service-url, fixed tests * removing wrongly placed --blockchain-service-url * formatting * fix integration test with chain dir * fix financial test * remove unused import * integration tests fix * fixing Windows tests * fixing masq UI * wait to Node shutdownt increased to 10 sec * remove empty line * fixing tests with default chain directory * fixing gwei_min_resolution_clause in receivable_dao.rs::custom_query * formatting * fixed multinode tests * formatting * after self review * addressing review comments * fix typo in test * review2 changes
1 parent ded8ac0 commit fb9718e

File tree

20 files changed

+292
-84
lines changed

20 files changed

+292
-84
lines changed

masq/src/commands/setup_command.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ mod tests {
227227
"zero-hop".to_string(),
228228
"--log-level".to_string(),
229229
"--chain".to_string(),
230-
"polygon-mainnet".to_string(),
230+
DEFAULT_CHAIN.rec().literal_identifier.to_string(),
231231
"--scan-intervals".to_string(),
232232
"123|111|228".to_string(),
233233
"--scans".to_string(),

masq/tests/chain_specific_directory_test_integration.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn ensure_data_directory_has_specific_chain_directory_within_integration() {
2020
let mut masq_handle2 = MasqProcess::new().start_interactive(port, true);
2121
let mut stdin_handle = masq_handle2.create_stdin_handle();
2222

23-
stdin_handle.type_command("setup --data-directory /home/booga/masqhome/polygon-mainnet");
23+
stdin_handle.type_command("setup --data-directory /home/booga/masqhome/base-mainnet");
2424

2525
thread::sleep(Duration::from_millis(1000));
2626

@@ -29,12 +29,12 @@ fn ensure_data_directory_has_specific_chain_directory_within_integration() {
2929
let (stdout2, _stderr2, _exit_code2) = masq_handle2.stop();
3030
let expected = format!(
3131
"{:29} {:64} {}",
32-
"data-directory", "/home/booga/masqhome/polygon-mainnet", "Set"
32+
"data-directory", "/home/booga/masqhome/base-mainnet", "Set"
3333
);
3434

3535
assert!(
36-
!stdout.contains("MASQ/polygon-mainnet/MASQ/polygon-mainnet Default"),
37-
"Wrong directory: duplication of /MASQ/polygon-mainnet when Default"
36+
!stdout.contains("MASQ/base-mainnet/MASQ/base-mainnet Default"),
37+
"Wrong directory: duplication of /MASQ/base-mainnet when Default"
3838
);
3939
assert!(
4040
stdout2.contains(&expected),

masq_lib/src/constants.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::blockchains::chains::Chain;
44
use crate::data_version::DataVersion;
55
use const_format::concatcp;
66

7-
pub const DEFAULT_CHAIN: Chain = Chain::PolyMainnet;
7+
pub const DEFAULT_CHAIN: Chain = Chain::BaseMainnet;
88
pub const CURRENT_SCHEMA_VERSION: usize = 11;
99

1010
pub const HIGHEST_RANDOM_CLANDESTINE_PORT: u16 = 9999;
@@ -113,7 +113,7 @@ mod tests {
113113

114114
#[test]
115115
fn constants_have_correct_values() {
116-
assert_eq!(DEFAULT_CHAIN, Chain::PolyMainnet);
116+
assert_eq!(DEFAULT_CHAIN, Chain::BaseMainnet);
117117
assert_eq!(HIGHEST_RANDOM_CLANDESTINE_PORT, 9999);
118118
assert_eq!(HTTP_PORT, 80);
119119
assert_eq!(TLS_PORT, 443);

masq_lib/src/multi_config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use crate::shared_schema::{ConfiguratorError, ParamError};
44
#[allow(unused_imports)]
55
use clap::{value_t, values_t};
6-
use clap::{App, ArgMatches};
6+
use clap::{App, ArgMatches, Error};
77
use regex::Regex;
88
use std::collections::HashSet;
99
use std::fmt::{Debug, Display, Formatter};
@@ -102,7 +102,7 @@ impl<'a> MultiConfig<'a> {
102102
}
103103
}
104104

105-
pub fn make_configurator_error(e: clap::Error) -> ConfiguratorError {
105+
pub fn make_configurator_error(e: Error) -> ConfiguratorError {
106106
let invalid_value_patterns = vec![
107107
("Invalid value for '--(.*?) <.*>': (.*)$", 1, 2),
108108
("error: (.*) isn't a valid value for '--(.*?) <.*>'", 2, 1),

masq_lib/src/shared_schema.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@ use lazy_static::lazy_static;
1313
pub const BLOCKCHAIN_SERVICE_HELP: &str =
1414
"The Ethereum client you wish to use to provide Blockchain \
1515
exit services from your MASQ Node (e.g. http://localhost:8545, \
16-
https://ropsten.infura.io/v3/YOUR-PROJECT-ID, https://mainnet.infura.io/v3/YOUR-PROJECT-ID), \
17-
https://base-mainnet.g.alchemy.com/v2/d66UL0lPrltmweEqVsv3opBSVI3wkL8I, \
18-
https://polygon-mainnet.infura.io/v3/YOUR-PROJECT-ID";
16+
https://ropsten.infura.io/v3/<api-key>, https://mainnet.infura.io/v3/<api-key>), \
17+
https://base-mainnet.g.alchemy.com/<api-key>, https://polygon-mainnet.infura.io/v3/<api-key> \n \
18+
This argument is mandatory, to ensure that you will not be deliquency banned due to being unable to \
19+
pay your debts to MASQ network. If you are in a region where you have no access to blockchain \
20+
services, to create your own app, use one of following the public endpoints for Base Mainnet \
21+
(you need to specify `--chain base-mainnet` as the chain argument): \n\
22+
https://mainnet.base.org \nhttps://base.llamarpc.com \nhttps://1rpc.io/base \nhttps://base-rpc.publicnode.com";
1923
pub const CHAIN_HELP: &str =
2024
"The blockchain network MASQ Node will configure itself to use. You must ensure the \
2125
Ethereum client specified by --blockchain-service-url communicates with the same blockchain network.";
@@ -733,9 +737,13 @@ mod tests {
733737
BLOCKCHAIN_SERVICE_HELP,
734738
"The Ethereum client you wish to use to provide Blockchain \
735739
exit services from your MASQ Node (e.g. http://localhost:8545, \
736-
https://ropsten.infura.io/v3/YOUR-PROJECT-ID, https://mainnet.infura.io/v3/YOUR-PROJECT-ID), \
737-
https://base-mainnet.g.alchemy.com/v2/d66UL0lPrltmweEqVsv3opBSVI3wkL8I, \
738-
https://polygon-mainnet.infura.io/v3/YOUR-PROJECT-ID"
740+
https://ropsten.infura.io/v3/<api-key>, https://mainnet.infura.io/v3/<api-key>), \
741+
https://base-mainnet.g.alchemy.com/<api-key>, https://polygon-mainnet.infura.io/v3/<api-key> \n \
742+
This argument is mandatory, to ensure that you will not be deliquency banned due to being unable to \
743+
pay your debts to MASQ network. If you are in a region where you have no access to blockchain \
744+
services, to create your own app, use one of following the public endpoints for Base Mainnet \
745+
(you need to specify `--chain base-mainnet` as the chain argument): \n\
746+
https://mainnet.base.org \nhttps://base.llamarpc.com \nhttps://1rpc.io/base \nhttps://base-rpc.publicnode.com"
739747
);
740748
assert_eq!(
741749
CHAIN_HELP,

multinode_integration_tests/tests/bookkeeping_test.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use multinode_integration_tests_lib::utils::{payable_dao, receivable_dao};
99
use node_lib::accountant::db_access_objects::payable_dao::PayableAccount;
1010
use node_lib::accountant::db_access_objects::receivable_dao::ReceivableAccount;
1111
use node_lib::accountant::db_access_objects::utils::CustomQuery;
12+
use node_lib::sub_lib::neighborhood::RatePack;
1213
use node_lib::sub_lib::wallet::Wallet;
1314
use std::collections::HashMap;
1415
use std::thread;
@@ -116,6 +117,15 @@ pub fn start_real_node(cluster: &mut MASQNodeCluster, neighbor: NodeReference) -
116117
.neighbor(neighbor)
117118
.earning_wallet_info(make_earning_wallet_info(&index.to_string()))
118119
.chain(cluster.chain)
120+
.rate_pack(RatePack {
121+
//TODO in case we are going to test more scenarios with need of higher RatePack:
122+
// create method in RatePack to return Default RatePack increased by some value or factor
123+
// make sure there is a test for this method
124+
routing_byte_rate: 2000000000,
125+
routing_service_rate: 2000000000,
126+
exit_byte_rate: 2000000000,
127+
exit_service_rate: 2000000000,
128+
})
119129
.build(),
120130
)
121131
}

node/src/accountant/db_access_objects/receivable_dao.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,10 @@ impl ReceivableDao for ReceivableDaoReal {
253253
}
254254

255255
fn custom_query(&self, custom_query: CustomQuery<i64>) -> Option<Vec<ReceivableAccount>> {
256-
let variant_top = TopStmConfig{
256+
let variant_top = TopStmConfig {
257257
limit_clause: "limit :limit_count",
258-
gwei_min_resolution_clause: "where (balance_high_b > 0) or ((balance_high_b = 0) and (balance_low_b >= 1000000000))",
258+
gwei_min_resolution_clause:
259+
"where (balance_high_b > 0) or ((balance_high_b = 0) and (balance_low_b >= 1000000000))",
259260
age_ordering_clause: "last_received_timestamp asc",
260261
};
261262
let variant_range = RangeStmConfig {

node/src/blockchain/blockchain_interface/blockchain_interface_web3/utils.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ mod tests {
406406
result,
407407
HashAndAmount {
408408
hash: H256::from_str(
409-
"94881436a9c89f48b01651ff491c69e97089daf71ab8cfb240243d7ecf9b38b2"
409+
"1931f78f7ce5b43ffae11a2c22f18765508a2b2d4810e84744f53b10f7072c7f"
410410
)
411411
.unwrap(),
412412
amount: account.balance_wei
@@ -453,14 +453,14 @@ mod tests {
453453
vec![
454454
HashAndAmount {
455455
hash: H256::from_str(
456-
"94881436a9c89f48b01651ff491c69e97089daf71ab8cfb240243d7ecf9b38b2"
456+
"1931f78f7ce5b43ffae11a2c22f18765508a2b2d4810e84744f53b10f7072c7f"
457457
)
458458
.unwrap(),
459459
amount: 1000000000
460460
},
461461
HashAndAmount {
462462
hash: H256::from_str(
463-
"3811874d2b73cecd51234c94af46bcce918d0cb4de7d946c01d7da606fe761b5"
463+
"0d6daf751e62b89e79cac26d6376cf259d58e996cfccd63f3f43bb6408d1bae8"
464464
)
465465
.unwrap(),
466466
amount: 2000000000
@@ -648,14 +648,14 @@ mod tests {
648648
Correct(PendingPayable {
649649
recipient_wallet: accounts[0].wallet.clone(),
650650
hash: H256::from_str(
651-
"35f42b260f090a559e8b456718d9c91a9da0f234ed0a129b9d5c4813b6615af4",
651+
"7bff7fd8e627d317203742a40f77be1a4155b4c3a29dfd4f96088775f0237023",
652652
)
653653
.unwrap(),
654654
}),
655655
Correct(PendingPayable {
656656
recipient_wallet: accounts[1].wallet.clone(),
657657
hash: H256::from_str(
658-
"7f3221109e4f1de8ba1f7cd358aab340ecca872a1456cb1b4f59ca33d3e22ee3",
658+
"5bc60cce367d9698b8dbdb340e2af3a3166bb4469e69db899f5074938ea0d61b",
659659
)
660660
.unwrap(),
661661
}),
@@ -678,8 +678,8 @@ mod tests {
678678
let expected_result = Err(Sending {
679679
msg: format!("Transport error: Error(Connect, Os {{ code: {}, kind: ConnectionRefused, message: {:?} }})", os_code, os_msg).to_string(),
680680
hashes: vec![
681-
H256::from_str("35f42b260f090a559e8b456718d9c91a9da0f234ed0a129b9d5c4813b6615af4").unwrap(),
682-
H256::from_str("7f3221109e4f1de8ba1f7cd358aab340ecca872a1456cb1b4f59ca33d3e22ee3").unwrap()
681+
H256::from_str("7bff7fd8e627d317203742a40f77be1a4155b4c3a29dfd4f96088775f0237023").unwrap(),
682+
H256::from_str("5bc60cce367d9698b8dbdb340e2af3a3166bb4469e69db899f5074938ea0d61b").unwrap()
683683
],
684684
});
685685

@@ -719,7 +719,7 @@ mod tests {
719719
data: None,
720720
}),
721721
recipient_wallet: accounts[0].wallet.clone(),
722-
hash: H256::from_str("35f42b260f090a559e8b456718d9c91a9da0f234ed0a129b9d5c4813b6615af4").unwrap(),
722+
hash: H256::from_str("7bff7fd8e627d317203742a40f77be1a4155b4c3a29dfd4f96088775f0237023").unwrap(),
723723
}),
724724
Failed(RpcPayableFailure {
725725
rpc_error: Rpc(Error {
@@ -728,7 +728,7 @@ mod tests {
728728
data: None,
729729
}),
730730
recipient_wallet: accounts[1].wallet.clone(),
731-
hash: H256::from_str("7f3221109e4f1de8ba1f7cd358aab340ecca872a1456cb1b4f59ca33d3e22ee3").unwrap(),
731+
hash: H256::from_str("5bc60cce367d9698b8dbdb340e2af3a3166bb4469e69db899f5074938ea0d61b").unwrap(),
732732
}),
733733
]);
734734

@@ -758,7 +758,7 @@ mod tests {
758758
let expected_result = Ok(vec![
759759
Correct(PendingPayable {
760760
recipient_wallet: accounts[0].wallet.clone(),
761-
hash: H256::from_str("35f42b260f090a559e8b456718d9c91a9da0f234ed0a129b9d5c4813b6615af4").unwrap(),
761+
hash: H256::from_str("7bff7fd8e627d317203742a40f77be1a4155b4c3a29dfd4f96088775f0237023").unwrap(),
762762
}),
763763
Failed(RpcPayableFailure {
764764
rpc_error: Rpc(Error {
@@ -767,7 +767,7 @@ mod tests {
767767
data: None,
768768
}),
769769
recipient_wallet: accounts[1].wallet.clone(),
770-
hash: H256::from_str("7f3221109e4f1de8ba1f7cd358aab340ecca872a1456cb1b4f59ca33d3e22ee3").unwrap(),
770+
hash: H256::from_str("5bc60cce367d9698b8dbdb340e2af3a3166bb4469e69db899f5074938ea0d61b").unwrap(),
771771
}),
772772
]);
773773

node/src/blockchain/blockchain_interface_initializer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ mod tests {
9292

9393
#[test]
9494
#[should_panic(expected = "Invalid blockchain service URL \"http://λ:8545\". \
95-
Error: Transport(\"InvalidUri(InvalidUriChar)\"). Chain: polygon-mainnet")]
95+
Error: Transport(\"InvalidUri(InvalidUriChar)\"). Chain: base-mainnet")]
9696
fn invalid_blockchain_url_for_produces_panic_for_web3_interface() {
9797
let blockchain_service_url = "http://λ:8545";
9898
let subject = BlockchainInterfaceInitializer {};

node/src/bootstrapper.rs

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,6 +1155,8 @@ mod tests {
11551155
subject
11561156
.initialize_as_unprivileged(
11571157
&make_simplified_multi_config([
1158+
"--blockchain-service-url",
1159+
"https://booga.com",
11581160
"--ip",
11591161
"1.2.3.4",
11601162
"--clandestine-port",
@@ -1276,7 +1278,14 @@ mod tests {
12761278

12771279
subject
12781280
.initialize_as_unprivileged(
1279-
&make_simplified_multi_config(["--ip", "1.2.3.4", "--clandestine-port", "5123"]),
1281+
&make_simplified_multi_config([
1282+
"--blockchain-service-url",
1283+
"https://booga.com",
1284+
"--ip",
1285+
"1.2.3.4",
1286+
"--clandestine-port",
1287+
"5123",
1288+
]),
12801289
&mut FakeStreamHolder::new().streams(),
12811290
)
12821291
.unwrap();
@@ -1323,6 +1332,8 @@ mod tests {
13231332
subject
13241333
.initialize_as_unprivileged(
13251334
&make_simplified_multi_config([
1335+
"--blockchain-service-url",
1336+
"https://booga.com",
13261337
"--data-directory",
13271338
data_dir.to_str().unwrap(),
13281339
"--clandestine-port",
@@ -1361,7 +1372,14 @@ mod tests {
13611372

13621373
subject
13631374
.initialize_as_unprivileged(
1364-
&make_simplified_multi_config(["--ip", "1.2.3.4", "--gas-price", "11"]),
1375+
&make_simplified_multi_config([
1376+
"--blockchain-service-url",
1377+
"https://booga.com",
1378+
"--ip",
1379+
"1.2.3.4",
1380+
"--gas-price",
1381+
"11",
1382+
]),
13651383
&mut FakeStreamHolder::new().streams(),
13661384
)
13671385
.unwrap();
@@ -1436,6 +1454,8 @@ mod tests {
14361454
"init_as_privileged_stores_dns_servers_and_passes_them_to_actor_system_factory_for_proxy_client_in_init_as_unprivileged",
14371455
);
14381456
let args = [
1457+
"--blockchain-service-url",
1458+
"https://booga.com",
14391459
"--dns-servers",
14401460
"1.2.3.4,2.3.4.5",
14411461
"--ip",
@@ -1495,7 +1515,12 @@ mod tests {
14951515
.build();
14961516

14971517
subject
1498-
.initialize_as_privileged(&make_simplified_multi_config(["--ip", "111.111.111.111"]))
1518+
.initialize_as_privileged(&make_simplified_multi_config([
1519+
"--blockchain-service-url",
1520+
"https://booga.com",
1521+
"--ip",
1522+
"111.111.111.111",
1523+
]))
14991524
.unwrap();
15001525
}
15011526

@@ -1622,6 +1647,8 @@ mod tests {
16221647
subject
16231648
.initialize_as_unprivileged(
16241649
&make_simplified_multi_config([
1650+
"--blockchain-service-url",
1651+
"https://booga.com",
16251652
"--clandestine-port",
16261653
"1234",
16271654
"--ip",
@@ -1649,6 +1676,8 @@ mod tests {
16491676
let data_dir = ensure_node_home_directory_exists("bootstrapper", "initialize_as_unprivileged_moves_streams_from_listener_handlers_to_stream_handler_pool");
16501677
init_test_logging();
16511678
let args = [
1679+
"--blockchain-service-url",
1680+
"https://booga.com",
16521681
"--ip",
16531682
"111.111.111.111",
16541683
"--data-directory",

0 commit comments

Comments
 (0)