Accept custom snapshot sources in Env::from_ledger_snapshot#1620
Accept custom snapshot sources in Env::from_ledger_snapshot#1620leighmcculloch merged 37 commits intomainfrom
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
…k-snapshot-source
…k-snapshot-source
mootz12
left a comment
There was a problem hiding this comment.
Small comment on naming, looks good otherwise
|
@mootz12 I've simplified how this works so that it doesn't write out any new files and this is just an interface change to allow providing custom implementations for snapshots. Any file writing will be the job of the snapshot implementation itself if it wants to do caching on its own terms. |
There was a problem hiding this comment.
Pull request overview
This PR introduces a new SnapshotSourceInput struct to enable Env::from_ledger_snapshot to accept custom snapshot source types beyond just LedgerSnapshot. This provides flexibility for testing scenarios using different snapshot sources like RPCs, history archives, or meta lakes.
Key Changes:
- Introduced
SnapshotSourceInputstruct that wrapssource,ledger_info, andsnapshotparameters - Implemented
From<LedgerSnapshot>for backward compatibility - Modified
Env::from_ledger_snapshotto acceptimpl Into<SnapshotSourceInput>instead of directly acceptingLedgerSnapshot
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| soroban-sdk/src/testutils.rs | Adds SnapshotSourceInput struct and From<LedgerSnapshot> implementation; exports SnapshotSource and HostError from internal modules |
| soroban-sdk/src/env.rs | Updates from_ledger_snapshot signature to accept generic input convertible to SnapshotSourceInput; updates import to include SnapshotSourceInput |
mootz12
left a comment
There was a problem hiding this comment.
LG2M. Had one clarification question on docs.
What
Accept custom snapshot source input types as ledger snapshots through a new SnapshotSourceInput struct that wraps source, ledger_info, and snapshot parameters. Implement From for SnapshotSourceInput to maintain backward compatibility. Cache anything loaded from the snapshot source and write it out for reuse.
Why
Enables Env to be initialized from different snapshot source types beyond just the LedgerSnapshot file, providing more flexibility for testing scenarios while keeping the existing API intact. The snapshot source is only used to load the data once, then it is loaded from the cache file for test reproducibility and speed.
This will support hooking in more snapshot sources such as RPCs, history archives, and the meta lake which I am working on.
For #1448
Merging
Targeting
main, but dependent on: