Skip to content

fix(calculated-price): require decimals quorum before scaling - #5626

Draft
kyleburton-cl wants to merge 1 commit into
mainfrom
fix/hackerone-3846990-calculated-price-decimals-quorum
Draft

kyleburton-cl wants to merge 1 commit into
mainfrom
fix/hackerone-3846990-calculated-price-decimals-quorum

Conversation

@kyleburton-cl

Copy link
Copy Markdown
Contributor

Description

calculated-price scales the computed result by a decimals exponent read from each source's response (when operandNDecimalsField and outputDecimals are configured). In fetchFromSources, sources that omit the field were filtered out before the consistency check, so the check passed when exactly one source reported it — and that single source's exponent then scaled the whole price by 10^delta, returned as a valid 200. Omission was tolerated for the exponent while the value still required a minAnswers quorum.

This change requires every successful source to report a valid integer exponent and for all reported values to agree; an omission is treated as a disagreement and the request fails closed (502).

Changes

  • packages/composites/calculated-price/src/transport/computePrice.ts — no longer filter omitters before the consistency check; require validDecimals.length === successfulResults.length and a single unique value. Tighten validation to Number.isInteger (rejects non-numeric / non-integer values the previous !Number.isNaN guard allowed).
  • packages/composites/calculated-price/test/integration/adapter.test.ts — regression test: two sources with minAnswers=2, only one reports decimals → expects 502.
  • .changeset/calculated-price-decimals-quorum.md — patch changeset.

Steps to Test

  1. yarn && yarn setup
  2. yarn test packages/composites/calculated-price/test
  3. Confirm the new test returns failure when only some upstream responses report the decimals field passes (502), and the existing decimal-scaling tests still pass (200 when all sources agree, 502 on mismatch / all-missing).

Quality Assurance

  • If a new adapter was made, or an existing one was modified so that its environment variables have changed, update the relevant infra-k8s configuration file. — N/A: no environment variable changes.
  • If a new adapter was made, or an existing one was modified so that its environment variables have changed, update the relevant adapter-secrets configuration file. — N/A: no secret changes.
  • If a new adapter was made, or a new endpoint was added, update the test-payload.json file with relevant requests. — N/A: no new endpoint.
  • The branch naming follows git flow (feature/x, chore/x, release/x, hotfix/x, fix/x) or is created from Jira.
  • This is related to a maximum of one Jira story or GitHub issue. — DF-26320
  • Types are safe (avoid TypeScript/TSLint features like any and disable, instead use more specific types).
  • All code changes have 100% unit and integration test coverage. — the new omission branch is covered by the added integration test.

Every successful source must report the decimals field and agree; an
omission is now treated as a disagreement (502) instead of being filtered
out before the consistency check. Previously a single source reporting the
field could dictate the scaling exponent while other sources omitted it,
shifting the delivered price by 10^delta.

Fixes HackerOne 3846990.
@changeset-bot

changeset-bot Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f98c538

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@chainlink/calculated-price-adapter Patch

Not sure what this means? Click here to learn what changesets are.

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

@kyleburton-cl
kyleburton-cl force-pushed the fix/hackerone-3846990-calculated-price-decimals-quorum branch from cfbc2b1 to f98c538 Compare November 24, 2026 00:06

This branch has not been deployed

No deployments
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