Skip to content

Commit

Permalink
Fix consistency check, update metadata setting, update justfile, rena…
Browse files Browse the repository at this point in the history
…me tasks.
  • Loading branch information
shenkeyao committed Aug 15, 2023
1 parent 186f3db commit 45c35c9
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 34 deletions.
10 changes: 5 additions & 5 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ test_async_std_all:
echo Testing with async std executor
RUST_LOG="error" cargo test --features=full-ci --lib --bins --tests --benches --workspace --no-fail-fast test_basic -- --test-threads=1 --nocapture

_test_basic:
test_basic:
echo Testing with async std executor
RUST_LOG="" cargo test --features=full-ci --lib --bins --tests --benches --workspace --no-fail-fast test_basic -- --test-threads=1 --nocapture

_test_basic_tokio:
echo Testing with async std executor
test_basic_tokio:
echo Testing with tokio executor
RUST_LOG="" cargo test --features=tokio-ci --lib --bins --tests --benches --workspace --no-fail-fast test_basic -- --test-threads=1 --nocapture

_test_with_failures:
test_with_failures:
echo Testing nodes leaving the network with async std executor
RUST_LOG="" cargo test --features=full-ci --lib --bins --tests --benches --workspace --no-fail-fast test_with_failures -- --test-threads=1 --nocapture
RUST_LOG="" ASYNC_STD_THREAD_COUNT=1 cargo test --features=full-ci --lib --bins --tests --benches --workspace --no-fail-fast test_with_failures -- --test-threads=1 --nocapture

test_pkg := "hotshot"

Expand Down
29 changes: 16 additions & 13 deletions testing/src/overall_safety_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use hotshot_task::{
};
use hotshot_types::{
certificate::QuorumCertificate,
data::LeafType,
data::{DeltasType, LeafType},
error::RoundTimedoutState,
event::{Event, EventType},
traits::node_implementation::NodeType,
Expand Down Expand Up @@ -258,7 +258,7 @@ impl<TYPES: NodeType, LEAF: LeafType<NodeType = TYPES>> RoundResult<TYPES, LEAF>
);

let mut result_state = None;
let mut result_block = None;
let mut result_commitment = None;

