From 05da47bd5bf60deefaaa479f191654649419c9d6 Mon Sep 17 00:00:00 2001 From: Justin Restivo Date: Sun, 31 Dec 2023 14:06:20 -0500 Subject: [PATCH 1/5] feat: compiling view sync task --- crates/testing/src/completion_task.rs | 4 +- crates/testing/src/lib.rs | 3 + crates/testing/src/test_builder.rs | 31 +++++-- crates/testing/src/test_launcher.rs | 19 ++++- crates/testing/src/test_runner.rs | 16 +++- crates/testing/src/view_sync_task.rs | 114 ++++++++++++++++++++++++++ 6 files changed, 172 insertions(+), 15 deletions(-) create mode 100644 crates/testing/src/view_sync_task.rs diff --git a/crates/testing/src/completion_task.rs b/crates/testing/src/completion_task.rs index 669148682d..241b84e27b 100644 --- a/crates/testing/src/completion_task.rs +++ b/crates/testing/src/completion_task.rs @@ -19,11 +19,11 @@ use super::{test_launcher::TaskGenerator, GlobalTestEvent}; /// the idea here is to run as long as we want -/// Data Availability task error +/// Completion Task error #[derive(Snafu, Debug)] pub struct CompletionTaskErr {} -/// Data availability task state +/// Completion task state pub struct CompletionTask> { pub(crate) test_event_stream: ChannelStream, pub(crate) handles: Vec>, diff --git a/crates/testing/src/lib.rs b/crates/testing/src/lib.rs index 7e39871ed1..48426a2f7b 100644 --- a/crates/testing/src/lib.rs +++ b/crates/testing/src/lib.rs @@ -30,6 +30,9 @@ pub mod completion_task; /// task to spin nodes up and down pub mod spinning_task; +/// task for checking if view sync got activated +pub mod view_sync_task; + /// block types pub mod block_types; diff --git a/crates/testing/src/test_builder.rs b/crates/testing/src/test_builder.rs index e858816e3f..af51ac9c09 100644 --- a/crates/testing/src/test_builder.rs +++ b/crates/testing/src/test_builder.rs @@ -12,7 +12,7 @@ use hotshot_types::{ use super::completion_task::{CompletionTaskDescription, TimeBasedCompletionTaskDescription}; use crate::{ spinning_task::SpinningTaskDescription, - test_launcher::{ResourceGenerators, TestLauncher}, + test_launcher::{ResourceGenerators, TestLauncher}, view_sync_task::ViewSyncTaskDescription, }; use super::{ @@ -58,6 +58,8 @@ pub struct TestMetadata { pub min_transactions: usize, /// timing data pub timing_data: TimingData, + /// view sync check task + pub view_sync_properties: ViewSyncTaskDescription } impl Default for TimingData { @@ -75,10 +77,11 @@ impl Default for TimingData { impl TestMetadata { pub fn default_stress() -> Self { + let num_nodes = 100; TestMetadata { num_bootstrap_nodes: 15, - total_nodes: 100, - start_nodes: 100, + total_nodes: num_nodes, + start_nodes: num_nodes, overall_safety_properties: OverallSafetyPropertiesDescription { num_successful_views: 50, check_leaf: true, @@ -95,14 +98,16 @@ impl TestMetadata { round_start_delay: 25, ..TimingData::default() }, + view_sync_properties: ViewSyncTaskDescription::Threshold(0, num_nodes), ..TestMetadata::default() } } pub fn default_multiple_rounds() -> TestMetadata { + let num_nodes = 10; TestMetadata { - total_nodes: 10, - start_nodes: 10, + total_nodes: num_nodes, + start_nodes: num_nodes, overall_safety_properties: OverallSafetyPropertiesDescription { num_successful_views: 20, check_leaf: true, @@ -117,15 +122,17 @@ impl TestMetadata { round_start_delay: 25, ..TimingData::default() }, + view_sync_properties: ViewSyncTaskDescription::Threshold(0, num_nodes), ..TestMetadata::default() } } /// Default setting with 20 nodes and 8 views of successful views. pub fn default_more_nodes() -> TestMetadata { + let num_nodes = 20; TestMetadata { - total_nodes: 20, - start_nodes: 20, + total_nodes: num_nodes, + start_nodes: num_nodes, num_bootstrap_nodes: 20, // The first 14 (i.e., 20 - f) nodes are in the DA committee and we may shutdown the // remaining 6 (i.e., f) nodes. We could remove this restriction after fixing the @@ -146,6 +153,7 @@ impl TestMetadata { next_view_timeout: 5000, ..TimingData::default() }, + view_sync_properties: ViewSyncTaskDescription::Threshold(0, num_nodes), ..TestMetadata::default() } } @@ -154,11 +162,12 @@ impl TestMetadata { impl Default for TestMetadata { /// by default, just a single round fn default() -> Self { + let num_nodes = 5; Self { timing_data: TimingData::default(), min_transactions: 0, - total_nodes: 5, - start_nodes: 5, + total_nodes: num_nodes, + start_nodes: num_nodes, num_bootstrap_nodes: 5, da_committee_size: 5, spinning_properties: SpinningTaskDescription { @@ -173,6 +182,7 @@ impl Default for TestMetadata { duration: Duration::from_millis(10000), }, ), + view_sync_properties: ViewSyncTaskDescription::Threshold(0, num_nodes) } } } @@ -195,6 +205,7 @@ impl TestMetadata { completion_task_description, overall_safety_properties, spinning_properties, + view_sync_properties, .. } = self.clone(); @@ -263,6 +274,7 @@ impl TestMetadata { let completion_task_generator = completion_task_description.build_and_launch(); let overall_safety_task_generator = overall_safety_properties.build(); let spinning_task_generator = spinning_properties.build(); + let view_sync_task_generator = view_sync_properties.build(); TestLauncher { resource_generator: ResourceGenerators { channel_generator: >::gen_comm_channels( @@ -278,6 +290,7 @@ impl TestMetadata { overall_safety_task_generator, completion_task_generator, spinning_task_generator, + view_sync_task_generator, hooks: vec![], } .modify_default_config(mod_config) diff --git a/crates/testing/src/test_launcher.rs b/crates/testing/src/test_launcher.rs index 3771eb841f..4a58df5009 100644 --- a/crates/testing/src/test_launcher.rs +++ b/crates/testing/src/test_launcher.rs @@ -10,7 +10,7 @@ use hotshot_task::{ }; use hotshot_types::{traits::node_implementation::NodeType, HotShotConfig}; -use crate::spinning_task::SpinningTask; +use crate::{spinning_task::SpinningTask, view_sync_task::ViewSyncTask}; use super::{ completion_task::CompletionTask, overall_safety_task::OverallSafetyTask, @@ -71,9 +71,11 @@ pub struct TestLauncher> { pub completion_task_generator: TaskGenerator>, /// overall safety task generator pub overall_safety_task_generator: TaskGenerator>, - + /// task for spinning nodes up/down pub spinning_task_generator: TaskGenerator>, - + /// task for view sync + pub view_sync_task_generator: TaskGenerator>, + /// extra hooks in case we want to check additional things pub hooks: Vec, } @@ -133,6 +135,17 @@ impl> TestLauncher>, + ) -> Self { + Self { + view_sync_task_generator, + ..self + } + } + /// override resource generators pub fn with_resource_generator(self, resource_generator: ResourceGenerators) -> Self { Self { diff --git a/crates/testing/src/test_runner.rs b/crates/testing/src/test_runner.rs index 515d4a8787..4d46256971 100644 --- a/crates/testing/src/test_runner.rs +++ b/crates/testing/src/test_runner.rs @@ -5,7 +5,7 @@ use super::{ }; use crate::{ spinning_task::{ChangeNode, UpDown}, - test_launcher::{Networks, TestLauncher}, + test_launcher::{Networks, TestLauncher}, view_sync_task::ViewSyncTask, }; use hotshot::{types::SystemContextHandle, Memberships}; @@ -146,6 +146,20 @@ where .await; task_runner = task_runner.add_task(id, "Test Overall Safety Task".to_string(), task); + /// add view sync task + let view_sync_task_state = ViewSyncTask { + test_event_stream: test_event_stream.clone(), + handles: nodes.clone(), + hit_view_sync: HashMap::new(), + }; + + let (id, task) = (launcher.view_sync_task_generator)( + view_sync_task_state, + registry.clone(), + test_event_stream.clone(), + ).await; + task_runner = task_runner.add_task(id, "View Sync Task".to_string(), task); + // wait for networks to be ready for node in &nodes { node.networks.0.wait_for_ready().await; diff --git a/crates/testing/src/view_sync_task.rs b/crates/testing/src/view_sync_task.rs new file mode 100644 index 0000000000..e99329e998 --- /dev/null +++ b/crates/testing/src/view_sync_task.rs @@ -0,0 +1,114 @@ +use std::{sync::Arc, collections::{HashSet, HashMap}}; +use futures::FutureExt; +use hotshot_task::task::HotShotTaskTypes; +use async_compatibility_layer::channel::UnboundedStream; +use hotshot_task::{task_impls::{TaskBuilder, HSTWithEventAndMessage}, task::{FilterEvent, HandleMessage, HandleEvent, TS}, MergeN, event_stream::ChannelStream}; +use hotshot_task_impls::events::HotShotEvent; +use hotshot_types::traits::node_implementation::{TestableNodeImplementation, NodeType}; +use snafu::Snafu; + +use crate::{test_launcher::TaskGenerator, test_runner::Node, GlobalTestEvent}; + +/// ViewSync Task error +#[derive(Snafu, Debug)] +pub struct ViewSyncTaskErr {} + +/// ViewSync task state +pub struct ViewSyncTask> { + /// the global event stream + pub(crate) test_event_stream: ChannelStream, + /// the node handles + pub(crate) handles: Vec>, + /// nodes that hit view sync + pub(crate) hit_view_sync: HashMap::Time> +} + +impl> TS for ViewSyncTask {} + +/// ViewSync task types +pub type ViewSyncTaskTypes = HSTWithEventAndMessage< + ViewSyncTaskErr, + GlobalTestEvent, + ChannelStream, + (usize, HotShotEvent), + MergeN>>, + ViewSyncTask, +>; + +#[derive(Clone, Debug, Copy)] +pub enum ShouldHitViewSync { + /// the node should hit view sync + Yes, + /// the node should not hit view sync + No, + /// don't care if the node should hit view sync + DontCare +} + +/// Description for a view sync task. +#[derive(Clone, Debug)] +pub enum ViewSyncTaskDescription { + /// (min, max) number nodes that may hit view sync, inclusive + Threshold(usize, usize), + /// node idx -> whether or not the node should hit view sync + /// if node not in map, assumed to be `ShouldHItViewSync::DontCare` + Precise(HashMap) +} + +impl ViewSyncTaskDescription { + pub fn build>( + self, + ) -> TaskGenerator> { + Box::new(move |mut state, mut registry, test_event_stream| { + async move { + + let event_handler = HandleEvent::>(Arc::new(move |event, state| { + async move { + match event { + GlobalTestEvent::ShutDown => { + todo!() + // logic checking stuff + } + } + }.boxed() + + })); + + let message_handler = HandleMessage::>(Arc::new( + move |msg, mut state| { + todo!() + } + )); + let mut streams = vec![]; + for handle in &mut state.handles { + let stream = handle.handle.get_internal_event_stream_known_impl(FilterEvent::default()).await.0; + streams.push(stream); + } + + let builder = TaskBuilder::>::new( + "Test Completion Task".to_string(), + ) + .register_event_stream(test_event_stream, FilterEvent::default()) + .await + .register_registry(&mut registry) + .await + .register_state(state) + .register_event_handler(event_handler) + .register_message_handler(message_handler) + .register_message_stream(MergeN::new(streams)); + let task_id = builder.get_task_id().unwrap(); + (task_id, ViewSyncTaskTypes::build(builder).launch()) + }.boxed() + }) + + // match self { + // ViewSyncTaskDescription::Threshold(threshold) => { + // + // }, + // ViewSyncTaskDescription::Precise(map) => { + // + // } + // } + } + +} From ade69d8a4bca93877bd5ae6c99d388cefb48244a Mon Sep 17 00:00:00 2001 From: Justin Restivo Date: Sun, 31 Dec 2023 14:52:34 -0500 Subject: [PATCH 2/5] feat: view sync check task --- crates/testing/src/test_builder.rs | 7 +- crates/testing/src/test_runner.rs | 11 +- crates/testing/src/view_sync_task.rs | 162 +++++++++++++++++++++------ 3 files changed, 135 insertions(+), 45 deletions(-) diff --git a/crates/testing/src/test_builder.rs b/crates/testing/src/test_builder.rs index af51ac9c09..0d0e617513 100644 --- a/crates/testing/src/test_builder.rs +++ b/crates/testing/src/test_builder.rs @@ -12,7 +12,8 @@ use hotshot_types::{ use super::completion_task::{CompletionTaskDescription, TimeBasedCompletionTaskDescription}; use crate::{ spinning_task::SpinningTaskDescription, - test_launcher::{ResourceGenerators, TestLauncher}, view_sync_task::ViewSyncTaskDescription, + test_launcher::{ResourceGenerators, TestLauncher}, + view_sync_task::ViewSyncTaskDescription, }; use super::{ @@ -59,7 +60,7 @@ pub struct TestMetadata { /// timing data pub timing_data: TimingData, /// view sync check task - pub view_sync_properties: ViewSyncTaskDescription + pub view_sync_properties: ViewSyncTaskDescription, } impl Default for TimingData { @@ -182,7 +183,7 @@ impl Default for TestMetadata { duration: Duration::from_millis(10000), }, ), - view_sync_properties: ViewSyncTaskDescription::Threshold(0, num_nodes) + view_sync_properties: ViewSyncTaskDescription::Threshold(0, num_nodes), } } } diff --git a/crates/testing/src/test_runner.rs b/crates/testing/src/test_runner.rs index 4d46256971..776f9268e5 100644 --- a/crates/testing/src/test_runner.rs +++ b/crates/testing/src/test_runner.rs @@ -5,7 +5,8 @@ use super::{ }; use crate::{ spinning_task::{ChangeNode, UpDown}, - test_launcher::{Networks, TestLauncher}, view_sync_task::ViewSyncTask, + test_launcher::{Networks, TestLauncher}, + view_sync_task::ViewSyncTask, }; use hotshot::{types::SystemContextHandle, Memberships}; @@ -146,18 +147,18 @@ where .await; task_runner = task_runner.add_task(id, "Test Overall Safety Task".to_string(), task); - /// add view sync task + // add view sync task let view_sync_task_state = ViewSyncTask { - test_event_stream: test_event_stream.clone(), handles: nodes.clone(), - hit_view_sync: HashMap::new(), + hit_view_sync: HashSet::new(), }; let (id, task) = (launcher.view_sync_task_generator)( view_sync_task_state, registry.clone(), test_event_stream.clone(), - ).await; + ) + .await; task_runner = task_runner.add_task(id, "View Sync Task".to_string(), task); // wait for networks to be ready diff --git a/crates/testing/src/view_sync_task.rs b/crates/testing/src/view_sync_task.rs index e99329e998..f3a26ce157 100644 --- a/crates/testing/src/view_sync_task.rs +++ b/crates/testing/src/view_sync_task.rs @@ -1,26 +1,34 @@ -use std::{sync::Arc, collections::{HashSet, HashMap}}; -use futures::FutureExt; -use hotshot_task::task::HotShotTaskTypes; use async_compatibility_layer::channel::UnboundedStream; -use hotshot_task::{task_impls::{TaskBuilder, HSTWithEventAndMessage}, task::{FilterEvent, HandleMessage, HandleEvent, TS}, MergeN, event_stream::ChannelStream}; +use futures::FutureExt; +use hotshot_task::task::{HotShotTaskCompleted, HotShotTaskTypes}; +use hotshot_task::{ + event_stream::ChannelStream, + task::{FilterEvent, HandleEvent, HandleMessage, TS}, + task_impls::{HSTWithEventAndMessage, TaskBuilder}, + MergeN, +}; use hotshot_task_impls::events::HotShotEvent; -use hotshot_types::traits::node_implementation::{TestableNodeImplementation, NodeType}; +use hotshot_types::traits::node_implementation::{NodeType, TestableNodeImplementation}; use snafu::Snafu; +use std::{ + collections::{HashMap, HashSet}, + sync::Arc, +}; use crate::{test_launcher::TaskGenerator, test_runner::Node, GlobalTestEvent}; /// ViewSync Task error -#[derive(Snafu, Debug)] -pub struct ViewSyncTaskErr {} +#[derive(Snafu, Debug, Clone)] +pub struct ViewSyncTaskErr { + hit_view_sync: HashSet, +} /// ViewSync task state pub struct ViewSyncTask> { - /// the global event stream - pub(crate) test_event_stream: ChannelStream, /// the node handles pub(crate) handles: Vec>, /// nodes that hit view sync - pub(crate) hit_view_sync: HashMap::Time> + pub(crate) hit_view_sync: HashSet, } impl> TS for ViewSyncTask {} @@ -42,7 +50,7 @@ pub enum ShouldHitViewSync { /// the node should not hit view sync No, /// don't care if the node should hit view sync - DontCare + Ignore, } /// Description for a view sync task. @@ -52,7 +60,7 @@ pub enum ViewSyncTaskDescription { Threshold(usize, usize), /// node idx -> whether or not the node should hit view sync /// if node not in map, assumed to be `ShouldHItViewSync::DontCare` - Precise(HashMap) + Precise(HashMap), } impl ViewSyncTaskDescription { @@ -61,44 +69,125 @@ impl ViewSyncTaskDescription { ) -> TaskGenerator> { Box::new(move |mut state, mut registry, test_event_stream| { async move { - - let event_handler = HandleEvent::>(Arc::new(move |event, state| { - async move { - match event { - GlobalTestEvent::ShutDown => { - todo!() - // logic checking stuff + let event_handler = + HandleEvent::>(Arc::new(move |event, state| { + let self_dup = self.clone(); + async move { + match event { + GlobalTestEvent::ShutDown => match self_dup.clone() { + ViewSyncTaskDescription::Threshold(min, max) => { + let num_hits = state.hit_view_sync.len(); + if min <= num_hits && num_hits <= max { + (Some(HotShotTaskCompleted::ShutDown), state) + } else { + ( + Some(HotShotTaskCompleted::Error(Box::new( + ViewSyncTaskErr { + hit_view_sync: state.hit_view_sync.clone(), + }, + ))), + state, + ) + } + } + ViewSyncTaskDescription::Precise(map) => { + for (id, should_hit) in map { + match should_hit { + ShouldHitViewSync::Yes => { + if !state.hit_view_sync.contains(&id) { + return ( + Some(HotShotTaskCompleted::Error( + Box::new(ViewSyncTaskErr { + hit_view_sync: state + .hit_view_sync + .clone(), + }), + )), + state, + ); + } + } + ShouldHitViewSync::No => { + if state.hit_view_sync.contains(&id) { + return ( + Some(HotShotTaskCompleted::Error( + Box::new(ViewSyncTaskErr { + hit_view_sync: state + .hit_view_sync + .clone(), + }), + )), + state, + ); + } + } + ShouldHitViewSync::Ignore => {} + } + } + (Some(HotShotTaskCompleted::ShutDown), state) + } + }, } } - }.boxed() - - })); + .boxed() + })); let message_handler = HandleMessage::>(Arc::new( - move |msg, mut state| { - todo!() + // NOTE: could short circuit on entering view sync if we're not supposed to + // enter view sync. I opted not to do this just to gather more information + // (since we'll fail the test later anyway) + move |(id, msg), mut state| { + async move { + match msg { + // all the view sync events + HotShotEvent::ViewSyncTimeout(_, _, _) + | HotShotEvent::ViewSyncPreCommitVoteRecv(_) + | HotShotEvent::ViewSyncCommitVoteRecv(_) + | HotShotEvent::ViewSyncFinalizeVoteRecv(_) + | HotShotEvent::ViewSyncPreCommitVoteSend(_) + | HotShotEvent::ViewSyncCommitVoteSend(_) + | HotShotEvent::ViewSyncFinalizeVoteSend(_) + | HotShotEvent::ViewSyncPreCommitCertificate2Recv(_) + | HotShotEvent::ViewSyncCommitCertificate2Recv(_) + | HotShotEvent::ViewSyncFinalizeCertificate2Recv(_) + | HotShotEvent::ViewSyncPreCommitCertificate2Send(_, _) + | HotShotEvent::ViewSyncCommitCertificate2Send(_, _) + | HotShotEvent::ViewSyncFinalizeCertificate2Send(_, _) + | HotShotEvent::ViewSyncTrigger(_) => { + state.hit_view_sync.insert(id); + } + _ => (), + } + (None, state) } - )); + .boxed() + }, + )); let mut streams = vec![]; for handle in &mut state.handles { - let stream = handle.handle.get_internal_event_stream_known_impl(FilterEvent::default()).await.0; + let stream = handle + .handle + .get_internal_event_stream_known_impl(FilterEvent::default()) + .await + .0; streams.push(stream); } let builder = TaskBuilder::>::new( "Test Completion Task".to_string(), - ) - .register_event_stream(test_event_stream, FilterEvent::default()) - .await - .register_registry(&mut registry) - .await - .register_state(state) - .register_event_handler(event_handler) - .register_message_handler(message_handler) - .register_message_stream(MergeN::new(streams)); + ) + .register_event_stream(test_event_stream, FilterEvent::default()) + .await + .register_registry(&mut registry) + .await + .register_state(state) + .register_event_handler(event_handler) + .register_message_handler(message_handler) + .register_message_stream(MergeN::new(streams)); let task_id = builder.get_task_id().unwrap(); (task_id, ViewSyncTaskTypes::build(builder).launch()) - }.boxed() + } + .boxed() }) // match self { @@ -110,5 +199,4 @@ impl ViewSyncTaskDescription { // } // } } - } From c73cd3b869c4c4f14d0e5e3ce2641c5875806756 Mon Sep 17 00:00:00 2001 From: Justin Restivo Date: Sun, 31 Dec 2023 15:11:57 -0500 Subject: [PATCH 3/5] fix: catchup test --- crates/testing/tests/catchup.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/testing/tests/catchup.rs b/crates/testing/tests/catchup.rs index 92c718436f..078a9aa053 100644 --- a/crates/testing/tests/catchup.rs +++ b/crates/testing/tests/catchup.rs @@ -218,6 +218,8 @@ async fn test_catchup_in_view_sync() { metadata.timing_data = timing_data; metadata.start_nodes = 18; metadata.total_nodes = 20; + metadata.view_sync_properties = + hotshot_testing::view_sync_task::ViewSyncTaskDescription::Threshold(0, 20); metadata.spinning_properties = SpinningTaskDescription { node_changes: vec![(25, catchup_nodes)], From af1595b5c697d6d7965f4372867300c58b06ce1c Mon Sep 17 00:00:00 2001 From: Justin Restivo Date: Sun, 31 Dec 2023 19:35:49 -0500 Subject: [PATCH 4/5] fix: catchup test --- crates/testing/tests/catchup.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/testing/tests/catchup.rs b/crates/testing/tests/catchup.rs index 078a9aa053..642819143c 100644 --- a/crates/testing/tests/catchup.rs +++ b/crates/testing/tests/catchup.rs @@ -37,6 +37,9 @@ async fn test_catchup() { metadata.start_nodes = 18; metadata.total_nodes = 20; + metadata.view_sync_properties = + hotshot_testing::view_sync_task::ViewSyncTaskDescription::Threshold(0, 20); + metadata.spinning_properties = SpinningTaskDescription { // Start the nodes before their leadership. node_changes: vec![(15, catchup_nodes)], From 5c3069b9fa9637190356f246bce8deb5abdc282a Mon Sep 17 00:00:00 2001 From: Justin Restivo Date: Tue, 9 Jan 2024 11:46:01 -0500 Subject: [PATCH 5/5] feat: brendon's suggested changes --- crates/testing/src/view_sync_task.rs | 53 +--------------------------- 1 file changed, 1 insertion(+), 52 deletions(-) diff --git a/crates/testing/src/view_sync_task.rs b/crates/testing/src/view_sync_task.rs index f3a26ce157..a94fdb7d1c 100644 --- a/crates/testing/src/view_sync_task.rs +++ b/crates/testing/src/view_sync_task.rs @@ -10,10 +10,7 @@ use hotshot_task::{ use hotshot_task_impls::events::HotShotEvent; use hotshot_types::traits::node_implementation::{NodeType, TestableNodeImplementation}; use snafu::Snafu; -use std::{ - collections::{HashMap, HashSet}, - sync::Arc, -}; +use std::{collections::HashSet, sync::Arc}; use crate::{test_launcher::TaskGenerator, test_runner::Node, GlobalTestEvent}; @@ -58,9 +55,6 @@ pub enum ShouldHitViewSync { pub enum ViewSyncTaskDescription { /// (min, max) number nodes that may hit view sync, inclusive Threshold(usize, usize), - /// node idx -> whether or not the node should hit view sync - /// if node not in map, assumed to be `ShouldHItViewSync::DontCare` - Precise(HashMap), } impl ViewSyncTaskDescription { @@ -90,42 +84,6 @@ impl ViewSyncTaskDescription { ) } } - ViewSyncTaskDescription::Precise(map) => { - for (id, should_hit) in map { - match should_hit { - ShouldHitViewSync::Yes => { - if !state.hit_view_sync.contains(&id) { - return ( - Some(HotShotTaskCompleted::Error( - Box::new(ViewSyncTaskErr { - hit_view_sync: state - .hit_view_sync - .clone(), - }), - )), - state, - ); - } - } - ShouldHitViewSync::No => { - if state.hit_view_sync.contains(&id) { - return ( - Some(HotShotTaskCompleted::Error( - Box::new(ViewSyncTaskErr { - hit_view_sync: state - .hit_view_sync - .clone(), - }), - )), - state, - ); - } - } - ShouldHitViewSync::Ignore => {} - } - } - (Some(HotShotTaskCompleted::ShutDown), state) - } }, } } @@ -189,14 +147,5 @@ impl ViewSyncTaskDescription { } .boxed() }) - - // match self { - // ViewSyncTaskDescription::Threshold(threshold) => { - // - // }, - // ViewSyncTaskDescription::Precise(map) => { - // - // } - // } } }