Skip to content
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

chore(workspace): Removes Primitives #638

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
22 changes: 2 additions & 20 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ kona-preimage = { path = "crates/preimage", version = "0.0.3" }
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" }
kona-providers-alloy = { path = "crates/providers-alloy", version = "0.0.1", default-features = false }

Expand Down Expand Up @@ -122,6 +121,7 @@ rocksdb = { version = "0.22", default-features = false, features = ["snappy"] }
alloy-rlp = { version = "0.3.8", default-features = false }
alloy-trie = { version = "0.6.0", default-features = false }
alloy-eips = { version = "0.4.0", default-features = false }
alloy-serde = { version = "0.4.0", default-features = false }
alloy-provider = { version = "0.4.0", default-features = false }
alloy-primitives = { version = "0.8", default-features = false }
alloy-consensus = { version = "0.4.0", default-features = false }
Expand Down
1 change: 0 additions & 1 deletion bin/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ kona-mpt.workspace = true
kona-derive.workspace = true
kona-executor.workspace = true
kona-providers.workspace = true
kona-primitives = { workspace = true, features = ["serde"] }
op-alloy-genesis = { workspace = true, features = ["serde"] }
op-alloy-protocol.workspace = true
op-alloy-rpc-types-engine.workspace = true
Expand Down
13 changes: 6 additions & 7 deletions bin/client/src/l1/blob_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
use crate::HintType;
use alloc::{boxed::Box, sync::Arc, vec::Vec};
use alloy_consensus::Blob;
use alloy_eips::eip4844::FIELD_ELEMENTS_PER_BLOB;
use alloy_eips::{eip1898::NumHash, eip4844::FIELD_ELEMENTS_PER_BLOB};
use alloy_primitives::keccak256;
use anyhow::Result;
use async_trait::async_trait;
use kona_derive::traits::BlobProvider;
use kona_preimage::{CommsClient, PreimageKey, PreimageKeyType};
use kona_primitives::IndexedBlobHash;
use op_alloy_protocol::BlockInfo;

/// An oracle-backed blob provider.
Expand All @@ -33,10 +32,10 @@ impl<T: CommsClient> OracleBlobProvider<T> {
/// ## Returns
/// - `Ok(blob)`: The blob.
/// - `Err(e)`: The blob could not be retrieved.
async fn get_blob(&self, block_ref: &BlockInfo, blob_hash: &IndexedBlobHash) -> Result<Blob> {
async fn get_blob(&self, block_ref: &BlockInfo, blob_hash: &NumHash) -> Result<Blob> {
let mut blob_req_meta = [0u8; 48];
blob_req_meta[0..32].copy_from_slice(blob_hash.hash.as_ref());
blob_req_meta[32..40].copy_from_slice((blob_hash.index as u64).to_be_bytes().as_ref());
blob_req_meta[32..40].copy_from_slice((blob_hash.number).to_be_bytes().as_ref());
blob_req_meta[40..48].copy_from_slice(block_ref.timestamp.to_be_bytes().as_ref());

// Send a hint for the blob commitment and field elements.
Expand Down Expand Up @@ -78,11 +77,11 @@ impl<T: CommsClient + Sync + Send> BlobProvider for OracleBlobProvider<T> {
async fn get_blobs(
&mut self,
block_ref: &BlockInfo,
blob_hashes: &[IndexedBlobHash],
) -> Result<Vec<Blob>, Self::Error> {
blob_hashes: &[NumHash],
) -> Result<Vec<Box<Blob>>, Self::Error> {
let mut blobs = Vec::with_capacity(blob_hashes.len());
for hash in blob_hashes {
blobs.push(self.get_blob(block_ref, hash).await?);
blobs.push(Box::new(self.get_blob(block_ref, hash).await?));
}
Ok(blobs)
}
Expand Down
1 change: 0 additions & 1 deletion bin/host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ kona-client.workspace = true
kona-common.workspace = true
kona-preimage.workspace = true
kona-providers-alloy.workspace = true
kona-primitives = { workspace = true, features = ["online"] }

# Alloy & Revm
alloy-eips.workspace = true
Expand Down
7 changes: 4 additions & 3 deletions bin/host/src/fetcher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

use crate::{kv::KeyValueStore, util};
use alloy_consensus::{Header, TxEnvelope, EMPTY_ROOT_HASH};
use alloy_eips::{eip2718::Encodable2718, eip4844::FIELD_ELEMENTS_PER_BLOB, BlockId};
use alloy_eips::{
eip1898::NumHash, eip2718::Encodable2718, eip4844::FIELD_ELEMENTS_PER_BLOB, BlockId,
};
use alloy_primitives::{address, keccak256, Address, Bytes, B256};
use alloy_provider::{Provider, ReqwestProvider};
use alloy_rlp::{Decodable, EMPTY_STRING_CODE};
Expand All @@ -13,7 +15,6 @@ use alloy_rpc_types::{
use anyhow::{anyhow, Result};
use kona_client::HintType;
use kona_preimage::{PreimageKey, PreimageKeyType};
use kona_primitives::IndexedBlobHash;
use kona_providers_alloy::{OnlineBeaconClient, OnlineBlobProvider, SimpleSlotDerivation};
use op_alloy_protocol::BlockInfo;
use std::sync::Arc;
Expand Down Expand Up @@ -188,7 +189,7 @@ where
let timestamp = u64::from_be_bytes(timestamp_data_bytes);

let partial_block_ref = BlockInfo { timestamp, ..Default::default() };
let indexed_hash = IndexedBlobHash { index: index as usize, hash };
let indexed_hash = NumHash { number: index, hash };

// Fetch the blob sidecar from the blob provider.
let mut sidecars = self
Expand Down
2 changes: 0 additions & 2 deletions crates/derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ async-trait.workspace = true

# Workspace
kona-providers.workspace = true
kona-primitives.workspace = true

# `serde` feature dependencies
serde = { workspace = true, optional = true }
Expand Down Expand Up @@ -70,7 +69,6 @@ metrics = [
]
serde = [
"dep:serde",
"kona-primitives/serde",
"alloy-primitives/serde",
"alloy-consensus/serde",
"op-alloy-consensus/serde",
Expand Down
18 changes: 17 additions & 1 deletion crates/derive/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,27 @@ use crate::batch::SpanBatchError;
use alloc::string::String;
use alloy_eips::BlockNumHash;
use alloy_primitives::B256;
use kona_primitives::BlobDecodingError;
use op_alloy_genesis::system::SystemConfigUpdateError;
use op_alloy_protocol::DepositError;
use thiserror::Error;

/// Blob Decuding Error
#[derive(Error, Debug, PartialEq, Eq)]
pub enum BlobDecodingError {
/// Invalid field element
#[error("Invalid field element")]
InvalidFieldElement,
/// Invalid encoding version
#[error("Invalid encoding version")]
InvalidEncodingVersion,
/// Invalid length
#[error("Invalid length")]
InvalidLength,
/// Missing Data
#[error("Missing data")]
MissingData,
}

/// A result type for the derivation pipeline stages.
pub type PipelineResult<T> = Result<T, PipelineErrorKind>;

Expand Down
Loading
Loading