Skip to content

Commit

Permalink
feat: port op-alloy -> maili in all crates
Browse files Browse the repository at this point in the history
  • Loading branch information
merklefruit committed Jan 16, 2025
1 parent f4b0a07 commit ec512d0
Show file tree
Hide file tree
Showing 31 changed files with 75 additions and 65 deletions.
6 changes: 4 additions & 2 deletions crates/driver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ alloy-provider = { workspace = true, features = ["ipc", "ws", "reqwest"] }
alloy-primitives = { workspace = true, features = ["map"] }

# Op Alloy
op-alloy-genesis.workspace = true
op-alloy-protocol.workspace = true
op-alloy-rpc-types-engine.workspace = true

# Maili
maili-genesis.workspace = true
maili-protocol.workspace = true

# Reth
reth-primitives.workspace = true
reth-execution-types.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions crates/driver/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
use alloy_rpc_types_engine::JwtSecret;
use kona_derive::traits::ChainProvider;
use kona_driver::PipelineCursor;
use op_alloy_genesis::RollupConfig;
use op_alloy_protocol::{BatchValidationProvider, BlockInfo, L2BlockInfo};
use maili_genesis::RollupConfig;
use maili_protocol::{BatchValidationProvider, BlockInfo, L2BlockInfo};
use serde::{Deserialize, Serialize};
use std::sync::Arc;
use url::Url;
Expand Down
3 changes: 1 addition & 2 deletions crates/driver/src/context/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ fn parse_reth_header_to_alloy_rpc(block: &reth_primitives::SealedBlock) -> Heade
blob_gas_used: block.blob_gas_used,
excess_blob_gas: block.excess_blob_gas,
parent_beacon_block_root: block.parent_beacon_block_root,
requests_hash: block.requests_hash,
target_blobs_per_block: None,
requests_hash: block.requests_root,
},
}
}
2 changes: 1 addition & 1 deletion crates/driver/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ where
loop {
tokio::select! {
result = driver.advance_to_target(&self.cfg.rollup_config, None) => match result {
Ok((bn, hash)) => {
Ok((bn, hash, _output_root)) => {
error!("Driver unexpectedly stopped at target block: {} {}", bn, hash);
}
Err(e) => {
Expand Down
2 changes: 1 addition & 1 deletion crates/driver/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/anton-rs/hilo/issues/")]
#![doc(issue_tracker_base_url = "https://github.com/op-rs/hilo/issues/")]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]

Expand Down
4 changes: 2 additions & 2 deletions crates/driver/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ use kona_derive::{
types::{PipelineResult, Signal, StepResult},
};
use kona_driver::{DriverPipeline, PipelineCursor};
use op_alloy_genesis::{RollupConfig, SystemConfig};
use op_alloy_protocol::{BlockInfo, L2BlockInfo};
use maili_genesis::{RollupConfig, SystemConfig};
use maili_protocol::{BlockInfo, L2BlockInfo};
use op_alloy_rpc_types_engine::OpAttributesWithParent;
use std::{boxed::Box, sync::Arc};

Expand Down
8 changes: 5 additions & 3 deletions crates/engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ alloy-transport-http = { workspace = true, features = ["jwt-auth"] }
alloy-rpc-types-engine = { workspace = true, features = ["jwt", "serde"] }

# Op Alloy
op-alloy-genesis.workspace = true
op-alloy-provider.workspace = true
op-alloy-consensus.workspace = true
op-alloy-protocol.workspace = true
op-alloy-rpc-types-engine.workspace = true
op-alloy-consensus.workspace = true

# Maili
maili-genesis.workspace = true
maili-protocol.workspace = true

# Misc
async-trait.workspace = true
Expand Down
8 changes: 4 additions & 4 deletions crates/engine/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use alloy_eips::eip1898::BlockNumberOrTag;
use alloy_network::AnyNetwork;
use alloy_primitives::{Bytes, B256};
use alloy_provider::{ReqwestProvider, RootProvider /* , ext::EngineApi */};
use alloy_provider::{ReqwestProvider, RootProvider};
use alloy_rpc_client::RpcClient;
use alloy_rpc_types_engine::{
ExecutionPayloadEnvelopeV2, ExecutionPayloadFieldV2, ExecutionPayloadInputV2,
Expand All @@ -19,8 +19,8 @@ use alloy_transport_http::{
};
use async_trait::async_trait;
use http_body_util::Full;
use op_alloy_genesis::RollupConfig;
use op_alloy_protocol::{BatchValidationProvider, BlockInfo, L2BlockInfo};
use maili_genesis::RollupConfig;
use maili_protocol::{BatchValidationProvider, BlockInfo, L2BlockInfo};
use op_alloy_provider::ext::engine::OpEngineApi;
use op_alloy_rpc_types_engine::{OpExecutionPayloadEnvelopeV3, OpPayloadAttributes};
use std::sync::Arc;
Expand Down Expand Up @@ -66,7 +66,7 @@ impl EngineClient {
/// Returns which fork choice version to use based on the timestamp
/// and rollup config.
pub fn fork_choice_version(&self, timestamp: u64) -> u64 {
// TODO: replace this with https://github.com/alloy-rs/op-alloy/pull/321
// TODO: replace this with https://github.com/alloy-rs/maili/pull/321
// once it's merged and updated in kona.
if self.cfg.ecotone_time.is_some_and(|t| timestamp >= t) {
// Cancun
Expand Down
4 changes: 2 additions & 2 deletions crates/engine/src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use alloy_rpc_types_engine::{
use async_trait::async_trait;
use hilo_providers_alloy::AlloyL2ChainProvider;
use kona_driver::Executor;
use maili_genesis::RollupConfig;
use maili_protocol::{BatchValidationProvider, BlockInfo};
use op_alloy_consensus::OpBlock;
use op_alloy_genesis::RollupConfig;
use op_alloy_protocol::{BatchValidationProvider, BlockInfo};
use op_alloy_rpc_types_engine::OpPayloadAttributes;
use std::{sync::Arc, time::Duration};
use tokio::time::sleep;
Expand Down
2 changes: 1 addition & 1 deletion crates/engine/src/epoch.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Contains an epoch type.
use alloy_primitives::B256;
use op_alloy_protocol::BlockInfo;
use maili_protocol::BlockInfo;

/// L1 epoch block
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
Expand Down
2 changes: 1 addition & 1 deletion crates/engine/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/anton-rs/hilo/issues/")]
#![doc(issue_tracker_base_url = "https://github.com/op-rs/hilo/issues/")]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]

Expand Down
2 changes: 1 addition & 1 deletion crates/engine/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use alloy_rpc_types_engine::{
ForkchoiceState, ForkchoiceUpdated, PayloadId, PayloadStatus,
};
use async_trait::async_trait;
use op_alloy_protocol::L2BlockInfo;
use maili_protocol::L2BlockInfo;
use op_alloy_rpc_types_engine::{OpExecutionPayloadEnvelopeV3, OpPayloadAttributes};

/// Engine trait specifies the interface between the hilo-engine and the engine-api.
Expand Down
2 changes: 0 additions & 2 deletions crates/engine/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ impl TrustedPayloadValidator {
// Withdrawals on optimism are always empty, *after* canyon (Shanghai) activation
withdrawals: (header.timestamp >= self.canyon_activation).then_some(Vec::default()),
parent_beacon_block_root: header.parent_beacon_block_root,
target_blobs_per_block: header.target_blobs_per_block,
max_blobs_per_block: None,
},
transactions: Some(transactions),
no_tx_pool: Some(true),
Expand Down
7 changes: 3 additions & 4 deletions crates/hilo/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
## `hilo`

<a href="https://github.com/anton-rs/hilo/actions/workflows/rust_ci.yaml"><img src="https://github.com/anton-rs/hilo/actions/workflows/rust_ci.yaml/badge.svg?label=ci" alt="CI"></a>
<a href="https://github.com/op-rs/hilo/actions/workflows/rust_ci.yaml"><img src="https://github.com/op-rs/hilo/actions/workflows/rust_ci.yaml/badge.svg?label=ci" alt="CI"></a>
<a href="https://crates.io/crates/hilo"><img src="https://img.shields.io/crates/v/hilo.svg?label=hilo&labelColor=2a2f35" alt="Kona Derive Alloy"></a>
<a href="https://github.com/anton-rs/hilo/blob/main/LICENSE.md"><img src="https://img.shields.io/badge/License-MIT-d1d1f6.svg?label=license&labelColor=2a2f35" alt="License"></a>
<a href="https://img.shields.io/codecov/c/github/anton-rs/hilo"><img src="https://img.shields.io/codecov/c/github/anton-rs/hilo" alt="Codecov"></a>

<a href="https://github.com/op-rs/hilo/blob/main/LICENSE.md"><img src="https://img.shields.io/badge/License-MIT-d1d1f6.svg?label=license&labelColor=2a2f35" alt="License"></a>
<a href="https://img.shields.io/codecov/c/github/op-rs/hilo"><img src="https://img.shields.io/codecov/c/github/op-rs/hilo" alt="Codecov"></a>

A suite of `std` components for the Superchain.

Expand Down
4 changes: 2 additions & 2 deletions crates/hilo/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![doc = include_str!("../README.md")]
#![doc(
html_logo_url = "https://raw.githubusercontent.com/anton-rs/hilo/main/assets/alloy.jpg",
html_favicon_url = "https://raw.githubusercontent.com/anton-rs/hilo/main/assets/favicon.ico"
html_logo_url = "https://raw.githubusercontent.com/op-rs/hilo/main/assets/alloy.jpg",
html_favicon_url = "https://raw.githubusercontent.com/op-rs/hilo/main/assets/favicon.ico"
)]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
Expand Down
2 changes: 1 addition & 1 deletion crates/net/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ futures.workspace = true
discv5.workspace = true
libp2p = { workspace = true, features = ["macros", "tokio", "tcp", "noise", "gossipsub", "ping", "yamux"] }
openssl = { workspace = true, features = ["vendored"] }
libp2p-identity = { workspace = true, features = [ "secp256k1" ] }
libp2p-identity = { workspace = true, features = ["secp256k1"] }

# Misc
eyre.workspace = true
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/anton-rs/hilo/issues/")]
#![doc(issue_tracker_base_url = "https://github.com/op-rs/hilo/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 crates/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ alloy-transport.workspace = true
alloy-primitives.workspace = true
alloy-rpc-types-engine = { workspace = true, features = ["jwt", "serde"] }

# op-alloy
op-alloy-genesis = { workspace = true, features = ["serde"] }
# maili
maili-genesis = { workspace = true, features = ["serde"] }

# Misc
serde.workspace = true
Expand All @@ -32,4 +32,4 @@ url = { workspace = true, features = ["serde"] }

[dev-dependencies]
serde_json.workspace = true
op-alloy-registry.workspace = true
maili-registry.workspace = true
4 changes: 2 additions & 2 deletions crates/node/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use crate::SyncMode;
use alloy_rpc_types_engine::JwtSecret;
use op_alloy_genesis::RollupConfig;
use maili_genesis::RollupConfig;
use serde::{Deserialize, Serialize};
use url::Url;

Expand Down Expand Up @@ -90,7 +90,7 @@ where
#[cfg(test)]
mod tests {
use super::*;
use op_alloy_registry::ROLLUP_CONFIGS;
use maili_registry::ROLLUP_CONFIGS;

#[test]
fn test_roundtrip_config() {
Expand Down
2 changes: 1 addition & 1 deletion crates/node/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/anton-rs/hilo/issues/")]
#![doc(issue_tracker_base_url = "https://github.com/op-rs/hilo/issues/")]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]

Expand Down
6 changes: 4 additions & 2 deletions crates/providers-alloy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ alloy-provider = { workspace = true, features = ["ipc", "ws", "reqwest"] }
alloy-primitives = { workspace = true, features = ["map"] }

# Op Alloy
op-alloy-genesis.workspace = true
op-alloy-protocol.workspace = true
op-alloy-consensus.workspace = true

# Maili
maili-genesis.workspace = true
maili-protocol.workspace = true

# Misc
url.workspace = true
tracing.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/providers-alloy/src/blob_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use alloy_primitives::{map::HashMap, B256};
use async_trait::async_trait;
use eyre::{eyre, Result};
use kona_derive::{errors::BlobProviderError, traits::BlobProvider};
use op_alloy_protocol::BlockInfo;
use maili_protocol::BlockInfo;
use parking_lot::Mutex;
use tracing::warn;
use url::Url;
Expand Down
2 changes: 1 addition & 1 deletion crates/providers-alloy/src/blobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use alloy_eips::eip4844::{Blob, BlobTransactionSidecarItem, IndexedBlobHash};
use alloy_rpc_types_beacon::sidecar::BlobData;
use async_trait::async_trait;
use kona_derive::{errors::BlobProviderError, traits::BlobProvider};
use op_alloy_protocol::BlockInfo;
use maili_protocol::BlockInfo;
use std::{
boxed::Box,
string::{String, ToString},
Expand Down
2 changes: 1 addition & 1 deletion crates/providers-alloy/src/chain_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use kona_derive::{
traits::ChainProvider,
};
use lru::LruCache;
use op_alloy_protocol::BlockInfo;
use maili_protocol::BlockInfo;
use std::{boxed::Box, num::NonZeroUsize, vec::Vec};

const CACHE_SIZE: usize = 16;
Expand Down
17 changes: 11 additions & 6 deletions crates/providers-alloy/src/l2_chain_provider.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Providers that use alloy provider types on the backend.
use alloy_consensus::Block;
use alloy_primitives::{Bytes, U64};
use alloy_provider::{Provider, ReqwestProvider};
use alloy_rlp::Decodable;
Expand All @@ -10,9 +11,9 @@ use kona_derive::{
traits::L2ChainProvider,
};
use lru::LruCache;
use op_alloy_consensus::OpBlock;
use op_alloy_genesis::{RollupConfig, SystemConfig};
use op_alloy_protocol::{to_system_config, BatchValidationProvider, L2BlockInfo};
use maili_genesis::{RollupConfig, SystemConfig};
use maili_protocol::{to_system_config, BatchValidationProvider, L2BlockInfo};
use op_alloy_consensus::OpTxEnvelope;
use std::{boxed::Box, num::NonZeroUsize, sync::Arc};

const CACHE_SIZE: usize = 16;
Expand All @@ -30,7 +31,7 @@ pub struct AlloyL2ChainProvider {
/// The rollup configuration.
rollup_config: Arc<RollupConfig>,
/// `block_by_number` LRU cache.
block_by_number_cache: LruCache<u64, OpBlock>,
block_by_number_cache: LruCache<u64, Block<OpTxEnvelope>>,
/// `l2_block_info_by_number` LRU cache.
l2_block_info_by_number_cache: LruCache<u64, L2BlockInfo>,
/// `system_config_by_l2_hash` LRU cache.
Expand Down Expand Up @@ -105,6 +106,7 @@ impl From<AlloyL2ChainProviderError> for PipelineErrorKind {
#[async_trait]
impl BatchValidationProvider for AlloyL2ChainProvider {
type Error = AlloyL2ChainProviderError;
type Transaction = OpTxEnvelope;

async fn l2_block_info_by_number(&mut self, number: u64) -> Result<L2BlockInfo, Self::Error> {
if let Some(l2_block_info) = self.l2_block_info_by_number_cache.get(&number) {
Expand All @@ -128,7 +130,10 @@ impl BatchValidationProvider for AlloyL2ChainProvider {
Ok(l2_block_info)
}

async fn block_by_number(&mut self, number: u64) -> Result<OpBlock, Self::Error> {
async fn block_by_number(
&mut self,
number: u64,
) -> Result<Block<Self::Transaction>, Self::Error> {
if let Some(block) = self.block_by_number_cache.get(&number) {
return Ok(block.clone());
}
Expand All @@ -141,7 +146,7 @@ impl BatchValidationProvider for AlloyL2ChainProvider {
return Err(AlloyL2ChainProviderError::BlockNotFound(number));
}
};
let block = match OpBlock::decode(&mut raw_block.as_ref()) {
let block: Block<Self::Transaction> = match Block::decode(&mut raw_block.as_ref()) {
Ok(b) => b,
Err(_) => {
return Err(AlloyL2ChainProviderError::OpBlockDecode(number));
Expand Down
2 changes: 1 addition & 1 deletion crates/providers-alloy/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/anton-rs/hilo/issues/")]
#![doc(issue_tracker_base_url = "https://github.com/op-rs/hilo/issues/")]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]

Expand Down
6 changes: 4 additions & 2 deletions crates/providers-local/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ alloy-consensus.workspace = true
alloy-primitives = { workspace = true, features = ["map"] }

# Op Alloy
op-alloy-genesis.workspace = true
op-alloy-protocol.workspace = true
op-alloy-consensus.workspace = true

# Maili
maili-genesis.workspace = true
maili-protocol.workspace = true

# Reth
reth-provider.workspace = true
reth-primitives.workspace = true
Expand Down
Loading

0 comments on commit ec512d0

Please sign in to comment.