Skip to content

Commit

Permalink
Lints
Browse files Browse the repository at this point in the history
  • Loading branch information
elliedavidson committed Sep 12, 2023
1 parent 3a7146f commit 149a404
Show file tree
Hide file tree
Showing 20 changed files with 199 additions and 395 deletions.
157 changes: 26 additions & 131 deletions crates/hotshot/examples/infra/modDA.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use hotshot_orchestrator::{
use hotshot_task::task::FilterEvent;
use hotshot_types::{
certificate::ViewSyncCertificate,
data::{DAProposal, QuorumProposal, SequencingLeaf, TestableLeaf},
data::{QuorumProposal, SequencingLeaf, TestableLeaf},
event::{Event, EventType},
message::{Message, SequencingMessage},
traits::{
Expand All @@ -33,7 +33,6 @@ use hotshot_types::{
},
state::{ConsensusTime, TestableBlock, TestableState},
},
vote::{DAVote, QuorumVote, ViewSyncVote},
HotShotConfig,
};
// use libp2p::{
Expand Down Expand Up @@ -67,27 +66,9 @@ use tracing::{debug, error, info, warn};
pub async fn run_orchestrator_da<
TYPES: NodeType,
MEMBERSHIP: Membership<TYPES> + Debug,
DANETWORK: CommunicationChannel<
TYPES,
Message<TYPES, NODE>,
DAProposal<TYPES>,
DAVote<TYPES>,
MEMBERSHIP,
> + Debug,
QUORUMNETWORK: CommunicationChannel<
TYPES,
Message<TYPES, NODE>,
QuorumProposal<TYPES, SequencingLeaf<TYPES>>,
QuorumVote<TYPES, SequencingLeaf<TYPES>>,
MEMBERSHIP,
> + Debug,
VIEWSYNCNETWORK: CommunicationChannel<
TYPES,
Message<TYPES, NODE>,
ViewSyncCertificate<TYPES>,
ViewSyncVote<TYPES>,
MEMBERSHIP,
> + Debug,
DANETWORK: CommunicationChannel<TYPES, Message<TYPES, NODE>, MEMBERSHIP> + Debug,
QUORUMNETWORK: CommunicationChannel<TYPES, Message<TYPES, NODE>, MEMBERSHIP> + Debug,
VIEWSYNCNETWORK: CommunicationChannel<TYPES, Message<TYPES, NODE>, MEMBERSHIP> + Debug,
NODE: NodeImplementation<
TYPES,
Leaf = SequencingLeaf<TYPES>,
Expand Down Expand Up @@ -135,27 +116,9 @@ pub async fn run_orchestrator_da<
pub trait RunDA<
TYPES: NodeType,
MEMBERSHIP: Membership<TYPES> + Debug,
DANETWORK: CommunicationChannel<
TYPES,
Message<TYPES, NODE>,
DAProposal<TYPES>,
DAVote<TYPES>,
MEMBERSHIP,
> + Debug,
QUORUMNETWORK: CommunicationChannel<
TYPES,
Message<TYPES, NODE>,
QuorumProposal<TYPES, SequencingLeaf<TYPES>>,
QuorumVote<TYPES, SequencingLeaf<TYPES>>,
MEMBERSHIP,
> + Debug,
VIEWSYNCNETWORK: CommunicationChannel<
TYPES,
Message<TYPES, NODE>,
ViewSyncCertificate<TYPES>,
ViewSyncVote<TYPES>,
MEMBERSHIP,
> + Debug,
DANETWORK: CommunicationChannel<TYPES, Message<TYPES, NODE>, MEMBERSHIP> + Debug,
QUORUMNETWORK: CommunicationChannel<TYPES, Message<TYPES, NODE>, MEMBERSHIP> + Debug,
VIEWSYNCNETWORK: CommunicationChannel<TYPES, Message<TYPES, NODE>, MEMBERSHIP> + Debug,
NODE: NodeImplementation<
TYPES,
Leaf = SequencingLeaf<TYPES>,
Expand Down Expand Up @@ -416,21 +379,13 @@ pub trait RunDA<
// WEB SERVER

/// Alias for the [`WebCommChannel`] for sequencing consensus.
type StaticDAComm<TYPES, I, MEMBERSHIP> =
WebCommChannel<TYPES, I, DAProposal<TYPES>, DAVote<TYPES>, MEMBERSHIP>;
type StaticDAComm<TYPES, I, MEMBERSHIP> = WebCommChannel<TYPES, I, MEMBERSHIP>;

/// Alias for the ['WebCommChannel'] for validating consensus
type StaticQuorumComm<TYPES, I, MEMBERSHIP> = WebCommChannel<
TYPES,
I,
QuorumProposal<TYPES, SequencingLeaf<TYPES>>,
QuorumVote<TYPES, SequencingLeaf<TYPES>>,
MEMBERSHIP,
>;
type StaticQuorumComm<TYPES, I, MEMBERSHIP> = WebCommChannel<TYPES, I, MEMBERSHIP>;

/// Alias for the ['WebCommChannel'] for view sync consensus
type StaticViewSyncComm<TYPES, I, MEMBERSHIP> =
WebCommChannel<TYPES, I, ViewSyncCertificate<TYPES>, ViewSyncVote<TYPES>, MEMBERSHIP>;
type StaticViewSyncComm<TYPES, I, MEMBERSHIP> = WebCommChannel<TYPES, I, MEMBERSHIP>;

/// Represents a web server-based run
pub struct WebServerDARun<
Expand Down Expand Up @@ -463,32 +418,20 @@ impl<
SequencingLeaf<TYPES>,
QuorumProposal<TYPES, SequencingLeaf<TYPES>>,
MEMBERSHIP,
WebCommChannel<
TYPES,
NODE,
QuorumProposal<TYPES, SequencingLeaf<TYPES>>,
QuorumVote<TYPES, SequencingLeaf<TYPES>>,
MEMBERSHIP,
>,
WebCommChannel<TYPES, NODE, MEMBERSHIP>,
Message<TYPES, NODE>,
>,
CommitteeExchange<
TYPES,
MEMBERSHIP,
WebCommChannel<TYPES, NODE, DAProposal<TYPES>, DAVote<TYPES>, MEMBERSHIP>,
WebCommChannel<TYPES, NODE, MEMBERSHIP>,
Message<TYPES, NODE>,
>,
ViewSyncExchange<
TYPES,
ViewSyncCertificate<TYPES>,
MEMBERSHIP,
WebCommChannel<
TYPES,
NODE,
ViewSyncCertificate<TYPES>,
ViewSyncVote<TYPES>,
MEMBERSHIP,
>,
WebCommChannel<TYPES, NODE, MEMBERSHIP>,
Message<TYPES, NODE>,
>,
>,
Expand Down Expand Up @@ -540,21 +483,11 @@ where
);

