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

feat: implement eth handshake disconnects #1494

Merged
merged 6 commits into from
Feb 22, 2023

Conversation

Rjected
Copy link
Member

@Rjected Rjected commented Feb 22, 2023

This implements disconnects in the eth handshake by introducing the CanDisconnect trait, following the design in #1492

The trait extends Sink<T>, with Default implementations for ECIESStream and all Framed<T, U> that implement Sink. These implementations just close the sink using SinkExt::close.

@Rjected Rjected added C-enhancement New feature or request A-devp2p Related to the Ethereum P2P protocol labels Feb 22, 2023
@codecov-commenter
Copy link

codecov-commenter commented Feb 22, 2023

Codecov Report

Merging #1494 (a469bfc) into main (0fc9f67) will decrease coverage by 0.06%.
The diff coverage is 46.15%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##             main    #1494      +/-   ##
==========================================
- Coverage   76.00%   75.94%   -0.06%     
==========================================
  Files         358      358              
  Lines       42660    42689      +29     
==========================================
- Hits        32423    32422       -1     
- Misses      10237    10267      +30     
Flag Coverage Δ
integration-tests 21.83% <26.92%> (-0.03%) ⬇️
unit-tests 70.40% <46.15%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
crates/net/eth-wire/src/lib.rs 100.00% <ø> (ø)
crates/net/eth-wire/src/ethstream.rs 83.97% <25.00%> (-3.07%) ⬇️
crates/net/eth-wire/src/p2pstream.rs 79.41% <58.82%> (-0.42%) ⬇️
crates/net/eth-wire/src/disconnect.rs 82.55% <66.66%> (-1.03%) ⬇️
crates/net/network/src/session/active.rs 84.59% <100.00%> (ø)
crates/net/network/src/listener.rs 76.74% <0.00%> (-6.98%) ⬇️
crates/net/network/src/session/mod.rs 76.59% <0.00%> (-1.36%) ⬇️
crates/net/eth-wire/src/capability.rs 74.26% <0.00%> (-0.74%) ⬇️
crates/stages/src/stages/sender_recovery.rs 90.95% <0.00%> (-0.54%) ⬇️
... and 2 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Comment on lines +159 to +160
async fn disconnect(
&mut self,
Copy link
Collaborator

Choose a reason for hiding this comment

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

using mut borrow is fine I guess, mimicks what TcpStream::shutdown does as well.

and we likely need this mut borrow if we want to use it in Sink/Stream impls

@mattsse mattsse merged commit c168ef4 into main Feb 22, 2023
@mattsse mattsse deleted the dan/disconnect-on-handshake-failure branch February 22, 2023 11:18
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
None yet
Development

Successfully merging this pull request may close these issues.

3 participants