Skip to content

feat(oracle): wire generic relayer runtime - #803

Merged
ByteYue merged 1 commit into
mainfrom
codex/oracle-runtime-core
Aug 3, 2026
Merged

feat(oracle): wire generic relayer runtime#803
ByteYue merged 1 commit into
mainfrom
codex/oracle-runtime-core

Conversation

@ByteYue

@ByteYue ByteYue commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • wire gravity_node to the merged generic Reth Oracle relayer API
  • decode the fixed-size OracleState snapshot from the latest committed Gravity block
  • reconcile providers by the shared (source_type, source_id) URI identity
  • retain and re-emit a pending observation until the authoritative on-chain nonce catches up
  • suppress stale or already-committed observations before they become guaranteed-revert system transactions
  • keep provider endpoints validator-local and redact credentials, paths, and query strings from logs

Runtime behavior

add_uri now requires an authoritative on-chain source state before warming the Reth provider with its latest_nonce and latest_position. get_last_state follows the same snapshot and fails closed when OracleState is unavailable, malformed, or missing the requested source.

After a provider returns an update, the wrapper caches that exact PollResult. While its nonce is ahead of the committed state, later observations return the cached payload instead of polling again. Once execution catches up, polling resumes. A provider result with observed_nonce <= onchain_nonce is marked unchanged so it cannot inject a recordBatch that must revert with NonceNotSequential.

The state-read error path does not mutate the pending tracker, so a transient committed-state failure cannot erase an observation waiting for execution.

Dependency alignment

The lockfile is necessarily large because the existing SDK branch moves from its older Reth/Aptos dependency graphs to those merged revisions.

Non-goals

  • no Binance source implementation
  • no Polygon or Polymarket source implementation
  • no external-network E2E or frontend demo

Those remain isolated provider and E2E slices in the split plan.

Validation

  • RUSTFLAGS='--cfg tokio_unstable' cargo +1.93.0 check -p gravity_node --tests --locked
  • RUSTFLAGS='--cfg tokio_unstable' cargo +1.93.0 test -p gravity_node relayer::tests --locked (12 passed)
  • cargo +nightly fmt --all -- --check
  • cargo +1.93.0 metadata --locked --no-deps --format-version 1

Tracking

  • Galxe/gravity-audit#1038
  • Addresses Galxe/gravity-audit#908

Read fixed-size OracleState snapshots at the latest committed block, reconcile each URI by source identity, retain pending observations until the authoritative nonce catches up, and suppress already-committed duplicates. Pin the merged Aptos API and Reth generic relayer revisions and align the node CLI with Reth 2.3.
@ByteYue
ByteYue merged commit c404861 into main Aug 3, 2026
4 checks passed
@ByteYue
ByteYue deleted the codex/oracle-runtime-core branch August 3, 2026 08:28
nekomoto911 added a commit to nekomoto911/gravity-sdk that referenced this pull request Aug 3, 2026
…th-v2.3.0

Resolve conflicts with Galxe#803 (generic oracle relayer + greth 53a9df97):

- Keep main's greth pin 53a9df97 (bc817c64 + Galxe#416/Galxe#417) and EthTransactionPool
  / alloy / tokio pins from main
- Keep PR unique work: apply_node_defaults, prague betaTime, stop LOCK wait
- Cargo.lock: take main's lock (same greth rev)
nekomoto911 added a commit that referenced this pull request Aug 3, 2026
## Summary

Port of [#802](#802) onto
**`branch-v1.9`**.

- **Base:** `branch-v1.9` (not `main`)
- **Explicitly excludes
[#803](#803 (`feat(oracle):
wire generic relayer runtime`), which was merged to `main` but must not
land on v1.9. That PR rewires the oracle relayer + pins different
greth/gaptos revs (`53a9df97` / `a64f8adc`).
- Cherry-picked the three #802 commits cleanly onto
`upstream/branch-v1.9` @ `6c233dfc` (same merge-base as the original
#802 head).

### Greth pin

- `greth` / workspace `reth-primitives-traits` patch →
[`bc817c642c9c3816cc4e22754e13e3c9633419dd`](Galxe/gravity-reth@bc817c6)
(Galxe/gravity-reth#414 — block-gas last gate at Beta; includes
#413/#412/#410)
- `gaptos` remains the v1.9 pin (`b1f68dc…`), **not** the #803 Aptos rev

### Key changes (same as #802)

1. **Deps:** greth v2.3.0 pin + lockfile; alloy pins aligned
(`alloy-primitives` 1.6.0, `alloy-*` 2.0.5); tokio `taskdump` enabled
for `gravity_node`
2. **CLI:** `cli.rs` / `reth_cli.rs` adapted to reth v2.3.0 command
signatures (`Runtime` / `CliContext`) and greth node log defaults /
`TracingGuards`
3. **Prague e2e:** set `betaTime` with `pragueTime` so greth #412
EIP-7702 lockdown is released for SetCode txs
4. **Stop LOCK race:** wait for real process exit in `cluster/stop.sh`,
`cluster/deploy.sh` stop templates, and `node.py` so greth v2.3+ RocksDB
LOCK flush after SIGTERM does not race e2e restart

### Out of scope (same as #802)

- No `gravity_e2e` storage_v2 baseline/upgrade/fresh_sync work
- No #803 oracle relayer rewrite

## Test plan

- [ ] File set matches #802: `Cargo.toml`, `Cargo.lock`,
`bin/gravity_node/Cargo.toml`, `cli.rs`, `reth_cli.rs`,
`cluster/deploy.sh`, `cluster/stop.sh`, prague `genesis.toml`, `node.py`
- [ ] Greth rev is `bc817c64…`; no `53a9df97` / `a64f8adc` (#803) pins;
`relayer.rs` unchanged vs `branch-v1.9`
- [ ] `RUSTFLAGS="--cfg tokio_unstable" cargo check -p gravity_node`
- [ ] Smoke: node starts and writes log files with default node log
settings
- [ ] Local e2e batch stop / restart no longer hits RocksDB LOCK
`Resource temporarily unavailable`
- [ ] CI e2e (incl. prague suite with `betaTime`)
nekomoto911 added a commit that referenced this pull request Aug 3, 2026
…a9df97) (#802)

## Summary

Follow-up on top of **main after #803** (which already lands greth
**v2.3.0** at
[`53a9df97`](Galxe/gravity-reth@53a9df9)).

This PR does **not** re-pin greth relative to current `main`. Greth
stays at the same rev as main (`53a9df97` = `bc817c64` +
gravity-reth#416 + #417). The open work is **SDK e2e / node lifecycle**
so CI passes and file logging works under the new greth behavior.

### What changed (vs current `main`)

1. **prague e2e — `betaTime`**
   - greth#412 fail-closes EIP-7702 type-4 packing until Gravity Beta.
- Missing `betaTime` → lockdown forever → SetCode receipt timeouts in
the prague suite.
- Set `betaTime = pragueTime` in
`gravity_e2e/cluster_test_cases/prague/genesis.toml`.

2. **stop / restart — wait for real process exit (RocksDB LOCK race)**
- greth v2.3+ can hold RocksDB LOCK for several seconds after SIGTERM
while flushing.
- Old stop path deleted the pid file / returned before the process was
gone; restart then failed with `Resource temporarily unavailable` on
`.../db/state/LOCK` (single_node `BATCH_COMMIT_SIZE`, pfn_chain
blackhole phase).
- Fix: `cluster/stop.sh` + generated per-node stop in `deploy.sh` wait
until `kill -0` fails (SIGTERM then SIGKILL); `Node.stop()` captures PID
before stop and waits for exit.

3. **node log defaults**
- `cli.rs`: `apply_node_defaults()` so greth node-subcommand file
logging is actually installed.

### Greth pin (for clarity)

| Tree | greth rev |
|------|-----------|
| `main` / this PR after merge with #803 |
[`53a9df97`](Galxe/gravity-reth@53a9df9)
|
| Earlier draft of this PR (superseded) | `bc817c64` (strict ancestor of
`53a9df97`) |

Includes greth#412 (7702 lockdown @ Beta), #413, #414 (block-gas last
gate), #416 (oracle relayer), #417 (alloy-trie).

### Out of scope

- `bridge_cross_epoch` jwk `[-2:]` oracle (pre-existing brittle assert;
mint path OK)
- storage_v2 e2e suite (separate branch)

## Test plan

- [x] Local: prague suite **13 passed** with `betaTime`
- [x] Local: `test_batch_execution` + `test_batch_exec_restart`
**passed** after stop wait fix
- [ ] CI e2e-docker after approval
- [x] `cargo metadata --locked` clean after merge with main
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