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::{TransactionV0 as LegacyTransaction, TransactionV2 as Transaction};
20
use ethereum_types::{H160, H256, U256};
21
use parity_scale_codec::{Decode, Encode};
22
use sp_std::vec::Vec;
23

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

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

            
47
60
		fn trace_transaction(
48
60
			extrinsics: Vec<Block::Extrinsic>,
49
60
			transaction: &Transaction,
50
60
			header: &Block::Header,
51
60
		) -> Result<(), sp_runtime::DispatchError>;
52
60

            
53
60
		#[changed_in(5)]
54
60
		fn trace_block(
55
60
			extrinsics: Vec<Block::Extrinsic>,
56
60
			known_transactions: Vec<H256>,
57
60
		) -> Result<(), sp_runtime::DispatchError>;
58
60

            
59
60
		fn trace_block(
60
60
			extrinsics: Vec<Block::Extrinsic>,
61
60
			known_transactions: Vec<H256>,
62
60
			header: &Block::Header,
63
60
		) -> Result<(), sp_runtime::DispatchError>;
64
60

            
65
60
		fn trace_call(
66
60
			header: &Block::Header,
67
60
			from: H160,
68
60
			to: H160,
69
60
			data: Vec<u8>,
70
60
			value: U256,
71
60
			gas_limit: U256,
72
60
			max_fee_per_gas: Option<U256>,
73
60
			max_priority_fee_per_gas: Option<U256>,
74
60
			nonce: Option<U256>,
75
60
			access_list: Option<Vec<(H160, Vec<H256>)>>,
76
60
		) -> Result<(), sp_runtime::DispatchError>;
77
60
	}
78
60
}
79

            
80
#[derive(Clone, Copy, Eq, PartialEq, Debug, Encode, Decode)]
81
pub enum TracerInput {
82
	None,
83
	Blockscout,
84
	CallTracer,
85
}
86

            
87
/// DebugRuntimeApi V2 result. Trace response is stored in client and runtime api call response is
88
/// empty.
89
#[derive(Debug)]
90
pub enum Response {
91
	Single,
92
	Block,
93
}