Skip to content

Commit 5d0e211

Browse files
authored
feat(derive): Touchup Docs (op-rs#555)
* feat: kona-derive docs * fix: doc imports
1 parent 5ee09be commit 5d0e211

File tree

3 files changed

+46
-14
lines changed

3 files changed

+46
-14
lines changed

Diff for: crates/derive/README.md

+46-8
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,60 @@ A `no_std` compatible implementation of the OP Stack's [derivation pipeline][der
88

99
[derive]: (https://specs.optimism.io/protocol/derivation.html#l2-chain-derivation-specification).
1010

11+
## Usage
12+
13+
The intended way of working with `kona-derive` is to use the [`DerivationPipeline`][dp] which implements the [`Pipeline`][p] trait. To create an instance of the [`DerivationPipeline`][dp], it's recommended to use the [`PipelineBuilder`][pb] as follows.
14+
15+
```rust,ignore
16+
use std::sync::Arc;
17+
use op_alloy_genesis::RollupConfig;
18+
use kona_derive::sources::EthereumDataSource;
19+
use kona_derive::pipeline::PipelineBuilder;
20+
use kona_derive::stages::{StatefulAttributesBuilder};
21+
22+
let chain_provider = ...;
23+
let l2_chain_provider = ...;
24+
let blob_provider = ...;
25+
let l1_origin = ...;
26+
27+
let cfg = Arc::new(RollupConfig::default());
28+
let attributes = StatefulAttributesBuilder::new(
29+
cfg.clone(),
30+
l2_chain_provider.clone(),
31+
chain_provider.clone(),
32+
);
33+
let dap = EthereumDataSource::new(
34+
chain_provider.clone(),
35+
blob_provider,
36+
cfg.as_ref()
37+
);
38+
39+
// Construct a new derivation pipeline.
40+
let pipeline = PipelineBuilder::new()
41+
.rollup_config(cfg)
42+
.dap_source(dap)
43+
.l2_chain_provider(l2_chain_provider)
44+
.chain_provider(chain_provider)
45+
.builder(attributes)
46+
.origin(l1_origin)
47+
.build();
48+
```
49+
50+
[p]: ./src/traits/pipeline.rs
51+
[pb]: ./src/pipeline/builder.rs
52+
[dp]: ./src/pipeline/core.rs
53+
1154
## Features
1255

1356
The most up-to-date feature list will be available on the [docs.rs `Feature Flags` tab][ff] of the `kona-derive` crate.
1457

1558
Some features include the following.
1659
- `serde`: Serialization and Deserialization support for `kona-derive` types.
17-
- `k256`: [secp256k1][k] public key recovery support.
60+
- `metrics`: Enables prometheus metric collection. _Note: This requires an `std` environment._
1861
- `online`: Exposes an [alloy-provider][ap] powered data source using "online" HTTP requests.
62+
- `test-utils`: Test utilities for downstream libraries.
1963

20-
By default, `kona-derive` enables features `serde` and `k256`.
21-
22-
Key recovery using the [secp256k1][k] curve sits behind a `k256` feature flag so that when compiled in `offline` mode,
23-
secp recovery can fall through to the fpp host, accelerating key recovery. This was necessary since invalid instructions
24-
were found when compiling `k256` recovery down to a bare-metal MIPS target. Since public key recovery requires elliptic
25-
curve pairings, `k256` fall-through host recovery should drastically accelerate derivation on the FPVM.
64+
By default, `kona-derive` enables the `serde` feature.
2665

27-
[k]: https://en.bitcoin.it/wiki/Secp256k1
2866
[ap]: https://docs.rs/crate/alloy-providers/latest
2967
[ff]: https://docs.rs/crate/kona-derive/latest/features

Diff for: crates/derive/USAGE.md

-5
This file was deleted.

Diff for: crates/derive/src/pipeline/builder.rs

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ type BatchQueueStage<DAP, P, T> = BatchQueue<ChannelReaderStage<DAP, P>, T>;
2020
type AttributesQueueStage<DAP, P, T, B> = AttributesQueue<BatchQueueStage<DAP, P, T>, B>;
2121

2222
/// The `PipelineBuilder` constructs a [DerivationPipeline] using a builder pattern.
23-
#[cfg_attr(feature = "online", doc = include_str!("../../USAGE.md"))]
2423
#[derive(Debug)]
2524
pub struct PipelineBuilder<B, P, T, D>
2625
where

0 commit comments

Comments
 (0)