Add flag to disable warning logs for duplicate gossip messages (#5009)

* Add flag to disable warning logs for duplicate gossip messages.

* Update Lighthouse book.
This commit is contained in:
Jimmy Chen
2023-12-15 09:26:51 +11:00
committed by GitHub
parent ae4a296089
commit 366f0d7ac2
7 changed files with 64 additions and 1 deletions

View File

@@ -158,6 +158,10 @@ pub struct Config {
/// Configuration for the inbound rate limiter (requests received by this node).
pub inbound_rate_limiter_config: Option<InboundRateLimiterConfig>,
/// Whether to disable logging duplicate gossip messages as WARN. If set to true, duplicate
/// errors will be logged at DEBUG level.
pub disable_duplicate_warn_logs: bool,
}
impl Config {
@@ -375,6 +379,7 @@ impl Default for Config {
outbound_rate_limiter_config: None,
invalid_block_storage: None,
inbound_rate_limiter_config: None,
disable_duplicate_warn_logs: false,
}
}
}

View File

@@ -128,6 +128,8 @@ pub struct Network<AppReqId: ReqId, TSpec: EthSpec> {
gossip_cache: GossipCache,
/// This node's PeerId.
pub local_peer_id: PeerId,
/// Flag to disable warning logs for duplicate gossip messages and log at DEBUG level instead.
pub disable_duplicate_warn_logs: bool,
/// Logger for behaviour actions.
log: slog::Logger,
}
@@ -425,6 +427,7 @@ impl<AppReqId: ReqId, TSpec: EthSpec> Network<AppReqId, TSpec> {
update_gossipsub_scores,
gossip_cache,
local_peer_id,
disable_duplicate_warn_logs: config.disable_duplicate_warn_logs,
log,
};
@@ -743,7 +746,21 @@ impl<AppReqId: ReqId, TSpec: EthSpec> Network<AppReqId, TSpec> {
.gossipsub_mut()
.publish(Topic::from(topic.clone()), message_data.clone())
{
slog::warn!(self.log, "Could not publish message"; "error" => ?e);
if self.disable_duplicate_warn_logs && matches!(e, PublishError::Duplicate) {
debug!(
self.log,
"Could not publish message";
"error" => ?e,
"kind" => %topic.kind(),
);
} else {
warn!(
self.log,
"Could not publish message";
"error" => ?e,
"kind" => %topic.kind(),
);
};
// add to metrics
match topic.kind() {