Skip to content

Saved contracts on devnet/regtest are not tied to a chain, and document FFIs resolve contracts from the cache only #6078

Open

Description

@QuantumExplorer

Basic explanation

SwiftExampleApp saves contracts with only their Network value, and AppState.loadKnownContractsIntoSDK preloads a new SDK with the saved contracts of its network, keyed by contract id. Two devnet configurations, or a devnet that was reset, share .devnet. So a contract saved on the old chain under a shared id (such as DashPay's) at an equal or higher version can shadow the new chain's copy.

For private document reads, newer_private_document_contract (#6052) keeps the held contract when the fetched version is not higher. The read then fails or reads under the stale schema.

Skipping the preload on configurable networks is not a fix today. SDKWrapper::data_contract in rs-sdk-ffi (18 call sites across the document FFIs: create, put, replace, delete, erase, transfer, purchase, price, fetch, history) reads only the context provider. A saved custom contract would then fail with "not found in the SDK's context provider". PersistentIdentity is keyed by networkRaw only too, so this is an app-wide gap for configurable networks.

Proposed

  1. An rs-sdk resolver that fetches and registers the proved contract on a cache miss, used by the document FFIs, with a cold-SDK test (a saved non-system contract, no intervening download).
  2. Record chain identity on saved rows for configurable networks, or drop the preload there once (1) lands.

Raised in the review of #6052, which narrows the preload from every network to the SDK's network.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions