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

[TECH_DEBT] Remove CommunicationChannel trait #2578

Merged
merged 12 commits into from
Feb 14, 2024
30 changes: 14 additions & 16 deletions crates/example-types/src/node_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ use crate::{
use hotshot::traits::{
election::static_committee::{StaticCommittee, StaticElectionConfig},
implementations::{
CombinedCommChannel, Libp2pCommChannel, MemoryCommChannel, MemoryStorage, WebCommChannel,
CombinedNetworks, Libp2pNetwork, MemoryNetwork, MemoryStorage, WebServerNetwork,
},
NodeImplementation,
};
use hotshot_types::{
data::ViewNumber, signature_key::BLSPubKey, traits::node_implementation::NodeType,
data::ViewNumber, message::Message, signature_key::BLSPubKey,
traits::node_implementation::NodeType,
};
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -65,34 +66,31 @@ pub struct CombinedImpl;
pub type StaticMembership = StaticCommittee<TestTypes>;

/// memory network
pub type StaticMemoryDAComm = MemoryCommChannel<TestTypes>;
pub type StaticMemoryDAComm =
MemoryNetwork<Message<TestTypes>, <TestTypes as NodeType>::SignatureKey>;

/// libp2p network
type StaticLibp2pDAComm = Libp2pCommChannel<TestTypes>;
type StaticLibp2pDAComm = Libp2pNetwork<Message<TestTypes>, <TestTypes as NodeType>::SignatureKey>;

/// web server network communication channel
type StaticWebDAComm = WebCommChannel<TestTypes>;
type StaticWebDAComm = WebServerNetwork<TestTypes>;

/// combined network
type StaticCombinedDAComm = CombinedCommChannel<TestTypes>;
type StaticCombinedDAComm = CombinedNetworks<TestTypes>;

/// memory comm channel
pub type StaticMemoryQuorumComm = MemoryCommChannel<TestTypes>;
pub type StaticMemoryQuorumComm =
MemoryNetwork<Message<TestTypes>, <TestTypes as NodeType>::SignatureKey>;

/// libp2p comm channel
type StaticLibp2pQuorumComm = Libp2pCommChannel<TestTypes>;
type StaticLibp2pQuorumComm =
Libp2pNetwork<Message<TestTypes>, <TestTypes as NodeType>::SignatureKey>;

/// web server comm channel
type StaticWebQuorumComm = WebCommChannel<TestTypes>;
type StaticWebQuorumComm = WebServerNetwork<TestTypes>;

/// combined network (libp2p + web server)
type StaticCombinedQuorumComm = CombinedCommChannel<TestTypes>;

/// memory network
pub type StaticMemoryViewSyncComm = MemoryCommChannel<TestTypes>;

/// memory network
pub type StaticMemoryVIDComm = MemoryCommChannel<TestTypes>;
type StaticCombinedQuorumComm = CombinedNetworks<TestTypes>;

impl NodeImplementation<TestTypes> for Libp2pImpl {
type Storage = MemoryStorage<TestTypes>;
Expand Down
24 changes: 8 additions & 16 deletions crates/examples/combined/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use tracing::{error, instrument};
use crate::{
infra::run_orchestrator,
infra::{ConfigArgs, OrchestratorArgs},
types::{DANetwork, NodeImpl, QuorumNetwork, VIDNetwork, ViewSyncNetwork},
types::{DANetwork, NodeImpl, QuorumNetwork},
};

/// general infra used for this example
Expand Down Expand Up @@ -78,8 +78,6 @@ async fn main() {
TestTypes,
DANetwork,
QuorumNetwork,
ViewSyncNetwork,
VIDNetwork,
NodeImpl,
>(OrchestratorArgs {
url: orchestrator_url.clone(),
Expand All @@ -96,19 +94,13 @@ async fn main() {
for _ in 0..config.config.total_nodes.into() {
let orchestrator_url = orchestrator_url.clone();
let node = async_spawn(async move {
infra::main_entry_point::<
TestTypes,
DANetwork,
QuorumNetwork,
ViewSyncNetwork,
VIDNetwork,
NodeImpl,
ThisRun,
>(ValidatorArgs {
url: orchestrator_url,
public_ip: Some(IpAddr::V4(Ipv4Addr::LOCALHOST)),
network_config_file: None,
})
infra::main_entry_point::<TestTypes, DANetwork, QuorumNetwork, NodeImpl, ThisRun>(
ValidatorArgs {
url: orchestrator_url,
public_ip: Some(IpAddr::V4(Ipv4Addr::LOCALHOST)),
network_config_file: None,
},
)
.await;
});
nodes.push(node);
Expand Down
15 changes: 4 additions & 11 deletions crates/examples/combined/multi-validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ use clap::Parser;
use hotshot_example_types::state_types::TestTypes;
use hotshot_orchestrator::client::{MultiValidatorArgs, ValidatorArgs};
use tracing::instrument;
use types::VIDNetwork;

use crate::types::{DANetwork, NodeImpl, QuorumNetwork, ThisRun, ViewSyncNetwork};
use crate::types::{DANetwork, NodeImpl, QuorumNetwork, ThisRun};

/// types used for this example
pub mod types;
Expand All @@ -34,15 +33,9 @@ async fn main() {
let args = args.clone();

let node = async_spawn(async move {
infra::main_entry_point::<
TestTypes,
DANetwork,
QuorumNetwork,
ViewSyncNetwork,
VIDNetwork,
NodeImpl,
ThisRun,
>(ValidatorArgs::from_multi_args(args, node_index))
infra::main_entry_point::<TestTypes, DANetwork, QuorumNetwork, NodeImpl, ThisRun>(
ValidatorArgs::from_multi_args(args, node_index),
)
.await;
});
nodes.push(node);
Expand Down
8 changes: 2 additions & 6 deletions crates/examples/combined/orchestrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ use async_compatibility_layer::logging::{setup_backtrace, setup_logging};
use clap::Parser;
use hotshot_example_types::state_types::TestTypes;
use tracing::instrument;
use types::VIDNetwork;

use crate::infra::run_orchestrator;
use crate::infra::OrchestratorArgs;
use crate::types::{DANetwork, NodeImpl, QuorumNetwork, ViewSyncNetwork};
use crate::types::{DANetwork, NodeImpl, QuorumNetwork};

/// general infra used for this example
#[path = "../infra/mod.rs"]
Expand All @@ -27,8 +26,5 @@ async fn main() {
setup_backtrace();
let args = OrchestratorArgs::parse();

run_orchestrator::<TestTypes, DANetwork, QuorumNetwork, ViewSyncNetwork, VIDNetwork, NodeImpl>(
args,
)
.await;
run_orchestrator::<TestTypes, DANetwork, QuorumNetwork, NodeImpl>(args).await;
}
10 changes: 5 additions & 5 deletions crates/examples/combined/types.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::infra::CombinedDARun;
use hotshot::traits::implementations::{CombinedCommChannel, MemoryStorage};
use hotshot::traits::implementations::{CombinedNetworks, MemoryStorage};
use hotshot_example_types::state_types::TestTypes;
use hotshot_types::traits::node_implementation::NodeImplementation;
use serde::{Deserialize, Serialize};
Expand All @@ -10,13 +10,13 @@ use std::fmt::Debug;
pub struct NodeImpl {}

/// convenience type alias
pub type DANetwork = CombinedCommChannel<TestTypes>;
pub type DANetwork = CombinedNetworks<TestTypes>;
/// convenience type alias
pub type VIDNetwork = CombinedCommChannel<TestTypes>;
pub type VIDNetwork = CombinedNetworks<TestTypes>;
/// convenience type alias
pub type QuorumNetwork = CombinedCommChannel<TestTypes>;
pub type QuorumNetwork = CombinedNetworks<TestTypes>;
/// convenience type alias
pub type ViewSyncNetwork = CombinedCommChannel<TestTypes>;
pub type ViewSyncNetwork = CombinedNetworks<TestTypes>;

impl NodeImplementation<TestTypes> for NodeImpl {
type Storage = MemoryStorage<TestTypes>;
Expand Down
14 changes: 2 additions & 12 deletions crates/examples/combined/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ use async_compatibility_layer::logging::{setup_backtrace, setup_logging};
use clap::Parser;
use hotshot_example_types::state_types::TestTypes;
use tracing::{info, instrument};
use types::VIDNetwork;

use crate::types::{DANetwork, NodeImpl, QuorumNetwork, ThisRun, ViewSyncNetwork};
use crate::types::{DANetwork, NodeImpl, QuorumNetwork, ThisRun};

use hotshot_orchestrator::client::ValidatorArgs;

Expand All @@ -27,14 +26,5 @@ async fn main() {
setup_backtrace();
let args = ValidatorArgs::parse();
info!("connecting to orchestrator at {:?}", args.url);
infra::main_entry_point::<
TestTypes,
DANetwork,
QuorumNetwork,
ViewSyncNetwork,
VIDNetwork,
NodeImpl,
ThisRun,
>(args)
.await;
infra::main_entry_point::<TestTypes, DANetwork, QuorumNetwork, NodeImpl, ThisRun>(args).await;
}
Loading