feat(api): add pending transaction support in the eth subscription API#6941
feat(api): add pending transaction support in the eth subscription API#6941akaladarshi wants to merge 2 commits into
eth subscription API#6941Conversation
WalkthroughThis PR refactors Ethereum pubsub subscriptions from a handle_subscription/JoinHandle pattern to a stream-based architecture, adding a broadcast stream utility, exposing a helper function for tx hash conversion, and removing now-obsolete chain.rs subscribers. ChangesETH Pubsub Stream-based Refactoring
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
c221f29 to
f4b122e
Compare
f4b122e to
6f51115
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/rpc/methods/eth/pubsub.rs`:
- Around line 126-128: The stream currently iterates only changes.applies so
reverted tipsets are ignored; update the flat_map over
subscription_stream(head_rx) to emit both applies and reverts (e.g., pair each
tipset with a boolean or enum indicating is_revert) instead of only
changes.applies, then adjust the subsequent filter_map closure that binds ts to
accept that (tipset, is_revert) and produce log removal events for reverts and
normal events for applies; target the subscription_stream/head_rx pipeline and
the closure capturing ts in pubsub.rs so reorg-driven log removals are emitted.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 023ea685-f51d-4356-8476-c6eea9c54e3d
📒 Files selected for processing (7)
src/message_pool/msgpool/events.rssrc/message_pool/msgpool/msg_pool.rssrc/rpc/methods/chain.rssrc/rpc/methods/eth.rssrc/rpc/methods/eth/pubsub.rssrc/utils/broadcast/mod.rssrc/utils/broadcast/tests.rs
💤 Files with no reviewable changes (2)
- src/message_pool/msgpool/msg_pool.rs
- src/rpc/methods/chain.rs
| let stream = subscription_stream(head_rx) | ||
| .flat_map(|changes| futures::stream::iter(changes.applies)) | ||
| .filter_map(move |ts| { |
There was a problem hiding this comment.
Handle revert tipsets in logs subscriptions.
On Line 127, the stream only iterates changes.applies, so reverted tipsets are dropped and reorg-driven log removals cannot be emitted.
💡 Suggested fix
- let stream = subscription_stream(head_rx)
- .flat_map(|changes| futures::stream::iter(changes.applies))
+ let stream = subscription_stream(head_rx)
+ .flat_map(|changes| {
+ futures::stream::iter(
+ changes
+ .reverts
+ .into_iter()
+ .chain(changes.applies.into_iter()),
+ )
+ })
.filter_map(move |ts| {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/rpc/methods/eth/pubsub.rs` around lines 126 - 128, The stream currently
iterates only changes.applies so reverted tipsets are ignored; update the
flat_map over subscription_stream(head_rx) to emit both applies and reverts
(e.g., pair each tipset with a boolean or enum indicating is_revert) instead of
only changes.applies, then adjust the subsequent filter_map closure that binds
ts to accept that (tipset, is_revert) and produce log removal events for reverts
and normal events for applies; target the subscription_stream/head_rx pipeline
and the closure capturing ts in pubsub.rs so reorg-driven log removals are
emitted.
Codecov Report❌ Patch coverage is
Additional details and impacted files
... and 29 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Summary of changes
Changes introduced in this pull request:
sinkReference issue to close (if applicable)
Closes #6031
Other information and links
Change checklist
Outside contributions
Summary by CodeRabbit
Release Notes
New Features
pendingTransactions,logs, andnewHeadswith improved stream handling.Refactor
Tests