-
Notifications
You must be signed in to change notification settings - Fork 1
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
[solana] Skip last checkpoint in filled checkpoints account #261
[solana] Skip last checkpoint in filled checkpoints account #261
Conversation
The idea of copying the last checkpoint value in a filled checkpoint account to a new checkpoint account implied that the last value in the account would never be used as a valid checkpoint. When we go through the checkpoints in the vote_weight window, we have to skip the last checkpoint in the filled account!!! Thus, we have an error in this condition: |
I also put the cast_vote tests in a separate test file, because api_test.ts was quite large. |
Considering the last value in a checkpoint account and the first value in the next checkpoint account are always same, it should not be correct to say the last checkpoint of a filled account has a non-valid value. The reason behind the check in https://github.com/wormhole-foundation/multigov/blob/main/solana/programs/staking/src/lib.rs#L550, should be to prevent using a filled checkpoint account from past, so it is only for the case where PR creates an unnecessary burden for a user when Consider this case:
Currently this part of the program seems to work as expected, it does indeed counts the same value twice (once in last index, once in first index of the next account), but instead of optimizing this, giving the user flexibility to not create a checkpoint when it is not necessary might be a better approach. Apart from this, I would like to bring attention to last value of the checkpoint account is not an invalid value. Thinking that can lead to problems in future developments. |
This is not always true, as the value in the first checkpoint can be overwritten if both the account creation and delegation instructions are executed within the same block. I have added a new test that demonstrates this. |
This is true, but other than that we always require the next account to be created as soon as the previous one is full. In fact, no instructions work for a user account until the next checkpoints account is created. |
Understood your point, you are mentioning in the case that: in the same timestamp account is filled, a new checkpoint is created and a new delegate happened. Thank you for clarification with test. |
Logic is sane to me but just took some time to reason about. If the checkpoint limit is 5 and it only has four elements, it will break since it's the end of it. If the checkpoint is full with 5 elements, then the final checkpoint is skipped, requiring the NEXT checkpoint account to be provided. Tests also seem fairly comprehensive. |
No description provided.