Repository navigation
Conversation
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).
Contributor
✅ API Diff Results -
|
- 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.
|
…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.
Author
|
Superseded by #1676, which has the store and the proxy in one PR. The branch stays. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




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
storeprogram, which the store's write-through keeps current.Reads
Both take an optional round ID (the latest round when
None) and returnRound { 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 withset_min_decimals) and at most 18. Truncates toward zero, and fails withRoundsToZerowhen 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 severalreadinstructions.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.Also adds the
chainlink-solana-data-feeds-proxycrate for customer programs, Go bindings, and mock reader instructions indummy-receiverfor the swap test.Tests
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.TestDataFeedsStorereads through the proxy on a local validator.readand 11k forread_scaled.