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

Stub network crate #43

Merged
merged 11 commits into from
Nov 1, 2024
Merged

Stub network crate #43

merged 11 commits into from
Nov 1, 2024

Conversation

jimmygchen
Copy link
Member

@jimmygchen jimmygchen commented Oct 24, 2024

Addresses #17 partially.

Specification: https://github.com/ssvlabs/ssv-spec/tree/main/p2p

@jimmygchen jimmygchen requested a review from AgeManning October 24, 2024 05:48
@jimmygchen jimmygchen marked this pull request as draft October 24, 2024 05:49
@jimmygchen jimmygchen self-assigned this Oct 28, 2024
@AgeManning AgeManning requested a review from jking-aus October 28, 2024 05:38
@AgeManning
Copy link
Member

Nice!
Exactly this!

We need to decide on the thing that is going to poll the swarm. In lighthouse we have network, but Anchor doesn't need to do any syncing and I suspect this version of network is probably going to be very small, so we might be able to house the task that polls the swarm inside p2p-network.

The next part will be building a config for the network, instantiating it and then initialising it on boot.

Dialing peers and that will be handled by discovery and the peer manager, once we add them in.

I think for initial steps, it might be nice to just dial some configured boot-nodes and listen on some gossipsub topics. We could do these steps in future PRs

@AgeManning
Copy link
Member

If we can group both objects together, we might get away with just calling this crate network, if we are being ambitious :p

@jimmygchen jimmygchen changed the title Stub p2p-network crate Stub network crate Oct 29, 2024
@AgeManning AgeManning marked this pull request as ready for review November 1, 2024 00:45
Copy link
Member

@AgeManning AgeManning left a comment

Choose a reason for hiding this comment

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

Great start! Nice work

Copy link
Contributor

@jking-aus jking-aus left a comment

Choose a reason for hiding this comment

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

looks good

@jking-aus jking-aus merged commit 4956972 into sigp:unstable Nov 1, 2024
8 checks passed
@jking-aus jking-aus deleted the network-crate branch November 1, 2024 01:00
if let Ok(mut network_key_file) = File::open(network_key_f.clone()) {
let mut key_bytes: Vec<u8> = Vec::with_capacity(36);
match network_key_file.read_to_end(&mut key_bytes) {
Err(_) => debug!("Could not read network key file"),

Choose a reason for hiding this comment

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

Should we return an error if the key file exists but can't be read?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question - the current behaviour is, if the file does not exist, is invalid or cannot be read, then we generate a new one.

This is the same behaviour from Lighthouse - tbh I didn't really think about changing it when I copied this from LH. This node private key is mostly transparent to the user and used for node id, peer id and noise protocol encryption. As it's transparent to the user, I think it's better UX to treat it as invalid if the file cannot be read, and regenerate a new one, instead of crashing and asking the user to fix it manually or delete the existing corrupted file.

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.

4 participants