From 73c887b83e98ef909574080f149a6e91a7a7149d Mon Sep 17 00:00:00 2001 From: Khanh Hoa Date: Sat, 2 Nov 2024 22:12:47 +0700 Subject: [PATCH 1/6] feat: add jsonrpsee trait for SuperchainSignal --- crates/rpc-jsonrpsee/Cargo.toml | 3 +++ crates/rpc-jsonrpsee/src/lib.rs | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/crates/rpc-jsonrpsee/Cargo.toml b/crates/rpc-jsonrpsee/Cargo.toml index d38c18598..aad3fe00c 100644 --- a/crates/rpc-jsonrpsee/Cargo.toml +++ b/crates/rpc-jsonrpsee/Cargo.toml @@ -17,11 +17,14 @@ workspace = true [dependencies] # Alloy op-alloy-rpc-types.workspace = true +op-alloy-rpc-types-engine.workspace = true alloy-eips.workspace = true alloy-primitives.workspace = true +alloy-transport.workspace = true # rpc jsonrpsee.workspace = true +serde = { version = "1.0.214", features = ["derive"] } [features] client = [ diff --git a/crates/rpc-jsonrpsee/src/lib.rs b/crates/rpc-jsonrpsee/src/lib.rs index 40df5736c..b67218203 100644 --- a/crates/rpc-jsonrpsee/src/lib.rs +++ b/crates/rpc-jsonrpsee/src/lib.rs @@ -7,3 +7,25 @@ #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] pub mod traits; + +use alloy_transport::Transport; +use jsonrpsee::{core::RpcResult, proc_macros::rpc}; +use op_alloy_rpc_types_engine::{ProtocolVersion, SuperchainSignal}; + +/// Engine API extension for Optimism superchain signaling +#[cfg_attr(not(feature = "client"), rpc(server, namespace = "engine"))] +#[cfg_attr(feature = "client", rpc(server, client, namespace = "engine"))] +pub trait EngineApiExt { + /// Signal superchain v1 message + /// + /// The execution engine SHOULD warn when the recommended version is newer than the current + /// version. The execution engine SHOULD take safety precautions if it does not meet + /// the required version. + /// + /// # Returns + /// The latest supported OP-Stack protocol version of the execution engine. + /// + /// See: https://specs.optimism.io/protocol/exec-engine.html#engine_signalsuperchainv1 + #[method(name = "engine_signalSuperchainV1")] + async fn signal_superchain_v1(&self, signal: SuperchainSignal) -> RpcResult; +} From d6466162f869bbdbac538178cabd757431d9854c Mon Sep 17 00:00:00 2001 From: Khanh Hoa Date: Sat, 2 Nov 2024 22:17:13 +0700 Subject: [PATCH 2/6] bet --- crates/rpc-jsonrpsee/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/rpc-jsonrpsee/src/lib.rs b/crates/rpc-jsonrpsee/src/lib.rs index b67218203..199a1d48f 100644 --- a/crates/rpc-jsonrpsee/src/lib.rs +++ b/crates/rpc-jsonrpsee/src/lib.rs @@ -8,7 +8,6 @@ pub mod traits; -use alloy_transport::Transport; use jsonrpsee::{core::RpcResult, proc_macros::rpc}; use op_alloy_rpc_types_engine::{ProtocolVersion, SuperchainSignal}; From 1831260afa09f9c5e2acc84f09e48636bf292945 Mon Sep 17 00:00:00 2001 From: Khanh Hoa Date: Sat, 2 Nov 2024 22:24:44 +0700 Subject: [PATCH 3/6] bet --- crates/rpc-jsonrpsee/src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/rpc-jsonrpsee/src/lib.rs b/crates/rpc-jsonrpsee/src/lib.rs index 199a1d48f..87b06aa84 100644 --- a/crates/rpc-jsonrpsee/src/lib.rs +++ b/crates/rpc-jsonrpsee/src/lib.rs @@ -8,6 +8,10 @@ pub mod traits; +// Add these use statements to satisfy unused dependency warnings +use alloy_transport as _; +use serde as _; + use jsonrpsee::{core::RpcResult, proc_macros::rpc}; use op_alloy_rpc_types_engine::{ProtocolVersion, SuperchainSignal}; @@ -24,7 +28,7 @@ pub trait EngineApiExt { /// # Returns /// The latest supported OP-Stack protocol version of the execution engine. /// - /// See: https://specs.optimism.io/protocol/exec-engine.html#engine_signalsuperchainv1 + /// See: #[method(name = "engine_signalSuperchainV1")] async fn signal_superchain_v1(&self, signal: SuperchainSignal) -> RpcResult; } From c078275d7f332d0fd6dd6da97d7c78a728d561f0 Mon Sep 17 00:00:00 2001 From: Khanh Hoa Date: Sat, 2 Nov 2024 22:28:19 +0700 Subject: [PATCH 4/6] bet --- crates/rpc-jsonrpsee/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/rpc-jsonrpsee/Cargo.toml b/crates/rpc-jsonrpsee/Cargo.toml index aad3fe00c..efbceec19 100644 --- a/crates/rpc-jsonrpsee/Cargo.toml +++ b/crates/rpc-jsonrpsee/Cargo.toml @@ -24,7 +24,7 @@ alloy-transport.workspace = true # rpc jsonrpsee.workspace = true -serde = { version = "1.0.214", features = ["derive"] } +serde = { workspace = true, optional = true } [features] client = [ From cd243503a3925e78cd385d04cd3d55ca0b548dc2 Mon Sep 17 00:00:00 2001 From: Khanh Hoa Date: Sat, 2 Nov 2024 22:34:40 +0700 Subject: [PATCH 5/6] bet --- crates/rpc-jsonrpsee/Cargo.toml | 4 +++- crates/rpc-jsonrpsee/src/lib.rs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/rpc-jsonrpsee/Cargo.toml b/crates/rpc-jsonrpsee/Cargo.toml index efbceec19..292ed9b69 100644 --- a/crates/rpc-jsonrpsee/Cargo.toml +++ b/crates/rpc-jsonrpsee/Cargo.toml @@ -24,7 +24,9 @@ alloy-transport.workspace = true # rpc jsonrpsee.workspace = true -serde = { workspace = true, optional = true } +# Serde +serde_json.workspace = true +serde = { workspace = true, features = ["derive"] } [features] client = [ diff --git a/crates/rpc-jsonrpsee/src/lib.rs b/crates/rpc-jsonrpsee/src/lib.rs index 87b06aa84..0c9a7232a 100644 --- a/crates/rpc-jsonrpsee/src/lib.rs +++ b/crates/rpc-jsonrpsee/src/lib.rs @@ -8,9 +8,9 @@ pub mod traits; -// Add these use statements to satisfy unused dependency warnings use alloy_transport as _; use serde as _; +use serde_json as _; use jsonrpsee::{core::RpcResult, proc_macros::rpc}; use op_alloy_rpc_types_engine::{ProtocolVersion, SuperchainSignal}; From af3af3e7a0ed14bb0fb8b7982d54161d86bd7c27 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sun, 3 Nov 2024 16:29:50 +0100 Subject: [PATCH 6/6] move --- crates/rpc-jsonrpsee/Cargo.toml | 6 +----- crates/rpc-jsonrpsee/src/lib.rs | 25 ------------------------- crates/rpc-jsonrpsee/src/traits.rs | 19 +++++++++++++++++++ 3 files changed, 20 insertions(+), 30 deletions(-) diff --git a/crates/rpc-jsonrpsee/Cargo.toml b/crates/rpc-jsonrpsee/Cargo.toml index 292ed9b69..721ab0510 100644 --- a/crates/rpc-jsonrpsee/Cargo.toml +++ b/crates/rpc-jsonrpsee/Cargo.toml @@ -17,16 +17,12 @@ workspace = true [dependencies] # Alloy op-alloy-rpc-types.workspace = true -op-alloy-rpc-types-engine.workspace = true +op-alloy-rpc-types-engine = { workspace = true, features = ["serde"] } alloy-eips.workspace = true alloy-primitives.workspace = true -alloy-transport.workspace = true # rpc jsonrpsee.workspace = true -# Serde -serde_json.workspace = true -serde = { workspace = true, features = ["derive"] } [features] client = [ diff --git a/crates/rpc-jsonrpsee/src/lib.rs b/crates/rpc-jsonrpsee/src/lib.rs index 0c9a7232a..40df5736c 100644 --- a/crates/rpc-jsonrpsee/src/lib.rs +++ b/crates/rpc-jsonrpsee/src/lib.rs @@ -7,28 +7,3 @@ #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] pub mod traits; - -use alloy_transport as _; -use serde as _; -use serde_json as _; - -use jsonrpsee::{core::RpcResult, proc_macros::rpc}; -use op_alloy_rpc_types_engine::{ProtocolVersion, SuperchainSignal}; - -/// Engine API extension for Optimism superchain signaling -#[cfg_attr(not(feature = "client"), rpc(server, namespace = "engine"))] -#[cfg_attr(feature = "client", rpc(server, client, namespace = "engine"))] -pub trait EngineApiExt { - /// Signal superchain v1 message - /// - /// The execution engine SHOULD warn when the recommended version is newer than the current - /// version. The execution engine SHOULD take safety precautions if it does not meet - /// the required version. - /// - /// # Returns - /// The latest supported OP-Stack protocol version of the execution engine. - /// - /// See: - #[method(name = "engine_signalSuperchainV1")] - async fn signal_superchain_v1(&self, signal: SuperchainSignal) -> RpcResult; -} diff --git a/crates/rpc-jsonrpsee/src/traits.rs b/crates/rpc-jsonrpsee/src/traits.rs index 2b42a91bc..9bf7bf5ea 100644 --- a/crates/rpc-jsonrpsee/src/traits.rs +++ b/crates/rpc-jsonrpsee/src/traits.rs @@ -12,6 +12,7 @@ use op_alloy_rpc_types::{ safe_head::SafeHeadResponse, sync::SyncStatus, }; +use op_alloy_rpc_types_engine::{ProtocolVersion, SuperchainSignal}; use std::net::IpAddr; /// Optimism specified rpc interface. @@ -120,3 +121,21 @@ pub trait OpAdminApi { #[method(name = "sequencerActive")] async fn admin_sequencer_active(&self) -> RpcResult; } + +/// Engine API extension for Optimism superchain signaling +#[cfg_attr(not(feature = "client"), rpc(server, namespace = "engine"))] +#[cfg_attr(feature = "client", rpc(server, client, namespace = "engine"))] +pub trait EngineApiExt { + /// Signal superchain v1 message + /// + /// The execution engine SHOULD warn when the recommended version is newer than the current + /// version. The execution engine SHOULD take safety precautions if it does not meet + /// the required version. + /// + /// # Returns + /// The latest supported OP-Stack protocol version of the execution engine. + /// + /// See: + #[method(name = "signalSuperchainV1")] + async fn signal_superchain_v1(&self, signal: SuperchainSignal) -> RpcResult; +}