Skip to content

Commit

Permalink
feat(inclusion_monitor): remove quotes, reorder
Browse files Browse the repository at this point in the history
  • Loading branch information
alextes committed Feb 8, 2024
1 parent d7b9ff9 commit 88aa82d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 27 deletions.
49 changes: 24 additions & 25 deletions src/phoenix/inclusion_monitor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,15 @@ async fn report_missing_payload(
delivered block not found
beaconcha\\.in: [slot/{slot}]({explorer_url}/slot/{slot})
slot: `{slot}`
payload\\_block\\_hash: `{payload_block_hash}`
on\\_chain\\_block\\_hash: `{on_chain_block_hash}`
slot: {slot}
payload\\_block\\_hash: {payload_block_hash}
on\\_chain\\_block\\_hash: {on_chain_block_hash}
"
);

let is_adjustment_hash = check_is_adjustment_hash(relay_pool, &payload.block_hash).await?;
message.push_str(&format!("is\\_missed\\_adjustment: {}", is_adjustment_hash));

// Check if a publish was attempted, if yes, add publish stats.
match loki_client.published_stats(payload.slot).await? {
Some(payload_stats) => {
Expand All @@ -173,12 +176,11 @@ async fn report_missing_payload(
} = payload_stats;
let published_stats_message = formatdoc!(
"
publish was attempted
decoded\\_at\\_slot\\_age\\_ms: `{decoded_at_slot_age_ms}`
pre\\_publish\\_duration\\_ms: `{pre_publish_duration_ms}`
publish\\_duration\\_ms: `{publish_duration_ms}`
request\\_download\\_duration\\_ms: `{request_download_duration_ms}`
publish was attempted, publish stats
decoded\\_at\\_slot\\_age\\_ms: {decoded_at_slot_age_ms}
pre\\_publish\\_duration\\_ms: {pre_publish_duration_ms}
publish\\_duration\\_ms: {publish_duration_ms}
request\\_download\\_duration\\_ms: {request_download_duration_ms}
",
);
message.push_str("\n\n");
Expand Down Expand Up @@ -228,22 +230,17 @@ async fn report_missing_payload(
let proposer_meta_message = formatdoc!(
"
proposer meta
proposer\\_city: `{proposer_city}`
proposer\\_country: `{proposer_country}`
proposer\\_grafitti: `{grafitti}`
proposer\\_ip: `{proposer_ip}`
proposer\\_label: `{operator}`
proposer\\_lido\\_operator: `{lido_operator}`
proposer\\_city: {proposer_city}
proposer\\_country: {proposer_country}
proposer\\_grafitti: {grafitti}
proposer\\_ip: {proposer_ip}
proposer\\_label: {operator}
proposer\\_lido\\_operator: {lido_operator}
",
);
message.push_str("\n\n");
message.push_str(&proposer_meta_message);

let is_adjustment_hash = check_is_adjustment_hash(relay_pool, &payload.block_hash).await?;
message.push_str("\n\n");
message.push_str(&format!("is_missed_adjustment: `{}`", is_adjustment_hash));

let publish_errors = loki_client.error_messages(slot).await?;
if !publish_errors.is_empty() {
message.push_str("\n\n");
Expand All @@ -262,6 +259,9 @@ async fn report_missing_payload(
};
message.push_str(&error_message);
}
} else {
message.push_str("\n\n");
message.push_str("no publish errors found");
}

let late_call_stats = loki_client.late_call_stats(slot).await?;
Expand All @@ -272,18 +272,17 @@ async fn report_missing_payload(
} = late_call_stats;
let late_call_message = formatdoc!(
"
found late call warnings
decoded\\_at\\_slot\\_age\\_ms: `{decoded_at_slot_age_ms}`
request\\_download\\_duration\\_ms: `{request_download_duration_ms}`
found late call warnings, first warning stats
decoded\\_at\\_slot\\_age\\_ms: {decoded_at_slot_age_ms}
request\\_download\\_duration\\_ms: {request_download_duration_ms}
"
);
message.push_str("\n\n");
message.push_str(&late_call_message);
}

if publish_errors.is_empty() && late_call_stats.is_some() {
send_telegram_warning(&message, "MarkdownV2").await?;
send_telegram_warning(&message).await?;
} else {
send_telegram_alert(&message).await?;
}
Expand Down
4 changes: 2 additions & 2 deletions src/phoenix/telegram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn escape_code_block(input: &str) -> String {

/// Sends a message to the Telegram warnings channel.
/// Make sure the message is escaped.
pub async fn send_telegram_warning(message: &str, parse_mode: &str) -> anyhow::Result<()> {
pub async fn send_telegram_warning(message: &str) -> anyhow::Result<()> {
let url = format!(
"https://api.telegram.org/bot{}/sendMessage",
&APP_CONFIG.telegram_api_key
Expand All @@ -49,7 +49,7 @@ pub async fn send_telegram_warning(message: &str, parse_mode: &str) -> anyhow::R
.query(&[
("chat_id", APP_CONFIG.telegram_warnings_channel_id.as_str()),
("text", message),
("parse_mode", parse_mode),
("parse_mode", "MarkdownV2"),
("disable_web_page_preview", "true"),
])
.send()
Expand Down

0 comments on commit 88aa82d

Please sign in to comment.