Skip to content

Commit

Permalink
VID task and exchange (#1903)
Browse files Browse the repository at this point in the history
* separate out vid task

* almost done :)

* fix vid test

* remove polling from vid

* lint

* fix merge conflicts

* Update crates/testing/tests/vid_task.rs

Co-authored-by: Gus Gutoski <[email protected]>

* Update crates/task-impls/src/vid.rs

Co-authored-by: Gus Gutoski <[email protected]>

* Update crates/task-impls/src/vid.rs

Co-authored-by: Gus Gutoski <[email protected]>

* pr comments

* clippy

Signed-off-by: Rob <[email protected]>

* separate out VID certificate

* add function for signing VID proposal

---------

Signed-off-by: Rob <[email protected]>
Co-authored-by: Gus Gutoski <[email protected]>
  • Loading branch information
rob-maron and ggutoski authored Oct 23, 2023
1 parent 454b5d2 commit d7b3c93
Show file tree
Hide file tree
Showing 29 changed files with 1,275 additions and 311 deletions.
54 changes: 53 additions & 1 deletion crates/hotshot/examples/infra/modDA.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use hotshot_orchestrator::{
config::{NetworkConfig, WebServerConfig},
};
use hotshot_task::task::FilterEvent;
use hotshot_types::traits::election::VIDExchange;
use hotshot_types::{
block_impl::{VIDBlockPayload, VIDTransaction},
certificate::ViewSyncCertificate,
Expand Down Expand Up @@ -85,6 +86,7 @@ pub async fn run_orchestrator_da<
DANETWORK: CommunicationChannel<TYPES, Message<TYPES, NODE>, MEMBERSHIP> + Debug,
QUORUMNETWORK: CommunicationChannel<TYPES, Message<TYPES, NODE>, MEMBERSHIP> + Debug,
VIEWSYNCNETWORK: CommunicationChannel<TYPES, Message<TYPES, NODE>, MEMBERSHIP> + Debug,
VIDNETWORK: CommunicationChannel<TYPES, Message<TYPES, NODE>, MEMBERSHIP> + Debug,
NODE: NodeImplementation<
TYPES,
Leaf = SequencingLeaf<TYPES>,
Expand All @@ -107,6 +109,7 @@ pub async fn run_orchestrator_da<
VIEWSYNCNETWORK,
Message<TYPES, NODE>,
>,
VIDExchange<TYPES, MEMBERSHIP, VIDNETWORK, Message<TYPES, NODE>>,
>,
Storage = MemoryStorage<TYPES, SequencingLeaf<TYPES>>,
ConsensusMessage = SequencingMessage<TYPES, NODE>,
Expand Down Expand Up @@ -148,6 +151,7 @@ pub trait RunDA<
DANETWORK: CommunicationChannel<TYPES, Message<TYPES, NODE>, MEMBERSHIP> + Debug,
QUORUMNETWORK: CommunicationChannel<TYPES, Message<TYPES, NODE>, MEMBERSHIP> + Debug,
VIEWSYNCNETWORK: CommunicationChannel<TYPES, Message<TYPES, NODE>, MEMBERSHIP> + Debug,
VIDNETWORK: CommunicationChannel<TYPES, Message<TYPES, NODE>, MEMBERSHIP> + Debug,
NODE: NodeImplementation<
TYPES,
Leaf = SequencingLeaf<TYPES>,
Expand All @@ -170,6 +174,7 @@ pub trait RunDA<
VIEWSYNCNETWORK,
Message<TYPES, NODE>,
>,
VIDExchange<TYPES, MEMBERSHIP, VIDNETWORK, Message<TYPES, NODE>>,
>,
Storage = MemoryStorage<TYPES, SequencingLeaf<TYPES>>,
ConsensusMessage = SequencingMessage<TYPES, NODE>,
Expand Down Expand Up @@ -213,6 +218,7 @@ pub trait RunDA<
let da_network = self.get_da_network();
let quorum_network = self.get_quorum_network();
let view_sync_network = self.get_view_sync_network();
let vid_network = self.get_vid_network();

// Since we do not currently pass the election config type in the NetworkConfig, this will always be the default election config
let quorum_election_config = config.config.election_config.clone().unwrap_or_else(|| {
Expand All @@ -236,6 +242,7 @@ pub trait RunDA<
quorum_network.clone(),
da_network.clone(),
view_sync_network.clone(),
vid_network.clone(),
),
pk.clone(),
entry.clone(),
Expand Down Expand Up @@ -367,6 +374,9 @@ pub trait RunDA<
///Returns view sync network for this run
fn get_view_sync_network(&self) -> VIEWSYNCNETWORK;

///Returns VID network for this run
fn get_vid_network(&self) -> VIDNETWORK;

/// Returns the config for this run
fn get_config(
&self,
Expand All @@ -393,6 +403,7 @@ pub struct WebServerDARun<
quorum_network: WebCommChannel<TYPES, I, MEMBERSHIP>,
da_network: WebCommChannel<TYPES, I, MEMBERSHIP>,
view_sync_network: WebCommChannel<TYPES, I, MEMBERSHIP>,
vid_network: WebCommChannel<TYPES, I, MEMBERSHIP>,
}

#[async_trait]
Expand Down Expand Up @@ -426,6 +437,12 @@ impl<
WebCommChannel<TYPES, NODE, MEMBERSHIP>,
Message<TYPES, NODE>,
>,
VIDExchange<
TYPES,
MEMBERSHIP,
WebCommChannel<TYPES, NODE, MEMBERSHIP>,
Message<TYPES, NODE>,
>,
>,
Storage = MemoryStorage<TYPES, SequencingLeaf<TYPES>>,
ConsensusMessage = SequencingMessage<TYPES, NODE>,
Expand All @@ -437,6 +454,7 @@ impl<
WebCommChannel<TYPES, NODE, MEMBERSHIP>,
WebCommChannel<TYPES, NODE, MEMBERSHIP>,
WebCommChannel<TYPES, NODE, MEMBERSHIP>,
WebCommChannel<TYPES, NODE, MEMBERSHIP>,
NODE,
> for WebServerDARun<TYPES, NODE, MEMBERSHIP>
where
Expand Down Expand Up @@ -489,6 +507,17 @@ where

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

let vid_network: WebCommChannel<TYPES, NODE, MEMBERSHIP> = WebCommChannel::new(
WebServerNetwork::create(&host.to_string(), port, wait_between_polls, pub_key, true)
.into(),
);
Expand All @@ -498,6 +527,7 @@ where
quorum_network,
da_network,
view_sync_network,
vid_network,
}
}

