Skip to content

fix: auto-load BPF upgradeable programs (#240)#269

Open
alex-sumner wants to merge 4 commits intoLiteSVM:masterfrom
alex-sumner:fix/auto-load-upgradeable-programs
Open

fix: auto-load BPF upgradeable programs (#240)#269
alex-sumner wants to merge 4 commits intoLiteSVM:masterfrom
alex-sumner:fix/auto-load-upgradeable-programs

Conversation

@alex-sumner
Copy link
Copy Markdown

Fixes #240

Summary

When programs are deployed via BPF Loader Upgradeable, only the ProgramData account gets written to the ExecutionRecord, not the Program account. This causes subsequent transactions to fail.

Changes

  • Set executable flag for Program accounts in sync_accounts()
  • Add load_all_existing_programs() to scan and load uncached programs
  • Auto-load programs during transaction execution if missing from cache
  • Sync BPF loader accounts even when not writable in execute_tx_helper()
  • Add load_existing_programs() public API
  • Add tests

Test Plan

  • cargo test --package litesvm --test bpf_upgradeable_autoload (4 tests pass)

@alex-sumner alex-sumner force-pushed the fix/auto-load-upgradeable-programs branch from ca12c1d to cfc9049 Compare March 25, 2026 09:27
@alex-sumner
Copy link
Copy Markdown
Author

Any feedback on this contribution would be welcome. At the moment we are maintaining our own fork of litesvm because we need these changes for some of our Solana tests. It would be great if this could be merged. Happy to look at it again if you think it needs changes, or just to hear your thoughts on it.

@Aursen
Copy link
Copy Markdown
Collaborator

Aursen commented Mar 27, 2026

The main problem of this PR is the impact on performance. What's the use case to it ?

@alex-sumner
Copy link
Copy Markdown
Author

alex-sumner commented Apr 1, 2026

The main problem of this PR is the impact on performance. What's the use case to it ?

Thanks, I agree it is too expensive. The use case is making freshly deployed or synced BPF upgradeable programs immediately invokable in LiteSVM without requiring a separate full-program reload step.

I’ve updated it so sync_accounts() no longer scans the full accounts DB after every transaction. The patch now only does what's needed for the upgradeable-loader case:

  • sync loader-owned program accounts from post-execution state even if they aren’t marked writable,
  • fix up upgradeable Program accounts to be executable when they deserialize as UpgradeableLoaderState::Program,
  • keep load_existing_programs() as an explicit recovery/init API

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.

BPF Loader Upgradeable programs not automatically loaded after deployment

2 participants