add debug_chainConfig endpoint (#14346)

This commit is contained in:
Simon Oswald
2025-02-09 23:27:07 +01:00
committed by GitHub
parent d57535caad
commit 46d63e8054
4 changed files with 13 additions and 1 deletions

1
Cargo.lock generated
View File

@ -8965,6 +8965,7 @@ name = "reth-rpc-api"
version = "1.1.5" version = "1.1.5"
dependencies = [ dependencies = [
"alloy-eips", "alloy-eips",
"alloy-genesis",
"alloy-json-rpc", "alloy-json-rpc",
"alloy-primitives", "alloy-primitives",
"alloy-rpc-types", "alloy-rpc-types",

View File

@ -32,6 +32,7 @@ alloy-rpc-types-admin.workspace = true
alloy-serde.workspace = true alloy-serde.workspace = true
alloy-rpc-types-beacon.workspace = true alloy-rpc-types-beacon.workspace = true
alloy-rpc-types-engine.workspace = true alloy-rpc-types-engine.workspace = true
alloy-genesis.workspace = true
# misc # misc
jsonrpsee = { workspace = true, features = ["server", "macros"] } jsonrpsee = { workspace = true, features = ["server", "macros"] }

View File

@ -1,4 +1,5 @@
use alloy_eips::{BlockId, BlockNumberOrTag}; use alloy_eips::{BlockId, BlockNumberOrTag};
use alloy_genesis::ChainConfig;
use alloy_primitives::{Address, Bytes, B256}; use alloy_primitives::{Address, Bytes, B256};
use alloy_rpc_types_debug::ExecutionWitness; use alloy_rpc_types_debug::ExecutionWitness;
use alloy_rpc_types_eth::{transaction::TransactionRequest, Block, Bundle, StateContext}; use alloy_rpc_types_eth::{transaction::TransactionRequest, Block, Bundle, StateContext};
@ -186,6 +187,10 @@ pub trait DebugApi {
#[method(name = "chaindbCompact")] #[method(name = "chaindbCompact")]
async fn debug_chaindb_compact(&self) -> RpcResult<()>; async fn debug_chaindb_compact(&self) -> RpcResult<()>;
/// Returns the current chain config.
#[method(name = "chainConfig")]
async fn debug_chain_config(&self) -> RpcResult<ChainConfig>;
/// Returns leveldb properties of the key-value database. /// Returns leveldb properties of the key-value database.
#[method(name = "chaindbProperty")] #[method(name = "chaindbProperty")]
async fn debug_chaindb_property(&self, property: String) -> RpcResult<()>; async fn debug_chaindb_property(&self, property: String) -> RpcResult<()>;

View File

@ -1,5 +1,6 @@
use alloy_consensus::BlockHeader; use alloy_consensus::BlockHeader;
use alloy_eips::{eip2718::Encodable2718, BlockId, BlockNumberOrTag}; use alloy_eips::{eip2718::Encodable2718, BlockId, BlockNumberOrTag};
use alloy_genesis::ChainConfig;
use alloy_primitives::{Address, Bytes, B256, U256}; use alloy_primitives::{Address, Bytes, B256, U256};
use alloy_rlp::{Decodable, Encodable}; use alloy_rlp::{Decodable, Encodable};
use alloy_rpc_types_debug::ExecutionWitness; use alloy_rpc_types_debug::ExecutionWitness;
@ -14,7 +15,7 @@ use alloy_rpc_types_trace::geth::{
}; };
use async_trait::async_trait; use async_trait::async_trait;
use jsonrpsee::core::RpcResult; use jsonrpsee::core::RpcResult;
use reth_chainspec::EthereumHardforks; use reth_chainspec::{EthChainSpec, EthereumHardforks};
use reth_evm::{ use reth_evm::{
env::EvmEnv, env::EvmEnv,
execute::{BlockExecutorProvider, Executor}, execute::{BlockExecutorProvider, Executor},
@ -1035,6 +1036,10 @@ where
Ok(()) Ok(())
} }
async fn debug_chain_config(&self) -> RpcResult<ChainConfig> {
Ok(self.provider().chain_spec().genesis().config.clone())
}
async fn debug_chaindb_property(&self, _property: String) -> RpcResult<()> { async fn debug_chaindb_property(&self, _property: String) -> RpcResult<()> {
Ok(()) Ok(())
} }