Skip to content

Commit

Permalink
fix(constraints-api): review constraints saving logic
Browse files Browse the repository at this point in the history
  • Loading branch information
thedevbirb committed Nov 27, 2024
1 parent ca4d329 commit 8f91119
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions crates/api/src/constraints/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use axum::{
http::{Request, StatusCode},
Extension,
};
use ethereum_consensus::{deneb::Slot, ssz};
use ethereum_consensus::ssz;
use helix_common::{
api::constraints_api::{
SignableBLS, SignedDelegation, SignedRevocation, DELEGATION_ACTION,
Expand Down Expand Up @@ -170,18 +170,18 @@ where
// Send to the constraints channel
api.constraints_handle.send_constraints(constraint.clone());

// Decode the constraints and generate proof data.
let constraints_with_proofs = SignedConstraintsWithProofData::try_from(constraint).map_err(|err| {
error!(request_id = %request_id, "Failed to decode constraints transactions and generate proof data");
err
})?;

// Finally add the constraints to the redis cache
if let Err(err) = api
.save_constraints_to_auctioneer(
&mut trace,
constraint.message.slot,
constraint,
&request_id,
)
.await
{
error!(request_id = %request_id, error = %err, "Failed to save constraints to auctioneer");
};
api.save_constraints_to_auctioneer(&mut trace, constraints_with_proofs, &request_id)
.await.map_err(|err| {
error!(request_id = %request_id, error = %err, "Failed to save constraints to auctioneer");
err
})?;
}

// Log some final info
Expand Down Expand Up @@ -355,12 +355,17 @@ where
async fn save_constraints_to_auctioneer(
&self,
trace: &mut ConstraintSubmissionTrace,
slot: Slot,
constraint: SignedConstraints,
constraints_with_proofs: SignedConstraintsWithProofData,
request_id: &Uuid,
) -> Result<(), ConstraintsApiError> {
let message_with_data = SignedConstraintsWithProofData::try_from(constraint)?;
match self.auctioneer.save_constraints(slot, message_with_data).await {
match self
.auctioneer
.save_constraints(
constraints_with_proofs.signed_constraints.message.slot,
constraints_with_proofs,
)
.await
{
Ok(()) => {
trace.auctioneer_update = get_nanos_timestamp()?;
info!(
Expand Down

0 comments on commit 8f91119

Please sign in to comment.