-
Notifications
You must be signed in to change notification settings - Fork 48
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
Double Voting Prevention #3971
Double Voting Prevention #3971
Conversation
crates/types/src/consensus.rs
Outdated
// Clean up old vote records periodically | ||
self.vote_tracker.cleanup_old_views(view); |
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.
Doesn't this open us up tot he opposite problem would have? Vote in view n
, then view n+1
then we can vote for view n
again? The old code of course just allows any duplicate vote so there is an improvement with this code.
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.
@bfish713 I have implemented a robust system for tracking view sequences. Added a queue mechanism that handles out-of-order votes. This prevents double voting while allowing the network to be resilient. Sorry, I missed the importance of the TODO comment. Comprehensive test coverage of both epoch transitions and network partitioning scenarios is included in this solution.
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.
I think we should discuss the solution to this before adding more details. I don't think we need this complex of vote tracking inserted at this point. DA voting is not the same as regular voting so double voting for a view is not really security issue, though not ideal. Also there is no requirement that votes be sequential. We can vote for view n+1
before view n
for DA, we cannot when voting on a proposal.
The properties we would ideally enforce for voting on DA are:
- Don't vote twice in a view
- Don't vote for old views. And old view an be considered a view less or equal to the high QC view
- Don't vote for views too far in the future, this can just be a heuristic value to prevent a leader from calculating all it's future views and spamming us with proposals.
Ideally most of these properties are enforced before we ever get update_action
Also can you elaborate on why there are changes to the epoch functions in consensus.rs
This implements a robust double voting prevention mechanism for the HotShot. The implementation addresses a critical security vulnerability where nodes could potentially cast multiple votes for the same view under certain conditions.
Problem
In the current implementation, there's a significant security vulnerability in the voting mechanism:
This implementation fails to prevent double voting because:
Solution
1. New VoteTracker Component
Introduced a new
VoteTracker
struct that provides atomic vote tracking:Key features:
2. Consensus Integration
Modified the Consensus struct to incorporate vote tracking:
Updated vote handling logic:
Security Implications
Vote Uniqueness
Byzantine Fault Tolerance
View Synchronization
Technical Implementation
1. Vote Recording Process
Key aspects:
2. Memory Management
Features:
Time Complexity
Unit Tests