Skip to content

feat(snapshot): support CAP-85 ExternalRef contract executables and offline spec resolution (#2703) - #2853

Closed
jdjioe5-cpu wants to merge 1 commit into
stellar:mainfrom
jdjioe5-cpu:feat/issue-2703-snapshot-contract-executables
Closed

jdjioe5-cpu wants to merge 1 commit into
stellar:mainfrom
jdjioe5-cpu:feat/issue-2703-snapshot-contract-executables

Conversation

@jdjioe5-cpu

Copy link
Copy Markdown

What

Closes #2703.

This PR adds full support for contract executables in snapshot operations:

  1. snapshot create captures CAP-85 ExternalRef executables:
    • Expanded SearchInputs with contract_data_keys: HashSet<(ScAddress, ScVal)> to allow targeted filtering on specific ContractData keys.
    • When encountering a ContractExecutable::ExternalRef(external_ref), snapshot create tracks the reference entry key (external_ref.executable_owner, ScVal::ExecutableTag(external_ref.tag)) for the next search pass.
    • When matching an ScVal::ExecutableTag entry, decodes the referenced 32-byte Wasm Hash into next.wasm_hashes, ensuring the underlying ContractCode is discovered and included in the snapshot.
    • Replaced silent _ => {} wildcard with explicit, exhaustive handling for all three ContractExecutable variants (Wasm, StellarAsset, ExternalRef).
  2. Offline contract spec and executable resolution:
    • Implemented snapshot inspect/resolution helpers in cmd/soroban-cli/src/commands/snapshot/inspect.rs:
      • get_contract_instance
      • resolve_external_ref_wasm_hash
      • get_wasm_from_hash
      • get_wasm_hash_for_contract
      • get_contract_wasm
      • get_contract_spec
    • Fully mirrors the RPC resolution behavior (get_spec.rs, wasm.rs) for offline snapshot analysis across StellarAsset, Wasm, and ExternalRef.
  3. Tests:
    • Added unit tests in inspect.rs testing StellarAsset built-in spec extraction, direct Wasm resolution, and two-hop ExternalRef resolution (Instance -> ExecutableTag ContractData -> Wasm Hash -> ContractCode -> Bytecode/Spec).
    • Added unit test in create.rs verifying SearchInputs filtering and expansion for ExternalRef.

Why

Previously, snapshot create only handled Wasm and StellarAsset, while ExternalRef fell into a catch-all _ => {} and was silently dropped. As a result, snapshots of contracts using externally-managed executables were incomplete, missing both the reference entry and the underlying Wasm bytecode. Furthermore, there were no offline helpers to resolve contract specs or executables directly from a LedgerSnapshot.

@github-project-automation github-project-automation Bot moved this to Backlog (Not Ready) in DevX Oct 23, 2026
@github-project-automation github-project-automation Bot moved this from Backlog (Not Ready) to Done in DevX Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Support contract executables when working with snapshots

2 participants