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: rm kona-providers, update dependencies #101

Merged
merged 5 commits into from
Oct 16, 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,503 changes: 1,639 additions & 864 deletions Cargo.lock

Large diffs are not rendered by default.

68 changes: 37 additions & 31 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,12 @@ edition = "2021"
rust-version = "1.81"
authors = []
license = "MIT OR Apache-2.0"
repository = "https://github.com/paradigmxyz/op-rs"
repository = "https://github.com/ithacaxyz/op-rs"
keywords = ["ethereum", "crypto"]
categories = ["cryptography", "cryptography::cryptocurrencies"]

[workspace]
members = [
"bin/hera",
"bin/op-rs",
"crates/net",
"crates/kona-providers",
"crates/rollup",
"crates/ser",
]
members = ["bin/*", "crates/*"]
default-members = ["bin/hera"]

# Explicitly set the resolver to version 2, which is the default for packages with edition >= 2021
Expand All @@ -30,20 +23,30 @@ panic = "unwind"
codegen-units = 1
incremental = false

[patch.crates-io]
op-alloy-consensus = { git = "https://github.com/alloy-rs/op-alloy", branch = "main" }
op-alloy-protocol = { git = "https://github.com/alloy-rs/op-alloy", branch = "main" }
op-alloy-genesis = { git = "https://github.com/alloy-rs/op-alloy", branch = "main" }
op-alloy-rpc-types = { git = "https://github.com/alloy-rs/op-alloy", branch = "main" }
op-alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/op-alloy", branch = "main" }

[workspace.dependencies]
# Workspace
op-net = { path = "crates/net" }
kona-providers = { path = "crates/kona-providers" }
rollup = { path = "crates/rollup" }
ser = { path = "crates/ser" }
kona-providers-local = { path = "crates/providers-local" }

# Optimism
superchain = { version = "0.5", default-features = false }
# superchain = { version = "0.7", default-features = false }
superchain = { git = "https://github.com/anton-rs/superchain", branch = "main", default-features = false }
kona-providers = { git = "https://github.com/anton-rs/kona", branch = "main", default-features = true }
kona-providers-alloy = { git = "https://github.com/anton-rs/kona", branch = "main", default-features = true }
kona-primitives = { git = "https://github.com/anton-rs/kona", branch = "main", default-features = true }
kona-derive = { git = "https://github.com/anton-rs/kona", branch = "main", default-features = true }

