Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add debug_chainConfig endpoint #14346

Merged
merged 2 commits into from
Feb 9, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/rpc/rpc-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
5 changes: 5 additions & 0 deletions crates/rpc/rpc-api/src/debug.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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<ChainConfig>;

/// Returns leveldb properties of the key-value database.
#[method(name = "chaindbProperty")]
async fn debug_chaindb_property(&self, property: String) -> RpcResult<()>;
Expand Down
28 changes: 17 additions & 11 deletions crates/rpc/rpc/src/debug.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -14,6 +15,7 @@ use alloy_rpc_types_trace::geth::{
};
use async_trait::async_trait;
use jsonrpsee::core::RpcResult;
use reth_chainspec::EthChainSpec;
use reth_chainspec::EthereumHardforks;
use reth_evm::{
env::EvmEnv,
Expand Down Expand Up @@ -293,7 +295,7 @@ where
Ok(inspector)
})
.await?;
return Ok(FourByteFrame::from(&inspector).into())
return Ok(FourByteFrame::from(&inspector).into());
siosw marked this conversation as resolved.
Show resolved Hide resolved
}
GethDebugBuiltInTracerType::CallTracer => {
let call_config = tracer_config
Expand All @@ -316,7 +318,7 @@ where
Ok(frame.into())
})
.await?;
return Ok(frame)
return Ok(frame);
}
GethDebugBuiltInTracerType::PreStateTracer => {
let prestate_config = tracer_config
Expand Down Expand Up @@ -347,7 +349,7 @@ where
Ok(frame)
})
.await?;
return Ok(frame.into())
return Ok(frame.into());
}
GethDebugBuiltInTracerType::NoopTracer => Ok(NoopFrame::default().into()),
GethDebugBuiltInTracerType::MuxTracer => {
Expand Down Expand Up @@ -390,7 +392,7 @@ where
Ok(frame.into())
})
.await?;
return Ok(frame)
return Ok(frame);
}
GethDebugBuiltInTracerType::FlatCallTracer => {
let flat_call_config = tracer_config
Expand Down Expand Up @@ -456,7 +458,7 @@ where

Ok(GethTrace::JS(res))
}
}
};
}

// default structlog tracer
Expand Down Expand Up @@ -492,7 +494,7 @@ where
opts: Option<GethDebugTracingCallOptions>,
) -> Result<Vec<Vec<GethTrace>>, Eth::Error> {
if bundles.is_empty() {
return Err(EthApiError::InvalidParams(String::from("bundles are empty.")).into())
return Err(EthApiError::InvalidParams(String::from("bundles are empty.")).into());
}

let StateContext { transaction_index, block_number } = state_context.unwrap_or_default();
Expand Down Expand Up @@ -702,7 +704,7 @@ where
let mut inspector = FourByteInspector::default();
let (res, _) =
self.eth_api().inspect(db, evm_env, tx_env, &mut inspector)?;
return Ok((FourByteFrame::from(&inspector).into(), res.state))
return Ok((FourByteFrame::from(&inspector).into(), res.state));
}
GethDebugBuiltInTracerType::CallTracer => {
let call_config = tracer_config
Expand All @@ -725,7 +727,7 @@ where
.geth_builder()
.geth_call_traces(call_config, res.result.gas_used());

return Ok((frame.into(), res.state))
return Ok((frame.into(), res.state));
}
GethDebugBuiltInTracerType::PreStateTracer => {
let prestate_config = tracer_config
Expand All @@ -747,7 +749,7 @@ where
.geth_prestate_traces(&res, &prestate_config, db)
.map_err(Eth::Error::from_eth_err)?;

return Ok((frame.into(), res.state))
return Ok((frame.into(), res.state));
}
GethDebugBuiltInTracerType::NoopTracer => {
Ok((NoopFrame::default().into(), Default::default()))
Expand All @@ -766,7 +768,7 @@ where
let frame = inspector
.try_into_mux_frame(&res, db, tx_info)
.map_err(Eth::Error::from_eth_err)?;
return Ok((frame.into(), res.state))
return Ok((frame.into(), res.state));
}
GethDebugBuiltInTracerType::FlatCallTracer => {
let flat_call_config = tracer_config
Expand Down Expand Up @@ -815,7 +817,7 @@ where
inspector.json_result(res, &env, db).map_err(Eth::Error::from_eth_err)?;
Ok((GethTrace::JS(result), state))
}
}
};
}

// default structlog tracer
Expand Down Expand Up @@ -1035,6 +1037,10 @@ where
Ok(())
}

async fn debug_chain_config(&self) -> RpcResult<ChainConfig> {
Ok(self.provider().chain_spec().genesis().clone().config)
siosw marked this conversation as resolved.
Show resolved Hide resolved
}

async fn debug_chaindb_property(&self, _property: String) -> RpcResult<()> {
Ok(())
}
Expand Down
Loading