1use alloy_eips::BlockId;
2use alloy_primitives::{map::HashSet, Bytes, B256};
3use alloy_rpc_types_eth::{
4 state::StateOverride, transaction::TransactionRequest, BlockOverrides, Index,
5};
6use alloy_rpc_types_trace::{
7 filter::TraceFilter,
8 opcode::{BlockOpcodeGas, TransactionOpcodeGas},
9 parity::*,
10};
11use jsonrpsee::{core::RpcResult, proc_macros::rpc};
12
13#[cfg_attr(not(feature = "client"), rpc(server, namespace = "trace"))]
15#[cfg_attr(feature = "client", rpc(server, client, namespace = "trace"))]
16pub trait TraceApi {
17 #[method(name = "call")]
19 async fn trace_call(
20 &self,
21 call: TransactionRequest,
22 trace_types: HashSet<TraceType>,
23 block_id: Option<BlockId>,
24 state_overrides: Option<StateOverride>,
25 block_overrides: Option<Box<BlockOverrides>>,
26 ) -> RpcResult<TraceResults>;
27
28 #[method(name = "callMany")]
32 async fn trace_call_many(
33 &self,
34 calls: Vec<(TransactionRequest, HashSet<TraceType>)>,
35 block_id: Option<BlockId>,
36 ) -> RpcResult<Vec<TraceResults>>;
37
38 #[method(name = "rawTransaction")]
42 async fn trace_raw_transaction(
43 &self,
44 data: Bytes,
45 trace_types: HashSet<TraceType>,
46 block_id: Option<BlockId>,
47 ) -> RpcResult<TraceResults>;
48
49 #[method(name = "replayBlockTransactions")]
51 async fn replay_block_transactions(
52 &self,
53 block_id: BlockId,
54 trace_types: HashSet<TraceType>,
55 ) -> RpcResult<Option<Vec<TraceResultsWithTransactionHash>>>;
56
57 #[method(name = "replayTransaction")]
59 async fn replay_transaction(
60 &self,
61 transaction: B256,
62 trace_types: HashSet<TraceType>,
63 ) -> RpcResult<TraceResults>;
64
65 #[method(name = "block")]
67 async fn trace_block(
68 &self,
69 block_id: BlockId,
70 ) -> RpcResult<Option<Vec<LocalizedTransactionTrace>>>;
71
72 #[method(name = "filter")]
76 async fn trace_filter(&self, filter: TraceFilter) -> RpcResult<Vec<LocalizedTransactionTrace>>;
77
78 #[method(name = "get")]
85 async fn trace_get(
86 &self,
87 hash: B256,
88 indices: Vec<Index>,
89 ) -> RpcResult<Option<LocalizedTransactionTrace>>;
90
91 #[method(name = "transaction")]
93 async fn trace_transaction(
94 &self,
95 hash: B256,
96 ) -> RpcResult<Option<Vec<LocalizedTransactionTrace>>>;
97
98 #[method(name = "transactionOpcodeGas")]
101 async fn trace_transaction_opcode_gas(
102 &self,
103 tx_hash: B256,
104 ) -> RpcResult<Option<TransactionOpcodeGas>>;
105
106 #[method(name = "blockOpcodeGas")]
110 async fn trace_block_opcode_gas(&self, block_id: BlockId) -> RpcResult<Option<BlockOpcodeGas>>;
111}