-
Notifications
You must be signed in to change notification settings - Fork 197
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 feedback for peer honesty in consensus #1979
Merged
LucianMincu
merged 15 commits into
release-candidate
from
add-feedback-for-peer-honesty-in-consensus
Jun 22, 2020
Merged
Changes from 2 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
7aa35fc
* Added a consensus rating mechanism to handle the situation when som…
SebastianMarian 9187e2c
* Fixed after review
SebastianMarian 15a4e9e
* Reorder old code
SebastianMarian e04aeb0
* Removed more duplicate code
SebastianMarian aabbad1
* Refactored PeerHonestyHandler interface
SebastianMarian 6314212
Merge branch 'release-candidate' into add-feedback-for-peer-honesty-i…
LucianMincu 93547bb
Merge branch 'release-candidate' into add-feedback-for-peer-honesty-i…
LucianMincu abb0f9e
* Fixed a blacklist situation which should not be done
SebastianMarian 553ca76
Merge branch 'release-candidate' into add-feedback-for-peer-honesty-i…
iulianpascalau 4a9709e
* Fixed an edge case which blacklisted peers of a node which was in s…
SebastianMarian cf8a806
Merge remote-tracking branch 'origin/add-feedback-for-peer-honesty-in…
SebastianMarian 79446fa
Merge branch 'release-candidate' into add-feedback-for-peer-honesty-i…
iulianpascalau b3beaa1
* Fixed an edge case which blacklisted peers when a node missed to pr…
SebastianMarian 7c6f6e4
Merge remote-tracking branch 'origin/add-feedback-for-peer-honesty-in…
SebastianMarian 084b840
* Fixed an unit test
SebastianMarian File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package mock | ||
|
||
// PeerHonestyHandlerStub - | ||
type PeerHonestyHandlerStub struct { | ||
IncreaseCalled func(round int64, pk string, topic string, value float64) | ||
DecreaseCalled func(round int64, pk string, topic string, value float64) | ||
} | ||
|
||
// Increase - | ||
func (phhs *PeerHonestyHandlerStub) Increase(round int64, pk string, topic string, value float64) { | ||
if phhs.IncreaseCalled != nil { | ||
phhs.IncreaseCalled(round, pk, topic, value) | ||
return | ||
} | ||
} | ||
|
||
// Decrease - | ||
func (phhs *PeerHonestyHandlerStub) Decrease(round int64, pk string, topic string, value float64) { | ||
if phhs.DecreaseCalled != nil { | ||
phhs.DecreaseCalled(round, pk, topic, value) | ||
return | ||
} | ||
} | ||
|
||
// IsInterfaceNil - | ||
func (phhs *PeerHonestyHandlerStub) IsInterfaceNil() bool { | ||
return phhs == nil | ||
} |
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 |
---|---|---|
|
@@ -125,13 +125,19 @@ func (sr *subroundSignature) doSignatureJob() bool { | |
// If the signature is valid, than the jobDone map corresponding to the node which sent it, | ||
// is set on true for the subround Signature | ||
func (sr *subroundSignature) receivedSignature(cnsDta *consensus.Message) bool { | ||
if !sr.IsSelfLeaderInCurrentRound() { | ||
node := string(cnsDta.PubKey) | ||
|
||
if !sr.IsConsensusDataSet() { | ||
return false | ||
} | ||
|
||
node := string(cnsDta.PubKey) | ||
sr.updateValidatorPeerHonesty(node) | ||
|
||
if !sr.IsConsensusDataSet() { | ||
if !sr.IsNodeInConsensusGroup(node) { | ||
return false | ||
} | ||
|
||
if !sr.IsSelfLeaderInCurrentRound() { | ||
return false | ||
} | ||
|
||
|
@@ -263,3 +269,21 @@ func (sr *subroundSignature) remainingTime() time.Duration { | |
|
||
return remainigTime | ||
} | ||
|
||
func (sr *subroundSignature) updateValidatorPeerHonesty(node string) { | ||
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. This can also be moved in Subround struct |
||
if !sr.IsNodeInConsensusGroup(node) { | ||
sr.PeerHonestyHandler().Decrease( | ||
sr.Rounder().Index(), | ||
node, | ||
spos.GetConsensusTopicID(sr.ShardCoordinator()), | ||
spos.ValidatorPeerHonestyDecreaseFactor) | ||
|
||
return | ||
} | ||
|
||
sr.PeerHonestyHandler().Increase( | ||
sr.Rounder().Index(), | ||
node, | ||
spos.GetConsensusTopicID(sr.ShardCoordinator()), | ||
spos.ValidatorPeerHonestyIncreaseFactor) | ||
} |
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
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.
Duplicate code with subroundEndRound. Suggestion to move this in Subround struct.