Skip to content

feat: BlockExtractorConfig #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 1, 2025
Merged
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
1 change: 1 addition & 0 deletions crates/blobber/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ reth.workspace = true
reth-chainspec.workspace = true
reth-transaction-pool = { workspace = true, optional = true }

serde.workspace = true
smallvec.workspace = true
tokio.workspace = true
tracing.workspace = true
Expand Down
16 changes: 15 additions & 1 deletion crates/blobber/src/builder.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::block_data::BlockExtractor;
use crate::{block_data::BlockExtractor, BlockExtractorConfig};
use init4_bin_base::utils::calc::SlotCalculator;
use reth::transaction_pool::TransactionPool;
use url::Url;
Expand Down Expand Up @@ -59,6 +59,20 @@ impl<Pool> BlockExtractorBuilder<Pool> {
self.with_pool(reth_transaction_pool::test_utils::testing_pool())
}

/// Set the configuration for the CL url, pylon url, from the provided
/// [`BlockExtractorConfig`].
pub fn with_config(self, config: &BlockExtractorConfig) -> Result<Self, BuilderError> {
let this = self.with_explorer_url(config.blob_explorer_url());
let this =
if let Some(cl_url) = config.cl_url() { this.with_cl_url(cl_url)? } else { this };

if let Some(pylon_url) = config.pylon_url() {
this.with_pylon_url(pylon_url)
} else {
Ok(this)
}
}

/// Set the blob explorer URL to use for the extractor. This will be used
/// to construct a [`foundry_blob_explorers::Client`].
pub fn with_explorer_url(mut self, explorer_url: &str) -> Self {
Expand Down
36 changes: 36 additions & 0 deletions crates/blobber/src/config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use init4_bin_base::utils::from_env::FromEnv;
use std::borrow::Cow;

/// Configuration for the block extractor.
#[derive(Debug, Clone, serde::Deserialize, FromEnv)]
#[serde(rename_all = "camelCase")]
pub struct BlockExtractorConfig {
/// URL of the blob explorer.
#[from_env(var = "BLOB_EXPLORER_URL", desc = "URL of the blob explorer", infallible)]
blob_explorer_url: Cow<'static, str>,

/// Consensus layer RPC URL
#[from_env(var = "SIGNET_CL_URL", desc = "Consensus layer URL", infallible, optional)]
cl_url: Option<Cow<'static, str>>,

/// The Pylon node URL
#[from_env(var = "SIGNET_PYLON_URL", desc = "Pylon node URL", infallible, optional)]
pylon_url: Option<Cow<'static, str>>,
}

impl BlockExtractorConfig {
/// Create a new `BlockExtractorConfig` with the provided CL URL, Pylon URL,
pub fn cl_url(&self) -> Option<&str> {
self.cl_url.as_deref()
}

/// Get the Pylon URL.
pub fn pylon_url(&self) -> Option<&str> {
self.pylon_url.as_deref()
}

/// Get the blob explorer URL.
pub fn blob_explorer_url(&self) -> &str {
&self.blob_explorer_url
}
}
3 changes: 3 additions & 0 deletions crates/blobber/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ pub use block_data::{Blobs, BlockExtractor};
mod builder;
pub use builder::BlockExtractorBuilder;

mod config;
pub use config::BlockExtractorConfig;

mod error;
pub use error::{BlockExtractionError, ExtractionResult};

Expand Down