OpenZeppelin / OpenZeppelin/Robust-Provider
Add unsubscribe to RobustSubscription / Provider
Nobody has claimed this yet.
- 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:
- It calls
provider.unsubscribe(id)on the underlyingRootProvider - This removes the subscription from the pubsub frontend's internal tracking
- However, the
RobustSubscriptionstill holds its ownSubscription<N::HeaderResponse>object - 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:
- Cancels the internal subscription
- Signals the stream to close
Options:
- Add an
unsubscribe()method directly onRobustSubscription - Use a cancellation token/channel that
RobustProvider::unsubscribecan signal - Track active subscriptions in
RobustProviderand notify them on unsubscribe
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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