From 586115dd6ba0b71ce7e72ee66669debf37f8c506 Mon Sep 17 00:00:00 2001 From: Emilia Hane Date: Fri, 3 Jan 2025 11:05:56 +0100 Subject: [PATCH] chore(rpc): `no_std` support `op-alloy-rpc-jsonrpsee` (#356) ## Motivation Closes https://github.com/alloy-rs/op-alloy/issues/355 ## Solution Adds `no_std` support `op-alloy-rpc-jsonrpsee`, and removes exclusion from CI wasm check ## PR Checklist - [ ] Added Tests - [ ] Added Documentation - [ ] Breaking changes --- .github/workflows/ci.yml | 2 +- crates/rpc-jsonrpsee/Cargo.toml | 7 +++++++ crates/rpc-jsonrpsee/src/lib.rs | 3 +++ crates/rpc-jsonrpsee/src/traits.rs | 4 +++- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f233486a..f891505f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -103,7 +103,7 @@ jobs: cache-on-failure: true - name: cargo hack run: | - cargo hack build --workspace --target wasm32-wasi --exclude op-alloy-network --exclude op-alloy-rpc-types --exclude op-alloy-rpc-jsonrpsee --exclude op-alloy-provider + cargo hack build --workspace --target wasm32-wasi --exclude op-alloy-network --exclude op-alloy-rpc-types --exclude op-alloy-provider no-std: runs-on: ubuntu-latest diff --git a/crates/rpc-jsonrpsee/Cargo.toml b/crates/rpc-jsonrpsee/Cargo.toml index 721ab051..b6622913 100644 --- a/crates/rpc-jsonrpsee/Cargo.toml +++ b/crates/rpc-jsonrpsee/Cargo.toml @@ -25,6 +25,13 @@ alloy-primitives.workspace = true jsonrpsee.workspace = true [features] +default = ["std"] +std = [ + "op-alloy-rpc-types/std", + "op-alloy-rpc-types-engine/std", + "alloy-eips/std", + "alloy-primitives/std", +] client = [ "jsonrpsee/client", "jsonrpsee/async-client", diff --git a/crates/rpc-jsonrpsee/src/lib.rs b/crates/rpc-jsonrpsee/src/lib.rs index 40df5736..dd08fe38 100644 --- a/crates/rpc-jsonrpsee/src/lib.rs +++ b/crates/rpc-jsonrpsee/src/lib.rs @@ -5,5 +5,8 @@ )] #![cfg_attr(not(test), warn(unused_crate_dependencies))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] +#![cfg_attr(not(feature = "std"), no_std)] + +extern crate alloc; pub mod traits; diff --git a/crates/rpc-jsonrpsee/src/traits.rs b/crates/rpc-jsonrpsee/src/traits.rs index abc59488..4fa14a53 100644 --- a/crates/rpc-jsonrpsee/src/traits.rs +++ b/crates/rpc-jsonrpsee/src/traits.rs @@ -2,6 +2,9 @@ //! Rollup Node +use alloc::{boxed::Box, string::String, vec::Vec}; +use core::net::IpAddr; + use alloy_eips::BlockNumberOrTag; use alloy_primitives::{B256, U64}; use jsonrpsee::{core::RpcResult, proc_macros::rpc}; @@ -9,7 +12,6 @@ use op_alloy_rpc_types::{ OutputResponse, PeerDump, PeerInfo, PeerStats, RollupConfig, SafeHeadResponse, SyncStatus, }; use op_alloy_rpc_types_engine::{ProtocolVersion, SuperchainSignal}; -use std::net::IpAddr; /// Optimism specified rpc interface. ///