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

Use p2p Disconnects in eth handshake #1492

Closed
Rjected opened this issue Feb 21, 2023 · 2 comments
Closed

Use p2p Disconnects in eth handshake #1492

Rjected opened this issue Feb 21, 2023 · 2 comments
Assignees
Labels
A-devp2p Related to the Ethereum P2P protocol C-enhancement New feature or request

Comments

@Rjected
Copy link
Member

Rjected commented Feb 21, 2023

Describe the feature

Currently we just terminate the stream when receiving a message, and do not send a Disconnect message when disconnecting. The EthStream treats the underlying stream it wraps as a generic Stream and Sink, so we will need to add an additional bound that is implemented as a no-op by standard stream types like TcpStream.

Something like the following:

/// This trait is meant to allow higher level protocols like `eth` to disconnect from a peer, using
/// lower-level disconnect functions (such as those that exist in the `p2p` protocol) if the
/// underlying stream supports it.
#[async_trait::async_trait]
pub trait CanDisconnect<T>: Sink<T> + Unpin + Sized {
    /// Disconnects from the underlying stream, using a [`DisconnectReason`] as disconnect
    /// information if the stream implements a protocol that can carry the additional disconnect
    /// metadata.
    async fn disconnect(
        &mut self,
        reason: DisconnectReason,
    ) -> Result<(), <Self as Sink<T>>::Error>;
}

This will then be implemented by P2PStream, so an EthStream<P2PStream<S>> can access this method on its inner field.

Additional context

Hive devp2p tests depend on this functionality, and reth currently fails due to this:
https://github.com/paradigmxyz/reth/actions/runs/4237113733/jobs/7362781160#step:7:34

This is where hive checks for a disconnect in the devp2p tests:
https://github.com/ethereum/go-ethereum/blob/fe01a2f63b8591d8226742726d8d6aaad4cd981e/cmd/devp2p/internal/ethtest/helpers.go#L511

@Rjected Rjected added C-enhancement New feature or request S-needs-triage This issue needs to be labelled A-devp2p Related to the Ethereum P2P protocol and removed S-needs-triage This issue needs to be labelled labels Feb 21, 2023
@Rjected Rjected self-assigned this Feb 21, 2023
@mattsse
Copy link
Collaborator

mattsse commented Feb 22, 2023

Closed by #1494
?

@Rjected
Copy link
Member Author

Rjected commented Feb 22, 2023

Closed by #1494
?

yep, forgot to add the fixes line

@Rjected Rjected closed this as completed Feb 22, 2023
@github-project-automation github-project-automation bot moved this from Todo to Done in Reth Tracker Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-devp2p Related to the Ethereum P2P protocol C-enhancement New feature or request
Projects
Archived in project
Development

No branches or pull requests

2 participants