Skip to content

Commit

Permalink
Reapply "chore: bump alloy deps (#788)"
Browse files Browse the repository at this point in the history
This reverts commit 2459976.
  • Loading branch information
refcell committed Nov 7, 2024
1 parent 534b32e commit 5e713ca
Show file tree
Hide file tree
Showing 17 changed files with 442 additions and 256 deletions.
537 changes: 391 additions & 146 deletions Cargo.lock

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,24 @@ kona-derive-alloy = { path = "crates/derive-alloy", version = "0.0.3", default-f
# Alloy
alloy-rlp = { version = "0.3.9", default-features = false }
alloy-trie = { version = "0.7.2", default-features = false }
alloy-eips = { version = "0.5.4", default-features = false }
alloy-serde = { version = "0.5.4", default-features = false }
alloy-provider = { version = "0.5.4", default-features = false }
alloy-eips = { version = "0.6.1", default-features = false }
alloy-serde = { version = "0.6.1", default-features = false }
alloy-provider = { version = "0.6.1", default-features = false }
alloy-primitives = { version = "0.8", default-features = false }
alloy-consensus = { version = "0.5.4", default-features = false }
alloy-transport = { version = "0.5.4", default-features = false }
alloy-rpc-types = { version = "0.5.4", default-features = false }
alloy-rpc-client = { version = "0.5.4", default-features = false }
alloy-node-bindings = { version = "0.5.4", default-features = false }
alloy-transport-http = { version = "0.5.4", default-features = false }
alloy-rpc-types-engine = { version = "0.5.4", default-features = false }
alloy-rpc-types-beacon = { version = "0.5.4", default-features = false }
alloy-consensus = { version = "0.6.1", default-features = false }
alloy-transport = { version = "0.6.1", default-features = false }
alloy-rpc-types = { version = "0.6.1", default-features = false }
alloy-rpc-client = { version = "0.6.1", default-features = false }
alloy-node-bindings = { version = "0.6.1", default-features = false }
alloy-transport-http = { version = "0.6.1", default-features = false }
alloy-rpc-types-engine = { version = "0.6.1", default-features = false }
alloy-rpc-types-beacon = { version = "0.6.1", default-features = false }

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

# General
lru = "0.12.4"
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,10 +3,10 @@
use crate::{errors::OracleProviderError, 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 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/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-derive-alloy.workspace = true
Expand Down
15 changes: 7 additions & 8 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_derive_alloy::{OnlineBeaconClient, OnlineBlobProvider};
use kona_preimage::{PreimageKey, PreimageKeyType};
use op_alloy_protocol::BlockInfo;
Expand Down Expand Up @@ -182,7 +185,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 Expand Up @@ -516,11 +519,7 @@ where
let encoded_transactions = transactions
.into_iter()
.map(|tx| {
let envelope: TxEnvelope = tx.try_into().map_err(|e| {
anyhow!(
"Failed to convert RPC transaction into consensus envelope: {e}"
)
})?;
let envelope = TxEnvelope::from(tx);

Ok::<_, anyhow::Error>(envelope.encoded_2718())
})
Expand Down
3 changes: 2 additions & 1 deletion crates/derive-alloy/src/alloy_providers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ impl ChainProvider for AlloyChainProvider {
.raw_request("debug_getRawBlock".into(), [hash])
.await
.map_err(AlloyProviderError::Rpc)?;
let block = Block::decode(&mut raw_block.as_ref()).map_err(AlloyProviderError::Rlp)?;
let block: Block<TxEnvelope> =
Block::decode(&mut raw_block.as_ref()).map_err(AlloyProviderError::Rlp)?;

let block_info = BlockInfo {
hash: block.header.hash_slow(),
Expand Down
4 changes: 2 additions & 2 deletions crates/derive-alloy/src/beacon_client.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! Contains an online implementation of the `BeaconClient` trait.

use alloy_eips::eip4844::IndexedBlobHash;
use alloy_rpc_types_beacon::sidecar::{BeaconBlobBundle, BlobData};
use async_trait::async_trait;
use kona_derive::sources::IndexedBlobHash;
use reqwest::Client;

/// The config spec engine api method.
Expand Down Expand Up @@ -128,7 +128,7 @@ impl BeaconClient for OnlineBeaconClient {
let mut sidecars = Vec::with_capacity(hashes.len());
hashes.iter().for_each(|hash| {
if let Some(sidecar) =
raw_response.data.iter().find(|sidecar| sidecar.index == hash.index as u64)
raw_response.data.iter().find(|sidecar| sidecar.index == hash.index)
{
sidecars.push(sidecar.clone());
}
Expand Down
20 changes: 8 additions & 12 deletions crates/derive-alloy/src/blob_provider.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//! Contains an online implementation of the `BlobProvider` trait.

use crate::{BeaconClient, OnlineBeaconClient};
use alloy_eips::eip4844::{Blob, BlobTransactionSidecarItem};
use alloy_eips::eip4844::{Blob, BlobTransactionSidecarItem, IndexedBlobHash};
use alloy_rpc_types_beacon::sidecar::BlobData;
use async_trait::async_trait;
use kona_derive::{errors::BlobProviderError, sources::IndexedBlobHash, traits::BlobProvider};
use kona_derive::{errors::BlobProviderError, traits::BlobProvider};
use op_alloy_protocol::BlockInfo;
use tracing::warn;

Expand Down Expand Up @@ -103,7 +103,7 @@ impl<B: BeaconClient> OnlineBlobProvider<B> {
let sidecars = self.fetch_sidecars(slot, blob_hashes).await?;

// Filter blob sidecars that match the indicies in the specified list.
let blob_hash_indicies = blob_hashes.iter().map(|b| b.index as u64).collect::<Vec<u64>>();
let blob_hash_indicies = blob_hashes.iter().map(|b| b.index).collect::<Vec<u64>>();
let filtered = sidecars
.into_iter()
.filter(|s| blob_hash_indicies.contains(&s.index))
Expand Down Expand Up @@ -156,10 +156,7 @@ where
let hash = blob_hashes
.get(i)
.ok_or(BlobProviderError::Backend("Missing blob hash".to_string()))?;
match sidecar.verify_blob(&alloy_eips::eip1898::NumHash {
hash: hash.hash,
number: hash.index as u64,
}) {
match sidecar.verify_blob(&IndexedBlobHash { hash: hash.hash, index: hash.index }) {
Ok(_) => Ok(sidecar.blob),
Err(e) => Err(BlobProviderError::Backend(e.to_string())),
}
Expand Down Expand Up @@ -250,7 +247,7 @@ impl<B: BeaconClient, F: BlobSidecarProvider> OnlineBlobProviderWithFallback<B,
let sidecars = fallback.beacon_blob_side_cars(slot, blob_hashes).await?;

// Filter blob sidecars that match the indicies in the specified list.
let blob_hash_indicies = blob_hashes.iter().map(|b| b.index as u64).collect::<Vec<_>>();
let blob_hash_indicies = blob_hashes.iter().map(|b| b.index).collect::<Vec<_>>();
let filtered = sidecars
.into_iter()
.filter(|s| blob_hash_indicies.contains(&s.index))
Expand Down Expand Up @@ -312,10 +309,9 @@ where
let hash = blob_hashes.get(i).ok_or(BlobProviderError::Backend(
"fallback: failed to get blob hash".to_string(),
))?;
match sidecar.verify_blob(&alloy_eips::eip1898::NumHash {
hash: hash.hash,
number: hash.index as u64,
}) {
match sidecar
.verify_blob(&IndexedBlobHash { hash: hash.hash, index: hash.index })
{
Ok(_) => Ok(sidecar.blob),
Err(e) => Err(BlobProviderError::Backend(e.to_string())),
}
Expand Down
2 changes: 1 addition & 1 deletion crates/derive-alloy/src/test_utils.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//! Test Utilities for Online Providers

use crate::{APIConfigResponse, APIGenesisResponse};
use alloy_eips::eip4844::IndexedBlobHash;
use alloy_node_bindings::{Anvil, AnvilInstance};
use alloy_provider::{network::Ethereum, ReqwestProvider};
use alloy_rpc_client::RpcClient;
use alloy_rpc_types_beacon::sidecar::{BeaconBlobBundle, BlobData};
use alloy_transport_http::Http;
use async_trait::async_trait;
use kona_derive::sources::IndexedBlobHash;
use reqwest::Client;

/// Spawns an Anvil instance and returns a provider and the instance.
Expand Down
4 changes: 0 additions & 4 deletions crates/derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ async-trait.workspace = true
alloc-no-stdlib.workspace = true
derive_more = { workspace = true, features = ["full"] }

# `serde` feature dependencies
serde = { workspace = true, optional = true, features = ["derive"] }

# `test-utils` feature dependencies
spin = { workspace = true, optional = true }
tracing-subscriber = { workspace = true, optional = true, features = ["fmt"] }
Expand All @@ -51,7 +48,6 @@ alloy-primitives = { workspace = true, features = ["rlp", "k256", "map", "arbitr
[features]
default = ["serde"]
serde = [
"dep:serde",
"alloy-primitives/serde",
"alloy-consensus/serde",
"op-alloy-consensus/serde",
Expand Down
45 changes: 0 additions & 45 deletions crates/derive/src/sources/blob_hash.rs

This file was deleted.

15 changes: 8 additions & 7 deletions crates/derive/src/sources/blobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

use crate::{
errors::{BlobProviderError, PipelineError},
sources::{BlobData, IndexedBlobHash},
sources::BlobData,
traits::{BlobProvider, ChainProvider, DataAvailabilityProvider},
types::PipelineResult,
};
use alloc::{boxed::Box, string::ToString, vec::Vec};
use alloy_consensus::{Transaction, TxEip4844Variant, TxEnvelope, TxType};
use alloy_eips::eip4844::IndexedBlobHash;
use alloy_primitives::{Address, Bytes};
use async_trait::async_trait;
use op_alloy_protocol::BlockInfo;
Expand Down Expand Up @@ -57,7 +58,7 @@ where
}

fn extract_blob_data(&self, txs: Vec<TxEnvelope>) -> (Vec<BlobData>, Vec<IndexedBlobHash>) {
let mut number: u64 = 0;
let mut index: u64 = 0;
let mut data = Vec::new();
let mut hashes = Vec::new();
for tx in txs {
Expand All @@ -79,11 +80,11 @@ where
let Some(to) = tx_kind else { continue };

if to != self.batcher_address {
number += blob_hashes.map_or(0, |h| h.len() as u64);
index += blob_hashes.map_or(0, |h| h.len() as u64);
continue;
}
if tx.recover_signer().unwrap_or_default() != self.signer {
number += blob_hashes.map_or(0, |h| h.len() as u64);
index += blob_hashes.map_or(0, |h| h.len() as u64);
continue;
}
if tx.tx_type() != TxType::Eip4844 {
Expand All @@ -106,11 +107,11 @@ where
} else {
continue;
};
for blob in blob_hashes {
let indexed = IndexedBlobHash { hash: blob, index: number as usize };
for hash in blob_hashes {
let indexed = IndexedBlobHash { hash, index };
hashes.push(indexed);
data.push(BlobData::default());
number += 1;
index += 1;
}
}
(data, hashes)
Expand Down
2 changes: 1 addition & 1 deletion crates/derive/src/sources/calldata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ mod tests {
use crate::{errors::PipelineErrorKind, test_utils::TestChainProvider};
use alloc::{vec, vec::Vec};
use alloy_consensus::{Signed, TxEip2930, TxEip4844, TxEip4844Variant, TxLegacy};
use alloy_primitives::{address, Address, Signature, TxKind};
use alloy_primitives::{address, Address, PrimitiveSignature as Signature, TxKind};

pub(crate) fn test_legacy_tx(to: Address) -> TxEnvelope {
let sig = Signature::test_signature();
Expand Down
3 changes: 0 additions & 3 deletions crates/derive/src/sources/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
//! [DataAvailabilityProvider]: crate::traits::DataAvailabilityProvider
//! [BlockInfo]: op_alloy_protocol::BlockInfo

mod blob_hash;
pub use blob_hash::IndexedBlobHash;

mod blob_data;
pub use blob_data::BlobData;

Expand Down
4 changes: 2 additions & 2 deletions crates/derive/src/test_utils/blob_provider.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! An implementation of the [BlobProvider] trait for tests.

use crate::{errors::BlobProviderError, sources::IndexedBlobHash, traits::BlobProvider};
use crate::{errors::BlobProviderError, traits::BlobProvider};
use alloc::{boxed::Box, vec::Vec};
use alloy_eips::eip4844::Blob;
use alloy_eips::eip4844::{Blob, IndexedBlobHash};
use alloy_primitives::{map::HashMap, B256};
use async_trait::async_trait;
use op_alloy_protocol::BlockInfo;
Expand Down
4 changes: 2 additions & 2 deletions crates/derive/src/traits/data_sources.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//! Contains traits that describe the functionality of various data sources used in the derivation
//! pipeline's stages.

use crate::{errors::PipelineErrorKind, sources::IndexedBlobHash, types::PipelineResult};
use crate::{errors::PipelineErrorKind, types::PipelineResult};
use alloc::{boxed::Box, fmt::Debug, string::ToString, vec::Vec};
use alloy_eips::eip4844::Blob;
use alloy_eips::eip4844::{Blob, IndexedBlobHash};
use alloy_primitives::Bytes;
use async_trait::async_trait;
use core::fmt::Display;
Expand Down
5 changes: 1 addition & 4 deletions crates/mpt/src/test_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,7 @@ pub(crate) async fn get_live_derivable_transactions_list(
let BlockTransactions::Full(txs) = block.transactions else {
anyhow::bail!("Did not fetch full block");
};
let consensus_txs = txs
.into_iter()
.map(|tx| TxEnvelope::try_from(tx).map_err(anyhow::Error::from))
.collect::<Result<Vec<_>>>()?;
let consensus_txs = txs.into_iter().map(TxEnvelope::from).collect::<Vec<_>>();

// Compute the derivable list
let mut list = ordered_trie_with_encoder(consensus_txs.as_ref(), |rlp: &TxEnvelope, buf| {
Expand Down

0 comments on commit 5e713ca

Please sign in to comment.