Skip to content
Open
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
11 changes: 0 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["benches/*", "bin", "crates/*", "examples/builder_log", "examples/da_commit", "examples/status_api", "tests"]
members = ["benches/*", "bin", "crates/*", "examples/da_commit", "examples/status_api", "tests"]
resolver = "2"

[workspace.package]
Expand Down
1 change: 0 additions & 1 deletion bin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ pub mod prelude {
load_builder_module_config, load_commit_module_config, load_pbs_config,
load_pbs_custom_config, LogsSettings, StartCommitModuleConfig, PBS_MODULE_NAME,
},
pbs::{BuilderEvent, BuilderEventClient, OnBuilderApiEvent},
signer::EcdsaSignature,
types::{BlsPublicKey, BlsSignature, Chain},
utils::{initialize_tracing_log, utcnow_ms, utcnow_ns, utcnow_sec, utcnow_us},
Expand Down
5 changes: 2 additions & 3 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -241,15 +241,14 @@ proxy_dir = "./proxies"
# secrets_path = "./tests/data/proxy/secrets"

# Commit-Boost can optionally run "modules" which extend the capabilities of the sidecar.
# Currently, two types of modules are supported:
# Currently, one type of module is supported:
# - "commit": modules which request commitment signatures from the validator keys
# - "events": modules which callback to BuilderAPI events as triggered from the PBS modules, used e.g. for monitoring
# If any "commit" module is present, then the [signer] section should also be configured
# OPTIONAL
[[modules]]
# Unique ID of the module
id = "DA_COMMIT"
# Type of the module. Supported values: commit, events
# Type of the module. Supported values: commit
type = "commit"
# Docker image of the module
docker_image = "test_da_commit"
Expand Down
79 changes: 9 additions & 70 deletions crates/cli/src/docker_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ use std::{

use cb_common::{
config::{
CommitBoostConfig, LogsSettings, ModuleKind, SignerConfig, SignerType, BUILDER_PORT_ENV,
BUILDER_URLS_ENV, CHAIN_SPEC_ENV, CONFIG_DEFAULT, CONFIG_ENV, DIRK_CA_CERT_DEFAULT,
DIRK_CA_CERT_ENV, DIRK_CERT_DEFAULT, DIRK_CERT_ENV, DIRK_DIR_SECRETS_DEFAULT,
DIRK_DIR_SECRETS_ENV, DIRK_KEY_DEFAULT, DIRK_KEY_ENV, JWTS_ENV, LOGS_DIR_DEFAULT,
LOGS_DIR_ENV, METRICS_PORT_ENV, MODULE_ID_ENV, MODULE_JWT_ENV, PBS_ENDPOINT_ENV,
PBS_MODULE_NAME, PROXY_DIR_DEFAULT, PROXY_DIR_ENV, PROXY_DIR_KEYS_DEFAULT,
PROXY_DIR_KEYS_ENV, PROXY_DIR_SECRETS_DEFAULT, PROXY_DIR_SECRETS_ENV, SIGNER_DEFAULT,
SIGNER_DIR_KEYS_DEFAULT, SIGNER_DIR_KEYS_ENV, SIGNER_DIR_SECRETS_DEFAULT,
SIGNER_DIR_SECRETS_ENV, SIGNER_ENDPOINT_ENV, SIGNER_KEYS_ENV, SIGNER_MODULE_NAME,
SIGNER_PORT_DEFAULT, SIGNER_URL_ENV,
CommitBoostConfig, LogsSettings, ModuleKind, SignerConfig, SignerType, CHAIN_SPEC_ENV,
CONFIG_DEFAULT, CONFIG_ENV, DIRK_CA_CERT_DEFAULT, DIRK_CA_CERT_ENV, DIRK_CERT_DEFAULT,
DIRK_CERT_ENV, DIRK_DIR_SECRETS_DEFAULT, DIRK_DIR_SECRETS_ENV, DIRK_KEY_DEFAULT,
DIRK_KEY_ENV, JWTS_ENV, LOGS_DIR_DEFAULT, LOGS_DIR_ENV, METRICS_PORT_ENV, MODULE_ID_ENV,
MODULE_JWT_ENV, PBS_ENDPOINT_ENV, PBS_MODULE_NAME, PROXY_DIR_DEFAULT, PROXY_DIR_ENV,
PROXY_DIR_KEYS_DEFAULT, PROXY_DIR_KEYS_ENV, PROXY_DIR_SECRETS_DEFAULT,
PROXY_DIR_SECRETS_ENV, SIGNER_DEFAULT, SIGNER_DIR_KEYS_DEFAULT, SIGNER_DIR_KEYS_ENV,
SIGNER_DIR_SECRETS_DEFAULT, SIGNER_DIR_SECRETS_ENV, SIGNER_ENDPOINT_ENV, SIGNER_KEYS_ENV,
SIGNER_MODULE_NAME, SIGNER_PORT_DEFAULT, SIGNER_URL_ENV,
},
pbs::{BUILDER_V1_API_PATH, GET_STATUS_PATH},
signer::{ProxyStore, SignerLoader},
Expand Down Expand Up @@ -81,9 +80,6 @@ pub async fn handle_docker_init(config_path: PathBuf, output_dir: PathBuf) -> Re
format!("http://cb_signer:{signer_port}")
};

let builder_events_port = 30000;
let mut builder_events_modules = Vec::new();

let mut warnings = Vec::new();

let needs_signer_module = cb_config.pbs.with_signer ||
Expand Down Expand Up @@ -185,58 +181,6 @@ pub async fn handle_docker_init(config_path: PathBuf, output_dir: PathBuf) -> Re
..Service::default()
}
}
// an event module just needs a port to listen on
ModuleKind::Events => {
let mut ports = vec![];
builder_events_modules
.push(format!("http://{module_cid}:{builder_events_port}"));

// module ids are assumed unique, so envs dont override each other
let mut module_envs = IndexMap::from([
get_env_val(MODULE_ID_ENV, &module.id),
get_env_val(CONFIG_ENV, CONFIG_DEFAULT),
get_env_uval(BUILDER_PORT_ENV, builder_events_port),
]);

if let Some((key, val)) = chain_spec_env.clone() {
module_envs.insert(key, val);
}
if let Some(metrics_config) = &cb_config.metrics {
if metrics_config.enabled {
let host_endpoint =
SocketAddr::from((metrics_config.host, metrics_port));
ports.push(format!("{}:{}", host_endpoint, metrics_port));
warnings.push(format!(
"{} has an exported port on {}",
module_cid, metrics_port
));
targets.push(format!("{host_endpoint}"));
let (key, val) = get_env_uval(METRICS_PORT_ENV, metrics_port as u64);
module_envs.insert(key, val);

metrics_port += 1;
}
}
if log_to_file {
let (key, val) = get_env_val(LOGS_DIR_ENV, LOGS_DIR_DEFAULT);
module_envs.insert(key, val);
}

// volumes
let mut module_volumes = vec![config_volume.clone()];
module_volumes.extend(chain_spec_volume.clone());
module_volumes.extend(get_log_volume(&cb_config.logs, &module.id));

Service {
container_name: Some(module_cid.clone()),
image: Some(module.docker_image),
ports: Ports::Short(ports),
volumes: module_volumes,
environment: Environment::KvPair(module_envs),
depends_on: DependsOnOptions::Simple(vec!["cb_pbs".to_owned()]),
..Service::default()
}
}
};

