Skip to content

Can't let one rpc fail fuck things up.#1

Open
br0wnD3v wants to merge 1 commit intomainfrom
public-rpc-fallback
Open

Can't let one rpc fail fuck things up.#1
br0wnD3v wants to merge 1 commit intomainfrom
public-rpc-fallback

Conversation

@br0wnD3v
Copy link
Copy Markdown
Collaborator

@br0wnD3v br0wnD3v commented Apr 2, 2026

3-Layered RPC Fallback for Transaction Sending

Adds backup and public RPC endpoints as fallback layers when the primary RPC fails to send oracle price updates.

Problem

MrOracle uses a single RPC endpoint with no failover. If it goes down, oracle price updates stop silently. A 13-hour RPC
outage meant no prices were pushed on-chain, which blocked all user position operations (close, SL, TP) and led to a
preventable situation.

Solution

New fallback chain for every price update transaction :
Primary RPC → Backup RPC → Public RPC (api.mainnet-beta.solana.com)

Each layer: get blockhash → sign → send → confirm (2 polls @ 500ms) → next layer if failed.

Changes

  • New rpc_fallback.rs module with RpcFallback::sign_and_send()
  • Two new CLI args: --rpc-backup (optional) and --rpc-public (defaults to mainnet-beta)
  • update_pool_aum rewritten to build raw instructions via InstructionData + ToAccountMetas instead of anchor
    RequestBuilder, then delegates to rpc_fallback.sign_and_send()
  • Explicit error logging per layer: [Price Update] PRIMARY RPC failed: ...
  • Final message on total failure: All RPCs failed. Please handle ASAP. Critical Priority.

What's NOT changed

  • Core 5-second loop timing
  • Priority fee polling
  • Database price fetching (with retry)
  • Pool account fetching at startup
  • let _ = non-blocking error handling in the main loop

Usage

--rpc-backup "https://adrena-solanam-6f0c.mainnet.rpcpool.com/"

Without --rpc-backup: primary → public. With it: primary → backup → public.

@br0wnD3v br0wnD3v requested review from AamirAlam and ElementalBrian and removed request for ElementalBrian April 2, 2026 22:28
Copy link
Copy Markdown
Collaborator

@AamirAlam AamirAlam left a comment

Choose a reason for hiding this comment

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

LGTM

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.

3 participants