Expand All @@ -513,6 +543,10 @@ where
self.view_sync_network.clone()
}

fn get_vid_network(&self) -> WebCommChannel<TYPES, NODE, MEMBERSHIP> {
self.vid_network.clone()
}

fn get_config(
&self,
) -> NetworkConfig<
Expand All @@ -537,6 +571,7 @@ pub struct Libp2pDARun<TYPES: NodeType, I: NodeImplementation<TYPES>, MEMBERSHIP
quorum_network: Libp2pCommChannel<TYPES, I, MEMBERSHIP>,
da_network: Libp2pCommChannel<TYPES, I, MEMBERSHIP>,
view_sync_network: Libp2pCommChannel<TYPES, I, MEMBERSHIP>,
vid_network: Libp2pCommChannel<TYPES, I, MEMBERSHIP>,
}

#[async_trait]
Expand Down Expand Up @@ -570,6 +605,12 @@ impl<
Libp2pCommChannel<TYPES, NODE, MEMBERSHIP>,
Message<TYPES, NODE>,
>,
VIDExchange<
TYPES,
MEMBERSHIP,
Libp2pCommChannel<TYPES, NODE, MEMBERSHIP>,
Message<TYPES, NODE>,
>,
>,
Storage = MemoryStorage<TYPES, SequencingLeaf<TYPES>>,
ConsensusMessage = SequencingMessage<TYPES, NODE>,
Expand All @@ -581,6 +622,7 @@ impl<
Libp2pCommChannel<TYPES, NODE, MEMBERSHIP>,
Libp2pCommChannel<TYPES, NODE, MEMBERSHIP>,
Libp2pCommChannel<TYPES, NODE, MEMBERSHIP>,
Libp2pCommChannel<TYPES, NODE, MEMBERSHIP>,
NODE,
> for Libp2pDARun<TYPES, NODE, MEMBERSHIP>
where
Expand Down Expand Up @@ -722,11 +764,15 @@ where
let da_network: Libp2pCommChannel<TYPES, NODE, MEMBERSHIP> =
Libp2pCommChannel::new(underlying_quorum_network.clone().into());

let vid_network: Libp2pCommChannel<TYPES, NODE, MEMBERSHIP> =
Libp2pCommChannel::new(underlying_quorum_network.clone().into());

