program: rewrite process_split()
#90
Draft
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.
NOTE presently based on #87
i rewrote
Splitfrom scratch to fix #1 plus some other bugs with minimum delegation. i also tried to make it more readable.Splithas gone through several layers of changes which caused it to accumulate a lot of cruft, particularly because it originally ignored delegation, worked with lamports exclusively, and never used stake historycurrent
Splittriesmatchonce on source stake and share code for both theInitializedandStakecases in the unifiedvalidate_split_amount()function and then do more work for theStakecase after. it ends up being quite difficult to understand because:Stakeis deactivated it should actually follow the same logic asInitialized, not the logic forStakefeature_set::rent_exempt_split_destinationswas added in a minimally invasive wayi find
Splitthe most difficult stake operation to reason about. in rewritingprocess_split(), i decided to:matching on stake states as convenient rather than forcing the code to be structured around a singlematchthis results in a function that has a bit more boilerplate but none of the difficult calculations of the orginal
Spliti also made it an error to split 0 from
Uninitialized. i dont see any good reason to allow itthis soft-depends on #82 and #87, we could change it if either of those fail to land but i assume they will both land first. it was a total rewrite of
Split, so we definitely want more review care and possibly a scoped audit, so this should be merged after we cut the next stake program releasecloses #1