Skip to content

Commit

Permalink
feat(promotion_monitor): promote incorrect gas limit errors
Browse files Browse the repository at this point in the history
  • Loading branch information
blombern committed Jan 18, 2024
1 parent b4bc9fe commit 405e574
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/phoenix/demotion_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use tracing::{error, info};

use crate::{
env::{ToBeaconExplorerUrl, ToNetwork},
phoenix::{markdown, promotion_monitor::ELIGIBLE_ERRORS},
phoenix::markdown,
};

use super::{
Expand Down Expand Up @@ -66,6 +66,14 @@ pub async fn get_builder_demotions(
.map_err(Into::into)
}

/// Demotion errors that shouldn't be broadcast on telegram
pub const SILENT_ERRORS: &[&str] = &[
"HTTP status server error (500 Internal Server Error) for url (http://prio-load-balancer/)",
"Post \"http://prio-load-balancer:80\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)",
"json error: request timeout hit before processing",
"simulation failed: unknown ancestor",
];

pub async fn run_demotion_monitor(relay_pool: &PgPool, mev_pool: &PgPool) -> Result<()> {
let checkpoint = match checkpoint::get_checkpoint(mev_pool, CheckpointId::Demotion).await? {
Some(c) => c,
Expand All @@ -86,7 +94,7 @@ pub async fn run_demotion_monitor(relay_pool: &PgPool, mev_pool: &PgPool) -> Res
.into_iter()
// reduce alert noise by filtering out duplicate demotions and auto-promotable ones
.unique_by(|d| format!("{}{}{}", d.builder_pubkey, d.slot, d.sim_error))
.filter(|d| !ELIGIBLE_ERRORS.contains(&d.sim_error.as_str()))
.filter(|d| !SILENT_ERRORS.contains(&d.sim_error.as_str()))
.collect_vec();

if !demotions.is_empty() {
Expand Down
13 changes: 11 additions & 2 deletions src/phoenix/promotion_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,22 @@ fn format_builder_list(builders: &Vec<(String, String)>) -> String {
})
}

pub const ELIGIBLE_ERRORS: &[&str] = &[
/// Demotion errors eligible for re-promotion if no slot was missed
const PROMOTABLE_ERRORS: &[&str] = &[
"HTTP status server error (500 Internal Server Error) for url (http://prio-load-balancer/)",
"Post \"http://prio-load-balancer:80\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)",
"json error: request timeout hit before processing",
"simulation failed: unknown ancestor",
"simulation failed: incorrect gas limit set"
];

fn is_promotable_error(error: &str) -> bool {
PROMOTABLE_ERRORS
.iter()
// Use starts_with to account for additional info in gas limit error
.any(|promotable_error| error.starts_with(promotable_error))
}

fn get_eligible_builders(demotions: Vec<BuilderDemotion>, missed_slots: Vec<i64>) -> Vec<String> {
debug!(
"get_eligible_builders: demotions: {:?}, missed_slots {:?}",
Expand All @@ -107,7 +116,7 @@ fn get_eligible_builders(demotions: Vec<BuilderDemotion>, missed_slots: Vec<i64>
let no_missed_slots = demotions.iter().all(|d| !missed_slots.contains(&d.slot));
let only_eligible_errors = demotions
.iter()
.all(|d| ELIGIBLE_ERRORS.contains(&d.sim_error.as_str()));
.all(|d| is_promotable_error(d.sim_error.as_str()));

if no_missed_slots && only_eligible_errors {
Some(builder_id)
Expand Down

0 comments on commit 405e574

Please sign in to comment.