Skip to content

Add the data-feeds-store program - #1676

Draft
cawthorne wants to merge 22 commits into
developfrom
feat/df-store-and-proxy
Draft

cawthorne wants to merge 22 commits into
developfrom
feat/df-store-and-proxy

Conversation

@cawthorne

@cawthorne cawthorne commented Nov 10, 2026 •

Copy link
Copy Markdown

Adds the data-feeds-store program for Chainlink Data Feeds written by CRE on Solana. This replaces the stacked #1665 (store) and #1668 (proxy).

One program. The store is a Solana port of the EVM DataFeedsStore without SVR, and it is also the program readers integrate with: there is no separate proxy. Each data ID has one feed account, PDA ["feed", state, data_id], holding its latest round, a ring of past rounds, the description, how it is read (minimum decimals, a read freeze) and how it is written (its own workflows, answer bounds, a write freeze, a DF1 link). Readers pass that one account.

Reports. The keystone forwarder delivers DON-signed reports to on_report. Each report is handled on its own, as on EVM: it is skipped with an event when its data ID is invalid, its feed hasn't been set, its writes are disabled, its workflow isn't allowed (the feed's own list, otherwise the store's default list), or it is future-dated, stale or out of range. The rest of the batch still lands.

Feeds are set by a feed admin. set_feeds creates feeds and sets their descriptions and, optionally, their own workflows; every per-feed setter also creates missing feeds. The admin pays the rent: the forwarder passes every account unsigned, so a report can't pay for a feed. Reports for unset feeds are skipped.

Reads match Stellar's proxy: latest_round(data_id, decimals) and get_round(data_id, round_id, decimals) return the answer at the decimals asked for, down to a per-feed minimum, and fail while the read freeze is set. No phase IDs. The chainlink-solana-data-feeds-store crate wraps those calls and can also decode a feed account directly, with no call.

DF1 write-through. A data ID linked to a DF1 feed also writes each round there through DF1's unchanged submit, signed by the store's df1_writer PDA. The store first checks everything submit could fail on, and skips only the DF1 write (with a reason) if any check fails. No generic report callbacks. The DF1 store program and dummy receiver are unchanged from develop.

Also: only the program's upgrade authority creates stores; Go bindings, Anchor specs and a Go end-to-end test with a real forwarder.

Measured (Go e2e, local validator, every transaction within mainnet's 64-account lock limit, no lookup tables):

  • One forwarder report at F=5: 1,207 bytes store-only, which fits a legacy transaction; 1,304 bytes with the DF1 write, which needs V1.
  • One V1 transaction at F=5: 40 store-only reports (3,898 bytes, 51 accounts) or 25 DF1-backed reports (3,752 bytes, 63 accounts).
  • 20 DF1-backed reports in one on_report: about 211k compute units; 20 store-only: about 94k.
  • set_feeds creating 20 feeds: about 238k compute units.

Tests: Rust unit tests, tests/data-feeds-store.spec.ts, and go test ./gotests -run 'TestDataFeedsStore$'.

Solana port of the EVM DataFeedsStore (SVR included) that receives
Data Feeds reports from a CRE DON through the keystone forwarder.

- data-feeds-store program: per-feed history ring, SVR paths, proxy
  configs, descriptions, workflow permissions and generic report
  callbacks. Non-SVR settings live in the feed account so a non-SVR
  report passes one store account; SVR paths keep a DataIdConfig.
- store: on_report_callback writes each round through to the existing
  DF1 feed account, rescaled to its decimals, once its writer is the
  data feeds store authority. Emits CacheRoundSubmitted/Skipped.
- chainlink-solana-data-feeds-store crate for CPI reads.
- Go bindings for data_feeds_store and the updated store.
- TS SDK: StoreFeed listens for CacheRoundSubmitted.
- Tests: Anchor spec, and a Go e2e test sending legacy transactions
  as CRE builds them (2 DF1-backed reports at F=2, 1 store-only
  report at F=5).
Drop the single forwarder program the store pinned, and its
update_forwarder_id instruction. As on EVM, a report is applied only
when its sender, workflow owner and workflow name match an allowed
workflow, so any number of forwarders (e.g. a separate forwarder
program per zone, as CRE mainline uses on Solana) is just more
workflow metadata.
The store ships without SVR and without per-feed proxy configs. Both
may come back later, SVR through a store version or a bolt-on
contract, and proxies live in their own program.

- Remove SVR paths: the data ID config account, its instructions, SVR
  descriptions, the SVR selection, fallback and sync logic, and the
  visible round exclusivity. Non-zero SVR path bytes in a data ID are
  reserved and rejected, so IDs keep their layout if SVR is added.
- Remove ProxyConfig, the proxy instructions and the proxy and direct
  reads.
- Add a reader interface proxies call: get_latest_round, get_round,
  get_decimals and get_description, with Borsh return data and
  18-decimal answers. NoDataPresent for a missing round.
- Drop svr_path_id and is_freshest from OnReportCallbackArgs and the
  SVR skip reason from the DF1 store callback. SVR can come back as a
  new callback instruction.
- The CPI crate is now the reader client.
- Keep FeedData layout (the visible round becomes reserved bytes).
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).
…gram callback signers, CPI events

