moonbeam_rpc_primitives_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
17#![cfg_attr(not(feature = "std"), no_std)]
18
19use ethereum::{AuthorizationList, LegacyTransaction, TransactionV2, TransactionV3};
20use ethereum_types::{H160, H256, U256};
21use parity_scale_codec::{Decode, Encode};
22use sp_std::vec::Vec;
23
24sp_api::decl_runtime_apis! {
25	// Api version is virtually 5.
26	//
27	// We realized that even using runtime overrides, using the ApiExt interface reads the api
28	// versions from the state runtime, meaning we cannot just reset the versioning as we see fit.
29	//
30	// In order to be able to use ApiExt as part of the RPC handler logic we need to be always
31	// above the version that exists on chain for this Api, even if this Api is only meant
32	// to be used overridden.
33	#[api_version(7)]
34	pub trait DebugRuntimeApi {
35		#[changed_in(4)]
36		fn trace_transaction(
37			extrinsics: Vec<Block::Extrinsic>,
38			transaction: &LegacyTransaction,
39		) -> Result<(), sp_runtime::DispatchError>;
40
41		#[changed_in(5)]
42		fn trace_transaction(
43			extrinsics: Vec<Block::Extrinsic>,
44			transaction: &TransactionV2,
45		) -> Result<(), sp_runtime::DispatchError>;
46
47		#[changed_in(7)]
48		fn trace_transaction(
49			extrinsics: Vec<Block::Extrinsic>,
50			transaction: &TransactionV2,
51			header: &Block::Header,
52		) -> Result<(), sp_runtime::DispatchError>;
53
54		fn trace_transaction(
55			extrinsics: Vec<Block::Extrinsic>,
56			transaction: &TransactionV3,
57			header: &Block::Header,
58		) -> Result<(), sp_runtime::DispatchError>;
59
60		#[changed_in(5)]
61		fn trace_block(
62			extrinsics: Vec<Block::Extrinsic>,
63			known_transactions: Vec<H256>,
64		) -> Result<(), sp_runtime::DispatchError>;
65
66		fn trace_block(
67			extrinsics: Vec<Block::Extrinsic>,
68			known_transactions: Vec<H256>,
69			header: &Block::Header,
70		) -> Result<(), sp_runtime::DispatchError>;
71
72		fn trace_call(
73			header: &Block::Header,
74			from: H160,
75			to: H160,
76			data: Vec<u8>,
77			value: U256,
78			gas_limit: U256,
79			max_fee_per_gas: Option<U256>,
80			max_priority_fee_per_gas: Option<U256>,
81			nonce: Option<U256>,
82			access_list: Option<Vec<(H160, Vec<H256>)>>,
83			authorization_list: Option<AuthorizationList>,
84		) -> Result<(), sp_runtime::DispatchError>;
85	}
86}
87
88#[derive(Clone, Copy, Eq, PartialEq, Debug, Encode, Decode)]
89pub enum TracerInput {
90	None,
91	Blockscout,
92	CallTracer,
93}
94
95/// DebugRuntimeApi V2 result. Trace response is stored in client and runtime api call response is
96/// empty.
97#[derive(Debug)]
98pub enum Response {
99	Single,
100	Block,
101}