# Alloy
alloy = { version = "0.3.6", features = [
alloy = { version = "0.4.2", features = [
"contract",
"providers",
"provider-http",
Expand All @@ -58,10 +61,13 @@ alloy = { version = "0.3.6", features = [
] }
alloy-primitives = { version = "0.8", features = ["serde"] }
alloy-rlp = "0.3"
op-alloy-protocol = { version = "0.2.12", default-features = false }
op-alloy-rpc-types = { version = "0.2.12", default-features = false }
op-alloy-rpc-types-engine = { version = "0.2.12", default-features = false }
op-alloy-genesis = { version = "0.2.12", 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 = { version = "0.4.0", default-features = false }
op-alloy-rpc-types-engine = { version = "0.4.0", default-features = false }

# Tokio
tokio = { version = "1.21", default-features = false }
Expand All @@ -71,20 +77,20 @@ serde_json = "1"
ethereum_ssz = "0.7.1"

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

# Networking
snap = "1.1.1"
Expand All @@ -109,7 +115,7 @@ async-trait = "0.1.81"
hashbrown = "0.14.5"
parking_lot = "0.12.3"
unsigned-varint = "0.8.0"
rand = { version = "0.8.3", features = ["small_rng"], default-features = false }
rand = { version = "0.8.5", features = ["small_rng", "alloc", "getrandom"], default-features = false }
url = "2.5.2"

[workspace.metadata.docs.rs]
Expand Down
5 changes: 3 additions & 2 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ doc-lints:

# Lint
lint:
cargo clippy --workspace --examples --tests --benches --all-features \
&& cargo hack check
cargo clippy --workspace --examples --tests --benches --all-features && \
cargo +stable install cargo-hack --locked && \
cargo hack check

# Format
fmt:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ shall be dual licensed as above, without any additional terms or conditions.
[apache-badge]: https://img.shields.io/badge/license-Apache--2.0-blue.svg
[mit-url]: LICENSE-MIT
[apache-url]: LICENSE-APACHE
[actions-badge]: https://github.com/paradigmxyz/op-rs/workflows/unit/badge.svg
[actions-url]: https://github.com/paradigmxyz/op-rs/actions?query=workflow%3ACI+branch%3Amain
[actions-badge]: https://github.com/ithacaxyz/op-rs/workflows/unit/badge.svg
[actions-url]: https://github.com/ithacaxyz/op-rs/actions?query=workflow%3ACI+branch%3Amain
2 changes: 1 addition & 1 deletion bin/hera/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Hera OP Stack Rollup node

#![doc = include_str!("../README.md")]
#![doc(issue_tracker_base_url = "https://github.com/paradigmxyz/op-rs/issues/")]
#![doc(issue_tracker_base_url = "https://github.com/ithacaxyz/op-rs/issues/")]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]

Expand Down
6 changes: 3 additions & 3 deletions bin/op-rs/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//! Runner for OP-RS execution extensions

#![doc = include_str!("../README.md")]
#![doc(issue_tracker_base_url = "https://github.com/paradigmxyz/op-rs/issues/")]
#![doc(issue_tracker_base_url = "https://github.com/ithacaxyz/op-rs/issues/")]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]

use clap::Parser;
use eyre::{bail, Result};
use reth::{args::utils::DefaultChainSpecParser, cli::Cli};
use reth::{args::utils::EthereumChainSpecParser, cli::Cli};
use reth_node_ethereum::EthereumNode;
use tracing::{info, warn};

Expand All @@ -29,7 +29,7 @@ pub(crate) struct RethArgsExt {
}

fn main() -> Result<()> {
Cli::<DefaultChainSpecParser, RethArgsExt>::parse().run(|builder, args| async move {
Cli::<EthereumChainSpecParser, RethArgsExt>::parse().run(|builder, args| async move {
if args.hera {
info!("Running Reth with the Hera Execution Extension");
let Some(hera_args) = args.hera_config else {
Expand Down
17 changes: 0 additions & 17 deletions crates/kona-providers/src/lib.rs

This file was deleted.

5 changes: 1 addition & 4 deletions crates/net/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@ rust-version.workspace = true
# Alloy
alloy.workspace = true
alloy-rlp.workspace = true

# Kona
kona-primitives.workspace = true
op-alloy-rpc-types-engine = { workspace = true, features = ["std"] }

# Networking
ethereum_ssz.workspace = true
snap.workspace = true
futures.workspace = true
discv5.workspace = true
Expand Down
17 changes: 9 additions & 8 deletions crates/net/src/driver.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
//! Driver for network services.

use crate::{
builder::NetworkDriverBuilder, discovery::driver::DiscoveryDriver,
gossip::driver::GossipDriver, types::envelope::ExecutionPayloadEnvelope,
};
use alloy::primitives::Address;
use eyre::Result;
use std::sync::mpsc::Receiver;

use alloy::{primitives::Address, rpc::types::engine::ExecutionPayload};
use eyre::Result;
use tokio::{select, sync::watch};

use crate::{
builder::NetworkDriverBuilder, discovery::driver::DiscoveryDriver, gossip::driver::GossipDriver,
};

/// NetworkDriver
///
/// Contains the logic to run Optimism's consensus-layer networking stack.
Expand All @@ -17,7 +18,7 @@ use tokio::{select, sync::watch};
/// - Peer discovery with `discv5`.
pub struct NetworkDriver {
/// Channel to receive unsafe blocks.
pub(crate) unsafe_block_recv: Option<Receiver<ExecutionPayloadEnvelope>>,
pub(crate) unsafe_block_recv: Option<Receiver<ExecutionPayload>>,
/// Channel to send unsafe signer updates.
pub(crate) unsafe_block_signer_sender: Option<watch::Sender<Address>>,
/// The swarm instance.
Expand All @@ -33,7 +34,7 @@ impl NetworkDriver {
}

/// Take the unsafe block receiver.
pub fn take_unsafe_block_recv(&mut self) -> Option<Receiver<ExecutionPayloadEnvelope>> {
pub fn take_unsafe_block_recv(&mut self) -> Option<Receiver<ExecutionPayload>> {
self.unsafe_block_recv.take()
}

Expand Down
27 changes: 14 additions & 13 deletions crates/net/src/gossip/handler.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
//! Block Handler

use crate::types::envelope::ExecutionPayloadEnvelope;
use alloy::primitives::Address;
use libp2p::gossipsub::{IdentTopic, Message, MessageAcceptance, TopicHash};
use std::{
sync::mpsc::{channel, Receiver, Sender},
time::SystemTime,
};

use alloy::{primitives::Address, rpc::types::engine::ExecutionPayload};
use libp2p::gossipsub::{IdentTopic, Message, MessageAcceptance, TopicHash};
use op_alloy_rpc_types_engine::OpNetworkPayloadEnvelope;
use tokio::sync::watch;

/// This trait defines the functionality required to process incoming messages
Expand All @@ -29,7 +30,7 @@ pub struct BlockHandler {
/// blockchains.
pub chain_id: u64,
/// A channel sender to forward new blocks to other modules
pub block_sender: Sender<ExecutionPayloadEnvelope>,
pub block_sender: Sender<ExecutionPayload>,
/// A [Receiver] to monitor changes to the unsafe block signer.
pub unsafe_signer_recv: watch::Receiver<Address>,
/// The libp2p topic for pre Canyon/Shangai blocks.
Expand All @@ -47,19 +48,19 @@ impl Handler for BlockHandler {
tracing::debug!("received block");

let decoded = if msg.topic == self.blocks_v1_topic.hash() {
ExecutionPayloadEnvelope::decode_v1(&msg.data)
OpNetworkPayloadEnvelope::decode_v1(&msg.data)
} else if msg.topic == self.blocks_v2_topic.hash() {
ExecutionPayloadEnvelope::decode_v2(&msg.data)
OpNetworkPayloadEnvelope::decode_v2(&msg.data)
} else if msg.topic == self.blocks_v3_topic.hash() {
ExecutionPayloadEnvelope::decode_v3(&msg.data)
OpNetworkPayloadEnvelope::decode_v3(&msg.data)
} else {
return MessageAcceptance::Reject;
};

match decoded {
Ok(envelope) => {
if self.block_valid(&envelope) {
_ = self.block_sender.send(envelope);
_ = self.block_sender.send(envelope.payload);
MessageAcceptance::Accept
} else {
tracing::warn!("invalid unsafe block");
Expand All @@ -84,7 +85,7 @@ impl BlockHandler {
pub fn new(
chain_id: u64,
unsafe_recv: watch::Receiver<Address>,
) -> (Self, Receiver<ExecutionPayloadEnvelope>) {
) -> (Self, Receiver<ExecutionPayload>) {
let (sender, recv) = channel();

let handler = Self {
Expand All @@ -103,15 +104,15 @@ impl BlockHandler {
///
/// True if the block is less than 1 minute old, and correctly signed by the unsafe block
/// signer.
fn block_valid(&self, envelope: &ExecutionPayloadEnvelope) -> bool {
fn block_valid(&self, envelope: &OpNetworkPayloadEnvelope) -> bool {
let current_timestamp =
SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_secs();

let is_future = envelope.payload.timestamp > current_timestamp + 5;
let is_past = envelope.payload.timestamp < current_timestamp - 60;
let is_future = envelope.payload.timestamp() > current_timestamp + 5;
let is_past = envelope.payload.timestamp() < current_timestamp - 60;
let time_valid = !(is_future || is_past);

let msg = envelope.hash.signature_message(self.chain_id);
let msg = envelope.payload_hash.signature_message(self.chain_id);
let block_signer = *self.unsafe_signer_recv.borrow();
let Ok(msg_signer) = envelope.signature.recover_address_from_msg(msg) else {
// TODO: add telemetry here if this happens.
Expand Down
2 changes: 1 addition & 1 deletion crates/net/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![doc = include_str!("../README.md")]
#![doc(issue_tracker_base_url = "https://github.com/paradigmxyz/op-rs/issues/")]
#![doc(issue_tracker_base_url = "https://github.com/ithacaxyz/op-rs/issues/")]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]

Expand Down
Loading