// Create the network
let quorum_network: WebCommChannel<
TYPES,
NODE,
QuorumProposal<TYPES, SequencingLeaf<TYPES>>,
QuorumVote<TYPES, SequencingLeaf<TYPES>>,
MEMBERSHIP,
> = WebCommChannel::new(underlying_quorum_network.clone().into());
let quorum_network: WebCommChannel<TYPES, NODE, MEMBERSHIP> =
WebCommChannel::new(underlying_quorum_network.clone().into());

let view_sync_network: WebCommChannel<
TYPES,
NODE,
ViewSyncCertificate<TYPES>,
ViewSyncVote<TYPES>,
MEMBERSHIP,
> = WebCommChannel::new(underlying_quorum_network.into());
let view_sync_network: WebCommChannel<TYPES, NODE, MEMBERSHIP> =
WebCommChannel::new(underlying_quorum_network.into());

let WebServerConfig {
host,
Expand All @@ -563,17 +496,10 @@ where
}: WebServerConfig = config.clone().da_web_server_config.unwrap();

// Each node runs the DA network so that leaders have access to transactions and DA votes
let da_network: WebCommChannel<TYPES, NODE, DAProposal<TYPES>, DAVote<TYPES>, MEMBERSHIP> =
WebCommChannel::new(
WebServerNetwork::create(
&host.to_string(),
port,
wait_between_polls,
pub_key,
true,
)
let da_network: WebCommChannel<TYPES, NODE, MEMBERSHIP> = WebCommChannel::new(
WebServerNetwork::create(&host.to_string(), port, wait_between_polls, pub_key, true)
.into(),
);
);

WebServerDARun {
config,
Expand All @@ -583,28 +509,15 @@ where
}
}

fn get_da_network(
&self,
) -> WebCommChannel<TYPES, NODE, DAProposal<TYPES>, DAVote<TYPES>, MEMBERSHIP> {
fn get_da_network(&self) -> WebCommChannel<TYPES, NODE, MEMBERSHIP> {
self.da_network.clone()
}

fn get_quorum_network(
&self,
) -> WebCommChannel<
TYPES,
NODE,
QuorumProposal<TYPES, SequencingLeaf<TYPES>>,
QuorumVote<TYPES, SequencingLeaf<TYPES>>,
MEMBERSHIP,
> {
fn get_quorum_network(&self) -> WebCommChannel<TYPES, NODE, MEMBERSHIP> {
self.quorum_network.clone()
}

fn get_view_sync_network(
&self,
) -> WebCommChannel<TYPES, NODE, ViewSyncCertificate<TYPES>, ViewSyncVote<TYPES>, MEMBERSHIP>
{
fn get_view_sync_network(&self) -> WebCommChannel<TYPES, NODE, MEMBERSHIP> {
self.view_sync_network.clone()
}

Expand All @@ -623,27 +536,9 @@ where
pub async fn main_entry_point<
TYPES: NodeType,
MEMBERSHIP: Membership<TYPES> + Debug,
DANETWORK: CommunicationChannel<
TYPES,
Message<TYPES, NODE>,
DAProposal<TYPES>,
DAVote<TYPES>,
MEMBERSHIP,
> + Debug,
QUORUMNETWORK: CommunicationChannel<
TYPES,
Message<TYPES, NODE>,
QuorumProposal<TYPES, SequencingLeaf<TYPES>>,
QuorumVote<TYPES, SequencingLeaf<TYPES>>,
MEMBERSHIP,
> + Debug,
VIEWSYNCNETWORK: CommunicationChannel<
TYPES,
Message<TYPES, NODE>,
ViewSyncCertificate<TYPES>,
ViewSyncVote<TYPES>,
MEMBERSHIP,
> + Debug,
DANETWORK: CommunicationChannel<TYPES, Message<TYPES, NODE>, MEMBERSHIP> + Debug,
QUORUMNETWORK: CommunicationChannel<TYPES, Message<TYPES, NODE>, MEMBERSHIP> + Debug,
VIEWSYNCNETWORK: CommunicationChannel<TYPES, Message<TYPES, NODE>, MEMBERSHIP> + Debug,
NODE: NodeImplementation<
TYPES,
Leaf = SequencingLeaf<TYPES>,
Expand Down
9 changes: 3 additions & 6 deletions crates/hotshot/examples/web-server-da/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,9 @@ pub struct NodeImpl {}
pub type ThisLeaf = SequencingLeaf<SDemoTypes>;
pub type ThisMembership =
GeneralStaticCommittee<SDemoTypes, ThisLeaf, <SDemoTypes as NodeType>::SignatureKey>;
pub type DANetwork =
WebCommChannel<SDemoTypes, NodeImpl, ThisDAProposal, ThisDAVote, ThisMembership>;
pub type QuorumNetwork =
WebCommChannel<SDemoTypes, NodeImpl, ThisQuorumProposal, ThisQuorumVote, ThisMembership>;
pub type ViewSyncNetwork =
WebCommChannel<SDemoTypes, NodeImpl, ThisViewSyncProposal, ThisViewSyncVote, ThisMembership>;
pub type DANetwork = WebCommChannel<SDemoTypes, NodeImpl, ThisMembership>;
pub type QuorumNetwork = WebCommChannel<SDemoTypes, NodeImpl, ThisMembership>;
pub type ViewSyncNetwork = WebCommChannel<SDemoTypes, NodeImpl, ThisMembership>;

pub type ThisDAProposal = DAProposal<SDemoTypes>;
pub type ThisDAVote = DAVote<SDemoTypes>;
Expand Down
19 changes: 5 additions & 14 deletions crates/hotshot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ use hotshot_task_impls::{events::SequencingHotShotEvent, network::NetworkTaskKin
use hotshot_types::{
certificate::{DACertificate, ViewSyncCertificate},
consensus::{BlockStore, Consensus, ConsensusMetrics, View, ViewInner, ViewQueue},
data::{DAProposal, DeltasType, LeafType, ProposalType, QuorumProposal, SequencingLeaf},
data::{DAProposal, DeltasType, LeafType, QuorumProposal, SequencingLeaf},
error::StorageSnafu,
message::{
ConsensusMessageType, DataMessage, InternalTrigger, Message, MessageKind,
Expand All @@ -79,7 +79,7 @@ use hotshot_types::{
storage::StoredView,
State,
},
vote::{ViewSyncData, VoteType},
vote::ViewSyncData,
HotShotConfig,
};
use snafu::ResultExt;
Expand Down Expand Up @@ -936,10 +936,7 @@ impl<
I: NodeImplementation<TYPES, ConsensusMessage = SequencingMessage<TYPES, I>>,
> SequencingConsensusApi<TYPES, I::Leaf, I> for HotShotSequencingConsensusApi<TYPES, I>
{
async fn send_direct_message<
PROPOSAL: ProposalType<NodeType = TYPES>,
VOTE: VoteType<TYPES>,
>(
async fn send_direct_message(
&self,
recipient: TYPES::SignatureKey,
message: SequencingMessage<TYPES, I>,
Expand All @@ -964,10 +961,7 @@ impl<
Ok(())
}

async fn send_direct_da_message<
PROPOSAL: ProposalType<NodeType = TYPES>,
VOTE: VoteType<TYPES>,
>(
async fn send_direct_da_message(
&self,
recipient: TYPES::SignatureKey,
message: SequencingMessage<TYPES, I>,
Expand All @@ -994,10 +988,7 @@ impl<

// TODO (DA) Refactor ConsensusApi and HotShot to use SystemContextInner directly.
// <https://github.com/EspressoSystems/HotShot/issues/1194>
async fn send_broadcast_message<
PROPOSAL: ProposalType<NodeType = TYPES>,
VOTE: VoteType<TYPES>,
>(
async fn send_broadcast_message(
&self,
message: SequencingMessage<TYPES, I>,
) -> std::result::Result<(), NetworkError> {
Expand Down
Loading

0 comments on commit 149a404

Please sign in to comment.