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

core/tracker: validate events from peers #971

Merged
merged 2 commits into from
Aug 16, 2022
Merged

Conversation

dB2510
Copy link
Contributor

@dB2510 dB2510 commented Aug 14, 2022

Validates parSigEx events in analyseParticipation.

category: feature
ticket: #855

@codecov
Copy link

codecov bot commented Aug 14, 2022

Codecov Report

Merging #971 (d4f55bf) into main (c7bbf51) will decrease coverage by 0.33%.
The diff coverage is 67.50%.

@@            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     
Impacted Files Coverage Δ
core/tracker/tracker.go 63.63% <67.50%> (+3.87%) ⬆️
core/qbft/qbft.go 71.67% <0.00%> (-10.31%) ⬇️
core/consensus/component.go 56.42% <0.00%> (-3.46%) ⬇️
app/app.go 57.08% <0.00%> (-0.52%) ⬇️
core/parsigex/parsigex.go 56.80% <0.00%> (-0.35%) ⬇️
app/monitoringapi.go 74.00% <0.00%> (ø)
testutil/compose/config.go 83.33% <0.00%> (ø)
testutil/compose/compose/main.go 0.00% <0.00%> (ø)
testutil/compose/run.go 85.18% <0.00%> (+0.97%) ⬆️
core/dutydb/memory.go 71.91% <0.00%> (+1.27%) ⬆️
... and 2 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moving logging to reporter

@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpectedShares

continue
}

if e.shareIdx == 0 {
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah right

}

// validateParticipation validates events from peers for a given duty.
func validateParticipation(duty core.Duty, pubkey core.PubKey, allEvents map[core.Duty][]event) error {
Copy link
Contributor

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.

Copy link
Contributor Author

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 {
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure


// 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 {
Copy link
Contributor

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

@dB2510 dB2510 linked an issue Aug 16, 2022 that may be closed by this pull request
@dB2510 dB2510 added the merge when ready Indicates bulldozer bot may merge when all checks pass label Aug 16, 2022
@obol-bulldozer obol-bulldozer bot merged commit 263ae95 into main Aug 16, 2022
@obol-bulldozer obol-bulldozer bot deleted the dhruv/participation branch August 16, 2022 03:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge when ready Indicates bulldozer bot may merge when all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve analyze participation
2 participants