-
Notifications
You must be signed in to change notification settings - Fork 52
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
Add VID to webserver #1954
Merged
Merged
Add VID to webserver #1954
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,8 @@ use hotshot_task::{ | |
task::{FilterEvent, HandleEvent, HotShotTaskCompleted, HotShotTaskTypes, TS}, | ||
task_impls::{HSTWithEvent, TaskBuilder}, | ||
}; | ||
use hotshot_types::vote::VoteType; | ||
use hotshot_types::traits::network::CommunicationChannel; | ||
use hotshot_types::traits::network::ConsensusIntentEvent; | ||
use hotshot_types::{ | ||
certificate::VIDCertificate, traits::election::SignedCertificate, vote::VIDVoteAccumulator, | ||
}; | ||
|
@@ -141,13 +142,16 @@ where | |
{ | ||
match event { | ||
HotShotEvent::VidVoteRecv(vote) => { | ||
// TODO copy-pasted from DAVoteRecv https://github.com/EspressoSystems/HotShot/issues/1690 | ||
debug!("VID vote recv, collection task {:?}", vote.current_view); | ||
// panic!("Vote handle received VID vote for view {}", *vote.current_view); | ||
|
||
debug!("VID vote recv, collection task {:?}", vote.get_view()); | ||
// panic!("Vote handle received DA vote for view {}", *vote.current_view); | ||
// For the case where we receive votes after we've made a certificate | ||
if state.accumulator.is_right() { | ||
debug!("VID accumulator finished view: {:?}", state.cur_view); | ||
return (None, state); | ||
} | ||
|
||
let accumulator = state.accumulator.left().unwrap(); | ||
|
||
match state | ||
.vid_exchange | ||
.accumulate_vote(accumulator, &vote, &vote.block_commitment) | ||
|
@@ -167,13 +171,19 @@ where | |
.await; | ||
|
||
state.accumulator = Right(vid_cert.clone()); | ||
state | ||
.vid_exchange | ||
.network() | ||
.inject_consensus_info(ConsensusIntentEvent::CancelPollForVIDVotes( | ||
*vid_cert.view_number, | ||
)) | ||
.await; | ||
|
||
// Return completed at this point | ||
return (Some(HotShotTaskCompleted::ShutDown), state); | ||
} | ||
} | ||
} | ||
HotShotEvent::Shutdown => return (Some(HotShotTaskCompleted::ShutDown), state), | ||
_ => { | ||
error!("unexpected event {:?}", event); | ||
} | ||
|
@@ -206,12 +216,10 @@ where | |
) -> Option<HotShotTaskCompleted> { | ||
match event { | ||
HotShotEvent::VidVoteRecv(vote) => { | ||
// TODO copy-pasted from DAVoteRecv https://github.com/EspressoSystems/HotShot/issues/1690 | ||
|
||
// warn!( | ||
// "VID vote recv, Main Task {:?}, key: {:?}", | ||
// vote.current_view, | ||
// self.vid_exchange.public_key() | ||
// self.committee_exchange.public_key() | ||
// ); | ||
// Check if we are the leader and the vote is from the sender. | ||
let view = vote.current_view; | ||
|
@@ -361,6 +369,9 @@ where | |
} | ||
} | ||
} | ||
HotShotEvent::VidCertRecv(_) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually think we'd want to put this event into the consensus task, since replicas need to check if they have it before voting on a quorum proposal. But this can be done in a separate issue. |
||
// RM TODO | ||
} | ||
HotShotEvent::ViewChange(view) => { | ||
if *self.cur_view >= *view { | ||
return None; | ||
|
@@ -371,6 +382,35 @@ where | |
} | ||
self.cur_view = view; | ||
|
||
// Start polling for VID disperse for the new view | ||
self.vid_exchange | ||
.network() | ||
.inject_consensus_info(ConsensusIntentEvent::PollForVIDDisperse( | ||
*self.cur_view + 1, | ||
)) | ||
.await; | ||
|
||
self.vid_exchange | ||
.network() | ||
.inject_consensus_info(ConsensusIntentEvent::PollForVIDCertificate( | ||
*self.cur_view + 1, | ||
)) | ||
.await; | ||
|
||
// If we are not the next leader, we should exit | ||
if !self.vid_exchange.is_leader(self.cur_view + 1) { | ||
// panic!("We are not the DA leader for view {}", *self.cur_view + 1); | ||
return None; | ||
} | ||
|
||
// Start polling for VID votes for the "next view" | ||
self.vid_exchange | ||
.network() | ||
.inject_consensus_info(ConsensusIntentEvent::PollForVIDVotes( | ||
*self.cur_view + 1, | ||
)) | ||
.await; | ||
|
||
return None; | ||
} | ||
|
||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice!