From cdfa298ff83558fa4d1bf46428c05d5be94dc569 Mon Sep 17 00:00:00 2001 From: refcell Date: Thu, 9 Jan 2025 09:26:13 -0700 Subject: [PATCH 1/2] chore: remove protocol crate --- Cargo.toml | 1 - crates/op-alloy/Cargo.toml | 6 - crates/op-alloy/src/lib.rs | 4 - crates/protocol/Cargo.toml | 26 -- crates/protocol/README.md | 12 - crates/protocol/src/lib.rs | 10 - crates/protocol/src/test_utils.rs | 112 -------- crates/protocol/src/utils.rs | 305 ---------------------- crates/rpc-jsonrpsee/Cargo.toml | 4 +- crates/rpc-jsonrpsee/src/traits.rs | 2 +- crates/rpc-types-engine/Cargo.toml | 6 +- crates/rpc-types-engine/src/attributes.rs | 2 +- scripts/check_no_std.sh | 1 - 13 files changed, 8 insertions(+), 483 deletions(-) delete mode 100644 crates/protocol/Cargo.toml delete mode 100644 crates/protocol/README.md delete mode 100644 crates/protocol/src/lib.rs delete mode 100644 crates/protocol/src/test_utils.rs delete mode 100644 crates/protocol/src/utils.rs diff --git a/Cargo.toml b/Cargo.toml index 6928443f9..a75850aef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,6 @@ rustdoc-args = ["--cfg", "docsrs"] [workspace.dependencies] # Workspace op-alloy-genesis = { version = "0.9.2", path = "crates/genesis", default-features = false } -op-alloy-protocol = { version = "0.9.2", path = "crates/protocol", default-features = false } op-alloy-consensus = { version = "0.9.2", path = "crates/consensus", default-features = false } op-alloy-network = { version = "0.9.2", path = "crates/network", default-features = false } op-alloy-provider = { version = "0.9.2", path = "crates/provider", default-features = false } diff --git a/crates/op-alloy/Cargo.toml b/crates/op-alloy/Cargo.toml index 68b49b905..54d260944 100644 --- a/crates/op-alloy/Cargo.toml +++ b/crates/op-alloy/Cargo.toml @@ -22,7 +22,6 @@ workspace = true op-alloy-consensus = { workspace = true, optional = true } op-alloy-genesis = { workspace = true, optional = true } op-alloy-network = { workspace = true, optional = true } -op-alloy-protocol = { workspace = true, optional = true } op-alloy-registry = { workspace = true, optional = true } op-alloy-provider = { workspace = true, optional = true } op-alloy-rpc-jsonrpsee = { workspace = true, optional = true } @@ -35,7 +34,6 @@ default = ["std", "k256", "serde"] std = [ "op-alloy-consensus?/std", "op-alloy-genesis?/std", - "op-alloy-protocol?/std", "op-alloy-registry?/std", "op-alloy-rpc-types?/std", "op-alloy-rpc-types-engine?/std", @@ -47,7 +45,6 @@ full = [ "provider", "registry", "network", - "protocol", "rpc-types", "rpc-types-engine", "rpc-jsonrpsee", @@ -60,7 +57,6 @@ k256 = [ arbitrary = [ "op-alloy-consensus?/arbitrary", "op-alloy-genesis?/arbitrary", - "op-alloy-protocol?/arbitrary", "op-alloy-rpc-types?/arbitrary", "op-alloy-rpc-types-engine?/arbitrary", ] @@ -68,7 +64,6 @@ arbitrary = [ serde = [ "op-alloy-consensus?/serde", "op-alloy-genesis?/serde", - "op-alloy-protocol?/serde", "op-alloy-rpc-types-engine?/serde", ] @@ -76,7 +71,6 @@ serde = [ consensus = ["dep:op-alloy-consensus"] genesis = ["dep:op-alloy-genesis"] registry = ["dep:op-alloy-registry"] -protocol = ["dep:op-alloy-protocol"] rpc-types = ["dep:op-alloy-rpc-types"] rpc-types-engine = ["dep:op-alloy-rpc-types-engine"] diff --git a/crates/op-alloy/src/lib.rs b/crates/op-alloy/src/lib.rs index b009cccfe..9805076b3 100644 --- a/crates/op-alloy/src/lib.rs +++ b/crates/op-alloy/src/lib.rs @@ -19,10 +19,6 @@ pub use op_alloy_genesis as genesis; #[doc(inline)] pub use op_alloy_network as network; -#[cfg(feature = "protocol")] -#[doc(inline)] -pub use op_alloy_protocol as protocol; - #[cfg(feature = "registry")] #[doc(inline)] pub use op_alloy_registry as registry; diff --git a/crates/protocol/Cargo.toml b/crates/protocol/Cargo.toml deleted file mode 100644 index 64d8f8907..000000000 --- a/crates/protocol/Cargo.toml +++ /dev/null @@ -1,26 +0,0 @@ -[package] -name = "op-alloy-protocol" -description = "Re-export of op-rs/maili-protocol" - -version.workspace = true -edition.workspace = true -rust-version.workspace = true -authors.workspace = true -license.workspace = true -homepage.workspace = true -repository.workspace = true -exclude.workspace = true - -[lints] -workspace = true - -[dependencies] -# Maili -maili-protocol = { workspace = true, default-features = false } - -[features] -default = ["serde", "std"] -test-utils = ["maili-protocol/test-utils"] -arbitrary = ["maili-protocol/arbitrary"] -std = ["maili-protocol/std"] -serde = ["maili-protocol/serde"] diff --git a/crates/protocol/README.md b/crates/protocol/README.md deleted file mode 100644 index 54de4a596..000000000 --- a/crates/protocol/README.md +++ /dev/null @@ -1,12 +0,0 @@ -## `op-alloy-protocol` - -CI -op-alloy-protocol crate -MIT License -Apache License -Book - - -See [maili-protocol] - -[maili-protocol]: https://github.com/op-rs/maili/blob/main/crates/protocol/README.md diff --git a/crates/protocol/src/lib.rs b/crates/protocol/src/lib.rs deleted file mode 100644 index 63bb96912..000000000 --- a/crates/protocol/src/lib.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![doc = include_str!("../README.md")] -#![doc( - html_logo_url = "https://raw.githubusercontent.com/alloy-rs/core/main/assets/alloy.jpg", - html_favicon_url = "https://raw.githubusercontent.com/alloy-rs/core/main/assets/favicon.ico" -)] -#![cfg_attr(not(test), warn(unused_crate_dependencies))] -#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] -#![cfg_attr(not(any(test, feature = "std")), no_std)] - -pub use maili_protocol::*; diff --git a/crates/protocol/src/test_utils.rs b/crates/protocol/src/test_utils.rs deleted file mode 100644 index 459b06c36..000000000 --- a/crates/protocol/src/test_utils.rs +++ /dev/null @@ -1,112 +0,0 @@ -//! Test utilities for the protocol crate. - -use alloc::{boxed::Box, format, string::String, sync::Arc, vec::Vec}; -use async_trait::async_trait; -use op_alloy_consensus::OpBlock; -use spin::Mutex; -use tracing::{Event, Level, Subscriber}; -use tracing_subscriber::{layer::Context, Layer}; - -use crate::{BatchValidationProvider, L2BlockInfo}; - -/// An error for implementations of the [BatchValidationProvider] trait. -#[derive(Debug, thiserror::Error)] -pub enum TestBatchValidatorError { - /// The block was not found. - #[error("Block not found")] - BlockNotFound, - /// The L2 block was not found. - #[error("L2 Block not found")] - L2BlockNotFound, -} - -/// An [TestBatchValidator] implementation for testing. -#[derive(Debug, Default, Clone)] -pub struct TestBatchValidator { - /// Blocks - pub blocks: Vec, - /// Short circuit the block return to be the first block. - pub short_circuit: bool, - /// Blocks - pub op_blocks: Vec, -} - -impl TestBatchValidator { - /// Creates a new []TestBatchValidator with the given origin and batches. - pub const fn new(blocks: Vec, op_blocks: Vec) -> Self { - Self { blocks, short_circuit: false, op_blocks } - } -} - -#[async_trait] -impl BatchValidationProvider for TestBatchValidator { - type Error = TestBatchValidatorError; - - async fn l2_block_info_by_number(&mut self, number: u64) -> Result { - if self.short_circuit { - return self - .blocks - .first() - .copied() - .ok_or_else(|| TestBatchValidatorError::BlockNotFound); - } - self.blocks - .iter() - .find(|b| b.block_info.number == number) - .cloned() - .ok_or_else(|| TestBatchValidatorError::BlockNotFound) - } - - async fn block_by_number(&mut self, number: u64) -> Result { - self.op_blocks - .iter() - .find(|p| p.header.number == number) - .cloned() - .ok_or_else(|| TestBatchValidatorError::L2BlockNotFound) - } -} - -/// The storage for the collected traces. -#[derive(Debug, Default, Clone)] -pub struct TraceStorage(pub Arc>>); - -impl TraceStorage { - /// Returns the items in the storage that match the specified level. - pub fn get_by_level(&self, level: Level) -> Vec { - self.0 - .lock() - .iter() - .filter_map(|(l, message)| if *l == level { Some(message.clone()) } else { None }) - .collect() - } - - /// Returns if the storage is empty. - pub fn is_empty(&self) -> bool { - self.0.lock().is_empty() - } -} - -/// A subscriber layer that collects traces and their log levels. -#[derive(Debug, Default)] -pub struct CollectingLayer { - /// The storage for the collected traces. - pub storage: TraceStorage, -} - -impl CollectingLayer { - /// Creates a new collecting layer with the specified storage. - pub const fn new(storage: TraceStorage) -> Self { - Self { storage } - } -} - -impl Layer for CollectingLayer { - fn on_event(&self, event: &Event<'_>, _ctx: Context<'_, S>) { - let metadata = event.metadata(); - let level = *metadata.level(); - let message = format!("{:?}", event); - - let mut storage = self.storage.0.lock(); - storage.push((level, message)); - } -} diff --git a/crates/protocol/src/utils.rs b/crates/protocol/src/utils.rs deleted file mode 100644 index a36e7bf0c..000000000 --- a/crates/protocol/src/utils.rs +++ /dev/null @@ -1,305 +0,0 @@ -//! Utility methods used by protocol types. - -use alloc::vec::Vec; -use alloy_consensus::TxType; -use alloy_primitives::B256; -use alloy_rlp::{Buf, Header}; -use op_alloy_consensus::{OpBlock, OpTxEnvelope}; -use op_alloy_genesis::{RollupConfig, SystemConfig}; - -use crate::{ - L1BlockInfoBedrock, L1BlockInfoEcotone, L1BlockInfoTx, OpBlockConversionError, SpanBatchError, - SpanDecodingError, -}; - -/// Returns if the given `value` is a deposit transaction. -pub fn starts_with_2718_deposit(value: &B) -> bool -where - B: AsRef<[u8]>, -{ - value.as_ref().first() == Some(&0x7E) -} - -/// Converts the [OpBlock] to a partial [SystemConfig]. -pub fn to_system_config( - block: &OpBlock, - rollup_config: &RollupConfig, -) -> Result { - if block.header.number == rollup_config.genesis.l2.number { - if block.header.hash_slow() != rollup_config.genesis.l2.hash { - return Err(OpBlockConversionError::InvalidGenesisHash( - rollup_config.genesis.l2.hash, - block.header.hash_slow(), - )); - } - return rollup_config - .genesis - .system_config - .ok_or(OpBlockConversionError::MissingSystemConfigGenesis); - } - - if block.body.transactions.is_empty() { - return Err(OpBlockConversionError::EmptyTransactions(block.header.hash_slow())); - } - let OpTxEnvelope::Deposit(ref tx) = block.body.transactions[0] else { - return Err(OpBlockConversionError::InvalidTxType( - block.body.transactions[0].tx_type() as u8 - )); - }; - - let l1_info = L1BlockInfoTx::decode_calldata(tx.input.as_ref())?; - let l1_fee_scalar = match l1_info { - L1BlockInfoTx::Bedrock(L1BlockInfoBedrock { l1_fee_scalar, .. }) => l1_fee_scalar, - L1BlockInfoTx::Ecotone(L1BlockInfoEcotone { - base_fee_scalar, - blob_base_fee_scalar, - .. - }) => { - // Translate Ecotone values back into encoded scalar if needed. - // We do not know if it was derived from a v0 or v1 scalar, - // but v1 is fine, a 0 blob base fee has the same effect. - let mut buf = B256::ZERO; - buf[0] = 0x01; - buf[24..28].copy_from_slice(blob_base_fee_scalar.to_be_bytes().as_ref()); - buf[28..32].copy_from_slice(base_fee_scalar.to_be_bytes().as_ref()); - buf.into() - } - }; - - let mut cfg = SystemConfig { - batcher_address: l1_info.batcher_address(), - overhead: l1_info.l1_fee_overhead(), - scalar: l1_fee_scalar, - gas_limit: block.header.gas_limit, - ..Default::default() - }; - - // After holocene's activation, the EIP-1559 parameters are stored in the block header's nonce. - if rollup_config.is_holocene_active(block.header.timestamp) { - let eip1559_params = block.header.nonce; - cfg.eip1559_denominator = Some(u32::from_be_bytes( - eip1559_params[0..4] - .try_into() - .map_err(|_| OpBlockConversionError::Eip1559DecodeError)?, - )); - cfg.eip1559_elasticity = Some(u32::from_be_bytes( - eip1559_params[4..8] - .try_into() - .map_err(|_| OpBlockConversionError::Eip1559DecodeError)?, - )); - } - - Ok(cfg) -} - -/// Returns the length of the data after compression through FastLZ, based on -// https://github.com/Vectorized/solady/blob/5315d937d79b335c668896d7533ac603adac5315/js/solady.js -pub(crate) fn flz_compress_len(input: &[u8]) -> u32 { - let mut idx: u32 = 2; - - let idx_limit: u32 = if input.len() < 13 { 0 } else { input.len() as u32 - 13 }; - - let mut anchor = 0; - - let mut size = 0; - - let mut htab = [0; 8192]; - - while idx < idx_limit { - let mut r: u32; - let mut distance: u32; - - loop { - let seq = u24(input, idx); - let hash = hash(seq); - r = htab[hash as usize]; - htab[hash as usize] = idx; - distance = idx - r; - if idx >= idx_limit { - break; - } - idx += 1; - if distance < 8192 && seq == u24(input, r) { - break; - } - } - - if idx >= idx_limit { - break; - } - - idx -= 1; - - if idx > anchor { - size = literals(idx - anchor, size); - } - - let len = cmp(input, r + 3, idx + 3, idx_limit + 9); - size = flz_match(len, size); - - idx = set_next_hash(&mut htab, input, idx + len); - idx = set_next_hash(&mut htab, input, idx); - anchor = idx; - } - - literals(input.len() as u32 - anchor, size) -} - -const fn literals(r: u32, size: u32) -> u32 { - let size = size + 0x21 * (r / 0x20); - let r = r % 0x20; - if r != 0 { - size + r + 1 - } else { - size - } -} - -const fn cmp(input: &[u8], p: u32, q: u32, r: u32) -> u32 { - let mut l = 0; - let mut r = r - q; - while l < r { - if input[(p + l) as usize] != input[(q + l) as usize] { - r = 0; - } - l += 1; - } - l -} - -const fn flz_match(l: u32, size: u32) -> u32 { - let l = l - 1; - let size = size + (3 * (l / 262)); - if l % 262 >= 6 { - size + 3 - } else { - size + 2 - } -} - -fn set_next_hash(htab: &mut [u32; 8192], input: &[u8], idx: u32) -> u32 { - htab[hash(u24(input, idx)) as usize] = idx; - idx + 1 -} - -const fn hash(v: u32) -> u16 { - let hash = (v as u64 * 2654435769) >> 19; - hash as u16 & 0x1fff -} - -fn u24(input: &[u8], idx: u32) -> u32 { - u32::from(input[idx as usize]) - + (u32::from(input[(idx + 1) as usize]) << 8) - + (u32::from(input[(idx + 2) as usize]) << 16) -} - -/// Reads transaction data from a reader. -pub fn read_tx_data(r: &mut &[u8]) -> Result<(Vec, TxType), SpanBatchError> { - let mut tx_data = Vec::new(); - let first_byte = - *r.first().ok_or(SpanBatchError::Decoding(SpanDecodingError::InvalidTransactionData))?; - let mut tx_type = 0; - if first_byte <= 0x7F { - // EIP-2718: Non-legacy tx, so write tx type - tx_type = first_byte; - tx_data.push(tx_type); - r.advance(1); - } - - // Read the RLP header with a different reader pointer. This prevents the initial pointer from - // being advanced in the case that what we read is invalid. - let rlp_header = Header::decode(&mut (**r).as_ref()) - .map_err(|_| SpanBatchError::Decoding(SpanDecodingError::InvalidTransactionData))?; - - let tx_payload = if rlp_header.list { - // Grab the raw RLP for the transaction data from `r`. It was unaffected since we copied it. - let payload_length_with_header = rlp_header.payload_length + rlp_header.length(); - let payload = r[0..payload_length_with_header].to_vec(); - r.advance(payload_length_with_header); - Ok(payload) - } else { - Err(SpanBatchError::Decoding(SpanDecodingError::InvalidTransactionData)) - }?; - tx_data.extend_from_slice(&tx_payload); - - Ok(( - tx_data, - tx_type - .try_into() - .map_err(|_| SpanBatchError::Decoding(SpanDecodingError::InvalidTransactionType))?, - )) -} - -#[cfg(test)] -mod tests { - use super::*; - use alloy_sol_types::{sol, SolCall}; - use revm::{ - db::BenchmarkDB, - primitives::{address, bytes, Bytecode, Bytes, TxKind, U256}, - Evm, - }; - use rstest::rstest; - use std::vec::Vec; - - #[rstest] - #[case::empty(&[], 0)] - #[case::thousand_zeros(&[0; 1000], 21)] - #[case::thousand_forty_twos(&[42; 1000], 21)] - #[case::short_hex(&bytes!("FACADE"), 4)] - #[case::sample_contract_call(&bytes!("02f901550a758302df1483be21b88304743f94f80e51afb613d764fa61751affd3313c190a86bb870151bd62fd12adb8e41ef24f3f000000000000000000000000000000000000000000000000000000000000006e000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831000000000000000000000000000000000000000000000000000000000003c1e5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000148c89ed219d02f1a5be012c689b4f5b731827bebe000000000000000000000000c001a033fd89cb37c31b2cba46b6466e040c61fc9b2a3675a7f5f493ebd5ad77c497f8a07cdf65680e238392693019b4092f610222e71b7cec06449cb922b93b6a12744e"), 202)] - #[case::base_0x5dadeb52979f29fc7a7494c43fdabc5be1d8ff404f3aafe93d729fa8e5d00769(&bytes!("b9047c02f904788221050883036ee48409c6c87383037f6f941195cf65f83b3a5768f3c496d3a05ad6412c64b78644364c5bb000b90404d123b4d80000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000f6476f90447748c19248ccaa31e6b8bfda4eb9d830f5f47df7f0998f7c2123d9e6137761b75d3184efb0f788e3b14516000000000000000000000000000000000000000000000000000044364c5bb000000000000000000000000000f38e53bd45c8225a7c94b513beadaa7afe5d222d0000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000002e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000084d6574614d61736b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000035697066733a2f2f516d656852577a743347745961776343347564745657557233454c587261436746434259416b66507331696f48610000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000cd0d83d9e840f8e27d5c2e365fd365ff1c05b2480000000000000000000000000000000000000000000000000000000000000ce40000000000000000000000000000000000000000000000000000000000000041e4480d358dbae20880960a0a464d63b06565a0c9f9b1b37aa94b522247b23ce149c81359bf4239d1a879eeb41047ec710c15f5c0f67453da59a383e6abd742971c00000000000000000000000000000000000000000000000000000000000000c001a0b57f0ff8516ea29cb26a44ac5055a5420847d1e16a8e7b03b70f0c02291ff2d5a00ad3771e5f39ccacfff0faa8c5d25ef7a1c179f79e66e828ffddcb994c8b512e"), 471)] - fn test_flz_compress_len(#[case] input: &[u8], #[case] expected: u32) { - assert_eq!(flz_compress_len(input), expected); - } - - #[test] - fn test_flz_compress_len_no_repeats() { - let mut input = Vec::new(); - let mut len = 0; - - for i in 0..256 { - input.push(i as u8); - let prev_len = len; - len = flz_compress_len(&input); - assert!(len > prev_len); - } - } - - #[rstest] - #[case::short_hex(bytes!("FACADE"))] - #[case::sample_contract_call(bytes!("02f901550a758302df1483be21b88304743f94f80e51afb613d764fa61751affd3313c190a86bb870151bd62fd12adb8e41ef24f3f000000000000000000000000000000000000000000000000000000000000006e000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831000000000000000000000000000000000000000000000000000000000003c1e5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000148c89ed219d02f1a5be012c689b4f5b731827bebe000000000000000000000000c001a033fd89cb37c31b2cba46b6466e040c61fc9b2a3675a7f5f493ebd5ad77c497f8a07cdf65680e238392693019b4092f610222e71b7cec06449cb922b93b6a12744e"))] - #[case::base_0x5dadeb52979f29fc7a7494c43fdabc5be1d8ff404f3aafe93d729fa8e5d00769(bytes!("b9047c02f904788221050883036ee48409c6c87383037f6f941195cf65f83b3a5768f3c496d3a05ad6412c64b78644364c5bb000b90404d123b4d80000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000f6476f90447748c19248ccaa31e6b8bfda4eb9d830f5f47df7f0998f7c2123d9e6137761b75d3184efb0f788e3b14516000000000000000000000000000000000000000000000000000044364c5bb000000000000000000000000000f38e53bd45c8225a7c94b513beadaa7afe5d222d0000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000002e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000084d6574614d61736b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000035697066733a2f2f516d656852577a743347745961776343347564745657557233454c587261436746434259416b66507331696f48610000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000cd0d83d9e840f8e27d5c2e365fd365ff1c05b2480000000000000000000000000000000000000000000000000000000000000ce40000000000000000000000000000000000000000000000000000000000000041e4480d358dbae20880960a0a464d63b06565a0c9f9b1b37aa94b522247b23ce149c81359bf4239d1a879eeb41047ec710c15f5c0f67453da59a383e6abd742971c00000000000000000000000000000000000000000000000000000000000000c001a0b57f0ff8516ea29cb26a44ac5055a5420847d1e16a8e7b03b70f0c02291ff2d5a00ad3771e5f39ccacfff0faa8c5d25ef7a1c179f79e66e828ffddcb994c8b512e"))] - #[case::base_0xfaada76a2dac09fc17f5a28d066aaabefc6d82ef6589b211ed8c9f766b070721(bytes!("b87602f873822105528304320f8409cfe5c98252089480c67432656d59144ceff962e8faf8926599bcf888011dfe52d06b633f80c001a08632f069f837aea7a28bab0affee14dda116956bd5a850a355c045d25afedd17a0084b8f273efffe17ece527116053e5781a4915ff89ab9c379f1e62c25b697687"))] - #[case::base_0x112864e9b971af6a1dac840018833c5a5a659acc187cfdaba919ad1da013678d(bytes!("b8b302f8b0822105308304320f8409cfe5c9827496944ed4e862860bed51a9570b96d89af5e1b0efefed80b844095ea7b3000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba300000000000000000000000000000000000000000000015e10fb0973595fffffc001a02020e39f07917c1a852feb131c857e12478c7e88a20772b91a8bf5cee38c5aeea06055981727f9aaa3471c1af800555b35a77916c154be3f9d02ad1a63029455ab"))] - #[case::base_0x6905051352691641888d0c427fb137c5b95afb5870d5169ff014eff1d0952195(bytes!("b87202f86f8221058303dc6c8310db1f84068fa8d7838954409436af2ff952a7355c8045fcd5e88bc9f6c8257f7b8080c001a0b89e7ff3d7694109e73e7f4244e032581670313c36e48e485c9c94b853bd81d2a038ffaf8f10859ce21d1f7f7046c3d08027fb8aa15b69038f6102be97aaa1179a"))] - #[case::base_0x6a38e9a26d7202a2268de69d2d47531c1a9829867579a483fb48d78e9e0b080d(bytes!("b9049b02f904978221058201618506fc23ac008506fc23ac008306ddd0943fc91a3afd70395cd496c647d5a6cc9d4b2b7fad80b904243593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000006641d67b00000000000000000000000000000000000000000000000000000000000000030a000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000160000000000000000000000000088487bd8c3222d64d1d0b3fa7098dcf9d94d79e000000000000000000000000ffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000006669635d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000003fc91a3afd70395cd496c647d5a6cc9d4b2b7fad000000000000000000000000000000000000000000000000000000006641d78900000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000418661369ca026f92ff88347bd0e3625a7b5ed65071b366368c68ad7c55aed136c18659b34f9246e30a784227a53dd374fbd3d2124696808c678cd987c4e954a681b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000549e5c020c764dbfffff00000000000000000000000000000000000000000000000002e5a629c093a2b600000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002b088487bd8c3222d64d1d0b3fa7098dcf9d94d79e0027104200000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000c001a014a3acef764ff6d3bb9bd81e420bfa94171a5734ab997dfbc9b41b653ce018a4a01ff5fccb01ef5c60ba3aef67d4e74f3f47312dd78bfbbff9e5090fbf2d3d62bb"))] - fn test_flz_native_evm_parity(#[case] input: Bytes) { - // This bytecode and ABI is for a contract, which wraps the LibZip library for easier fuzz - // testing. The source of this contract is here: https://github.com/danyalprout/fastlz/blob/main/src/FastLz.sol#L6-L10 - sol! { - interface FastLz { - function fastLz(bytes input) external view returns (uint256); - } - } - - let contract_bytecode = Bytecode::new_raw(bytes!("608060405234801561001057600080fd5b506004361061002b5760003560e01c8063920a769114610030575b600080fd5b61004361003e366004610374565b610055565b60405190815260200160405180910390f35b600061006082610067565b5192915050565b60606101e0565b818153600101919050565b600082840393505b838110156100a25782810151828201511860001a1590930292600101610081565b9392505050565b825b602082106100d75782516100c0601f8361006e565b5260209290920191601f19909101906021016100ab565b81156100a25782516100ec600184038361006e565b520160010192915050565b60006001830392505b61010782106101385761012a8360ff1661012560fd6101258760081c60e0018961006e565b61006e565b935061010682039150610100565b600782106101655761015e8360ff16610125600785036101258760081c60e0018961006e565b90506100a2565b61017e8360ff166101258560081c8560051b018761006e565b949350505050565b80516101d890838303906101bc90600081901a600182901a60081b1760029190911a60101b17639e3779b90260131c611fff1690565b8060021b6040510182815160e01c1860e01b8151188152505050565b600101919050565b5060405161800038823961800081016020830180600d8551820103826002015b81811015610313576000805b50508051604051600082901a600183901a60081b1760029290921a60101b91909117639e3779b9810260111c617ffc16909101805160e081811c878603811890911b9091189091528401908183039084841061026857506102a3565b600184019350611fff821161029d578251600081901a600182901a60081b1760029190911a60101b17810361029d57506102a3565b5061020c565b8383106102b1575050610313565b600183039250858311156102cf576102cc87878886036100a9565b96505b6102e3600985016003850160038501610079565b91506102f08782846100f7565b9650506103088461030386848601610186565b610186565b915050809350610200565b5050617fe061032884848589518601036100a9565b03925050506020820180820383525b81811161034e57617fe08101518152602001610337565b5060008152602001604052919050565b634e487b7160e01b600052604160045260246000fd5b60006020828403121561038657600080fd5b813567ffffffffffffffff8082111561039e57600080fd5b818401915084601f8301126103b257600080fd5b8135818111156103c4576103c461035e565b604051601f8201601f19908116603f011681019083821181831017156103ec576103ec61035e565b8160405282815287602084870101111561040557600080fd5b82602086016020830137600092810160200192909252509594505050505056fea264697066735822122000646b2953fc4a6f501bd0456ac52203089443937719e16b3190b7979c39511264736f6c63430008190033")); - - let native_val = flz_compress_len(&input); - - let mut evm = Evm::builder() - .with_db(BenchmarkDB::new_bytecode(contract_bytecode)) - .modify_tx_env(|tx| { - tx.caller = address!("1000000000000000000000000000000000000000"); - tx.transact_to = TxKind::Call(address!("0000000000000000000000000000000000000000")); - tx.data = FastLz::fastLzCall::new((input,)).abi_encode().into(); - }) - .build(); - - let result_and_state = evm.transact().unwrap(); - let output = result_and_state.result.output().unwrap(); - let evm_val = FastLz::fastLzCall::abi_decode_returns(output, true).unwrap()._0; - - assert_eq!(U256::from(native_val), evm_val); - } -} diff --git a/crates/rpc-jsonrpsee/Cargo.toml b/crates/rpc-jsonrpsee/Cargo.toml index 47e14b7c3..e709e977a 100644 --- a/crates/rpc-jsonrpsee/Cargo.toml +++ b/crates/rpc-jsonrpsee/Cargo.toml @@ -18,10 +18,12 @@ workspace = true # Alloy op-alloy-rpc-types.workspace = true op-alloy-rpc-types-engine = { workspace = true, features = ["serde"] } -op-alloy-protocol.workspace = true alloy-eips.workspace = true alloy-primitives.workspace = true +# Maili +maili-protocol.workspace = true + # rpc jsonrpsee.workspace = true diff --git a/crates/rpc-jsonrpsee/src/traits.rs b/crates/rpc-jsonrpsee/src/traits.rs index 50347d80c..e13c531b8 100644 --- a/crates/rpc-jsonrpsee/src/traits.rs +++ b/crates/rpc-jsonrpsee/src/traits.rs @@ -8,7 +8,7 @@ use core::net::IpAddr; use alloy_eips::BlockNumberOrTag; use alloy_primitives::{B256, U64}; use jsonrpsee::{core::RpcResult, proc_macros::rpc}; -use op_alloy_protocol::{ExecutingMessage, SafetyLevel}; +use maili_protocol::{ExecutingMessage, SafetyLevel}; use op_alloy_rpc_types::{ OutputResponse, PeerDump, PeerInfo, PeerStats, RollupConfig, SafeHeadResponse, SyncStatus, }; diff --git a/crates/rpc-types-engine/Cargo.toml b/crates/rpc-types-engine/Cargo.toml index 2a72e9d0c..de45b56cb 100644 --- a/crates/rpc-types-engine/Cargo.toml +++ b/crates/rpc-types-engine/Cargo.toml @@ -17,7 +17,6 @@ workspace = true [dependencies] # Workspace op-alloy-consensus.workspace = true -op-alloy-protocol.workspace = true # Alloy alloy-primitives.workspace = true @@ -25,6 +24,7 @@ alloy-eips.workspace = true alloy-rpc-types-engine.workspace = true # Maili +maili-protocol.workspace = true maili-rpc-types-engine = { workspace = true, default-features = false } # Encoding @@ -54,13 +54,13 @@ std = [ "alloy-primitives/std", "alloy-rpc-types-engine/std", "op-alloy-consensus/std", - "op-alloy-protocol/std", + "maili-protocol/std", "maili-rpc-types-engine/std", ] serde = [ "dep:serde", "dep:alloy-serde", - "op-alloy-protocol/serde", + "maili-protocol/serde", "alloy-rpc-types-engine/serde", "maili-rpc-types-engine/serde", ] diff --git a/crates/rpc-types-engine/src/attributes.rs b/crates/rpc-types-engine/src/attributes.rs index 3f90e7e56..5e716c763 100644 --- a/crates/rpc-types-engine/src/attributes.rs +++ b/crates/rpc-types-engine/src/attributes.rs @@ -4,8 +4,8 @@ use alloc::vec::Vec; use alloy_eips::eip1559::BaseFeeParams; use alloy_primitives::{Bytes, B64}; use alloy_rpc_types_engine::PayloadAttributes; +use maili_protocol::L2BlockInfo; use op_alloy_consensus::{decode_eip_1559_params, encode_holocene_extra_data, EIP1559ParamError}; -use op_alloy_protocol::L2BlockInfo; /// Optimism Payload Attributes #[derive(Clone, Debug, Default, PartialEq, Eq)] diff --git a/scripts/check_no_std.sh b/scripts/check_no_std.sh index 34950af63..2b2addd33 100755 --- a/scripts/check_no_std.sh +++ b/scripts/check_no_std.sh @@ -4,7 +4,6 @@ set -eo pipefail no_std_packages=( op-alloy op-alloy-consensus - op-alloy-protocol op-alloy-registry op-alloy-genesis op-alloy-rpc-types From 14126a964176e7e951f592a462eeaff5e5e4f177 Mon Sep 17 00:00:00 2001 From: refcell Date: Thu, 9 Jan 2025 09:42:36 -0700 Subject: [PATCH 2/2] chore: remove protocol from docs --- README.md | 3 --- crates/op-alloy/README.md | 2 -- 2 files changed, 5 deletions(-) diff --git a/README.md b/README.md index 60f1d6723..398074f4d 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,6 @@ The following crates are provided by `op-alloy`. - [`op-alloy-consensus`][op-alloy-consensus] - [`op-alloy-genesis`][op-alloy-genesis] - [`op-alloy-network`][op-alloy-network] -- [`op-alloy-protocol`][op-alloy-protocol] - [`op-alloy-registry`][op-alloy-registry] - [`op-alloy-provider`][op-alloy-provider] - [`op-alloy-rpc-jsonrpsee`][op-alloy-rpc-jsonrpsee] @@ -57,7 +56,6 @@ The following crates support `no_std`. Notice, provider crates do not support `no_std` compatibility. - [`op-alloy-genesis`][op-alloy-genesis] -- [`op-alloy-protocol`][op-alloy-protocol] - [`op-alloy-registry`][op-alloy-registry] (note: requires `serde`) - [`op-alloy-consensus`][op-alloy-consensus] - [`op-alloy-rpc-types`][op-alloy-rpc-types] @@ -95,7 +93,6 @@ shall be dual licensed as above, without any additional terms or conditions. [op-alloy-consensus]: https://crates.io/crates/op-alloy-consensus [op-alloy-genesis]: https://crates.io/crates/op-alloy-genesis [op-alloy-network]: https://crates.io/crates/op-alloy-network -[op-alloy-protocol]: https://crates.io/crates/op-alloy-protocol [op-alloy-registry]: https://crates.io/crates/op-alloy-registry [op-alloy-provider]: https://crates.io/crates/op-alloy-provider [op-alloy-rpc-jsonrpsee]: https://crates.io/crates/op-alloy-rpc-jsonrpsee diff --git a/crates/op-alloy/README.md b/crates/op-alloy/README.md index 03268089f..86a7d6a0c 100644 --- a/crates/op-alloy/README.md +++ b/crates/op-alloy/README.md @@ -53,7 +53,6 @@ Notice, provider crates do not support `no_std` compatibility. - [`op-alloy-consensus`][op-alloy-consensus] - [`op-alloy-genesis`][op-alloy-genesis] -- [`op-alloy-protocol`][op-alloy-protocol] - [`op-alloy-rpc-types-engine`][op-alloy-rpc-types-engine] - [`op-alloy-rpc-types`][op-alloy-rpc-types] @@ -89,7 +88,6 @@ shall be dual licensed as above, without any additional terms or conditions. [op-alloy-consensus]: https://crates.io/crates/op-alloy-consensus [op-alloy-genesis]: https://crates.io/crates/op-alloy-genesis [op-alloy-network]: https://crates.io/crates/op-alloy-network -[op-alloy-protocol]: https://crates.io/crates/op-alloy-protocol [op-alloy-provider]: https://crates.io/crates/op-alloy-provider [op-alloy-rpc-jsonrpsee]: https://crates.io/crates/op-alloy-rpc-jsonrpsee [op-alloy-rpc-types-engine]: https://crates.io/crates/op-alloy-rpc-types-engine