feat: add litesvm-persistence crate for state snapshot save/load#319
Open
Rhovian wants to merge 2 commits intoLiteSVM:masterfrom
Open
feat: add litesvm-persistence crate for state snapshot save/load#319Rhovian wants to merge 2 commits intoLiteSVM:masterfrom
Rhovian wants to merge 2 commits intoLiteSVM:masterfrom
Conversation
Add the ability to save and restore LiteSVM state to/from disk, enabling hot-reload dev workflows, CI test fixture caching, and debugging. - New `persistence-internal` feature flag on core litesvm crate exposing getters, setters, and cache rebuild methods - New `litesvm-persistence` workspace crate with public API: save_to_file, load_from_file, to_bytes, from_bytes - Two-pass restoration: bulk insert accounts first, then rebuild sysvar cache and program cache to avoid ordering dependencies - Bincode serialization with version byte for forward compatibility - Serde remote derives for upstream types lacking serde (FeeStructure, ComputeBudget) - 16 roundtrip tests including BPF program execution after restore Closes LiteSVM#303
69a91aa to
f1784f5
Compare
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.
Add the ability to save and restore LiteSVM state to/from disk, enabling hot-reload dev workflows, CI test fixture caching, and debugging.
persistence-internalfeature flag on core litesvm crate exposing getters, setters, and cache rebuild methodslitesvm-persistenceworkspace crate with public API: save_to_file, load_from_file, to_bytes, from_bytesOne note on restore semantics:
rebuild_caches()currently rebuilds the builtin runtime by callingset_builtins().I think that is the right tradeoff for this PR, since the target workflow is persistence for standard
LiteSVM::new()environments, where rebuilding builtins/runtime state is effectively idempotent.The limitation is that restore is not intended to exactly preserve custom environments that mutate builtin accounts or intentionally strip builtins. Supporting that cleanly would likely require splitting runtime-environment rebuild from builtin-account insertion, which felt like too much scope for an otherwise additive persistence PR.
Happy to document this explicitly and leave stricter round-trip guarantees for custom builtin setups as a follow-up if desired.
Closes #303