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

            
19
use ethereum::{AuthorizationList, LegacyTransaction, TransactionV2, TransactionV3};
20
use ethereum_types::{H160, H256, U256};
21
use parity_scale_codec::{Decode, Encode};
22
use sp_std::vec::Vec;
23

            
24
63
sp_api::decl_runtime_apis! {
25
63
	// Api version is virtually 5.
26
63
	//
27
63
	// We realized that even using runtime overrides, using the ApiExt interface reads the api
28
63
	// versions from the state runtime, meaning we cannot just reset the versioning as we see fit.
29
63
	//
30
63
	// In order to be able to use ApiExt as part of the RPC handler logic we need to be always
31
63
	// above the version that exists on chain for this Api, even if this Api is only meant
32
63
	// to be used overridden.
33
63
	#[api_version(7)]
34
63
	pub trait DebugRuntimeApi {
35
63
		#[changed_in(4)]
36
63
		fn trace_transaction(
37
63
			extrinsics: Vec<Block::Extrinsic>,
38
63
			transaction: &LegacyTransaction,
39
63
		) -> Result<(), sp_runtime::DispatchError>;
40
63

            
41
63
		#[changed_in(5)]
42
63
		fn trace_transaction(
43
63
			extrinsics: Vec<Block::Extrinsic>,
44
63
			transaction: &TransactionV2,
45
63
		) -> Result<(), sp_runtime::DispatchError>;
46
63

            
47
63
		#[changed_in(7)]
48
63
		fn trace_transaction(
49
63
			extrinsics: Vec<Block::Extrinsic>,
50
63
			transaction: &TransactionV2,
51
63
			header: &Block::Header,
52
63
		) -> Result<(), sp_runtime::DispatchError>;
53
63

            
54
63
		fn trace_transaction(
55
63
			extrinsics: Vec<Block::Extrinsic>,
56
63
			transaction: &TransactionV3,
57
63
			header: &Block::Header,
58
63
		) -> Result<(), sp_runtime::DispatchError>;
59
63

            
60
63
		#[changed_in(5)]
61
63
		fn trace_block(
62
63
			extrinsics: Vec<Block::Extrinsic>,
63
63
			known_transactions: Vec<H256>,
64
63
		) -> Result<(), sp_runtime::DispatchError>;
65
63

            
66
63
		fn trace_block(
67
63
			extrinsics: Vec<Block::Extrinsic>,
68
63
			known_transactions: Vec<H256>,
69
63
			header: &Block::Header,
70
63
		) -> Result<(), sp_runtime::DispatchError>;
71
63

            
72
63
		fn trace_call(
73
63
			header: &Block::Header,
74
63
			from: H160,
75
63
			to: H160,
76
63
			data: Vec<u8>,
77
63
			value: U256,
78
63
			gas_limit: U256,
79
63
			max_fee_per_gas: Option<U256>,
80
63
			max_priority_fee_per_gas: Option<U256>,
81
63
			nonce: Option<U256>,
82
63
			access_list: Option<Vec<(H160, Vec<H256>)>>,
83
63
			authorization_list: Option<AuthorizationList>,
84
63
		) -> Result<(), sp_runtime::DispatchError>;
85
63
	}
86
63
}
87

            
88
#[derive(Clone, Copy, Eq, PartialEq, Debug, Encode, Decode)]
89
pub 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)]
98
pub enum Response {
99
	Single,
100
	Block,
101
}