Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-633: Optimise routing to reduce DNS resolution 'mark' #183

Merged
merged 72 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
d645095
GH-633: modify how the NodeRecordMetadataMessage is handled
utkarshg6 Oct 13, 2022
370a3b4
GH-633: use the hashset for unreachable hosts for compute_undesirabil…
utkarshg6 Oct 13, 2022
ffe6912
GH-633: NodeRecordMetadataMessage handler is able to add unreachable …
utkarshg6 Oct 13, 2022
d09c7f2
GH-633: add the ability to receive the Option of hostname inside comp…
utkarshg6 Oct 13, 2022
d046672
GH-633: remove clippy warnings
utkarshg6 Oct 14, 2022
8459237
GH-633: fix tests in proxy_server.rs
utkarshg6 Oct 14, 2022
cde41a9
GH-611: fix test masq_erc20_contract_exists_on_ethereum_ropsten_integ…
utkarshg6 Oct 7, 2022
4046f20
GH-633: remove commented out code
utkarshg6 Oct 14, 2022
2614c13
GH-633: fix the errors in multinode integration tests
utkarshg6 Oct 14, 2022
1b253f4
GH-633: use an enum to generalise NodeRecordMetadataMessage and only …
utkarshg6 Oct 18, 2022
b25dda6
GH-633: remove the desirable_for_exit field
utkarshg6 Oct 18, 2022
9ad161e
GH-633: rename server_name to server_name_opt inside AddReturnRouteMe…
utkarshg6 Oct 18, 2022
6b55c2b
GH-633: remove problems due to change in NodeRecordMetadata structure…
utkarshg6 Oct 18, 2022
27c473e
Merge branch 'master' into GH-633-review-1
utkarshg6 Oct 18, 2022
ce55d4e
GH-633: use lifetime specifier instead of cloning the hostname as a S…
utkarshg6 Oct 18, 2022
4004057
GH-633: Review 2 changes
utkarshg6 Oct 20, 2022
fc20e35
GH-633: refactor the code isnide handle_dns_resolve_failure()
utkarshg6 Oct 20, 2022
0e45f6e
Partial multinode test
dnwiebe Oct 20, 2022
fef22df
GH-633 Test is written, but doesn't pass yet
dnwiebe Oct 21, 2022
bd65f38
GH-633 New multinode test passes, but suspiciously
dnwiebe Oct 21, 2022
05c7d21
GH-633 Multinode test working, but failing; plus some light mods
dnwiebe Oct 21, 2022
486c98b
Removed warnings
dnwiebe Oct 31, 2022
3e5df46
Merge branch 'GH-633-review-2' into GH-633
dnwiebe Oct 31, 2022
ed89281
GH-499: Made ProxyServer picky about main and alias keys; fixed Crypt…
dnwiebe Nov 3, 2022
158513b
There's something funky about the way Standard Gossip is processed th…
dnwiebe Nov 10, 2022
2a6324a
GH-633: Test works better
dnwiebe Nov 22, 2022
0773cdc
GH-633: remove clippy warnings
utkarshg6 Nov 22, 2022
46f9edf
GH-633: fix the failing test
utkarshg6 Nov 22, 2022
8c4d072
Multinode test is still failing, but more successfully than ever before
dnwiebe Nov 29, 2022
f2ea122
GH-633: Commented out part of multinode test that doesn't pass in ord…
dnwiebe Nov 29, 2022
68ad73d
GH-633: minor review changes inside proxy_server/mod.rs
utkarshg6 Dec 5, 2022
40dc88c
Merge branch 'GH-633-adolescent' into GH-633
utkarshg6 Dec 5, 2022
a3f2540
GH-633: formatting changes
utkarshg6 Dec 5, 2022
382f0a4
GH-633: remove clippy warnings
utkarshg6 Dec 5, 2022
d056696
GH-633: increase version
utkarshg6 Dec 5, 2022
0623f24
GH-633: rename field to originator_public_key
utkarshg6 Dec 5, 2022
f7c402b
GH-631: Did more fixing on the blockchain multinode test
dnwiebe Nov 30, 2022
954a7c9
GH-633: An attempt to remove the warnings inside the multinode test
utkarshg6 Dec 7, 2022
9d36611
GH-633: change the version number of libc from 2.36-4 to 2.36-6
masqrauder Nov 30, 2022
377ea42
GH-633: implement alias_public_key
utkarshg6 Dec 13, 2022
4306af7
GH-633: trying to fix the multinode test errors
utkarshg6 Dec 13, 2022
9dfd5d2
Merge branch 'master' into GH-633
utkarshg6 Dec 14, 2022
7ba5d97
GH-633: rename the field back to originator_alias_public_key
utkarshg6 Dec 14, 2022
2481865
GH-633: remove clippy warnings from the multinode tests
utkarshg6 Dec 14, 2022
2bb39b8
GH-611: remove unused import from the file communication_failure_test.rs
utkarshg6 Dec 14, 2022
e89ec3a
GH-633: remove warnings from the connection_termination_test.rs
utkarshg6 Dec 14, 2022
283d02d
GH-633: Added some time for example.com to respond
dnwiebe Dec 15, 2022
4f94905
GH-633: fixing to right use of cryptdes on decrypting cores packages …
Dec 15, 2022
dc14b39
GH-633: fix one test in the routing_service.rs
utkarshg6 Dec 27, 2022
5002092
GH-633: modify helper functions and fix the test logs_and_ignores_mes…
utkarshg6 Dec 27, 2022
633be05
GH-633: fix test route_logs_and_ignores_cores_package_that_demands_pr…
utkarshg6 Dec 27, 2022
0edf4a5
GH-633: fix test converts_live_message_to_expired_for_existing_proxy_…
utkarshg6 Dec 27, 2022
9cd7903
GH-633: continue with Bert
utkarshg6 Dec 27, 2022
69322a2
GH-633: add some panics and eprintlns for debugging
utkarshg6 Dec 29, 2022
2294d63
GH-633: fix all tests in routing_service.rs
utkarshg6 Dec 29, 2022
dab612c
GH-633: add a todo
utkarshg6 Dec 30, 2022
ad4676b
GH-633: fix the integration test
utkarshg6 Dec 30, 2022
507915d
GH-633: fix test reported_server_drop
utkarshg6 Jan 2, 2023
57d50d4
GH-633: fix of an issue with fatal instance dropping: seeking for a d…
Jan 8, 2023
8f058d9
Merge remote-tracking branch 'upstream/master' into GH-633
utkarshg6 Jan 10, 2023
f374f60
GH-633(for bert): Review 1 Changes (#228)
utkarshg6 Mar 3, 2023
97467a0
GH-633: attempt to fix build errors
utkarshg6 Mar 6, 2023
5ed08ec
Merge branch 'master' of https://github.com/MASQ-Project/Node into GH…
utkarshg6 Mar 6, 2023
0b0da22
GH-671: removing www.failingFailing.com as non-http anymore for www.n…
Mar 3, 2023
9a5b568
GH-633: fix formatting issues
utkarshg6 Mar 6, 2023
28c17c7
GH-633: correction of a non-ideal design for a configurable mock node…
Mar 6, 2023
842f065
Merge branch 'GH-633' of github.com:MASQ-Project/Node into GH-633
Mar 6, 2023
9008032
GH-633: fix the test symmetric_encryption_fails_with_different_keys
utkarshg6 Mar 6, 2023
0fa899b
GH-633: fix formatting issues
utkarshg6 Mar 6, 2023
2bbc265
Merge branch 'GH-633' of github.com:MASQ-Project/Node into GH-633
Mar 6, 2023
f1e6433
GH-633: review five (#235)
bertllll Mar 10, 2023
13c48ee
GH-633: bump the version to 0.7.2
utkarshg6 Mar 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 34 additions & 35 deletions multinode_integration_tests/src/masq_mock_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,15 @@ use std::net::SocketAddr;
use std::net::TcpStream;
use std::net::{IpAddr, Shutdown};
use std::ops::Add;
use std::rc::Rc;
use std::thread;
use std::time::{Duration, Instant};

pub struct MASQMockNode {
control_stream: RefCell<TcpStream>,
guts: MASQMockNodeGuts,
//keep this smart pointer because any drop() called on a clone of the naked structure
//would stop the Docker container for this Node...or redesign...
guts: Rc<MASQMockNodeGuts>,
}

enum CryptDEEnum {
Expand All @@ -53,7 +56,7 @@ impl Clone for MASQMockNode {
fn clone(&self) -> Self {
MASQMockNode {
control_stream: RefCell::new(self.control_stream.borrow().try_clone().unwrap()),
guts: self.guts.clone(),
guts: Rc::clone(&self.guts),
}
}
}
Expand Down Expand Up @@ -142,14 +145,19 @@ impl MASQNode for MASQMockNode {
}
}

impl MASQMockNode {
pub struct ConfigurableMASQMockNode {
pub control_stream: RefCell<TcpStream>,
configurable_guts: MASQMockNodeGuts,
}

impl ConfigurableMASQMockNode {
pub fn start_with_public_key(
ports: Vec<u16>,
index: usize,
host_node_parent_dir: Option<String>,
public_key: &PublicKey,
chain: Chain,
) -> MASQMockNode {
) -> ConfigurableMASQMockNode {
let main_cryptde = CryptDENull::from(public_key, chain);
let mut key = public_key.as_slice().to_vec();
key.reverse();
Expand All @@ -163,7 +171,7 @@ impl MASQMockNode {
index: usize,
host_node_parent_dir: Option<String>,
chain: Chain,
) -> MASQMockNode {
) -> ConfigurableMASQMockNode {
let cryptde_enum = CryptDEEnum::Real(CryptDEReal::new(chain));
Self::start_with_cryptde_enum(ports, index, host_node_parent_dir, cryptde_enum)
}
Expand All @@ -173,17 +181,17 @@ impl MASQMockNode {
index: usize,
host_node_parent_dir: Option<String>,
cryptde_enum: CryptDEEnum,
) -> MASQMockNode {
) -> ConfigurableMASQMockNode {
let name = format!("mock_node_{}", index);
let node_addr = NodeAddr::new(&IpAddr::V4(Ipv4Addr::new(172, 18, 1, index as u8)), &ports);
let earning_wallet = make_wallet(format!("{}_earning", name).as_str());
let consuming_wallet = Some(make_paying_wallet(format!("{}_consuming", name).as_bytes()));
MASQNodeUtils::clean_up_existing_container(&name[..]);
Self::do_docker_run(&node_addr, host_node_parent_dir, &name);
MASQMockNode::do_docker_run(&node_addr, host_node_parent_dir, &name);
let wait_addr = SocketAddr::new(node_addr.ip_addr(), CONTROL_STREAM_PORT);
let control_stream = RefCell::new(Self::wait_for_startup(wait_addr, &name));
let control_stream = RefCell::new(MASQMockNode::wait_for_startup(wait_addr, &name));
let framer = RefCell::new(DataHunkFramer::new());
let guts = MASQMockNodeGuts {
let configurable_guts = MASQMockNodeGuts {
name,
node_addr,
earning_wallet,
Expand All @@ -193,12 +201,27 @@ impl MASQMockNode {
framer,
chain: TEST_DEFAULT_MULTINODE_CHAIN,
};
MASQMockNode {
ConfigurableMASQMockNode {
control_stream,
guts,
configurable_guts,
}
}

pub fn absorb_configuration(&mut self, node_record: &NodeRecord) {
// Copy attributes from the NodeRecord into the MASQNode.
self.configurable_guts.earning_wallet = node_record.earning_wallet();
self.configurable_guts.rate_pack = *node_record.rate_pack();
}

pub fn finish_with_guts_pointer(self) -> MASQMockNode {
bertllll marked this conversation as resolved.
Show resolved Hide resolved
MASQMockNode {
control_stream: self.control_stream,
guts: Rc::new(self.configurable_guts),
}
}
}

impl MASQMockNode {
pub fn cryptde_real(&self) -> Option<&CryptDEReal> {
match &self.guts.cryptde_enum {
CryptDEEnum::Fake(_) => None,
Expand Down Expand Up @@ -424,12 +447,6 @@ impl MASQMockNode {
stream.shutdown(Shutdown::Both).unwrap();
}

pub fn absorb_configuration(&mut self, node_record: &NodeRecord) {
// Copy attributes from the NodeRecord into the MASQNode.
self.guts.earning_wallet = node_record.earning_wallet();
self.guts.rate_pack = *node_record.rate_pack();
}

fn do_docker_run(node_addr: &NodeAddr, host_node_parent_dir: Option<String>, name: &str) {
let root = match host_node_parent_dir {
Some(dir) => dir,
Expand Down Expand Up @@ -506,21 +523,3 @@ impl Drop for MASQMockNodeGuts {
MASQNodeUtils::stop(self.name.as_str());
}
}

impl Clone for MASQMockNodeGuts {
fn clone(&self) -> Self {
Self {
name: self.name.clone(),
node_addr: self.node_addr.clone(),
earning_wallet: self.earning_wallet.clone(),
consuming_wallet: self.consuming_wallet.clone(),
rate_pack: self.rate_pack,
cryptde_enum: match &self.cryptde_enum {
CryptDEEnum::Fake((m, a)) => CryptDEEnum::Fake((m.clone(), a.clone())),
CryptDEEnum::Real(_) => panic!("A mock Node with a real CryptDE? Seriously?"),
},
framer: self.framer.clone(),
chain: self.chain,
}
}
}
46 changes: 33 additions & 13 deletions multinode_integration_tests/src/masq_node_cluster.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved.
use crate::command::Command;
use crate::masq_mock_node::MASQMockNode;
use crate::masq_mock_node::{ConfigurableMASQMockNode, MASQMockNode};
use crate::masq_node::{MASQNode, MASQNodeUtils};
use crate::masq_real_node::MASQRealNode;
use crate::masq_real_node::NodeStartupConfig;
Expand Down Expand Up @@ -77,38 +77,58 @@ impl MASQNodeCluster {
}

pub fn start_mock_node_with_real_cryptde(&mut self, ports: Vec<u16>) -> MASQMockNode {
self.start_mock_node(ports, None)
let unfinished_node = self.start_configurable_mock_node(ports, None);
self.finish_mock_node(unfinished_node)
}

pub fn start_mock_node_with_public_key(
&mut self,
ports: Vec<u16>,
public_key: &PublicKey,
) -> MASQMockNode {
self.start_mock_node(ports, Some(public_key))
let unfinished_node = self.start_configurable_mock_node(ports, Some(public_key));
self.finish_mock_node(unfinished_node)
}

fn start_mock_node(
pub fn start_configurable_mock_node_with_public_key(
&mut self,
ports: Vec<u16>,
public_key: &PublicKey,
) -> ConfigurableMASQMockNode {
self.start_configurable_mock_node(ports, Some(public_key))
}

fn start_configurable_mock_node(
&mut self,
ports: Vec<u16>,
public_key_opt: Option<&PublicKey>,
) -> MASQMockNode {
) -> ConfigurableMASQMockNode {
let index = self.next_index;
self.next_index += 1;
let node = match public_key_opt {
Some(public_key) => MASQMockNode::start_with_public_key(
match public_key_opt {
Some(public_key) => ConfigurableMASQMockNode::start_with_public_key(
ports,
index,
self.host_node_parent_dir.clone(),
public_key,
self.chain,
),
None => {
MASQMockNode::start(ports, index, self.host_node_parent_dir.clone(), self.chain)
}
};
let name = node.name().to_string();
self.mock_nodes.insert(name.clone(), node);
None => ConfigurableMASQMockNode::start(
ports,
index,
self.host_node_parent_dir.clone(),
self.chain,
),
}
}

pub fn finish_mock_node(
bertllll marked this conversation as resolved.
Show resolved Hide resolved
&mut self,
configurable_mock_node: ConfigurableMASQMockNode,
) -> MASQMockNode {
let mock_node = configurable_mock_node.finish_with_guts_pointer();
let name = mock_node.name().to_string();
self.mock_nodes.insert(name.clone(), mock_node);
self.mock_nodes.get(&name).unwrap().clone()
}

Expand Down
10 changes: 7 additions & 3 deletions multinode_integration_tests/src/neighborhood_constructor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ fn make_mock_node_map(
.map(|node| (node.main_public_key().clone(), node))
.collect::<HashMap<PublicKey, MASQMockNode>>();
additional_keys_to_mock.iter().for_each(|key| {
let mock_node = cluster.start_mock_node_with_public_key(vec![10000], key);
bertllll marked this conversation as resolved.
Show resolved Hide resolved
let configurable_mock_node =
cluster.start_configurable_mock_node_with_public_key(vec![10000], key);
let mock_node = cluster.finish_mock_node(configurable_mock_node);
let mock_node_key = mock_node.main_public_key().clone();
mock_node_map.insert(mock_node_key, mock_node);
});
Expand Down Expand Up @@ -187,8 +189,10 @@ fn form_mock_node_skeleton(
.full_neighbor_keys(model_db)
.into_iter()
.map(|model_node_key| {
let mut node = cluster.start_mock_node_with_public_key(vec![10000], model_node_key);
node.absorb_configuration(model_db.node_by_key(model_node_key).unwrap());
let mut configurable_node =
cluster.start_configurable_mock_node_with_public_key(vec![10000], model_node_key);
configurable_node.absorb_configuration(model_db.node_by_key(model_node_key).unwrap());
let node = cluster.finish_mock_node(configurable_node);
node.transmit_debut(real_node).unwrap();
node.wait_for_gossip(Duration::from_secs(2)).unwrap();
let standard_gossip = StandardBuilder::new()
Expand Down
10 changes: 6 additions & 4 deletions multinode_integration_tests/tests/graph_connectivity_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ fn graph_connects_but_does_not_over_connect() {
})
.collect::<Vec<MASQRealNode>>();
let last_node = real_nodes.last().unwrap();
let mock_node =
cluster.start_mock_node_with_public_key(vec![10000], &PublicKey::new(&[1, 2, 3, 4]));
let configurable_mock_node = cluster
.start_configurable_mock_node_with_public_key(vec![10000], &PublicKey::new(&[1, 2, 3, 4]));
let mock_node = cluster.finish_mock_node(configurable_mock_node);
let dont_count_these = vec![mock_node.main_public_key()];
// Wait for Gossip to abate
thread::sleep(Duration::from_millis(2000));
Expand Down Expand Up @@ -90,8 +91,9 @@ fn lots_of_stalled_nodes_dont_prevent_acceptance_of_new_node() {
db.add_arbitrary_full_neighbor(root_node.public_key(), full_neighbor_key);
let mut cluster = MASQNodeCluster::start().unwrap();
let (_, root_node, _) = construct_neighborhood(&mut cluster, db, vec![]);
let new_node =
cluster.start_mock_node_with_public_key(vec![5050], &PublicKey::new(&[3, 4, 5, 6]));
let configurable_mock = cluster
.start_configurable_mock_node_with_public_key(vec![5050], &PublicKey::new(&[3, 4, 5, 6]));
let new_node = cluster.finish_mock_node(configurable_mock);

new_node.transmit_debut(&root_node).unwrap();

Expand Down