Skip to content

Commit

Permalink
copy traces
Browse files Browse the repository at this point in the history
  • Loading branch information
ltitanb committed Dec 6, 2024
1 parent 89cb716 commit f26f257
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 40 deletions.
17 changes: 7 additions & 10 deletions crates/api/src/builder/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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
{
Expand Down
8 changes: 4 additions & 4 deletions crates/api/src/builder/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ use helix_common::{

#[derive(Clone)]
pub enum DbInfo {
NewSubmission(Arc<SignedBidSubmission>, Arc<SubmissionTrace>, OptimisticVersion),
NewHeaderSubmission(Arc<SignedHeaderSubmission>, Arc<HeaderSubmissionTrace>),
GossipedHeader { block_hash: ByteVector<32>, trace: Arc<GossipedHeaderTrace> },
GossipedPayload { block_hash: ByteVector<32>, trace: Arc<GossipedPayloadTrace> },
NewSubmission(Arc<SignedBidSubmission>, SubmissionTrace, OptimisticVersion),
NewHeaderSubmission(Arc<SignedHeaderSubmission>, 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> },
}

Expand Down
7 changes: 3 additions & 4 deletions crates/api/src/proposer/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -916,7 +916,7 @@ where
payload_clone,
&signed_blinded_block,
&proposer_public_key,
&trace_clone,
trace_clone,
&request_id_clone,
user_agent,
)
Expand Down Expand Up @@ -1369,7 +1369,7 @@ where
payload: Arc<PayloadAndBlobs>,
signed_blinded_block: &SignedBlindedBeaconBlock,
proposer_public_key: &BlsPublicKey,
trace: &GetPayloadTrace,
trace: GetPayloadTrace,
request_id: &Uuid,
user_agent: Option<String>,
) {
Expand All @@ -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) =
Expand Down
10 changes: 6 additions & 4 deletions crates/common/src/traces/builder_api_trace.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion crates/common/src/traces/constraint_api_trace.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
8 changes: 5 additions & 3 deletions crates/common/src/traces/proposer_api.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
8 changes: 4 additions & 4 deletions crates/database/src/mock_database_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl DatabaseService for MockDatabaseService {
async fn store_block_submission(
&self,
_submission: Arc<SignedBidSubmission>,
_trace: Arc<SubmissionTrace>,
_trace: SubmissionTrace,
_optimistic_version: i16,
) -> Result<(), DatabaseError> {
Ok(())
Expand Down Expand Up @@ -252,23 +252,23 @@ impl DatabaseService for MockDatabaseService {
async fn store_header_submission(
&self,
_submission: Arc<SignedHeaderSubmission>,
_trace: Arc<HeaderSubmissionTrace>,
_trace: HeaderSubmissionTrace,
) -> Result<(), DatabaseError> {
Ok(())
}

async fn save_gossiped_header_trace(
&self,
_block_hash: ByteVector<32>,
_trace: Arc<GossipedHeaderTrace>,
_trace: GossipedHeaderTrace,
) -> Result<(), DatabaseError> {
Ok(())
}

async fn save_gossiped_payload_trace(
&self,
_block_hash: ByteVector<32>,
_trace: Arc<GossipedPayloadTrace>,
_trace: GossipedPayloadTrace,
) -> Result<(), DatabaseError> {
Ok(())
}
Expand Down
8 changes: 4 additions & 4 deletions crates/database/src/postgres/postgres_db_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ impl DatabaseService for PostgresDatabaseService {
async fn store_block_submission(
&self,
submission: Arc<SignedBidSubmission>,
trace: Arc<SubmissionTrace>,
trace: SubmissionTrace,
optimistic_version: i16,
) -> Result<(), DatabaseError> {
let mut record = DbMetricRecord::new("store_block_submission");
Expand Down Expand Up @@ -1717,7 +1717,7 @@ impl DatabaseService for PostgresDatabaseService {
async fn store_header_submission(
&self,
submission: Arc<SignedHeaderSubmission>,
trace: Arc<HeaderSubmissionTrace>,
trace: HeaderSubmissionTrace,
) -> Result<(), DatabaseError> {
let mut record = DbMetricRecord::new("store_header_submission");

Expand Down Expand Up @@ -1780,7 +1780,7 @@ impl DatabaseService for PostgresDatabaseService {
async fn save_gossiped_header_trace(
&self,
block_hash: ByteVector<32>,
trace: Arc<GossipedHeaderTrace>,
trace: GossipedHeaderTrace,
) -> Result<(), DatabaseError> {
let mut record = DbMetricRecord::new("save_gossiped_header_trace");

Expand Down Expand Up @@ -1810,7 +1810,7 @@ impl DatabaseService for PostgresDatabaseService {
async fn save_gossiped_payload_trace(
&self,
block_hash: ByteVector<32>,
trace: Arc<GossipedPayloadTrace>,
trace: GossipedPayloadTrace,
) -> Result<(), DatabaseError> {
let mut record = DbMetricRecord::new("save_gossiped_payload_trace");

Expand Down
4 changes: 2 additions & 2 deletions crates/database/src/postgres/postgres_db_service_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Expand Down Expand Up @@ -691,7 +691,7 @@ mod tests {
db_service
.store_header_submission(
Arc::new(signed_bid_submission),
Arc::new(HeaderSubmissionTrace::default()),
HeaderSubmissionTrace::default(),
)
.await?;
Ok(())
Expand Down
8 changes: 4 additions & 4 deletions crates/database/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pub trait DatabaseService: Send + Sync + Clone {
async fn store_block_submission(
&self,
submission: Arc<SignedBidSubmission>,
trace: Arc<SubmissionTrace>,
trace: SubmissionTrace,
optimistic_version: i16,
) -> Result<(), DatabaseError>;

Expand Down Expand Up @@ -175,19 +175,19 @@ pub trait DatabaseService: Send + Sync + Clone {
async fn store_header_submission(
&self,
submission: Arc<SignedHeaderSubmission>,
trace: Arc<HeaderSubmissionTrace>,
trace: HeaderSubmissionTrace,
) -> Result<(), DatabaseError>;

async fn save_gossiped_header_trace(
&self,
block_hash: ByteVector<32>,
trace: Arc<GossipedHeaderTrace>,
trace: GossipedHeaderTrace,
) -> Result<(), DatabaseError>;

async fn save_gossiped_payload_trace(
&self,
block_hash: ByteVector<32>,
trace: Arc<GossipedPayloadTrace>,
trace: GossipedPayloadTrace,
) -> Result<(), DatabaseError>;

async fn get_trusted_proposers(&self) -> Result<Vec<ProposerInfo>, DatabaseError>;
Expand Down

0 comments on commit f26f257

Please sign in to comment.