[codex] Add Binance index-kline price feed E2E#758
Draft
ByteYue wants to merge 14 commits into
Draft
Conversation
Document and test a local-only Polymarket-style settlement flow for Gravity. The polymarket_mock suite starts a local Polygon JSON-RPC mock, maps the configured oracle URI through relayer_config.json, drives the existing relayer plus unsupported-JWK/oracle consensus path into NativeOracle, and settles a match-market contract from the resolver result. How to run: PATH="$CONDA_PREFIX/bin:$HOME/.foundry/bin:$PWD/target/quick-release:$PATH" ./gravity_e2e/run_test.sh polymarket_mock --force-init Expected successful output includes Suite polymarket_mock PASSED and All suites passed. A verified local run passed with 1 test in about 128 seconds. This proves the settlement rail first; dynamic Polymarket-like request discovery can be layered later with finalized request events, watermarks, deadlines, and typed pending/unknown/expired states.
65d73c4 to
459ebc7
Compare
Update the SDK lockfile to the gravity-reth oracle branch commit that includes sourceType=3 price feed support and the Hype/HIP-3 adapter. Add a local hype_price_feed suite that registers deterministic NVDA/USD and GOOGL/USD price tasks, waits for the next short epoch so JWK observers rebuild relayer-backed providers, and verifies NativeOracle -> MultiSourceOracleResolver.latestPrice for feed IDs 1001 and 1002. Document how to run the suite, the expected resolved prices, and how this epoch-config feed path can support Gravity price-index or Polymarket-like products without claiming intra-epoch dynamic request discovery.
Switch the hype_price_feed suite from static observations to provider=hype URIs backed by a local deterministic /info mock. The relayer now runs the Hype/HIP-3 HTTP adapter for xyz:NVDA and xyz:GOOGL, publishes the canonical price bytes through the unsupported-JWK path, and the test verifies NativeOracle -> MultiSourceOracleResolver.latestPrice for feedIds 1001 and 1002. Run with: PATH="$HOME/.foundry/bin:$PWD/target/quick-release:$PWD/target/release:$PATH" ./gravity_e2e/run_test.sh hype_price_feed --force-init. Expected effect: both feed IDs resolve round 1 prices and the suite ends with All suites passed.
Replace the previous Hype price feed suite with a continuous Binance index-kline PoC. The suite registers NVDAUSDT and TSLAUSDT sourceType=3 tasks, serves deterministic closed 1-minute klines from a local mock Binance endpoint, waits for delivery nonce 3, and verifies MultiSourceOracleResolver.priceRounds for roundId 29720877. Verification: built gravity_cli and gravity_node with the local gravity-reth PoC branch; ran ./gravity_e2e/run_test.sh binance_price_feed --force-init --log-cli-level=INFO, which passed with both feeds resolved on-chain.
Add runner support for --keep-running and --demo-config-out so a successful suite can leave the local Gravity cluster alive for a frontend demo. Extract the Binance index-kline mock into a reusable server, add binance_price_feed hooks that keep the mock alive in demo mode, and write frontend-readable runtime config after the resolver is deployed. Verification: python3 -m py_compile for runner and Binance suite helpers; pytest --collect-only for binance_price_feed; ran binance_price_feed with --keep-running and confirmed the node, mock server, JSON-RPC, and resolver latestPrice remain available after runner exit.
Add a pre-deploy hook so the binance_price_feed suite can generate run-local relayer config for live Binance indexPriceKlines demos while keeping the deterministic mock path as the default E2E mode. Live mode computes a recent closed one-minute bucket, registers matching sourceType=3 task URIs, validates resolver writes without fixed price assertions, and writes provider metadata for the demo frontend. Verification: py_compile runner/hooks/test/mock; pytest --collect-only for binance_price_feed; generated live relayer config dry-run; git diff --check.
Add a Gravity oracle demo skill with the live Binance index-kline startup flow, including the testnet base URL fallback used when production Binance returns HTTP 451. Document frontend demo wiring and clarify that the Polymarket mock E2E can back both direct binary mirrors and single-condition 3-way mirrors.
Add oracle_demo, a single local Gravity E2E suite that runs Binance index-kline price feeds and a Fed-style Polymarket binary mirror in the same cluster. The suite starts deterministic local Binance and Polygon mocks, registers sourceType=3 and sourceType=6 oracle paths, settles the binary market, and can emit one frontend demo-config.json. Update the oracle demo skill with the combined startup command.
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
This PR adds an SDK E2E suite for the Gravity oracle price-feed rail using Binance USD-M
indexPriceKlinessemantics:gravity-rethdependency to the relayer-backed Binance continuous bucket PoC commit.hype_price_feedsuite withbinance_price_feed.sourceType=3tasks through governance:feedId=1001:provider=binance_index_kline_v1&pair=NVDAUSDT&interval=1m&continuous=true.feedId=1002:provider=binance_index_kline_v1&pair=TSLAUSDT&interval=1m&continuous=true.BINANCE_PRICE_FEED_MODE=livefor manual demos that fetch Binance publicindexPriceKlinesclosed 1-minute buckets directly.MultiSourceOracleResolver, wires it as theNativeOracledefault callback, waits for the short epoch to rebuild relayer-backed JWK observers, and verifies resolver writes.--keep-runningand--demo-config-out, so the local chain can stay alive for a frontend demo after assertions pass.How to run the deterministic E2E
Build the quick-release binaries, then run the suite:
make BINARY=gravity_node MODE=quick-release make BINARY=gravity_cli MODE=quick-release PATH="$HOME/.foundry/bin:$PWD/target/quick-release:$PATH" \ ./gravity_e2e/run_test.sh binance_price_feed --force-init --log-cli-level=INFOThis mode starts a local deterministic
/fapi/v1/indexPriceKlinesmock and still makes the relayer use the Binance adapter request shape:pair,interval,startTime,endTime, andlimit=1.How to run the mock frontend demo backend
Use keep-running mode and write a frontend-readable runtime config:
PATH="$HOME/.foundry/bin:$PWD/target/quick-release:$PATH" \ ./gravity_e2e/run_test.sh binance_price_feed \ --force-init \ --keep-running \ --demo-config-out ../gravity_price_feed_demo_web/public/demo-config.json \ --log-cli-level=INFOExpected output includes:
After that, the local Gravity RPC and deterministic Binance mock keep running. The web demo reads the generated config, proxies JSON-RPC through
/rpc, and renders continuously updating resolver state.Stop commands:
How to run the live Binance demo backend
For a pure manual demo, set live mode:
BINANCE_PRICE_FEED_MODE=live \ BINANCE_PRICE_FEED_LAG_MINUTES=2 \ PATH="$HOME/.foundry/bin:$PWD/target/quick-release:$PATH" \ ./gravity_e2e/run_test.sh binance_price_feed \ --force-init \ --keep-running \ --demo-config-out ../gravity_price_feed_demo_web/public/demo-config.json \ --log-cli-level=INFOLive mode sends outbound requests to Binance public market-data APIs. It does not require
BINANCE_API_KEYorBINANCE_SECRET_KEY.At startup it computes a recent closed 1-minute bucket, generates a run-local relayer config, and registers matching task URIs such as:
In live mode, stop only the local cluster:
Expected effect
Both mock and live modes exercise the same Gravity path:
relayer fetch -> canonical bytes -> unsupported-JWK consensus ->
NativeOracle->MultiSourceOracleResolver.priceRounds/latestPrice.Mock mode asserts exact fixture prices. Live mode asserts the resolver shape and positive observed price because the source data is external market data.
How this helps build a Polymarket-like Gravity product
This suite covers the long-running epoch-config oracle path:
sourceType=3can feed price/index markets or a demo PerpDex-style price board.sourceType=6-style settlement data.It does not implement intra-epoch dynamic request discovery. A future dynamic watcher should scan finalized request events with watermarks/backfill, request expiry, typed Pending / Unknown / Expired states, retryable
add_uri, and request/config/payload hashes in the signed object.Verification
Ran successfully without live Binance traffic:
Previously verified the keep-running mock backend end-to-end:
PATH="$HOME/.foundry/bin:$PWD/target/quick-release:$PATH" \ ./gravity_e2e/run_test.sh binance_price_feed \ --force-init \ --keep-running \ --demo-config-out ../gravity_price_feed_demo_web/public/demo-config.json \ --log-cli-level=INFONotes for reviewers: