Experimental discovery (#2577)

# Description

A few changes have been made to discovery. In particular a custom re-write of an LRU cache which previously was read/write O(N) for all our sessions ~5k, to a more reasonable hashmap-style O(1). 

Further there has been reported issues in the current discv5, so added error handling to help identify the issue has been added.
This commit is contained in:
Age Manning
2021-09-16 04:45:05 +00:00
parent c5c7476518
commit 56e0615df8
4 changed files with 221 additions and 243 deletions

View File

@@ -2,7 +2,7 @@
use super::BootNodeConfig;
use eth2_libp2p::{
discv5::{enr::NodeId, Discv5, Discv5ConfigBuilder, Discv5Event},
discv5::{enr::NodeId, Discv5, Discv5Event},
EnrExt, Eth2Enr,
};
use slog::info;
@@ -26,24 +26,13 @@ pub async fn run<T: EthSpec>(config: BootNodeConfig<T>, log: slog::Logger) {
info!(log, "Contact information"; "enr" => config.local_enr.to_base64());
info!(log, "Contact information"; "multiaddrs" => format!("{:?}", config.local_enr.multiaddr_p2p()));
// Build the discv5 server
// default configuration with packet filtering
let discv5_config = {
let mut builder = Discv5ConfigBuilder::new();
if !config.disable_packet_filter {
builder.enable_packet_filter();
}
if !config.auto_update {
builder.disable_enr_update();
}
builder.build()
};
// construct the discv5 server
let mut discv5 =
Discv5::new(config.local_enr.clone(), config.local_key, discv5_config).unwrap();
let mut discv5 = Discv5::new(
config.local_enr.clone(),
config.local_key,
config.discv5_config,
)
.unwrap();
// If there are any bootnodes add them to the routing table
for enr in config.boot_nodes {