feat(oracle): add finalized Polymarket settlement source - #420
Conversation
Add sourceType=6 for one-shot Polygon CTF settlement mirrors. Validators scan bounded finalized ranges, verify the source chain and CTF condition identity, derive canonical resolver bytes, and persist empty-scan watermarks without inventing delivery nonces. Wire discovery and execution through the existing unsupported-JWK path with the standard 500,000 callback gas limit. Document the market-discovery boundary, URI runbook, finality and idempotency semantics, and final contract ABI. Tested with the offline relayer suite (59 passed, 1 ignored), focused JWK execution tests (10 passed), oracle task helper test, rustfmt, and clippy. No external Polygon endpoint is contacted by the test suite.
9ee0cf8 to
ff233f5
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9ee0cf8a2d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if self.chain_verified.load(Ordering::Acquire) { | ||
| return Ok(()); |
There was a problem hiding this comment.
Revalidate the RPC chain before every scan
When a long-lived RPC URL changes backend after its first successful poll—for example, a load-balanced endpoint fails over to a non-Polygon chain—this early return skips eth_chainId verification forever. poll() can then trust the foreign chain's finalized height and persist an empty-scan cursor past unscanned Polygon blocks; restoring the Polygon backend will not revisit them, so the terminal ConditionResolution may be missed permanently. Recheck the chain ID before each scan or otherwise bind each watermark and log response to a verified Polygon backend.
Useful? React with 👍 / 👎.
Summary
6for one-shot Polymarket CTF settlement mirrorsPolymarketSettlementPayloadABI consumed bygravity_chain_core_contracts#115NativeOracle.recordBatchwith the standard500000callback gas limitTask URI
RPC URLs and credentials remain validator-local. The on-chain URI contains only deterministic consensus configuration.
Finality and idempotency
eth_chainId == 137eth_getBlockByNumber("finalized", false)maxBlocksPerPollblocks per poll(blockNumber, logIndex, transactionHash)and deduplicates only identical log identities1; confirmed nonce1disables further Polygon RPC callssourcePosition) separate from the later scan cursorContract compatibility
The provider recomputes:
Its resolver payload is decoded field-for-field in unit tests against the final struct merged in
Galxe/gravity_chain_core_contracts#115. The outer wrapper remains:No dependency or lockfile changes are included.
Validation
cargo test -p reth-pipe-exec-layer-relayer --no-fail-fast: 59 passed, 0 failed, 1 external-RPC test ignoredcargo test -p reth-pipe-exec-layer-ext-v2 onchain_config::jwk_oracle --no-fail-fast: 10 passedcargo test -p reth-pipe-exec-layer-ext-v2 onchain_config::oracle_task_helpers --lib --no-fail-fast: 1 passedcargo +nightly fmt --all -- --check: passedcargo clippy -p reth-pipe-exec-layer-relayer --all-targets: passed; reported only pre-existing warnings in untouched codesystem_caller_migration::tests::test_migration_defensive_when_system_caller_absent; its source and dependency inputs are unchanged by this PRThe relayer tests inject an in-memory Polygon RPC and do not contact an external endpoint.
Scope
This is the single remaining
gravity-rethPolymarket provider PR in the oracle split tracked byGalxe/gravity-audit#1038. SDK/product E2E wiring follows only after this provider is merged.