Skip to content
This repository was archived by the owner on Jan 7, 2026. It is now read-only.

core: Remove fraud detection logic - #572

Merged
pyropy merged 19 commits into
mainfrom
chore/remove-fraud-detection
Jun 26, 2025
Merged

core: Remove fraud detection logic#572
pyropy merged 19 commits into
mainfrom
chore/remove-fraud-detection

Conversation

@pyropy

@pyropy pyropy commented Jun 16, 2025

Copy link
Copy Markdown
Member

This pull request simplifies the evaluation process in lib/evaluate.js by removing the runFraudDetection function and replacing it with a streamlined approach for grouping and evaluating measurements. By removing the fraud detection all measurements are marked as valid and are accepted by the evaluation mechanism. It also updates related telemetry and test cases to reflect these changes.

Simplifications in Evaluation Logic:

  • Removed the runFraudDetection function and replaced it with an inline implementation that directly processes measurements marking them as valid using a generator function (iterateAcceptedMeasurements) to avoid array duplication. (lib/evaluate.js, [1] [2] [3]
  • Changed REQUIRED_COMMITTEE_SIZE from 30 to 1. (lib/evaluate.js, lib/evaluate.jsL3-R12)

Updates to Telemetry:

  • Removed telemetry for fraud_detection_duration_ms and retrieval_stats_honest, consolidating all retrieval stats under retrieval_stats_all. (lib/evaluate.js, [1] [2]

Test Case Adjustments:

  • Updated tests in test/evaluate.js to reflect the removal of runFraudDetection and the consolidation of telemetry points. This includes changes to expected telemetry data and test descriptions. (test/evaluate.js, [1] [2] [3] [4] [5]

Blocked by #569
Closes #574

@pyropy pyropy changed the title WIP: Remove fraud detection Remove fraud detection Jun 20, 2025
@pyropy
pyropy marked this pull request as ready for review June 20, 2025 09:42
@pyropy pyropy changed the title Remove fraud detection core: Remove fraud detection logic Jun 20, 2025
Base automatically changed from chore/remove-rewards to main June 23, 2025 10:52
@juliangruber

Copy link
Copy Markdown
Member

Looks like there's multiple type issues atm

Comment thread test/evaluate.js
prepareProviderRetrievalResultStats: async () => {}
})

let point = telemetry.find(p => p.name === 'retrieval_stats_honest')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

tooling probably consumes retrieval_stats_honest - what if we mirror all properties from retrieval_stats_all to retrieval_stats_honest, we we know now that all stats are honest?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good point, I've reintroduced retrieval_stats_honest in 2d2e291 for backwards compatibility of existing tools.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great catch, @juliangruber! 👏🏻

@pyropy
pyropy requested a review from juliangruber June 25, 2025 09:36

@juliangruber juliangruber left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Needs @bajtos's approval

@bajtos bajtos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

After you ship this change, you can also simplify the code in spark-0k-checker that's picking tasks from the round based using a deterministically random algorithm, see https://github.com/CheckerNetwork/spark-0k-checker/blob/61a41564122dd2f994e164b3d8690c29dfda1007/lib/tasker.js#L127-L162

Comment thread lib/evaluate.js Outdated
Comment on lines +48 to +57
// PERFORMANCE: Avoid duplicating the array of measurements because there are
// hundreds of thousands of them. All the function groupMeasurementsToCommittees
// needs is to iterate over the accepted measurements once.
const iterateAcceptedMeasurements = function * () {
for (const m of measurements) {
// Mark all measurements as accepted by default.
m.taskingEvaluation = 'OK'
yield m
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

  • The performance aspect is no longer true as we expect to have 100x-1000x fewer measurements in the 0k architecture.
  • The goal of the iterator was to provide a read-only view into a subset of measurements. In my mind, iterators are expected to only read the data source. I find it very surprising that iterating over accepted measurements changes m.taskEvaluation field.

Proposal: I assume your goal here is to mark all measurements as accepted. Let's use a simple for loop.

Suggested change
// PERFORMANCE: Avoid duplicating the array of measurements because there are
// hundreds of thousands of them. All the function groupMeasurementsToCommittees
// needs is to iterate over the accepted measurements once.
const iterateAcceptedMeasurements = function * () {
for (const m of measurements) {
// Mark all measurements as accepted by default.
m.taskingEvaluation = 'OK'
yield m
}
}
// Mark all measurements as accepted by default.
for (const m of measurements) {
m.taskingEvaluation = 'OK'
}

Comment thread lib/evaluate.js Outdated
const { committees, timings: fraudDetectionTimings } = await runFraudDetection({
const committees = Array.from(evaluationCommittees.values())
logger.log(
'EVALUATE ROUND %s: Evaluated %s measurements.\n',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
'EVALUATE ROUND %s: Evaluated %s measurements.\n',
'EVALUATE ROUND %s: Accepted all %s measurements.\n',

Comment thread lib/evaluate.js Outdated
}
logger.log(
'EVALUATE ROUND %s: Evaluated %s measurements.\n%o',
'EVALUATE ROUND %s: Evaluated %s measurements.\n',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is the same log as above. Let's remove it completely.

Also, please remove the /** @type line 62/72 above.

Comment thread lib/evaluate.js
Comment on lines -86 to -92
point.intField('fraud_detection_duration_ms', fraudDetectionDuration)
for (const { influxField, duration } of fraudDetectionTimings) {
point.intField(`fraud_detection_timings_${influxField}_ms`, duration)
}
for (const [type, count] of Object.entries(evaluationOutcomes)) {
point.intField(`measurements_${type}`, count)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this change may break some Grafana charts. I agree that we no longer need to monitor these metrics. After you ship this PR and some rounds are evaluated, please review the Grafana dashboard(s) and remove the charts that visualise these metrics and no longer have data.

@pyropy
pyropy enabled auto-merge (squash) June 26, 2025 17:12
@pyropy
pyropy merged commit 5c012b9 into main Jun 26, 2025
5 of 6 checks passed
@pyropy
pyropy deleted the chore/remove-fraud-detection branch June 26, 2025 17:13
@github-project-automation github-project-automation Bot moved this to ✅ done in CheckerNetwork Jun 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

Status: ✅ done

Development

Successfully merging this pull request may close these issues.

Remove Fraud Detection Logic From Evaluation Step

4 participants