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

fix(constraints-api): review constraints saving logic #29

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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