Guard against full exit overwriting same-batch partial withdrawal - #798
Open
cyc60 wants to merge 8 commits into
Open
Guard against full exit overwriting same-batch partial withdrawal#798cyc60 wants to merge 8 commits into
cyc60 wants to merge 8 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The greedy full-exit loop in
_get_withdrawalshad no guard against a validator already present in thewithdrawalsdict. A compounding validator can be assigned a partial withdrawal by the mid-loop top-up and also appear later in the exit order; a subsequent iteration would then overwrite the partial amount withGwei(0)— silently converting the partial into a full exit — whilequeued_assetshad already been decremented for both the partial amount and the full balance, under-requesting the remainder.With the partial-capacity accounting fixed (#796), the top-up always saturates the remaining queued assets and the loop terminates before this can happen, so the overwrite is not reachable through normal inputs today. This guard is defense-in-depth: correctness currently rests on the unenforced "top-up always saturates" invariant, and any future change to the top-up gate, exit ordering, or partial-allocation policy would silently reintroduce a fund-affecting bug. The regression test forces an under-saturating allocation via a patched
_get_partial_withdrawalsto pin the boundary independently of that invariant.Stacked on #797.