mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
chore(disc): update discv5 and tracing (#408)
* chore(disc): update discv5 and tracing * ignore
This commit is contained in:
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -987,7 +987,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "discv5"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/sigp/discv5#46fb65ce6dfead94bcdd63b7c27c0adfae10e269"
|
||||
source = "git+https://github.com/sigp/discv5#d31e62e3a6973d94be7e9d02f812a43e2c9d9749"
|
||||
dependencies = [
|
||||
"aes 0.7.5",
|
||||
"aes-gcm",
|
||||
@ -3267,12 +3267,12 @@ dependencies = [
|
||||
"reth-primitives",
|
||||
"reth-rlp",
|
||||
"reth-rlp-derive",
|
||||
"reth-tracing",
|
||||
"secp256k1",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"tracing",
|
||||
"tracing-test",
|
||||
"url",
|
||||
]
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@ rand = { version = "0.8", optional = true }
|
||||
[dev-dependencies]
|
||||
rand = "0.8"
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
tracing-test = "0.2"
|
||||
reth-tracing = { path = "../../tracing" }
|
||||
|
||||
[features]
|
||||
mock = ["rand"]
|
||||
@ -50,7 +50,7 @@ use tokio::{
|
||||
time::Interval,
|
||||
};
|
||||
use tokio_stream::{wrappers::ReceiverStream, Stream, StreamExt};
|
||||
use tracing::{debug, instrument, trace, warn};
|
||||
use tracing::{debug, trace, warn};
|
||||
|
||||
pub mod bootnodes;
|
||||
pub mod error;
|
||||
@ -455,9 +455,8 @@ impl Discv4Service {
|
||||
///
|
||||
/// This takes an optional Sender through which all successfully discovered nodes are sent once
|
||||
/// the request has finished.
|
||||
#[instrument(skip_all, fields(?target), target = "net::discv4")]
|
||||
fn lookup_with(&mut self, target: PeerId, tx: Option<NodeRecordSender>) {
|
||||
trace!("Starting lookup");
|
||||
trace!(target : "net::discv4", ?target, "Starting lookup");
|
||||
let key = kad_key(target);
|
||||
|
||||
// Start a lookup context with the 16 (MAX_NODES_PER_BUCKET) closest nodes
|
||||
@ -473,7 +472,7 @@ impl Discv4Service {
|
||||
// From those 16, pick the 3 closest to start the lookup.
|
||||
let closest = ctx.closest(ALPHA);
|
||||
|
||||
trace!(num = closest.len(), "Start lookup closest nodes");
|
||||
trace!(target : "net::discv4", ?target, num = closest.len(), "Start lookup closest nodes");
|
||||
|
||||
for node in closest {
|
||||
self.find_node(&node, ctx.clone());
|
||||
@ -526,7 +525,6 @@ impl Discv4Service {
|
||||
}
|
||||
let key = kad_key(record.id);
|
||||
let entry = NodeEntry { record, last_seen: Instant::now() };
|
||||
|
||||
match self.kbuckets.insert_or_update(
|
||||
&key,
|
||||
entry,
|
||||
@ -536,14 +534,14 @@ impl Discv4Service {
|
||||
},
|
||||
) {
|
||||
InsertResult::Inserted => {
|
||||
trace!( target : "net::disc",?record, "inserted new record to table");
|
||||
debug!(target : "net::disc",?record, "inserted new record to table");
|
||||
self.notify(TableUpdate::Added(record));
|
||||
}
|
||||
InsertResult::ValueUpdated { .. } | InsertResult::Updated { .. } => {
|
||||
trace!(target : "net::disc",?record, "updated record");
|
||||
}
|
||||
res => {
|
||||
debug!(target : "net::disc",?record, ?res, "failed to insert");
|
||||
warn!(target : "net::disc",?record, ?res, "failed to insert");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1292,7 +1290,6 @@ mod tests {
|
||||
bootnodes::mainnet_nodes,
|
||||
mock::{create_discv4, create_discv4_with_config},
|
||||
};
|
||||
use tracing_test::traced_test;
|
||||
|
||||
#[test]
|
||||
fn test_local_rotator() {
|
||||
@ -1314,7 +1311,6 @@ mod tests {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[traced_test]
|
||||
async fn test_pending_ping() {
|
||||
let (_, mut service) = create_discv4().await;
|
||||
|
||||
@ -1329,9 +1325,10 @@ mod tests {
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
#[traced_test]
|
||||
#[ignore]
|
||||
async fn test_lookup() {
|
||||
reth_tracing::init_tracing();
|
||||
|
||||
let all_nodes = mainnet_nodes();
|
||||
let config = Discv4Config::builder().add_boot_nodes(all_nodes).build();
|
||||
let (_discv4, mut service) = create_discv4_with_config(config).await;
|
||||
@ -1356,8 +1353,9 @@ mod tests {
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
#[traced_test]
|
||||
async fn test_service_commands() {
|
||||
reth_tracing::init_tracing();
|
||||
|
||||
let config = Discv4Config::builder().build();
|
||||
let (discv4, mut service) = create_discv4_with_config(config).await;
|
||||
|
||||
|
||||
@ -273,13 +273,13 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::{Discv4Event, PingReason};
|
||||
use std::net::{IpAddr, Ipv4Addr};
|
||||
use tracing_test::traced_test;
|
||||
|
||||
/// This test creates two local UDP sockets. The mocked discovery service responds to specific
|
||||
/// messages and we check the actual service receives answers
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
#[traced_test]
|
||||
async fn can_mock_discovery() {
|
||||
reth_tracing::init_tracing();
|
||||
|
||||
let mut rng = thread_rng();
|
||||
let (_, mut service) = create_discv4().await;
|
||||
let (mut mockv4, mut cmd) = MockDiscovery::new().await.unwrap();
|
||||
|
||||
Reference in New Issue
Block a user