Skip to content

Commit 3f56981

Browse files
committed
Debug
1 parent e15d30e commit 3f56981

File tree

2 files changed

+66
-9
lines changed

2 files changed

+66
-9
lines changed

builder-server/src/server.rs

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

81-
build_response_with_headers(res, content_type, api_impl.as_ref().fork_name_at_slot(slot)).await
81+
dbg!("in submit_blinded_block");
82+
let response =
83+
build_response_with_headers(res, content_type, api_impl.as_ref().fork_name_at_slot(slot))
84+
.await;
85+
dbg!(&response);
86+
response
8287
}
8388

8489
async fn get_status() -> StatusCode {
@@ -103,16 +108,17 @@ where
103108
Ok(Accept::Ssz) => {
104109
info!("REQUESTED SSZ");
105110
ContentType::Ssz
106-
},
111+
}
107112
_ => {
108113
info!("REQUESTED JSON");
109114
ContentType::Json
110-
},
115+
}
111116
};
112117

113118
let res = api_impl
114119
.as_ref()
115120
.get_header(slot, parent_hash, pubkey)
116121
.await;
122+
tracing::info!("Got response from builder, constructing response");
117123
build_response_with_headers(res, content_type, api_impl.as_ref().fork_name_at_slot(slot)).await
118124
}

common/src/lib.rs

Lines changed: 57 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+
println!(
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,14 @@ 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);
92+
dbg!(&e);
8493
StatusCode::INTERNAL_SERVER_ERROR
85-
})
94+
});
95+
dbg!(&resp);
96+
resp
8697
}
8798
Err(body) => {
8899
let mut response = response_builder.status(body.code);
@@ -241,9 +252,9 @@ where
241252
let content_type = headers
242253
.get(CONTENT_TYPE)
243254
.and_then(|value| value.to_str().ok());
244-
255+
dbg!(&headers);
245256
let fork_name = headers
246-
.get("")
257+
.get(CONSENSUS_VERSION_HEADER)
247258
.and_then(|value| ForkName::from_str(value.to_str().unwrap()).ok());
248259

249260
let bytes = Bytes::from_request(req, _state)
@@ -363,7 +374,7 @@ where
363374
}
364375

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

0 commit comments

Comments
 (0)