services.insert(module_cid, Some(module_service));
Expand Down Expand Up @@ -283,11 +227,6 @@ pub async fn handle_docker_init(config_path: PathBuf, output_dir: PathBuf) -> Re
let (key, val) = get_env_val(LOGS_DIR_ENV, LOGS_DIR_DEFAULT);
pbs_envs.insert(key, val);
}
if !builder_events_modules.is_empty() {
let env = builder_events_modules.join(",");
let (k, v) = get_env_val(BUILDER_URLS_ENV, &env);
pbs_envs.insert(k, v);
}

// inside the container expose on 0.0.0.0
let container_endpoint =
Expand Down
7 changes: 0 additions & 7 deletions crates/common/src/config/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ pub const LOGS_DIR_DEFAULT: &str = "/var/logs/commit-boost";
pub const PBS_IMAGE_DEFAULT: &str = "ghcr.io/commit-boost/pbs:latest";
pub const PBS_MODULE_NAME: &str = "pbs";

/// Urls the pbs modules should post events to (comma separated)
pub const BUILDER_URLS_ENV: &str = "CB_BUILDER_URLS";

/// Where to receive BuilderAPI calls from beacon node
pub const PBS_ENDPOINT_ENV: &str = "CB_PBS_ENDPOINT";

Expand Down Expand Up @@ -95,7 +92,3 @@ pub const MODULE_ID_ENV: &str = "CB_MODULE_ID";
pub const MODULE_JWT_ENV: &str = "CB_SIGNER_JWT";
/// Where to send signature request
pub const SIGNER_URL_ENV: &str = "CB_SIGNER_URL";

