Skip to content

Commit

Permalink
Adds debug_traceCall RPC method (#2796)
Browse files Browse the repository at this point in the history
* Adds debug_traceCall method

* test debug_traceCall rpc method

---------

Co-authored-by: Rodrigo Quelhas <rodrigo_quelhas@outlook.pt>
Co-authored-by: Éloïs <c@elo.tf>
  • Loading branch information
3 people authored May 20, 2024
1 parent b064f1a commit cb45c95
Show file tree
Hide file tree
Showing 13 changed files with 562 additions and 9 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ evm-tracing-events = { path = "primitives/rpc/evm-tracing-events", default-featu
moonbeam-core-primitives = { path = "core-primitives", default-features = false }
moonbeam-primitives-ext = { path = "primitives/ext", default-features = false }
moonbeam-rpc-primitives-debug = { path = "primitives/rpc/debug", default-features = false, features = [
"runtime-2900",
"runtime-3000",
] }
moonbeam-rpc-primitives-txpool = { path = "primitives/rpc/txpool", default-features = false }
storage-proof-primitives = { path = "primitives/storage-proof", default-features = false }
Expand Down
2 changes: 2 additions & 0 deletions client/rpc-core/debug/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ repository = { workspace = true }
version = "0.1.0"

[dependencies]
ethereum = { workspace = true, features = [ "with-codec" ] }
ethereum-types = { workspace = true, features = [ "std" ] }
futures = { workspace = true, features = [ "compat" ] }
jsonrpsee = { workspace = true, features = [ "macros", "server" ] }
Expand All @@ -17,3 +18,4 @@ serde = { workspace = true, features = [ "derive" ] }
serde_json = { workspace = true }

sp-core = { workspace = true, features = [ "std" ] }
fc-rpc-core = { workspace = true }
40 changes: 39 additions & 1 deletion client/rpc-core/debug/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@

// You should have received a copy of the GNU General Public License
// along with Moonbeam. If not, see <http://www.gnu.org/licenses/>.
use ethereum_types::H256;

use ethereum::AccessListItem;
use ethereum_types::{H160, H256, U256};
use fc_rpc_core::types::Bytes;
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
use moonbeam_client_evm_tracing::types::single;
use moonbeam_rpc_core_types::RequestBlockId;
Expand All @@ -30,6 +33,34 @@ pub struct TraceParams {
pub timeout: Option<String>,
}

#[derive(Debug, Clone, Default, Eq, PartialEq, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TraceCallParams {
/// Sender
pub from: Option<H160>,
/// Recipient
pub to: H160,
/// Gas Price, legacy.
pub gas_price: Option<U256>,
/// Max BaseFeePerGas the user is willing to pay.
pub max_fee_per_gas: Option<U256>,
/// The miner's tip.
pub max_priority_fee_per_gas: Option<U256>,
/// Gas
pub gas: Option<U256>,
/// Value of transaction in wei
pub value: Option<U256>,
/// Additional data sent with transaction
pub data: Option<Bytes>,
/// Nonce
pub nonce: Option<U256>,
/// EIP-2930 access list
pub access_list: Option<Vec<AccessListItem>>,
/// EIP-2718 type
#[serde(rename = "type")]
pub transaction_type: Option<U256>,
}

#[rpc(server)]
#[jsonrpsee::core::async_trait]
pub trait Debug {
Expand All @@ -39,6 +70,13 @@ pub trait Debug {
transaction_hash: H256,
params: Option<TraceParams>,
) -> RpcResult<single::TransactionTrace>;
#[method(name = "debug_traceCall")]
async fn trace_call(
&self,
call_params: TraceCallParams,
id: RequestBlockId,
params: Option<TraceParams>,
) -> RpcResult<single::TransactionTrace>;
#[method(name = "debug_traceBlockByNumber", aliases = ["debug_traceBlockByHash"])]
async fn trace_block(
&self,
Expand Down
1 change: 1 addition & 0 deletions client/rpc/debug/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ fc-consensus = { workspace = true }
fc-db = { workspace = true }
fc-api = { workspace = true }
fc-rpc = { workspace = true, features = [ "rpc-binary-search-estimate" ] }
fc-rpc-core = { workspace = true }
fc-storage = { workspace = true }
fp-rpc = { workspace = true, features = [ "std" ] }
Loading

0 comments on commit cb45c95

Please sign in to comment.