-
Notifications
You must be signed in to change notification settings - Fork 46
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
Count weight from equivocations #4
Comments
A more optimized way of using the votes is to have weight defined as struct Weight {
prevote: usize,
precommit: usize,
vote_bitfield: Bitfield, // 2x n_validators
weight_lookup: Box<Fn(u32) -> (usize, Kind)>,
} with add as fn add(&mut self, other: Self) {
self.prevote += other.prevote;
self.precommit += other.precommit;
let bitfield_overlap = self.bitfield & other.bitfield;
// returns immediately if empty.
for idx in bitfield_overlap {
match (self.weight_lookup)(idx) {
(weight, Kind::Prevote) => self.prevote -= weight,
(weight, Kind::Precommit) => self.precommit -= weight,
}
}
} We will need to remove the |
A bit of further optimization that lets us keep the The When we import the first equivocation from a validator, we "re-import" the first vote (not the equivocation) by that validator with a This means that in the general case, with no equivocations, we drag around only an extra word or two for the |
Based on #2 (review)
But only in vote-nodes where no vote-weight from the equivocating node has already been counted.
As a matter of practicality, we can rewrite the
Vote
object used in the round counter asand alter the
Add
operation to only add weight where the voter hasn't been counted yet.This will probably impede performance somewhat because we will have to do several hash-map queries per addition.
cc @AlistairStewart
Another open question is whether this introduces a DoS vector, as we could be spammed with votes on all possible blocks by an equivocating authority.
We discussed a few simple rules for dropping/forgetting votes, but we may want to investigate more:
The text was updated successfully, but these errors were encountered: