Skip to content

Commit a638435

Browse files
bomanapsArtiomTr
authored andcommitted
Fix devnet0 fork and connected peers metric
1 parent 666f364 commit a638435

5 files changed

Lines changed: 47 additions & 14 deletions

File tree

lean_client/fork_choice/src/handlers.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ fn validate_attestation_data(store: &Store, data: &AttestationData) -> Result<()
9494

9595
/// Returns the first block root (source, target, or head) referenced by `attestation_data`
9696
/// that is not yet present in the store, or `None` if all are known.
97-
fn find_unknown_attestation_block(store: &Store, attestation_data: &AttestationData) -> Option<H256> {
97+
fn find_unknown_attestation_block(
98+
store: &Store,
99+
attestation_data: &AttestationData,
100+
) -> Option<H256> {
98101
[
99102
attestation_data.source.root,
100103
attestation_data.target.root,

lean_client/networking/src/network/service.rs

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,11 @@ where
414414
}
415415

416416
METRICS.get().map(|metrics| {
417-
metrics.register_peer_connection_success(endpoint.is_listener())
417+
metrics.register_peer_connection_success(endpoint.is_listener());
418+
metrics
419+
.lean_connected_peers
420+
.with_label_values(&["unknown"])
421+
.set(connected as i64);
418422
});
419423

420424
None
@@ -452,7 +456,11 @@ where
452456
Some(ConnectionError::KeepAliveTimeout) => DisconnectReason::Timeout,
453457
};
454458

455-
metrics.register_peer_disconnect(endpoint.is_listener(), reason)
459+
metrics.register_peer_disconnect(endpoint.is_listener(), reason);
460+
metrics
461+
.lean_connected_peers
462+
.with_label_values(&["unknown"])
463+
.set(connected as i64);
456464
});
457465

458466
Some(NetworkEvent::PeerDisconnected(peer_id))
@@ -644,7 +652,14 @@ where
644652
} => {
645653
use crate::req_resp::{LeanRequest, LeanResponse};
646654

647-
let (response, peer_finalized_slot, peer_head_root, peer_head_slot, our_finalized_slot, our_head_slot) = match request {
655+
let (
656+
response,
657+
peer_finalized_slot,
658+
peer_head_root,
659+
peer_head_slot,
660+
our_finalized_slot,
661+
our_head_slot,
662+
) = match request {
648663
LeanRequest::Status(peer_status) => {
649664
let status = self.status_provider.read().clone();
650665
let our_finalized = status.finalized.slot.0;
@@ -653,7 +668,14 @@ where
653668
let pf = peer_status.finalized.slot.0;
654669
let ph = peer_status.head.root;
655670
let phs = peer_status.head.slot.0;
656-
(LeanResponse::Status(status), pf, ph, phs, our_finalized, our_head)
671+
(
672+
LeanResponse::Status(status),
673+
pf,
674+
ph,
675+
phs,
676+
our_finalized,
677+
our_head,
678+
)
657679
}
658680
_ => {
659681
warn!(peer = %peer, "Unexpected request type on Status protocol");
@@ -1063,8 +1085,7 @@ where
10631085
let our_finalized = self.status_provider.read().finalized.slot.0;
10641086
info!(
10651087
num_peers = peers.len(),
1066-
our_finalized,
1067-
"Periodic sync check: sending status to all connected peers"
1088+
our_finalized, "Periodic sync check: sending status to all connected peers"
10681089
);
10691090
for peer_id in peers {
10701091
self.send_status_request(peer_id);

lean_client/networking/src/req_resp.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,10 @@ impl LeanCodec {
320320
if declared_len as usize > MAX_PAYLOAD_SIZE {
321321
return Err(io::Error::new(
322322
io::ErrorKind::InvalidData,
323-
format!("Declared length too large: {} > {}", declared_len, MAX_PAYLOAD_SIZE),
323+
format!(
324+
"Declared length too large: {} > {}",
325+
declared_len, MAX_PAYLOAD_SIZE
326+
),
324327
));
325328
}
326329

@@ -336,7 +339,11 @@ impl LeanCodec {
336339
if ssz_bytes.len() != declared_len as usize {
337340
return Err(io::Error::new(
338341
io::ErrorKind::InvalidData,
339-
format!("Length mismatch: declared {}, got {}", declared_len, ssz_bytes.len()),
342+
format!(
343+
"Length mismatch: declared {}, got {}",
344+
declared_len,
345+
ssz_bytes.len()
346+
),
340347
));
341348
}
342349

@@ -377,7 +384,10 @@ impl LeanCodec {
377384
offset += consumed;
378385

379386
if code != RESPONSE_SUCCESS {
380-
warn!(response_code = code, "BlocksByRoot non-success response chunk");
387+
warn!(
388+
response_code = code,
389+
"BlocksByRoot non-success response chunk"
390+
);
381391
continue;
382392
}
383393
if ssz_bytes.is_empty() {

lean_client/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ async fn main() -> Result<()> {
576576
});
577577
}
578578

579-
let fork = "devnet3".to_string();
579+
let fork = "devnet0".to_string();
580580
// Subscribe to topics based on validator role:
581581
// - Aggregators: all attestation subnets
582582
// - Non-aggregator validators: only their own subnet

lean_client/validator/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use std::path::Path;
55
use anyhow::{Context, Result, anyhow, bail};
66
use containers::{
77
AggregatedSignatureProof, AggregationBits, Attestation, AttestationData, AttestationSignatures,
8-
Block, BlockSignatures, BlockWithAttestation,
9-
SignedAggregatedAttestation, SignedAttestation, SignedBlockWithAttestation, Slot,
8+
Block, BlockSignatures, BlockWithAttestation, SignedAggregatedAttestation, SignedAttestation,
9+
SignedBlockWithAttestation, Slot,
1010
};
1111
use fork_choice::store::Store;
1212
use metrics::{METRICS, stop_and_discard, stop_and_record};
@@ -407,5 +407,4 @@ impl ValidatorService {
407407
})
408408
.collect()
409409
}
410-
411410
}

0 commit comments

Comments
 (0)