From 46d63e8054b63f4fe09978a3850d3f1c02871b49 Mon Sep 17 00:00:00 2001 From: Simon Oswald Date: Sun, 9 Feb 2025 23:27:07 +0100 Subject: [PATCH] add debug_chainConfig endpoint (#14346) --- Cargo.lock | 1 + crates/rpc/rpc-api/Cargo.toml | 1 + crates/rpc/rpc-api/src/debug.rs | 5 +++++ crates/rpc/rpc/src/debug.rs | 7 ++++++- 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index c0fca41c4f50..855ec12868d4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8965,6 +8965,7 @@ name = "reth-rpc-api" version = "1.1.5" dependencies = [ "alloy-eips", + "alloy-genesis", "alloy-json-rpc", "alloy-primitives", "alloy-rpc-types", diff --git a/crates/rpc/rpc-api/Cargo.toml b/crates/rpc/rpc-api/Cargo.toml index abcdf98b5448..4eb9a6e653ce 100644 --- a/crates/rpc/rpc-api/Cargo.toml +++ b/crates/rpc/rpc-api/Cargo.toml @@ -32,6 +32,7 @@ alloy-rpc-types-admin.workspace = true alloy-serde.workspace = true alloy-rpc-types-beacon.workspace = true alloy-rpc-types-engine.workspace = true +alloy-genesis.workspace = true # misc jsonrpsee = { workspace = true, features = ["server", "macros"] } diff --git a/crates/rpc/rpc-api/src/debug.rs b/crates/rpc/rpc-api/src/debug.rs index 281e0798fcb7..4b9dc82467c7 100644 --- a/crates/rpc/rpc-api/src/debug.rs +++ b/crates/rpc/rpc-api/src/debug.rs @@ -1,4 +1,5 @@ use alloy_eips::{BlockId, BlockNumberOrTag}; +use alloy_genesis::ChainConfig; use alloy_primitives::{Address, Bytes, B256}; use alloy_rpc_types_debug::ExecutionWitness; use alloy_rpc_types_eth::{transaction::TransactionRequest, Block, Bundle, StateContext}; @@ -186,6 +187,10 @@ pub trait DebugApi { #[method(name = "chaindbCompact")] async fn debug_chaindb_compact(&self) -> RpcResult<()>; + /// Returns the current chain config. + #[method(name = "chainConfig")] + async fn debug_chain_config(&self) -> RpcResult; + /// Returns leveldb properties of the key-value database. #[method(name = "chaindbProperty")] async fn debug_chaindb_property(&self, property: String) -> RpcResult<()>; diff --git a/crates/rpc/rpc/src/debug.rs b/crates/rpc/rpc/src/debug.rs index e241bf8a4635..b52dca756be0 100644 --- a/crates/rpc/rpc/src/debug.rs +++ b/crates/rpc/rpc/src/debug.rs @@ -1,5 +1,6 @@ use alloy_consensus::BlockHeader; use alloy_eips::{eip2718::Encodable2718, BlockId, BlockNumberOrTag}; +use alloy_genesis::ChainConfig; use alloy_primitives::{Address, Bytes, B256, U256}; use alloy_rlp::{Decodable, Encodable}; use alloy_rpc_types_debug::ExecutionWitness; @@ -14,7 +15,7 @@ use alloy_rpc_types_trace::geth::{ }; use async_trait::async_trait; use jsonrpsee::core::RpcResult; -use reth_chainspec::EthereumHardforks; +use reth_chainspec::{EthChainSpec, EthereumHardforks}; use reth_evm::{ env::EvmEnv, execute::{BlockExecutorProvider, Executor}, @@ -1035,6 +1036,10 @@ where Ok(()) } + async fn debug_chain_config(&self) -> RpcResult { + Ok(self.provider().chain_spec().genesis().config.clone()) + } + async fn debug_chaindb_property(&self, _property: String) -> RpcResult<()> { Ok(()) }