OpenZeppelin / OpenZeppelin/Robust-Provider

Add unsubscribe to RobustSubscription / Provider

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

Nobody has claimed this yet.

effort: S 2-3 days priority: high type: feature
Dominant language
Rust
Stars
6
Forks
4
Avg merge
15h 52m
Merged PRs (30d)
5

Description

Problem

Currently, RobustProvider::unsubscribe(id) does not properly cancel a RobustSubscription.

Root Cause

Alloy's PubSubFrontend::unsubscribe (source) only sends a PubSubInstruction::Unsubscribe to the backend, which removes the subscription from local tracking. It does not make an eth_unsubscribe RPC call.

When RobustProvider::unsubscribe(sub_id) is called:

  1. It calls provider.unsubscribe(id) on the underlying RootProvider
  2. This removes the subscription from the pubsub frontend's internal tracking
  3. However, the RobustSubscription still holds its own Subscription<N::HeaderResponse> object
  4. The stream continues to receive blocks because the underlying websocket subscription is still active
Expected Behavior

After calling unsubscribe, the stream should return None (closed).

Proposed Solution

RobustSubscription needs its own unsubscribe method that:

  1. Cancels the internal subscription
  2. Signals the stream to close

Options:

  • Add an unsubscribe() method directly on RobustSubscription
  • Use a cancellation token/channel that RobustProvider::unsubscribe can signal
  • Track active subscriptions in RobustProvider and notify them on unsubscribe

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 at RobustProvider::unsubscribe and RobustSubscription, then read Alloy's PubSubFrontend::unsubscribe in crates/pubsub/src/frontend.rs at the linked source location. Trace how the internal Subscription is retained and identify a way for unsubscribe to signal the RobustSubscription; done means the stream returns None after RobustProvider::unsubscribe(id).

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.