-
Notifications
You must be signed in to change notification settings - Fork 90
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
core/tracker: validate events from peers #971
Conversation
Codecov Report
@@ Coverage Diff @@
## main #971 +/- ##
==========================================
- Coverage 54.18% 53.84% -0.34%
==========================================
Files 116 116
Lines 12750 12811 +61
==========================================
- Hits 6908 6898 -10
- Misses 4831 4893 +62
- Partials 1011 1020 +9
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
core/tracker/tracker.go
Outdated
if e.component == parSigEx || e.component == parSigDBInternal { | ||
if e.component == parSigEx { | ||
if err := validateParticipation(duty, e.pubkey, allEvents); err != nil { | ||
log.Warn(ctx, "Unexpected event found", err, z.Int("ShareIdx", e.shareIdx)) |
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.
moving logging to reporter
core/tracker/tracker.go
Outdated
@@ -113,11 +113,11 @@ func (t *Tracker) Run(ctx context.Context) error { | |||
t.failedDutyReporter(ctx, duty, failed, failedComponent, failedMsg) | |||
|
|||
// Analyse peer participation | |||
participatedShares, err := analyseParticipation(t.events[duty]) | |||
participatedShares, unexpectedPeers, err := analyseParticipation(ctx, duty, t.events) |
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.
unexpectedShares
core/tracker/tracker.go
Outdated
continue | ||
} | ||
|
||
if e.shareIdx == 0 { |
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.
you can assume shareIdx is valid since we verify partial signatures when received in parsigex
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.
yeah right
core/tracker/tracker.go
Outdated
} | ||
|
||
// validateParticipation validates events from peers for a given duty. | ||
func validateParticipation(duty core.Duty, pubkey core.PubKey, allEvents map[core.Duty][]event) error { |
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.
nit: isParSigEventExpected return true if partially signed data events is expected for the given duty and pubkey. Partially signed data events are generated by parsigex and parsigdb.
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.
done
return nil, nil, errors.New("shareIdx empty", z.Any("component", e.component)) | ||
} | ||
resp[e.shareIdx] = true | ||
} else if e.component == parSigDBInternal { |
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.
you also need to check if parSigDBInternal
is expected.
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.
sure
core/tracker/tracker.go
Outdated
|
||
// validateParticipation validates events from peers for a given duty. | ||
func validateParticipation(duty core.Duty, pubkey core.PubKey, allEvents map[core.Duty][]event) error { | ||
if len(allEvents[duty]) == 0 { |
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.
not sure this optimisation is worth it, it will never be true in practice
Validates parSigEx events in analyseParticipation.
category: feature
ticket: #855