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

fix: compile errors due to unpinned dependencies #85

Merged
merged 4 commits into from
Sep 8, 2024
Merged
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
2,069 changes: 798 additions & 1,271 deletions Cargo.lock

Large diffs are not rendered by default.

45 changes: 25 additions & 20 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ panic = "unwind"
codegen-units = 1
incremental = false

# TODO(nico): remove this once we have a new release
[patch.crates-io]
op-alloy-protocol = { git = "https://github.com/alloy-rs/op-alloy", rev = "cf27ad9" }

[workspace.dependencies]
# Workspace
op-net = { path = "crates/net" }
Expand All @@ -123,12 +127,12 @@ rollup = { path = "crates/rollup" }
ser = { path = "crates/ser" }

# Optimism
superchain-registry = { version = "0.2.6", default-features = false }
kona-primitives = { git = "https://github.com/anton-rs/kona", default-features = true }
kona-derive = { git = "https://github.com/anton-rs/kona", default-features = true }
superchain-registry = { version = "0.3.4", default-features = false }
kona-primitives = { git = "https://github.com/anton-rs/kona", rev = "4ba2812", default-features = true }
kona-derive = { git = "https://github.com/anton-rs/kona", rev = "4ba2812", default-features = true }

# Alloy
alloy = { version = "0.2", features = [
alloy = { version = "0.3", features = [
"contract",
"providers",
"provider-http",
Expand All @@ -143,29 +147,30 @@ alloy = { version = "0.2", features = [
] }
alloy-primitives = { version = "0.8", features = ["serde"] }
alloy-rlp = "0.3.4"
op-alloy-rpc-types = "0.2"
op-alloy-protocol = { version = "0.2", default-features = false }
op-alloy-rpc-types = { version = "0.2", default-features = false }

# Tokio
tokio = { version = "1.21", default-features = false }

# SSZ
ssz_rs = "0.9.0"
ethereum_ssz = "0.7.1"

# Reth
reth = { git = "https://github.com/paradigmxyz/reth", version = "1.0.5" }
reth-chainspec = { git = "https://github.com/paradigmxyz/reth", version = "1.0.5" }
reth-discv5 = { git = "https://github.com/paradigmxyz/reth", version = "1.0.5" }
reth-execution-errors = { git = "https://github.com/paradigmxyz/reth", version = "1.0.5" }
reth-execution-types = { git = "https://github.com/paradigmxyz/reth", version = "1.0.5" }
reth-exex = { git = "https://github.com/paradigmxyz/reth", features = ["serde"], version = "1.0.5" }
reth-network-peers = { git = "https://github.com/paradigmxyz/reth", version = "1.0.5" }
reth-node-api = { git = "https://github.com/paradigmxyz/reth", version = "1.0.5" }
reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth", version = "1.0.5" }
reth-primitives = { git = "https://github.com/paradigmxyz/reth", version = "1.0.5" }
reth-provider = { git = "https://github.com/paradigmxyz/reth", version = "1.0.5" }
reth-revm = { git = "https://github.com/paradigmxyz/reth", version = "1.0.5" }
reth-evm = { git = "https://github.com/paradigmxyz/reth", version = "1.0.5" }
reth-tracing = { git = "https://github.com/paradigmxyz/reth", version = "1.0.5" }
reth = { git = "https://github.com/paradigmxyz/reth", tag = "v1.0.6" }
reth-chainspec = { git = "https://github.com/paradigmxyz/reth", tag = "v1.0.6" }
reth-discv5 = { git = "https://github.com/paradigmxyz/reth", tag = "v1.0.6" }
reth-execution-errors = { git = "https://github.com/paradigmxyz/reth", tag = "v1.0.6" }
reth-execution-types = { git = "https://github.com/paradigmxyz/reth", tag = "v1.0.6" }
reth-exex = { git = "https://github.com/paradigmxyz/reth", features = ["serde"], tag = "v1.0.6" }
reth-network-peers = { git = "https://github.com/paradigmxyz/reth", tag = "v1.0.6" }
reth-node-api = { git = "https://github.com/paradigmxyz/reth", tag = "v1.0.6" }
reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth", tag = "v1.0.6" }
reth-primitives = { git = "https://github.com/paradigmxyz/reth", tag = "v1.0.6" }
reth-provider = { git = "https://github.com/paradigmxyz/reth", tag = "v1.0.6" }
reth-revm = { git = "https://github.com/paradigmxyz/reth", tag = "v1.0.6" }
reth-evm = { git = "https://github.com/paradigmxyz/reth", tag = "v1.0.6" }
reth-tracing = { git = "https://github.com/paradigmxyz/reth", tag = "v1.0.6" }

# Networking
snap = "1.1.1"
Expand Down
1 change: 1 addition & 0 deletions crates/kona-providers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ kona-primitives.workspace = true
tracing.workspace = true
eyre.workspace = true
url.workspace = true
op-alloy-protocol.workspace = true

# Needed for compatibility with kona's ChainProvider trait
anyhow = { version = "1.0.86", default-features = false }
Expand Down
5 changes: 3 additions & 2 deletions crates/kona-providers/src/blob_provider.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use alloc::{collections::VecDeque, sync::Arc};
use hashbrown::HashMap;

use alloy::primitives::B256;
use alloy::{eips::eip4844::Blob, primitives::B256};
use async_trait::async_trait;
use eyre::{eyre, Result};
use kona_derive::{
Expand All @@ -12,7 +12,8 @@ use kona_derive::{
},
traits::BlobProvider,
};
use kona_primitives::{Blob, BlockInfo, IndexedBlobHash};
use kona_primitives::IndexedBlobHash;
use op_alloy_protocol::BlockInfo;
use parking_lot::Mutex;
use reth::primitives::BlobTransactionSidecar;
use tracing::warn;
Expand Down
2 changes: 1 addition & 1 deletion crates/net/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ alloy-rlp.workspace = true
kona-primitives.workspace = true

# Networking
ssz_rs.workspace = true
ethereum_ssz.workspace = true
snap.workspace = true
futures.workspace = true
discv5.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions crates/net/src/types/envelope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use alloy::{
rpc::types::engine::{ExecutionPayloadV1, ExecutionPayloadV2, ExecutionPayloadV3},
};
use eyre::Result;
use kona_primitives::{alloy_primitives::private::ssz::Decode, L2ExecutionPayload};
use ssz_rs::prelude::*;
use kona_primitives::L2ExecutionPayload;
use ssz::Decode;

use super::payload::PayloadHash;

Expand Down
1 change: 0 additions & 1 deletion crates/net/src/types/payload.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Execution Payload Types

use alloy::primitives::{keccak256, B256};
use ssz_rs::prelude::*;

/// Represents the Keccak256 hash of the block
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
Expand Down
11 changes: 5 additions & 6 deletions crates/rollup/src/driver/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use alloy::{
};
use async_trait::async_trait;
use kona_providers::chain_provider::reth_to_alloy_tx;
use reth::rpc::types::{BlockTransactions, Header, OtherFields};
use reth::rpc::types::{BlockTransactions, Header};
use reth_execution_types::Chain;
use reth_exex::ExExNotification;
use tokio::sync::mpsc::error::SendError;
Expand Down Expand Up @@ -88,7 +88,7 @@ impl Blocks {
impl From<Block<TxEnvelope>> for Blocks {
fn from(value: Block<TxEnvelope>) -> Self {
let mut blocks = BTreeMap::new();
blocks.insert(value.header.number.unwrap(), value);
blocks.insert(value.header.number, value);
Self(Arc::new(blocks))
}
}
Expand All @@ -97,7 +97,7 @@ impl From<Vec<Block<TxEnvelope>>> for Blocks {
fn from(value: Vec<Block<TxEnvelope>>) -> Self {
let mut blocks = BTreeMap::new();
for block in value {
blocks.insert(block.header.number.unwrap(), block);
blocks.insert(block.header.number, block);
}
Self(Arc::new(blocks))
}
Expand All @@ -116,7 +116,6 @@ impl From<Arc<Chain>> for Blocks {
),
size: Some(U256::from(sealed_block.size())),
withdrawals: sealed_block.withdrawals.clone().map(|w| w.into_inner()),
other: OtherFields::default(),
};
blocks.insert(*block_number, block);
}
Expand All @@ -139,7 +138,7 @@ impl From<ExExNotification> for ChainNotification {
// from reth::primitives::SealedBlock to alloy::rpc::types::Header
fn parse_reth_rpc_header(block: &reth::primitives::SealedBlock) -> Header {
Header {
hash: Some(block.header.hash()),
hash: block.header.hash(),
parent_hash: block.parent_hash,
uncles_hash: block.ommers_hash,
miner: block.beneficiary,
Expand All @@ -148,7 +147,7 @@ fn parse_reth_rpc_header(block: &reth::primitives::SealedBlock) -> Header {
receipts_root: block.receipts_root,
logs_bloom: block.logs_bloom,
difficulty: block.difficulty,
number: Some(block.number),
number: block.number,
gas_limit: block.gas_limit as u128,
gas_used: block.gas_used as u128,
timestamp: block.timestamp,
Expand Down
23 changes: 5 additions & 18 deletions crates/rollup/src/driver/context/standalone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ impl DriverContext for StandaloneContext {
// generic but currently are very coupled to the node mode (standalone vs exex).

let block = self.new_block_rx.recv().await?;
let block_num = block.header.number.unwrap_or(0);
let block_num = block.header.number;

let entry = self.reorg_cache.entry(block_num).or_default();
entry.insert(block.header.hash.unwrap(), block.clone());
entry.insert(block.header.hash, block.clone());

if block_num <= self.l1_tip {
todo!("handle reorgs");
Expand Down Expand Up @@ -187,7 +187,6 @@ fn parse_reth_rpc_block(block: Block) -> Block<TxEnvelope> {
transactions: BlockTransactions::Full(txs),
size: block.size,
withdrawals: block.withdrawals,
other: block.other,
}
}

Expand Down Expand Up @@ -243,16 +242,13 @@ mod tests {
// Simulate receiving 100 blocks
for i in 1..=100 {
let block = create_mock_block(i);
ctx.reorg_cache.entry(i).or_default().insert(block.header.hash.unwrap(), block);
ctx.reorg_cache.entry(i).or_default().insert(block.header.hash, block);
}

// Simulate receiving a new block that should trigger pruning
let new_block = create_mock_block(101);
ctx.l1_tip = 101;
ctx.reorg_cache
.entry(101)
.or_default()
.insert(new_block.header.hash.unwrap(), new_block.clone());
ctx.reorg_cache.entry(101).or_default().insert(new_block.header.hash, new_block.clone());

// Manually call the pruning logic
ctx.reorg_cache.retain(|num, _| *num > 101 - FINALIZATION_TIMEOUT);
Expand All @@ -272,25 +268,16 @@ mod tests {
// Send a processed tip event
let result = ctx.send_processed_tip_event(100);
assert!(result.is_ok());

// Verify that the event was sent correctly
let received_tip = ctx.processed_block_rx.recv().await.unwrap();
assert_eq!(received_tip, 100);
}

// Helper function to create a mock Block<TxEnvelope>
fn create_mock_block(number: u64) -> Block<TxEnvelope> {
Block {
header: Header {
number: Some(number),
hash: Some(B256::random()),
..Default::default()
},
header: Header { number, hash: B256::random(), ..Default::default() },
transactions: BlockTransactions::Full(vec![]),
uncles: vec![],
size: None,
withdrawals: None,
other: Default::default(),
}
}
}
27 changes: 12 additions & 15 deletions crates/rollup/src/driver/cursor.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
use hashbrown::HashMap;
use std::{
collections::{BTreeMap, VecDeque},
sync::Arc,
};
use std::collections::{BTreeMap, VecDeque};

use kona_primitives::{BlockInfo, L2BlockInfo};
use superchain_registry::RollupConfig;

/// A cursor that keeps track of the L2 tip block for a given L1 origin block.
///
Expand All @@ -16,7 +12,7 @@ pub struct SyncCursor {
/// The block cache capacity before evicting old entries
/// (to avoid unbounded memory growth)
capacity: usize,
/// The channel timeout for the [RollupConfig] used to create the cursor.
/// The channel timeout used to create the cursor.
channel_timeout: u64,
/// The L1 origin block numbers for which we have an L2 block in the cache.
/// Used to keep track of the order of insertion and evict the oldest entry.
Expand All @@ -30,23 +26,24 @@ pub struct SyncCursor {
impl SyncCursor {
/// Create a new cursor with the default cache capacity.
pub fn new(channel_timeout: u64) -> Self {
// NOTE: capacity must be greater than the `channel_timeout` to allow
// for derivation to proceed through a deep reorg.
// Ref: <https://specs.optimism.io/protocol/derivation.html#timeouts>
let capacity = channel_timeout as usize + 5;

Self {
// NOTE: capacity must be greater than the `channel_timeout` to allow
// for derivation to proceed through a deep reorg.
// Ref: <https://specs.optimism.io/protocol/derivation.html#timeouts>
capacity: channel_timeout + 5,
capacity,
channel_timeout,
l1_origin_key_order: VecDeque::with_capacity(capacity),
l1_origin_block_info: HashMap::with_capacity(capacity),
l1_origin_to_l2_blocks: BTreeMap::new(),
}
}

/// Get the current L2 tip and the corresponding L1 origin block info.
pub fn tip(&self) -> (L2BlockInfo, BlockInfo) {
if let Some((origin_number, l2_tip)) = self.l1_origin_to_l2_blocks.last_key_value() {
let origin_block = self.l1_origin_block_info[origin_number];
(*l2_tip, origin_block)
/// Get the current L2 tip
pub fn tip(&self) -> L2BlockInfo {
if let Some((_, l2_tip)) = self.l1_origin_to_l2_blocks.last_key_value() {
*l2_tip
} else {
unreachable!("cursor must be initialized with one block before advancing")
}
Expand Down
Loading