Skip to content

Fix: Fetch StakeHistory sysvar and Stake program from mainnet#605

Open
aoikurokawa wants to merge 2 commits intosolana-foundation:mainfrom
aoikurokawa:ak/stake_history
Open

Fix: Fetch StakeHistory sysvar and Stake program from mainnet#605
aoikurokawa wants to merge 2 commits intosolana-foundation:mainfrom
aoikurokawa:ak/stake_history

Conversation

@aoikurokawa
Copy link
Copy Markdown

@aoikurokawa aoikurokawa commented Mar 31, 2026

Description

  • Fetch StakeHistory sysvar from remote RPC during init/reset — the Stake program accesses it via get_sysvar syscall (not as a transaction account), so lazy fetching never picks it up. Without this, Split panics with SBF program Panicked in src/sysvar/stake_history.rs
  • Replace LiteSVM's bundled Stake program (core_bpf_stake-1.0.1.so) with the live mainnet version — the bundled ELF was compiled against solana-vote-interface v2.x which only knows VoteStateVersions variants 0-2, but mainnet vote accounts now use V4 (discriminant 3), causing DelegateStake to fail with InvalidAccountData
  • Preserve all fetched accounts (StakeHistory, StakeConfig, Stake program + programdata) across garbage collection and network resets
  • Add get_raw_account method to SurfnetRemoteClient for fetching accounts without token/program classification

@aoikurokawa aoikurokawa changed the title Fix: proactively fetch and preserve StakeHistory sysvar from remote Fix: Fetch StakeHistory sysvar and Stake program from mainnet Mar 31, 2026
@aoikurokawa aoikurokawa marked this pull request as ready for review March 31, 2026 23:10
Copy link
Copy Markdown
Collaborator

@MicaiahReid MicaiahReid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like a lot of this should be fixed at the LiteSVM level:

  • the StakeConfig sysvar could be loaded during the set_sysvars call like the other sysvars are
  • the stake program could be loaded with the other default programs

This would remove a lot of the complexity here.

Could you also add an integration test that is reproducing the issue you're seeing, so we can verify this fixes the issue? With the integration test in place, we can easily try the litesvm fixes to make sure they resolve surfpool upstream

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.

2 participants