Libp2pDARun {
config,
quorum_network,
da_network,
view_sync_network,
vid_network,
}
}

Expand All @@ -742,6 +788,10 @@ where
self.view_sync_network.clone()
}

fn get_vid_network(&self) -> Libp2pCommChannel<TYPES, NODE, MEMBERSHIP> {
self.vid_network.clone()
}

fn get_config(
&self,
) -> NetworkConfig<
Expand All @@ -760,6 +810,7 @@ pub async fn main_entry_point<
DANETWORK: CommunicationChannel<TYPES, Message<TYPES, NODE>, MEMBERSHIP> + Debug,
QUORUMNETWORK: CommunicationChannel<TYPES, Message<TYPES, NODE>, MEMBERSHIP> + Debug,
VIEWSYNCNETWORK: CommunicationChannel<TYPES, Message<TYPES, NODE>, MEMBERSHIP> + Debug,
VIDNETWORK: CommunicationChannel<TYPES, Message<TYPES, NODE>, MEMBERSHIP> + Debug,
NODE: NodeImplementation<
TYPES,
Leaf = SequencingLeaf<TYPES>,
Expand All @@ -782,11 +833,12 @@ pub async fn main_entry_point<
VIEWSYNCNETWORK,
Message<TYPES, NODE>,
>,
VIDExchange<TYPES, MEMBERSHIP, VIDNETWORK, Message<TYPES, NODE>>,
>,
Storage = MemoryStorage<TYPES, SequencingLeaf<TYPES>>,
ConsensusMessage = SequencingMessage<TYPES, NODE>,
>,
RUNDA: RunDA<TYPES, MEMBERSHIP, DANETWORK, QUORUMNETWORK, VIEWSYNCNETWORK, NODE>,
RUNDA: RunDA<TYPES, MEMBERSHIP, DANETWORK, QUORUMNETWORK, VIEWSYNCNETWORK, VIDNETWORK, NODE>,
>(
args: ValidatorArgs,
) where
Expand Down
2 changes: 2 additions & 0 deletions crates/hotshot/examples/libp2p/multi-validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use hotshot::demo::DemoTypes;
use hotshot_orchestrator::client::ValidatorArgs;
use std::net::IpAddr;
use tracing::instrument;
use types::VIDNetwork;

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

