Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions crates/common/src/commit/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use super::{
error::SignerClientError,
request::SignRequest,
};
use crate::DEFAULT_REQUEST_TIMEOUT;

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct GetPubkeysResponse {
Expand All @@ -34,14 +35,17 @@ impl SignerClient {
HeaderValue::from_str(&format!("Bearer {}", jwt)).expect("invalid jwt");
auth_value.set_sensitive(true);
headers.insert(AUTHORIZATION, auth_value);

let client = reqwest::Client::builder().default_headers(headers).build().unwrap();
let client = reqwest::Client::builder()
.timeout(DEFAULT_REQUEST_TIMEOUT)
.default_headers(headers)
.build()
.unwrap();

Self { url: url.into(), client }
}

/// Request a list of validator pubkeys for which signatures can be requested.
/// TODO: add more docs on how proxy keys work
/// Request a list of validator pubkeys for which signatures can be
/// requested. TODO: add more docs on how proxy keys work
pub async fn get_pubkeys(&self) -> Result<GetPubkeysResponse, SignerClientError> {
let url = format!("{}{}", self.url, GET_PUBKEYS_PATH);
let res = self.client.get(&url).send().await?;
Expand Down
5 changes: 5 additions & 0 deletions crates/common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::time::Duration;

pub mod commit;
pub mod config;
pub mod constants;
Expand All @@ -7,3 +9,6 @@ pub mod signature;
pub mod signer;
pub mod types;
pub mod utils;


pub const DEFAULT_REQUEST_TIMEOUT: Duration = Duration::from_secs(12);
12 changes: 7 additions & 5 deletions crates/pbs/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use std::{
sync::{Arc, Mutex},
};

use alloy::primitives::B256;
use alloy::rpc::types::beacon::BlsPublicKey;
use alloy::{primitives::B256, rpc::types::beacon::BlsPublicKey};
use axum::http::{HeaderMap, HeaderName, HeaderValue};
use cb_common::{
config::{PbsConfig, PbsModuleConfig},
pbs::{RelayEntry, HEADER_VERSION_KEY, HEAVER_VERSION_VALUE},
DEFAULT_REQUEST_TIMEOUT,
};
use dashmap::DashMap;
use tokio::sync::broadcast;
Expand Down Expand Up @@ -62,6 +62,7 @@ where

let relay_client = reqwest::Client::builder()
.default_headers(headers)
.timeout(DEFAULT_REQUEST_TIMEOUT)
.build()
.expect("failed to build relay client");

Expand Down Expand Up @@ -115,9 +116,10 @@ where
self.relay_client.clone()
}

/// Add some bids to the cache, the bids are all assumed to be for the provided slot
/// Returns the bid with the max value
/// TODO: this doesnt handle cancellations if we call multiple times get_header
/// Add some bids to the cache, the bids are all assumed to be for the
/// provided slot Returns the bid with the max value
/// TODO: this doesnt handle cancellations if we call multiple times
/// get_header
pub fn add_bids(&self, slot: u64, bids: Vec<GetHeaderReponse>) -> Option<GetHeaderReponse> {
let mut slot_entry = self.bid_cache.entry(slot).or_default();
slot_entry.extend(bids);
Expand Down