Skip to content

Commit ad3b860

Browse files
committed
fix: make the handler compile
1 parent 396050a commit ad3b860

File tree

2 files changed

+40
-15
lines changed

2 files changed

+40
-15
lines changed

crates/rpc/src/debug/endpoints.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ use crate::{
22
RpcCtx, TraceError,
33
utils::{await_jh_option_response, response_tri},
44
};
5-
use ajj::HandlerCtx;
6-
use ajj::ResponsePayload;
5+
use ajj::{HandlerCtx, ResponsePayload};
76
use alloy::eips::BlockId;
87
use reth::rpc::{
98
server_types::eth::EthApiError,
@@ -12,9 +11,12 @@ use reth::rpc::{
1211
use reth_node_api::FullNodeComponents;
1312
use signet_node_types::Pnt;
1413

14+
/// Params for the `debug_traceBlockByNumber` and `debug_traceBlockByHash`
15+
/// endpoints.
1516
#[derive(Debug, serde::Deserialize)]
16-
struct TraceBlockParams<T>(T, #[serde(default)] Option<GethDebugTracingOptions>);
17+
pub(super) struct TraceBlockParams<T>(T, #[serde(default)] Option<GethDebugTracingOptions>);
1718

19+
/// `debug_traceBlockByNumber` and `debug_traceBlockByHash` endpoint handler.
1820
pub(super) async fn trace_block<T, Host, Signet>(
1921
hctx: HandlerCtx,
2022
TraceBlockParams(id, opts): TraceBlockParams<T>,
@@ -28,16 +30,18 @@ where
2830
let id = id.into();
2931

3032
let fut = async move {
31-
// // Fetch the block by ID
32-
// let Some((hash, block)) = response_tri!(ctx.signet().raw_block(id).await) else {
33-
// return ResponsePayload::internal_error_message(
34-
// EthApiError::HeaderNotFound(id).to_string().into(),
35-
// );
36-
// };
37-
// // Instantiate the EVM with the block
38-
// let evm = response_tri!(ctx.trevm(id, &block.header()));
33+
// Fetch the block by ID
34+
let Some((hash, block)) = response_tri!(ctx.signet().raw_block(id).await) else {
35+
return ResponsePayload::internal_error_message(
36+
EthApiError::HeaderNotFound(id).to_string().into(),
37+
);
38+
};
39+
// Instantiate the EVM with the block
40+
let evm = response_tri!(ctx.trevm(id, block.header()));
3941

40-
ResponsePayload::Success(vec![])
42+
todo!()
43+
44+
// ResponsePayload::Success(vec![])
4145
};
4246

4347
await_jh_option_response!(hctx.spawn_blocking(fut))

crates/rpc/src/debug/error.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,29 @@ use reth::{
44
};
55

66
/// Errors that can occur when interacting with the `eth_` namespace.
7-
#[derive(Debug, thiserror::Error)]
7+
#[derive(Debug, thiserror::Error, Clone)]
88
pub enum TraceError {
99
/// Provider error: [`ProviderError`].
1010
#[error("Provider error: {0}")]
1111
Provider(#[from] ProviderError),
1212
/// Filter error [`EthFilterError`].
1313
#[error("Filter error: {0}")]
14-
Filter(#[from] EthFilterError),
14+
Filter(String),
1515
/// Eth API error: [`EthApiError`].
1616
#[error("Eth API error: {0}")]
17-
Rpc(#[from] EthApiError),
17+
Rpc(String),
18+
}
19+
20+
impl From<EthFilterError> for TraceError {
21+
fn from(err: EthFilterError) -> Self {
22+
TraceError::Filter(err.to_string())
23+
}
24+
}
25+
26+
impl From<EthApiError> for TraceError {
27+
fn from(err: EthApiError) -> Self {
28+
TraceError::Rpc(err.to_string())
29+
}
1830
}
1931

2032
impl TraceError {
@@ -24,3 +36,12 @@ impl TraceError {
2436
ToString::to_string(&self)
2537
}
2638
}
39+
40+
impl serde::Serialize for TraceError {
41+
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
42+
where
43+
S: serde::Serializer,
44+
{
45+
serializer.serialize_str(&self.to_string())
46+
}
47+
}

0 commit comments

Comments
 (0)