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

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

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

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

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

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