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

Prioritise primary stream #6086

Closed
wants to merge 7 commits into from
Closed

Prioritise primary stream #6086

wants to merge 7 commits into from

Conversation

emhane
Copy link
Member

@emhane emhane commented Jan 16, 2024

programmability spans up a new attack surface onto the node. this pr prioritises the primary stream. it is a good precaution that aims to limit the damage of user-defined vulnerabilities to the injected handles, and not let them effect the whole node.

by letting users inject cap-handles into reth, we are making the node vulnerable to all kinds of errors we cannot foresee and therefore not make any guarantees for how the node runs. a scenario that could happen before, is that some user-defined cap-handle can be dos:ed so that it sends endless messages, this means that the RlpxSatelliteStream stream will get stuck in a loop and no more eth messages would be sent or received.

Copy link
Collaborator

@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.

oh yeah this is better.

we're still draining all protocol messages but hitting the primary earlier again.

one comment about break statement and FuturesUnordered suggestion

Poll::Ready(None) => return Poll::Ready(None),
Poll::Pending => {
this.inner.protocols.push(proto);
break
Copy link
Collaborator

Choose a reason for hiding this comment

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

this break will terminate the for loop now, but we still want to advance the remaining streams, right?

perhaps we should rewrite protocols: Vec<ProtocolStream> as
FuturesUnordered<StreamFuture<ProtocolStream>

see also SelectAll impl

https://docs.rs/futures-util/0.3.30/src/futures_util/stream/select_all.rs.html#93

Copy link
Member Author

Choose a reason for hiding this comment

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

absolutely. I also found some more code that impedes us from prioritising the primary stream, fixed it in the latest commit.

@mattsse mattsse added C-perf A change motivated by improving speed, memory usage or disk footprint A-networking Related to networking in general labels Jan 16, 2024
@emhane
Copy link
Member Author

emhane commented Jan 17, 2024

stoping development, in favour of using MuxDemuxStream from #5577 with ConnectionHandler.

@emhane emhane closed this Jan 17, 2024
@emhane emhane deleted the emhane/dos-patch branch November 20, 2024 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-networking Related to networking in general C-perf A change motivated by improving speed, memory usage or disk footprint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants