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
1 change: 1 addition & 0 deletions crates/common/src/constants.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub const APPLICATION_BUILDER_DOMAIN: [u8; 4] = [0, 0, 0, 1];
pub const GENESIS_VALIDATORS_ROOT: [u8; 32] = [0; 32];
pub const COMMIT_BOOST_DOMAIN: [u8; 4] = [109, 109, 111, 67];
pub const COMMIT_BOOST_VERSION: &str = env!("CARGO_PKG_VERSION");
4 changes: 3 additions & 1 deletion crates/common/src/pbs/constants.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use crate::constants::COMMIT_BOOST_VERSION;

pub const BUILDER_API_PATH: &str = "/eth/v1/builder";

pub const GET_HEADER_PATH: &str = "/header/:slot/:parent_hash/:pubkey";
Expand All @@ -9,7 +11,7 @@ pub const SUBMIT_BLOCK_PATH: &str = "/blinded_blocks";

pub const HEADER_SLOT_UUID_KEY: &str = "X-MEVBoost-SlotID";
pub const HEADER_VERSION_KEY: &str = "X-CommitBoost-Version";
pub const HEADER_VERSION_VALUE: &str = env!("CARGO_PKG_VERSION");
pub const HEADER_VERSION_VALUE: &str = COMMIT_BOOST_VERSION;
pub const HEADER_START_TIME_UNIX_MS: &str = "X-MEVBoost-StartTimeUnixMS";

pub const BUILDER_EVENTS_PATH: &str = "/builder_events";
Expand Down
8 changes: 4 additions & 4 deletions crates/common/src/pbs/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ pub enum PbsError {
#[error("reqwest error: {0}")]
Reqwest(#[from] reqwest::Error),

#[error("serde decode error: {0}")]
SerdeDecodeError(#[from] serde_json::Error),
#[error("json decode error: {err}, raw: {raw}")]
JsonDecode { err: serde_json::Error, raw: String },

#[error("relay response error. Code: {code}, err: {error_msg}")]
RelayResponse { error_msg: String, code: u16 },

#[error("Response size exceeds 10MB! Got: {payload_size}")]
PayloadTooLarge { payload_size: usize },
#[error("response size exceeds max size: max: {max} got: {got}")]
PayloadTooLarge { max: usize, got: usize },

#[error("failed validating relay response: {0}")]
Validation(#[from] ValidationError),
Expand Down
16 changes: 12 additions & 4 deletions crates/pbs/src/mev_boost/get_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub async fn get_header<S: BuilderApiState>(
}
Ok(_) => {}
Err(err) if err.is_timeout() => error!(err = "Timed Out", relay_id),
Err(err) => error!(?err, relay_id),
Err(err) => error!(%err, relay_id),
}
}

Expand Down Expand Up @@ -163,7 +163,7 @@ async fn send_timed_get_header(
}
Err(err) if err.is_timeout() => None,
Err(err) => {
error!(?err, "TG: error sending header request");
error!(%err, "TG: error sending header request");
None
}
})
Expand Down Expand Up @@ -245,7 +245,7 @@ async fn send_one_get_header(

let response_bytes = res.bytes().await?;
if response_bytes.len() > MAX_SIZE {
return Err(PbsError::PayloadTooLarge { payload_size: response_bytes.len() });
return Err(PbsError::PayloadTooLarge { max: MAX_SIZE, got: response_bytes.len() });
}

if !code.is_success() {
Expand All @@ -264,7 +264,15 @@ async fn send_one_get_header(
return Ok((start_request_time, None));
}

let get_header_response: GetHeaderResponse = serde_json::from_slice(&response_bytes)?;
let get_header_response = match serde_json::from_slice::<GetHeaderResponse>(&response_bytes) {
Ok(parsed) => parsed,
Err(err) => {
return Err(PbsError::JsonDecode {
err,
raw: String::from_utf8_lossy(&response_bytes).into_owned(),
});
}
};

debug!(
latency = ?request_latency,
Expand Down
4 changes: 2 additions & 2 deletions crates/pbs/src/mev_boost/register_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ async fn send_register_validator(

let response_bytes = res.bytes().await?;
if response_bytes.len() > MAX_SIZE {
return Err(PbsError::PayloadTooLarge { payload_size: response_bytes.len() });
return Err(PbsError::PayloadTooLarge { max: MAX_SIZE, got: response_bytes.len() });
}
if !code.is_success() {
let err = PbsError::RelayResponse {
Expand All @@ -102,7 +102,7 @@ async fn send_register_validator(
};

// error here since we check if any success aboves
error!(?err, "failed registration");
error!(%err, "failed registration");
return Err(err);
};

Expand Down
4 changes: 2 additions & 2 deletions crates/pbs/src/mev_boost/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ async fn send_relay_check(relay: &RelayClient, headers: HeaderMap) -> Result<(),

let response_bytes = res.bytes().await?;
if response_bytes.len() > MAX_SIZE {
return Err(PbsError::PayloadTooLarge { payload_size: response_bytes.len() });
return Err(PbsError::PayloadTooLarge { max: MAX_SIZE, got: response_bytes.len() });
}
if !code.is_success() {
let err = PbsError::RelayResponse {
error_msg: String::from_utf8_lossy(&response_bytes).into_owned(),
code: code.as_u16(),
};

error!(?err, "status failed");
error!(%err, "status failed");
return Err(err);
};

Expand Down
15 changes: 12 additions & 3 deletions crates/pbs/src/mev_boost/submit_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ async fn send_submit_block(
let response_bytes = res.bytes().await?;

if response_bytes.len() > MAX_SIZE {
return Err(PbsError::PayloadTooLarge { payload_size: response_bytes.len() });
return Err(PbsError::PayloadTooLarge { max: MAX_SIZE, got: response_bytes.len() });
}
if !code.is_success() {
let err = PbsError::RelayResponse {
Expand All @@ -106,11 +106,20 @@ async fn send_submit_block(
};

// we request payload to all relays, but some may have not received it
warn!(?err, "failed to get payload (this might be ok if other relays have it)");
warn!(%err, "failed to get payload (this might be ok if other relays have it)");
return Err(err);
};

let block_response: SubmitBlindedBlockResponse = serde_json::from_slice(&response_bytes)?;
let block_response = match serde_json::from_slice::<SubmitBlindedBlockResponse>(&response_bytes)
{
Ok(parsed) => parsed,
Err(err) => {
return Err(PbsError::JsonDecode {
err,
raw: String::from_utf8_lossy(&response_bytes).into_owned(),
});
}
};

debug!(
latency = ?request_latency,
Expand Down
6 changes: 3 additions & 3 deletions crates/pbs/src/routes/register_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async fn send_relay_monitor_registrations(
{
Ok(res) => res,
Err(err) => {
error!(?err, "failed monitor registration");
error!(%err, "failed monitor registration");
return;
}
};
Expand All @@ -89,10 +89,10 @@ async fn send_relay_monitor_registrations(
debug!(?code, latency = ?request_latency, "relay monitor registration successful");
} else {
let err = String::from_utf8_lossy(&response_bytes);
error!(?code, ?err, "failed monitor registration");
error!(?code, %err, "failed monitor registration");
}
}

Err(err) => error!(?err, "failed to decode monitor response"),
Err(err) => error!(%err, "failed to decode monitor response"),
}
}
2 changes: 1 addition & 1 deletion crates/pbs/src/routes/submit_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub async fn handle_submit_block<S: BuilderApiState, A: BuilderApi<S>>(
relays: fault_relays,
});
} else {
error!(?err, %block_hash, "CRITICAL: no payload delivered and no relay for block hash. Was getHeader even called?");
error!(%err, %block_hash, "CRITICAL: no payload delivered and no relay for block hash. Was getHeader even called?");
state.publish_event(BuilderEvent::MissedPayload {
block_hash,
relays: String::default(),
Expand Down
5 changes: 2 additions & 3 deletions crates/pbs/src/service.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::net::SocketAddr;

use cb_common::constants::COMMIT_BOOST_VERSION;
use cb_metrics::provider::MetricsProvider;
use eyre::{Context, Result};
use prometheus::core::Collector;
Expand All @@ -15,14 +16,12 @@ use crate::{

pub struct PbsService;

// TODO: add ServerMaxHeaderBytes

impl PbsService {
pub async fn run<S: BuilderApiState, A: BuilderApi<S>>(state: PbsState<S>) -> Result<()> {
let address = SocketAddr::from(([0, 0, 0, 0], state.config.pbs_config.port));
let events_subs =
state.config.event_publisher.as_ref().map(|e| e.n_subscribers()).unwrap_or_default();
info!(?address, events_subs, chain =? state.config.chain, "Starting PBS service");
info!(version = COMMIT_BOOST_VERSION, ?address, events_subs, chain =? state.config.chain, "Starting PBS service");

let app = create_app_router::<S, A>(state);
let listener = TcpListener::bind(address).await.expect("failed tcp binding");
Expand Down
5 changes: 3 additions & 2 deletions crates/signer/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use cb_common::{
},
},
config::StartSignerConfig,
constants::COMMIT_BOOST_VERSION,
types::{Jwt, ModuleId},
};
use eyre::{Result, WrapErr};
Expand Down Expand Up @@ -50,7 +51,7 @@ impl SigningService {
let module_ids: Vec<String> =
config.jwts.left_values().cloned().map(Into::into).collect();

info!(modules =? module_ids, port =? config.server_port, "Starting signing service");
info!(version = COMMIT_BOOST_VERSION, modules =? module_ids, port =? config.server_port, "Starting signing service");
}

let mut manager = SigningManager::new(config.chain);
Expand All @@ -73,7 +74,7 @@ impl SigningService {
let listener = TcpListener::bind(address).await.wrap_err("failed tcp binding")?;

if let Err(err) = axum::serve(listener, app).await {
error!(?err, "Signing server exited")
error!(%err, "Signing server exited")
}
Ok(())
}
Expand Down
8 changes: 4 additions & 4 deletions docs/docs/developing/commit-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ sidebar_position: 2

# Commit Module

While a module can be written in any language, we currently provide some utils for Rust, with the goal of supporting more generalized APIs and simplify development in languages other than Rust.
While a module can be written in any language, we currently provide some utilities for Rust, with the goal of supporting more generalized APIs and simplify development in languages other than Rust.

:::note
Commit-Boost is still in alpha development, all APIs are subject to change
Expand All @@ -25,7 +25,7 @@ use commit_boost::prelude::*;
## Config
Your module will likely need a configuration for the Node Operator to customize. This will have to be in the `cb-config.toml` file, in the correct `[[module]]` section. In the module, you can define and load your config as follows.

First define all the parameters needed in a struct:
First, define all the parameters needed in a struct:
```rust
#[derive(Debug, Deserialize)]
struct ExtraConfig {
Expand Down Expand Up @@ -109,7 +109,7 @@ You can use the `prometheus` crate to create a custom registry and metrics, for

```rust
static ref MY_CUSTOM_REGISTRY: Registry = Registry::new_custom(Some("da_commit".to_string()), None).unwrap();
static ref SIG_RECEIVED_COUNTER: IntCounter = IntCounter::new("signature_received", "successful signatures requests received").unwrap();
static ref SIG_RECEIVED_COUNTER: IntCounter = IntCounter::new("signature_received", "successful signature requests received").unwrap();
```

### Start Metrics Provider
Expand All @@ -125,4 +125,4 @@ All that is left is to use the metrics throughout your code:
```rust
SIG_RECEIVED_COUNTER.inc();
```
These will automatically scraped by the Prometheus service running, and exposed on port `9090`. We plan to allow developers to ship pre-made dashboards together with their modules, to allow Node Operators to have an improved oversight on the modules they are running.
These will be automatically scraped by the Prometheus service running, and exposed on port `9090`. We plan to allow developers to ship pre-made dashboards together with their modules, to allow Node Operators to have an improved oversight on the modules they are running.
2 changes: 1 addition & 1 deletion docs/docs/get_started/running/binary.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ For loading keys we currently support:
- `CB_MODULE_ID`: required, unique id of the module

#### Commit modules
- `CB_SIGNER_URL`: requred, url to the signer module server
- `CB_SIGNER_URL`: required, url to the signer module server
- `CB_SIGNER_JWT`: required, jwt to use to for signature requests (needs to match what is in `CB_JWTS`)

#### Events modules
Expand Down
2 changes: 1 addition & 1 deletion examples/builder_log/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async fn main() -> eyre::Result<()> {
let client = BuilderEventClient::new(config.server_port, LogProcessor);

if let Err(err) = client.run().await {
error!(?err, "Service failed");
error!(%err, "Service failed");
}
}
Err(err) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/da_commit/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ async fn main() -> Result<()> {
let service = DaCommitService { config };

if let Err(err) = service.run().await {
error!(?err, "Service failed");
error!(%err, "Service failed");
}
}
Err(err) => {
Expand Down
33 changes: 0 additions & 33 deletions tests/src/main.rs

This file was deleted.