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(provider): check list size before calling range.nth #10460

Merged
merged 4 commits into from
Aug 23, 2024
Merged

Conversation

joshieDo
Copy link
Collaborator

@joshieDo joshieDo commented Aug 22, 2024

If the range has 0 database it will overflow and return empty (or undefined?)

Ended up refactoring the range logic into using one method: fetch_db_mem_range and applied the fix.
closes #10461

@joshieDo joshieDo added the C-bug An unexpected or incorrect behavior label Aug 22, 2024
@joshieDo joshieDo changed the title fix(provider): use saturating_sub to avoid int underflow fix(provider): use saturating_sub to avoid subtract with overflow Aug 22, 2024
Copy link
Collaborator

@shekhirin shekhirin left a comment

Choose a reason for hiding this comment

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

It should be if db_headers.is_empty() { ... } because range.nth(0) will advance range by 1

@joshieDo joshieDo changed the title fix(provider): use saturating_sub to avoid subtract with overflow fix(provider): check list size before calling range.nth Aug 22, 2024
Copy link
Collaborator

@shekhirin shekhirin left a comment

Choose a reason for hiding this comment

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

much better

@shekhirin shekhirin added A-db Related to the database A-blockchain-tree Related to sidechains, reorgs and pending blocks labels Aug 23, 2024
@joshieDo joshieDo added this pull request to the merge queue Aug 23, 2024
Merged via the queue into main with commit 8ba7821 Aug 23, 2024
34 checks passed
@joshieDo joshieDo deleted the joshie/fix-range branch August 23, 2024 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-blockchain-tree Related to sidechains, reorgs and pending blocks A-db Related to the database C-bug An unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor range functions on BlockchainProvider2
3 participants