Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Don't try to connect to ourselves. #3855

Merged
merged 2 commits into from
Sep 16, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
13 changes: 9 additions & 4 deletions node/network/gossip-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,19 @@ impl State {
);
}

let authorities = determine_relevant_authorities(ctx, relay_parent).await?;
let our_index = ensure_i_am_an_authority(keystore, &authorities).await?;
let all_authorities = determine_relevant_authorities(ctx, relay_parent).await?;
let our_index = ensure_i_am_an_authority(keystore, &all_authorities).await?;
let other_authorities = {
let mut authorities = all_authorities.clone();
authorities.remove(our_index);
eskimor marked this conversation as resolved.
Show resolved Hide resolved
authorities
};

self.issue_connection_request(ctx, authorities.clone()).await?;
self.issue_connection_request(ctx, other_authorities).await?;

if is_new_session {
self.last_session_index = Some(session_index);
update_gossip_topology(ctx, our_index, authorities, relay_parent).await?;
update_gossip_topology(ctx, our_index, all_authorities, relay_parent).await?;
}
}
}
Expand Down
21 changes: 14 additions & 7 deletions node/network/gossip-support/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,27 @@ async fn overseer_recv(overseer: &mut VirtualOverseer) -> AllMessages {
}

fn authorities() -> Vec<AuthorityDiscoveryId> {
let mut authorities = other_authorities();
authorities.push(Sr25519Keyring::Ferdie.public().into());
authorities
}

// Authorities other than ourselves:
fn other_authorities() -> Vec<AuthorityDiscoveryId> {
vec![
Sr25519Keyring::Alice.public().into(),
Sr25519Keyring::Bob.public().into(),
Sr25519Keyring::Charlie.public().into(),
Sr25519Keyring::Ferdie.public().into(),
Sr25519Keyring::Eve.public().into(),
Sr25519Keyring::One.public().into(),
Sr25519Keyring::Two.public().into(),
]
}

fn neighbors() -> Vec<AuthorityDiscoveryId> {
vec![
Sr25519Keyring::One.public().into(),
Sr25519Keyring::Alice.public().into(),
Sr25519Keyring::Two.public().into(),
Sr25519Keyring::Charlie.public().into(),
Sr25519Keyring::Eve.public().into(),
]
}
Expand Down Expand Up @@ -177,7 +184,7 @@ fn issues_a_connection_request_on_new_session() {
peer_set,
failed,
}) => {
assert_eq!(validator_ids, authorities());
assert_eq!(validator_ids, other_authorities());
assert_eq!(peer_set, PeerSet::Validation);
failed.send(0).unwrap();
}
Expand Down Expand Up @@ -245,7 +252,7 @@ fn issues_a_connection_request_on_new_session() {
peer_set,
failed,
}) => {
assert_eq!(validator_ids, authorities());
assert_eq!(validator_ids, other_authorities());
assert_eq!(peer_set, PeerSet::Validation);
failed.send(0).unwrap();
}
Expand Down Expand Up @@ -293,7 +300,7 @@ fn issues_a_connection_request_when_last_request_was_mostly_unresolved() {
peer_set,
failed,
}) => {
assert_eq!(validator_ids, authorities());
assert_eq!(validator_ids, other_authorities());
assert_eq!(peer_set, PeerSet::Validation);
failed.send(2).unwrap();
}
Expand Down Expand Up @@ -340,7 +347,7 @@ fn issues_a_connection_request_when_last_request_was_mostly_unresolved() {
peer_set,
failed,
}) => {
assert_eq!(validator_ids, authorities());
assert_eq!(validator_ids, other_authorities());
assert_eq!(peer_set, PeerSet::Validation);
failed.send(1).unwrap();
}
Expand Down