Repository navigation
fix(sdk): ban node and retry elsewhere on UNIMPLEMENTED responses - #3875
Conversation
During a mixed-version network rollout, gRPC UNIMPLEMENTED means the selected evonode runs an older build that doesn't expose the method yet, not that the method is unsupported network-wide. Classify it as retryable so the executor bans the stale node and retries the request on another address. If every node answers UNIMPLEMENTED, the address list is exhausted and the error still surfaces as NoAvailableAddressesToRetry, which is itself non-retryable. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Warning Review limit reached
More reviews will be available in 7 minutes and 42 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ Review complete (commit cb468d8) |
thepastaclaw
left a comment
There was a problem hiding this comment.
Code Review
Small, well-scoped change that correctly routes gRPC UNIMPLEMENTED through the existing ban-and-retry path so stale nodes get rotated out during a mixed-version rollout. Two real concerns survive validation: (1) the PR description's all-stale safety claim only holds when live_addresses <= settings.retries — with more nodes than the retry budget, callers observe a still-retryable Unimplemented; (2) UNIMPLEMENTED is now address-scoped, so calling any genuinely unsupported method (e.g. broadcast_state_transition / wait_for_state_transition_result / get_consensus_params from rs-drive-abci or any MethodNotFound mapped by rs-dapi) bans an otherwise healthy node for the full ban window. Both are bounded by existing rs-sdk total_retries cap and the ban TTL, so I treat them as suggestions rather than blockers.
🟡 2 suggestion(s)
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `packages/rs-dapi-client/src/transport/grpc.rs`:
- [SUGGESTION] packages/rs-dapi-client/src/transport/grpc.rs:114-123: All-stale collapse to NoAvailableAddressesToRetry only holds when live_addresses <= settings.retries
The new comment and the PR description state that if every node answers UNIMPLEMENTED, the error surfaces as NoAvailableAddressesToRetry (non-retryable). That invariant only holds when the address list is exhausted before the retry budget is. In `DapiClient::execute` (packages/rs-dapi-client/src/dapi_client.rs:681) the inner loop exits via the `retries < max_retries` cap before `get_live_address()` returns None whenever `live_addresses > max_retries`. In that branch the executor returns the raw `DapiClientError::Transport(Grpc(Unimplemented))`, and with this change `can_retry()` is now true on that surfaced error. Direct rs-dapi-client callers that obey `CanRetry` (anyone not going through `rs-sdk/src/sync.rs:131`, which caps via `total_retries > max_retries`) can keep retrying a genuinely unsupported method. The integration test in `tests/unimplemented_failover.rs:143` uses 2 addresses with the default 5 retries and so cannot exercise this branch. Either tighten the executor so an UNIMPLEMENTED that has visited every live address surfaces as a terminal/non-retryable error regardless of which cap triggers first, or add a coverage case with `live_addresses > settings.retries` and adjust the comment/PR claim to match the actual contract.
- [SUGGESTION] packages/rs-dapi-client/src/transport/grpc.rs:114-122: Address-scoped ban for UNIMPLEMENTED can degrade healthy nodes serving other methods
`update_address_ban_status` (packages/rs-dapi-client/src/dapi_client.rs:162) bans by `Address`, not by `(address, method)`. UNIMPLEMENTED is not only emitted by stale rollout nodes: `packages/rs-drive-abci/src/query/service.rs:262,271,446,453` deliberately returns `Status::unimplemented` for `broadcast_state_transition`, `wait_for_state_transition_result`, and `get_consensus_params`, and `packages/rs-dapi/src/error.rs:163` maps every `DapiError::MethodNotFound` to `Status::unimplemented`. After this change, a call to any such endpoint bans that otherwise-healthy node across all methods for the full ban window (60s base, exponential on repeat). On clients with small address pools this can make unrelated supported requests fail with `NoAvailableAddresses` until the ban expires. The targeted mixed-version rollout case justifies the trade-off, but it should at least be documented inline and tracked as a follow-up for per-method ban granularity so optional / feature-gated endpoints do not poison the shared address list.
| | Aborted | ||
| | Internal | ||
| | Unavailable | ||
| // During a mixed-version network rollout, Unimplemented means this | ||
| // particular node runs an older build that doesn't expose the method | ||
| // yet; another node may serve it. Marking it retryable makes the | ||
| // executor ban the node and retry elsewhere. If no node implements | ||
| // the method, all addresses get exhausted and the error still | ||
| // surfaces as NoAvailableAddressesToRetry. | ||
| | Unimplemented |
There was a problem hiding this comment.
🟡 Suggestion: All-stale collapse to NoAvailableAddressesToRetry only holds when live_addresses <= settings.retries
The new comment and the PR description state that if every node answers UNIMPLEMENTED, the error surfaces as NoAvailableAddressesToRetry (non-retryable). That invariant only holds when the address list is exhausted before the retry budget is. In DapiClient::execute (packages/rs-dapi-client/src/dapi_client.rs:681) the inner loop exits via the retries < max_retries cap before get_live_address() returns None whenever live_addresses > max_retries. In that branch the executor returns the raw DapiClientError::Transport(Grpc(Unimplemented)), and with this change can_retry() is now true on that surfaced error. Direct rs-dapi-client callers that obey CanRetry (anyone not going through rs-sdk/src/sync.rs:131, which caps via total_retries > max_retries) can keep retrying a genuinely unsupported method. The integration test in tests/unimplemented_failover.rs:143 uses 2 addresses with the default 5 retries and so cannot exercise this branch. Either tighten the executor so an UNIMPLEMENTED that has visited every live address surfaces as a terminal/non-retryable error regardless of which cap triggers first, or add a coverage case with live_addresses > settings.retries and adjust the comment/PR claim to match the actual contract.
source: ['claude', 'codex']
There was a problem hiding this comment.
Resolved in cb468d8 — All-stale collapse to NoAvailableAddressesToRetry only holds when live_addresses <= settings.retries no longer present.
Auto-resolved by the review system based on the latest commit diff. If you believe this was closed in error, reopen the thread.
| | Aborted | ||
| | Internal | ||
| | Unavailable | ||
| // During a mixed-version network rollout, Unimplemented means this | ||
| // particular node runs an older build that doesn't expose the method | ||
| // yet; another node may serve it. Marking it retryable makes the | ||
| // executor ban the node and retry elsewhere. If no node implements | ||
| // the method, all addresses get exhausted and the error still | ||
| // surfaces as NoAvailableAddressesToRetry. |
There was a problem hiding this comment.
🟡 Suggestion: Address-scoped ban for UNIMPLEMENTED can degrade healthy nodes serving other methods
update_address_ban_status (packages/rs-dapi-client/src/dapi_client.rs:162) bans by Address, not by (address, method). UNIMPLEMENTED is not only emitted by stale rollout nodes: packages/rs-drive-abci/src/query/service.rs:262,271,446,453 deliberately returns Status::unimplemented for broadcast_state_transition, wait_for_state_transition_result, and get_consensus_params, and packages/rs-dapi/src/error.rs:163 maps every DapiError::MethodNotFound to Status::unimplemented. After this change, a call to any such endpoint bans that otherwise-healthy node across all methods for the full ban window (60s base, exponential on repeat). On clients with small address pools this can make unrelated supported requests fail with NoAvailableAddresses until the ban expires. The targeted mixed-version rollout case justifies the trade-off, but it should at least be documented inline and tracked as a follow-up for per-method ban granularity so optional / feature-gated endpoints do not poison the shared address list.
source: ['claude', 'codex']
There was a problem hiding this comment.
Resolved in cb468d8 — Address-scoped ban for UNIMPLEMENTED can degrade healthy nodes serving other methods no longer present.
Auto-resolved by the review system based on the latest commit diff. If you believe this was closed in error, reopen the thread.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v3.1-dev #3875 +/- ##
============================================
+ Coverage 70.82% 71.20% +0.37%
============================================
Files 20 20
Lines 2797 2837 +40
============================================
+ Hits 1981 2020 +39
- Misses 816 817 +1
🚀 New features to boost your workflow:
|
|
✅ DashSDKFFI.xcframework built for this PR.
SwiftPM (host the zip at a stable URL, then use): .binaryTarget(
name: "DashSDKFFI",
url: "https://your.cdn.example/DashSDKFFI.xcframework.zip",
checksum: "e31666d0e9ce0beec7232260886d2ccb07d7c5962f9947c2c3193f3820b831be"
)Xcode manual integration:
|
… branch Addresses review feedback on the UNIMPLEMENTED failover change: - Rewrite the `CanRetry for tonic::Status` comment to state the actual two-cap termination contract: the non-retryable NoAvailableAddressesToRetry collapse only holds when live_addresses <= settings.retries; with a larger pool the per-call retry budget trips first and the raw (still-retryable) Unimplemented surfaces, bounded by the caller's own cap (rs-sdk total_retries) and progressive banning across rounds. - Document the address-scoped (not per-method) ban trade-off inline with a TODO(per-method-ban) follow-up, since UNIMPLEMENTED is also returned for genuinely unsupported / feature-gated endpoints. - Add integration test `unimplemented_surfaces_retryable_when_pool_exceeds_retry_budget` (3 nodes, retries = 1) pinning the large-pool branch the prior tests didn't exercise. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
thepastaclaw
left a comment
There was a problem hiding this comment.
Code Review
Carried-forward prior findings: prior-1 (FIXED — grpc.rs now documents both termination branches and a new test pins the live_addresses > settings.retries case); prior-2 (INTENTIONALLY DEFERRED — explicit TODO(per-method-ban) and inline caveat in grpc.rs:137-145). New findings in the latest delta: one real bug in rs-sdk error wrapping — Error::can_retry() does not delegate to the wrapped DapiClientError, so the rs-dapi-client comment's claim that rs-sdk re-enters and converges on NoAvailableAddressesToRetry is false for SDK callers; in the live_addresses > settings.retries branch, shielded sync can stop before reaching an upgraded node. The fix is a one-line delegation.
🟡 1 suggestion(s)
1 additional finding(s) omitted (not in diff).
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `packages/rs-sdk/src/error.rs`:
- [SUGGESTION] packages/rs-sdk/src/error.rs:341-347: rs-sdk Error::can_retry drops retryability of wrapped DapiClientError, breaking the mixed-version failover convergence the PR documents
The new `Unimplemented` reclassification in `packages/rs-dapi-client/src/transport/grpc.rs:117-146` explicitly relies on callers honoring `CanRetry` to re-enter `DapiClient::execute` and converge on `NoAvailableAddressesToRetry` in the `live_addresses > settings.retries` branch (see the comment block: "A caller that honors `CanRetry` then re-enters and bans more nodes each round … rs-sdk also bounds this via its own `total_retries` cap (see `rs-sdk/src/sync.rs`)").
But `Error::can_retry()` here only matches `StaleNode | TimeoutReached | Proof`. When `DapiClient::execute` returns a raw retryable `DapiClientError::Transport(Grpc(Unimplemented))` (the `live_addresses > settings.retries` branch), `From<DapiClientError> for Error` wraps it as `Error::DapiClientError(value)` (line 221), and `sync::retry` at `packages/rs-sdk/src/sync.rs:124` evaluates `!error.can_retry()` → terminates immediately. The SDK only bans `settings.retries + 1` stale nodes and surfaces `Unimplemented` to the caller instead of converging on exhausted addresses as the in-tree documentation claims.
For the PR's stated mixed-version rollout scenario (shielded sync over a pool larger than the per-call retry budget), SDK callers can still fail before reaching an upgraded node. The new `unimplemented_failover` integration test covers the rs-dapi-client boundary but not the SDK wrapper boundary, so this regression is invisible at test time.
Delegating to the wrapped error's `can_retry()` closes the gap and aligns rs-sdk with the contract the grpc.rs comment promises.
Issue being fixed or feature implemented
rs-dapi-client classifies gRPC
Unimplementedas non-retryable, so the error surfaces directly to the caller. For a stable network that's correct, but during a mixed-version rollout (e.g. shielded endpoints newly activated on testnet 4.0.0-rc.2) UNIMPLEMENTED actually means "this particular evonode runs an older build" — the same request succeeds on an upgraded node.Observed 2026-06-12 on testnet: SwiftExampleApp's shielded sync failed with
Dapi client error: transport error: grpc error: 'Operation is not implemented or not supported'from one rotation node, whileseed-1.testnet.networks.dash.org:1443(and subsequent syncs) served all sixgetShielded*methods fine.What was done?
Reclassified
Code::Unimplementedas retryable inCanRetry for tonic::Status. In the executor, ban-and-failover is the retryable path:update_address_ban_statusbans the failed address only for retryable errors, and the retry loop then selects a fresh live address. So the stale node gets banned (60s base, exponential backoff on repeat) and the request transparently retries on another node.This is bounded, not infinitely retryable. How an all-UNIMPLEMENTED network terminates depends on which of
DapiClient::execute's two caps trips first:live_addresses <= settings.retries: the address list is exhausted before the retry budget, soget_live_address()runs dry and the executor surfacesNoAvailableAddressesToRetrywrapping the last UNIMPLEMENTED status — itself non-retryable, so caller-level retry wrappers (e.g. rs-sdk'sretry) won't loop on a genuinely unsupported network.live_addresses > settings.retries: the per-call retry budget (settings.retries, default 5) trips first, banningsettings.retries + 1nodes and surfacing the raw (still-retryable)Unimplemented. A caller that honorsCanRetrythen re-enters and bans more nodes each round, converging on the exhausted-addresses case above; rs-sdk additionally bounds this with its owntotal_retriescap. Either way the loop is bounded — it never retries the same node forever.Caveat (follow-up): bans are address-scoped, not
(address, method)-scoped, andUnimplementedis also returned deliberately for genuinely unsupported / feature-gated endpoints (rs-drive-abci'sbroadcast_state_transition/wait_for_state_transition_result/get_consensus_params, and any rs-dapiMethodNotFound). Calling such an endpoint now bans an otherwise-healthy node across all methods for the ban window. Acceptable for the targeted mixed-version-rollout case; per-method ban granularity is left as a follow-up (documented inline asTODO(per-method-ban)).Server-side uses of
Unimplemented(rs-dapi error mapping, drive-abci handler codes) are unaffected; nothing else in the workspace relied on the old client-side classification.How Has This Been Tested?
can_retry()classification unit tests intransport.rs.tests/unimplemented_failover.rsdrive the realDapiClient::executeretry loop with a fake transport (the existingMockDapiClientbypasses the executor, so it can't cover this):retries == 1, the response comes from a different address, and the stale node is banned in theAddressList;live_addresses <= settings.retries): both nodes are tried exactly once, the surfaced error isNoAvailableAddressesToRetry(Unimplemented)and reports non-retryable;live_addresses > settings.retries): with 3 nodes andretries = 1, the retry cap trips first — exactlyretries + 1 = 2nodes are banned and the surfaced rawUnimplementedis still retryable. This pins the branch where the all-stale collapse does not hold, so the inline comment and this description match the actual contract.cargo test -p rs-dapi-client(default and--all-features),cargo clippy -p rs-dapi-client --all-features --tests,cargo fmt— all clean.Breaking Changes
None.
Checklist:
For repository code-owners and collaborators only
🤖 Generated with Claude Code