Skip to content

Fix stake program panics and failures when testing with mainnet-forked state#346

Open
aoikurokawa wants to merge 1 commit into
LiteSVM:masterfrom
aoikurokawa:ak/stake
Open

Fix stake program panics and failures when testing with mainnet-forked state#346
aoikurokawa wants to merge 1 commit into
LiteSVM:masterfrom
aoikurokawa:ak/stake

Conversation

@aoikurokawa
Copy link
Copy Markdown

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.so
    was compiled against solana-vote-interface v2.x and only knew
    VoteStateVersions discriminants 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() is
    hard-coded to 16 KiB (512 max entries). Initialising via set_sysvar
    allocated that full padded buffer, so sol_get_sysvar reads beyond
    the actual data returned zeros instead of an error. The Stake BPF
    program asserts entry_epoch == target_epoch after each partial read,
    causing a panic at any epoch >= 1 for operations that read stake
    history (e.g. Merge, Split, DelegateStake). The account is now
    initialised with the exact serialized size so out-of-bounds reads fail
    cleanly.

  • Populate StakeConfig account: The deprecated StakeConfig account
    (StakeConfig11111111111111111111111111111111) was never created,
    causing DelegateStake instructions that pass it as an account to
    fail. It is now populated in set_sysvars() with the correct
    config-program encoding (8-byte key-count header +
    bincode(Config::default())).

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.

1 participant