if check_state {
for (state, num_nodes) in states {
Expand All @@ -276,19 +276,22 @@ impl<TYPES: NodeType, LEAF: LeafType<NodeType = TYPES>> RoundResult<TYPES, LEAF>
}

if check_block {
for (block, num_nodes) in blocks.clone() {
if num_nodes >= threshold {
result_block = Some(block.clone());
self.success = true;
self.agreed_block = Some(block);
// Check if the block commitments are the same.
let mut consistent_block = None;
for (delta, _) in blocks.clone() {
let commitment = delta.block_commitment();
if let Some(consistent_commitment) = result_commitment {
if commitment != consistent_commitment {
self.success = false;
error!("Inconsistent blocks, blocks: {:?}", blocks);
return Err(OverallSafetyTaskErr::InconsistentBlocks);
}
}
result_commitment = Some(commitment);
consistent_block = Some(delta);
}

if result_block.is_none() {
self.success = false;
error!("Inconsistent blocks, blocks: {:?}", blocks);
return Err(OverallSafetyTaskErr::InconsistentBlocks);
}
self.success = true;
self.agreed_block = consistent_block;
}
Ok(())
}
Expand Down
3 changes: 1 addition & 2 deletions testing/src/spinning_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use hotshot_types::traits::node_implementation::NodeType;
use snafu::Snafu;

use crate::{test_launcher::TaskGenerator, test_runner::Node, GlobalTestEvent};

#[derive(Snafu, Debug)]
pub struct SpinningTaskErr {}

Expand Down Expand Up @@ -125,7 +124,7 @@ impl SpinningTaskDescription {
},
));
let builder = TaskBuilder::<SpinningTaskTypes<TYPES, I>>::new(
"Spinning Nodes Task".to_string(),
"Test Spinning Task".to_string(),
)
.register_event_stream(test_event_stream, FilterEvent::default())
.await
Expand Down
13 changes: 12 additions & 1 deletion testing/src/test_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,18 @@ impl TestMetadata {
total_nodes: 20,
start_nodes: 20,
num_bootstrap_nodes: 20,
da_committee_size: 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
// following issue.
// TODO: Update message broadcasting to avoid hanging
// <https://github.com/EspressoSystems/HotShot/issues/1567>
da_committee_size: 14,
completion_task_description: CompletionTaskDescription::TimeBasedCompletionTaskBuilder(
TimeBasedCompletionTaskDescription {
// Increase the duration to get the expected number of successful views.
duration: Duration::new(40, 0),
},
),
overall_safety_properties: OverallSafetyPropertiesDescription {
num_successful_views: 10,
..Default::default()
Expand Down
6 changes: 3 additions & 3 deletions testing/src/test_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ where
test_event_stream.clone(),
)
.await;
task_runner = task_runner.add_task(id, "Completion Task".to_string(), task);
task_runner = task_runner.add_task(id, "Test Completion Task".to_string(), task);

// add spinning task
let spinning_task_state = crate::spinning_task::SpinningTask {
Expand All @@ -135,7 +135,7 @@ where
test_event_stream.clone(),
)
.await;
task_runner = task_runner.add_task(id, "Completion Task".to_string(), task);
task_runner = task_runner.add_task(id, "Test Spinning Task".to_string(), task);

// add safety task
let overall_safety_task_state = OverallSafetyTask {
Expand All @@ -149,7 +149,7 @@ where
test_event_stream.clone(),
)
.await;
task_runner = task_runner.add_task(id, "Overall Safety Task".to_string(), task);
task_runner = task_runner.add_task(id, "Test Overall Safety Task".to_string(), task);

// Start hotshot
// Goes through all nodes, but really only needs to call this on the leader node of the first view
Expand Down
35 changes: 25 additions & 10 deletions testing/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@ async fn test_with_failures_one() {
async_compatibility_layer::logging::setup_logging();
async_compatibility_layer::logging::setup_backtrace();
let mut metadata = TestMetadata::default_more_nodes_less_success();
// 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
// following issue.
// TODO: Update message broadcasting to avoid hanging
// <https://github.com/EspressoSystems/HotShot/issues/1567>
let dead_nodes = vec![ChangeNode {
idx: 10,
idx: 19,
updown: UpDown::Down,
}];

Expand Down Expand Up @@ -73,17 +78,22 @@ async fn test_with_failures_half_f() {
async_compatibility_layer::logging::setup_logging();
async_compatibility_layer::logging::setup_backtrace();
let mut metadata = TestMetadata::default_more_nodes_less_success();
// 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
// following issue.
// TODO: Update message broadcasting to avoid hanging
// <https://github.com/EspressoSystems/HotShot/issues/1567>
let dead_nodes = vec![
ChangeNode {
idx: 5,
idx: 17,
updown: UpDown::Down,
},
ChangeNode {
idx: 10,
idx: 18,
updown: UpDown::Down,
},
ChangeNode {
idx: 15,
idx: 19,
updown: UpDown::Down,
},
];
Expand Down Expand Up @@ -117,29 +127,34 @@ async fn test_with_failures_f() {
async_compatibility_layer::logging::setup_logging();
async_compatibility_layer::logging::setup_backtrace();
let mut metadata = TestMetadata::default_more_nodes_less_success();
// 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
// following issue.
// TODO: Update message broadcasting to avoid hanging
// <https://github.com/EspressoSystems/HotShot/issues/1567>
let dead_nodes = vec![
ChangeNode {
idx: 5,
idx: 14,
updown: UpDown::Down,
},
ChangeNode {
idx: 6,
idx: 15,
updown: UpDown::Down,
},
ChangeNode {
idx: 10,
idx: 16,
updown: UpDown::Down,
},
ChangeNode {
idx: 11,
idx: 17,
updown: UpDown::Down,
},
ChangeNode {
idx: 15,
idx: 18,
updown: UpDown::Down,
},
ChangeNode {
idx: 16,
idx: 19,
updown: UpDown::Down,
},
];
Expand Down

0 comments on commit 45c35c9

Please sign in to comment.