-
Notifications
You must be signed in to change notification settings - Fork 14
fix: prevent duplicate piece IDs in schedulePieceDeletions #228
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: prevent duplicate piece IDs in schedulePieceDeletions #228
Conversation
- Add descriptive names to mapping keys for better readability - Optimize array processing by copying elements and deleting entire array - Replace individual pop() calls with bulk array deletion
Signed-off-by: Jakub Sztandera <[email protected]>
c9b4cb5 to
bdb1ce7
Compare
Also add a redudant but explicit case that zero sized pieces won't be added to the data set Signed-off-by: Jakub Sztandera <[email protected]>
bdb1ce7 to
fa640b3
Compare
|
Hey, @Chaitu-Tatipamula, I pushed two commits, one of which removes the whole slots when clearing out the list. |
Kubuxu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGWM, but would like a second set of eyes from @wjmelements given that I pushed some code into this branch
src/PDPVerifier.sol
Outdated
| // This is a redudant check as Cids.isPaddingExcessive already checks for pieces which would result in leafCount == 0 | ||
| // but we keep it here for clarity | ||
| revert IndexedError(callIdx, "Leaf count of the pieece must be greater than 0"); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm for removing redundant checks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They become untestable branches in the codecoverage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added it because I spent a good 15 minutes verifying that it is actually true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but I get that, hmmm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can leave your comment about the assumption to preserve your hard work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the redundant check and just improved docstrings.
Signed-off-by: Jakub Sztandera <[email protected]>
Fix: Prevent duplicate piece IDs in schedulePieceDeletions
Problem
The
schedulePieceDeletionsfunction didn't check for duplicate piece IDs, allowing the same piece to be scheduled for removal multiple times. This could happen within a single call or across multiple calls.Changes
isScheduledForRemovalmapping for O(1) lookups for duplicate checkingschedulePieceDeletionsto validate against existing scheduled removalsnextProvingPeriodto prevent stale stateTests
testSchedulePieceDeletionsDuplicatePrevention: Verifies duplicate detection works for both within-call and cross-call scenariostestMappingClearedAfterRemoval: Ensures mapping is properly cleared after removals are processedFixes #227