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

foot gun: create_da_message should return DAVote #1717

Closed
ggutoski opened this issue Sep 12, 2023 · 0 comments · Fixed by #1684
Closed

foot gun: create_da_message should return DAVote #1717

ggutoski opened this issue Sep 12, 2023 · 0 comments · Fixed by #1684
Assignees

Comments

@ggutoski
Copy link
Contributor

ggutoski commented Sep 12, 2023

/// Create a message with a vote on DA proposal.
fn create_da_message(
&self,
block_commitment: Commitment<TYPES::BlockType>,
current_view: TYPES::Time,
vote_token: TYPES::VoteTokenType,
) -> CommitteeConsensusMessage<TYPES>;

Returns type CommitteeConsensusMessage<TYPES> even though all uses immediately match on DAVote variant. See for example here:

let message = self.committee_exchange.create_da_message(
block_commitment,
view,
vote_token,
);
// ED Don't think this is necessary?
// self.cur_view = view;
if let CommitteeConsensusMessage::DAVote(vote) = message {
debug!("Sending vote to the DA leader {:?}", vote.current_view);
self.event_stream
.publish(SequencingHotShotEvent::DAVoteSend(vote))
.await;
}

These uses have no error-handling for when the match fails, which could lead to nasty bugs in the future. Better to use the type system to ensure this can't happen at compile time. Just return a DAVote instead.

Same for create_vid_message.

@ggutoski ggutoski self-assigned this Sep 12, 2023
ggutoski added a commit that referenced this issue Sep 12, 2023
@ggutoski ggutoski linked a pull request Sep 12, 2023 that will close this issue
2 tasks
ggutoski added a commit that referenced this issue Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant