Skip to content

Commit e0bd8e3

Browse files
utkarshg6dnwiebemasqrauder
authored
GH-631: Gossip Storm Avoidance (#196)
* GH-631: get the skeleton ready * GH-631: add a working recursive method for computing patch * GH-631: add test for computing patch; not working yet * GH-631: improve the test for the compute_patch function and make it working * GH-631: refactor the recursive function to compute patch * GH-631: refactor the conditionals inside the recursion * GH-631: refactor the compute_patch() to use match * GH-631: compute_patch() should search for neighbors in it's database for the root node * GH-631: improve the solution for the compute_patch() * GH-631: minor code cleanup * GH-631: add one more test to make compute_patch() robust * GH-631: add one more test for compute_patch() * GH-631: reduce the number of recursion calls and minize hashset size * GH-631: add test to check if the standard gossip handler ignores gossips that are outside the patch * GH-631: make the test work * GH-631: fix the test proper_standard_gossip_is_matched_and_handled * GH-631: fix the tests inside gossip_acceptor.rs * GH-631: refactor the compute_patch() * GH-631: remove compiler warnings * GH-631: filter agrs before calling the function that'll add introductory node * GH-631: only use references to build hashmap from agr * GH-631: use constant for computing patch * GH-631: remove redundant code * GH-631: remove clippy warnings * GH-631: rename test to can_retrieve_all_full_and_half_neighbors() * GH-631: remove contract test for eth ropsten * GH-631: modify extract_node_reference() * GH-631: Did more fixing on the blockchain multinode test * GH-631: format the code * GH-600: Workaround multinode test libc failure * GH-631: Review 1 (#202) * GH-631: refactor the compute_patch() * GH-631: use node record instead of database * GH-631: rename the some_node into not_a_neighbor * GH-631: create an outboard function for creating patch * GH-631: make a function for filtering agrs * GH-631: remove unused functions * GH-631: refactor test in gossip_acceptor.rs * GH-631: minor changes in gossip_acceptor.rs * GH-631: write test gossip_acceptor_filters_out_the_node_addr_of_incoming_gossip; not working yet * GH-631: remove the test that you've recently written * GH-631: Review 1 changes * GH-631: remove clippy warnings * GH-633: change the version number of libc from 2.36-4 to 2.36-6 * Trigger Build * GH-631: An attempt to fix multinode test provided_and_consumed_services_are_recorded_in_databases() by using duration * GH-631: remove the clippy allow statement for the compute_patch_recursive() Co-authored-by: Dan Wiebe <[email protected]> Co-authored-by: masqrauder <[email protected]>
1 parent f148227 commit e0bd8e3

File tree

7 files changed

+381
-59
lines changed

7 files changed

+381
-59
lines changed

multinode_integration_tests/docker/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved.
22
#FROM debian:stable-slim
33
#FROM debian:buster-slim
4-
FROM debian:bullseye-slim
4+
#FROM debian:bullseye-slim
5+
FROM debian:bookworm-slim
56

67
RUN apt-get update && \
7-
apt-get install -y libc6 && \
8+
apt-get install -y libc6=2.36-6 && \
89
# These lines are commented out because for some reason the installation of iptables-persistent hangs forever on
910
# bullseye-slim. Its absence means that the NodeStartupConfigBuilder::open_firewall_port() function won't work, but
1011
# at the time of this comment it's used in only one place in a way that doesn't have any value. So we decided to

multinode_integration_tests/src/masq_real_node.rs

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,39 +1144,42 @@ impl MASQRealNode {
11441144
}
11451145

11461146
fn extract_node_reference(name: &str) -> Result<NodeReference, String> {
1147-
let regex = Self::descriptor_regex();
1147+
let descriptor_regex = Self::descriptor_regex();
11481148
let mut retries_left = 25;
11491149
loop {
1150+
if retries_left <= 0 {
1151+
return Err(format!("Node {} never started", name));
1152+
}
1153+
retries_left -= 1;
11501154
println!("Checking for {} startup", name);
1151-
thread::sleep(Duration::from_millis(100));
1152-
let output = Self::exec_command_on_container_and_wait(
1155+
thread::sleep(Duration::from_millis(250));
1156+
match Self::exec_command_on_container_and_wait(
11531157
name,
11541158
vec![
11551159
"cat",
11561160
&format!("{}/{}", DATA_DIRECTORY, CURRENT_LOGFILE_NAME),
11571161
],
1158-
)
1159-
.unwrap_or_else(|e| {
1160-
panic!(
1161-
"Failed to read {}/{}: {}",
1162-
DATA_DIRECTORY, CURRENT_LOGFILE_NAME, e
1163-
)
1164-
});
1165-
match regex.captures(output.as_str()) {
1166-
Some(captures) => {
1167-
let node_reference =
1168-
NodeReference::from_str(captures.get(1).unwrap().as_str()).unwrap();
1169-
println!("{} startup detected at {}", name, node_reference);
1170-
return Ok(node_reference);
1171-
}
1172-
None => {
1173-
if retries_left <= 0 {
1174-
return Err(format!("Node {} never started:\n{}", name, output));
1162+
) {
1163+
Ok(output) => {
1164+
if let Some(captures) = descriptor_regex.captures(output.as_str()) {
1165+
let node_reference =
1166+
NodeReference::from_str(captures.get(1).unwrap().as_str()).unwrap();
1167+
println!("{} startup detected at {}", name, node_reference);
1168+
return Ok(node_reference);
11751169
} else {
1176-
retries_left -= 1;
1170+
println!(
1171+
"No local descriptor for {} in logfile yet\n{}",
1172+
name, output
1173+
)
11771174
}
11781175
}
1179-
}
1176+
Err(e) => {
1177+
println!(
1178+
"Failed to cat logfile for {} at {}/{}: {}",
1179+
name, DATA_DIRECTORY, CURRENT_LOGFILE_NAME, e
1180+
);
1181+
}
1182+
};
11801183
}
11811184
}
11821185
}

multinode_integration_tests/tests/blockchain_interaction_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ fn debtors_are_credited_once_but_not_twice() {
136136
}
137137

138138
#[test]
139-
fn blockchain_bridge_logs_when_started() {
139+
fn blockchain_bridge_starts_properly_on_bootstrap() {
140140
let mut cluster = MASQNodeCluster::start().unwrap();
141141
let private_key = "0011223300112233001122330011223300112233001122330011223300112233";
142142
let subject = cluster.start_real_node(

multinode_integration_tests/tests/bookkeeping_test.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn provided_and_consumed_services_are_recorded_in_databases() {
2323
.map(|_| start_real_node(&mut cluster, originating_node.node_reference()))
2424
.collect::<Vec<MASQRealNode>>();
2525

26-
thread::sleep(Duration::from_millis(10_000));
26+
thread::sleep(Duration::from_secs(10));
2727

2828
let mut client = originating_node.make_client(8080);
2929
let request = "GET / HTTP/1.1\r\nHost: example.com\r\n\r\n".as_bytes();
@@ -39,6 +39,9 @@ fn provided_and_consumed_services_are_recorded_in_databases() {
3939
// get all payables from originating node
4040
let payables = non_pending_payables(&originating_node);
4141

42+
// Waiting until the serving nodes have finished accruing their receivables
43+
thread::sleep(Duration::from_secs(2));
44+
4245
// get all receivables from all other nodes
4346
let receivable_balances = non_originating_nodes
4447
.iter()

node/src/neighborhood/gossip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use std::net::{IpAddr, SocketAddr};
2525
pub struct GossipNodeRecord {
2626
pub signed_data: PlainData,
2727
pub signature: CryptData,
28-
pub node_addr_opt: Option<NodeAddr>, // Only for use in introductions
28+
pub node_addr_opt: Option<NodeAddr>,
2929
}
3030

3131
impl Debug for GossipNodeRecord {

0 commit comments

Comments
 (0)