Crate kona_derive

Source
Expand description

§kona-derive

CI Kona Derive License Codecov

A no_std compatible implementation of the OP Stack’s derivation pipeline.

§Usage

The intended way of working with kona-derive is to use the DerivationPipeline which implements the Pipeline trait. To create an instance of the DerivationPipeline, it’s recommended to use the PipelineBuilder as follows.

use std::sync::Arc;
use kona_genesis::RollupConfig;
use kona_derive::EthereumDataSource;
use kona_derive::PipelineBuilder;
use kona_derive::StatefulAttributesBuilder;

let chain_provider = todo!();
let l2_chain_provider = todo!();
let blob_provider = todo!();
let l1_origin = todo!();

let cfg = Arc::new(RollupConfig::default());
let attributes = StatefulAttributesBuilder::new(
   cfg.clone(),
   l2_chain_provider.clone(),
   chain_provider.clone(),
);
let dap = EthereumDataSource::new(
   chain_provider.clone(),
   blob_provider,
   cfg.as_ref()
);

// Construct a new derivation pipeline.
let pipeline = PipelineBuilder::new()
   .rollup_config(cfg)
   .dap_source(dap)
   .l2_chain_provider(l2_chain_provider)
   .chain_provider(chain_provider)
   .builder(attributes)
   .origin(l1_origin)
   .build();

§Features

The most up-to-date feature list will be available on the docs.rs Feature Flags tab of the kona-derive crate.

Some features include the following.

  • serde: Serialization and Deserialization support for kona-derive types.
  • test-utils: Test utilities for downstream libraries.

By default, kona-derive enables the serde feature.

Macros§

ensure
crate::ensure is a short-hand for bubbling up errors in the case of a condition not being met.

Structs§

ActivationSignal
A pipeline hardfork activation signal.
AttributesQueue
AttributesQueue accepts batches from the BatchQueue stage and transforms them into OpPayloadAttributes.
BatchProvider
The BatchProvider stage is a mux between the BatchQueue and BatchValidator stages.
BatchQueue
BatchQueue is responsible for ordering unordered batches and generating empty batches when the sequence window has passed.
BatchStream
BatchStream stage in the derivation pipeline.
BatchValidator
The BatchValidator stage is responsible for validating the SingleBatches from the BatchStream AttributesQueue’s consumption.
BlobData
The Blob Data
BlobSource
A data iterator that reads from a blob.
CalldataSource
A data iterator that reads from calldata.
ChannelAssembler
The ChannelAssembler stage is responsible for assembling the Frames from the FrameQueue stage into a raw compressed Channel.
ChannelBank
ChannelBank is a stateful stage that does the following:
ChannelProvider
The ChannelProvider stage is a mux between the ChannelBank and ChannelAssembler stages.
ChannelReader
ChannelReader is a stateful stage that reads Batches from Channels.
DerivationPipeline
The derivation pipeline is responsible for deriving L2 inputs from L1 data.
EthereumDataSource
A factory for creating an Ethereum data source provider.
FrameQueue
The FrameQueue stage of the derivation pipeline. This stage takes the output of the L1Retrieval stage and parses it into frames.
IndexedTraversal
The IndexedTraversal stage of the derivation pipeline.
L1Retrieval
The L1Retrieval stage of the derivation pipeline.
Metrics
Container for metrics.
PipelineBuilder
The PipelineBuilder constructs a DerivationPipeline using a builder pattern.
PollingTraversal
The PollingTraversal stage of the derivation pipeline.
ResetSignal
A pipeline reset signal.
StatefulAttributesBuilder
A stateful implementation of the AttributesBuilder.

Enums§

BatchDecompressionError
A frame decompression error.
BlobDecodingError
Blob Decoding Error
BlobProviderError
An error returned by the BlobProviderError.
BuilderError
An AttributesBuilder Error.
PipelineEncodingError
A decoding error.
PipelineError
An error encountered during derivation pipeline processing.
PipelineErrorKind
A top-level severity filter for PipelineError that categorizes errors by handling strategy.
ResetError
A reset error
Signal
A signal to send to the pipeline.
StepResult
A pipeline error.
TraversalStage
The type of traversal stage used in the derivation pipeline.

Traits§

AttributesBuilder
The AttributesBuilder is responsible for preparing OpPayloadAttributes that can be used to construct an L2 Block containing only deposits.
AttributesProvider
AttributesProvider is a trait abstraction that generalizes the BatchQueue stage.
BatchStreamProvider
Provides Batches for the BatchStream stage.
BatchValidationProviderDerive
A super-trait for BatchValidationProvider that binds Self::Error to have a conversion into PipelineErrorKind.
BlobProvider
The BlobProvider trait specifies the functionality of a data source that can provide blobs.
ChainProvider
Describes the functionality of a data source that can provide information from the blockchain.
ChannelReaderProvider
The ChannelReader provider trait.
DataAvailabilityProvider
Describes the functionality of a data source that can provide data availability information.
FrameQueueProvider
Provides data frames for the FrameQueue stage.
L1RetrievalProvider
Provides L1 blocks for the L1Retrieval stage. This is the previous stage in the pipeline.
L2ChainProvider
Describes the functionality of a data source that fetches safe blocks.
NextAttributes
NextAttributes defines the interface for pulling attributes from the top level AttributesQueue stage of the pipeline.
NextBatchProvider
Provides Batches for the BatchQueue and BatchValidator stages.
NextFrameProvider
Provides frames for the ChannelBank and ChannelAssembler stages.
OriginAdvancer
Defines a trait for advancing the L1 origin of the pipeline.
OriginProvider
Provides a method for accessing the pipeline’s current L1 origin.
Pipeline
This trait defines the interface for interacting with the derivation pipeline.
ResetProvider
Provides the BlockInfo and SystemConfig for the stack to reset the stages.
SignalReceiver
Providers a way for the pipeline to accept a signal from the driver.

Type Aliases§

AttributesQueueStage
Type alias for the AttributesQueue stage.
BatchProviderStage
Type alias for the BatchProvider stage.
BatchStreamStage
Type alias for the BatchStream stage.
ChannelProviderStage
Type alias for the ChannelProvider stage.
ChannelReaderStage
Type alias for the ChannelReader stage.
FrameQueueStage
Type alias for the FrameQueue stage.
IndexedAttributesQueueStage
Type alias for the AttributesQueue stage that uses a IndexedTraversal stage.
L1RetrievalStage
Type alias for the L1Retrieval stage.
PipelineResult
A result type for the derivation pipeline stages.
PolledAttributesQueueStage
Type alias for the AttributesQueue stage that uses a PollingTraversal stage.