Skip to content
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] Fix bug dropping first checkpoint in castVote #227

Merged
merged 5 commits into from
Jan 10, 2025

Conversation

zpoken
Copy link
Collaborator

@zpoken zpoken commented Jan 9, 2025

No description provided.

@zpoken zpoken requested review from Birua and djb15 January 9, 2025 17:43
mdulin2
mdulin2 previously approved these changes Jan 9, 2025
@zpoken
Copy link
Collaborator Author

zpoken commented Jan 9, 2025

The error in the test is related to the fact that two instructions combined into one transaction still did not get into one block. This was unexpected for me.

@zpoken
Copy link
Collaborator Author

zpoken commented Jan 9, 2025

The test assumes that we will overwrite the first checkpoint after creating a new account checkpoint. I managed to do this during local testing. Checked several times. Apparently this is not guaranteed in the test.

@zpoken
Copy link
Collaborator Author

zpoken commented Jan 10, 2025

The explanation for the error in the test turns out to be this:
In the CreateCheckpoints instruction, we copy the checkpoint.timestamp from the last checkpoint of the previous account.
https://github.com/wormhole-foundation/multigov/blob/solana/fix/bug-dropping-first-checkpoint-in-castVote/solana/programs/staking/src/lib.rs#L146
So to overwrite the first checkpoint we need to add the last checkpoint and add the second checkpoint in the same block. In this case the second checkpoint will not be created. That is, we need to combine not two instructions, but three instructions into one transaction.

@zpoken zpoken requested a review from mdulin2 January 10, 2025 05:07
@zpoken zpoken merged commit e1478a5 into main Jan 10, 2025
6 checks passed
@nik-suri nik-suri deleted the solana/fix/bug-dropping-first-checkpoint-in-castVote branch January 10, 2025 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants