Skip to content
Closed
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Key | Required | Description
`ROLLUP_RPC_URL` | Yes | RPC endpoint for the rollup chain
`QUINCEY_URL` | Yes | Remote sequencer signing endpoint
`SEQUENCER_KEY` | No | AWS Key ID _OR_ local private key for the Sequencer; set IFF using local Sequencer signing instead of remote (via `QUINCEY_URL`) Quincey signing
`TX_POOL_URL` | Yes | Transaction pool URL (must end with `/`)
`TX_POOL_URL` | Yes | Transaction pool URL
`FLASHBOTS_ENDPOINT` | No | Flashbots API to submit blocks to
`ROLLUP_BLOCK_GAS_LIMIT` | No | Override for rollup block gas limit
`MAX_HOST_GAS_COEFFICIENT` | No | Optional maximum host gas coefficient, as a percentage, to use when building blocks
Expand Down
18 changes: 17 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ use std::sync::OnceLock;
/// Global static configuration for the Builder binary.
pub static CONFIG: OnceLock<config::BuilderConfig> = OnceLock::new();

/// Ensures a URL has a trailing slash, which is required for correct behavior
/// with `Url::join()`. Without a trailing slash, `join()` replaces the last
/// path segment instead of appending to it.
fn ensure_trailing_slash(url: &mut url::Url) {
let path = url.path();
if !path.ends_with('/') {
url.set_path(&format!("{}/", path));
}
}

/// Load the Builder configuration from the environment and store it in the
/// global static CONFIG variable. Returns a reference to the configuration.
///
Expand All @@ -51,7 +61,13 @@ pub static CONFIG: OnceLock<config::BuilderConfig> = OnceLock::new();
/// Panics if the configuration cannot be loaded from the environment AND no
/// other configuration has been previously initialized.
pub fn config_from_env() -> &'static config::BuilderConfig {
CONFIG.get_or_init(|| config::BuilderConfig::from_env().expect("Failed to load Builder config"))
CONFIG.get_or_init(|| {
let mut config =
config::BuilderConfig::from_env().expect("Failed to load Builder config");
// Sanitize tx_pool_url to ensure it ends with `/` for correct Url::join() behavior
ensure_trailing_slash(&mut config.tx_pool_url);
config
})
}

/// Get a reference to the global Builder configuration.
Expand Down
Loading