-
Notifications
You must be signed in to change notification settings - Fork 26
program: reallocate stake account on zero lamports #82
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
base: main
Are you sure you want to change the base?
Conversation
this might also be a good time to think about how we are going to do fuzzing, because it is a small simple change that slihgtly changes behavior. ideally we have some kind of runner via mollusk that tells us something changed between the two versions, we can say "ok this is fine" and adjust the things we expect to be different, and confirm nothing unexpected changed by accident. i have no idea yet what impling this kind of flow would be like since it depends on multiple versions of the program and idk if it can really be part of ci... idk think about it |
9cf5be8
to
a4e9019
Compare
a4e9019
to
4d57d16
Compare
4d57d16
to
2d24e1c
Compare
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.
Looks great to me! I took another looks through the stakes cache, and I believe this will be safe.
The stakes cache only stores stake accounts with delegations, and if lamports go to 0 OR if the account can no longer be deserialized as a stake account, it gets removed from the cache. So essentially we'll go from deserializing StakeState::Uninitialized
and then failing to get its delegation.
We should be aware that this does create a DOS opportunity on stake accounts. If someone closes a stake account and then tops it up with lamports in the same transaction, it will be impossible to ever reuse it. We could relax the logic in withdraw
to treat a zero-length account the same as a StakeState::Uninitialized
-- what do you think?
im gonna leave this in draft until im back, i havent thought deeply about downstream effects the zero-len accounts or the ability to withdraw from them. at least we need to add test cases to make sure some of the other instructions refuse to interact with them. its probably fine since i believe everything goes through |
6936e9b
to
6ff30e2
Compare
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.
The new commit looks great to me! And yeah definitely good to think about all of the other interactions
instead of zeroing account data, we should realloc accounts to 0 size, to ease headaches of downstream programs dealing with stake accounts across multiple instructions in the same transaction
closes #71