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

refactor: break fraudAssessment into evaluations #442

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

bajtos
Copy link
Member

@bajtos bajtos commented Jan 9, 2025

Break Measurement.fraudAssessment into two new fields:

  • taskingEvaluation for the tasking-related checks
    Example: DUP_INET_GROUP

  • majorityEvaluation for the result of the majority seeking process based on committees.
    Example: MINORITY_RESULT

After this change, places filtering "accepted" measurements have to explicitly spell out how they define "accepted".

  • Some places are interested in tasking evaluation results only and consider minority results as "accepted" too. Example: RSR calculated from individual measurements.

  • Other places are stricter and want only measurements in majority. Example: which measurements to reward.

However, this pull request is intended to be pure refactoring with no change in the functionality. It should simply expand the check fraudAssessment === 'OK' into taskingEvaluation === 'OK' && majorityEvaluation === 'OK' and surface the places where we may want to include minority measurements too. Such changes can be implement in follow-up pull requests.

This is a follow-up for #396 (comment)

See also #439

Break `Measurement.fraudAssessment` into two new fields:

- `taskingEvaluation` for the tasking-related checks
  Example: DUP_INET_GROUP

- `majorityEvaluation` for the result of the majority seeking
  process based on committees.
  Example: MINORITY_RESULT

After this change, places filtering "accepted" measurements have to
explicitly spell out how they define "accepted".

- Some places are interested in tasking evaluation results only
  and consider minority results as "accepted" too. Example: RSR
  calculated from individual measurements.

- Other places are stricter and want only measurements in majority.
  Example: which measurements to reward.

Signed-off-by: Miroslav Bajtoš <[email protected]>
Signed-off-by: Miroslav Bajtoš <[email protected]>
Copy link
Member Author

@bajtos bajtos left a comment

Choose a reason for hiding this comment

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

🧵 TODO items blocking the conversion from "draft" to "ready" 👇🏻

lib/evaluate.js Show resolved Hide resolved
lib/evaluate.js Outdated Show resolved Hide resolved
bin/evaluate-measurements.js Outdated Show resolved Hide resolved
Comment on lines -10 to 15
/** @type {import('./preprocess.js').Measurement[]} */
/** @type {string[]} */
this.measurementBatches = []
/** @type {Measurement[]} */
this.measurements = []
Copy link
Member Author

Choose a reason for hiding this comment

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

The field measurementBatches stores a list of CIDs, see here:

round.measurementBatches.push(cid)

Copy link
Member Author

@bajtos bajtos left a comment

Choose a reason for hiding this comment

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

More TODOs 👇🏻

lib/platform-stats.js Show resolved Hide resolved
lib/retrieval-stats.js Show resolved Hide resolved
lib/retrieval-stats.js Show resolved Hide resolved
@bajtos bajtos marked this pull request as ready for review January 10, 2025 09:43
bin/dry-run.js Outdated Show resolved Hide resolved
@@ -98,22 +98,24 @@ async function processRound (roundIndex, measurements, resultCounts) {
})

for (const m of round.measurements) {
if (m.fraudAssessment !== 'OK') continue
if (m.taskingEvaluation !== 'OK') continue
Copy link
Member

Choose a reason for hiding this comment

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

This is also a change in behavior. Previously, majority failures would be rejected here, now they are kept.

Before I continue with the review, can we please resolve this and the above comment? It looks like this question affects most of the changes.

Copy link
Member Author

Choose a reason for hiding this comment

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

Great catch, I'll fix this place to preserve the current behaviour and add a FIXME comment similar to the one on lines 109-111 below.

I'd also like to point out that this is a helper script for SPs to inspect recent Spark measurements, it's known to be flawed (see #396), and yet nobody complained about that bug yet - so again, I think the impact of a breaking change in this file is low.

Copy link
Member Author

Choose a reason for hiding this comment

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

I re-read the PR description and now see that this change in behavior might be intentional. Are you confident that all changes in behavior in this PR are intentional?
(...)
Before I continue with the review, can we please resolve this and the above comment? It looks like this question affects most of the changes.

I started this PR with the intention to combine refactoring with changes fixing the conditions determining which measurements are considered as accepted. I quickly realise that would make it difficult to reason about the changes in the future, so I decided to pivot and change this pull request into pure refactoring with no change in functionality.

I updated the pull request description to clearly spell out this intention.

I am 90% confident that this pull request does not introduce any change in the functionality in the lib files. I wasn't paying as much attention to bin files, but I think you caught the remaining places to fix and this PR is not introducing any unintentional changes now.

Copy link
Member Author

Choose a reason for hiding this comment

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

I searched for all occurences of fraudAssessment === in the pull request and verified that they are all expanded to taskingEvaluation === 'OK' && majorityEvaluation === 'OK'.

I found one place I had to fix - see 16938d8

bajtos and others added 3 commits January 10, 2025 15:23
Co-authored-by: Julian Gruber <[email protected]>
Signed-off-by: Miroslav Bajtoš <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants