Skip to content
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

Mempool: remove disconnected orphans #1152

Merged
merged 5 commits into from
Aug 10, 2023

Conversation

iljakuklic
Copy link
Contributor

@iljakuklic iljakuklic commented Aug 9, 2023

Remove orphan transactions sent by a peer when the peer disconnects.

I am not satisfied with the way the events are wired up. Since p2p already listens for mempool events (orphans being processed) and now mempool listens to p2p events, there is a bit of circularity. Usually, the subsystem subscribes to events it wants to listen to during its setup. However in this case, p2p setup code subscribes mempool to p2p events. Another unfortunate side effect of this is that mempool handler that processes p2p events is now exposed via public API.

A follow up PR that addresses these issues is in the works. It involves separating p2p interface and mempool interface into their own crates. As a side effect, we get a better interface / implementation separation for these two subsystems at crate level. Came up with an alternative solution. Still suffers from the issue of exposing event handlers via a public interface but good enough for now.

Comment on lines 76 to 80
/// Handle a p2p event.
// TODO This is here because of awkward inter-crate dependencies. A nicer solution would be to
// factor out subsystem interface traits into separate crates and subscribe to p2p events
// together with the other mempool setup code
fn handle_p2p_event(&mut self, evt: p2p_types::p2p_event::P2pEvent);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not very happy about exposing this via a public interface. See the PR description for details.

@iljakuklic iljakuklic marked this pull request as draft August 9, 2023 10:01
@iljakuklic iljakuklic force-pushed the mempool-remove-disconnected-orphans branch from 5063911 to 4a4f557 Compare August 9, 2023 15:40
@iljakuklic
Copy link
Contributor Author

I am not satisfied with the way the events are wired up. Since p2p already listens for mempool events (orphans being processed) and now mempool listens to p2p events, there is a bit of circularity. Usually, the subsystem subscribes to events it wants to listen to during its setup. However in this case, p2p setup code subscribes mempool to p2p events. Another unfortunate side effect of this is that mempool handler that processes p2p events is now exposed via public API.

This has now been changed to a subsystem call rather than event subscribtion. The issue that the event handler for processing peer disconnect events by mempool is now a part of the public API still remains.

A follow up PR that addresses these issues is in the works. It involves separating p2p interface and mempool interface into their own crates. As a side effect, we get a better interface / implementation separation for these two subsystems at crate level.

Abandoning the approach mentioned here for now.

@iljakuklic iljakuklic marked this pull request as ready for review August 9, 2023 15:50
@iljakuklic iljakuklic force-pushed the mempool-remove-disconnected-orphans branch from 4a4f557 to f3b06b1 Compare August 10, 2023 07:43
Copy link
Contributor

@muursh muursh left a comment

Choose a reason for hiding this comment

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

I have no qualms with this

Copy link
Collaborator

@TheQuantumPhysicist TheQuantumPhysicist left a comment

Choose a reason for hiding this comment

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

Besides the minor comments, looking good.

Though the main message of the PR may need to be updated. I believe you're satisfied with the current state :-)

@iljakuklic iljakuklic merged commit 2699a1e into master Aug 10, 2023
23 checks passed
@iljakuklic iljakuklic deleted the mempool-remove-disconnected-orphans branch August 10, 2023 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants