Skip to content

Commit 6043b0c

Browse files
committed
Improve error logging
1 parent c505174 commit 6043b0c

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

beacon_node/http_api/src/publish_attestations.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use beacon_processor::work_reprocessing_queue::{QueuedUnaggregate, ReprocessQueu
4343
use eth2::types::Failure;
4444
use lighthouse_network::PubsubMessage;
4545
use network::NetworkMessage;
46-
use slog::{debug, error, Logger};
46+
use slog::{debug, error, warn, Logger};
4747
use std::sync::Arc;
4848
use std::time::Duration;
4949
use tokio::sync::{
@@ -75,6 +75,7 @@ fn verify_and_publish_attestation<T: BeaconChainTypes>(
7575
attestation: &Attestation<T::EthSpec>,
7676
seen_timestamp: Duration,
7777
network_tx: &UnboundedSender<NetworkMessage<T::EthSpec>>,
78+
log: &Logger,
7879
) -> Result<(), Error> {
7980
let attestation = chain
8081
.verify_unaggregated_attestation_for_gossip(attestation, None)
@@ -103,6 +104,21 @@ fn verify_and_publish_attestation<T: BeaconChainTypes>(
103104
let fc_result = chain.apply_attestation_to_fork_choice(&attestation);
104105
let naive_aggregation_result = chain.add_to_naive_aggregation_pool(&attestation);
105106

107+
if let Err(e) = &fc_result {
108+
warn!(
109+
log,
110+
"Attestation invalid for fork choice";
111+
"err" => ?e,
112+
);
113+
}
114+
if let Err(e) = &naive_aggregation_result {
115+
warn!(
116+
log,
117+
"Attestation invalid for aggregation";
118+
"err" => ?e
119+
);
120+
}
121+
106122
if let Err(e) = fc_result {
107123
Err(Error::ForkChoice(e))
108124
} else if let Err(e) = naive_aggregation_result {
@@ -129,6 +145,7 @@ pub async fn publish_attestations<T: BeaconChainTypes>(
129145

130146
// Gossip validate and publish attestations that can be immediately processed.
131147
let seen_timestamp = timestamp_now();
148+
let inner_log = log.clone();
132149
let mut prelim_results = task_spawner
133150
.blocking_task(Priority::P0, move || {
134151
Ok(attestations
@@ -139,6 +156,7 @@ pub async fn publish_attestations<T: BeaconChainTypes>(
139156
&attestation,
140157
seen_timestamp,
141158
&network_tx,
159+
&inner_log,
142160
) {
143161
Ok(()) => PublishAttestationResult::Success,
144162
Err(Error::Validation(AttestationError::UnknownHeadBlock {
@@ -151,12 +169,14 @@ pub async fn publish_attestations<T: BeaconChainTypes>(
151169
let (tx, rx) = oneshot::channel();
152170
let reprocess_chain = chain.clone();
153171
let reprocess_network_tx = network_tx.clone();
172+
let reprocess_log = inner_log.clone();
154173
let reprocess_fn = move || {
155174
let result = verify_and_publish_attestation(
156175
&reprocess_chain,
157176
&attestation,
158177
seen_timestamp,
159178
&reprocess_network_tx,
179+
&reprocess_log,
160180
);
161181
// Ignore failure on the oneshot that reports the result. This
162182
// shouldn't happen unless some catastrophe befalls the waiting
@@ -208,6 +228,12 @@ pub async fn publish_attestations<T: BeaconChainTypes>(
208228
// This part should be quick so we just stay in the Tokio executor's async task.
209229
for (i, reprocess_result) in reprocess_indices.into_iter().zip(reprocess_results) {
210230
let Some(result_entry) = prelim_results.get_mut(i) else {
231+
error!(
232+
log,
233+
"Unreachable case in attestation publishing";
234+
"case" => "prelim out of bounds",
235+
"request_index" => i,
236+
);
211237
continue;
212238
};
213239
*result_entry = Some(match reprocess_result {

0 commit comments

Comments
 (0)