1use alloy_eips::BlockId;
2use alloy_primitives::{map::HashSet, Bytes, B256};
3use alloy_rpc_types_eth::{state::StateOverride, BlockOverrides, Index};
4use alloy_rpc_types_trace::{
5 filter::TraceFilter,
6 opcode::{BlockOpcodeGas, TransactionOpcodeGas},
7 parity::*,
8};
9use jsonrpsee::{core::RpcResult, proc_macros::rpc};
10
11#[cfg_attr(not(feature = "client"), rpc(server, namespace = "trace"))]
13#[cfg_attr(feature = "client", rpc(server, client, namespace = "trace"))]
14pub trait TraceApi<TxReq> {
15 #[method(name = "call")]
17 async fn trace_call(
18 &self,
19 call: TxReq,
20 trace_types: HashSet<TraceType>,
21 block_id: Option<BlockId>,
22 state_overrides: Option<StateOverride>,
23 block_overrides: Option<Box<BlockOverrides>>,
24 ) -> RpcResult<TraceResults>;
25
26 #[method(name = "callMany")]
30 async fn trace_call_many(
31 &self,
32 calls: Vec<(TxReq, HashSet<TraceType>)>,
33 block_id: Option<BlockId>,
34 ) -> RpcResult<Vec<TraceResults>>;
35
36 #[method(name = "rawTransaction")]
40 async fn trace_raw_transaction(
41 &self,
42 data: Bytes,
43 trace_types: HashSet<TraceType>,
44 block_id: Option<BlockId>,
45 ) -> RpcResult<TraceResults>;
46
47 #[method(name = "replayBlockTransactions")]
49 async fn replay_block_transactions(
50 &self,
51 block_id: BlockId,
52 trace_types: HashSet<TraceType>,
53 ) -> RpcResult<Option<Vec<TraceResultsWithTransactionHash>>>;
54
55 #[method(name = "replayTransaction")]
57 async fn replay_transaction(
58 &self,
59 transaction: B256,
60 trace_types: HashSet<TraceType>,
61 ) -> RpcResult<TraceResults>;
62
63 #[method(name = "block")]
65 async fn trace_block(
66 &self,
67 block_id: BlockId,
68 ) -> RpcResult<Option<Vec<LocalizedTransactionTrace>>>;
69
70 #[method(name = "filter")]
74 async fn trace_filter(&self, filter: TraceFilter) -> RpcResult<Vec<LocalizedTransactionTrace>>;
75
76 #[method(name = "get")]
83 async fn trace_get(
84 &self,
85 hash: B256,
86 indices: Vec<Index>,
87 ) -> RpcResult<Option<LocalizedTransactionTrace>>;
88
89 #[method(name = "transaction")]
91 async fn trace_transaction(
92 &self,
93 hash: B256,
94 ) -> RpcResult<Option<Vec<LocalizedTransactionTrace>>>;
95
96 #[method(name = "transactionOpcodeGas")]
99 async fn trace_transaction_opcode_gas(
100 &self,
101 tx_hash: B256,
102 ) -> RpcResult<Option<TransactionOpcodeGas>>;
103
104 #[method(name = "blockOpcodeGas")]
108 async fn trace_block_opcode_gas(&self, block_id: BlockId) -> RpcResult<Option<BlockOpcodeGas>>;
109}