moonbeam_rpc_core_debug/
lib.rs

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
17use ethereum::{AccessListItem, AuthorizationList};
18use ethereum_types::{H160, H256, U256};
19use fc_rpc_core::types::Bytes;
20use jsonrpsee::{core::RpcResult, proc_macros::rpc};
21use moonbeam_client_evm_tracing::types::{block, single};
22use moonbeam_rpc_core_types::RequestBlockId;
23use serde::Deserialize;
24
25#[derive(Clone, Eq, PartialEq, Debug, Deserialize)]
26#[serde(rename_all = "camelCase")]
27pub 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")]
39pub 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-7702 authorization list
61	pub authorization_list: Option<AuthorizationList>,
62	/// EIP-2718 type
63	#[serde(rename = "type")]
64	pub transaction_type: Option<U256>,
65}
66
67#[rpc(server)]
68#[jsonrpsee::core::async_trait]
69pub trait Debug {
70	#[method(name = "debug_traceTransaction")]
71	async fn trace_transaction(
72		&self,
73		transaction_hash: H256,
74		params: Option<TraceParams>,
75	) -> RpcResult<single::TransactionTrace>;
76	#[method(name = "debug_traceCall")]
77	async fn trace_call(
78		&self,
79		call_params: TraceCallParams,
80		id: RequestBlockId,
81		params: Option<TraceParams>,
82	) -> RpcResult<single::TransactionTrace>;
83	#[method(name = "debug_traceBlockByNumber", aliases = ["debug_traceBlockByHash"])]
84	async fn trace_block(
85		&self,
86		id: RequestBlockId,
87		params: Option<TraceParams>,
88	) -> RpcResult<Vec<block::BlockTransactionTrace>>;
89}