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

Explain Q and F #803

Merged
merged 3 commits into from
Jan 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions consensus/istanbul/validator/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,30 @@ func newDefaultSet(validators []istanbul.ValidatorData) *defaultSet {
}
}

func (val *defaultSet) Serialize() ([]byte, error) { return rlp.EncodeToBytes(val) }
func (valSet *defaultSet) F() int { return int(math.Ceil(float64(valSet.Size())/3)) - 1 }
func (valSet *defaultSet) MinQuorumSize() int { return int(math.Ceil(float64(2*valSet.Size()) / 3)) }
// We include the optimization described at https://arxiv.org/pdf/1901.07160.pdf as “PM-6” and
// discussed in Lemma 22. For values of N=3F for integer F=1,2,3,.. we can tolerate a quorum
// size one smaller than anticipated by Q = N - F. The intersection of any two sets of Q
// nodes of N=3F must contain an honest validator.
//
// For example, with N=9, F=2, Q=6. Any two sets of Q=6 from N=9 nodes must overlap
// by >9-6=3 nodes. At least 3-F=3-2=1 must be honest.
//
// 1 2 3 4 5 6 7 8 9
// x x x x x x
// y y y y y y
// F F H
//
// For N=10, F=3, Q=7. Any two sets of Q=7 nodes from N=10 must overlap by >4 nodes.
// At least 4-F=4-3=1 must be honest.
//
// 1 2 3 4 5 6 7 8 9 10
// x x x x x x x
// y y y y y y y
// F F F H

func (valSet *defaultSet) F() int { return int(math.Ceil(float64(valSet.Size())/3)) - 1 }
func (valSet *defaultSet) MinQuorumSize() int { return int(math.Ceil(float64(2*valSet.Size()) / 3)) }

func (valSet *defaultSet) SetRandomness(seed common.Hash) { valSet.randomness = seed }
func (valSet *defaultSet) GetRandomness() common.Hash { return valSet.randomness }

Expand Down Expand Up @@ -234,6 +255,8 @@ func (val *defaultSet) DecodeRLP(stream *rlp.Stream) error {
return nil
}

func (val *defaultSet) Serialize() ([]byte, error) { return rlp.EncodeToBytes(val) }

// Utility Functions

func mapValidatorsToData(validators []istanbul.Validator) []istanbul.ValidatorData {
Expand Down