Skip to content

Add the data-feeds-proxy program - #1668

Closed
cawthorne wants to merge 11 commits into
feature/df-cre-solana-legacy-storefrom
feat/df-proxy-program
Closed

cawthorne wants to merge 11 commits into
feature/df-cre-solana-legacy-storefrom
feat/df-proxy-program

Conversation

@cawthorne

Copy link
Copy Markdown

Summary

Adds data-feeds-proxy, a stable address in front of a data feeds store (stacked on #1665). Like Stellar's data feeds proxy, one proxy serves every feed: the reader passes the data ID, and optionally the decimals it wants. Its program id and state account are what readers integrate with, so the store behind it can be swapped without readers changing the proxy they call.

DF1 readers are unaffected: on Solana they read the DF1 feed accounts through the DF1 store program, which the store's write-through keeps current.

Reads

Both take an optional round ID (the latest round when None) and return Round { round_id, answer, observations_timestamp, recorded_timestamp }.

  • read(data_id, round_id): the store's answer at its 18 decimals, unscaled.
  • read_scaled(data_id, decimals, round_id): the answer at the caller's decimals, at least the data ID's minimum (18 unless an admin lowers it with set_min_decimals) and at most 18. Truncates toward zero, and fails with RoundsToZero when a non-zero answer would become zero.

Every read calls the configured store's reader interface by CPI, after checking the passed program and state are the configured ones. A missing round fails with the store's NoDataPresent. There is no batch read: a transaction can carry several read instructions.

Administration

  • set_store (owner) points the proxy at another program implementing the reader interface. A reader keeps the proxy address but passes the new store's accounts, which clients resolve from the proxy state.
  • set_min_decimals (owner or feed admin), set_feed_admin, two-step ownership transfer.
  • No read gating and no per-feed freeze.

Also adds the chainlink-solana-data-feeds-proxy crate for customer programs, Go bindings, and mock reader instructions in dummy-receiver for the swap test.

Tests

  • Rust unit tests for the scaling rules.
  • Anchor spec contracts/tests/data-feeds-proxy.spec.ts (11): reads latest and by round, unconfigured and configured minimum decimals, RoundsToZero, feed admin authorization, store swap to a mock reader (and the old store's accounts being rejected), ownership transfer.
  • Go e2e TestDataFeedsStore reads through the proxy on a local validator.
  • Compute cost measured on a local validator: about 1.5k units for a direct store read, 6.4k for read and 11k for read_scaled.

A standalone proxy with a stable address in front of a data feeds
store, modelled on Stellar's multi-feed proxy: one proxy serves every
feed and the reader passes the data ID.

- read(data_id, round_id): the latest or a given round at the store's
  18 decimals. read_scaled(data_id, decimals, round_id) rescales the
  answer, within a per-feed minimum (18 unless an admin lowers it) and
  failing with RoundsToZero when a non-zero answer would become zero.
- Reads call the configured store's reader interface by CPI, after
  checking the passed program and state are the configured ones.
  set_store points the proxy at another store, so the proxy address
  survives a store swap.
- Owner and feed admins, two-step ownership, per-feed min decimals.
- chainlink-solana-data-feeds-proxy crate for customer programs, and
  Go bindings.
- dummy-receiver gains mock reader instructions for the swap test.
- Tests: Anchor spec, and a Go e2e step reading through the proxy on a
  local validator (about 6.4k compute units for read against 1.5k for
  a direct store read).
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

✅ API Diff Results - github.com/smartcontractkit/chainlink-solana/contracts

✅ Compatible Changes (1)

package github (1)
  • com/smartcontractkit/chainlink-solana/contracts/generated/data_feeds_proxy — ➕ Added

📄 View full apidiff report

- Events are CPI events (emit_cpi!), as in the store.
- Feed config PDAs and stored data IDs use the data ID zero padded to 32 bytes, as the store's
  accounts do, and FeedConfig gets reserved space for later per-feed read settings (e.g. SVR
  fallback time and sync iterations).
- Proxy state and feed config versions are checked on load.
- Tests follow the store's new accounts (event authorities, padded feed seeds); the Go e2e test
  reads through the proxy after the store change.
…a feed config

- One error enum: Unauthorized was a separate #[error_code] block numbered 6000 like
  InvalidDecimals and missing from the IDL. It is now ProxyError::Unauthorized (6007).
- set_min_decimals refuses to rewrite an existing FeedConfig with an unknown version.
@cl-sonarqube-production

Copy link
Copy Markdown

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
1.6% Duplication on New Code

See analysis details on SonarQube

…e proxy

- The store and proxy client crates read return data themselves instead of
  Anchor's Return::get, which panics and accepts data from any program: a
  missing or foreign answer fails with IncorrectProgramId, a malformed one
  with InvalidAccountData.
- The proxy crate only calls the proxy program it is built for; both crates
  document that callers pin the store or proxy state they trust.
- Proxy docs: round IDs restart after set_store, get_min_decimals needs the
  feed config to report a lowered minimum, the store is assumed at 18
  decimals.
Same as the store: initialize requires the program's upgrade authority
(checked through its ProgramData account) and fills a pre-created state
account of the exact size (new error InvalidAccount, 6008), so a timelock
holding the authority can create further proxies by proposal.
@cawthorne

Copy link
Copy Markdown
Author

Superseded by #1676, which has the store and the proxy in one PR. The branch stays.

@cawthorne cawthorne closed this Nov 10, 2026
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