Conversation
cc3a2a2 to
5bbfb57
Compare
7eda5b5 to
2ca4167
Compare
| EventStream::InActive | ||
| }; | ||
|
|
||
| if !network_config.boot_nodes_multiaddr.is_empty() { |
There was a problem hiding this comment.
Bootnodes MA might not be necessary. See https://github.com/ssvlabs/ssv-spec/blob/main/p2p/SPEC.md#discovery
There was a problem hiding this comment.
Or maybe we should accept a UDP MA for discv5
|
I removed the hardcoded bootnode ENR. It's possible to use the holesky bootnode running: |
4ea508d to
e532014
Compare
jxs
left a comment
There was a problem hiding this comment.
Thanks for starting this Diego! Left some comments, mainly I think we should not merge commented instructions without proper explaining on the why
anchor/network/src/network.rs
Outdated
| } | ||
| }, | ||
| // TODO handle other swarm events | ||
| SwarmEvent::NewListenAddr { .. } => {}, |
There was a problem hiding this comment.
Good catch, removed.
| // Build and start the discovery sub-behaviour | ||
| let mut discovery = Discovery::new(local_keypair.clone(), network_config) | ||
| .await | ||
| .unwrap(); |
There was a problem hiding this comment.
nit, either:
| .unwrap(); | |
| .expect("Discovery should be able to start"); |
or ? to bubble up the error and treat it in the function caller
There was a problem hiding this comment.
we'll need to refactor the function and return a Result instead.
There was a problem hiding this comment.
Could we create an issue and address it in a new PR?
| global = true, | ||
| value_delimiter = ',', | ||
| help = "One or more comma-delimited base64-encoded ENR's to bootstrap the p2p network", | ||
| display_order = 0 |
There was a problem hiding this comment.
We can declare the default boot nodes somewhere (like anchor/network/src/config.rs) with:
const DEFAULT_BOOTNODES: [&'static str; 3] = ["ENR1", "ENR2", "ENR3"];and then import it and use it here:
| display_order = 0 | |
| display_order = 0 | |
| default_values_t = DEFAULT_BOOTNODES.into_iter().map(Into::into) |
There was a problem hiding this comment.
It seems LH defines them in yaml files https://github.com/sigp/lighthouse/blob/stable/common/eth2_network_config/built_in_network_configs/holesky/boot_enr.yaml
There was a problem hiding this comment.
yeah can also be, but then we should get them by default, if you prefer it can be done in a subsequent PR
There was a problem hiding this comment.
Yes, it's probably better in another PR.
| } | ||
|
|
||
| // Start the discv5 service and obtain an event stream | ||
| let event_stream = if !network_config.disable_discovery { |
There was a problem hiding this comment.
will we want to disable discovery? cc @Age @jking-aus
There was a problem hiding this comment.
hmm not sure. It is mainly used in testing, where you can set the bootnodes and only connect to that node. It is kinda handy. Maybe worth keeping
anchor/network/src/discovery.rs
Outdated
| // TODO info!(log, "ENR Initialised"; "enr" => local_enr.to_base64(), "seq" => local_enr.seq(), "id"=> %local_enr.node_id(), | ||
| // "ip4" => ?local_enr.ip4(), "udp4"=> ?local_enr.udp4(), "tcp4" => ?local_enr.tcp4(), "tcp6" => ?local_enr.tcp6(), "udp6" => ?local_enr.udp6(), | ||
| // "quic4" => ?local_enr.quic4(), "quic6" => ?local_enr.quic6() | ||
| // ); |
There was a problem hiding this comment.
We probably need a local_enr, but I don't understand how it works yet.
| // TODO if bootnode_enr.node_id() == local_node_id { | ||
| // // If we are a boot node, ignore adding it to the routing table | ||
| // continue; | ||
| // } |
There was a problem hiding this comment.
is anchor planned to also be run as bootnode? If so this can be uncommented right?
There was a problem hiding this comment.
Waiting for input here as I don't know the answer
There was a problem hiding this comment.
I think so yep -- would be good to be able to provide anchor based bootnodes so not reliant on the go client for entrypoints
| } | ||
| } | ||
|
|
||
| impl NetworkBehaviour for Discovery { |
There was a problem hiding this comment.
this can probably be moved into upstream discv5 feature gated by libp2p (like the enr crate does) as its shared by both lighthouse and anchor wdyt @AgeManning
There was a problem hiding this comment.
oh except the types might be annoying. The NetworkBehaviour and libp2p traits, will come from the upstream libp2p dependency and then this won't work if Anchor sets its own libp2p version.
i.e We will have to always be doing releases for discv5 to keep up to libp2p, which could get annoying
There was a problem hiding this comment.
the NetworkBehaviour traits (which they all depend) are contained in libp2p-swarm which updates roughly once a year, the last update to 0.45 was due to the Transport trait update. There isn't an update like that in sight wrt that I think we are ok
| // Add QUIC fields to the ENR. | ||
| // Since QUIC is used as an alternative transport for the libp2p protocols, | ||
| // the related fields should only be added when both QUIC and libp2p are enabled | ||
| if !config.disable_quic_support { | ||
| // If we are listening on ipv4, add the quic ipv4 port. | ||
| if let Some(quic4_port) = config.enr_quic4_port.or_else(|| { | ||
| config | ||
| .listen_addresses | ||
| .v4() | ||
| .and_then(|v4_addr| v4_addr.quic_port.try_into().ok()) | ||
| }) { | ||
| builder.add_value(QUIC_ENR_KEY, &quic4_port.get()); | ||
| } | ||
|
|
||
| // If we are listening on ipv6, add the quic ipv6 port. | ||
| if let Some(quic6_port) = config.enr_quic6_port.or_else(|| { | ||
| config | ||
| .listen_addresses | ||
| .v6() | ||
| .and_then(|v6_addr| v6_addr.quic_port.try_into().ok()) | ||
| }) { | ||
| builder.add_value(QUIC6_ENR_KEY, &quic6_port.get()); | ||
| } | ||
| } |
There was a problem hiding this comment.
the spec only mentions TCP as a transport, and the go ssv client doesn't seem to support it, do we plan to support it nonetheless?
There was a problem hiding this comment.
We could support QUIC for communication between rust nodes.
There was a problem hiding this comment.
Yeah, lets support it, and hopefully they follow suit
There was a problem hiding this comment.
ok nice! Then we should probably create a PR upstream to manifest that
jking-aus
left a comment
There was a problem hiding this comment.
one small change then let's merge
Co-authored-by: jking-aus <72330194+jking-aus@users.noreply.github.com>
Co-authored-by: jking-aus <72330194+jking-aus@users.noreply.github.com>
Issue Addressed
Add discv5 and partially implement #35.
Proposed Changes
Additional Info