Skip to content

Reduce Arbitrum payment polling RPCs - #120

Merged
j0sh merged 3 commits into
mainfrom
ja/rpc
Dec 5, 2026
Merged

j0sh merged 3 commits into
mainfrom
ja/rpc

Conversation

@j0sh

@j0sh j0sh commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #103.

Summary

  • Poll the Arbitrum One head every five seconds. Read an ordinary payment snapshot in two RPCs, with one additional log query when payer history is needed.
  • Verify the candidate and retained ancestor in a hash-pinned Multicall, and preserve pinned recovery and the prior snapshot’s freshness rules. Credit the upstream range polling and event-decoder pattern in the code.
  • Skip redemption snapshot reads for empty pages and nonce-gap probes once a finalized receipt proves the acknowledged nonce floor is consumed.
  • Update Gorilla WebSocket and OpenTelemetry to resolve GO-2026-6278 and GO-2026-6974. Update the affected transitive Go modules.

The ranged log query relies on the RPC provider to return complete history for the candidate's chain. The pinned Multicall confirms the candidate and its retained ancestor. A provider that serves the range from a different fork can omit a withdrawal and leave cached payer collateral overstated.

Verification

  • Passed race-enabled tests for eth, redemption, orchestrator, signer, redeemer, and internal/observability.
  • Confirmed two idle RPCs and three RPCs with a cached payer on Arbitrum One’s public endpoint. The regression tests also cover the 128-block limit, reorgs, cancellation, and finalized replacement recovery.
  • GitHub Actions passed the race and real-process tests, vet, staticcheck, and govulncheck.

Copilot AI balanced review requested due to automatic review settings December 4, 2026 23:34
@j0sh
j0sh temporarily deployed to docker-publish December 4, 2026 23:36 — with GitHub Actions Inactive
@j0sh
j0sh temporarily deployed to docker-publish December 4, 2026 23:36 — with GitHub Actions Inactive
@j0sh
j0sh temporarily deployed to docker-publish December 4, 2026 23:36 — with GitHub Actions Inactive
@j0sh
j0sh temporarily deployed to docker-publish December 4, 2026 23:37 — with GitHub Actions Inactive

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

For ranges longer than two blocks, the history check does not bind earlier logs to the candidate chain, even though the later Multicall is hash-pinned. If a load-balanced provider returns history from another fork, a canonical withdrawal could be missed while Multicall succeeds, leaving stale payer collateral in the new snapshot.

1 open issue
What changed in this PR

Reduces orchestrator RPC usage on Arbitrum One, addressing the polling costs reported in #103.

Changes:

  • Adds Multicall snapshots and ranged payer-event polling.
  • Skips unnecessary redemption reads and finalized nonce probes.
  • Moves balance sampling into the observer and adds regression coverage.
File Description
redemption/​worker.go Skips snapshots for empty queues.
redemption/​worker_test.go Verifies idle passes make no RPC calls.
redemption/​redemption_recovery.go Skips nonce probes after finalized consumption.
redemption/​redemption_recovery_test.go Covers idle finalized-replacement recovery.
orchestrator/​metrics.go Removes separate readiness balance polling.
orchestrator/​metrics_test.go Updates readiness test setup.
orchestrator/​app.go Connects observer balance samples to metrics.
internal/​test/​chainrpc.go Supports Multicall and ranged-log fixtures.
eth/​senderwatcher.go Adds ranged event queries and cache handling.
eth/​rpc.go Identifies Arbitrum One and verifies headers.
eth/​payment.go Refactors snapshot construction and validation.
eth/​payment_observer.go Integrates optimized polling and pinned recovery.
eth/​payment_multicall.go Implements aggregated payment snapshot reads.
eth/​payment_multicall_test.go Covers budgets, reorgs, cancellation, and recovery.
eth/​contracts.go Registers new bindings and shares contract names.

Review effort: Balanced

Comment thread eth/senderwatcher.go Resolved
Copilot AI balanced review requested due to automatic review settings December 4, 2026 23:42
@j0sh
j0sh temporarily deployed to docker-publish December 4, 2026 23:44 — with GitHub Actions Inactive
@j0sh
j0sh temporarily deployed to docker-publish December 4, 2026 23:45 — with GitHub Actions Inactive
@j0sh
j0sh temporarily deployed to docker-publish December 4, 2026 23:45 — with GitHub Actions Inactive
@j0sh
j0sh temporarily deployed to docker-publish December 4, 2026 23:45 — with GitHub Actions Inactive

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The observer/recovery refactor spans payment collateral caching, reorg invalidation, and durable nonce finality. Mocked RPC coverage does not settle its financial correctness or provider-consistency guarantees; those remain open for human review.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings December 5, 2026 00:00
@j0sh
j0sh temporarily deployed to docker-publish December 5, 2026 00:03 — with GitHub Actions Inactive

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The observer changes payment-safety invariants across reorg recovery, hash-pinned snapshots, and concurrent cached-collateral reads. Synthetic RPC coverage cannot establish production-provider consistency for these behaviors, leaving a payment-safety uncertainty that warrants human protocol review.

No open issues 🎉

Review effort: Balanced

@j0sh
j0sh temporarily deployed to docker-publish December 5, 2026 00:04 — with GitHub Actions Inactive
@j0sh
j0sh temporarily deployed to docker-publish December 5, 2026 00:04 — with GitHub Actions Inactive
@j0sh
j0sh temporarily deployed to docker-publish December 5, 2026 00:04 — with GitHub Actions Inactive
@j0sh
j0sh merged commit 2614143 into main Dec 5, 2026
13 checks passed
@j0sh
j0sh deleted the ja/rpc branch December 5, 2026 00:18

This branch was previously deployed

1 inactive deployment
docker-publish — 85b3c7d1 Deployed Dec 5, 2026 by j0sh via docker-pr / promote #229
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.

Orchestrator chain polling costs ~670k RPC requests/day on Arbitrum

2 participants