- Accounts key data IDs zero padded to 32 bytes (feed, description PDAs and stored IDs), so a
  wider data ID format later keeps every account address. Data IDs stay 16 bytes on the wire, in
  events and in callback arguments, matching the EVM DataFeedsStore. FeedData keeps its size;
  _reserved0 stays free for an SVR visible round ID.
- on_report skips a report with an invalid (zero or SVR) data ID or for an uninitialized feed with
  an event instead of aborting the batch. Only a malformed payload, a mismatched feed account,
  callback accounts not passed as configured and a failing callback still abort.
- Report callbacks are signed by a callback authority PDA per callback program
  ([callback_authority, state, program]) instead of the store authority, and only programs the
  owner allowed (set_callback_program_allowed) can be configured. A callback program can no longer
  act as another program's signer, e.g. as a DF1 feed's writer. The store authority only holds
  recoverable tokens and SOL now. on_report no longer takes it.
- Events are CPI events (emit_cpi!) in the store and in the DF1 store's report callback, so they
  survive log truncation.
- close_feeds is removed: feeds are never deleted, as on the EVM store.
- get_latest_rounds reads up to 31 feeds at once, as the EVM store's getLatestRoundDataBatch.
- Account versions are checked on load.

Measured in TestDataFeedsStore: F=2 fits 1 report with DF1 write-through (1,143 B) or 2 store-only
reports in a legacy transaction; about 5k CU per store-only report and 21k CU per report with DF1
write-through, on top of the forwarder.
- 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.
…version checks on overwrite

- on_report reuses one FeedData buffer, the callback account lists and the callback instruction
  for every report, and serializes events straight into one reused instruction. The bump
  allocator never frees, so the per-report allocations ran out of the 32KiB heap at about 15
  reports (bytemuck zeroed_box panic). Measured now: 22 store-only reports in one on_report use
  ~103k CU, 20 with DF1 write-through ~389k CU, both within the default heap.
- One error enum: Unauthorized was a separate #[error_code] block numbered 6000 like
  ArrayLengthMismatch and missing from the IDL. It is now StoreError::Unauthorized (6026), so
  every code is unique and in the IDL; existing codes keep their numbers.
- set_callback_program_allowed and set_feed_descriptions refuse to overwrite an existing account
  with an unknown version.
- TestDataFeedsStore measures 12/20/22 store-only and 12/20 DF1-backed reports in a V0
  transaction with a lookup table.
…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.
…ck config

- get_latest_rounds reuses one buffer and reads a never-created feed (its
  own PDA, still empty) as a zero round; 31 feeds fit in one call.
- init_feeds, set_max_stored_reports, set_min_max_answers and the settings
  instructions reuse one feed buffer and emit through EventEmitter, so 20
  feeds fit in one admin instruction.
- on_report requires the feed to be writable before calling back, reads the
  callback's return data without a heap copy and only from the callback
  program, and treats a non-executable callback program as returning false.
