Skip to content

Commit c7aee9c

Browse files
committed
Debug
1 parent e15d30e commit c7aee9c

File tree

2 files changed

+56
-6
lines changed

2 files changed

+56
-6
lines changed

builder-server/src/server.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ where
7878
let slot = block.slot();
7979
let res = api_impl.as_ref().submit_blinded_block(block).await;
8080

81+
dbg!("in submit_blinded_block");
8182
build_response_with_headers(res, content_type, api_impl.as_ref().fork_name_at_slot(slot)).await
8283
}
8384

@@ -114,5 +115,6 @@ where
114115
.as_ref()
115116
.get_header(slot, parent_hash, pubkey)
116117
.await;
118+
tracing::info!("Got response from builder, constructing response");
117119
build_response_with_headers(res, content_type, api_impl.as_ref().fork_name_at_slot(slot)).await
118120
}

common/src/lib.rs

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ where
3232

3333
let resp = match result {
3434
Ok(body) => {
35+
tracing::info!(
36+
"Got a valid response from builder, content-type {:?}",
37+
content_type
38+
);
39+
dbg!(
40+
"Got a valid response from builder, content-type {:?}",
41+
content_type
42+
);
3543
let mut response = response_builder.status(200);
3644

3745
if let Some(response_headers) = response.headers_mut() {
@@ -78,11 +86,13 @@ where
7886
StatusCode::INTERNAL_SERVER_ERROR
7987
})?,
8088
};
81-
82-
response.body(Body::from(body_content)).map_err(|e| {
89+
dbg!(&body_content.len());
90+
let resp = response.body(Body::from(body_content)).map_err(|e| {
8391
error!(error = ?e);
8492
StatusCode::INTERNAL_SERVER_ERROR
85-
})
93+
});
94+
dbg!(&resp);
95+
resp
8696
}
8797
Err(body) => {
8898
let mut response = response_builder.status(body.code);
@@ -241,9 +251,9 @@ where
241251
let content_type = headers
242252
.get(CONTENT_TYPE)
243253
.and_then(|value| value.to_str().ok());
244-
254+
dbg!(&headers);
245255
let fork_name = headers
246-
.get("")
256+
.get(CONSENSUS_VERSION_HEADER)
247257
.and_then(|value| ForkName::from_str(value.to_str().unwrap()).ok());
248258

249259
let bytes = Bytes::from_request(req, _state)
@@ -363,7 +373,7 @@ where
363373
}
364374

365375
// Headers
366-
#[derive(Default, Clone, Copy)]
376+
#[derive(Default, Clone, Copy, Debug)]
367377
pub enum ContentType {
368378
#[default]
369379
Json,
@@ -540,3 +550,41 @@ impl FromStr for Accept {
540550
accept_type.ok_or_else(|| "accept header is not supported".to_string())
541551
}
542552
}
553+
554+
#[cfg(test)]
555+
mod tests {
556+
use std::usize;
557+
558+
use super::*;
559+
use axum::body::to_bytes;
560+
use beacon_api_types::{
561+
Blob, BlobsBundle, EthSpec, ExecutionPayload, ExecutionPayloadAndBlobs,
562+
ExecutionPayloadDeneb, FullPayloadContents, KzgCommitment, KzgProof, MainnetEthSpec,
563+
};
564+
565+
#[tokio::test]
566+
async fn test_something() {
567+
let payload_and_blobs: ExecutionPayloadAndBlobs<MainnetEthSpec> =
568+
ExecutionPayloadAndBlobs {
569+
blobs_bundle: BlobsBundle {
570+
commitments: vec![KzgCommitment::empty_for_testing()].into(),
571+
proofs: vec![KzgProof::empty()].into(),
572+
blobs: vec![Blob::<MainnetEthSpec>::new(vec![
573+
42;
574+
MainnetEthSpec::bytes_per_blob()
575+
])
576+
.unwrap()]
577+
.into(),
578+
},
579+
execution_payload: ExecutionPayload::Deneb(ExecutionPayloadDeneb {
580+
..Default::default()
581+
}),
582+
};
583+
let full_payload = FullPayloadContents::PayloadAndBlobs(payload_and_blobs);
584+
let resp = build_response_with_headers(Ok(full_payload), ContentType::Ssz, ForkName::Deneb)
585+
.await
586+
.unwrap();
587+
let body = to_bytes(resp.into_body(), usize::MAX).await.unwrap();
588+
dbg!(FullPayloadContents::<MainnetEthSpec>::from_ssz_bytes_by_fork(&body, ForkName::Deneb));
589+
}
590+
}

0 commit comments

Comments
 (0)