-
Notifications
You must be signed in to change notification settings - Fork 103
feat(rpc): migrate base_subscribe to eth_subscribe #272
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
feat(rpc): migrate base_subscribe to eth_subscribe #272
Conversation
✅ Heimdall Review Status
|
Migrates flashblocks subscriptions from the base namespace to eth namespace per issue base#250. Since no release has been cut with base_subscribe yet, this is a clean replacement with no backwards compatibility needed. Changes: - Rename BasePubSubApi -> EthPubSubApi (namespace: base -> eth) - Rename BasePubSub -> EthPubSub - Rename BaseSubscriptionKind -> EthSubscriptionKind - Use replace_configured to override reth's existing eth_subscribe - Update all tests to use eth_subscribe/eth_unsubscribe Closes base#250
0efce22 to
58c4468
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. Would appreciate second set of eyes from @danyalprout. Since we're using replace_configured on the module context, we shouldn't run into any namespace collision errors and the test suite should validate this behavior. Nice work @madisoncarter1234!
glad to help!! |
|
This looks great re: renaming. As we're overriding, do we need to extend the enum for the standard subscription types and proxy them to Reth? |
Right. The initial PR was mainly about the namespace migration from base_subscribe to eth_subscribe and didn't really consider the full enum extension that you mentioned in #250. Because replace_configured changes the whole eth_subscribe handler, standard subscription types such as newHeads and logs would stop working if used with the current implementation. I will change the enum to include standard types and proxy them to reth's underlying handler. A revision will be pushed. |
|
Amazing -- thank you @madisoncarter1234 |
Per base#250, this extends the eth_subscribe handler to support both standard Ethereum subscription types and Base-specific flashblocks subscriptions. Changes: - Rename EthSubscriptionKind to ExtendedSubscriptionKind - Add standard types: newHeads, logs, newPendingTransactions, syncing - Add Base-specific types: newFlashblocks, pendingLogs - Proxy standard subscription types to reth's underlying implementation - Add reth-rpc dependency for access to RethEthPubSub - Update EthPubSub to accept eth_api for proxying - Add test for standard newHeads subscription This ensures backwards compatibility with existing eth_subscribe usage while adding flashblocks-specific subscription capabilities.
|
Updated the implementation to extend eth_subscribe with full support for standard subscription types per #250. Changes:
This maintains backwards compatibility, existing eth_subscribe("newHeads") calls will still function as they have been while also allowing for flashblocks-specific subscriptions to be used. Regarding the overriding of newPendingTransactions to use flashblocks state, I have left it as standard behavior for now since it has different semantics (mempool txs vs sequenced txs) I would be glad to create a flashblocks specific variant in a follow up if you want |
refcell
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great; nice work!
| /// New flashblocks subscription. | ||
| pub enum ExtendedSubscriptionKind { | ||
| /// New block headers subscription (standard). | ||
| NewHeads, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe this enum should encapsulate the SubscriptionKind enum rather than redefining it. while i dont expect the signature to change anytime soon, if it ever were to change, it would be nice to automatically have support for it or automatically get an unhandled error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
➕ I like this approach as well.
| assert_eq!(sub["jsonrpc"], "2.0"); | ||
| assert_eq!(sub["id"], 1); | ||
| // Should return a subscription ID, confirming the subscription was accepted | ||
| assert!(sub["result"].is_string(), "Expected subscription ID, got: {:?}", sub); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is is_string the correct assertion to make here?
danyalprout
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, I'm happy to experiment with the enum proposal in a follow up.
|
Thanks everyone!! |
Summary
Migrates flashblocks subscriptions from the
basenamespace to theethnamespace per #250.Since no release has been cut with
base_subscribeyet, this is a clean replacement with no backwards compatibility needed.BasePubSubApi→EthPubSubApi(namespace:base→eth)BasePubSub→EthPubSubBaseSubscriptionKind→EthSubscriptionKindreplace_configuredto override reth's existingeth_subscribeeth_subscribe/eth_unsubscribeUsage
Test plan
Closes #250