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

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
170 changes: 94 additions & 76 deletions Cargo.lock

Large diffs are not rendered by default.

58 changes: 29 additions & 29 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,37 @@ lto = "fat"

[workspace.dependencies]
# Workspace
kona-client = { path = "bin/client", version = "0.1.0" }
kona-mpt = { path = "crates/mpt", version = "0.0.3" }
kona-common = { path = "crates/common", version = "0.0.3" }
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-mpt = { path = "crates/mpt", version = "0.0.3", default-features = false }
kona-client = { path = "bin/client", version = "0.1.0", default-features = false }
kona-common = { path = "crates/common", version = "0.0.3", default-features = false }
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-preimage = { path = "crates/preimage", version = "0.0.3", default-features = false }
kona-executor = { path = "crates/executor", version = "0.0.2", default-features = false }
kona-providers = { path = "crates/providers", version = "0.0.1", default-features = false }
kona-common-proc = { path = "crates/common-proc", version = "0.0.3", default-features = false }
kona-providers-alloy = { path = "crates/providers-alloy", version = "0.0.1", default-features = false }

# OP Alloy
op-alloy-genesis = { version = "0.5.0", default-features = false }
op-alloy-protocol = { version = "0.5.0", default-features = false }
op-alloy-consensus = { version = "0.5.0", default-features = false }
op-alloy-rpc-types-engine = { version = "0.5.0", default-features = false }

# Alloy
alloy-rlp = { version = "0.3.8", default-features = false }
alloy-trie = { version = "0.7.2", default-features = false }
alloy-eips = { version = "0.5.0", default-features = false }
alloy-serde = { version = "0.5.0", default-features = false }
alloy-provider = { version = "0.5.0", default-features = false }
alloy-primitives = { version = "0.8", default-features = false }
alloy-consensus = { version = "0.5.0", default-features = false }
alloy-transport = { version = "0.5.0", default-features = false }
alloy-rpc-types = { version = "0.5.0", default-features = false }
alloy-rpc-client = { version = "0.5.0", default-features = false }
alloy-node-bindings = { version = "0.5.0", default-features = false }
alloy-transport-http = { version = "0.5.0", default-features = false }
alloy-rpc-types-engine = { version = "0.5.0", default-features = false }

# General
anyhow = { version = "1.0.89", default-features = false }
thiserror = { git = "https://github.com/quartiq/thiserror", branch = "no-std", default-features = false }
Expand Down Expand Up @@ -111,30 +131,10 @@ serde_json = { version = "1.0.128", default-features = false }

# Ethereum
unsigned-varint = "0.8.0"
revm = { version = "14.0.3", default-features = false }
revm = { version = "16.0.0", default-features = false }

# Optimism
superchain = { version = "0.7", default-features = false }

# K/V database
rocksdb = { version = "0.22", default-features = false, features = ["snappy"] }

# Alloy
alloy-rlp = { version = "0.3.8", default-features = false }
alloy-trie = { version = "0.7.2", default-features = false }
alloy-eips = { version = "0.4.2", default-features = false }
alloy-provider = { version = "0.4.2", default-features = false }
alloy-primitives = { version = "0.8", default-features = false }
alloy-consensus = { version = "0.4.2", default-features = false }
alloy-transport = { version = "0.4.2", default-features = false }
alloy-rpc-types = { version = "0.4.2", default-features = false }
alloy-rpc-client = { version = "0.4.2", default-features = false }
alloy-rpc-types-engine = { version = "0.4.2", default-features = false }
alloy-node-bindings = { version = "0.4.2", default-features = false }
alloy-transport-http = { version = "0.4.2", default-features = false }

# OP Alloy
op-alloy-consensus = { version = "0.4.0", default-features = false }
op-alloy-protocol = { version = "0.4.0", default-features = false }
op-alloy-genesis = { version = "0.4.0", default-features = false }
op-alloy-rpc-types-engine = { version = "0.4.0", default-features = false }
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> {
refcell marked this conversation as resolved.
Show resolved Hide resolved
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};
use op_alloy_protocol::BlockInfo;
use std::sync::Arc;
Expand Down Expand Up @@ -187,7 +188,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: 1 addition & 1 deletion book/src/sdk/fpvm-backend.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

Kona is effectively split into two parts:

- OP Stack state transition logic & types (`kona-derive`, `kona-executor`, `kona-mpt`, `kona-primitives`)
- OP Stack state transition logic (`kona-derive`, `kona-executor`, `kona-mpt`)
- {{#template ../../templates/glossary-link.md root=./ ref=fault-proof-vm text=Fault Proof VM}} IO and utilities
(`kona-common`, `kona-common-proc`, `kona-preimage`)

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 @@ -72,7 +71,6 @@ metrics = [
]
serde = [
"dep:serde",
"kona-primitives/serde",
"alloy-primitives/serde",
"alloy-consensus/serde",
"op-alloy-consensus/serde",
Expand Down
8 changes: 4 additions & 4 deletions crates/derive/src/attributes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ mod tests {
prev_randao,
suggested_fee_recipient: SEQUENCER_FEE_VAULT_ADDRESS,
parent_beacon_block_root,
withdrawals: None,
withdrawals: Some(vec![]),
},
transactions: payload.transactions.clone(),
no_tx_pool: Some(true),
Expand Down Expand Up @@ -693,8 +693,8 @@ mod tests {
timestamp: next_l2_time,
prev_randao,
suggested_fee_recipient: SEQUENCER_FEE_VAULT_ADDRESS,
parent_beacon_block_root: None,
withdrawals: None,
parent_beacon_block_root: Some(B256::ZERO),
withdrawals: Some(vec![]),
},
transactions: payload.transactions.clone(),
no_tx_pool: Some(true),
Expand All @@ -703,7 +703,7 @@ mod tests {
)),
eip_1559_params: None,
};
assert_eq!(payload.transactions.as_ref().unwrap().len(), 10);
assert_eq!(payload, expected);
assert_eq!(payload.transactions.unwrap().len(), 4);
refcell marked this conversation as resolved.
Show resolved Hide resolved
}
}
8 changes: 4 additions & 4 deletions crates/derive/src/batch/span_batch/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use alloc::vec::Vec;
use alloy_consensus::{Transaction, TxEnvelope, TxType};
use alloy_eips::eip2718::Encodable2718;
use alloy_primitives::{Address, Bytes, TxKind, U256};
use alloy_primitives::{Address, Bytes, U256};
use alloy_rlp::{Buf, Decodable, Encodable};

/// This struct contains the decoded information for transactions in a span batch.
Expand Down Expand Up @@ -348,11 +348,11 @@
let signature_v = signature.v().to_u64();
let y_parity_bit = convert_v_to_y_parity(signature_v, tx_type)?;
let contract_creation_bit = match to {
TxKind::Call(address) => {
Some(address) => {
self.tx_tos.push(address);
0
}
TxKind::Create => 1,
None => 1,

Check warning on line 355 in crates/derive/src/batch/span_batch/transactions.rs

View check run for this annotation

Codecov / codecov/patch

crates/derive/src/batch/span_batch/transactions.rs#L355

Added line #L355 was not covered by tests
};
let mut tx_data_buf = Vec::new();
span_batch_tx.encode(&mut tx_data_buf);
Expand All @@ -374,7 +374,7 @@
mod tests {
use super::*;
use alloy_consensus::{Signed, TxEip1559, TxEip2930, TxLegacy};
use alloy_primitives::{address, Signature};
use alloy_primitives::{address, Signature, TxKind};

#[test]
fn test_span_batch_transactions_add_empty_txs() {
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 @@ -7,11 +7,27 @@ use crate::{
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