No string in slog (#2017)
## Issue Addressed Following slog's documentation, this should help a bit with string allocations. I left it run for two days and mem usage is lower. This is of course anecdotal, but shouldn't harm anyway ## Proposed Changes remove `String` creation in logs when possible
This commit is contained in:
parent
3f036fd193
commit
8fcd22992c
@ -198,7 +198,7 @@ impl<TSpec: EthSpec> Behaviour<TSpec> {
|
||||
current_slot,
|
||||
)?;
|
||||
|
||||
trace!(behaviour_log, "Using peer score params"; "params" => format!("{:?}", params));
|
||||
trace!(behaviour_log, "Using peer score params"; "params" => ?params);
|
||||
|
||||
let update_gossipsub_scores = tokio::time::interval(params.decay_interval);
|
||||
|
||||
@ -241,9 +241,9 @@ impl<TSpec: EthSpec> Behaviour<TSpec> {
|
||||
debug!(self.log, "Updating gossipsub score parameters";
|
||||
"active_validators" => active_validators);
|
||||
trace!(self.log, "Updated gossipsub score parameters";
|
||||
"beacon_block_params" => format!("{:?}", beacon_block_params),
|
||||
"beacon_aggregate_proof_params" => format!("{:?}", beacon_aggregate_proof_params),
|
||||
"beacon_attestation_subnet_params" => format!("{:?}", beacon_attestation_subnet_params),
|
||||
"beacon_block_params" => ?beacon_block_params,
|
||||
"beacon_aggregate_proof_params" => ?beacon_aggregate_proof_params,
|
||||
"beacon_attestation_subnet_params" => ?beacon_attestation_subnet_params,
|
||||
);
|
||||
|
||||
self.gossipsub
|
||||
@ -341,11 +341,11 @@ impl<TSpec: EthSpec> Behaviour<TSpec> {
|
||||
|
||||
match self.gossipsub.subscribe(&topic) {
|
||||
Err(_) => {
|
||||
warn!(self.log, "Failed to subscribe to topic"; "topic" => topic.to_string());
|
||||
warn!(self.log, "Failed to subscribe to topic"; "topic" => %topic);
|
||||
false
|
||||
}
|
||||
Ok(v) => {
|
||||
debug!(self.log, "Subscribed to topic"; "topic" => topic.to_string());
|
||||
debug!(self.log, "Subscribed to topic"; "topic" => %topic);
|
||||
v
|
||||
}
|
||||
}
|
||||
@ -364,11 +364,11 @@ impl<TSpec: EthSpec> Behaviour<TSpec> {
|
||||
|
||||
match self.gossipsub.unsubscribe(&topic) {
|
||||
Err(_) => {
|
||||
warn!(self.log, "Failed to unsubscribe from topic"; "topic" => topic.to_string());
|
||||
warn!(self.log, "Failed to unsubscribe from topic"; "topic" => %topic);
|
||||
false
|
||||
}
|
||||
Ok(v) => {
|
||||
debug!(self.log, "Unsubscribed to topic"; "topic" => topic.to_string());
|
||||
debug!(self.log, "Unsubscribed to topic"; "topic" => %topic);
|
||||
v
|
||||
}
|
||||
}
|
||||
@ -382,7 +382,7 @@ impl<TSpec: EthSpec> Behaviour<TSpec> {
|
||||
Ok(message_data) => {
|
||||
if let Err(e) = self.gossipsub.publish(topic.clone().into(), message_data) {
|
||||
slog::warn!(self.log, "Could not publish message";
|
||||
"error" => format!("{:?}", e));
|
||||
"error" => ?e);
|
||||
|
||||
// add to metrics
|
||||
match topic.kind() {
|
||||
@ -424,7 +424,7 @@ impl<TSpec: EthSpec> Behaviour<TSpec> {
|
||||
propagation_source,
|
||||
validation_result,
|
||||
) {
|
||||
warn!(self.log, "Failed to report message validation"; "message_id" => message_id.to_string(), "peer_id" => propagation_source.to_string(), "error" => format!("{:?}", e));
|
||||
warn!(self.log, "Failed to report message validation"; "message_id" => %message_id, "peer_id" => %propagation_source, "error" => ?e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -565,7 +565,7 @@ impl<TSpec: EthSpec> Behaviour<TSpec> {
|
||||
let ping = crate::rpc::Ping {
|
||||
data: self.network_globals.local_metadata.read().seq_number,
|
||||
};
|
||||
trace!(self.log, "Sending Ping"; "request_id" => id, "peer_id" => peer_id.to_string());
|
||||
trace!(self.log, "Sending Ping"; "request_id" => id, "peer_id" => %peer_id);
|
||||
|
||||
self.eth2_rpc
|
||||
.send_request(peer_id, id, RPCRequest::Ping(ping));
|
||||
@ -576,7 +576,7 @@ impl<TSpec: EthSpec> Behaviour<TSpec> {
|
||||
let ping = crate::rpc::Ping {
|
||||
data: self.network_globals.local_metadata.read().seq_number,
|
||||
};
|
||||
trace!(self.log, "Sending Pong"; "request_id" => id.1, "peer_id" => peer_id.to_string());
|
||||
trace!(self.log, "Sending Pong"; "request_id" => id.1, "peer_id" => %peer_id);
|
||||
let event = RPCCodedResponse::Success(RPCResponse::Pong(ping));
|
||||
self.eth2_rpc.send_response(peer_id, id, event);
|
||||
}
|
||||
@ -620,7 +620,7 @@ impl<TSpec: EthSpec> Behaviour<TSpec> {
|
||||
&propagation_source,
|
||||
MessageAcceptance::Reject,
|
||||
) {
|
||||
warn!(self.log, "Failed to report message validation"; "message_id" => id.to_string(), "peer_id" => propagation_source.to_string(), "error" => format!("{:?}", e));
|
||||
warn!(self.log, "Failed to report message validation"; "message_id" => %id, "peer_id" => %propagation_source, "error" => ?e);
|
||||
}
|
||||
}
|
||||
Ok(msg) => {
|
||||
@ -669,7 +669,7 @@ impl<TSpec: EthSpec> Behaviour<TSpec> {
|
||||
debug!(
|
||||
self.log,
|
||||
"Ignoring rpc message of disconnected peer";
|
||||
"peer" => peer_id.to_string()
|
||||
"peer" => %peer_id
|
||||
);
|
||||
return;
|
||||
}
|
||||
@ -730,9 +730,9 @@ impl<TSpec: EthSpec> Behaviour<TSpec> {
|
||||
// queue for disconnection without a goodbye message
|
||||
debug!(
|
||||
self.log, "Peer sent Goodbye";
|
||||
"peer_id" => peer_id.to_string(),
|
||||
"reason" => reason.to_string(),
|
||||
"client" => self.network_globals.client(&peer_id).to_string(),
|
||||
"peer_id" => %peer_id,
|
||||
"reason" => %reason,
|
||||
"client" => %self.network_globals.client(&peer_id),
|
||||
);
|
||||
self.peers_to_dc.push_back((peer_id, None));
|
||||
// NOTE: We currently do not inform the application that we are
|
||||
@ -835,7 +835,7 @@ impl<TSpec: EthSpec> Behaviour<TSpec> {
|
||||
}
|
||||
PeerManagerEvent::DisconnectPeer(peer_id, reason) => {
|
||||
debug!(self.log, "PeerManager disconnecting peer";
|
||||
"peer_id" => peer_id.to_string(), "reason" => reason.to_string());
|
||||
"peer_id" => %peer_id, "reason" => %reason);
|
||||
// send one goodbye
|
||||
return Poll::Ready(NBAction::NotifyHandler {
|
||||
peer_id,
|
||||
@ -881,12 +881,12 @@ impl<TSpec: EthSpec> Behaviour<TSpec> {
|
||||
// send peer info to the peer manager.
|
||||
self.peer_manager.identify(&peer_id, &info);
|
||||
|
||||
debug!(self.log, "Identified Peer"; "peer" => format!("{}", peer_id),
|
||||
"protocol_version" => info.protocol_version,
|
||||
"agent_version" => info.agent_version,
|
||||
"listening_ addresses" => format!("{:?}", info.listen_addrs),
|
||||
"observed_address" => format!("{:?}", observed_addr),
|
||||
"protocols" => format!("{:?}", info.protocols)
|
||||
debug!(self.log, "Identified Peer"; "peer" => %peer_id,
|
||||
"protocol_version" => info.protocol_version,
|
||||
"agent_version" => info.agent_version,
|
||||
"listening_ addresses" => ?info.listen_addrs,
|
||||
"observed_address" => ?observed_addr,
|
||||
"protocols" => ?info.protocols
|
||||
);
|
||||
}
|
||||
IdentifyEvent::Sent { .. } => {}
|
||||
@ -985,10 +985,10 @@ impl<TSpec: EthSpec> NetworkBehaviour for Behaviour<TSpec> {
|
||||
if let Some(goodbye_reason) = goodbye_reason {
|
||||
match goodbye_reason {
|
||||
GoodbyeReason::Banned => {
|
||||
debug!(self.log, "Disconnecting newly connected peer"; "peer_id" => peer_id.to_string(), "reason" => goodbye_reason.to_string())
|
||||
debug!(self.log, "Disconnecting newly connected peer"; "peer_id" => %peer_id, "reason" => %goodbye_reason)
|
||||
}
|
||||
_ => {
|
||||
trace!(self.log, "Disconnecting newly connected peer"; "peer_id" => peer_id.to_string(), "reason" => goodbye_reason.to_string())
|
||||
trace!(self.log, "Disconnecting newly connected peer"; "peer_id" => %peer_id, "reason" => %goodbye_reason)
|
||||
}
|
||||
}
|
||||
self.peers_to_dc
|
||||
@ -1005,13 +1005,13 @@ impl<TSpec: EthSpec> NetworkBehaviour for Behaviour<TSpec> {
|
||||
self.peer_manager
|
||||
.connect_ingoing(&peer_id, send_back_addr.clone());
|
||||
self.add_event(BehaviourEvent::PeerConnected(peer_id.clone()));
|
||||
debug!(self.log, "Connection established"; "peer_id" => peer_id.to_string(), "connection" => "Incoming");
|
||||
debug!(self.log, "Connection established"; "peer_id" => %peer_id, "connection" => "Incoming");
|
||||
}
|
||||
ConnectedPoint::Dialer { address } => {
|
||||
self.peer_manager
|
||||
.connect_outgoing(&peer_id, address.clone());
|
||||
self.add_event(BehaviourEvent::PeerDialed(peer_id.clone()));
|
||||
debug!(self.log, "Connection established"; "peer_id" => peer_id.to_string(), "connection" => "Dialed");
|
||||
debug!(self.log, "Connection established"; "peer_id" => %peer_id, "connection" => "Dialed");
|
||||
}
|
||||
}
|
||||
// report the event to the behaviour
|
||||
@ -1310,8 +1310,8 @@ pub fn save_metadata_to_disk<E: EthSpec>(dir: &PathBuf, metadata: MetaData<E>, l
|
||||
warn!(
|
||||
log,
|
||||
"Could not write metadata to disk";
|
||||
"file" => format!("{:?}{:?}",dir, METADATA_FILENAME),
|
||||
"error" => format!("{}", e)
|
||||
"file" => format!("{:?}{:?}", dir, METADATA_FILENAME),
|
||||
"error" => %e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ pub fn use_or_load_enr(
|
||||
// if the same node id, then we may need to update our sequence number
|
||||
if local_enr.node_id() == disk_enr.node_id() {
|
||||
if compare_enr(&local_enr, &disk_enr) {
|
||||
debug!(log, "ENR loaded from disk"; "file" => format!("{:?}", enr_f));
|
||||
debug!(log, "ENR loaded from disk"; "file" => ?enr_f);
|
||||
// the stored ENR has the same configuration, use it
|
||||
*local_enr = disk_enr;
|
||||
return Ok(());
|
||||
@ -87,7 +87,7 @@ pub fn use_or_load_enr(
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
warn!(log, "ENR from file could not be decoded"; "error" => format!("{:?}", e));
|
||||
warn!(log, "ENR from file could not be decoded"; "error" => ?e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -188,7 +188,7 @@ pub fn save_enr_to_disk(dir: &Path, enr: &Enr, log: &slog::Logger) {
|
||||
Err(e) => {
|
||||
warn!(
|
||||
log,
|
||||
"Could not write ENR to file"; "file" => format!("{:?}{:?}",dir, ENR_FILENAME), "error" => format!("{}", e)
|
||||
"Could not write ENR to file"; "file" => format!("{:?}{:?}",dir, ENR_FILENAME), "error" => %e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
|
||||
|
||||
let local_enr = network_globals.local_enr.read().clone();
|
||||
|
||||
info!(log, "ENR Initialised"; "enr" => local_enr.to_base64(), "seq" => local_enr.seq(), "id"=> format!("{}",local_enr.node_id()), "ip" => format!("{:?}", local_enr.ip()), "udp"=> format!("{:?}", local_enr.udp()), "tcp" => format!("{:?}", local_enr.tcp()));
|
||||
info!(log, "ENR Initialised"; "enr" => local_enr.to_base64(), "seq" => local_enr.seq(), "id"=> %local_enr.node_id(), "ip" => ?local_enr.ip(), "udp"=> ?local_enr.udp(), "tcp" => ?local_enr.tcp());
|
||||
|
||||
let listen_socket = SocketAddr::new(config.listen_address, config.discovery_port);
|
||||
|
||||
@ -193,11 +193,11 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
|
||||
debug!(
|
||||
log,
|
||||
"Adding node to routing table";
|
||||
"node_id" => bootnode_enr.node_id().to_string(),
|
||||
"peer_id" => bootnode_enr.peer_id().to_string(),
|
||||
"ip" => format!("{:?}", bootnode_enr.ip()),
|
||||
"udp" => format!("{:?}", bootnode_enr.udp()),
|
||||
"tcp" => format!("{:?}", bootnode_enr.tcp())
|
||||
"node_id" => %bootnode_enr.node_id(),
|
||||
"peer_id" => %bootnode_enr.peer_id(),
|
||||
"ip" => ?bootnode_enr.ip(),
|
||||
"udp" => ?bootnode_enr.udp(),
|
||||
"tcp" => ?bootnode_enr.tcp()
|
||||
);
|
||||
let repr = bootnode_enr.to_string();
|
||||
let _ = discv5.add_enr(bootnode_enr).map_err(|e| {
|
||||
@ -247,11 +247,11 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
|
||||
debug!(
|
||||
log,
|
||||
"Adding node to routing table";
|
||||
"node_id" => enr.node_id().to_string(),
|
||||
"peer_id" => enr.peer_id().to_string(),
|
||||
"ip" => format!("{:?}", enr.ip()),
|
||||
"udp" => format!("{:?}", enr.udp()),
|
||||
"tcp" => format!("{:?}", enr.tcp())
|
||||
"node_id" => %enr.node_id(),
|
||||
"peer_id" => %enr.peer_id(),
|
||||
"ip" => ?enr.ip(),
|
||||
"udp" => ?enr.udp(),
|
||||
"tcp" => ?enr.tcp()
|
||||
);
|
||||
let _ = discv5.add_enr(enr).map_err(|e| {
|
||||
error!(
|
||||
@ -318,7 +318,7 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
|
||||
debug!(
|
||||
self.log,
|
||||
"Making discovery query for subnets";
|
||||
"subnets" => format!("{:?}", subnets_to_discover.iter().map(|s| s.subnet_id).collect::<Vec<_>>())
|
||||
"subnets" => ?subnets_to_discover.iter().map(|s| s.subnet_id).collect::<Vec<_>>()
|
||||
);
|
||||
for subnet in subnets_to_discover {
|
||||
self.add_subnet_query(subnet.subnet_id, subnet.min_ttl, 0);
|
||||
@ -334,7 +334,7 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
|
||||
debug!(
|
||||
self.log,
|
||||
"Could not add peer to the local routing table";
|
||||
"error" => e.to_string()
|
||||
"error" => %e
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -461,8 +461,8 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
|
||||
};
|
||||
|
||||
info!(self.log, "Updating the ENR fork version";
|
||||
"fork_digest" => format!("{:?}", enr_fork_id.fork_digest),
|
||||
"next_fork_version" => format!("{:?}", enr_fork_id.next_fork_version),
|
||||
"fork_digest" => ?enr_fork_id.fork_digest,
|
||||
"next_fork_version" => ?enr_fork_id.next_fork_version,
|
||||
"next_fork_epoch" => next_fork_epoch_log,
|
||||
);
|
||||
|
||||
@ -473,7 +473,7 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
|
||||
warn!(
|
||||
self.log,
|
||||
"Could not update eth2 ENR field";
|
||||
"error" => format!("{:?}", e)
|
||||
"error" => ?e
|
||||
)
|
||||
});
|
||||
|
||||
@ -607,7 +607,7 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
|
||||
debug!(
|
||||
self.log,
|
||||
"Starting grouped subnet query";
|
||||
"subnets" => format!("{:?}", grouped_queries.iter().map(|q| q.subnet_id).collect::<Vec<_>>()),
|
||||
"subnets" => ?grouped_queries.iter().map(|q| q.subnet_id).collect::<Vec<_>>(),
|
||||
);
|
||||
self.start_subnet_query(grouped_queries);
|
||||
processed = true;
|
||||
@ -659,7 +659,7 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
|
||||
"target_subnet_peers" => TARGET_SUBNET_PEERS,
|
||||
"peers_to_find" => target_peers,
|
||||
"attempt" => subnet_query.retries,
|
||||
"min_ttl" => format!("{:?}", subnet_query.min_ttl),
|
||||
"min_ttl" => ?subnet_query.min_ttl,
|
||||
);
|
||||
|
||||
filtered_subnet_ids.push(subnet_query.subnet_id);
|
||||
@ -757,7 +757,7 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
|
||||
return Some(results);
|
||||
}
|
||||
Err(e) => {
|
||||
warn!(self.log, "Discovery query failed"; "error" => e.to_string());
|
||||
warn!(self.log, "Discovery query failed"; "error" => %e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -766,10 +766,10 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
|
||||
queries.iter().map(|query| query.subnet_id).collect();
|
||||
match query_result.1 {
|
||||
Ok(r) if r.is_empty() => {
|
||||
debug!(self.log, "Grouped subnet discovery query yielded no results."; "subnets_searched_for" => format!("{:?}",subnets_searched_for));
|
||||
debug!(self.log, "Grouped subnet discovery query yielded no results."; "subnets_searched_for" => ?subnets_searched_for);
|
||||
}
|
||||
Ok(r) => {
|
||||
debug!(self.log, "Peer grouped subnet discovery request completed"; "peers_found" => r.len(), "subnets_searched_for" => format!("{:?}",subnets_searched_for));
|
||||
debug!(self.log, "Peer grouped subnet discovery request completed"; "peers_found" => r.len(), "subnets_searched_for" => ?subnets_searched_for);
|
||||
|
||||
let mut mapped_results = HashMap::new();
|
||||
|
||||
@ -836,7 +836,7 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
warn!(self.log,"Grouped subnet discovery query failed"; "subnets_searched_for" => format!("{:?}",subnets_searched_for), "error" => e.to_string());
|
||||
warn!(self.log,"Grouped subnet discovery query failed"; "subnets_searched_for" => ?subnets_searched_for, "error" => %e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -881,7 +881,7 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
|
||||
self.event_stream = EventStream::Present(stream);
|
||||
}
|
||||
Err(e) => {
|
||||
slog::crit!(self.log, "Discv5 event stream failed"; "error" => e.to_string());
|
||||
slog::crit!(self.log, "Discv5 event stream failed"; "error" => %e);
|
||||
self.event_stream = EventStream::InActive;
|
||||
}
|
||||
}
|
||||
@ -907,7 +907,7 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
|
||||
*/
|
||||
}
|
||||
Discv5Event::SocketUpdated(socket) => {
|
||||
info!(self.log, "Address updated"; "ip" => format!("{}",socket.ip()), "udp_port" => format!("{}", socket.port()));
|
||||
info!(self.log, "Address updated"; "ip" => %socket.ip(), "udp_port" => %socket.port());
|
||||
metrics::inc_counter(&metrics::ADDRESS_UPDATE_COUNT);
|
||||
// Discv5 will have updated our local ENR. We save the updated version
|
||||
// to disk.
|
||||
|
@ -34,15 +34,15 @@ where
|
||||
trace!(
|
||||
log_clone,
|
||||
"Peer found but not on any of the desired subnets";
|
||||
"peer_id" => format!("{}", enr.peer_id())
|
||||
"peer_id" => %enr.peer_id()
|
||||
);
|
||||
return false;
|
||||
} else {
|
||||
trace!(
|
||||
log_clone,
|
||||
"Peer found on desired subnet(s)";
|
||||
"peer_id" => format!("{}", enr.peer_id()),
|
||||
"subnets" => format!("{:?}", matches.as_slice())
|
||||
"peer_id" => %enr.peer_id(),
|
||||
"subnets" => ?matches.as_slice()
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
||||
&self.log,
|
||||
);
|
||||
if previous_state == info.score_state() {
|
||||
debug!(self.log, "Peer score adjusted"; "peer_id" => peer_id.to_string(), "score" => info.score().to_string());
|
||||
debug!(self.log, "Peer score adjusted"; "peer_id" => %peer_id, "score" => %info.score());
|
||||
}
|
||||
}
|
||||
} // end write lock
|
||||
@ -241,7 +241,7 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
||||
trace!(
|
||||
self.log,
|
||||
"Discovery query ignored";
|
||||
"subnet_id" => format!("{:?}",s.subnet_id),
|
||||
"subnet_id" => ?s.subnet_id,
|
||||
"reason" => "Already connected to desired peers",
|
||||
"connected_peers_on_subnet" => peers_on_subnet,
|
||||
"target_subnet_peers" => TARGET_SUBNET_PEERS,
|
||||
@ -441,7 +441,7 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
||||
if let Some(peer_info) = self.network_globals.peers.read().peer_info(peer_id) {
|
||||
// received a ping
|
||||
// reset the to-ping timer for this peer
|
||||
debug!(self.log, "Received a ping request"; "peer_id" => peer_id.to_string(), "seq_no" => seq);
|
||||
debug!(self.log, "Received a ping request"; "peer_id" => %peer_id, "seq_no" => seq);
|
||||
match peer_info.connection_direction {
|
||||
Some(ConnectionDirection::Incoming) => {
|
||||
self.inbound_ping_peers.insert(peer_id.clone());
|
||||
@ -458,20 +458,20 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
||||
if let Some(meta_data) = &peer_info.meta_data {
|
||||
if meta_data.seq_number < seq {
|
||||
debug!(self.log, "Requesting new metadata from peer";
|
||||
"peer_id" => peer_id.to_string(), "known_seq_no" => meta_data.seq_number, "ping_seq_no" => seq);
|
||||
"peer_id" => %peer_id, "known_seq_no" => meta_data.seq_number, "ping_seq_no" => seq);
|
||||
self.events
|
||||
.push(PeerManagerEvent::MetaData(peer_id.clone()));
|
||||
}
|
||||
} else {
|
||||
// if we don't know the meta-data, request it
|
||||
debug!(self.log, "Requesting first metadata from peer";
|
||||
"peer_id" => peer_id.to_string());
|
||||
"peer_id" => %peer_id);
|
||||
self.events
|
||||
.push(PeerManagerEvent::MetaData(peer_id.clone()));
|
||||
}
|
||||
} else {
|
||||
crit!(self.log, "Received a PING from an unknown peer";
|
||||
"peer_id" => peer_id.to_string());
|
||||
"peer_id" => %peer_id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -484,19 +484,19 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
||||
if let Some(meta_data) = &peer_info.meta_data {
|
||||
if meta_data.seq_number < seq {
|
||||
debug!(self.log, "Requesting new metadata from peer";
|
||||
"peer_id" => peer_id.to_string(), "known_seq_no" => meta_data.seq_number, "pong_seq_no" => seq);
|
||||
"peer_id" => %peer_id, "known_seq_no" => meta_data.seq_number, "pong_seq_no" => seq);
|
||||
self.events
|
||||
.push(PeerManagerEvent::MetaData(peer_id.clone()));
|
||||
}
|
||||
} else {
|
||||
// if we don't know the meta-data, request it
|
||||
debug!(self.log, "Requesting first metadata from peer";
|
||||
"peer_id" => peer_id.to_string());
|
||||
"peer_id" => %peer_id);
|
||||
self.events
|
||||
.push(PeerManagerEvent::MetaData(peer_id.clone()));
|
||||
}
|
||||
} else {
|
||||
crit!(self.log, "Received a PONG from an unknown peer"; "peer_id" => peer_id.to_string());
|
||||
crit!(self.log, "Received a PONG from an unknown peer"; "peer_id" => %peer_id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -506,21 +506,21 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
||||
if let Some(known_meta_data) = &peer_info.meta_data {
|
||||
if known_meta_data.seq_number < meta_data.seq_number {
|
||||
debug!(self.log, "Updating peer's metadata";
|
||||
"peer_id" => peer_id.to_string(), "known_seq_no" => known_meta_data.seq_number, "new_seq_no" => meta_data.seq_number);
|
||||
"peer_id" => %peer_id, "known_seq_no" => known_meta_data.seq_number, "new_seq_no" => meta_data.seq_number);
|
||||
peer_info.meta_data = Some(meta_data);
|
||||
} else {
|
||||
debug!(self.log, "Received old metadata";
|
||||
"peer_id" => peer_id.to_string(), "known_seq_no" => known_meta_data.seq_number, "new_seq_no" => meta_data.seq_number);
|
||||
"peer_id" => %peer_id, "known_seq_no" => known_meta_data.seq_number, "new_seq_no" => meta_data.seq_number);
|
||||
}
|
||||
} else {
|
||||
// we have no meta-data for this peer, update
|
||||
debug!(self.log, "Obtained peer's metadata";
|
||||
"peer_id" => peer_id.to_string(), "new_seq_no" => meta_data.seq_number);
|
||||
"peer_id" => %peer_id, "new_seq_no" => meta_data.seq_number);
|
||||
peer_info.meta_data = Some(meta_data);
|
||||
}
|
||||
} else {
|
||||
crit!(self.log, "Received METADATA from an unknown peer";
|
||||
"peer_id" => peer_id.to_string());
|
||||
"peer_id" => %peer_id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -672,7 +672,7 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
||||
}
|
||||
}
|
||||
for peer_id in to_dial_peers {
|
||||
debug!(self.log, "Dialing discovered peer"; "peer_id"=> peer_id.to_string());
|
||||
debug!(self.log, "Dialing discovered peer"; "peer_id" => %peer_id);
|
||||
self.dial_peer(&peer_id);
|
||||
}
|
||||
}
|
||||
@ -688,7 +688,7 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
||||
let mut peerdb = self.network_globals.peers.write();
|
||||
if peerdb.is_banned(&peer_id) {
|
||||
// don't connect if the peer is banned
|
||||
slog::crit!(self.log, "Connection has been allowed to a banned peer"; "peer_id" => peer_id.to_string());
|
||||
slog::crit!(self.log, "Connection has been allowed to a banned peer"; "peer_id" => %peer_id);
|
||||
}
|
||||
|
||||
let enr = self.discovery.enr_of_peer(peer_id);
|
||||
@ -751,11 +751,11 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
||||
if previous_state != info.score_state() {
|
||||
match info.score_state() {
|
||||
ScoreState::Banned => {
|
||||
debug!(log, "Peer has been banned"; "peer_id" => peer_id.to_string(), "score" => info.score().to_string());
|
||||
debug!(log, "Peer has been banned"; "peer_id" => %peer_id, "score" => %info.score());
|
||||
to_ban_peers.push(peer_id.clone());
|
||||
}
|
||||
ScoreState::Disconnected => {
|
||||
debug!(log, "Peer transitioned to disconnect state"; "peer_id" => peer_id.to_string(), "score" => info.score().to_string(), "past_state" => previous_state.to_string());
|
||||
debug!(log, "Peer transitioned to disconnect state"; "peer_id" => %peer_id, "score" => %info.score(), "past_state" => %previous_state);
|
||||
// disconnect the peer if it's currently connected or dialing
|
||||
if info.is_connected_or_dialing() {
|
||||
// Change the state to inform that we are disconnecting the peer.
|
||||
@ -769,7 +769,7 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
||||
}
|
||||
}
|
||||
ScoreState::Healthy => {
|
||||
debug!(log, "Peer transitioned to healthy state"; "peer_id" => peer_id.to_string(), "score" => info.score().to_string(), "past_state" => previous_state.to_string());
|
||||
debug!(log, "Peer transitioned to healthy state"; "peer_id" => %peer_id, "score" => %info.score(), "past_state" => %previous_state);
|
||||
// unban the peer if it was previously banned.
|
||||
if info.is_banned() {
|
||||
to_unban_peers.push(peer_id.clone());
|
||||
|
@ -347,7 +347,7 @@ impl<TSpec: EthSpec> PeerDB<TSpec> {
|
||||
.checked_duration_since(Instant::now())
|
||||
.map(|duration| duration.as_secs())
|
||||
.unwrap_or_else(|| 0);
|
||||
debug!(self.log, "Updating the time a peer is required for"; "peer_id" => peer_id.to_string(), "future_min_ttl_secs" => min_ttl_secs);
|
||||
debug!(self.log, "Updating the time a peer is required for"; "peer_id" => %peer_id, "future_min_ttl_secs" => min_ttl_secs);
|
||||
}
|
||||
}
|
||||
|
||||
@ -457,7 +457,7 @@ impl<TSpec: EthSpec> PeerDB<TSpec> {
|
||||
let log_ref = &self.log;
|
||||
let info = self.peers.entry(peer_id.clone()).or_insert_with(|| {
|
||||
warn!(log_ref, "Banning unknown peer";
|
||||
"peer_id" => peer_id.to_string());
|
||||
"peer_id" => %peer_id);
|
||||
PeerInfo::default()
|
||||
});
|
||||
|
||||
@ -514,7 +514,7 @@ impl<TSpec: EthSpec> PeerDB<TSpec> {
|
||||
let log_ref = &self.log;
|
||||
let info = self.peers.entry(peer_id.clone()).or_insert_with(|| {
|
||||
warn!(log_ref, "UnBanning unknown peer";
|
||||
"peer_id" => peer_id.to_string());
|
||||
"peer_id" => %peer_id);
|
||||
PeerInfo::default()
|
||||
});
|
||||
|
||||
@ -563,7 +563,7 @@ impl<TSpec: EthSpec> PeerDB<TSpec> {
|
||||
self.banned_peers_count = BannedPeersCount::new();
|
||||
None
|
||||
} {
|
||||
debug!(self.log, "Removing old banned peer"; "peer_id" => to_drop.to_string());
|
||||
debug!(self.log, "Removing old banned peer"; "peer_id" => %to_drop);
|
||||
self.peers.remove(&to_drop);
|
||||
}
|
||||
}
|
||||
@ -581,7 +581,7 @@ impl<TSpec: EthSpec> PeerDB<TSpec> {
|
||||
.min_by_key(|(_, since)| *since)
|
||||
.map(|(id, _)| id.clone())
|
||||
{
|
||||
debug!(self.log, "Removing old disconnected peer"; "peer_id" => to_drop.to_string());
|
||||
debug!(self.log, "Removing old disconnected peer"; "peer_id" => %to_drop);
|
||||
self.peers.remove(&to_drop);
|
||||
}
|
||||
// If there is no minimum, this is a coding error. For safety we decrease
|
||||
@ -595,7 +595,7 @@ impl<TSpec: EthSpec> PeerDB<TSpec> {
|
||||
if let Some(peer_info) = self.peers.get_mut(peer_id) {
|
||||
peer_info.meta_data = Some(meta_data);
|
||||
} else {
|
||||
warn!(self.log, "Tried to add meta data for a non-existant peer"; "peer_id" => peer_id.to_string());
|
||||
warn!(self.log, "Tried to add meta data for a non-existent peer"; "peer_id" => %peer_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -307,7 +307,7 @@ where
|
||||
if matches!(self.state, HandlerState::Deactivated) {
|
||||
// we no longer send responses after the handler is deactivated
|
||||
debug!(self.log, "Response not sent. Deactivated handler";
|
||||
"response" => response.to_string(), "id" => inbound_id);
|
||||
"response" => %response, "id" => inbound_id);
|
||||
return;
|
||||
}
|
||||
inbound_info.pending_items.push(response);
|
||||
@ -419,7 +419,7 @@ where
|
||||
)
|
||||
.is_some()
|
||||
{
|
||||
crit!(self.log, "Duplicate outbound substream id"; "id" => format!("{:?}", self.current_outbound_substream_id));
|
||||
crit!(self.log, "Duplicate outbound substream id"; "id" => self.current_outbound_substream_id);
|
||||
}
|
||||
self.current_outbound_substream_id.0 += 1;
|
||||
}
|
||||
@ -563,7 +563,7 @@ where
|
||||
}
|
||||
}
|
||||
Poll::Ready(Some(Err(e))) => {
|
||||
warn!(self.log, "Inbound substream poll failed"; "error" => format!("{:?}", e));
|
||||
warn!(self.log, "Inbound substream poll failed"; "error" => ?e);
|
||||
// drops the peer if we cannot read the delay queue
|
||||
return Poll::Ready(ProtocolsHandlerEvent::Close(RPCError::InternalError(
|
||||
"Could not poll inbound stream timer",
|
||||
@ -592,7 +592,7 @@ where
|
||||
}
|
||||
}
|
||||
Poll::Ready(Some(Err(e))) => {
|
||||
warn!(self.log, "Outbound substream poll failed"; "error" => format!("{:?}", e));
|
||||
warn!(self.log, "Outbound substream poll failed"; "error" => ?e);
|
||||
return Poll::Ready(ProtocolsHandlerEvent::Close(RPCError::InternalError(
|
||||
"Could not poll outbound stream timer",
|
||||
)));
|
||||
|
@ -399,11 +399,11 @@ impl slog::KV for StatusMessage {
|
||||
serializer: &mut dyn slog::Serializer,
|
||||
) -> slog::Result {
|
||||
use slog::Value;
|
||||
serializer.emit_str("fork_digest", &format!("{:?}", self.fork_digest))?;
|
||||
serializer.emit_arguments("fork_digest", &format_args!("{:?}", self.fork_digest))?;
|
||||
Value::serialize(&self.finalized_epoch, record, "finalized_epoch", serializer)?;
|
||||
serializer.emit_str("finalized_root", &self.finalized_root.to_string())?;
|
||||
serializer.emit_arguments("finalized_root", &format_args!("{}", self.finalized_root))?;
|
||||
Value::serialize(&self.head_slot, record, "head_slot", serializer)?;
|
||||
serializer.emit_str("head_root", &self.head_root.to_string())?;
|
||||
serializer.emit_arguments("head_root", &format_args!("{}", self.head_root))?;
|
||||
slog::Result::Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ where
|
||||
// Use connection established/closed instead of these currently
|
||||
fn inject_connected(&mut self, peer_id: &PeerId) {
|
||||
// find the peer's meta-data
|
||||
debug!(self.log, "Requesting new peer's metadata"; "peer_id" => format!("{}",peer_id));
|
||||
debug!(self.log, "Requesting new peer's metadata"; "peer_id" => %peer_id);
|
||||
let rpc_event = RPCSend::Request(RequestId::Behaviour, RPCRequest::MetaData(PhantomData));
|
||||
self.events.push(NetworkBehaviourAction::NotifyHandler {
|
||||
peer_id: peer_id.clone(),
|
||||
@ -253,7 +253,7 @@ where
|
||||
}
|
||||
Err(RateLimitedErr::TooSoon(wait_time)) => {
|
||||
debug!(self.log, "Request exceeds the rate limit";
|
||||
"request" => req.to_string(), "peer_id" => peer_id.to_string(), "wait_time_ms" => wait_time.as_millis());
|
||||
"request" => %req, "peer_id" => %peer_id, "wait_time_ms" => wait_time.as_millis());
|
||||
// send an error code to the peer.
|
||||
// the handler upon receiving the error code will send it back to the behaviour
|
||||
self.send_response(
|
||||
|
@ -93,13 +93,13 @@ impl<TSpec: EthSpec> Service<TSpec> {
|
||||
&log,
|
||||
));
|
||||
|
||||
info!(log, "Libp2p Service"; "peer_id" => enr.peer_id().to_string());
|
||||
info!(log, "Libp2p Service"; "peer_id" => %enr.peer_id());
|
||||
let discovery_string = if config.disable_discovery {
|
||||
"None".into()
|
||||
} else {
|
||||
config.discovery_port.to_string()
|
||||
};
|
||||
debug!(log, "Attempting to open listening ports"; "address" => format!("{}", config.listen_address), "tcp_port" => config.libp2p_port, "udp_port" => discovery_string);
|
||||
debug!(log, "Attempting to open listening ports"; "address" => ?config.listen_address, "tcp_port" => config.libp2p_port, "udp_port" => discovery_string);
|
||||
|
||||
let (mut swarm, bandwidth) = {
|
||||
// Set up the transport - tcp/ws with noise and mplex
|
||||
@ -147,14 +147,14 @@ impl<TSpec: EthSpec> Service<TSpec> {
|
||||
Ok(_) => {
|
||||
let mut log_address = listen_multiaddr;
|
||||
log_address.push(Protocol::P2p(local_peer_id.clone().into()));
|
||||
info!(log, "Listening established"; "address" => format!("{}", log_address));
|
||||
info!(log, "Listening established"; "address" => %log_address);
|
||||
}
|
||||
Err(err) => {
|
||||
crit!(
|
||||
log,
|
||||
"Unable to listen on libp2p address";
|
||||
"error" => format!("{:?}", err),
|
||||
"listen_multiaddr" => format!("{}", listen_multiaddr),
|
||||
"error" => ?err,
|
||||
"listen_multiaddr" => %listen_multiaddr,
|
||||
);
|
||||
return Err("Libp2p was unable to listen on the given listen address.".into());
|
||||
}
|
||||
@ -165,10 +165,10 @@ impl<TSpec: EthSpec> Service<TSpec> {
|
||||
// strip the p2p protocol if it exists
|
||||
strip_peer_id(&mut multiaddr);
|
||||
match Swarm::dial_addr(&mut swarm, multiaddr.clone()) {
|
||||
Ok(()) => debug!(log, "Dialing libp2p peer"; "address" => format!("{}", multiaddr)),
|
||||
Ok(()) => debug!(log, "Dialing libp2p peer"; "address" => %multiaddr),
|
||||
Err(err) => debug!(
|
||||
log,
|
||||
"Could not connect to peer"; "address" => format!("{}", multiaddr), "error" => format!("{:?}", err)
|
||||
"Could not connect to peer"; "address" => %multiaddr, "error" => ?err
|
||||
),
|
||||
};
|
||||
};
|
||||
@ -216,12 +216,12 @@ impl<TSpec: EthSpec> Service<TSpec> {
|
||||
if swarm.subscribe_kind(topic_kind.clone()) {
|
||||
subscribed_topics.push(topic_kind.clone());
|
||||
} else {
|
||||
warn!(log, "Could not subscribe to topic"; "topic" => format!("{}",topic_kind));
|
||||
warn!(log, "Could not subscribe to topic"; "topic" => %topic_kind);
|
||||
}
|
||||
}
|
||||
|
||||
if !subscribed_topics.is_empty() {
|
||||
info!(log, "Subscribed to topics"; "topics" => format!("{:?}", subscribed_topics));
|
||||
info!(log, "Subscribed to topics"; "topics" => ?subscribed_topics);
|
||||
}
|
||||
|
||||
let service = Service {
|
||||
@ -279,7 +279,7 @@ impl<TSpec: EthSpec> Service<TSpec> {
|
||||
endpoint: _,
|
||||
num_established,
|
||||
} => {
|
||||
trace!(self.log, "Connection closed"; "peer_id"=> peer_id.to_string(), "cause" => format!("{:?}", cause), "connections" => num_established);
|
||||
trace!(self.log, "Connection closed"; "peer_id" => %peer_id, "cause" => ?cause, "connections" => num_established);
|
||||
}
|
||||
SwarmEvent::NewListenAddr(multiaddr) => {
|
||||
return Libp2pEvent::NewListenAddr(multiaddr)
|
||||
@ -288,14 +288,14 @@ impl<TSpec: EthSpec> Service<TSpec> {
|
||||
local_addr,
|
||||
send_back_addr,
|
||||
} => {
|
||||
trace!(self.log, "Incoming connection"; "our_addr" => local_addr.to_string(), "from" => send_back_addr.to_string())
|
||||
trace!(self.log, "Incoming connection"; "our_addr" => %local_addr, "from" => %send_back_addr)
|
||||
}
|
||||
SwarmEvent::IncomingConnectionError {
|
||||
local_addr,
|
||||
send_back_addr,
|
||||
error,
|
||||
} => {
|
||||
debug!(self.log, "Failed incoming connection"; "our_addr" => local_addr.to_string(), "from" => send_back_addr.to_string(), "error" => error.to_string())
|
||||
debug!(self.log, "Failed incoming connection"; "our_addr" => %local_addr, "from" => %send_back_addr, "error" => %error)
|
||||
}
|
||||
SwarmEvent::BannedPeer { .. } => {
|
||||
// We do not ban peers at the swarm layer, so this should never occur.
|
||||
@ -306,29 +306,29 @@ impl<TSpec: EthSpec> Service<TSpec> {
|
||||
error,
|
||||
attempts_remaining,
|
||||
} => {
|
||||
debug!(self.log, "Failed to dial address"; "peer_id" => peer_id.to_string(), "address" => address.to_string(), "error" => error.to_string(), "attempts_remaining" => attempts_remaining);
|
||||
debug!(self.log, "Failed to dial address"; "peer_id" => %peer_id, "address" => %address, "error" => %error, "attempts_remaining" => attempts_remaining);
|
||||
}
|
||||
SwarmEvent::UnknownPeerUnreachableAddr { address, error } => {
|
||||
debug!(self.log, "Peer not known at dialed address"; "address" => address.to_string(), "error" => error.to_string());
|
||||
debug!(self.log, "Peer not known at dialed address"; "address" => %address, "error" => %error);
|
||||
}
|
||||
SwarmEvent::ExpiredListenAddr(multiaddr) => {
|
||||
debug!(self.log, "Listen address expired"; "multiaddr" => multiaddr.to_string())
|
||||
debug!(self.log, "Listen address expired"; "multiaddr" => %multiaddr)
|
||||
}
|
||||
SwarmEvent::ListenerClosed { addresses, reason } => {
|
||||
crit!(self.log, "Listener closed"; "addresses" => format!("{:?}", addresses), "reason" => format!("{:?}", reason));
|
||||
crit!(self.log, "Listener closed"; "addresses" => ?addresses, "reason" => ?reason);
|
||||
if Swarm::listeners(&self.swarm).count() == 0 {
|
||||
return Libp2pEvent::ZeroListeners;
|
||||
}
|
||||
}
|
||||
SwarmEvent::ListenerError { error } => {
|
||||
// this is non fatal, but we still check
|
||||
warn!(self.log, "Listener error"; "error" => format!("{:?}", error.to_string()));
|
||||
warn!(self.log, "Listener error"; "error" => ?error);
|
||||
if Swarm::listeners(&self.swarm).count() == 0 {
|
||||
return Libp2pEvent::ZeroListeners;
|
||||
}
|
||||
}
|
||||
SwarmEvent::Dialing(peer_id) => {
|
||||
debug!(self.log, "Dialing peer"; "peer_id" => peer_id.to_string());
|
||||
debug!(self.log, "Dialing peer"; "peer_id" => %peer_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -492,7 +492,7 @@ fn load_or_build_metadata<E: EthSpec>(
|
||||
debug!(
|
||||
log,
|
||||
"Metadata from file could not be decoded";
|
||||
"error" => format!("{:?}", e),
|
||||
"error" => ?e,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ impl<T: BeaconChainTypes> AttestationService<T> {
|
||||
// This will subscribe to long-lived random subnets if required.
|
||||
trace!(self.log,
|
||||
"Validator subscription";
|
||||
"subscription" => format!("{:?}", subscription),
|
||||
"subscription" => ?subscription,
|
||||
);
|
||||
self.add_known_validator(subscription.validator_index);
|
||||
|
||||
@ -220,7 +220,7 @@ impl<T: BeaconChainTypes> AttestationService<T> {
|
||||
Err(e) => {
|
||||
warn!(self.log,
|
||||
"Failed to compute subnet id for validator subscription";
|
||||
"error" => format!("{:?}", e),
|
||||
"error" => ?e,
|
||||
"validator_index" => subscription.validator_index
|
||||
);
|
||||
continue;
|
||||
@ -257,7 +257,7 @@ impl<T: BeaconChainTypes> AttestationService<T> {
|
||||
} else {
|
||||
trace!(self.log,
|
||||
"Subscribed to subnet for aggregator duties";
|
||||
"exact_subnet" => format!("{:?}", exact_subnet),
|
||||
"exact_subnet" => ?exact_subnet,
|
||||
"validator_index" => subscription.validator_index
|
||||
);
|
||||
}
|
||||
@ -339,7 +339,7 @@ impl<T: BeaconChainTypes> AttestationService<T> {
|
||||
// peer before they can be removed.
|
||||
warn!(self.log,
|
||||
"Not enough time for a discovery search";
|
||||
"subnet_id" => format!("{:?}", exact_subnet)
|
||||
"subnet_id" => ?exact_subnet
|
||||
);
|
||||
None
|
||||
}
|
||||
|
@ -961,7 +961,7 @@ impl Drop for SendOnDrop {
|
||||
self.log,
|
||||
"Unable to free worker";
|
||||
"msg" => "did not free worker, shutdown may be underway",
|
||||
"error" => e.to_string()
|
||||
"error" => %e
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
self.log,
|
||||
"New block received";
|
||||
"slot" => verified_block.block.slot(),
|
||||
"hash" => verified_block.block_root.to_string()
|
||||
"hash" => %verified_block.block_root
|
||||
);
|
||||
self.propagate_validation_result(
|
||||
message_id,
|
||||
@ -232,7 +232,7 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
| Err(e @ BlockError::NotFinalizedDescendant { .. })
|
||||
| Err(e @ BlockError::BeaconChainError(_)) => {
|
||||
debug!(self.log, "Could not verify block for gossip, ignoring the block";
|
||||
"error" => e.to_string());
|
||||
"error" => %e);
|
||||
// Prevent recurring behaviour by penalizing the peer slightly.
|
||||
self.penalize_peer(peer_id.clone(), PeerAction::HighToleranceError);
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Ignore);
|
||||
@ -252,7 +252,7 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
| Err(e @ BlockError::WeakSubjectivityConflict)
|
||||
| Err(e @ BlockError::GenesisBlock) => {
|
||||
warn!(self.log, "Could not verify block for gossip, rejecting the block";
|
||||
"error" => e.to_string());
|
||||
"error" => %e);
|
||||
self.propagate_validation_result(
|
||||
message_id,
|
||||
peer_id.clone(),
|
||||
@ -307,15 +307,15 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
debug!(
|
||||
self.log,
|
||||
"Invalid gossip beacon block";
|
||||
"outcome" => format!("{:?}", other),
|
||||
"block root" => format!("{}", block.canonical_root()),
|
||||
"outcome" => ?other,
|
||||
"block root" => %block.canonical_root(),
|
||||
"block slot" => block.slot()
|
||||
);
|
||||
self.penalize_peer(peer_id, PeerAction::MidToleranceError);
|
||||
trace!(
|
||||
self.log,
|
||||
"Invalid gossip beacon block ssz";
|
||||
"ssz" => format!("0x{}", hex::encode(block.as_ssz_bytes())),
|
||||
"ssz" => format_args!("0x{}", hex::encode(block.as_ssz_bytes())),
|
||||
);
|
||||
}
|
||||
};
|
||||
@ -787,8 +787,8 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
debug!(
|
||||
self.log,
|
||||
"Received attestation on incorrect subnet";
|
||||
"expected" => format!("{:?}", expected),
|
||||
"received" => format!("{:?}", received),
|
||||
"expected" => ?expected,
|
||||
"received" => ?received,
|
||||
);
|
||||
self.propagate_validation_result(
|
||||
message_id,
|
||||
|
@ -225,14 +225,14 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
self.processor.on_block_gossip(id, peer_id, block);
|
||||
}
|
||||
PubsubMessage::VoluntaryExit(exit) => {
|
||||
debug!(self.log, "Received a voluntary exit"; "peer_id" => format!("{}", peer_id));
|
||||
debug!(self.log, "Received a voluntary exit"; "peer_id" => %peer_id);
|
||||
self.processor.on_voluntary_exit_gossip(id, peer_id, exit);
|
||||
}
|
||||
PubsubMessage::ProposerSlashing(proposer_slashing) => {
|
||||
debug!(
|
||||
self.log,
|
||||
"Received a proposer slashing";
|
||||
"peer_id" => format!("{}", peer_id)
|
||||
"peer_id" => %peer_id
|
||||
);
|
||||
self.processor
|
||||
.on_proposer_slashing_gossip(id, peer_id, proposer_slashing);
|
||||
@ -241,7 +241,7 @@ impl<T: BeaconChainTypes> Router<T> {
|
||||
debug!(
|
||||
self.log,
|
||||
"Received a attester slashing";
|
||||
"peer_id" => format!("{}", peer_id)
|
||||
"peer_id" => %peer_id
|
||||
);
|
||||
self.processor
|
||||
.on_attester_slashing_gossip(id, peer_id, attester_slashing);
|
||||
|
@ -179,7 +179,7 @@ impl<T: BeaconChainTypes> Processor<T> {
|
||||
trace!(
|
||||
self.log,
|
||||
"Received BlocksByRange Response";
|
||||
"peer" => peer_id.to_string(),
|
||||
"peer" => %peer_id,
|
||||
);
|
||||
|
||||
if let RequestId::Sync(id) = request_id {
|
||||
@ -206,7 +206,7 @@ impl<T: BeaconChainTypes> Processor<T> {
|
||||
trace!(
|
||||
self.log,
|
||||
"Received BlocksByRoot Response";
|
||||
"peer" => peer_id.to_string(),
|
||||
"peer" => %peer_id,
|
||||
);
|
||||
|
||||
if let RequestId::Sync(id) = request_id {
|
||||
@ -356,10 +356,9 @@ impl<T: EthSpec> HandlerNetworkContext<T> {
|
||||
|
||||
/// Sends a message to the network task.
|
||||
fn inform_network(&mut self, msg: NetworkMessage<T>) {
|
||||
let msg_r = &format!("{:?}", msg);
|
||||
self.network_send
|
||||
.send(msg)
|
||||
.unwrap_or_else(|e| warn!(self.log, "Could not send message to the network service"; "error" => %e, "message" => msg_r))
|
||||
self.network_send.send(msg).unwrap_or_else(
|
||||
|e| warn!(self.log, "Could not send message to the network service"; "error" => %e),
|
||||
)
|
||||
}
|
||||
|
||||
/// Disconnects and ban's a peer, sending a Goodbye request with the associated reason.
|
||||
|
@ -241,13 +241,13 @@ fn spawn_service<T: BeaconChainTypes>(
|
||||
debug!(
|
||||
service.log,
|
||||
"Persisting DHT to store";
|
||||
"Number of peers" => format!("{}", enrs.len()),
|
||||
"Number of peers" => enrs.len(),
|
||||
);
|
||||
match persist_dht::<T::EthSpec, T::HotStore, T::ColdStore>(service.store.clone(), enrs) {
|
||||
Err(e) => error!(
|
||||
service.log,
|
||||
"Failed to persist DHT on drop";
|
||||
"error" => format!("{:?}", e)
|
||||
"error" => ?e
|
||||
),
|
||||
Ok(_) => info!(
|
||||
service.log,
|
||||
@ -354,9 +354,9 @@ fn spawn_service<T: BeaconChainTypes>(
|
||||
validation_result,
|
||||
} => {
|
||||
trace!(service.log, "Propagating gossipsub message";
|
||||
"propagation_peer" => format!("{:?}", propagation_source),
|
||||
"message_id" => message_id.to_string(),
|
||||
"validation_result" => format!("{:?}", validation_result)
|
||||
"propagation_peer" => ?propagation_source,
|
||||
"message_id" => %message_id,
|
||||
"validation_result" => ?validation_result
|
||||
);
|
||||
service
|
||||
.libp2p
|
||||
@ -376,7 +376,7 @@ fn spawn_service<T: BeaconChainTypes>(
|
||||
service.log,
|
||||
"Sending pubsub messages";
|
||||
"count" => messages.len(),
|
||||
"topics" => format!("{:?}", topic_kinds)
|
||||
"topics" => ?topic_kinds
|
||||
);
|
||||
metrics::expose_publish_metrics(&messages);
|
||||
service.libp2p.swarm.publish(messages);
|
||||
@ -398,7 +398,7 @@ fn spawn_service<T: BeaconChainTypes>(
|
||||
if service.libp2p.swarm.subscribe_kind(topic_kind.clone()) {
|
||||
subscribed_topics.push(topic_kind.clone());
|
||||
} else {
|
||||
warn!(service.log, "Could not subscribe to topic"; "topic" => format!("{}",topic_kind));
|
||||
warn!(service.log, "Could not subscribe to topic"; "topic" => %topic_kind);
|
||||
}
|
||||
}
|
||||
|
||||
@ -412,13 +412,13 @@ fn spawn_service<T: BeaconChainTypes>(
|
||||
service.libp2p.swarm.update_enr_subnet(subnet_id, true);
|
||||
subscribed_topics.push(topic_kind.clone());
|
||||
} else {
|
||||
warn!(service.log, "Could not subscribe to topic"; "topic" => format!("{}",topic_kind));
|
||||
warn!(service.log, "Could not subscribe to topic"; "topic" => %topic_kind);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !subscribed_topics.is_empty() {
|
||||
info!(service.log, "Subscribed to topics"; "topics" => format!("{:?}", subscribed_topics));
|
||||
info!(service.log, "Subscribed to topics"; "topics" => ?subscribed_topics);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -545,7 +545,7 @@ fn spawn_service<T: BeaconChainTypes>(
|
||||
}
|
||||
Libp2pEvent::ZeroListeners => {
|
||||
let _ = shutdown_sender.send("All listeners are closed. Unable to listen").await.map_err(|e| {
|
||||
warn!(service.log, "failed to send a shutdown signal"; "error" => e.to_string()
|
||||
warn!(service.log, "failed to send a shutdown signal"; "error" => %e
|
||||
)
|
||||
});
|
||||
}
|
||||
|
@ -611,7 +611,7 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
||||
|
||||
if let Some(peer_info) = self.network_globals.peers.write().peer_info_mut(peer_id) {
|
||||
let new_state = sync_type.as_sync_status(remote_sync_info);
|
||||
let rpr = new_state.to_string();
|
||||
let rpr = new_state.as_str();
|
||||
let was_updated = peer_info.sync_status.update(new_state);
|
||||
if was_updated {
|
||||
debug!(self.log, "Peer transitioned sync state"; "peer_id" => %peer_id, "new_state" => rpr,
|
||||
|
@ -125,7 +125,7 @@ impl<T: EthSpec> SyncNetworkContext<T> {
|
||||
"Sending BlocksByRoot Request";
|
||||
"method" => "BlocksByRoot",
|
||||
"count" => request.block_roots.len(),
|
||||
"peer" => format!("{:?}", peer_id)
|
||||
"peer" => %peer_id
|
||||
);
|
||||
self.send_rpc_request(peer_id, Request::BlocksByRoot(request))
|
||||
}
|
||||
@ -139,11 +139,11 @@ impl<T: EthSpec> SyncNetworkContext<T> {
|
||||
}
|
||||
|
||||
pub fn report_peer(&mut self, peer_id: PeerId, action: PeerAction) {
|
||||
debug!(self.log, "Sync reporting peer"; "peer_id" => peer_id.to_string(), "action" => action.to_string());
|
||||
debug!(self.log, "Sync reporting peer"; "peer_id" => %peer_id, "action" => %action);
|
||||
self.network_send
|
||||
.send(NetworkMessage::ReportPeer { peer_id, action })
|
||||
.unwrap_or_else(|e| {
|
||||
warn!(self.log, "Could not report peer, channel failed"; "error"=> e.to_string());
|
||||
warn!(self.log, "Could not report peer, channel failed"; "error"=> %e);
|
||||
});
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ impl<T: EthSpec> SyncNetworkContext<T> {
|
||||
self.network_send
|
||||
.send(NetworkMessage::SubscribeCoreTopics)
|
||||
.unwrap_or_else(|e| {
|
||||
warn!(self.log, "Could not subscribe to core topics."; "error" => e.to_string());
|
||||
warn!(self.log, "Could not subscribe to core topics."; "error" => %e);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -391,7 +391,7 @@ impl<T: EthSpec> slog::KV for BatchInfo<T> {
|
||||
)?;
|
||||
serializer.emit_usize("downloaded", self.failed_download_attempts.len())?;
|
||||
serializer.emit_usize("processed", self.failed_processing_attempts.len())?;
|
||||
serializer.emit_str("state", &format!("{:?}", self.state))?;
|
||||
serializer.emit_arguments("state", &format_args!("{:?}", self.state))?;
|
||||
slog::Result::Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -513,7 +513,7 @@ impl<T: BeaconChainTypes> SyncingChain<T> {
|
||||
// This should be unlikely, so we tolerate these errors, but not often.
|
||||
let action = PeerAction::LowToleranceError;
|
||||
warn!(self.log, "Batch failed to download. Dropping chain scoring peers";
|
||||
"score_adjustment" => action.to_string(),
|
||||
"score_adjustment" => %action,
|
||||
"batch_epoch"=> batch_id);
|
||||
for (peer, _) in self.peers.drain() {
|
||||
network.report_peer(peer, action);
|
||||
@ -1028,7 +1028,7 @@ impl<T: BeaconChainTypes> slog::KV for SyncingChain<T> {
|
||||
"to",
|
||||
serializer,
|
||||
)?;
|
||||
serializer.emit_str("end_root", &self.target_head_root.to_string())?;
|
||||
serializer.emit_arguments("end_root", &format_args!("{}", self.target_head_root))?;
|
||||
Value::serialize(
|
||||
&self.processing_target,
|
||||
record,
|
||||
|
@ -215,13 +215,15 @@ impl<T: BeaconChainTypes> ChainCollection<T> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn state(&self) -> Result<Option<(RangeSyncType, Slot /* from */, Slot /* to */)>, String> {
|
||||
pub fn state(
|
||||
&self,
|
||||
) -> Result<Option<(RangeSyncType, Slot /* from */, Slot /* to */)>, &'static str> {
|
||||
match self.state {
|
||||
RangeSyncState::Finalized(ref syncing_id) => {
|
||||
let chain = self
|
||||
.finalized_chains
|
||||
.get(syncing_id)
|
||||
.ok_or(format!("Finalized syncing chain not found: {}", syncing_id))?;
|
||||
.ok_or("Finalized syncing chain not found")?;
|
||||
Ok(Some((
|
||||
RangeSyncType::Finalized,
|
||||
chain.start_epoch.start_slot(T::EthSpec::slots_per_epoch()),
|
||||
@ -234,7 +236,7 @@ impl<T: BeaconChainTypes> ChainCollection<T> {
|
||||
let chain = self
|
||||
.head_chains
|
||||
.get(id)
|
||||
.ok_or(format!("Head syncing chain not found: {}", id))?;
|
||||
.ok_or("Head syncing chain not found")?;
|
||||
let start = chain.start_epoch.start_slot(T::EthSpec::slots_per_epoch());
|
||||
let target = chain.target_head_slot;
|
||||
|
||||
@ -242,8 +244,7 @@ impl<T: BeaconChainTypes> ChainCollection<T> {
|
||||
.map(|(min_start, max_slot)| (min_start.min(start), max_slot.max(target)))
|
||||
.or(Some((start, target)));
|
||||
}
|
||||
let (start_slot, target_slot) =
|
||||
range.ok_or_else(|| "Syncing head with empty head ids".to_string())?;
|
||||
let (start_slot, target_slot) = range.ok_or("Syncing head with empty head ids")?;
|
||||
Ok(Some((RangeSyncType::Head, start_slot, target_slot)))
|
||||
}
|
||||
RangeSyncState::Idle => Ok(None),
|
||||
|
@ -88,7 +88,9 @@ impl<T: BeaconChainTypes> RangeSync<T> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn state(&self) -> Result<Option<(RangeSyncType, Slot /* from */, Slot /* to */)>, String> {
|
||||
pub fn state(
|
||||
&self,
|
||||
) -> Result<Option<(RangeSyncType, Slot /* from */, Slot /* to */)>, &'static str> {
|
||||
self.chains.state()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user