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

Notify banned solvers #3262

Open
wants to merge 17 commits into
base: blacklist-failing-solvers
Choose a base branch
from

Conversation

squadgazzz
Copy link
Contributor

This is a follow-up to #3257, which was requested in #3257 (comment). Implements solver notification mechanism in case the driver is banned. Reroutes the notification request to the solver through the internal driver. External solvers need to be communicated about this change.

Copy link

github-actions bot commented Jan 30, 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.

Caused by:

@squadgazzz squadgazzz marked this pull request as ready for review January 30, 2025 20:24
@squadgazzz squadgazzz requested a review from a team as a code owner January 30, 2025 20:24
@squadgazzz squadgazzz marked this pull request as draft January 31, 2025 08:43
@squadgazzz squadgazzz marked this pull request as ready for review January 31, 2025 08:52
@squadgazzz squadgazzz force-pushed the notify-banned-solvers branch from 640f68f to 43e650f Compare January 31, 2025 17:39
@@ -106,6 +112,28 @@ impl Validator {
}
});
}

/// Try to notify all the non-settling solvers in a background task.
fn notify_solvers(non_settling_drivers: &[Arc<infra::Driver>]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the best place to notify? (db.rs file)

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree, domain should only be aware of the call:

self_.0.infra.notify()

while the implementation should be inside infra

tokio::task::spawn(future.in_current_span());
}

pub async fn notify(
Copy link
Contributor

Choose a reason for hiding this comment

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

why two functions with the same name but one public and the other private? is the public one really needed? 🤔

#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("Unable to notify solver")]
UnableToNotify,
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it is worth to add some context information like solver address or name?

#[derive(Debug)]
pub enum BanReason {
/// The driver won multiple consecutive auctions but never settled them.
UnsettledConsecutiveAuctions,
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we differentiate the ban reason between non-settled and low-settled rate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -106,6 +112,28 @@ impl Validator {
}
});
}

/// Try to notify all the non-settling solvers in a background task.
fn notify_solvers(non_settling_drivers: &[Arc<infra::Driver>]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Agree, domain should only be aware of the call:

self_.0.infra.notify()

while the implementation should be inside infra

fn from(value: NotifyRequest) -> Self {
match value {
NotifyRequest::UnsettledConsecutiveAuctions => {
notify::Kind::Banned(notify::BanReason::UnsettledConsecutiveAuctions)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit improvement proposal: As a solver I would be interested in knowing the block number when i will be enabled again.

req: axum::Json<dto::NotifyRequest>,
) -> Result<hyper::StatusCode, (hyper::StatusCode, axum::Json<Error>)> {
let solver = &state.solver().name().0;
tracing::trace!(?req, ?solver, "received a notification");
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: probably ok to set it to debug as we don't start with a lot of notifications.

}

#[derive(Debug, thiserror::Error)]
pub enum Error {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Personally I would be ok with omitting completely the error case for notify endpoint (be consistent with how the driver propagates it to solvers) as we always considered this endpoint not too important for system to work and we were not interested to act on failure of notification.

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.

4 participants