From 5baeb5100b571aec12bd73acff2db74b80364a4b Mon Sep 17 00:00:00 2001 From: thedevbirb Date: Tue, 22 Oct 2024 10:40:51 +0200 Subject: [PATCH] chore(sidecar): review CLI options and their defaults --- bolt-sidecar/src/config/chain.rs | 30 ++++++++++++++++++++++-------- bolt-sidecar/src/config/mod.rs | 14 ++++++++------ 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/bolt-sidecar/src/config/chain.rs b/bolt-sidecar/src/config/chain.rs index 4ce4f88a6..98edb7248 100644 --- a/bolt-sidecar/src/config/chain.rs +++ b/bolt-sidecar/src/config/chain.rs @@ -1,4 +1,5 @@ -use std::time::Duration; +use core::fmt; +use std::{fmt::Display, time::Duration}; use clap::{Args, ValueEnum}; use ethereum_consensus::deneb::{compute_fork_data_root, Root}; @@ -25,7 +26,7 @@ pub const COMMIT_BOOST_DOMAIN_MASK: [u8; 4] = [109, 109, 111, 67]; #[derive(Debug, Clone, Copy, Args, Deserialize)] pub struct ChainConfig { /// Chain on which the sidecar is running - #[clap(long, env = "BOLT_SIDECAR_CHAIN", default_value = "mainnet")] + #[clap(long, env = "BOLT_SIDECAR_CHAIN", default_value_t = Chain::Mainnet)] chain: Chain, /// The deadline in the slot at which the sidecar will stop accepting /// new commitments for the next block (parsed as milliseconds). @@ -65,6 +66,24 @@ pub enum Chain { Kurtosis, } +impl Chain { + /// Get the chain name for the given chain. + pub fn name(&self) -> &'static str { + match self { + Chain::Mainnet => "mainnet", + Chain::Holesky => "holesky", + Chain::Helder => "helder", + Chain::Kurtosis => "kurtosis", + } + } +} + +impl Display for Chain { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", self.name()) + } +} + impl ChainConfig { /// Get the chain ID for the given chain. pub fn chain_id(&self) -> u64 { @@ -78,12 +97,7 @@ impl ChainConfig { /// Get the chain name for the given chain. pub fn name(&self) -> &'static str { - match self.chain { - Chain::Mainnet => "mainnet", - Chain::Holesky => "holesky", - Chain::Helder => "helder", - Chain::Kurtosis => "kurtosis", - } + self.chain.name() } /// Get the slot time for the given chain in seconds. diff --git a/bolt-sidecar/src/config/mod.rs b/bolt-sidecar/src/config/mod.rs index fcade3aee..1b9e64b76 100644 --- a/bolt-sidecar/src/config/mod.rs +++ b/bolt-sidecar/src/config/mod.rs @@ -23,11 +23,13 @@ use limits::LimitsOpts; use crate::common::{BlsSecretKeyWrapper, EcdsaSecretKeyWrapper, JwtSecretConfig}; -/// Default port for the JSON-RPC server exposed by the sidecar. -pub const DEFAULT_RPC_PORT: u16 = 8000; +/// Default port for the JSON-RPC server exposed by the sidecar supporting the Commitments API. +/// +/// 8017 -> BOLT :) +pub const DEFAULT_RPC_PORT: u16 = 8017; -/// Default port for the Constraints proxy server. -pub const DEFAULT_CONSTRAINTS_PROXY_PORT: u16 = 18551; +/// Default port for the Constraints proxy server, binded to the default port used by MEV-Boost. +pub const DEFAULT_CONSTRAINTS_PROXY_PORT: u16 = 18550; /// Command-line options for the Bolt sidecar #[derive(Debug, Parser, Deserialize)] @@ -52,7 +54,7 @@ pub struct Opts { #[clap( long, env = "BOLT_SIDECAR_CONSTRAINTS_API_URL", - default_value = "http://localhost:3030" + default_value = "http://localhost:18551" )] pub constraints_api_url: Url, /// The port from which the Bolt sidecar will receive Builder-API requests from the @@ -68,7 +70,7 @@ pub struct Opts { /// - a comma-separated list of indexes (e.g. "1,2,3,4") /// - a contiguous range of indexes (e.g. "1..4") /// - a mix of the above (e.g. "1,2..4,6..8") - #[clap(long, env = "BOLT_SIDECAR_VALIDATOR_INDEXES", default_value_t)] + #[clap(long, env = "BOLT_SIDECAR_VALIDATOR_INDEXES")] pub validator_indexes: ValidatorIndexes, /// The JWT secret token to authenticate calls to the engine API. ///