OpenZeppelin / OpenZeppelin/Robust-Provider

Refactor RobustSubscription to delegate provider management to RobustProvider

Open
#2 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

effort: M 1 week priority: medium type: refactor
Dominant language
Rust
Stars
6
Forks
4
Avg merge
15h 52m
Merged PRs (30d)
5

Description

Summary

RobustSubscription currently tracks provider state (current_fallback_index, last_reconnect_attempt) and implements reconnection logic (try_reconnect_to_primary, switch_to_fallback). This violates separation of concerns—provider management should be the responsibility of RobustProvider, not the subscription.

Current Problems

1. RobustSubscription knows too much about providers
  • Tracks current_fallback_index and last_reconnect_attempt
  • Directly calls try_fallback_providers_from and try_provider_with_timeout
  • Implements try_reconnect_to_primary logic
2. Reconnection logic is subscription-agnostic
  • The periodic reconnection to primary provider is general RobustProvider functionality
  • Has nothing to do with subscriptions specifically
  • Should be reusable for other operations
3. Tight coupling
  • RobustSubscription needs internal knowledge of RobustProvider's fallback mechanism
  • Makes both components harder to maintain and test independently

Proposed Solution

RobustSubscription should only:

  • Hold the current subscription
  • Call recv() and handle timeouts
  • Tell RobustProvider: "give me a new subscription" when errors occur

RobustProvider should:

  • Track which provider is currently active (primary vs fallback index)
  • Track last_reconnect_attempt
  • Implement try_reconnect_to_primary logic
  • Expose a method like subscribe_blocks_with_failover() that handles all provider switching internally

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating RobustSubscription and RobustProvider, then read the existing fallback and reconnection entry points named in the issue: try_reconnect_to_primary, switch_to_fallback, try_fallback_providers_from, and try_provider_with_timeout. Done means RobustProvider owns provider state and switching, while RobustSubscription only receives subscriptions, handles recv() timeouts, and requests a new subscription through the provider.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend-api-design
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.