You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Register a fetched contract only with the context provider that verified it (DPNS registration, wallet document writes) #6292
TL;DR: If an app replaces the SDK's context provider while a DPNS registration or a wallet document write is in progress, the new provider can be handed a data contract it never checked itself.
User story
As a developer embedding the Rust SDK or platform-wallet, I want a contract I did not verify never to be injected into my context provider, to achieve a provider whose cache holds only contracts it authenticated.
Scenario
Base flow
An app starts a DPNS name registration, or a platform-wallet document write, then swaps the SDK's context provider (Sdk::set_context_provider) before the operation registers the contract it fetched.
Actual behavior
The fetched contract is registered with whichever provider is installed when registration runs, not the one that was in place when the contract was fetched and verified. The replacement provider receives a contract it did not authenticate.
Expected behavior
A fetched contract is registered only with the provider that was installed when the fetch started, and only while that provider is still installed. After a swap, neither provider is written to.
Steps to reproduce
Start one of the two operations below, call set_context_provider while its fetch is in flight, then inspect the new provider's registered contracts.
Detailed discussion
Two sites register through self.context_provider() read after the fetch:
Proposed fix, the pattern #5588 applies to Sdk::fetch_system_data_contract (commit 768820c): capture sdk.context_provider_arc() before the fetch, then register through that handle only if Arc::ptr_eq with the currently installed provider. set_context_provider installs a new Arc each time, so pointer equality means no swap happened. No Fetch API change is needed. Add a test that swaps the provider during the operation and asserts neither provider received the contract.
Low likelihood: it needs a provider swap during the operation.
Activity