From ae6caf3a0f26fc6bdce9815137b6c32bdd2fcb34 Mon Sep 17 00:00:00 2001 From: thedevbirb Date: Thu, 31 Oct 2024 15:28:39 +0100 Subject: [PATCH] fix(sidecar): send filtered delegations to mev-boost and not all of them --- bolt-sidecar/src/client/constraints_client.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/bolt-sidecar/src/client/constraints_client.rs b/bolt-sidecar/src/client/constraints_client.rs index 1e8d5af09..b1744855d 100644 --- a/bolt-sidecar/src/client/constraints_client.rs +++ b/bolt-sidecar/src/client/constraints_client.rs @@ -100,11 +100,22 @@ impl BuilderApi for ConstraintsClient { return Err(BuilderApiError::FailedRegisteringValidators(error)); } - // If there are any delegations, propagate them to the relay + // If there are any delegations, propagate the one associated to the incoming registrations to the relay if self.delegations.is_empty() { return Ok(()); - } else if let Err(err) = self.delegate(&self.delegations).await { - error!(?err, "Failed to propagate delegations during validator registration"); + } else { + let validator_pubkeys = + registrations.iter().map(|r| r.message.public_key.clone()).collect::>(); + let filtered_delegations = self + .delegations + .iter() + .filter(|d| validator_pubkeys.contains(&d.message.validator_pubkey)) + .cloned() + .collect::>(); + + if let Err(err) = self.delegate(&filtered_delegations).await { + error!(?err, "Failed to propagate delegations during validator registration"); + } } Ok(())