Skip to content

Commit dddec62

Browse files
Jonas Bostoenltitanb
authored andcommitted
feat: export more types for use in modules (#97)
* feat(constraints): scaffold constraints_api example * feat(constraints): scaffold constraints_api example * feat(constraints): more types, work out routes * feat(constraints): get_header_with_proofs initial endpoint * feat(constraints): wip constraint & proofs verification * feat(constraints): more proof scaffolding * refactor(constraints): smol rename * feat(constraints): multiproof verification * fix: typo * refactor: rm constraints_api example
1 parent c334f0b commit dddec62

File tree

8 files changed

+24
-22
lines changed

8 files changed

+24
-22
lines changed

crates/common/src/pbs/event.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use tokio::net::TcpListener;
1515
use tracing::{error, info, trace};
1616

1717
use super::{
18-
GetHeaderParams, GetHeaderReponse, SignedBlindedBeaconBlock, SubmitBlindedBlockResponse,
18+
GetHeaderParams, GetHeaderResponse, SignedBlindedBeaconBlock, SubmitBlindedBlockResponse,
1919
};
2020
use crate::{
2121
config::{load_env_var, BUILDER_SERVER_ENV},
@@ -25,7 +25,7 @@ use crate::{
2525
#[derive(Debug, Clone, Serialize, Deserialize)]
2626
pub enum BuilderEvent {
2727
GetHeaderRequest(GetHeaderParams),
28-
GetHeaderResponse(Box<Option<GetHeaderReponse>>),
28+
GetHeaderResponse(Box<Option<GetHeaderResponse>>),
2929
GetStatusEvent,
3030
GetStatusResponse,
3131
SubmitBlockRequest(Box<SignedBlindedBeaconBlock>),

crates/common/src/pbs/types/get_header.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ pub struct GetHeaderParams {
2222
}
2323

2424
/// Returned by relay in get_header
25-
pub type GetHeaderReponse = VersionedResponse<SignedExecutionPayloadHeader>;
25+
pub type GetHeaderResponse = VersionedResponse<SignedExecutionPayloadHeader>;
2626

27-
impl GetHeaderReponse {
27+
impl GetHeaderResponse {
2828
pub fn block_hash(&self) -> B256 {
2929
self.data.message.header.block_hash
3030
}
@@ -68,7 +68,7 @@ impl ExecutionPayloadHeaderMessage {
6868
mod tests {
6969
use alloy::primitives::U256;
7070

71-
use super::GetHeaderReponse;
71+
use super::GetHeaderResponse;
7272
use crate::{signature::verify_signed_builder_message, types::Chain};
7373

7474
#[test]
@@ -111,7 +111,7 @@ mod tests {
111111
}
112112
}"#;
113113

114-
let parsed = serde_json::from_str::<GetHeaderReponse>(&data).unwrap().data;
114+
let parsed = serde_json::from_str::<GetHeaderResponse>(&data).unwrap().data;
115115

116116
assert_eq!(parsed.message.value(), U256::from(4293912964927787u64));
117117

crates/common/src/pbs/types/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@ mod spec;
88
mod utils;
99

1010
pub use beacon_block::{SignedBlindedBeaconBlock, SubmitBlindedBlockResponse};
11-
pub use execution_payload::EMPTY_TX_ROOT_HASH;
12-
pub use get_header::{GetHeaderParams, GetHeaderReponse, SignedExecutionPayloadHeader};
11+
pub use execution_payload::{Transaction, EMPTY_TX_ROOT_HASH};
12+
pub use get_header::{GetHeaderParams, GetHeaderResponse, SignedExecutionPayloadHeader};
13+
pub use spec::{DenebSpec, EthSpec};
14+
pub use utils::{Version, VersionedResponse};

crates/pbs/src/api.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use alloy::rpc::types::beacon::relay::ValidatorRegistration;
22
use async_trait::async_trait;
33
use axum::{http::HeaderMap, Router};
44
use cb_common::pbs::{
5-
GetHeaderParams, GetHeaderReponse, SignedBlindedBeaconBlock, SubmitBlindedBlockResponse,
5+
GetHeaderParams, GetHeaderResponse, SignedBlindedBeaconBlock, SubmitBlindedBlockResponse,
66
};
77

88
use crate::{
@@ -22,7 +22,7 @@ pub trait BuilderApi<S: BuilderApiState>: 'static {
2222
params: GetHeaderParams,
2323
req_headers: HeaderMap,
2424
state: PbsState<S>,
25-
) -> eyre::Result<Option<GetHeaderReponse>> {
25+
) -> eyre::Result<Option<GetHeaderResponse>> {
2626
mev_boost::get_header(params, req_headers, state).await
2727
}
2828

crates/pbs/src/mev_boost/get_header.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use cb_common::{
99
config::PbsConfig,
1010
pbs::{
1111
error::{PbsError, ValidationError},
12-
GetHeaderParams, GetHeaderReponse, RelayClient, SignedExecutionPayloadHeader,
12+
GetHeaderParams, GetHeaderResponse, RelayClient, SignedExecutionPayloadHeader,
1313
EMPTY_TX_ROOT_HASH, HEADER_SLOT_UUID_KEY, HEADER_START_TIME_UNIX_MS,
1414
},
1515
signature::verify_signed_builder_message,
@@ -34,7 +34,7 @@ pub async fn get_header<S: BuilderApiState>(
3434
params: GetHeaderParams,
3535
req_headers: HeaderMap,
3636
state: PbsState<S>,
37-
) -> eyre::Result<Option<GetHeaderReponse>> {
37+
) -> eyre::Result<Option<GetHeaderResponse>> {
3838
let ms_into_slot = ms_into_slot(params.slot, state.config.chain);
3939
let max_timeout_ms = state
4040
.pbs_config()
@@ -97,7 +97,7 @@ async fn send_timed_get_header(
9797
headers: HeaderMap,
9898
ms_into_slot: u64,
9999
mut timeout_left_ms: u64,
100-
) -> Result<Option<GetHeaderReponse>, PbsError> {
100+
) -> Result<Option<GetHeaderResponse>, PbsError> {
101101
let url = relay.get_header_url(params.slot, params.parent_hash, params.pubkey)?;
102102

103103
if relay.config.enable_timing_games {
@@ -206,7 +206,7 @@ async fn send_one_get_header(
206206
skip_sigverify: bool,
207207
min_bid_wei: U256,
208208
mut req_config: RequestConfig,
209-
) -> Result<(u64, Option<GetHeaderReponse>), PbsError> {
209+
) -> Result<(u64, Option<GetHeaderResponse>), PbsError> {
210210
// the timestamp in the header is the consensus block time which is fixed,
211211
// use the beginning of the request as proxy to make sure we use only the
212212
// last one received
@@ -257,7 +257,7 @@ async fn send_one_get_header(
257257
return Ok((start_request_time, None));
258258
}
259259

260-
let get_header_response: GetHeaderReponse = serde_json::from_slice(&response_bytes)?;
260+
let get_header_response: GetHeaderResponse = serde_json::from_slice(&response_bytes)?;
261261

262262
debug!(
263263
latency = ?request_latency,

crates/pbs/src/state.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::{
66
use alloy::{primitives::B256, rpc::types::beacon::BlsPublicKey};
77
use cb_common::{
88
config::{PbsConfig, PbsModuleConfig},
9-
pbs::{BuilderEvent, GetHeaderReponse, RelayClient},
9+
pbs::{BuilderEvent, GetHeaderResponse, RelayClient},
1010
};
1111
use dashmap::DashMap;
1212
use uuid::Uuid;
@@ -25,7 +25,7 @@ pub struct PbsState<S: BuilderApiState = ()> {
2525
/// Info about the latest slot and its uuid
2626
current_slot_info: Arc<Mutex<(u64, Uuid)>>,
2727
/// Keeps track of which relays delivered which block for which slot
28-
bid_cache: Arc<DashMap<u64, Vec<GetHeaderReponse>>>,
28+
bid_cache: Arc<DashMap<u64, Vec<GetHeaderResponse>>>,
2929
}
3030

3131
impl PbsState<()> {
@@ -88,7 +88,7 @@ where
8888

8989
/// Add some bids to the cache, the bids are all assumed to be for the
9090
/// provided slot Returns the bid with the max value
91-
pub fn add_bids(&self, slot: u64, bids: Vec<GetHeaderReponse>) -> Option<GetHeaderReponse> {
91+
pub fn add_bids(&self, slot: u64, bids: Vec<GetHeaderResponse>) -> Option<GetHeaderResponse> {
9292
let mut slot_entry = self.bid_cache.entry(slot).or_default();
9393
slot_entry.extend(bids);
9494
slot_entry.iter().max_by_key(|bid| bid.value()).cloned()

tests/src/mock_relay.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use axum::{
1313
};
1414
use cb_common::{
1515
pbs::{
16-
GetHeaderParams, GetHeaderReponse, SubmitBlindedBlockResponse, BUILDER_API_PATH,
16+
GetHeaderParams, GetHeaderResponse, SubmitBlindedBlockResponse, BUILDER_API_PATH,
1717
GET_HEADER_PATH, GET_STATUS_PATH, REGISTER_VALIDATOR_PATH, SUBMIT_BLOCK_PATH,
1818
},
1919
signer::ConsensusSigner,
@@ -78,7 +78,7 @@ async fn handle_get_header(
7878
) -> Response {
7979
state.received_get_header.fetch_add(1, Ordering::Relaxed);
8080

81-
let mut response = GetHeaderReponse::default();
81+
let mut response = GetHeaderResponse::default();
8282
response.data.message.header.parent_hash = parent_hash;
8383
response.data.message.header.block_hash.0[0] = 1;
8484
response.data.message.set_value(U256::from(10));

tests/src/mock_validator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use alloy::{
22
primitives::B256,
33
rpc::types::beacon::{relay::ValidatorRegistration, BlsPublicKey},
44
};
5-
use cb_common::pbs::{GetHeaderReponse, RelayClient, SignedBlindedBeaconBlock};
5+
use cb_common::pbs::{GetHeaderResponse, RelayClient, SignedBlindedBeaconBlock};
66
use reqwest::Error;
77

88
use crate::utils::generate_mock_relay;
@@ -19,7 +19,7 @@ impl MockValidator {
1919
pub async fn do_get_header(&self) -> Result<(), Error> {
2020
let url = self.comm_boost.get_header_url(0, B256::ZERO, BlsPublicKey::ZERO).unwrap();
2121
let res = self.comm_boost.client.get(url).send().await?.bytes().await?;
22-
assert!(serde_json::from_slice::<GetHeaderReponse>(&res).is_ok());
22+
assert!(serde_json::from_slice::<GetHeaderResponse>(&res).is_ok());
2323

2424
Ok(())
2525
}

0 commit comments

Comments
 (0)