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

Update view sync for 2 timeouts #2233

Merged
merged 3 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions crates/task-impls/src/view_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,12 @@ impl<
self.num_timeouts_tracked, *view_number
);

if self.num_timeouts_tracked > 3 {
if self.num_timeouts_tracked >= 3 {
error!("Too many consecutive timeouts! This shouldn't happen");
}

if self.num_timeouts_tracked > 2 {
if self.num_timeouts_tracked >= 2 {
error!("Starting view sync protocol for view {}", *view_number + 1);
// Start polling for view sync certificates
self.network
.inject_consensus_info(ConsensusIntentEvent::PollForViewSyncCertificate(
Expand All @@ -499,9 +500,9 @@ impl<
let subscribe_view = if self.membership.get_leader(TYPES::Time::new(next_view))
== self.public_key
{
next_view
} else {
next_view + 1
} else {
next_view
};
// Subscribe to the next view just in case there is progress being made
self.network
Expand Down Expand Up @@ -743,6 +744,12 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, A: ConsensusApi<TYPES, I> +
.publish(HotShotEvent::ViewSyncFinalizeVoteSend(vote))
.await;
}

error!(
"View sync protocol has received view sync evidence to update the view to {}",
*self.next_view
);
Comment on lines +748 to +751
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the logging at lines 475 and 484 should suffice?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thought here was to log when view sync successfully updates the view, as well as when it starts. So we can see if view sync is updating the view or if the view is updated because a proposal was received.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense!


self.event_stream
.publish(HotShotEvent::ViewChange(self.next_view))
.await;
Expand Down
7 changes: 2 additions & 5 deletions crates/testing/tests/view_sync_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ async fn test_view_sync_task() {

let vote_data = ViewSyncPreCommitData {
relay: 0,
round: <TestTypes as hotshot_types::traits::node_implementation::NodeType>::Time::new(5),
round: <TestTypes as hotshot_types::traits::node_implementation::NodeType>::Time::new(4),
};
let vote = hotshot_types::simple_vote::ViewSyncPreCommitVote::<TestTypes>::create_signed_vote(
vote_data,
<TestTypes as hotshot_types::traits::node_implementation::NodeType>::Time::new(5),
<TestTypes as hotshot_types::traits::node_implementation::NodeType>::Time::new(4),
hotshot_types::traits::consensus_api::ConsensusApi::public_key(&api),
hotshot_types::traits::consensus_api::ConsensusApi::private_key(&api),
);
Expand All @@ -44,16 +44,13 @@ async fn test_view_sync_task() {

input.push(HotShotEvent::Timeout(ViewNumber::new(2)));
input.push(HotShotEvent::Timeout(ViewNumber::new(3)));
input.push(HotShotEvent::Timeout(ViewNumber::new(4)));

input.push(HotShotEvent::Shutdown);

output.insert(HotShotEvent::Timeout(ViewNumber::new(2)), 1);
output.insert(HotShotEvent::Timeout(ViewNumber::new(3)), 1);
output.insert(HotShotEvent::Timeout(ViewNumber::new(4)), 1);

output.insert(HotShotEvent::ViewChange(ViewNumber::new(2)), 1);
output.insert(HotShotEvent::ViewChange(ViewNumber::new(3)), 1);
output.insert(HotShotEvent::ViewSyncPreCommitVoteSend(vote.clone()), 1);

output.insert(HotShotEvent::Shutdown, 1);
Expand Down
Loading