Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ban solvers based on the settlements success rate #3263

Open
wants to merge 8 commits into
base: notify-banned-solvers
Choose a base branch
from

Conversation

squadgazzz
Copy link
Contributor

@squadgazzz squadgazzz commented Jan 31, 2025

Description

Another follow-up to #3257, which implements a suggested statistic-based approach #3257 (comment).

Changes

Introduces an additional DB-based validator, which searches for solvers with less than 10%(configurable) of successful settlements among 100 last auctions(configurable).

  • Updated config.
  • New notification details.
  • Some refactoring.

How to test

A new SQL query test.

Copy link

github-actions bot commented Jan 31, 2025

Reminder: Please consider backward compatibility when modifying the API specification.
If breaking changes are unavoidable, ensure:

  • You explicitly pointed out breaking changes.
  • You communicate the changes to affected teams (at least Frontend team and SAFE team).
  • You provide proper versioning and migration mechanisms.

Resolved

@squadgazzz squadgazzz changed the base branch from main to notify-banned-solvers January 31, 2025 18:11
@squadgazzz squadgazzz changed the title Db statistics based guard Ban solvers based on the settlements success rate Jan 31, 2025
@squadgazzz squadgazzz marked this pull request as ready for review January 31, 2025 18:12
@squadgazzz squadgazzz requested a review from a team as a code owner January 31, 2025 18:12
pub solver_blacklist_cache_ttl: Duration,

#[clap(flatten)]
pub non_settling_validator_config: NonSettlingValidatorConfig,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please could you add comments?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does the term "validator" come into play here? Aren't these solvers?

@@ -163,4 +163,26 @@ impl super::Postgres {
.await
.context("solver_competition::find_non_settling_solvers")
}

pub async fn find_low_settling_solvers(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please can you add a comment here too? 🙏

);
// Non-settling issue has a higher priority, remove duplicates from low-settling
// solvers.
low_settling_solvers.retain(|solver| !non_settling_solvers.contains(solver));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This .contains() executes a O(n)search for each element of low_settling_solvers. Consider returning a HashSet from find_non_settling_solvers() and find_low_settling_solvers()

self.0.non_settling_config.last_auctions_participation_count,
current_block,
)
.await
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing the debug trace tracing::debug!(solvers = ?non_settling_solver_names, "found non-settling solvers");

Copy link
Contributor

@fleupold fleupold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has this change been discussed with @harisang ? It's quite a steep intrusion into the arbitration cycle (any bonded solver is allowed to participate) and may require a CiP if we decide to selectively exclude solvers from the competition.

pub solver_blacklist_cache_ttl: Duration,

#[clap(flatten)]
pub non_settling_validator_config: NonSettlingValidatorConfig,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does the term "validator" come into play here? Aren't these solvers?

/// participation in the competition. Otherwise, the solver will be
/// banned.
#[clap(long, env, default_value = "0.1")]
pub solver_min_settlement_success_rate: f64,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if a solver has not won a single auction in the last n blocks? Then technically their success rate is 0 so they should be blocked. Does it make more sense to express this config in terms of a maximum failure rate instead?

pub struct LowSettlingValidatorConfig {
/// Enables search of non-settling solvers.
#[clap(
id = "low_settling_solvers_blacklisting_enabled",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is id used for?

);
self_.post_process(
&low_settling_solvers,
&dto::notify::Request::LowSettlingRate,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: HighSettleFailureRate might be more intuitive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants