Skip to content

fix(rust-sdk): propagate RPC errors in wait_past_perfect_time - #245

Open
crazywriter1 wants to merge 1 commit into
podnetwork:mainfrom
crazywriter1:fix/wait-past-perfect-time-errors
Open

fix(rust-sdk): propagate RPC errors in wait_past_perfect_time#245
crazywriter1 wants to merge 1 commit into
podnetwork:mainfrom
crazywriter1:fix/wait-past-perfect-time-errors

Conversation

@crazywriter1

Copy link
Copy Markdown

Summary

Fixes a bug in PodProvider::wait_past_perfect_time where unrelated RPC errors were silently treated as success.

Previously, the retry loop used a catch-all branch that returned Ok(()) for any error that was not the expected "PPT too far in the future" response. This meant callers could believe waiting succeeded even when the node returned a real failure (for example, protocol validation errors).

This PR:

  • Returns Ok(()) only when the RPC call succeeds
  • Retries only for the expected -32602 / "Requested PPT is too far in the future" error
  • Propagates all other RPC errors to the caller
  • Adds unit and integration tests for success, retry, and error propagation paths

Problem

match &result {
    Err(e) if retries < MAX_RETRIES && is_ppt_too_far_error(&e) => {
        // retry
    }
    _ => return Ok(()), // <- swallows unrelated errors
}

Any non-retryable RPC failure was converted into success, which can hide real node/network issues from SDK callers.

Fix

Extracted retry logic into wait_ppt_step() and is_ppt_too_far_error() so the behavior is explicit and testable:

  • Ok(true) → RPC succeeded, return success
  • Ok(false) → retryable PPT-too-far error, sleep and retry
  • Err(e) → propagate error to caller

Tests

Added 8 tests in rust-sdk/src/provider/mod.rs:

  • success path

  • retry on PPT-too-far

  • error when retry budget is exhausted

  • unrelated RPC errors are propagated

  • PPT-too-far matcher requires exact code + message

  • mocked provider integration tests for success, retry, and error propagation

    cargo test -p pod-sdk wait_ppt

Test plan

  • cargo test -p pod-sdk wait_ppt
  • Verified unrelated RPC errors are no longer swallowed
  • Verified retry behavior for PPT-too-far remains unchanged

Only retry when the node returns the expected PPT-too-far error;
all other RPC failures are now returned to the caller instead of
being silently swallowed as success.
Adds unit and integration tests for the retry and error paths.
@crazywriter1

Copy link
Copy Markdown
Author

Hi @poszu @shresthagrawal friendly ping for a review when you have a moment. This PR fixes wait_past_perfect_time so unrelated RPC errors are propagated instead of being silently treated as success. Only the expected PPT-too-far error (-32602) is retried. Added 8 tests covering success, retry, and error propagation paths. Verified locally with:

  • cargo test -p pod-sdk wait_ppt

Happy to adjust if you’d prefer a different error-handling structure. Thanks!

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.

1 participant