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

feat(derive): Upstream Indexed Blob Hash #710

Closed
wants to merge 1 commit into from
Closed
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
85 changes: 34 additions & 51 deletions Cargo.lock

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

12 changes: 12 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ panic = "abort"
codegen-units = 1
lto = "fat"

[patch.crates-io]
alloy-eips = { git = "https://github.com/refcell/alloy", branch = "rf/feat/indexed-blob-hash" }
alloy-serde = { git = "https://github.com/refcell/alloy", branch = "rf/feat/indexed-blob-hash" }
alloy-provider = { git = "https://github.com/refcell/alloy", branch = "rf/feat/indexed-blob-hash" }
alloy-consensus = { git = "https://github.com/refcell/alloy", branch = "rf/feat/indexed-blob-hash" }
alloy-transport = { git = "https://github.com/refcell/alloy", branch = "rf/feat/indexed-blob-hash" }
alloy-rpc-types = { git = "https://github.com/refcell/alloy", branch = "rf/feat/indexed-blob-hash" }
alloy-rpc-client = { git = "https://github.com/refcell/alloy", branch = "rf/feat/indexed-blob-hash" }
alloy-node-bindings = { git = "https://github.com/refcell/alloy", branch = "rf/feat/indexed-blob-hash" }
alloy-transport-http = { git = "https://github.com/refcell/alloy", branch = "rf/feat/indexed-blob-hash" }
alloy-rpc-types-engine = { git = "https://github.com/refcell/alloy", branch = "rf/feat/indexed-blob-hash" }
Comment on lines +57 to +67
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Remove these and bump alloy dep versions once a release is published that includes the IndexedBlobHash type.


