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

DA messages only gossip to DA nodes #1946

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions crates/hotshot/examples/infra/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,6 @@ where
}
all_keys.insert(pubkey);
}

let node_config = config_builder.build().unwrap();
let underlying_quorum_network = Libp2pNetwork::new(
NetworkingMetricsValue::new(),
Expand All @@ -799,7 +798,8 @@ where
// NOTE: this introduces an invariant that the keys are assigned using this indexed
// function
all_keys,
da_keys,
da_keys.clone(),
da_keys.contains(&pubkey),
)
.await
.unwrap();
Expand Down
17 changes: 14 additions & 3 deletions crates/hotshot/src/traits/networking/libp2p_network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ struct Libp2pNetworkInner<M: NetworkMsg, K: SignatureKey + 'static> {
/// NOTE: supposed to represent a ViewNumber but we
/// haven't made that atomic yet and we prefer lock-free
latest_seen_view: Arc<AtomicU64>,
/// if we're a member of the DA committee or not
is_da: bool,
}

/// Networking implementation that uses libp2p
Expand Down Expand Up @@ -227,12 +229,13 @@ where
Libp2pNetwork::new(
NetworkingMetricsValue::new(),
config,
pubkey,
pubkey.clone(),
bootstrap_addrs_ref,
num_bootstrap,
node_id as usize,
keys,
da,
da.clone(),
da.contains(&pubkey),
)
.await
.unwrap()
Expand Down Expand Up @@ -281,6 +284,7 @@ impl<M: NetworkMsg, K: SignatureKey + 'static> Libp2pNetwork<M, K> {
// HACK
committee_pks: BTreeSet<K>,
da_pks: BTreeSet<K>,
is_da: bool,
) -> Result<Libp2pNetwork<M, K>, NetworkError> {
assert!(bootstrap_addrs_len > 4, "Need at least 5 bootstrap nodes");
let network_handle = Arc::new(
Expand Down Expand Up @@ -336,6 +340,7 @@ impl<M: NetworkMsg, K: SignatureKey + 'static> Libp2pNetwork<M, K> {
// proposals on". We need this because to have consensus info injected we need a working
// network already. In the worst case, we send a few lookups we don't need.
latest_seen_view: Arc::new(AtomicU64::new(0)),
is_da,
}),
};

Expand Down Expand Up @@ -383,6 +388,7 @@ impl<M: NetworkMsg, K: SignatureKey + 'static> Libp2pNetwork<M, K> {
let is_bootstrapped = self.inner.is_bootstrapped.clone();
let node_type = self.inner.handle.config().node_type;
let metrics_connected_peers = self.inner.clone();
let is_da = self.inner.is_da;
async_spawn({
let is_ready = self.inner.is_ready.clone();
async move {
Expand Down Expand Up @@ -422,7 +428,12 @@ impl<M: NetworkMsg, K: SignatureKey + 'static> Libp2pNetwork<M, K> {
}

handle.subscribe(QC_TOPIC.to_string()).await.unwrap();
handle.subscribe("DA".to_string()).await.unwrap();

// only subscribe to DA events if we are DA
if is_da {
handle.subscribe("DA".to_string()).await.unwrap();
}

// TODO figure out some way of passing in ALL keypairs. That way we can add the
// global topic to the topic map
// NOTE this wont' work without this change
Expand Down