From 1404073e053fa2831ddd1a428db932f7e4b152c9 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 3 Dec 2024 14:12:13 +0100 Subject: [PATCH] feat: add miner rpc bindings (#13099) --- crates/rpc/rpc-api/src/lib.rs | 3 +++ crates/rpc/rpc-api/src/miner.rs | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 crates/rpc/rpc-api/src/miner.rs diff --git a/crates/rpc/rpc-api/src/lib.rs b/crates/rpc/rpc-api/src/lib.rs index ac39b4802a..098214f103 100644 --- a/crates/rpc/rpc-api/src/lib.rs +++ b/crates/rpc/rpc-api/src/lib.rs @@ -21,6 +21,7 @@ mod engine; mod ganache; mod hardhat; mod mev; +mod miner; mod net; mod otterscan; mod reth; @@ -40,6 +41,7 @@ pub mod servers { debug::{DebugApiServer, DebugExecutionWitnessApiServer}, engine::{EngineApiServer, EngineEthApiServer}, mev::{MevFullApiServer, MevSimApiServer}, + miner::MinerApiServer, net::NetApiServer, otterscan::OtterscanServer, reth::RethApiServer, @@ -70,6 +72,7 @@ pub mod clients { ganache::GanacheApiClient, hardhat::HardhatApiClient, mev::{MevFullApiClient, MevSimApiClient}, + miner::MinerApiClient, net::NetApiClient, otterscan::OtterscanClient, reth::RethApiClient, diff --git a/crates/rpc/rpc-api/src/miner.rs b/crates/rpc/rpc-api/src/miner.rs new file mode 100644 index 0000000000..3673b51c6e --- /dev/null +++ b/crates/rpc/rpc-api/src/miner.rs @@ -0,0 +1,21 @@ +use alloy_primitives::{Bytes, U128}; +use jsonrpsee::{core::RpcResult, proc_macros::rpc}; + +/// Miner namespace rpc interface that can control miner/builder settings +#[cfg_attr(not(feature = "client"), rpc(server, namespace = "miner"))] +#[cfg_attr(feature = "client", rpc(server, client, namespace = "miner"))] +pub trait MinerApi { + /// Sets the extra data string that is included when this miner mines a block. + /// + /// Returns an error if the extra data is too long. + #[method(name = "setExtra")] + fn set_extra(&self, record: Bytes) -> RpcResult; + + /// Sets the minimum accepted gas price for the miner. + #[method(name = "setGasPrice")] + fn set_gas_price(&self, gas_price: U128) -> RpcResult; + + /// Sets the gaslimit to target towards during mining. + #[method(name = "setGasLimit")] + fn set_gas_limit(&self, gas_price: U128) -> RpcResult; +}