Skip to content

Conversation

@Snezhkko
Copy link
Contributor

@Snezhkko Snezhkko commented Nov 6, 2025

Replace limit - deleted with limit.saturating_sub(deleted) in PruneLimiter::deleted_entries_limit_left() to prevent underflow when the deleted count exceeds the current limit (which can happen after lowering limits mid-run).
Add tests to ensure the function returns Some(0) when deleted >= limit, including after lowering the limit via both set_deleted_entries_limit() and floor_deleted_entries_limit_to_multiple_of().
This change hardens the limiter against panic/wraparound and matches the intended semantics of “remaining deletions.”

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.

The change itself LGTM, can we please combine these tests into one that just checks a scenario with no saturation and with saturation?

@github-project-automation github-project-automation bot moved this from Backlog to In Progress in Reth Tracker Nov 6, 2025
@shekhirin shekhirin added the A-pruning Related to pruning or full node label Nov 6, 2025
@Snezhkko
Copy link
Contributor Author

Snezhkko commented Nov 6, 2025

The change itself LGTM, can we please combine these tests into one that just checks a scenario with no saturation and with saturation?

Yes, corrected test

@shekhirin shekhirin added this pull request to the merge queue Nov 6, 2025
Merged via the queue into paradigmxyz:main with commit 04093cc Nov 6, 2025
42 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Reth Tracker Nov 6, 2025
@Snezhkko Snezhkko deleted the fix/prune-limiter-saturating-left branch November 7, 2025 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-pruning Related to pruning or full node

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants