Skip to content
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
44 changes: 26 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,32 @@
A collection of components for building the Signet node. These components
implement core node functionality, but are potentially indepedently useful.

### What's new in Signet?
## What's in the Components?

- **signet-node-types** - Shim types wrapping reth's internal node types
system to make it more usable in Signet.
- **signet-blobber** - Blob retrieval and parsing, using blob explorers,
Signet's Pylon, and the local node transaction API.
- **signet-rpc** - An Ethereum JSON-RPC Server for Signet nodes. Makes heavy
use of reth internals.
- **signet-db** - An extension of reth's database, providing a Signet-specific
database schema and utilities for working with Signet blocks and transactions.

### Contributing to the Node Components

Please see [CONTRIBUTING.md](CONTRIBUTING.md).

[Signet docs]: https://docs.signet.sh

## Note on Semver

This repo is UNPUBLISHED and may NOT respect semantic versioning between tagged
versions. In general, it is versioned to match the signet-sdk version with
which it is compatible. I.e. `node-components@0.8.x` is expected to be
compatible with any signet-sdk `0.8.x` version. However, a release of
`node-components@0.8.1` may have breaking changes from `node-components@0.8.0`.

## What's new in Signet?

Signet is a pragmatic Ethereum rollup that offers a new set of ideas and aims
to radically modernize rollup technology.
Expand All @@ -22,20 +47,3 @@ knowledge. Signet does not have a native token.
Signet is just a rollup.

See the [Signet docs] for more info.

### What's in the Components?

- **signet-node-types** - Shim types wrapping reth's internal node types
system to make it more usable in Signet.
- **signet-blobber** - Blob retrieval and parsing, using blob explorers,
Signet's Pylon, and the local node transaction API.
- **signet-rpc** - An Ethereum JSON-RPC Server for Signet nodes. Makes heavy
use of reth internals.
- **signet-db** - An extension of reth's database, providing a Signet-specific
database schema and utilities for working with Signet blocks and transactions.

### Contributing to the Node Components

Please see [CONTRIBUTING.md](CONTRIBUTING.md).

[Signet docs]: https://docs.signet.sh
6 changes: 5 additions & 1 deletion crates/blobber/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Block Extractor

The [`BlockExtractor`] retrieves blobs from host chain blocks and parses them
The [`BlobFetcher`] retrieves blobs from host chain blocks and parses them
into [`ZenithBlock`]s. It is used by the node during notification processing
when a [`Zenith::BlockSubmitted`] event is extracted from a host chain block.

The [`BlobCacher`] is a wrapper around the [`BlobFetcher`] that caches
blobs in an in-memory cache. It is used to avoid fetching the same blob and to
manage retry logic during fetching.

## Data Sources

The following sources can be configured:
Expand Down
45 changes: 26 additions & 19 deletions crates/blobber/src/builder.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::{BlockExtractorConfig, block_data::BlockExtractor};
use crate::{BlobCacher, BlobFetcher, BlobFetcherConfig};
use init4_bin_base::utils::calc::SlotCalculator;
use reth::transaction_pool::TransactionPool;
use url::Url;

/// Errors that can occur while building the [`BlockExtractor`] with a
/// [`BlockExtractorBuilder`].
/// Errors that can occur while building the [`BlobFetcher`] with a
/// [`BlobFetcherBuilder`].
#[derive(Debug, thiserror::Error)]
pub enum BuilderError {
/// The transaction pool was not provided.
Expand All @@ -27,9 +27,9 @@ pub enum BuilderError {
MissingSlotCalculator,
}

/// Builder for the [`BlockExtractor`].
/// Builder for the [`BlobFetcher`].
#[derive(Debug, Default, Clone)]
pub struct BlockExtractorBuilder<Pool> {
pub struct BlobFetcherBuilder<Pool> {
pool: Option<Pool>,
explorer_url: Option<String>,
client: Option<reqwest::Client>,
Expand All @@ -38,10 +38,10 @@ pub struct BlockExtractorBuilder<Pool> {
slot_calculator: Option<SlotCalculator>,
}

impl<Pool> BlockExtractorBuilder<Pool> {
impl<Pool> BlobFetcherBuilder<Pool> {
/// Set the transaction pool to use for the extractor.
pub fn with_pool<P2>(self, pool: P2) -> BlockExtractorBuilder<P2> {
BlockExtractorBuilder {
pub fn with_pool<P2>(self, pool: P2) -> BlobFetcherBuilder<P2> {
BlobFetcherBuilder {
pool: Some(pool),
explorer_url: self.explorer_url,
client: self.client,
Expand All @@ -53,15 +53,13 @@ impl<Pool> BlockExtractorBuilder<Pool> {

/// Set the transaction pool to use a mock test pool.
#[cfg(feature = "test-utils")]
pub fn with_test_pool(
self,
) -> BlockExtractorBuilder<reth_transaction_pool::test_utils::TestPool> {
pub fn with_test_pool(self) -> BlobFetcherBuilder<reth_transaction_pool::test_utils::TestPool> {
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> {
/// [`BlobFetcherConfig`].
pub fn with_config(self, config: &BlobFetcherConfig) -> 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 };
Expand Down Expand Up @@ -114,22 +112,22 @@ impl<Pool> BlockExtractorBuilder<Pool> {
pub const fn with_slot_calculator(
mut self,
slot_calculator: SlotCalculator,
) -> BlockExtractorBuilder<Pool> {
) -> BlobFetcherBuilder<Pool> {
self.slot_calculator = Some(slot_calculator);
self
}

/// Set the slot calculator to use for the extractor, using the Pecornino
/// host configuration.
pub const fn with_pecornino_slots(mut self) -> BlockExtractorBuilder<Pool> {
pub const fn with_pecornino_slots(mut self) -> BlobFetcherBuilder<Pool> {
self.slot_calculator = Some(SlotCalculator::pecorino_host());
self
}
}

impl<Pool: TransactionPool> BlockExtractorBuilder<Pool> {
/// Build the [`BlockExtractor`] with the provided parameters.
pub fn build(self) -> Result<BlockExtractor<Pool>, BuilderError> {
impl<Pool: TransactionPool> BlobFetcherBuilder<Pool> {
/// Build the [`BlobFetcher`] with the provided parameters.
pub fn build(self) -> Result<BlobFetcher<Pool>, BuilderError> {
let pool = self.pool.ok_or(BuilderError::MissingPool)?;

let explorer_url = self.explorer_url.ok_or(BuilderError::MissingExplorerUrl)?;
Expand All @@ -145,7 +143,16 @@ impl<Pool: TransactionPool> BlockExtractorBuilder<Pool> {

let slot_calculator = self.slot_calculator.ok_or(BuilderError::MissingSlotCalculator)?;

Ok(BlockExtractor::new(pool, explorer, client, cl_url, pylon_url, slot_calculator))
Ok(BlobFetcher::new(pool, explorer, client, cl_url, pylon_url, slot_calculator))
}

/// Build a [`BlobCacher`] with the provided parameters.
pub fn build_cache(self) -> Result<BlobCacher<Pool>, BuilderError>
where
Pool: 'static,
{
let fetcher = self.build()?;
Ok(BlobCacher::new(fetcher))
}
}

Expand Down
Loading