Skip to content

perf: send a schema reference in get-block-data instead of the full schema - #6402

Merged
Pyatakov merged 2 commits into
hashgraph:developfrom
Climission:perf/get-block-data-schema-reference
Aug 3, 2026
Merged

perf: send a schema reference in get-block-data instead of the full schema#6402
Pyatakov merged 2 commits into
hashgraph:developfrom
Climission:perf/get-block-data-schema-reference

Conversation

@vshvets-bc

Copy link
Copy Markdown
Collaborator

Problem

requestVcDocumentBlock and requestVcDocumentBlockAddon getData() embed the full schema (document + context) in every form block. For policies with large schemas the same schema is serialized once per form block, so get-block-data responses can reach tens of MB. That payload is JSON.parse/JSON.stringify-d as it is relayed between services (which do not read it), kept in memory on the client, and re-fetched on every block update — the repeated multi-MB serialization blocks the single Node event loop and slows unrelated requests.

Change

Emit a lightweight schema reference { id, iri, uuid, name, version } instead of the full document/context. The frontend resolves the full schema once by id (cached and de-duplicated) via the existing GET /schema/:id.

  • Much smaller get-block-data responses for schema-heavy forms.
  • Backward-compatible: the frontend uses a full schema (with document) exactly as before, so the client change is a no-op until the backend sends a reference. The change is sequenced so the frontend can ship first.

Details

  • policy-service: request-vc-document-block.ts, request-vc-document-block-addon.tsgetData returns the reference.
  • frontend: SchemaService.getSchemaById + cached/de-duplicated/error-evicting resolveSchemaById; request-document-block(-addon) _onSuccess resolves a reference to the full schema before the existing render flow.

Tests

  • policy-service (new request-vc-getdata-reference.test.mjs): getData emits a reference, not document/context. Passing.
  • frontend (new schema.service.spec.ts): endpoint, concurrent-subscriber de-dup, cache-hit, and error-eviction/retry.

Notes for reviewers

  • The frontend package was not built in this environment; the policy-service change and its test build and pass.
  • Worth confirming there is no non-frontend consumer of get-block-data that relies on the embedded document/context (e.g. remote/multi-policy interaction). The id/iri are still present for anything that needs to look the schema up.

…chema

request-vc-document-block(-addon) getData embedded the full schema
(document + context) in every form block, so get-block-data responses
grew to tens of MB for policies with large schemas - parsed and
re-serialized across services and refetched by the client.

Emit a lightweight schema reference { id, iri, uuid, name, version };
the client resolves the full schema once by id (cached, de-duplicated)
via GET /schema/:id. The frontend is backward-compatible: a full schema
(document present) is used as before, so the client change is a no-op
until the backend sends a reference.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vshvets-bc
vshvets-bc requested review from a team as code owners July 21, 2026 18:49
@Pyatakov Pyatakov self-assigned this Jul 23, 2026
…f rendering a blank form

Falling back to the bare reference (no `document`) made `parseDocument()`
a no-op, so `fields` stayed empty and the user saw a silently blank form.
Route the failure through `_onError` so it hits the normal error/loading path.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Pyatakov
Pyatakov merged commit 9678870 into hashgraph:develop Aug 3, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants