Skip to content

Commit

Permalink
Merge pull request #29 from chainbound/lore/fix/submit-constraints-logic
Browse files Browse the repository at this point in the history
fix(constraints-api): review constraints saving logic
  • Loading branch information
thedevbirb authored Nov 28, 2024
2 parents 242607c + 5848eec commit abf32f5
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, phase0::mainnet::SLOTS_PER_EPOCH, ssz};
use ethereum_consensus::{phase0::mainnet::SLOTS_PER_EPOCH, ssz};
use helix_common::{
api::constraints_api::{
SignableBLS, SignedDelegation, SignedRevocation, DELEGATION_ACTION,
Expand Down Expand Up @@ -200,18 +200,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 @@ -384,12 +384,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 abf32f5

Please sign in to comment.