Skip to content

Commit ae9c6f6

Browse files
Merge branch 'main' into deployer-tech-debt
2 parents 619202a + 0f9da7c commit ae9c6f6

File tree

29 files changed

+1236
-913
lines changed

29 files changed

+1236
-913
lines changed

Cargo.lock

Lines changed: 825 additions & 822 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/hotshot/hotshot/src/traits/networking/combined_network.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,12 +358,11 @@ impl<TYPES: NodeType> ConnectedNetwork<TYPES::SignatureKey> for CombinedNetworks
358358
let secondary = self.secondary().clone();
359359
let primary_message = message.clone();
360360
let secondary_message = message.clone();
361-
let topic_clone = topic.clone();
362361
self.send_both_networks(
363362
message,
364363
async move {
365364
primary
366-
.broadcast_message(primary_message, topic_clone, BroadcastDelay::None)
365+
.broadcast_message(primary_message, topic, BroadcastDelay::None)
367366
.await
368367
},
369368
async move {

crates/hotshot/hotshot/src/traits/networking/libp2p_network.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,15 @@ impl<T: NodeType> ConnectedNetwork<T::SignatureKey> for Libp2pNetwork<T> {
853853
return Err(NetworkError::NoPeersYet);
854854
};
855855

856+
// If we are subscribed to the DA topic, send the message to ourselves first
857+
let topic = Topic::Da.to_string();
858+
if self.inner.subscribed_topics.contains(&topic) {
859+
self.inner.sender.try_send(message.clone()).map_err(|_| {
860+
self.inner.metrics.num_failed_messages.add(1);
861+
NetworkError::ShutDown
862+
})?;
863+
}
864+
856865
let future_results = recipients
857866
.into_iter()
858867
.map(|r| self.direct_message(message.clone(), r));

crates/hotshot/hotshot/src/traits/networking/memory_network.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl<K: SignatureKey> MemoryNetwork<K> {
153153
for topic in subscribed_topics {
154154
master_map
155155
.subscribed_map
156-
.entry(topic.clone())
156+
.entry(*topic)
157157
.or_default()
158158
.push((pub_key.clone(), mn.clone()));
159159
}

crates/hotshot/hotshot/src/traits/networking/push_cdn_network.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,17 @@ impl<K: SignatureKey + 'static> PushCdnNetwork<K> {
274274
/// - If we fail to serialize the message
275275
/// - If we fail to send the broadcast message.
276276
async fn broadcast_message(&self, message: Vec<u8>, topic: Topic) -> Result<(), NetworkError> {
277+
// If the message should also go to us, add it to the internal queue
278+
if self
279+
.client
280+
.subscribed_topics
281+
.read()
282+
.await
283+
.contains(&(topic.clone() as u8))
284+
{
285+
self.internal_queue.lock().push_back(message.clone());
286+
}
287+
277288
// If we're paused, don't send the message
278289
#[cfg(feature = "hotshot-testing")]
279290
if self.is_paused.load(Ordering::Relaxed) {
@@ -517,6 +528,8 @@ impl<K: SignatureKey + 'static> ConnectedNetwork<K> for PushCdnNetwork<K> {
517528
if self.is_paused.load(Ordering::Relaxed) {
518529
return Ok(());
519530
}
531+
532+
// Broadcast the message
520533
self.broadcast_message(message, topic.into())
521534
.await
522535
.inspect_err(|_e| {
@@ -540,6 +553,8 @@ impl<K: SignatureKey + 'static> ConnectedNetwork<K> for PushCdnNetwork<K> {
540553
if self.is_paused.load(Ordering::Relaxed) {
541554
return Ok(());
542555
}
556+
557+
// Broadcast the message
543558
self.broadcast_message(message, Topic::Da)
544559
.await
545560
.inspect_err(|_e| {

crates/hotshot/types/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ displaydoc = { version = "0.2.5", default-features = false }
3737
dyn-clone = "1.0.17"
3838
either = { workspace = true }
3939
futures = { workspace = true, features = ["alloc"] }
40+
generic-array = "1"
4041
hotshot-utils = { workspace = true }
4142
jf-advz = { workspace = true }
4243
jf-crhf = { workspace = true }

crates/hotshot/types/src/constants.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ pub const COMBINED_NETWORK_DELAY_DURATION: u64 = 5000;
3838
pub const REQUEST_DATA_DELAY: u64 = 5000;
3939

4040
/// Default channel size for consensus event sharing
41-
pub const EVENT_CHANNEL_SIZE: usize = 100_000;
41+
pub const EVENT_CHANNEL_SIZE: usize = 1_000;
4242

4343
/// Default channel size for HotShot -> application communication
44-
pub const EXTERNAL_EVENT_CHANNEL_SIZE: usize = 100_000;
44+
pub const EXTERNAL_EVENT_CHANNEL_SIZE: usize = 1_000;
4545

4646
/// Default values for the upgrade constants
4747
pub const DEFAULT_UPGRADE_CONSTANTS: UpgradeConstants = UpgradeConstants {

crates/hotshot/types/src/qc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use ark_std::{
1717
vec::Vec,
1818
};
1919
use bitvec::prelude::*;
20-
use digest::generic_array::GenericArray;
20+
use generic_array::GenericArray;
2121
use jf_signature::{AggregateableSignatureSchemes, SignatureError};
2222
use serde::{Deserialize, Serialize};
2323
use typenum::U32;

crates/hotshot/types/src/signature_key.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use alloy::primitives::U256;
1010
use ark_serialize::SerializationError;
1111
use bitvec::{slice::BitSlice, vec::BitVec};
12-
use digest::generic_array::GenericArray;
12+
use generic_array::GenericArray;
1313
use jf_signature::{
1414
bls_over_bn254::{BLSOverBN254CurveSignatureScheme, KeyPair, SignKey, VerKey},
1515
SignatureError, SignatureScheme,

crates/hotshot/types/src/traits/network.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ impl NetworkReliability for ChaosNetwork {
587587
}
588588

589589
/// Used when broadcasting messages
590-
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
590+
#[derive(Clone, Debug, PartialEq, Eq, Hash, Copy)]
591591
pub enum Topic {
592592
/// The `Global` topic goes out to all nodes
593593
Global,

0 commit comments

Comments
 (0)