Skip to content

Add data-feeds-store program for Data Feeds on CRE - #1665

Closed
cawthorne wants to merge 8 commits into
developfrom
feature/df-cre-solana-legacy-store
Closed

cawthorne wants to merge 8 commits into
developfrom
feature/df-cre-solana-legacy-store

Conversation

@cawthorne

@cawthorne cawthorne commented Oct 19, 2026 •

Copy link
Copy Markdown

Summary

Adds data-feeds-store, a Solana port of the EVM DataFeedsStore without SVR, so Data Feeds can be written on Solana by a CRE DON through the keystone forwarder, the same way as on Aptos and Stellar. Existing DF1 feed accounts keep their addresses: the DF1 store program gains a report callback that the new store calls to write each round through.

Proxies are a separate program, stacked on this PR (see the PR for data-feeds-proxy).

data-feeds-store program

  • History: one FeedData PDA per data ID, holding a ring of reports (i128 answers at 18 decimals) and the data ID's settings (workflow permissions and report callback), so a report passes a single store account.
  • SVR: not supported yet. The SVR path bytes of the 16-byte data ID are reserved and rejected, accounts keep version and reserved bytes, and programs upgrade in place, so SVR can be added later without changing data IDs or moving readers.
  • Reader interface: get_latest_round, get_round, get_decimals, get_description with Borsh return data and 18-decimal answers. This is the seam proxies call, so a store version or program that implements it can replace this one.
  • Permissions: as on EVM, lists of {forwarder authority, workflow owner, workflow name}, a store default plus per data ID. The store doesn't pin a forwarder program and has no per-permission PDAs, so each forwarder (e.g. a separate forwarder program per zone) is one list entry.
  • Callbacks: generic on_report_callback(OnReportCallbackArgs) -> bool CPI, signed by the store authority PDA.
  • Also: min/max answer ranges, ring sizing under the EVM rules, descriptions, feed admins, two-step ownership, token recovery.

DF1 store program

  • on_report_callback writes the round into a DF1 Transmissions feed, rescaled to its decimals, only when the feed's writer is the data feeds store authority. Cutover per feed is set_writer(store_authority), and rollback is set_writer back to the OCR2 PDA.
  • Rounds it can't take are skipped with CacheRoundSkipped, and written rounds emit CacheRoundSubmitted. The TS SDK's StoreFeed listens for CacheRoundSubmitted.

Transaction size (legacy transactions, as CRE builds them today)

Measured in contracts/gotests/data_feeds_store_test.go, including the relayer's compute-budget instructions:

  • F=2: 2 reports with DF1 write-through fit in 1,178 bytes.
  • F=5: 1 store-only report fits in 1,204 bytes.
  • 3 reports at F=2 (1,281 bytes) and 1 report with DF1 write-through at F=5 (1,270 bytes) don't fit. Those wait for V1 transactions.

Tests

  • Rust unit tests for the state machine and data IDs, and for the DF1 store.
  • Anchor spec contracts/tests/data-feeds-store.spec.ts (13).
  • Go e2e TestDataFeedsStore, which sends real legacy transactions through the keystone forwarder.

Related

  • Proxy program: stacked PR on this branch (feat/df-proxy-program).
  • Workflow adapter: smartcontractkit/chainlink-data-feeds#290.
  • Deployment changesets: smartcontractkit/chainlink-data-feeds#291.

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).
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

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

✅ Compatible Changes (23)

generated/store (22)
  • CacheRoundSkipped — ➕ Added

  • CacheRoundSubmitted — ➕ Added

  • CacheSkipReason — ➕ Added

  • CacheSkipReason_AnswerOverflow — ➕ Added

  • CacheSkipReason_InvalidFeedAccount — ➕ Added

  • CacheSkipReason_InvalidVersion — ➕ Added

  • CacheSkipReason_NotWritable — ➕ Added

  • CacheSkipReason_StaleTimestamp — ➕ Added

  • CacheSkipReason_UnauthorizedWriter — ➕ Added

  • Event_CacheRoundSkipped — ➕ Added

  • Event_CacheRoundSubmitted — ➕ Added

  • Instruction_OnReportCallback — ➕ Added

  • NewOnReportCallbackInstruction — ➕ Added

  • OnReportCallbackArgs — ➕ Added

  • OnReportCallbackInstruction — ➕ Added

  • ParseAnyEvent — ➕ Added

  • ParseEvent_CacheRoundSkipped — ➕ Added

  • ParseEvent_CacheRoundSubmitted — ➕ Added

  • UnmarshalCacheRoundSkipped — ➕ Added

  • UnmarshalCacheRoundSubmitted — ➕ Added

  • UnmarshalOnReportCallbackArgs — ➕ Added

  • UnmarshalOnReportCallbackInstruction — ➕ Added

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

📄 View full apidiff report

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).
@cl-sonarqube-production

Copy link
Copy Markdown

Quality Gate failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 75%)
7 New Major Issues (required ≤ 5)
5 New Critical Issues (required ≤ 0)

See analysis details on SonarQube

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE SonarQube for IDE

…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.
…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.
…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.
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.
// declared id); what matters is how the store treats it once closed.
const callbackKey = Keypair.generate();
const keyPath = join(tmpdir(), `closed-callback-${Date.now()}.json`);
writeFileSync(keyPath, JSON.stringify(Array.from(callbackKey.secretKey)));
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.
@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.

2 participants