Skip to content

Support inverted observations for gRPC - #5302

Open
denis-chernov-smartcontract wants to merge 1 commit into
mainfrom
DS-3867
Open

Support inverted observations for gRPC#5302
denis-chernov-smartcontract wants to merge 1 commit into
mainfrom
DS-3867

Conversation

@denis-chernov-smartcontract

Copy link
Copy Markdown
Contributor

Closes #DS-3867

Description

Fixes a high-severity bug in the streams-adapter Go runtime: gRPC subscribers to an inverse pair (e.g. a client requesting TRY/USD against a provider that only publishes USD/TRY) received the un-inverted, reciprocal price — off by a factor matching the pair's magnitude (measured ~2,156x in one case) — delivered under the correct request's payload hash, with no error, flag, or other signal that the denomination was reversed.

The HTTP transport already handled this correctly: respondWithObservation reads each cache item's RequiresInverse flag and inverts before responding. The gRPC fan-out path in redcon.go's handleEval, however, published the raw provider observation to every subscriber of a transformed key regardless of that flag, so a client polling over HTTP and a client streaming the same request over gRPC would see different — reciprocal — values for the same underlying cache state.

Changes

  • redcon/redcon.go: the handleEval publish loop now looks up each subscriber's own RequiresInverse flag (per raw key, since a single provider feed can serve both a direct and an inverse subscriber) before publishing, inverting the observation for inverse subscribers. If inversion fails, that subscriber's update is skipped rather than falling back to publishing the raw (wrong) value.
  • helpers/inversion.go (new): InvertObservation and its private helpers, moved out of server so the HTTP and gRPC transports share a single implementation instead of duplicating (and risking diverging on) the reciprocal logic.
  • server/server.go: updated to call helpers.InvertObservation.

@changeset-bot

changeset-bot Bot commented Aug 19, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: e5d51a3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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.

1 participant