Skip to content

Commit

Permalink
Merge pull request #2233 from EspressoSystems/ed/update-view-sync
Browse files Browse the repository at this point in the history
Update view sync for 2 timeouts
  • Loading branch information
elliedavidson authored Dec 15, 2023
2 parents 127e938 + b094cf0 commit 5bda483
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
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
);

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

0 comments on commit 5bda483

Please sign in to comment.