diff --git a/README.md b/README.md index b9d69f2..f60c7fc 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/lib.rs b/src/lib.rs index bd5ec67..e52d0e7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -43,6 +43,16 @@ use std::sync::OnceLock; /// Global static configuration for the Builder binary. pub static CONFIG: OnceLock = 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. /// @@ -51,7 +61,13 @@ pub static CONFIG: OnceLock = 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.