Skip to content

[codex] Add combined Binance and Polymarket oracle E2E - #758

Draft
ByteYue wants to merge 17 commits into
mainfrom
codex/sports-score-oracle-poc
Draft

[codex] Add combined Binance and Polymarket oracle E2E#758
ByteYue wants to merge 17 commits into
mainfrom
codex/sports-score-oracle-poc

Conversation

@ByteYue

@ByteYue ByteYue commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds the Gravity Oracle transport and E2E surface for:

  • Binance USD-M closed indexPriceKlines buckets through sourceType=3;
  • finalized Polygon Polymarket CTF settlements through sourceType=6;
  • fail-closed OracleState handling that preserves pending payloads across transient state failures.

The relayer-backed observations reuse the existing unsupported-JWK consensus path and execute agreed bytes through NativeOracle callbacks.

E2E coverage

The review surface is intentionally limited to three non-overlapping suites:

Suite Network Unique coverage
oracle_demo Local mocks Deterministic Binance plus binary Polymarket coexistence and combined frontend config
polymarket_mock Local mock Three-outcome match, random winner mapping, settlement, winner claim, and loser zero-claim
binance_price_feed_multivalidator Binance public API Four independent fetchers, 3-of-4 voting-power QC, onchain execution, and four-RPC replication

Follow-up commit 29a6bab01e addresses Galxe/gravity-audit#1033:

  • removes the redundant standalone binance_price_feed suite;
  • moves live frontend config output to the stronger four-validator suite;
  • makes the shared Binance fixture directly executable as a Python module;
  • rejects readiness accidentally satisfied by an unrelated process on the mock port;
  • pins deterministic genesis files to contracts commit f5bd9a8079;
  • consolidates repeated suite, MANUAL, workflow, and skill text into one canonical runbook.

This reduces the GitHub PR diff from 4613+/395- to 3586+/395- while retaining the distinct deterministic, three-outcome settlement, live-source, and quorum assertions.

Canonical runbook: gravity_e2e/docs/ORACLE_E2E.md.

Binance task semantics

binance_index_kline_v1 is continuous by definition. The task URI rejects the legacy continuous parameter. For each feedId, bucketStartMs and interval are immutable; use a new feedId when either changes. This keeps delivery nonce, bucket time, and confirmed-cursor reconciliation monotonic.

Run

Build once:

RUSTFLAGS="--cfg tokio_unstable" \
  cargo build --profile quick-release -p gravity_node -p gravity_cli --locked

Deterministic combined gate:

PATH="$HOME/.foundry/bin:$PWD/target/quick-release:$PATH" \
  ./gravity_e2e/run_test.sh oracle_demo --force-init

Focused three-outcome Polymarket gate:

PATH="$HOME/.foundry/bin:$PWD/target/quick-release:$PATH" \
  ./gravity_e2e/run_test.sh polymarket_mock --force-init

The live four-validator command, outbound approval boundary, replay parameter, frontend mode, stop commands, and expected evidence are maintained only in the canonical runbook.

Pinned revisions

  • contracts: f5bd9a80794c318ea1ccdbd0fb7f15e1e83dbdad
  • gravity-reth: 20af4ae4a2125f6232d6b2c5e7cc3f40140f2501
  • gravity-aptos: 10c4553b16aead745e1701db7885a39313607b26
  • gravity-sdk base: 10c491bc7fe69838398971281270ce438c72e17a

Cargo.lock contains one Aptos api-types revision.

Validation

Current cleanup commit:

  • changed Python modules pass py_compile;
  • all three retained pytest cases collect successfully;
  • mock Binance module CLI and subprocess start/stop lifecycle pass locally;
  • occupied-port ownership guard rejects readiness from an unrelated process;
  • live frontend config schema generation passes;
  • all retained TOML files parse;
  • local Markdown links resolve;
  • removed-suite and user-specific path scans pass;
  • git diff --check passes.

The live four-validator suite previously passed at the pinned heads with four active validators, a 3-of-4 threshold, identical resolver rounds across four RPCs, and 1 passed in 47.97s.

Scope boundary

These suites prove configured task execution and contract consumption. They do not implement generic intra-epoch request discovery or automatic mirroring of arbitrary Polymarket UI markets. Production mirrors still require reviewed manifests, finality gates, watermarks, deadlines, and typed pending or expired states.

@ByteYue
ByteYue force-pushed the codex/sports-score-oracle-poc branch from 65d73c4 to 459ebc7 Compare June 28, 2026 14:47
@ByteYue ByteYue changed the title [codex] Add runnable Polymarket oracle mock E2E [codex] Add Hype price feed E2E Jun 30, 2026
@ByteYue ByteYue changed the title [codex] Add Hype price feed E2E [codex] Add Binance index-kline price feed E2E Jul 7, 2026
@ByteYue ByteYue changed the title [codex] Add Binance index-kline price feed E2E [codex] Add combined Binance and Polymarket oracle E2E Jul 12, 2026
@ByteYue
ByteYue force-pushed the codex/sports-score-oracle-poc branch 2 times, most recently from 57c27c8 to 6b80d5d Compare July 18, 2026 10:08
ByteYue added 6 commits July 23, 2026 18:13
Remove the legacy continuous query parameter from Binance task URIs and document that binance_index_kline_v1 is inherently continuous. Pin the SDK lockfile to gravity-reth d8cb206f6, and require a new feedId whenever the bucket origin or interval changes.
Pin the latest Aptos JWK observation fix and the aligned reth relayer revision, then launch four equal-power validators against explicit closed Binance index-price buckets.

The suite verifies independent per-validator certification and relayer state, a three-of-four voting-power QC, Binance-to-contract price equality, and identical resolver rounds from all four RPCs. It also lets genesis generation accept git worktrees.

Verified with Binance Futures testnet: 4 active validators, QC threshold 3/4, and 1 passed in 43.96s.
@ByteYue
ByteYue force-pushed the codex/sports-score-oracle-poc branch from 4142b88 to 5cb4e29 Compare July 23, 2026 10:29
ByteYue added 11 commits July 27, 2026 15:01
Keep the four-validator Binance suite's fixed listeners below Linux's default ephemeral source-port range and keep the advertised genesis validator/VFN addresses aligned with runtime listeners.

Validated with the live Binance testnet indexPriceKlines flow:
BINANCE_PRICE_FEED_MODE=live BINANCE_PRICE_FEED_BASE_URL=https://testnet.binancefuture.com BINANCE_PRICE_FEED_LAG_MINUTES=4 ./gravity_e2e/run_test.sh binance_price_feed_multivalidator --force-init --log-cli-level=INFO

Result: 1 passed; four active validators formed JWK quorum and all RPCs observed the same on-chain NVDAUSDT/TSLAUSDT round.
Remove the binary market deadline from the E2E create tuple, switch to permissionless finalizeMarket, and update all Market tuple indices after the ABI change.

Assert the resolver winner classification and Polygon provenance before finalization. Pin oracle_demo to contracts commit 0f769b8 and document the per-suite contract revisions and strict mirror semantics.

Tests: not run; oracle_demo execution deferred to the next session as requested.
Exercise a four-validator binary rollout while the existing bridge source remains live, then activate Binance price feeds and a Polymarket mirror through governance at the next epoch. Verify independent relayer checkpoints, JWK quorum evidence, fixed-size source progress, replica consistency, and restart catch-up.
Add a manual four-validator soak that registers a continuous Binance NVDA feed and one real Polymarket mirror through governance, waits for next-epoch activation, and monitors quorum-backed source progress, four-RPC consistency, liveness, restart recovery, replay safety, and final provider equality for a configurable duration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant