Skip to content

Deprecate DelegateCtx put/update/subscribe_contract wrappers; rename get_contract_state (freenet-core#5637) #132

Closed

Description

@sanity

Delegate contract write/subscribe host functions are being removed from freenet-core

freenet/freenet-core#5637 (PR freenet/freenet-core#5638) removes the node-side host functions behind three public DelegateCtx methods:

DelegateCtx method host import after #5638
put_contract_state __frnt__delegate__put_contract_state removed
update_contract_state __frnt__delegate__update_contract_state removed
subscribe_contract __frnt__delegate__subscribe_contract removed
get_contract_state __frnt__delegate__get_contract_state(_len) kept, same names

Why. The write functions wrote the raw Storage and bypassed the node's state-store chokepoints, so every side effect those perform had to be copied by hand. Two omissions reached production (freenet-core #4683, #5479). subscribe_contract only worked for a contract the node already held. A delegate should write by emitting OutboundDelegateMsg::PutContractRequest / UpdateContractRequest, and subscribe with SubscribeContractRequest. Those go through the node's normal path and, since freenet-core #5615, reach the network.

Effect on SDK users. A delegate that calls one of the three removed methods fails to instantiate on a node with #5638, with a named missing-import error. A delegate that only links stdlib is unaffected, because unused imports are dropped. No delegate in river, delta, harvest, ghostkeys, atlas, freenet-bitcoin or raven calls them.

What stdlib should do

  1. Deprecate put_contract_state, update_contract_state and subscribe_contract on DelegateCtx, pointing at the outbound-message equivalents, then remove them in a later breaking release. subscribe_contract_checked (0.10.0) imports __frnt__delegate__subscribe_contract_checked, which freenet-core has never provided; it needs the same treatment.
  2. Rename the read to say what it does. get_contract_state returns only the state this node already holds, and None means "not held here", not "does not exist". Suggested: add local_contract_state over the same __frnt__delegate__get_contract_state(_len) imports and deprecate get_contract_state as an alias. freenet-core deliberately kept the import names so existing delegates keep loading.
  3. Correct delegate_interface.rs (around line 884 in 0.10.0). It currently recommends "the V2 host-function API (the freenet_delegate_contracts import namespace)" as the forward-compatible path for delegates. After #5638 that namespace holds only the read.
  4. Stop calling this the "V2" API in docs. There is one delegate API version, DelegateWasmAPIVersion::V1.

Before starting, check: the local, unpushed branch feat/delegate-subscription-api (last commit 2026-08-22) documents these wrappers as the public delegate API, and a separate chore/deprecate-lone-subscribe branch exists. Check with whoever owns them first so the work doesn't collide.

[AI-assisted - Claude]

Activity

  1. added a commit that references this issue on Sep 22, 2026
  2. sanity commented on Oct 15, 2026

    @sanity
    ContributorAuthor

    Closing: the deprecation half is done. #134 (merged) removed the DelegateCtx put/update/subscribe wrappers outright, since no released freenet-core provides those host imports. The remaining get_contract_state → local_contract_state rename is cosmetic and would need a stdlib release plus a core bump; open a fresh issue if it's still wanted.

    [AI-assisted - Claude]

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