[workspace.dependencies]
# Workspace
kona-mpt = { path = "crates/mpt", version = "0.0.3", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion bin/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ revm.workspace = true
alloy-primitives.workspace = true
alloy-consensus.workspace = true
alloy-rlp.workspace = true
alloy-eips.workspace = true
alloy-eips = { workspace = true, features = ["kzg-sidecar"] }
op-alloy-consensus.workspace = true

# General
Expand Down
4 changes: 2 additions & 2 deletions bin/client/src/l1/blob_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
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::eip4844::{IndexedBlobHash, FIELD_ELEMENTS_PER_BLOB};
use alloy_primitives::keccak256;
use anyhow::Result;
use async_trait::async_trait;
use kona_derive::{sources::IndexedBlobHash, traits::BlobProvider};
use kona_derive::traits::BlobProvider;
use kona_preimage::{CommsClient, PreimageKey, PreimageKeyType};
use op_alloy_protocol::BlockInfo;

Expand Down
1 change: 0 additions & 1 deletion bin/client/src/l2/chain_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ impl<T: CommsClient + Send + Sync> L2ChainProvider for OracleL2ChainProvider<T>
.rollup_config
.is_canyon_active(timestamp)
.then(Vec::new),
requests: None,
},
};
Ok(optimism_block)
Expand Down
1 change: 0 additions & 1 deletion bin/host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ workspace = true
# Workspace
kona-mpt.workspace = true
kona-client.workspace = true
kona-derive.workspace = true
kona-common.workspace = true
kona-preimage.workspace = true
kona-providers-alloy.workspace = true
Expand Down
9 changes: 6 additions & 3 deletions bin/host/src/fetcher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@

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::{
eip2718::Encodable2718,
eip4844::{IndexedBlobHash, 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 @@ -12,7 +16,6 @@ use alloy_rpc_types::{
};
use anyhow::{anyhow, Result};
use kona_client::HintType;
use kona_derive::sources::IndexedBlobHash;
use kona_preimage::{PreimageKey, PreimageKeyType};
use kona_providers_alloy::{OnlineBeaconClient, OnlineBlobProvider};
use op_alloy_protocol::BlockInfo;
Expand Down Expand Up @@ -187,7 +190,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 = IndexedBlobHash { index, hash };

// Fetch the blob sidecar from the blob provider.
let mut sidecars = self
Expand Down
2 changes: 1 addition & 1 deletion crates/derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ workspace = true

[dependencies]
# Alloy
alloy-eips.workspace = true
alloy-eips = { workspace = true, features = ["kzg-sidecar"] }
alloy-rlp = { workspace = true, features = ["derive"] }
alloy-consensus = { workspace = true, features = ["k256"] }
alloy-primitives = { workspace = true, features = ["rlp", "k256", "map"] }
Expand Down
3 changes: 0 additions & 3 deletions crates/derive/src/batch/span_batch/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1459,7 +1459,6 @@ mod tests {
transactions: Vec::new(),
ommers: Vec::new(),
withdrawals: None,
requests: None,
},
};
let mut fetcher = TestL2ChainProvider {
Expand Down Expand Up @@ -1534,7 +1533,6 @@ mod tests {
transactions: Vec::new(),
ommers: Vec::new(),
withdrawals: None,
requests: None,
},
};
let mut fetcher = TestL2ChainProvider {
Expand Down Expand Up @@ -1611,7 +1609,6 @@ mod tests {
transactions: Vec::new(),
ommers: Vec::new(),
withdrawals: None,
requests: None,
},
};
let mut fetcher = TestL2ChainProvider {
Expand Down
23 changes: 4 additions & 19 deletions crates/derive/src/sources/blobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use crate::{
};
use alloc::{boxed::Box, format, string::ToString, vec, vec::Vec};
use alloy_consensus::{Transaction, TxEip4844Variant, TxEnvelope, TxType};
use alloy_eips::eip4844::{Blob, BYTES_PER_BLOB, VERSIONED_HASH_VERSION_KZG};
use alloy_primitives::{Address, Bytes, B256};
use alloy_eips::eip4844::{Blob, IndexedBlobHash, BYTES_PER_BLOB, VERSIONED_HASH_VERSION_KZG};
use alloy_primitives::{Address, Bytes};
use async_trait::async_trait;
use kona_providers::ChainProvider;
use op_alloy_protocol::BlockInfo;
Expand All @@ -22,22 +22,6 @@ pub(crate) const BLOB_MAX_DATA_SIZE: usize = (4 * 31 + 3) * 1024 - 4; // 130044
/// Blob Encoding/Decoding Rounds
pub(crate) const BLOB_ENCODING_ROUNDS: usize = 1024;

/// A Blob hash
#[derive(Default, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct IndexedBlobHash {
/// The index of the blob
pub index: usize,
/// The hash of the blob
pub hash: B256,
}

impl PartialEq for IndexedBlobHash {
fn eq(&self, other: &Self) -> bool {
self.index == other.index && self.hash == other.hash
}
}

/// The Blob Data
#[derive(Default, Clone, Debug)]
pub struct BlobData {
Expand Down Expand Up @@ -287,7 +271,7 @@ where
continue;
};
for blob in blob_hashes {
let indexed = IndexedBlobHash { hash: blob, index: number as usize };
let indexed = IndexedBlobHash { hash: blob, index: number };
hashes.push(indexed);
data.push(BlobData::default());
number += 1;
Expand Down Expand Up @@ -392,6 +376,7 @@ where
pub(crate) mod tests {
use super::*;
use crate::{errors::PipelineErrorKind, traits::test_utils::TestBlobProvider};
use alloy_primitives::B256;
use alloy_rlp::Decodable;
use kona_providers::test_utils::TestChainProvider;

Expand Down
2 changes: 1 addition & 1 deletion crates/derive/src/sources/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mod ethereum;
pub use ethereum::EthereumDataSource;

mod blobs;
pub use blobs::{BlobData, BlobSource, IndexedBlobHash};
pub use blobs::{BlobData, BlobSource};

mod calldata;
pub use calldata::CalldataSource;
Expand Down
Loading