Skip to content

feat(provider): apply GetSubscription to trait #2220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

frankudoags
Copy link
Contributor

Motivation

Follow up on #2203
Use GetSubscription type for subscription functions in Provider trait and refractor affected areas

Solution

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@frankudoags
Copy link
Contributor Author

@mattsse @yash-atreya
Kindly take a look

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

ty, some suggestions

Comment on lines 968 to 969
fn subscribe_pending_transactions(&self) -> GetSubscription<(&'static str,), B256, N> {
GetSubscription::new(self.root(), "eth_subscribe", Some(("newPendingTransactions",)))
Copy link
Member

Choose a reason for hiding this comment

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

we can replace the string with

pub enum SubscriptionKind {

Comment on lines 38 to 40
&self,
) -> TransportResult<alloy_pubsub::Subscription<alloy_rpc_types_admin::PeerEvent>>;
fn subscribe_peer_events(&self) -> GetSubscription<(), alloy_rpc_types_admin::PeerEvent, N>;
Copy link
Member

Choose a reason for hiding this comment

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

I believe we can get rid of the N generic if we use WeakClient instead of the RootProvider in the GetSubscription type

Copy link
Member

@yash-atreya yash-atreya Mar 20, 2025

Choose a reason for hiding this comment

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

Addressed in #2219

@github-project-automation github-project-automation bot moved this to In Progress in Alloy Mar 19, 2025
@mattsse
Copy link
Member

mattsse commented Mar 19, 2025

@yash-atreya I believe #2219 does the weakclient change, should we get this one in first?

@yash-atreya
Copy link
Member

yash-atreya commented Mar 20, 2025

@yash-atreya I believe #2219 does the weakclient change, should we get this one in first?

Yes we can get this one in and I can rebase #2219

@frankudoags
Copy link
Contributor Author

@yash-atreya I like the weak client change to drop the network generic and passing just the Rpc Call directly. I think we can merge #2219 in and I follow that to upgrade other subscription functions.

Seeing that if this gets merged, there'd still be clean up which can be avoided if that gets merged first. Wdyt?
cc @mattsse

@yash-atreya yash-atreya marked this pull request as ready for review March 20, 2025 07:40
@yash-atreya yash-atreya requested a review from klkvr as a code owner March 20, 2025 07:40
@yash-atreya
Copy link
Member

Hey @frankudoags, #2219 was merged.

Please rebase your PR and let me know if you need any help.

Thanks!

@frankudoags frankudoags force-pushed the feat-add-subscription-type-to-subscription-fns branch from 3c16bdf to 454b6da Compare March 20, 2025 15:00
@frankudoags frankudoags requested a review from yash-atreya March 20, 2025 15:03
@frankudoags
Copy link
Contributor Author

having some issues @yash-atreya

  1. The subscribe_logs is failing due to some lifetime issues and wants me to introduce a lifetime which I do not think I should(fails with "lifetime may not live long enough" for the &Filter in the response type

  2. Trying to use GetSubscription for admin_peerEvents_subscribe is failing

call: RpcCall<P, B256>,

expected RpcCall<(), FixedBytes<32>>, found RpcCall<[(); 0], _, _, fn(_) -> _>

@frankudoags
Copy link
Contributor Author

our call method inside GetSubscription is RpcCall<P, B256>, does that mean it must always have params? if that is the case, it would not work for admin_peerEvents_subscribe or any subscription with no params @yash-atreya

@frankudoags
Copy link
Contributor Author

All done now, @yash-atreya , ptal

@frankudoags frankudoags requested a review from yash-atreya March 20, 2025 18:26
@yash-atreya yash-atreya changed the title feat: use GetSubscription type for subscription functions in Provider… feat(provider): apply GetSubscription to trait Mar 21, 2025
Copy link
Member

@yash-atreya yash-atreya left a comment

Choose a reason for hiding this comment

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

send it!

@yash-atreya yash-atreya moved this from In Progress to Reviewed in Alloy Mar 21, 2025
@DaniPopes DaniPopes enabled auto-merge (squash) March 21, 2025 09:12
@DaniPopes DaniPopes merged commit 84eb058 into alloy-rs:main Mar 21, 2025
27 checks passed
@github-project-automation github-project-automation bot moved this from Reviewed to Done in Alloy Mar 21, 2025
@frankudoags
Copy link
Contributor Author

thank you all @mattsse @yash-atreya @DaniPopes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants