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