Repository navigation
Conversation
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).
✅ API Diff Results -
|
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).
|
…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.
|
Superseded by #1676, which has the store and the proxy in one PR. The branch stays. |




Summary
Adds
data-feeds-store, a Solana port of the EVMDataFeedsStorewithout 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 DF1storeprogram 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
FeedDataPDA 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.versionand reserved bytes, and programs upgrade in place, so SVR can be added later without changing data IDs or moving readers.get_latest_round,get_round,get_decimals,get_descriptionwith 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.{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.on_report_callback(OnReportCallbackArgs) -> boolCPI, signed by the store authority PDA.DF1
storeprogramon_report_callbackwrites the round into a DF1Transmissionsfeed, rescaled to its decimals, only when the feed's writer is the data feeds store authority. Cutover per feed isset_writer(store_authority), and rollback isset_writerback to the OCR2 PDA.CacheRoundSkipped, and written rounds emitCacheRoundSubmitted. The TS SDK'sStoreFeedlistens forCacheRoundSubmitted.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:Tests
contracts/tests/data-feeds-store.spec.ts(13).TestDataFeedsStore, which sends real legacy transactions through the keystone forwarder.Related
feat/df-proxy-program).