- Skip events carry the sender.
- Reject a NUL byte in descriptions, invalid data IDs in permission checks,
  the callback authority in callback accounts, accounts or revert on a
  disabled callback, the store itself as an allowed callback program, and
  ring sizes that overflow the account length.
…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.
A closed upgradeable program stays executable, so the store still calls it;
the loader refuses ("Program is not deployed") and the transaction aborts
without storing the report. Clearing the callback lets reports land again.
Anyone could initialize a store under this program ID and emit events and
feed accounts indistinguishable from ours. initialize now requires the
program's upgrade authority (checked through its ProgramData account) and
takes a pre-created state account (#[account(zero)], exact size), so it
needs no other signer and an MCMS timelock holding the authority can create
further stores by proposal. Any number of stores can still be created.

anchor test loads workspace programs as upgradeable by the provider wallet.
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.
A feed is now one account: init_feeds takes each feed's description and
set_feed_descriptions updates existing feeds in place, so the separate
FeedDescription PDA keyed by indexed feed ID is gone. Each data ID, also
each instance of a feed, has its own description, as on Stellar and DF1.

- FeedData gains description[64] after the settings; earlier offsets are
  unchanged, the header is 1,440 bytes and the largest ring at creation
  is 274 rounds
- get_description reads the feed account (FeedRead), get_decimals takes
  the state only
- FeedDescriptionSet carries the data ID
- the store client crate, Go bindings, specs and e2e test follow
@github-actions

github-actions Bot commented Nov 10, 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_store — ➕ Added

📄 View full apidiff report

Reshape the store and proxy to the signed-off design decisions:

- The proxy owns the feed accounts readers pass (round ring, description,
  minimum decimals, frozen flag) and trusts one store, its writer, replaced
  by the owner with set_store (as Stellar's set_cache). Round IDs live in
  the feed, so they continue across stores: no phase IDs. Reads match
  Stellar's proxy (latest_round, get_round with decimals, decimals,
  description, get_min_decimals, get_store); the client crate also decodes
  feed accounts directly, with no call.
- The store keeps the write logic and per-feed write settings (feed_config:
  specific workflows, answer bounds, writes_disabled, DF1 link), and writes
  every accepted round of a report into the proxy in one call.
- Feeds are created by their first report from a default workflow, as on
  EVM, the rent paid by the store's vault (the store authority PDA) and
  created in one proxy call per report. A vault that can't pay skips the
  report. Setters create missing accounts, the feed admin paying.
- Two freezes: frozen proxy feeds refuse reads while writes continue, and
  writes_disabled skips every workflow's reports while reads continue.
- No generic report callbacks: a data ID can be linked to a DF1 feed, which
  the store writes through DF1's unchanged submit, signed by its df1_writer
  PDA, after checking everything submit could fail on (skipping DF1 only).
  The DF1 store program and dummy receiver are back to develop.
- The store client crate is removed; reads go through the proxy.
Merge the proxy into the store. Each data ID has one feed account owned
by the store, holding its latest round, ring, description, read settings
and write settings, which readers pass to the store's reads or decode
directly. Keeping the feeds in a separate proxy no longer isolated the
store's layout, and its extra accounts cost reports per transaction.

- Feeds are created by a feed admin (set_feeds, or any per-feed setter),
  paying the rent: the forwarder passes every account unsigned, so a
  report can't pay for one. Reports for unset feeds are skipped.
- Reads take the decimals to return, down to a per-feed minimum, as on
  Stellar. A read freeze and a write freeze per feed.
- DF1 write-through calls DF1's unchanged submit, signed by the store's
  df1_writer PDA, after checking everything that would make it fail;
  otherwise only the DF1 write is skipped, with a reason.
- The client crate moves to chainlink-solana-data-feeds-store, with
  direct-decode and CPI reads.
- Tests assert transactions stay within the 64-account lock limit and
  use no lookup tables in production paths.
@cawthorne cawthorne changed the title Add the data-feeds-store and data-feeds-proxy programs Add the data-feeds-store program Nov 12, 2026

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.

2 participants