Skip to content

wasm-sdk: read removal records' kept values under a contract no older than the records #6059

Open

Description

@QuantumExplorer

getContractDocumentRemovals and getContractDocumentRemovalsWithProofInfo (packages/wasm-sdk/src/queries/contract_moderation.rs) decode each removal record's kept fields under a document type taken from get_or_fetch_contract: the cached contract, or one fetched before the records.

A compatible contract update can add members to a kept object field. Kept values are decoded under the schema they are read with, which reads only the members it declares. So a contract older than the records (stale in the cache, or answered by a lagging node) silently leaves out a member the record holds.

#6056 added ContractDocumentRemovalsPageQuery::fetch_with_kept_values in rs-sdk. It fetches the records first, then the contract, only when a record keeps values. It requires the contract's block height to be at least the records', asks for the contract again up to twice, and otherwise fails with StaleNode. The mobile FFI uses it.

To do:

  • Make both wasm reads use that operation, so the schema is never older than the records.
  • The WithProofInfo variant still has to return the records' metadata and proof. That probably means a variant of fetch_with_kept_values that also returns them.
  • A record that keeps no values should still cost the records' request alone.

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