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

chore(net): extract NetworkHandle methods for launching node to traits #9966

Merged
merged 4 commits into from
Aug 1, 2024

Conversation

emhane
Copy link
Member

@emhane emhane commented Jul 31, 2024

Ref #9872

  • Adds new traits BlockDownloaderProvider in order to use generic network in node builder, instead of concrete type NetworkHandle
  • Add new trait FullNetwork which unifies behaviour needed to launch node
  • Adds PeersHandleProvider to integrate generic network in testing
  • Moves necessary types from reth-network to reth-network-types in order to extract NetworkHandle methods into new traits

Note: In order to move BlockDownloaderProvider to reth-network-api, the FetchClient type would have to move to reth-network-types, and reth_network_p2p::EthResponseValidator and reth_network_p2p::HeadersRequest would have to move out of reth-network-p2p. The latter, is to remove dep on reth-network-types from reth-network-p2p, since FetchClient depends on reth-network-p2p

@emhane emhane added C-debt Refactor of code section that is hard to understand or maintain A-networking Related to networking in general labels Jul 31, 2024
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.

looks like a lot of the changes are unrelated and due to moved use statements, please try to avoid that in a pr that also moves stuff around because this makes it a lot harder to review

I'd like to break this down, can we start this process with a pr that introduces the new traits and perhaps (multiple) prs that move the types to network-types as prep?

Copy link
Collaborator

Choose a reason for hiding this comment

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

did anything change here?
all of this looks unrelated, hard to tell

Copy link
Member Author

Choose a reason for hiding this comment

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

hm, sometimes when bases switches, changes on main look like new changes. I checked this out from emhane/network-types originally.

Copy link
Member Author

Choose a reason for hiding this comment

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

the module preludes I crossed, I cleaned up, is this a problem?

@emhane emhane closed this Aug 1, 2024
@emhane emhane reopened this Aug 1, 2024
@emhane emhane closed this Aug 1, 2024
@emhane emhane reopened this Aug 1, 2024
@emhane emhane requested a review from mattsse August 1, 2024 12:24
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.

I would still prefer if we could do this incrementally, because it's a bit to keep an overview about why certain things are moved where.

I still think we can move the types that we need first and then introduce the traits

Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm, this would be more appropriate in network-api I believe

Copy link
Member Author

Choose a reason for hiding this comment

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

this is needed in PeersHandle type, so needs to stay too. we should try and keep types in the designated types crate and traits in the designated api crate, just like it's cleanly done for reth-rpc-eth-api and reth-rpc-eth-types

Copy link
Collaborator

Choose a reason for hiding this comment

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

these are all network api related types so I don't understand why we can't move this to the API crate, types is intended for standalone network related types, types we only used for interacting with network API functions don't fit here like command types

Copy link
Member Author

Choose a reason for hiding this comment

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

we can re-export them in reth-network-api, but it's much more intentional design if we keep types in types and api in api

crates/net/network-types/src/peers/handle.rs Show resolved Hide resolved
crates/net/network-types/src/peers/mod.rs Show resolved Hide resolved
@emhane
Copy link
Member Author

emhane commented Aug 1, 2024

I would still prefer if we could do this incrementally, because it's a bit to keep an overview about why certain things are moved where.

I still think we can move the types that we need first and then introduce the traits

I think that argument is contradictory, since the traits and cyclical deps are the reason why the types need to move

@emhane emhane requested a review from mattsse August 1, 2024 15:39
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.

okay convinced but please keep these smaller moving forward

@emhane emhane added this pull request to the merge queue Aug 1, 2024
Merged via the queue into main with commit b10517b Aug 1, 2024
33 checks passed
@emhane emhane deleted the emhane/network-traits branch August 1, 2024 17:03
@mattsse mattsse restored the emhane/network-traits branch August 1, 2024 19:13
@emhane emhane deleted the emhane/network-traits branch August 24, 2024 14:10
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-debt Refactor of code section that is hard to understand or maintain
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants