diff --git a/Cargo.lock b/Cargo.lock index d5cb2fa1..04b24e4f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2426,7 +2426,9 @@ dependencies = [ "backon", "eyre", "futures-util", + "git-version", "init4-bin-base", + "itertools 0.14.0", "openssl", "reqwest", "reth-chainspec", @@ -4187,6 +4189,26 @@ dependencies = [ "polyval", ] +[[package]] +name = "git-version" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad568aa3db0fcbc81f2f116137f263d7304f512a1209b35b85150d3ef88ad19" +dependencies = [ + "git-version-macro", +] + +[[package]] +name = "git-version-macro" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53010ccb100b96a67bc32c0175f0ed1426b31b655d562898e57325f81c023ac0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + [[package]] name = "git2" version = "0.20.4" @@ -4937,8 +4959,7 @@ dependencies = [ [[package]] name = "init4-bin-base" version = "0.18.0-rc.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68276e396fb82c74e041c90e8d7d1aec8dc4cf877e201a87dfd5a5a45cd31f38" +source = "git+https://github.com/init4tech/bin-base?branch=fraser%2Feng-1943%2Fvarious-updates#b9f9cad61b199ff278ffc4c6e9dbc348252de392" dependencies = [ "alloy", "async-trait", @@ -4946,6 +4967,7 @@ dependencies = [ "aws-sdk-kms", "axum 0.8.8", "chrono", + "eyre", "init4-from-env-derive", "metrics", "metrics-exporter-prometheus", @@ -4973,8 +4995,7 @@ dependencies = [ [[package]] name = "init4-from-env-derive" version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9c78527fcfeaecc9805e5736a7592a26ecad3b7845eb273c8c1710de0dbb0c" +source = "git+https://github.com/init4tech/bin-base?branch=fraser%2Feng-1943%2Fvarious-updates#b9f9cad61b199ff278ffc4c6e9dbc348252de392" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 1ecced31..c022f67a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,6 +50,8 @@ axum = "0.7.5" backon = { version = "1.6.0", features = ["tokio-sleep"] } eyre = "0.6.12" futures-util = "0.3.31" +git-version = "0.3.9" +itertools = "0.14.0" openssl = { version = "0.10", features = ["vendored"] } reqwest = { version = "0.12.22", features = ["blocking", "json"] } serde = { version = "1.0.197", features = ["derive"] } @@ -64,7 +66,7 @@ alloy-hardforks = "0.4.0" alloy-chains = "0.2" # comment / uncomment for local dev -# [patch.crates-io] +[patch.crates-io] # signet-constants = { path = "../signet-sdk/crates/constants" } # signet-types = { path = "../signet-sdk/crates/types" } # signet-zenith = { path = "../signet-sdk/crates/zenith" } @@ -74,4 +76,4 @@ alloy-chains = "0.2" # signet-journal = { path = "../signet-sdk/crates/journal" } # signet-tx-cache = { path = "../signet-sdk/crates/tx-cache" } # signet-bundle = { path = "../signet-sdk/crates/bundle" } -# init4-bin-base = { path = "../bin-base" } +init4-bin-base = { git = "https://github.com/init4tech/bin-base", branch = "fraser/eng-1943/various-updates" } diff --git a/bin/builder.rs b/bin/builder.rs index 1d41c6e8..8eefa4c9 100644 --- a/bin/builder.rs +++ b/bin/builder.rs @@ -1,23 +1,66 @@ #![recursion_limit = "256"] use builder::{ + config::{BuilderConfig, env_var_info}, service::serve_builder, tasks::{ block::sim::SimulatorTask, cache::CacheTasks, env::EnvTask, metrics::MetricsTask, submit::FlashbotsTask, }, }; -use init4_bin_base::deps::tracing::{info, info_span}; +use eyre::bail; +use git_version::git_version; +use init4_bin_base::{ + deps::tracing::{info, info_span}, + utils::from_env::FromEnv, +}; use tokio::select; +const GIT_COMMIT: &str = + git_version!(args = ["--always", "--match=", "--abbrev=7"], fallback = "unknown"); +const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); + +fn should_print_help() -> bool { + std::env::args().any(|arg| { + let lowercase_arg = arg.to_ascii_lowercase(); + lowercase_arg == "-h" || lowercase_arg == "--help" + }) +} + +fn print_help() { + let version = env!("CARGO_PKG_VERSION"); + let env_vars = env_var_info(); + println!( + r#"Signet block builder v{version} + +Run with no args. Configuration is via the following environment variables: +{env_vars} +"# + ) +} + // Note: Must be set to `multi_thread` to support async tasks. // See: https://docs.rs/tokio/latest/tokio/attr.main.html #[tokio::main(flavor = "multi_thread")] async fn main() -> eyre::Result<()> { - let _guard = init4_bin_base::init4(); + if should_print_help() { + print_help(); + return Ok(()); + } + + if let Err(e) = BuilderConfig::check_inventory() { + for item in e { + eprintln!("missing environment variable: {}: {}", item.var, item.description); + } + bail!( + "missing at least one required environment variable; run with '--help' to see the list" + ); + } + + let config = builder::config_from_env(); let init_span_guard = info_span!("builder initialization").entered(); - builder::config_from_env(); + info!(pkg_version = PKG_VERSION, git_commit = GIT_COMMIT, "starting builder"); // Pre-load the KZG settings in a separate thread. // @@ -45,7 +88,7 @@ async fn main() -> eyre::Result<()> { let build_jh = simulator_task.spawn_simulator_task(cache_system.sim_cache, submit_channel); // Start the healthcheck server - let server = serve_builder(([0, 0, 0, 0], builder::config().builder_port)); + let server = serve_builder(([0, 0, 0, 0], config.builder_port)); // We have finished initializing the builder, so we can drop the init span // guard. diff --git a/src/config.rs b/src/config.rs index 83156a24..8d338f2f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -3,7 +3,7 @@ use alloy::{ network::{Ethereum, EthereumWallet}, primitives::Address, providers::{ - self, Identity, ProviderBuilder, RootProvider, + Identity, ProviderBuilder, RootProvider, fillers::{ BlobGasFiller, ChainIdFiller, FillProvider, GasFiller, JoinFill, NonceFiller, SimpleNonceManager, WalletFiller, @@ -12,14 +12,18 @@ use alloy::{ }; use eyre::Result; use init4_bin_base::{ + Init4Config, perms::{Authenticator, OAuthConfig, SharedToken, pylon}, utils::{ calc::SlotCalculator, - from_env::FromEnv, + from_env::{EnvItemInfo, FromEnv, OptionalU8WithDefault, OptionalU64WithDefault}, + metrics::MetricsConfig, provider::{ProviderConfig, PubSubConfig}, signer::LocalOrAws, + tracing::TracingConfig, }, }; +use itertools::Itertools; use signet_constants::SignetSystemConstants; use signet_zenith::Zenith; use std::borrow::Cow; @@ -58,7 +62,7 @@ pub type FlashbotsProvider = FillProvider< >, WalletFiller, >, - providers::RootProvider, + RootProvider, >; /// The default concurrency limit for the builder if the system call @@ -145,7 +149,8 @@ pub struct BuilderConfig { /// The max number of simultaneous block simulations to run. #[from_env( var = "CONCURRENCY_LIMIT", - desc = "The max number of simultaneous block simulations to run" + desc = "The max number of simultaneous block simulations to run [default: std::thread::available_parallelism]", + optional )] pub concurrency_limit: Option, @@ -153,27 +158,27 @@ pub struct BuilderConfig { /// Defaults to 80% (80) if not set. #[from_env( var = "MAX_HOST_GAS_COEFFICIENT", - desc = "Optional maximum host gas coefficient, as a percentage, to use when building blocks", - default = 80 + desc = "Optional maximum host gas coefficient, as a percentage, to use when building blocks [default: 80]", + optional )] - pub max_host_gas_coefficient: Option, + pub max_host_gas_coefficient: OptionalU8WithDefault<80>, /// Number of milliseconds before the end of the slot to stop querying for new blocks and start the block signing and submission process. #[from_env( var = "BLOCK_QUERY_CUTOFF_BUFFER", - desc = "Number of milliseconds before the end of the slot to stop querying for new transactions and start the block signing and submission process. Quincey will stop accepting signature requests 2000ms before the end of the slot, so this buffer should be no less than 2000ms to match.", - default = 3000 + desc = "Number of milliseconds before the end of the slot to stop querying for new transactions and start the block signing and submission process. Quincey will stop accepting signature requests 2000ms before the end of the slot, so this buffer should be no less than 2000ms to match. [default: 3000]", + optional )] - pub block_query_cutoff_buffer: u64, + pub block_query_cutoff_buffer: OptionalU64WithDefault<3000>, /// Number of milliseconds before the end of the slot by which bundle submission to Flashbots must complete. /// If submission completes after this deadline, a warning is logged. #[from_env( var = "SUBMIT_DEADLINE_BUFFER", - desc = "Number of milliseconds before the end of the slot by which bundle submission must complete. Submissions that miss this deadline will be logged as warnings.", - default = 500 + desc = "Number of milliseconds before the end of the slot by which bundle submission must complete. Submissions that miss this deadline will be logged as warnings. [default: 500]", + optional )] - pub submit_deadline_buffer: u64, + pub submit_deadline_buffer: OptionalU64WithDefault<500>, /// The slot calculator for the builder. pub slot_calculator: SlotCalculator, @@ -184,6 +189,22 @@ pub struct BuilderConfig { /// URL for the Pylon blob server API. #[from_env(var = "PYLON_URL", desc = "URL for the Pylon blob server API")] pub pylon_url: url::Url, + + /// Tracing and OTEL configuration. + pub tracing: TracingConfig, + + /// Metrics configuration. + pub metrics: MetricsConfig, +} + +impl Init4Config for BuilderConfig { + fn tracing(&self) -> &TracingConfig { + &self.tracing + } + + fn metrics(&self) -> &MetricsConfig { + &self.metrics + } } impl BuilderConfig { @@ -266,7 +287,7 @@ impl BuilderConfig { } /// Get an oauth2 token for the builder, starting the authenticator if it - // is not already running. + /// is not already running. pub fn oauth_token(&self) -> SharedToken { static ONCE: std::sync::OnceLock = std::sync::OnceLock::new(); @@ -311,10 +332,9 @@ impl BuilderConfig { } /// Returns the maximum host gas to use for block building based on the configured max host gas coefficient. - pub fn max_host_gas(&self, gas_limit: u64) -> u64 { + pub const fn max_host_gas(&self, gas_limit: u64) -> u64 { // Set max host gas to a percentage of the host block gas limit - ((gas_limit as u128 * (self.max_host_gas_coefficient.unwrap_or(80) as u128)) / 100u128) - as u64 + ((gas_limit as u128 * self.max_host_gas_coefficient.into_inner() as u128) / 100u128) as u64 } /// Connect to the Pylon blob server. @@ -323,6 +343,31 @@ impl BuilderConfig { } } +/// Get a list of the env vars used to configure the app. +pub fn env_var_info() -> String { + // We need to remove the `SlotCalculator` env vars from the list. `SignetSystemConstants` + // already requires `CHAIN_NAME`, so we don't want to include `CHAIN_NAME` twice. That also + // means the other `SlotCalculator` env vars are ignored since `CHAIN_NAME` must be set. + let is_not_from_slot_calc = |env_item: &&EnvItemInfo| match env_item.var { + "CHAIN_NAME" if env_item.optional => false, + "START_TIMESTAMP" | "SLOT_OFFSET" | "SLOT_DURATION" => false, + _ => true, + }; + let inventory_iter = BuilderConfig::inventory().into_iter().filter(is_not_from_slot_calc); + let max_width = inventory_iter.clone().map(|env_item| env_item.var.len()).max().unwrap_or(0); + inventory_iter + .map(|env_item| { + format!( + " {:width$} {}{}", + env_item.var, + env_item.description, + if env_item.optional { " [optional]" } else { "" }, + width = max_width + ) + }) + .join("\n") +} + #[cfg(test)] mod tests { /// Tests that URL sanitization correctly handles trailing slashes for url.join() behavior. diff --git a/src/lib.rs b/src/lib.rs index fbe02fbc..dfb7245d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -34,26 +34,33 @@ pub mod utils; /// Test utilitites pub mod test_utils; -use init4_bin_base::utils::from_env::FromEnv; -// Anonymous import suppresses warnings about unused imports. +// Anonymous imports suppress warnings about unused crate dependencies. +use git_version as _; +use init4_bin_base::ConfigAndGuard; use openssl as _; use signet_constants::SignetSystemConstants; use std::sync::OnceLock; -/// Global static configuration for the Builder binary. -pub static CONFIG: OnceLock = OnceLock::new(); +/// Global static configuration and OTLP guard for the Builder binary. The +/// guard is kept alive for the lifetime of the process. +static CONFIG_AND_GUARD: OnceLock> = OnceLock::new(); -/// Load the Builder configuration from the environment and store it in the -/// global static CONFIG variable. Returns a reference to the configuration. +/// Load the Builder configuration from the environment, initialize tracing and +/// metrics, and store the config in the global static. Returns a reference to +/// the configuration. /// /// # Panics /// -/// Panics if the configuration cannot be loaded from the environment AND no -/// other configuration has been previously initialized. +/// Panics if the configuration cannot be loaded from the environment. pub fn config_from_env() -> &'static config::BuilderConfig { - CONFIG.get_or_init(|| { - config::BuilderConfig::from_env().expect("Failed to load Builder config").sanitize() - }) + &CONFIG_AND_GUARD + .get_or_init(|| { + let mut config_and_guard = init4_bin_base::init::() + .expect("Failed to load Builder config"); + config_and_guard.config = config_and_guard.config.sanitize(); + config_and_guard + }) + .config } /// Get a reference to the global Builder configuration. @@ -62,7 +69,7 @@ pub fn config_from_env() -> &'static config::BuilderConfig { /// /// Panics if the configuration has not been initialized. pub fn config() -> &'static config::BuilderConfig { - CONFIG.get().expect("Builder config not initialized") + &CONFIG_AND_GUARD.get().expect("Builder config not initialized").config } /// Get a reference to the Signet system constants from the global Builder diff --git a/src/tasks/block/sim.rs b/src/tasks/block/sim.rs index 4b4eee4e..4fd32e91 100644 --- a/src/tasks/block/sim.rs +++ b/src/tasks/block/sim.rs @@ -261,7 +261,7 @@ impl SimulatorTask { self.slot_calculator().current_point_within_slot_ms().expect("host chain has started"); let slot_duration = self.slot_calculator().slot_duration() * 1000; // convert to milliseconds - let query_cutoff_buffer = self.config.block_query_cutoff_buffer; + let query_cutoff_buffer = self.config.block_query_cutoff_buffer.into_inner(); // To find the remaining slot time, subtract the timepoint from the slot duration. // Then subtract the block query cutoff buffer from the slot duration to account for diff --git a/src/tasks/cache/bundle.rs b/src/tasks/cache/bundle.rs index e1d61726..3347db4c 100644 --- a/src/tasks/cache/bundle.rs +++ b/src/tasks/cache/bundle.rs @@ -1,6 +1,9 @@ //! Bundler service responsible for fetching bundles and sending them to the simulator. use crate::config::BuilderConfig; -use init4_bin_base::perms::tx_cache::{BuilderTxCache, BuilderTxCacheError}; +use init4_bin_base::{ + deps::metrics::{counter, histogram}, + perms::tx_cache::{BuilderTxCache, BuilderTxCacheError}, +}; use signet_tx_cache::{TxCacheError, types::CachedBundle}; use tokio::{ sync::mpsc::{UnboundedReceiver, UnboundedSender, unbounded_channel}, @@ -57,6 +60,8 @@ impl BundlePoller { match res { Ok(resp) => { let bundles = resp.into_inner(); + histogram!("signet.builder.cache.bundles_fetched") + .record(bundles.bundles.len() as f64); trace!(count = ?bundles.bundles.len(), "found bundles"); Ok(bundles.bundles) } @@ -64,6 +69,7 @@ impl BundlePoller { if matches!(&err, BuilderTxCacheError::TxCache(TxCacheError::NotOurSlot)) { trace!("Not our slot to fetch bundles"); } else { + counter!("signet.builder.cache.bundle_poll_errors").increment(1); error!(?err, "Failed to fetch bundles from tx-cache"); } Err(err) @@ -87,6 +93,7 @@ impl BundlePoller { // exit the span after the check. drop(_guard); + counter!("signet.builder.cache.bundle_poll_count").increment(1); if let Ok(bundles) = self.check_bundle_cache().instrument(span.clone()).await { for bundle in bundles.into_iter() { if let Err(err) = outbound.send(bundle) { diff --git a/src/tasks/cache/task.rs b/src/tasks/cache/task.rs index 1f9de1a7..74a1cd6f 100644 --- a/src/tasks/cache/task.rs +++ b/src/tasks/cache/task.rs @@ -1,12 +1,13 @@ use crate::tasks::env::SimEnv; use alloy::consensus::{TxEnvelope, transaction::SignerRecoverable}; +use init4_bin_base::deps::metrics::counter; use signet_sim::SimCache; use signet_tx_cache::types::CachedBundle; use tokio::{ sync::{mpsc, watch}, task::JoinHandle, }; -use tracing::{debug, info}; +use tracing::{debug, info, trace}; /// Cache task for the block builder. /// @@ -34,6 +35,8 @@ impl CacheTask { } async fn task_future(mut self, cache: SimCache) { + let mut skipped_bundle_count: u64 = 0; + loop { let mut basefee = 0; tokio::select! { @@ -48,6 +51,11 @@ impl CacheTask { let _guard = env.span().enter(); let sim_env = env.rollup_env(); + if skipped_bundle_count > 0 { + debug!(skipped_bundle_count, "skipped stale bundles for previous block"); + skipped_bundle_count = 0; + } + basefee = sim_env.basefee; info!( basefee, @@ -57,6 +65,7 @@ impl CacheTask { cache.clean( sim_env.number.to(), sim_env.timestamp.to() ); + counter!("signet.builder.cache.cache_cleans").increment(1); } } Some(bundle) = self.bundles.recv() => { @@ -68,21 +77,36 @@ impl CacheTask { // Don't insert bundles for past blocks if env_block > bundle_block { - debug!(env.block = env_block, bundle.block = bundle_block, "skipping bundle insert"); + trace!( + env.block = env_block, + bundle.block = bundle_block, + %bundle.id, + "skipping bundle insert" + ); + counter!("signet.builder.cache.bundles_skipped").increment(1); + skipped_bundle_count += 1; continue; } let res = cache.add_bundle(bundle.bundle, basefee); // Skip bundles that fail to be added to the cache if let Err(e) = res { + counter!("signet.builder.cache.bundle_add_errors").increment(1); debug!(?e, "Failed to add bundle to cache"); continue; } + counter!("signet.builder.cache.bundles_ingested").increment(1); } Some(txn) = self.txns.recv() => { match txn.try_into_recovered() { - Ok(recovered_tx) => cache.add_tx(recovered_tx, basefee), - Err(_) => debug!("Failed to recover transaction signature"), + Ok(recovered_tx) => { + cache.add_tx(recovered_tx, basefee); + counter!("signet.builder.cache.txs_ingested").increment(1); + } + Err(_) => { + counter!("signet.builder.cache.tx_recover_failures").increment(1); + debug!("Failed to recover transaction signature"); + } } } } diff --git a/src/tasks/cache/tx.rs b/src/tasks/cache/tx.rs index bc1efe29..ed9faea4 100644 --- a/src/tasks/cache/tx.rs +++ b/src/tasks/cache/tx.rs @@ -5,6 +5,7 @@ use alloy::{ providers::Provider, }; use eyre::Error; +use init4_bin_base::deps::metrics::{counter, histogram}; use reqwest::{Client, Url}; use serde::{Deserialize, Serialize}; use std::time::Duration; @@ -88,6 +89,7 @@ impl TxPoller { }; if tx.nonce() < tx_count { + counter!("signet.builder.cache.tx_nonce_stale").increment(1); span_debug!(span, %sender, tx_nonce = %tx.nonce(), ru_nonce = %tx_count, "Dropping transaction with stale nonce"); return; } @@ -123,12 +125,15 @@ impl TxPoller { break; } + counter!("signet.builder.cache.tx_poll_count").increment(1); if let Ok(transactions) = self.check_tx_cache().instrument(span.clone()).await.inspect_err(|err| { + counter!("signet.builder.cache.tx_poll_errors").increment(1); debug!(%err, "Error fetching transactions"); }) { let _guard = span.entered(); + histogram!("signet.builder.cache.txs_fetched").record(transactions.len() as f64); trace!(count = ?transactions.len(), "found transactions"); for tx in transactions.into_iter() { self.spawn_check_nonce(tx, outbound.clone()); diff --git a/src/tasks/submit/flashbots.rs b/src/tasks/submit/flashbots.rs index 177d2c3d..d9a5d1bd 100644 --- a/src/tasks/submit/flashbots.rs +++ b/src/tasks/submit/flashbots.rs @@ -224,7 +224,7 @@ impl FlashbotsTask { if let Err(err) = pylon.post_blob_tx(block_tx).await { counter!("signet.builder.pylon.submission_failures").increment(1); - error!(%err, "pylon submission failed"); + warn!(%err, "pylon submission failed"); return; } @@ -253,7 +253,7 @@ impl FlashbotsTask { slot_calculator.current_point_within_slot_ms().expect("host chain has started"); let slot_duration = slot_calculator.slot_duration() * 1000; // convert to milliseconds - let submit_buffer = self.config.submit_deadline_buffer; + let submit_buffer = self.config.submit_deadline_buffer.into_inner(); // To find the remaining slot time, subtract the timepoint from the slot duration. // Then subtract the submit deadline buffer to give us margin before slot ends. diff --git a/src/test_utils.rs b/src/test_utils.rs index 1512171e..733d6e32 100644 --- a/src/test_utils.rs +++ b/src/test_utils.rs @@ -6,60 +6,69 @@ use alloy::{ rpc::client::BuiltInConnectionString, signers::{SignerSync, local::PrivateKeySigner}, }; +use core::str::FromStr; use eyre::Result; use init4_bin_base::{ + ConfigAndGuard, deps::tracing_subscriber::{ EnvFilter, Layer, fmt, layer::SubscriberExt, registry, util::SubscriberInitExt, }, perms::OAuthConfig, - utils::{calc::SlotCalculator, provider::ProviderConfig}, + utils::{ + calc::SlotCalculator, metrics::MetricsConfig, provider::ProviderConfig, + tracing::TracingConfig, + }, }; use signet_constants::SignetSystemConstants; use std::env; -use std::str::FromStr; use trevm::revm::{context::BlockEnv, context_interface::block::BlobExcessGasAndPrice}; /// Set up a block builder with test values pub fn setup_test_config() -> &'static BuilderConfig { - crate::CONFIG.get_or_init(|| { - BuilderConfig { - host_rpc: "ws://host-rpc.pecorino.signet.sh" - .parse::() - .map(ProviderConfig::new) - .unwrap(), - ru_rpc: "ws://rpc.pecorino.signet.sh" - .parse::() - .unwrap() - .try_into() - .unwrap(), - flashbots_endpoint: "https://relay-sepolia.flashbots.net:443".parse().unwrap(), - quincey_url: "http://localhost:8080".into(), - sequencer_key: None, - builder_key: env::var("SEPOLIA_ETH_PRIV_KEY") - .unwrap_or_else(|_| B256::repeat_byte(0x42).to_string()), - builder_port: 8080, - builder_rewards_address: Address::default(), - rollup_block_gas_limit: 3_000_000_000, - tx_pool_url: "http://localhost:9000/".parse().unwrap(), - oauth: OAuthConfig { - oauth_client_id: "some_client_id".into(), - oauth_client_secret: "some_client_secret".into(), - oauth_authenticate_url: "http://localhost:8080".parse().unwrap(), - oauth_token_url: "http://localhost:8080".parse().unwrap(), - oauth_token_refresh_interval: 300, // 5 minutes - }, - concurrency_limit: None, // NB: Defaults to available parallelism - slot_calculator: SlotCalculator::new( - 1740681556, // pecorino start timestamp as sane default - 0, 1, - ), - block_query_cutoff_buffer: 3000, - submit_deadline_buffer: 500, - max_host_gas_coefficient: Some(80), - constants: SignetSystemConstants::parmigiana(), - pylon_url: "http://localhost:8081".parse().unwrap(), - } - }) + &crate::CONFIG_AND_GUARD + .get_or_init(|| { + let config = BuilderConfig { + host_rpc: "ws://host-rpc.pecorino.signet.sh" + .parse::() + .map(ProviderConfig::new) + .unwrap(), + ru_rpc: "ws://rpc.pecorino.signet.sh" + .parse::() + .unwrap() + .try_into() + .unwrap(), + flashbots_endpoint: "https://relay-sepolia.flashbots.net:443".parse().unwrap(), + quincey_url: "http://localhost:8080".into(), + sequencer_key: None, + builder_key: env::var("SEPOLIA_ETH_PRIV_KEY") + .unwrap_or_else(|_| B256::repeat_byte(0x42).to_string()), + builder_port: 8080, + builder_rewards_address: Address::default(), + rollup_block_gas_limit: 3_000_000_000, + tx_pool_url: "http://localhost:9000/".parse().unwrap(), + oauth: OAuthConfig { + oauth_client_id: "some_client_id".into(), + oauth_client_secret: "some_client_secret".into(), + oauth_authenticate_url: "http://localhost:8080".parse().unwrap(), + oauth_token_url: "http://localhost:8080".parse().unwrap(), + oauth_token_refresh_interval: 300, // 5 minutes + }, + concurrency_limit: None, // NB: Defaults to available parallelism + slot_calculator: SlotCalculator::new( + 1740681556, // pecorino start timestamp as sane default + 0, 1, + ), + block_query_cutoff_buffer: Default::default(), + submit_deadline_buffer: Default::default(), + max_host_gas_coefficient: Default::default(), + constants: SignetSystemConstants::parmigiana(), + pylon_url: "http://localhost:8081".parse().unwrap(), + tracing: TracingConfig::default(), + metrics: MetricsConfig::default(), + }; + ConfigAndGuard { config, guard: None } + }) + .config } /// Returns a new signed test transaction with the provided nonce, value, and mpfpg.