Skip to content

fix(sdk): ban node and retry elsewhere on UNIMPLEMENTED responses - #3875

Merged
QuantumExplorer merged 2 commits into
v3.1-devfrom
fix/dapi-client-unimplemented-failover
Jun 13, 2026
Merged

QuantumExplorer merged 2 commits into
v3.1-devfrom
fix/dapi-client-unimplemented-failover

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Jun 12, 2026 •

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

rs-dapi-client classifies gRPC Unimplemented as 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, while seed-1.testnet.networks.dash.org:1443 (and subsequent syncs) served all six getShielded* methods fine.

What was done?

Reclassified Code::Unimplemented as retryable in CanRetry for tonic::Status. In the executor, ban-and-failover is the retryable path: update_address_ban_status bans 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, so get_live_address() runs dry and the executor surfaces NoAvailableAddressesToRetry wrapping the last UNIMPLEMENTED status — itself non-retryable, so caller-level retry wrappers (e.g. rs-sdk's retry) won't loop on a genuinely unsupported network.
  • live_addresses > settings.retries: the per-call retry budget (settings.retries, default 5) trips first, banning settings.retries + 1 nodes and surfacing the raw (still-retryable) Unimplemented. A caller that honors CanRetry then re-enters and bans more nodes each round, converging on the exhausted-addresses case above; rs-sdk additionally bounds this with its own total_retries cap. Either way the loop is bounded — it never retries the same node forever.

Caveat (follow-up): bans are address-scoped, not (address, method)-scoped, and Unimplemented is also returned deliberately for genuinely unsupported / feature-gated endpoints (rs-drive-abci's broadcast_state_transition / wait_for_state_transition_result / get_consensus_params, and any rs-dapi MethodNotFound). 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 as TODO(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?

  • Updated the can_retry() classification unit tests in transport.rs.
  • Integration tests in tests/unimplemented_failover.rs drive the real DapiClient::execute retry loop with a fake transport (the existing MockDapiClient bypasses the executor, so it can't cover this):
    • mixed-version: with two nodes where the first attempt answers UNIMPLEMENTED, the request succeeds with retries == 1, the response comes from a different address, and the stale node is banned in the AddressList;
    • all-nodes-stale, small pool (live_addresses <= settings.retries): both nodes are tried exactly once, the surfaced error is NoAvailableAddressesToRetry(Unimplemented) and reports non-retryable;
    • all-nodes-stale, pool larger than the retry budget (live_addresses > settings.retries): with 3 nodes and retries = 1, the retry cap trips first — exactly retries + 1 = 2 nodes are banned and the surfaced raw Unimplemented is 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:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

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]>
@coderabbitai

coderabbitai Bot commented Jun 12, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@QuantumExplorer, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 87dc33de-8567-4a05-9c2f-48df76a30a7c

📥 Commits

Reviewing files that changed from the base of the PR and between 5507621 and cb468d8.

📒 Files selected for processing (3)
  • packages/rs-dapi-client/src/transport.rs
  • packages/rs-dapi-client/src/transport/grpc.rs
  • packages/rs-dapi-client/tests/unimplemented_failover.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/dapi-client-unimplemented-failover

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@thepastaclaw

thepastaclaw commented Jun 12, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Review complete (commit cb468d8)

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Comment on lines 114 to +123
| 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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🟡 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']

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Comment on lines +114 to +122
| 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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🟡 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']

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

codecov Bot commented Jun 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.20%. Comparing base (e2cde1d) to head (cb468d8).
⚠️ Report is 15 commits behind head on v3.1-dev.

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     
Components Coverage Δ
dpp ∅ <ø> (∅)
drive ∅ <ø> (∅)
drive-abci ∅ <ø> (∅)
sdk ∅ <ø> (∅)
dapi-client ∅ <ø> (∅)
platform-version ∅ <ø> (∅)
platform-value ∅ <ø> (∅)
platform-wallet ∅ <ø> (∅)
drive-proof-verifier ∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jun 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ 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:

  • Download 'DashSDKFFI.xcframework' artifact from the run link above.
  • Drag it into your app target (Frameworks, Libraries & Embedded Content) and set Embed & Sign.
  • If using the Swift wrapper package, point its binaryTarget to the xcframework location or add the package and place the xcframework at the expected path.

… 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 thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

@QuantumExplorer
QuantumExplorer merged commit fe27add into v3.1-dev Jun 13, 2026
18 of 19 checks passed
@QuantumExplorer
QuantumExplorer deleted the fix/dapi-client-unimplemented-failover branch June 13, 2026 20:30
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.

2 participants