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#[rpc(server, namespace = "trace")]
13pub trait TraceApi<TxReq> {
14 #[method(name = "call")]
16 async fn trace_call(
17 &self,
18 call: TxReq,
19 trace_types: HashSet<TraceType>,
20 block_id: Option<BlockId>,
21 state_overrides: Option<StateOverride>,
22 block_overrides: Option<Box<BlockOverrides>>,
23 ) -> RpcResult<TraceResults>;
24
25 #[method(name = "callMany")]
29 async fn trace_call_many(
30 &self,
31 calls: Vec<(TxReq, HashSet<TraceType>)>,
32 block_id: Option<BlockId>,
33 ) -> RpcResult<Vec<TraceResults>>;
34
35 #[method(name = "rawTransaction")]
39 async fn trace_raw_transaction(
40 &self,
41 data: Bytes,
42 trace_types: HashSet<TraceType>,
43 block_id: Option<BlockId>,
44 ) -> RpcResult<TraceResults>;
45
46 #[method(name = "replayBlockTransactions")]
48 async fn replay_block_transactions(
49 &self,
50 block_id: BlockId,
51 trace_types: HashSet<TraceType>,
52 ) -> RpcResult<Option<Vec<TraceResultsWithTransactionHash>>>;
53
54 #[method(name = "replayTransaction")]
56 async fn replay_transaction(
57 &self,
58 transaction: B256,
59 trace_types: HashSet<TraceType>,
60 ) -> RpcResult<Option<TraceResultsWithTransactionHash>>;
61
62 #[method(name = "block")]
64 async fn trace_block(
65 &self,
66 block_id: BlockId,
67 ) -> RpcResult<Option<Vec<LocalizedTransactionTrace>>>;
68
69 #[method(name = "filter")]
73 async fn trace_filter(&self, filter: TraceFilter) -> RpcResult<Vec<LocalizedTransactionTrace>>;
74
75 #[method(name = "get")]
81 async fn trace_get(
82 &self,
83 hash: B256,
84 indices: Vec<Index>,
85 ) -> RpcResult<Option<LocalizedTransactionTrace>>;
86
87 #[method(name = "transaction")]
89 async fn trace_transaction(
90 &self,
91 hash: B256,
92 ) -> RpcResult<Option<Vec<LocalizedTransactionTrace>>>;
93
94 #[method(name = "transactionOpcodeGas")]
97 async fn trace_transaction_opcode_gas(
98 &self,
99 tx_hash: B256,
100 ) -> RpcResult<Option<TransactionOpcodeGas>>;
101
102 #[method(name = "blockOpcodeGas")]
106 async fn trace_block_opcode_gas(&self, block_id: BlockId) -> RpcResult<Option<BlockOpcodeGas>>;
107}