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

Fix Logical Bug in isStaleReport Function #377

Merged
merged 3 commits into from
Dec 18, 2024
Merged

Conversation

dimkouv
Copy link
Contributor

@dimkouv dimkouv commented Dec 18, 2024

Pull Request: Fix Logical Bug in isStaleReport Function

Problem

The isStaleReport function contained a logical bug when comparing the on-chain sequence number (seqNr) with the report sequence number (latestSeqNr). The incorrect logic caused certain reports to be accepted and transmitted, leading to on-chain reverts.

Original (Buggy) Logic

if seqNr < latestSeqNr && len(decodedReport.MerkleRoots) == 0 {

Corrected Logic

if seqNr <= latestSeqNr && len(decodedReport.MerkleRoots) == 0 {

Issue Details

  • Bug: The condition seqNr < latestSeqNr was too restrictive, failing to account for cases where seqNr equals latestSeqNr.
  • Impact: Reports were incorrectly flagged as valid, causing unnecessary transmissions and on-chain reverts.

Fix

The condition is updated to include equality (<=) to ensure the comparison correctly identifies stale reports:

if seqNr <= latestSeqNr && len(decodedReport.MerkleRoots) == 0 {

Testing and Validation

  • Added/updated unit tests to verify the new logic.
  • Tested against scenarios that previously caused on-chain reverts to ensure the issue is resolved.

Additional Notes

  • This fix aligns the function's behavior with the intended logic for identifying stale reports.
  • Please review and confirm if additional edge cases should be considered.

Copy link

Metric dk/fix-stale-report-checks main
Coverage 76.8% 76.7%

@dimkouv dimkouv merged commit b26dfaf into main Dec 18, 2024
17 checks passed
@dimkouv dimkouv deleted the dk/fix-stale-report-checks branch December 19, 2024 10:13
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.

2 participants