Expand Down Expand Up @@ -54,6 +55,7 @@ async fn main() {
DANetwork,
QuorumNetwork,
ViewSyncNetwork,
VIDNetwork,
NodeImpl,
ThisRun,
>(ValidatorArgs {
Expand Down
3 changes: 2 additions & 1 deletion crates/hotshot/examples/libp2p/orchestrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use types::ThisMembership;
use crate::{
infra::OrchestratorArgs,
infra_da::run_orchestrator_da,
types::{DANetwork, NodeImpl, QuorumNetwork, ViewSyncNetwork},
types::{DANetwork, NodeImpl, QuorumNetwork, VIDNetwork, ViewSyncNetwork},
};

#[path = "../infra/mod.rs"]
Expand All @@ -34,6 +34,7 @@ async fn main() {
DANetwork,
QuorumNetwork,
ViewSyncNetwork,
VIDNetwork,
NodeImpl,
>(args)
.await;
Expand Down
4 changes: 3 additions & 1 deletion crates/hotshot/examples/libp2p/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use hotshot_types::{
data::{DAProposal, QuorumProposal, SequencingLeaf},
message::{Message, SequencingMessage},
traits::{
election::{CommitteeExchange, QuorumExchange, ViewSyncExchange},
election::{CommitteeExchange, QuorumExchange, VIDExchange, ViewSyncExchange},
node_implementation::{ChannelMaps, NodeImplementation, NodeType, SequencingExchanges},
},
vote::{DAVote, QuorumVote, ViewSyncVote},
Expand All @@ -26,6 +26,7 @@ pub type ThisLeaf = SequencingLeaf<DemoTypes>;
pub type ThisMembership =
GeneralStaticCommittee<DemoTypes, ThisLeaf, <DemoTypes as NodeType>::SignatureKey>;
pub type DANetwork = Libp2pCommChannel<DemoTypes, NodeImpl, ThisMembership>;
pub type VIDNetwork = Libp2pCommChannel<DemoTypes, NodeImpl, ThisMembership>;
pub type QuorumNetwork = Libp2pCommChannel<DemoTypes, NodeImpl, ThisMembership>;
pub type ViewSyncNetwork = Libp2pCommChannel<DemoTypes, NodeImpl, ThisMembership>;

Expand Down Expand Up @@ -60,6 +61,7 @@ impl NodeImplementation<DemoTypes> for NodeImpl {
ViewSyncNetwork,
Message<DemoTypes, Self>,
>,
VIDExchange<DemoTypes, ThisMembership, VIDNetwork, Message<DemoTypes, Self>>,
>;
type ConsensusMessage = SequencingMessage<DemoTypes, Self>;

Expand Down
2 changes: 2 additions & 0 deletions crates/hotshot/examples/libp2p/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use async_compatibility_layer::logging::{setup_backtrace, setup_logging};
use clap::Parser;
use hotshot::demo::DemoTypes;
use tracing::{info, instrument};
use types::VIDNetwork;

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

Expand Down Expand Up @@ -34,6 +35,7 @@ async fn main() {
DANetwork,
QuorumNetwork,
ViewSyncNetwork,
VIDNetwork,
NodeImpl,
ThisRun,
>(args)
Expand Down
2 changes: 2 additions & 0 deletions crates/hotshot/examples/web-server-da/multi-validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use hotshot::demo::DemoTypes;
use hotshot_orchestrator::client::ValidatorArgs;
use std::net::IpAddr;
use tracing::instrument;
use types::VIDNetwork;

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

Expand Down Expand Up @@ -54,6 +55,7 @@ async fn main() {
DANetwork,
QuorumNetwork,
ViewSyncNetwork,
VIDNetwork,
NodeImpl,
ThisRun,
>(ValidatorArgs {
Expand Down
3 changes: 2 additions & 1 deletion crates/hotshot/examples/web-server-da/orchestrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use async_compatibility_layer::logging::{setup_backtrace, setup_logging};
use clap::Parser;
use hotshot::demo::DemoTypes;
use tracing::instrument;
use types::ThisMembership;
use types::{ThisMembership, VIDNetwork};

use crate::{
infra::OrchestratorArgs,
Expand Down Expand Up @@ -34,6 +34,7 @@ async fn main() {
DANetwork,
QuorumNetwork,
ViewSyncNetwork,
VIDNetwork,
NodeImpl,
>(args)
.await;
Expand Down
4 changes: 3 additions & 1 deletion crates/hotshot/examples/web-server-da/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use hotshot_types::{
data::{DAProposal, QuorumProposal, SequencingLeaf},
message::{Message, SequencingMessage},
traits::{
election::{CommitteeExchange, QuorumExchange, ViewSyncExchange},
election::{CommitteeExchange, QuorumExchange, VIDExchange, ViewSyncExchange},
node_implementation::{ChannelMaps, NodeImplementation, NodeType, SequencingExchanges},
},
vote::{DAVote, QuorumVote, ViewSyncVote},
Expand All @@ -26,6 +26,7 @@ pub type ThisLeaf = SequencingLeaf<DemoTypes>;
pub type ThisMembership =
GeneralStaticCommittee<DemoTypes, ThisLeaf, <DemoTypes as NodeType>::SignatureKey>;
pub type DANetwork = WebCommChannel<DemoTypes, NodeImpl, ThisMembership>;
pub type VIDNetwork = WebCommChannel<DemoTypes, NodeImpl, ThisMembership>;
pub type QuorumNetwork = WebCommChannel<DemoTypes, NodeImpl, ThisMembership>;
pub type ViewSyncNetwork = WebCommChannel<DemoTypes, NodeImpl, ThisMembership>;

Expand Down Expand Up @@ -60,6 +61,7 @@ impl NodeImplementation<DemoTypes> for NodeImpl {
ViewSyncNetwork,
Message<DemoTypes, Self>,
>,
VIDExchange<DemoTypes, ThisMembership, VIDNetwork, Message<DemoTypes, Self>>,
>;
type ConsensusMessage = SequencingMessage<DemoTypes, Self>;

Expand Down
2 changes: 2 additions & 0 deletions crates/hotshot/examples/web-server-da/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use async_compatibility_layer::logging::{setup_backtrace, setup_logging};
use clap::Parser;
use hotshot::demo::DemoTypes;
use tracing::{info, instrument};
use types::VIDNetwork;

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

Expand Down Expand Up @@ -34,6 +35,7 @@ async fn main() {
DANetwork,
QuorumNetwork,
ViewSyncNetwork,
VIDNetwork,
NodeImpl,
ThisRun,
>(args)
Expand Down
Loading

0 comments on commit d7b3c93

Please sign in to comment.