Fix stake program panics and failures when testing with mainnet-forked state#346
Open
aoikurokawa wants to merge 1 commit into
Open
Fix stake program panics and failures when testing with mainnet-forked state#346aoikurokawa wants to merge 1 commit into
aoikurokawa wants to merge 1 commit 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.
Summary
Fixes three bugs that made the stake program unusable in LiteSVM when
testing against mainnet-forked state (reported in
solana-foundation/surfpool#605).
Update stake ELF to v5.0.0: The bundled
core_bpf_stake-1.0.1.sowas compiled against
solana-vote-interfacev2.x and only knewVoteStateVersionsdiscriminants 0–2. Delegating to a V4 vote account(discriminant 3, the current mainnet format) returned
InvalidAccountData.Replaced with
core_bpf_stake-5.0.0.so.Fix StakeHistory account size:
StakeHistory::size_of()ishard-coded to 16 KiB (512 max entries). Initialising via
set_sysvarallocated that full padded buffer, so
sol_get_sysvarreads beyondthe actual data returned zeros instead of an error. The Stake BPF
program asserts
entry_epoch == target_epochafter each partial read,causing a panic at any epoch >= 1 for operations that read stake
history (e.g.
Merge,Split,DelegateStake). The account is nowinitialised with the exact serialized size so out-of-bounds reads fail
cleanly.
Populate StakeConfig account: The deprecated
StakeConfigaccount(
StakeConfig11111111111111111111111111111111) was never created,causing
DelegateStakeinstructions that pass it as an account tofail. It is now populated in
set_sysvars()with the correctconfig-program encoding (8-byte key-count header +
bincode(Config::default())).