feat: add state persistence for LiteSVM#321
Draft
kc1116 wants to merge 1 commit intoLiteSVM:masterfrom
Draft
Conversation
Add a `litesvm-persistence` crate that can save and restore LiteSVM state to/from files or byte buffers using bincode serialization. Key design decisions: - Feature-gated `persistence-internal` on litesvm exposes getters/setters without polluting the public API - Two-pass account loading avoids MissingAccount errors when upgradeable programs are inserted before their ProgramData accounts - Compute budget is set before builtins so runtime environments are created with the correct budget - CRC32 checksums detect file corruption - Atomic temp-file-then-rename prevents corrupt snapshots on crash Persisted state includes: accounts, feature set, compute budget, fee structure, blockhash, airdrop keypair, sigverify/blockhash_check/ log_bytes_limit settings, and transaction history with capacity. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
litesvm-persistencecrate that can save and restore full LiteSVM state to/from files or byte buffers using bincode serializationpersistence-internalon litesvm exposes internal getters/setters without polluting the public APIMissingAccounterrors when upgradeable BPF programs are inserted before their ProgramData accountsPersisted state
Accounts, feature set, compute budget, fee structure (including compute_fee_bins), blockhash, airdrop keypair, sigverify/blockhash_check/log_bytes_limit settings, and transaction history with capacity.
Restore ordering
with_compute_budget()is called beforewith_builtins()so runtime environments are created with the correct budget. All accounts are bulk-inserted first (set_account_no_checks), then sysvar + program caches are rebuilt in a singlerebuild_caches()pass.Test plan
🤖 Generated with Claude Code