feat(ymax-planner): fall back to another Agoric RPC when the preferred one is down #12975
All Vouch review confidence checks passed
Residual risk 0.26 = Change Risk (0.48) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 555 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.378
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #12975"
general
weight: 0.35
gibson042
refs: AGO-1591
Description
The ymax planner used the single Agoric RPC from
AGORIC_NETfor everything, so an outage or stall of the dedicated follower stopped the planner. It now falls back to other RPCs and returns to the preferred one when that recovers.src/agoric-rpc.ts, new): the planner tries the first RPC fromAGORIC_NET, then each one in the newAGORIC_RPC_FALLBACKSsetting, and uses the first healthy one. If none is healthy (as during a chain halt, when no node has a recent block), it uses the first that serves the expected chain, logs a 🚨 error, and waits.status, not be catching up, have a block from the last 60 s, and answer a vstorage query. The query is there because a degraded node can answerstatuspromptly while its queries take minutes.waitForAgoricRpcSwitch): once a minute, the planner checks the RPC it is using over a separate connection, and whether its subscription got a new block since the previous check. It exits so that a restart selects again if that RPC fails 3 checks in a row or stalls, but only while another RPC passes the check. During a chain halt every node fails, so the planner stays.src/config.ts):AGORIC_RPC_FALLBACKSis a comma-separated list of URLs, empty by default on every cluster.unsubscribeno longer sends a request on a closed socket, which left an unhandled "already closed" rejection after a socket failure.CosmosRPCClientno longer fails a quiet subscription itself; it exposesnotificationCount()so the caller can tell a stalled subscription apart. ItsWebSocketoption is typed structurally (RpcWebSocket), listing only what it uses, so tests can supply a fake without casts.Most critical to review:
src/agoric-rpc.tsand the startup and shutdown changes insrc/main.ts.Security Considerations
When fallbacks are configured, the planner may read chain state from, and broadcast through, those RPCs as well as the preferred one. Each endpoint's chain ID is checked before use.
Scaling Considerations
When a fallback is configured, one short-lived websocket connection with a
statusrequest and a small query per minute to the RPC in use, and while on a fallback, another to the preferred RPC. While the RPC in use is stalled or failing, the others are also probed once a minute. A startup scan of vstorage on a public fallback is subject to that endpoint's rate limits.Documentation Considerations
services/ymax-planner/README.mddocumentsAGORIC_RPC_FALLBACKS. To usemain-aas a fallback on mainnet, the deployment must setAGORIC_RPC_FALLBACKS=https://main-a.rpc.agoric.net:443.Testing Considerations
Unit tests cover endpoint selection (including no healthy endpoint), health criteria (including a node whose queries hang), the wrong-chain failure, the wait for a better RPC, a stalled subscription, staying through a chain halt, switching back to the preferred RPC, the client's notification count, and config parsing. An earlier version of the health check was run by hand against the mainnet follower and
main-a(both pass in about 1 s) and a devnet endpoint (fails with the chain ID mismatch); the current version has not been run against live nodes.Upgrade Considerations
Switching endpoints happens by process exit, so it relies on the planner's container being restarted, as existing websocket-failure handling already does. Each restart rescans vstorage from the newly selected endpoint. Individual HTTP requests to the RPC still have no timeout of their own; a node that stalls them is left through the once-a-minute check.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Pb54yMwxzGY6S1JgByrAR4