diff --git a/Cargo.lock b/Cargo.lock
index 1c18395c8d..de486313f9 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2709,6 +2709,9 @@ name = "hex"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
+dependencies = [
+ "serde",
+]
[[package]]
name = "hex-literal"
@@ -4330,6 +4333,8 @@ dependencies = [
"jsonrpc-core 15.1.0",
"jsonrpc-pubsub 15.1.0",
"log",
+ "moonbeam-rpc-debug",
+ "moonbeam-rpc-primitives-debug",
"moonbeam-rpc-primitives-txpool",
"moonbeam-rpc-txpool",
"moonbeam-runtime",
@@ -4391,6 +4396,36 @@ dependencies = [
"trie-root 0.15.2",
]
+[[package]]
+name = "moonbeam-extensions-evm"
+version = "0.1.0"
+dependencies = [
+ "ethereum-types",
+ "evm",
+ "evm-core",
+ "fp-evm",
+ "moonbeam-rpc-primitives-debug",
+ "pallet-evm",
+ "sp-core",
+ "sp-io",
+ "sp-runtime",
+ "sp-std",
+]
+
+[[package]]
+name = "moonbeam-rpc-core-debug"
+version = "0.1.0"
+dependencies = [
+ "ethereum-types",
+ "jsonrpc-core 15.1.0",
+ "jsonrpc-core-client 14.2.0",
+ "jsonrpc-derive 14.2.2",
+ "moonbeam-rpc-primitives-debug",
+ "serde",
+ "serde_json",
+ "sp-core",
+]
+
[[package]]
name = "moonbeam-rpc-core-txpool"
version = "0.6.0"
@@ -4405,6 +4440,44 @@ dependencies = [
"serde_json",
]
+[[package]]
+name = "moonbeam-rpc-debug"
+version = "0.1.0"
+dependencies = [
+ "ethereum",
+ "ethereum-types",
+ "fc-consensus",
+ "fc-db",
+ "fp-rpc",
+ "jsonrpc-core 15.1.0",
+ "moonbeam-rpc-core-debug",
+ "moonbeam-rpc-primitives-debug",
+ "sc-client-api",
+ "sp-api",
+ "sp-block-builder",
+ "sp-blockchain",
+ "sp-core",
+ "sp-io",
+ "sp-runtime",
+]
+
+[[package]]
+name = "moonbeam-rpc-primitives-debug"
+version = "0.1.0"
+dependencies = [
+ "ethereum",
+ "ethereum-types",
+ "hex",
+ "parity-scale-codec",
+ "serde",
+ "serde_json",
+ "sp-api",
+ "sp-core",
+ "sp-io",
+ "sp-runtime",
+ "sp-std",
+]
+
[[package]]
name = "moonbeam-rpc-primitives-txpool"
version = "0.6.0"
@@ -4451,6 +4524,8 @@ dependencies = [
"frame-system-rpc-runtime-api",
"hex-literal",
"log",
+ "moonbeam-extensions-evm",
+ "moonbeam-rpc-primitives-debug",
"moonbeam-rpc-primitives-txpool",
"pallet-author-filter",
"pallet-balances",
@@ -4471,6 +4546,7 @@ dependencies = [
"parity-scale-codec",
"precompiles",
"serde",
+ "sha3 0.9.1",
"sp-api",
"sp-block-builder",
"sp-core",
diff --git a/client/rpc-core/debug/Cargo.toml b/client/rpc-core/debug/Cargo.toml
new file mode 100644
index 0000000000..b9525c241d
--- /dev/null
+++ b/client/rpc-core/debug/Cargo.toml
@@ -0,0 +1,21 @@
+[package]
+name = "moonbeam-rpc-core-debug"
+version = '0.1.0'
+authors = ['PureStake']
+edition = '2018'
+homepage = 'https://moonbeam.network'
+license = 'GPL-3.0-only'
+repository = 'https://github.com/PureStake/moonbeam/'
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+ethereum-types = "0.11.0"
+jsonrpc-core = "15.0.0"
+jsonrpc-core-client = "14.0.3"
+jsonrpc-derive = "14.0.3"
+serde = { version = "1.0", features = ["derive"] }
+serde_json = "1.0"
+sp-core = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
+moonbeam-rpc-primitives-debug = { path = "../../../primitives/rpc/debug" }
+#evm = { version = "0.20.0", default-features = false, features = ["with-codec"] }
diff --git a/client/rpc-core/debug/src/lib.rs b/client/rpc-core/debug/src/lib.rs
new file mode 100644
index 0000000000..3810271d1e
--- /dev/null
+++ b/client/rpc-core/debug/src/lib.rs
@@ -0,0 +1,52 @@
+// Copyright 2019-2020 PureStake Inc.
+// This file is part of Moonbeam.
+
+// Moonbeam is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Moonbeam is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Moonbeam. If not, see .
+
+use ethereum_types::H256;
+use jsonrpc_core::Result;
+use jsonrpc_derive::rpc;
+use serde::Deserialize;
+
+pub use crate::types::{StepLog, TraceExecutorResponse};
+
+pub use rpc_impl_Debug::gen_server::Debug as DebugServer;
+
+pub mod types {
+ pub use moonbeam_rpc_primitives_debug::{StepLog, TraceExecutorResponse};
+}
+
+// TODO: Add support for additional params.
+// - `disableStorage`, `disableMemory`, `disableStack`.
+// - `timeout` should be ignored unless we find out a way for actually evaluating the tracer input.
+#[derive(Clone, Eq, PartialEq, Debug, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct TraceParams {
+ /// Javascript tracer (we just check if it's Blockscout tracer string)
+ pub disable_storage: Option,
+ pub disable_memory: Option,
+ pub disable_stack: Option,
+ pub tracer: Option,
+ pub timeout: Option,
+}
+
+#[rpc(server)]
+pub trait Debug {
+ #[rpc(name = "debug_traceTransaction")]
+ fn trace_transaction(
+ &self,
+ transaction_hash: H256,
+ params: Option,
+ ) -> Result;
+}
diff --git a/client/rpc-core/txpool/src/types/content.rs b/client/rpc-core/txpool/src/types/content.rs
index 9a15476cfb..afda323343 100644
--- a/client/rpc-core/txpool/src/types/content.rs
+++ b/client/rpc-core/txpool/src/types/content.rs
@@ -45,6 +45,8 @@ pub struct Transaction {
pub gas: U256,
/// Data
pub input: Bytes,
+ /// Transaction Index
+ pub transaction_index: Option,
}
fn block_hash_serialize(hash: &Option, serializer: S) -> Result
@@ -77,6 +79,7 @@ impl GetT for Transaction {
gas_price: txn.gas_price,
gas: txn.gas_limit,
input: Bytes(txn.input.clone()),
+ transaction_index: None,
}
}
}
diff --git a/client/rpc/debug/Cargo.toml b/client/rpc/debug/Cargo.toml
new file mode 100644
index 0000000000..46a76e2147
--- /dev/null
+++ b/client/rpc/debug/Cargo.toml
@@ -0,0 +1,26 @@
+[package]
+name = "moonbeam-rpc-debug"
+version = '0.1.0'
+authors = ['PureStake']
+edition = '2018'
+homepage = 'https://moonbeam.network'
+license = 'GPL-3.0-only'
+repository = 'https://github.com/PureStake/moonbeam/'
+
+[dependencies]
+jsonrpc-core = "15.0.0"
+ethereum = { version = "0.7.1", default-features = false, features = ["with-codec"] }
+ethereum-types = "0.11.0"
+sp-core = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
+sp-api = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
+sp-io = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
+sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
+sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
+sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
+sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
+
+moonbeam-rpc-core-debug = { path = "../../rpc-core/debug" }
+moonbeam-rpc-primitives-debug = { path = "../../../primitives/rpc/debug" }
+fc-consensus = { git = "https://github.com/purestake/frontier", branch = "notlesh-moonbeam-v0.7" }
+fc-db = { git = "https://github.com/purestake/frontier", branch = "notlesh-moonbeam-v0.7" }
+fp-rpc = { git = "https://github.com/purestake/frontier", branch = "notlesh-moonbeam-v0.7" }
\ No newline at end of file
diff --git a/client/rpc/debug/src/lib.rs b/client/rpc/debug/src/lib.rs
new file mode 100644
index 0000000000..075a98b4ad
--- /dev/null
+++ b/client/rpc/debug/src/lib.rs
@@ -0,0 +1,214 @@
+// Copyright 2019-2020 PureStake Inc.
+// This file is part of Moonbeam.
+
+// Moonbeam is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Moonbeam is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Moonbeam. If not, see .
+
+pub use moonbeam_rpc_core_debug::{
+ Debug as DebugT, DebugServer, StepLog, TraceExecutorResponse, TraceParams,
+};
+
+use ethereum_types::{H128, H256};
+use fp_rpc::EthereumRuntimeRPCApi;
+use jsonrpc_core::Result as RpcResult;
+use jsonrpc_core::{Error as RpcError, ErrorCode};
+use moonbeam_rpc_primitives_debug::{DebugRuntimeApi, TraceType};
+use sc_client_api::backend::{AuxStore, Backend, StateBackend};
+use sp_api::{BlockId, HeaderT, ProvideRuntimeApi};
+use sp_block_builder::BlockBuilder;
+use sp_blockchain::{
+ Backend as BlockchainBackend, Error as BlockChainError, HeaderBackend, HeaderMetadata,
+};
+use sp_runtime::traits::{BlakeTwo256, Block as BlockT};
+use std::{str::FromStr, sync::Arc};
+
+pub fn internal_err(message: T) -> RpcError {
+ RpcError {
+ code: ErrorCode::InternalError,
+ message: message.to_string(),
+ data: None,
+ }
+}
+
+pub struct Debug {
+ client: Arc,
+ backend: Arc,
+ frontier_backend: Arc>,
+}
+
+impl Debug {
+ pub fn new(client: Arc, backend: Arc, frontier_backend: Arc>) -> Self {
+ Self {
+ client,
+ backend,
+ frontier_backend,
+ }
+ }
+}
+
+impl Debug
+where
+ BE: Backend + 'static,
+ BE::State: StateBackend,
+ BE::Blockchain: BlockchainBackend,
+ C: ProvideRuntimeApi + AuxStore,
+ C: HeaderMetadata + HeaderBackend,
+ C: Send + Sync + 'static,
+ B: BlockT + Send + Sync + 'static,
+ C::Api: BlockBuilder,
+ C::Api: DebugRuntimeApi,
+ C::Api: EthereumRuntimeRPCApi,
+{
+ // Asumes there is only one mapped canonical block in the AuxStore, otherwise something is wrong
+ fn load_hash(&self, hash: H256) -> RpcResult