Skip to content

feat: debounce/throttle duplicate proof-verification calls (#1974) - #2133

Merged
RUKAYAT-CODER merged 3 commits into
EarnQuestOne:mainfrom
Chinonso-Peter:feat/issue-1974-verification-dedup
Jul 30, 2026
Merged

feat: debounce/throttle duplicate proof-verification calls (#1974)#2133
RUKAYAT-CODER merged 3 commits into
EarnQuestOne:mainfrom
Chinonso-Peter:feat/issue-1974-verification-dedup

Conversation

@Chinonso-Peter

Copy link
Copy Markdown
Contributor

Summary

Adds two-layer deduplication for proof-verification (approve) requests:

  1. In-flight dedup — concurrent approveSubmission calls for the same submission ID share a single promise, avoiding redundant on-chain approve_submission invocations.
  2. Result cache — successful verification results are cached for 5 seconds, preventing re-execution of DB lookups, CAS updates, and chain calls on rapid retries. Failures are never cached so legitimate retries (e.g. after a chain rollback) always re-execute.

Changes

  • VerificationDedupService (src/common/services/verification-dedup.service.ts) — generic in-flight dedup + TTL result cache.
  • SubmissionsService.approveSubmission now delegates through VerificationDedupService.executeWithDedup with key approve:<submissionId>.
  • New metrics registered: submission_approval_dedup_hits_total (in-flight reuse) and submission_approval_cache_hits_total (cache hit).
  • SubmissionsModule updated to provide VerificationDedupService.
  • Unit tests for both VerificationDedupService (12 tests) and dedup integration in SubmissionsService (4 new tests).
  • Documentation in docs/VERIFICATION_DEDUP.md.

Before/After

Scenario Before After
2 concurrent approves, same submission 2 chain calls (one fails CAS) 1 chain call (in-flight dedup)
Rapid retry after successful approve Full re-execution → CAS conflict Cache hit → instant response
Retry after chain-failure rollback Re-executes (correct) Re-executes (failures not cached)

Tests

All 26 related tests pass (12 dedup service + 14 submissions service). 1018 other tests unchanged. No regression.

Closes #1974

Add VerificationDedupService that deduplicates in-flight verification
requests per submission ID and caches recent successful results briefly.

- In-flight dedup: concurrent approve calls for the same submission
  share a single promise instead of starting redundant on-chain work.
- Result cache: successful verification results cached for 5 seconds,
  avoiding re-execution of DB lookups, CAS updates, and chain calls.
- Failures are never cached, so legitimate retries (post-rollback) work.
- New metrics: submission_approval_dedup_hits_total and
  submission_approval_cache_hits_total.
- Documentation in docs/VERIFICATION_DEDUP.md.

Closes EarnQuestOne#1974
@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@Chinonso-Peter Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Chinonso-Peter

Copy link
Copy Markdown
Contributor Author

@RUKAYAT-CODER please review

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

kindly resolve conflict

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Thank you for contributing to the project.

@RUKAYAT-CODER
RUKAYAT-CODER merged commit ed491ca into EarnQuestOne:main Jul 30, 2026
2 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Debounce/throttle duplicate submission proof-verification calls

2 participants