Skip to content

Commit

Permalink
feat(derive): refactor out online providers
Browse files Browse the repository at this point in the history
  • Loading branch information
refcell committed Sep 24, 2024
1 parent 5d0e211 commit 50f3de3
Show file tree
Hide file tree
Showing 23 changed files with 330 additions and 180 deletions.
86 changes: 47 additions & 39 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ kona-executor = { path = "crates/executor", version = "0.0.2" }
kona-common-proc = { path = "crates/common-proc", version = "0.0.3" }
kona-derive = { path = "crates/derive", version = "0.0.3", default-features = false }
kona-primitives = { path = "crates/primitives", version = "0.0.2", default-features = false }
kona-providers = { path = "crates/providers", version = "0.0.1", default-features = false }

# General
anyhow = { version = "1.0.89", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion bin/host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ kona-mpt.workspace = true
kona-client.workspace = true
kona-common.workspace = true
kona-preimage.workspace = true
kona-derive = { workspace = true, features = ["online"] }
kona-providers.workspace = true
kona-primitives = { workspace = true, features = ["online"] }

# Alloy & Revm
Expand Down
2 changes: 1 addition & 1 deletion bin/host/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use clap::{
builder::styling::{AnsiColor, Color, Style},
ArgAction, Parser,
};
use kona_derive::online::{OnlineBeaconClient, OnlineBlobProvider, SimpleSlotDerivation};
use kona_providers::{OnlineBeaconClient, OnlineBlobProvider, SimpleSlotDerivation};
use op_alloy_genesis::RollupConfig;
use serde::Serialize;
use std::{path::PathBuf, sync::Arc};
Expand Down
2 changes: 1 addition & 1 deletion bin/host/src/fetcher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ use alloy_rpc_types::{
};
use anyhow::{anyhow, Result};
use kona_client::HintType;
use kona_derive::online::{OnlineBeaconClient, OnlineBlobProvider, SimpleSlotDerivation};
use kona_preimage::{PreimageKey, PreimageKeyType};
use kona_primitives::IndexedBlobHash;
use kona_providers::{OnlineBeaconClient, OnlineBlobProvider, SimpleSlotDerivation};
use op_alloy_protocol::BlockInfo;
use std::sync::Arc;
use tokio::sync::RwLock;
Expand Down
24 changes: 4 additions & 20 deletions crates/derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ kona-primitives.workspace = true
# `serde` feature dependencies
serde = { workspace = true, optional = true }

# `online` feature dependencies
lru = { workspace = true, optional = true }
alloy-transport = { workspace = true, optional = true }
alloy-provider = { workspace = true, optional = true }
reqwest = { workspace = true, optional = true }

# `metrics` feature dependencies
lazy_static = { workspace = true, optional = true }
prometheus = { workspace = true, optional = true }
Expand All @@ -67,6 +61,10 @@ serde_json.workspace = true

[features]
default = ["serde"]
metrics = [
"dep:prometheus",
"dep:lazy_static",
]
serde = [
"dep:serde",
"kona-primitives/serde",
Expand All @@ -77,20 +75,6 @@ serde = [
"op-alloy-genesis/serde",
"op-alloy-rpc-types-engine/serde",
]
metrics = ["dep:prometheus", "dep:lazy_static"]
online = [
"dep:alloy-provider",
"dep:alloy-transport",
"dep:reqwest",
"dep:lru",
"alloy-provider/reqwest",
"alloy-consensus/serde",
"kona-primitives/online",
"kona-primitives/serde",
"op-alloy-consensus/std",
"op-alloy-protocol/std",
"op-alloy-genesis/std",
]
test-utils = [
"dep:spin",
"dep:anyhow",
Expand Down
16 changes: 12 additions & 4 deletions crates/derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@

extern crate alloc;

mod macros;
/// Re-export commonly used types and traits.
pub mod prelude {
pub use crate::{
errors::{PipelineError, PipelineErrorKind},
pipeline::{DerivationPipeline, PipelineBuilder},
sources::EthereumDataSource,
stages::StatefulAttributesBuilder,
traits::{ChainProvider, L2ChainProvider, OriginProvider, Pipeline, StepResult},
};
}

pub mod batch;
pub mod block;
Expand All @@ -18,8 +27,7 @@ pub mod sources;
pub mod stages;
pub mod traits;

#[cfg(feature = "online")]
pub mod online;

#[cfg(feature = "metrics")]
pub mod metrics;

mod macros;
23 changes: 0 additions & 23 deletions crates/derive/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,29 +54,6 @@ lazy_static! {
"Compression ratio of batches"
).expect("Batch Compression Ratio failed to register");

/// Tracks the number of provider method calls.
pub static ref PROVIDER_CALLS: CounterVec = register_counter_vec!(
"kona_derive_provider_calls",
"Number of provider method calls",
&["provider", "method"]
).expect("Provider Calls failed to register");

/// Tracks the number of errors in provider methods.
pub static ref PROVIDER_ERRORS: CounterVec = register_counter_vec!(
"kona_derive_provider_errors",
"Number of provider errors",
&["provider", "method", "error"]
).expect("Provider Errors failed to register");

/// Tracks the time taken for provider methods.
pub static ref PROVIDER_RESPONSE_TIME: HistogramVec = register_histogram_vec!(
"kona_derive_provider_response_time_seconds",
"Provider response times",
&["provider", "method"],
RESPONSE_TIME_CUSTOM_BUCKETS.to_vec()
)
.expect("Failed to register histogram vec");

/// Tracks the time taken for stage advance methods.
pub static ref STAGE_ADVANCE_RESPONSE_TIME: HistogramVec = register_histogram_vec!(
"kona_derive_stage_advance_response_time_seconds",
Expand Down
30 changes: 0 additions & 30 deletions crates/derive/src/online/mod.rs

This file was deleted.

Loading

0 comments on commit 50f3de3

Please sign in to comment.