/// Events modules
/// Where to receive builder events
pub const BUILDER_PORT_ENV: &str = "CB_BUILDER_PORT";
7 changes: 0 additions & 7 deletions crates/common/src/config/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use crate::{
constants::{CONFIG_ENV, MODULE_ID_ENV, MODULE_JWT_ENV, SIGNER_URL_ENV},
load_env_var,
utils::load_file_from_env,
BUILDER_PORT_ENV,
},
types::{Chain, Jwt, ModuleId},
};
Expand All @@ -19,8 +18,6 @@ use crate::{
pub enum ModuleKind {
#[serde(alias = "commit")]
Commit,
#[serde(alias = "events")]
Events,
}

/// Static module config from config file
Expand Down Expand Up @@ -120,16 +117,13 @@ pub struct StartBuilderModuleConfig<T> {
pub id: ModuleId,
/// Chain spec
pub chain: Chain,
/// Where to listen for Builder events
pub server_port: u16,
/// Opaque module config
pub extra: T,
}

pub fn load_builder_module_config<T: DeserializeOwned>() -> eyre::Result<StartBuilderModuleConfig<T>>
{
let module_id = ModuleId(load_env_var(MODULE_ID_ENV)?);
let builder_events_port: u16 = load_env_var(BUILDER_PORT_ENV)?.parse()?;

#[derive(Debug, Deserialize)]
struct ThisModuleConfig<U> {
Expand Down Expand Up @@ -176,7 +170,6 @@ pub fn load_builder_module_config<T: DeserializeOwned>() -> eyre::Result<StartBu
Ok(StartBuilderModuleConfig {
id: module_config.static_config.id,
chain: cb_config.chain,
server_port: builder_events_port,
extra: module_config.extra,
})
}
10 changes: 2 additions & 8 deletions crates/common/src/config/pbs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ use crate::{
SIGNER_URL_ENV,
},
pbs::{
BuilderEventPublisher, DefaultTimeout, RelayClient, RelayEntry, DEFAULT_PBS_PORT,
LATE_IN_SLOT_TIME_MS, REGISTER_VALIDATOR_RETRY_LIMIT,
DefaultTimeout, RelayClient, RelayEntry, DEFAULT_PBS_PORT, LATE_IN_SLOT_TIME_MS,
REGISTER_VALIDATOR_RETRY_LIMIT,
},
types::{BlsPublicKey, Chain, Jwt, ModuleId},
utils::{
Expand Down Expand Up @@ -213,8 +213,6 @@ pub struct PbsModuleConfig {
pub all_relays: Vec<RelayClient>,
/// Signer client to call Signer API
pub signer_client: Option<SignerClient>,
/// Event publisher
pub event_publisher: Option<BuilderEventPublisher>,
/// Muxes config
pub muxes: Option<HashMap<BlsPublicKey, RuntimeMuxConfig>>,
}
Expand Down Expand Up @@ -253,7 +251,6 @@ pub async fn load_pbs_config() -> Result<PbsModuleConfig> {

let relay_clients =
config.relays.into_iter().map(RelayClient::new).collect::<Result<Vec<_>>>()?;
let maybe_publiher = BuilderEventPublisher::new_from_env()?;
let mut all_relays = HashMap::with_capacity(relay_clients.len());

if let Some(muxes) = &muxes {
Expand Down Expand Up @@ -281,7 +278,6 @@ pub async fn load_pbs_config() -> Result<PbsModuleConfig> {
relays: relay_clients,
all_relays,
signer_client: None,
event_publisher: maybe_publiher,
muxes,
})
}
Expand Down Expand Up @@ -329,7 +325,6 @@ pub async fn load_pbs_custom_config<T: DeserializeOwned>() -> Result<(PbsModuleC

let relay_clients =
cb_config.relays.into_iter().map(RelayClient::new).collect::<Result<Vec<_>>>()?;
let maybe_publiher = BuilderEventPublisher::new_from_env()?;
let mut all_relays = HashMap::with_capacity(relay_clients.len());

if let Some(muxes) = &muxes {
Expand Down Expand Up @@ -371,7 +366,6 @@ pub async fn load_pbs_custom_config<T: DeserializeOwned>() -> Result<(PbsModuleC
relays: relay_clients,
all_relays,
signer_client,
event_publisher: maybe_publiher,
muxes,
},
cb_config.pbs.extra,
Expand Down
1 change: 0 additions & 1 deletion crates/common/src/pbs/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ pub const HEADER_VERSION_KEY: &str = "X-CommitBoost-Version";
pub const HEADER_VERSION_VALUE: &str = COMMIT_BOOST_VERSION;
pub const HEADER_START_TIME_UNIX_MS: &str = "Date-Milliseconds";

pub const BUILDER_EVENTS_PATH: &str = "/builder_events";
pub const DEFAULT_PBS_JWT_KEY: &str = "DEFAULT_PBS";

pub const DEFAULT_PBS_PORT: u16 = 18550;
Expand Down
Loading
Loading