1
// Copyright 2019-2025 PureStake Inc.
2
// This file is part of Moonbeam.
3

            
4
// Moonbeam is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8

            
9
// Moonbeam is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13

            
14
// You should have received a copy of the GNU General Public License
15
// along with Moonbeam.  If not, see <http://www.gnu.org/licenses/>.
16

            
17
use ethereum::AccessListItem;
18
use ethereum_types::{H160, H256, U256};
19
use fc_rpc_core::types::Bytes;
20
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
21
use moonbeam_client_evm_tracing::types::{block, single};
22
use moonbeam_rpc_core_types::RequestBlockId;
23
use serde::Deserialize;
24

            
25
#[derive(Clone, Eq, PartialEq, Debug, Deserialize)]
26
#[serde(rename_all = "camelCase")]
27
pub struct TraceParams {
28
	pub disable_storage: Option<bool>,
29
	pub disable_memory: Option<bool>,
30
	pub disable_stack: Option<bool>,
31
	/// Javascript tracer (we just check if it's Blockscout tracer string)
32
	pub tracer: Option<String>,
33
	pub tracer_config: Option<single::TraceCallConfig>,
34
	pub timeout: Option<String>,
35
}
36

            
37
#[derive(Debug, Clone, Default, Eq, PartialEq, Deserialize)]
38
#[serde(rename_all = "camelCase")]
39
pub struct TraceCallParams {
40
	/// Sender
41
	pub from: Option<H160>,
42
	/// Recipient
43
	pub to: H160,
44
	/// Gas Price, legacy.
45
	pub gas_price: Option<U256>,
46
	/// Max BaseFeePerGas the user is willing to pay.
47
	pub max_fee_per_gas: Option<U256>,
48
	/// The miner's tip.
49
	pub max_priority_fee_per_gas: Option<U256>,
50
	/// Gas
51
	pub gas: Option<U256>,
52
	/// Value of transaction in wei
53
	pub value: Option<U256>,
54
	/// Additional data sent with transaction
55
	pub data: Option<Bytes>,
56
	/// Nonce
57
	pub nonce: Option<U256>,
58
	/// EIP-2930 access list
59
	pub access_list: Option<Vec<AccessListItem>>,
60
	/// EIP-2718 type
61
	#[serde(rename = "type")]
62
	pub transaction_type: Option<U256>,
63
}
64

            
65
#[rpc(server)]
66
#[jsonrpsee::core::async_trait]
67
pub trait Debug {
68
	#[method(name = "debug_traceTransaction")]
69
	async fn trace_transaction(
70
		&self,
71
		transaction_hash: H256,
72
		params: Option<TraceParams>,
73
	) -> RpcResult<single::TransactionTrace>;
74
	#[method(name = "debug_traceCall")]
75
	async fn trace_call(
76
		&self,
77
		call_params: TraceCallParams,
78
		id: RequestBlockId,
79
		params: Option<TraceParams>,
80
	) -> RpcResult<single::TransactionTrace>;
81
	#[method(name = "debug_traceBlockByNumber", aliases = ["debug_traceBlockByHash"])]
82
	async fn trace_block(
83
		&self,
84
		id: RequestBlockId,
85
		params: Option<TraceParams>,
86
	) -> RpcResult<Vec<block::BlockTransactionTrace>>;
87
}