Skip to content

feat(sdk): make TrustedHttpContextProvider report its network so the SDK refuses a mismatch #5766

Open

Description

@PastaPastaPasta

ContextProvider::network() (added in #5721) lets SdkBuilder::build and Sdk::set_context_provider refuse a provider built for another network than the SDK's. VerifiedHttpContextProvider reports its network, but TrustedHttpContextProvider keeps the default None, even though it serves exactly one network (self.network, used by get_platform_activation_height in packages/rs-sdk-trusted-context-provider/src/provider.rs). So a trusted provider for testnet on a mainnet SDK is still accepted. WasmTrustedContext forwards network(), so it forwards None too.

A mismatch fails closed: proofs signed by the other network's quorums don't verify. But it isn't harmless. The SDK's network also picks its initial protocol version (min_protocol_version(self.network) in SdkBuilder::build) and the network of DashPay invitation keys.

Proposal

  • Implement network() returning Some(self.network) on TrustedHttpContextProvider.
  • Add a native regression test: a testnet TrustedHttpContextProvider on a mainnet SdkBuilder is refused by both build and set_context_provider.
  • Fix the in-repo setups this would refuse. packages/dash-platform-balance-checker/src/main_trusted.rs builds a testnet trusted provider on SdkBuilder::new(...) without with_network, and the builder defaults to mainnet. It needs .with_network(Network::Testnet).
  • List it as a breaking change. Native Rust users whose builder network differs from their trusted provider's start getting Error::Config from build/set_context_provider. The FFI (dash_sdk_create_trusted) and wasm-sdk factories pass one network to both, so they are unaffected.

Why separately from #5721

#5721 adds the check for the new verified provider, which has no existing users. Retrofitting it to the trusted provider changes released behaviour for existing native consumers. That deserves its own changelog entry and review, not a late addition to a feature PR whose breaking-change list was already reviewed. #5721 lists this gap under "Known limitations".

🤖 Generated with Claude Code

Activity

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