Skip to content

perf(oracle): encode packed price payloads - #423

Open
ByteYue wants to merge 1 commit into
mainfrom
codex/oracle-packed-price-v1
Open

perf(oracle): encode packed price payloads#423
ByteYue wants to merge 1 commit into
mainfrom
codex/oracle-packed-price-v1

Conversation

@ByteYue

@ByteYue ByteYue commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

Implements the gravity-reth producer half of Galxe/gravity-audit#1092:

  • encode the resolver callback as the canonical 32-byte Price Feed V1 word
  • normalize Binance Index Price Kline close strings to fixed 8 decimals
  • pad short fractions and truncate excess positive fractional digits
  • reject signs, whitespace, scientific notation, malformed values, zero, and uint96 overflow
  • enforce uint32 round and uint48 timestamp bounds
  • retain the existing outer NativeOracle/JWK tuple and closed-bucket semantics
  • add exact Solidity-compatible inner and wrapped golden vectors

Golden inner payload:

0100000000000007d101b2e020018e23f2365f0000000000000009543637a800

Dependency

Depends on Galxe/gravity_chain_core_contracts#116, which freezes the matching decoder and one-slot round storage.

The SDK fixtures and E2E/soak suite are intentionally deferred to a separate follow-up PR.

Encoding correction

The existing Alloy call encodes a dynamic tuple value and includes a leading top-level tuple offset. Measured canonical wrapper sizes are therefore:

  • old 160-byte callback body: 320-byte wrapper
  • new 32-byte callback body: 192-byte wrapper

This corrects the 288 -> 160 estimate in #1092 without changing the existing outer encoding or JWK consensus path.

Polymarket source behavior and production code are unchanged.

Verification

  • cargo fmt --all -- --check
  • cargo test -p reth-pipe-exec-layer-relayer: 65 passed, 0 failed, 1 external-RPC test ignored
  • cargo clippy -p reth-pipe-exec-layer-relayer --all-targets -- -D warnings passes after allowing three unrelated lint classes already present in untouched files
  • exact 32-byte inner and 192-byte wrapped golden-vector tests
  • round, time, price, decimal, malformed input, and overflow boundary tests

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