diff --git a/crates/api/src/builder/api.rs b/crates/api/src/builder/api.rs index 5f287852..4520496a 100644 --- a/crates/api/src/builder/api.rs +++ b/crates/api/src/builder/api.rs @@ -510,10 +510,8 @@ where // Save submission to db. tokio::spawn( async move { - if let Err(err) = api - .db - .store_block_submission(payload, Arc::new(trace), optimistic_version as i16) - .await + if let Err(err) = + api.db.store_block_submission(payload, trace, optimistic_version as i16).await { error!(%err, "failed to store block submission") } @@ -721,7 +719,7 @@ where let db = api.db.clone(); tokio::spawn( async move { - if let Err(err) = db.store_header_submission(payload, Arc::new(trace)).await { + if let Err(err) = db.store_header_submission(payload, trace).await { error!( %err, "failed to store header submission", @@ -929,7 +927,7 @@ where async move { if let Err(err) = api .db - .store_block_submission(payload, Arc::new(trace), OptimisticVersion::V2 as i16) + .store_block_submission(payload, trace, OptimisticVersion::V2 as i16) .await { error!(%err, "failed to store block submission") @@ -1125,9 +1123,8 @@ where // Save latency trace to db let db = self.db.clone(); tokio::spawn(async move { - if let Err(err) = db - .save_gossiped_header_trace(req.bid_trace.block_hash.clone(), Arc::new(trace)) - .await + if let Err(err) = + db.save_gossiped_header_trace(req.bid_trace.block_hash.clone(), trace).await { error!(%err, "failed to store gossiped header trace") } @@ -1205,7 +1202,7 @@ where if let Err(err) = db .save_gossiped_payload_trace( req.execution_payload.execution_payload.block_hash().clone(), - Arc::new(trace), + trace, ) .await { diff --git a/crates/api/src/builder/types.rs b/crates/api/src/builder/types.rs index 5bdcd379..5fd9fb98 100644 --- a/crates/api/src/builder/types.rs +++ b/crates/api/src/builder/types.rs @@ -9,10 +9,10 @@ use helix_common::{ #[derive(Clone)] pub enum DbInfo { - NewSubmission(Arc, Arc, OptimisticVersion), - NewHeaderSubmission(Arc, Arc), - GossipedHeader { block_hash: ByteVector<32>, trace: Arc }, - GossipedPayload { block_hash: ByteVector<32>, trace: Arc }, + NewSubmission(Arc, SubmissionTrace, OptimisticVersion), + NewHeaderSubmission(Arc, HeaderSubmissionTrace), + GossipedHeader { block_hash: ByteVector<32>, trace: GossipedHeaderTrace }, + GossipedPayload { block_hash: ByteVector<32>, trace: GossipedPayloadTrace }, SimulationResult { block_hash: ByteVector<32>, block_sim_result: Result<(), BlockSimError> }, } diff --git a/crates/api/src/proposer/api.rs b/crates/api/src/proposer/api.rs index 43c58936..244a1340 100644 --- a/crates/api/src/proposer/api.rs +++ b/crates/api/src/proposer/api.rs @@ -883,7 +883,7 @@ where let self_clone = self.clone(); let unblinded_payload_clone = unblinded_payload.clone(); let request_id_clone = *request_id; - let mut trace_clone = trace.clone(); + let mut trace_clone = *trace; let payload_clone = payload.clone(); tokio::spawn(async move { @@ -916,7 +916,7 @@ where payload_clone, &signed_blinded_block, &proposer_public_key, - &trace_clone, + trace_clone, &request_id_clone, user_agent, ) @@ -1369,7 +1369,7 @@ where payload: Arc, signed_blinded_block: &SignedBlindedBeaconBlock, proposer_public_key: &BlsPublicKey, - trace: &GetPayloadTrace, + trace: GetPayloadTrace, request_id: &Uuid, user_agent: Option, ) { @@ -1394,7 +1394,6 @@ where }; let db = self.db.clone(); - let trace = trace.clone(); let request_id = *request_id; tokio::spawn(async move { if let Err(err) = diff --git a/crates/common/src/traces/builder_api_trace.rs b/crates/common/src/traces/builder_api_trace.rs index 123d891c..7419a02b 100644 --- a/crates/common/src/traces/builder_api_trace.rs +++ b/crates/common/src/traces/builder_api_trace.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Default, Debug, serde::Serialize, serde::Deserialize)] +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize)] pub struct SubmissionTrace { pub receive: u64, pub decode: u64, @@ -10,7 +12,7 @@ pub struct SubmissionTrace { pub request_finish: u64, } -#[derive(Clone, Default, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize)] pub struct HeaderSubmissionTrace { pub receive: u64, pub decode: u64, @@ -21,14 +23,14 @@ pub struct HeaderSubmissionTrace { pub request_finish: u64, } -#[derive(Clone, Default, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize)] pub struct GossipedPayloadTrace { pub receive: u64, pub pre_checks: u64, pub auctioneer_update: u64, } -#[derive(Clone, Default, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize)] pub struct GossipedHeaderTrace { pub on_receive: u64, pub on_gossip_receive: u64, diff --git a/crates/common/src/traces/constraint_api_trace.rs b/crates/common/src/traces/constraint_api_trace.rs index aa08b5e4..5e0b9d8c 100644 --- a/crates/common/src/traces/constraint_api_trace.rs +++ b/crates/common/src/traces/constraint_api_trace.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Default, Debug, serde::Serialize, serde::Deserialize)] +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize)] pub struct ConstraintSubmissionTrace { pub receive: u64, pub decode: u64, diff --git a/crates/common/src/traces/proposer_api.rs b/crates/common/src/traces/proposer_api.rs index 32f25c15..9f21ac99 100644 --- a/crates/common/src/traces/proposer_api.rs +++ b/crates/common/src/traces/proposer_api.rs @@ -1,17 +1,19 @@ -#[derive(Debug, Default)] +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, Default)] pub struct RegisterValidatorsTrace { pub receive: u64, pub registrations_complete: u64, } -#[derive(Debug, Default, Clone)] +#[derive(Debug, Clone, Copy, Default)] pub struct GetHeaderTrace { pub receive: u64, pub validation_complete: u64, pub best_bid_fetched: u64, } -#[derive(Debug, Default, serde::Serialize, serde::Deserialize, Clone)] +#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize)] pub struct GetPayloadTrace { pub receive: u64, pub proposer_index_validated: u64, diff --git a/crates/database/src/mock_database_service.rs b/crates/database/src/mock_database_service.rs index 6630622b..e15b3d47 100644 --- a/crates/database/src/mock_database_service.rs +++ b/crates/database/src/mock_database_service.rs @@ -150,7 +150,7 @@ impl DatabaseService for MockDatabaseService { async fn store_block_submission( &self, _submission: Arc, - _trace: Arc, + _trace: SubmissionTrace, _optimistic_version: i16, ) -> Result<(), DatabaseError> { Ok(()) @@ -252,7 +252,7 @@ impl DatabaseService for MockDatabaseService { async fn store_header_submission( &self, _submission: Arc, - _trace: Arc, + _trace: HeaderSubmissionTrace, ) -> Result<(), DatabaseError> { Ok(()) } @@ -260,7 +260,7 @@ impl DatabaseService for MockDatabaseService { async fn save_gossiped_header_trace( &self, _block_hash: ByteVector<32>, - _trace: Arc, + _trace: GossipedHeaderTrace, ) -> Result<(), DatabaseError> { Ok(()) } @@ -268,7 +268,7 @@ impl DatabaseService for MockDatabaseService { async fn save_gossiped_payload_trace( &self, _block_hash: ByteVector<32>, - _trace: Arc, + _trace: GossipedPayloadTrace, ) -> Result<(), DatabaseError> { Ok(()) } diff --git a/crates/database/src/postgres/postgres_db_service.rs b/crates/database/src/postgres/postgres_db_service.rs index a64dd635..8cb81519 100644 --- a/crates/database/src/postgres/postgres_db_service.rs +++ b/crates/database/src/postgres/postgres_db_service.rs @@ -1134,7 +1134,7 @@ impl DatabaseService for PostgresDatabaseService { async fn store_block_submission( &self, submission: Arc, - trace: Arc, + trace: SubmissionTrace, optimistic_version: i16, ) -> Result<(), DatabaseError> { let mut record = DbMetricRecord::new("store_block_submission"); @@ -1717,7 +1717,7 @@ impl DatabaseService for PostgresDatabaseService { async fn store_header_submission( &self, submission: Arc, - trace: Arc, + trace: HeaderSubmissionTrace, ) -> Result<(), DatabaseError> { let mut record = DbMetricRecord::new("store_header_submission"); @@ -1780,7 +1780,7 @@ impl DatabaseService for PostgresDatabaseService { async fn save_gossiped_header_trace( &self, block_hash: ByteVector<32>, - trace: Arc, + trace: GossipedHeaderTrace, ) -> Result<(), DatabaseError> { let mut record = DbMetricRecord::new("save_gossiped_header_trace"); @@ -1810,7 +1810,7 @@ impl DatabaseService for PostgresDatabaseService { async fn save_gossiped_payload_trace( &self, block_hash: ByteVector<32>, - trace: Arc, + trace: GossipedPayloadTrace, ) -> Result<(), DatabaseError> { let mut record = DbMetricRecord::new("save_gossiped_payload_trace"); diff --git a/crates/database/src/postgres/postgres_db_service_tests.rs b/crates/database/src/postgres/postgres_db_service_tests.rs index 57204bca..d39298b8 100644 --- a/crates/database/src/postgres/postgres_db_service_tests.rs +++ b/crates/database/src/postgres/postgres_db_service_tests.rs @@ -492,7 +492,7 @@ mod tests { }; db_service - .store_block_submission(Arc::new(signed_bid_submission), Arc::new(submission_trace), 0) + .store_block_submission(Arc::new(signed_bid_submission), submission_trace, 0) .await?; Ok(()) } @@ -691,7 +691,7 @@ mod tests { db_service .store_header_submission( Arc::new(signed_bid_submission), - Arc::new(HeaderSubmissionTrace::default()), + HeaderSubmissionTrace::default(), ) .await?; Ok(()) diff --git a/crates/database/src/traits.rs b/crates/database/src/traits.rs index c9db7764..06690a08 100644 --- a/crates/database/src/traits.rs +++ b/crates/database/src/traits.rs @@ -105,7 +105,7 @@ pub trait DatabaseService: Send + Sync + Clone { async fn store_block_submission( &self, submission: Arc, - trace: Arc, + trace: SubmissionTrace, optimistic_version: i16, ) -> Result<(), DatabaseError>; @@ -175,19 +175,19 @@ pub trait DatabaseService: Send + Sync + Clone { async fn store_header_submission( &self, submission: Arc, - trace: Arc, + trace: HeaderSubmissionTrace, ) -> Result<(), DatabaseError>; async fn save_gossiped_header_trace( &self, block_hash: ByteVector<32>, - trace: Arc, + trace: GossipedHeaderTrace, ) -> Result<(), DatabaseError>; async fn save_gossiped_payload_trace( &self, block_hash: ByteVector<32>, - trace: Arc, + trace: GossipedPayloadTrace, ) -> Result<(), DatabaseError>; async fn get_trusted_proposers(&self) -> Result, DatabaseError>;