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: add bootnode support and basic discv5 support #38

Merged
merged 2 commits into from
Feb 10, 2025

Conversation

KolbyML
Copy link
Contributor

@KolbyML KolbyML commented Jan 13, 2025

fixes #91

  • Add support for initialing libp2p with bootnodes
  • handle finding peers using discv5 and dialing them once found.

Followup PR's

In my next PR I am going to be implementing basic Req/Resp for the Req/Resp domain of the consensus p2p-interface spec https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/p2p-interface.md#the-reqresp-domain

There is still work to do like finding subnets, and setting a key-value in the enr to specify the node is an eth2 node

@KolbyML KolbyML force-pushed the connect-to-eth2 branch 3 times, most recently from fb19cc9 to 6cd7bac Compare February 10, 2025 02:14
@KolbyML KolbyML marked this pull request as ready for review February 10, 2025 02:22
@KolbyML KolbyML self-assigned this Feb 10, 2025
@KolbyML KolbyML changed the title feat: make discv5 peer discovery work feat: add bootnode support and basic discv5 support Feb 10, 2025
Copy link
Contributor

@hopinheimer hopinheimer left a comment

Choose a reason for hiding this comment

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

small nit, but I got peer responses from teku and nimbus, let's get this in we'll work on keeping the connection alive

@@ -64,16 +74,18 @@ impl Discovery {
}

let _ = discv5.add_enr(bootnode_enr).map_err(|e| {
println!("Discv5 service failed. Error: {:?}", e);
info!("Discv5 service failed. Error: {:?}", e);
Copy link
Contributor

Choose a reason for hiding this comment

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

error here

Copy link
Contributor

@jihoonsong jihoonsong left a comment

Choose a reason for hiding this comment

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

Just some nits. It looks work as expected within its scope. Once we have bootstrapping network done, we probably want to refactor it.

@@ -64,16 +74,18 @@ impl Discovery {
}

let _ = discv5.add_enr(bootnode_enr).map_err(|e| {
println!("Discv5 service failed. Error: {:?}", e);
info!("Discv5 service failed. Error: {:?}", e);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
info!("Discv5 service failed. Error: {:?}", e);
info!("Failed to add bootnode to DHT {e:?}");

Same here.

let enr_local = convert_to_enr(local_key)?;
let enr = Enr::builder().build(&enr_local).unwrap();
let node_local_id = enr.node_id();

let mut discv5 = Discv5::new(enr, enr_local, config.discv5_config.clone())
.map_err(|e| format!("Discv5 service failed. Error: {:?}", e))?;
.map_err(|e| anyhow!("Discv5 service failed. Error: {:?}", e))?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
.map_err(|e| anyhow!("Discv5 service failed. Error: {:?}", e))?;
.map_err(|e| anyhow!("Failed to create discv5 {e:?}"))?;

Can we have consistent and more descriptive error message something like this?


#[derive(NetworkBehaviour)]
pub(crate) struct ReamBehaviour {
pub identify: identify::Behaviour,

/// The discovery domain: discv5
pub discovery: Discovery,

pub connection_registry: libp2p::connection_limits::Behaviour,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pub connection_registry: libp2p::connection_limits::Behaviour,
pub connection_registry: connection_limits::Behaviour,

@KolbyML
Copy link
Contributor Author

KolbyML commented Feb 10, 2025

Once we have bootstrapping network done, we probably want to refactor it.

what do you mean refactor it?

@KolbyML KolbyML added this pull request to the merge queue Feb 10, 2025
Merged via the queue into ReamLabs:master with commit 8a65d26 Feb 10, 2025
5 checks passed
@jihoonsong
Copy link
Contributor

I see some room for improvements. Could be just trimming or refactor depending on rest of the implementation.

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.

Add bootnode support and basic discv5 support
3 participants