Skip to content

Accept custom snapshot sources in Env::from_ledger_snapshot#1620

Merged
leighmcculloch merged 37 commits intomainfrom
rs-soroban-sdk-snapshot-source
Dec 18, 2025
Merged

Accept custom snapshot sources in Env::from_ledger_snapshot#1620
leighmcculloch merged 37 commits intomainfrom
rs-soroban-sdk-snapshot-source

Conversation

@leighmcculloch
Copy link
Copy Markdown
Member

@leighmcculloch leighmcculloch commented Nov 14, 2025

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:

@leighmcculloch leighmcculloch changed the base branch from main to rs-soroban-sdk-ledgerinfo-default-testutils November 14, 2025 11:26
@leighmcculloch

This comment was marked as resolved.

Base automatically changed from rs-soroban-sdk-ledgerinfo-default-testutils to main November 14, 2025 17:56
@leighmcculloch

This comment was marked as resolved.

@leighmcculloch leighmcculloch changed the base branch from main to rs-soroban-sdk-file-number-at-start November 17, 2025 11:57
@leighmcculloch leighmcculloch changed the title Accept custom snapshot sources in Env::from_ledger_snapshot Fork Testing #2: Accept custom snapshot sources in Env::from_ledger_snapshot Nov 17, 2025
Base automatically changed from rs-soroban-sdk-file-number-at-start to main November 18, 2025 22:50
Copy link
Copy Markdown
Contributor

@mootz12 mootz12 left a comment

Choose a reason for hiding this comment

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

Small comment on naming, looks good otherwise

@leighmcculloch
Copy link
Copy Markdown
Member Author

@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.

@leighmcculloch leighmcculloch marked this pull request as ready for review December 12, 2025 22:08
Copilot AI review requested due to automatic review settings December 12, 2025 22:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 SnapshotSourceInput struct that wraps source, ledger_info, and snapshot parameters
  • Implemented From<LedgerSnapshot> for backward compatibility
  • Modified Env::from_ledger_snapshot to accept impl Into<SnapshotSourceInput> instead of directly accepting LedgerSnapshot

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

Copy link
Copy Markdown
Contributor

@mootz12 mootz12 left a comment

Choose a reason for hiding this comment

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

LG2M. Had one clarification question on docs.

@leighmcculloch leighmcculloch added this pull request to the merge queue Dec 16, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 16, 2025
@leighmcculloch leighmcculloch added this pull request to the merge queue Dec 18, 2025
Merged via the queue into main with commit f677ce8 Dec 18, 2025
95 checks passed
@leighmcculloch leighmcculloch deleted the rs-soroban-sdk-snapshot-source branch December 18, 2025 11:14
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.

3 participants