Skip to content

Align resolve_market ABI, reject stale prices, wire Reflector adapter (#680-#683) - #809

Open
Ndifreke000 wants to merge 1 commit into
Vatix-Protocol:devfrom
Ndifreke000:fix/issues-680-681-682-683
Open

Align resolve_market ABI, reject stale prices, wire Reflector adapter (#680-#683)#809
Ndifreke000 wants to merge 1 commit into
Vatix-Protocol:devfrom
Ndifreke000:fix/issues-680-681-682-683

Conversation

@Ndifreke000

Copy link
Copy Markdown
Contributor

Summary

  • Align ResolutionContract::finalize invoke with Market::resolve_market ABI #683ResolutionContract::finalize and arbitrate_uphold_proposer invoked Market::resolve_market with a mock ABI (bare u32 market_id, no resolver/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). resolver is the resolution contract's own address (self-authorizing as the direct invoker); expires_at reuses the candidate's already-checked signature_expiry. Added a market_id_to_string helper since resolve_market takes the id as a decimal String.
  • Reject stale Reflector/Pyth prices in adapters #682ReflectorAdapter/PythAdapter read a price timestamp/publish_time but never checked it. Added a MAX_PRICE_AGE_SECONDS (1 hour) staleness gate and a new ContractError::StalePrice (26) returned when a fetched price is older than that window.
  • Storage migration: per-market adapter config and resolution_price #681 — Added per-market MarketAdapterConfig (oracle contract address, Reflector Asset, resolution_price) stored separately from Market (no migration needed for existing markets), with admin-gated set_market_adapter_config / get_market_adapter_config entrypoints. Bumped STORAGE_VERSION to 6.
  • Wire OracleAdapter into resolve_market (Reflector first) #680oracle::verify_market_outcome / verify_market_outcome_v2 now dispatch to the on-chain ReflectorAdapter (built from the new per-market config) when the Reflector adapter is enabled via set_adapter_enabled, instead of always failing closed with UnauthorizedOracle. If enabled but unconfigured for a market, it fails closed with OraclePriceUnavailable rather than silently falling back.

Notes / TODO

  • Pyth wiring is intentionally left as a follow-up per Wire OracleAdapter into resolve_market (Reflector first) #680's "Reflector first" framing — Pyth needs a raw Wormhole VAA Bytes proof rather than the fixed 64-byte Ed25519 signature these entrypoints accept, so it still fails closed with UnauthorizedOracle when enabled.
  • ResolutionContract::void_market invokes a void_market entrypoint on the market contract that does not exist yet in contracts/market/src/lib.rs; this predates this PR and is out of scope for Align ResolutionContract::finalize invoke with Market::resolve_market ABI #683 (only finalize/resolve_market alignment was in scope).
  • Per repo owner's request, this PR was implemented and pushed without running cargo test/cargo build/soroban build — please run CI/tests before merge.

Closes #683
Closes #682
Closes #681
Closes #680

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant