Align resolve_market ABI, reject stale prices, wire Reflector adapter (#680-#683) - #809
Open
Ndifreke000 wants to merge 1 commit into
Open
Align resolve_market ABI, reject stale prices, wire Reflector adapter (#680-#683)#809Ndifreke000 wants to merge 1 commit into
Ndifreke000 wants to merge 1 commit into
Conversation
…lector adapter - resolution: ResolutionContract::finalize / arbitrate_uphold_proposer now invoke Market::resolve_market with its real ABI (resolver, String market_id, outcome, signature, expires_at) instead of a mismatched mock ABI (Vatix-Protocol#683). - market: ReflectorAdapter/PythAdapter reject price observations older than MAX_PRICE_AGE_SECONDS (1h) via a new ContractError::StalePrice (Vatix-Protocol#682). - market: added per-market MarketAdapterConfig storage (oracle contract, asset, resolution_price) plus admin-gated set/get entrypoints, bumping STORAGE_VERSION to 6 (Vatix-Protocol#681). - market: verify_market_outcome / verify_market_outcome_v2 now dispatch to the on-chain ReflectorAdapter when the Reflector adapter is enabled and configured for a market, instead of always failing closed (Vatix-Protocol#680). Pyth wiring is left as a follow-up (needs raw VAA proof plumbing) and still fails closed when enabled.
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
ResolutionContract::finalizeandarbitrate_uphold_proposerinvokedMarket::resolve_marketwith a mock ABI (bareu32market_id, noresolver/expires_at). Fixed both cross-contract calls to match the real ABI:(resolver: Address, market_id: String, outcome: bool, signature: BytesN<64>, expires_at: u64).resolveris the resolution contract's own address (self-authorizing as the direct invoker);expires_atreuses the candidate's already-checkedsignature_expiry. Added amarket_id_to_stringhelper sinceresolve_markettakes the id as a decimalString.ReflectorAdapter/PythAdapterread a price timestamp/publish_timebut never checked it. Added aMAX_PRICE_AGE_SECONDS(1 hour) staleness gate and a newContractError::StalePrice(26) returned when a fetched price is older than that window.MarketAdapterConfig(oracle contract address, ReflectorAsset,resolution_price) stored separately fromMarket(no migration needed for existing markets), with admin-gatedset_market_adapter_config/get_market_adapter_configentrypoints. BumpedSTORAGE_VERSIONto 6.oracle::verify_market_outcome/verify_market_outcome_v2now dispatch to the on-chainReflectorAdapter(built from the new per-market config) when the Reflector adapter is enabled viaset_adapter_enabled, instead of always failing closed withUnauthorizedOracle. If enabled but unconfigured for a market, it fails closed withOraclePriceUnavailablerather than silently falling back.Notes / TODO
Bytesproof rather than the fixed 64-byte Ed25519 signature these entrypoints accept, so it still fails closed withUnauthorizedOraclewhen enabled.ResolutionContract::void_marketinvokes avoid_marketentrypoint on the market contract that does not exist yet incontracts/market/src/lib.rs; this predates this PR and is out of scope for Align ResolutionContract::finalize invoke with Market::resolve_market ABI #683 (onlyfinalize/resolve_marketalignment was in scope).cargo test/cargo build/soroban build— please run CI/tests before merge.Closes #683
Closes #682
Closes #681
Closes #680