Skip to content

Commit

Permalink
feat: add rpc v2 types and api (polkadot-evm#1427)
Browse files Browse the repository at this point in the history
  • Loading branch information
koushiro authored and ipapandinas committed Sep 4, 2024
1 parent 79bf591 commit c17090d
Show file tree
Hide file tree
Showing 33 changed files with 3,710 additions and 0 deletions.
68 changes: 68 additions & 0 deletions Cargo.lock

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

7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ members = [
"client/consensus",
"client/rpc-core",
"client/rpc",
"client/rpc-v2",
"client/rpc-v2/api",
"client/rpc-v2/types",
"client/db",
"client/storage",
"client/mapping-sync",
Expand All @@ -48,6 +51,7 @@ repository = "https://github.com/paritytech/frontier/"
async-trait = "0.1"
bn = { package = "substrate-bn", version = "0.6", default-features = false }
clap = { version = "4.5", features = ["derive", "deprecated"] }
const-hex = { version = "1.11", default-features = false, features = ["alloc"] }
derive_more = "0.99"
environmental = { version = "1.1.4", default-features = false }
ethereum = { version = "0.15.0", default-features = false }
Expand Down Expand Up @@ -169,6 +173,9 @@ fc-db = { path = "client/db", default-features = false }
fc-mapping-sync = { path = "client/mapping-sync", default-features = false }
fc-rpc = { path = "client/rpc", default-features = false }
fc-rpc-core = { path = "client/rpc-core" }
fc-rpc-v2 = { path = "client/rpc-v2" }
fc-rpc-v2-api = { path = "client/rpc-v2/api" }
fc-rpc-v2-types = { path = "client/rpc-v2/types" }
fc-storage = { path = "client/storage" }
# Frontier Primitive
fp-account = { path = "primitives/account", default-features = false }
Expand Down
13 changes: 13 additions & 0 deletions client/rpc-v2/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "fc-rpc-v2"
version = "2.0.0-dev"
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
description = "Ethereum RPC (web3) compatibility layer for Substrate."
authors = { workspace = true }
edition = { workspace = true }
repository = { workspace = true }

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
15 changes: 15 additions & 0 deletions client/rpc-v2/api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "fc-rpc-v2-api"
version = "0.1.0"
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
description = "Ethereum RPC (web3) interfaces."
authors = { workspace = true }
edition = { workspace = true }
repository = { workspace = true }

[dependencies]
ethereum-types = { workspace = true }
jsonrpsee = { workspace = true, features = ["client-core", "server-core", "macros"] }

# Frontier
fc-rpc-v2-types = { workspace = true }
47 changes: 47 additions & 0 deletions client/rpc-v2/api/src/debug.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// This file is part of Frontier.

// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0

// This program 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.

// This program 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 this program. If not, see <https://www.gnu.org/licenses/>.

use ethereum_types::H256;
use jsonrpsee::{core::RpcResult, proc_macros::rpc};

use crate::types::{block_id::BlockNumberOrTagOrHash, bytes::Bytes};

/// Debug RPC interface.
#[rpc(client, server, namespace = "debug")]
#[async_trait]
pub trait DebugApi {
/// Returns an RLP-encoded header.
#[method(name = "getRawHeader")]
async fn raw_header(&self, block: BlockNumberOrTagOrHash) -> RpcResult<Option<Bytes>>;

/// Returns an RLP-encoded block.
#[method(name = "getRawBlock")]
async fn raw_block(&self, block: BlockNumberOrTagOrHash) -> RpcResult<Option<Bytes>>;

/// Returns the EIP-2718 binary-encoded transaction.
#[method(name = "getRawTransaction")]
async fn raw_transaction(&self, transaction_hash: H256) -> RpcResult<Option<Bytes>>;

/// Returns an array of EIP-2718 binary-encoded receipts.
#[method(name = "getRawReceipts")]
async fn raw_receipts(&self, block: BlockNumberOrTagOrHash) -> RpcResult<Vec<Bytes>>;

/// Returns an array of recent bad blocks that the client has seen on the network.
#[method(name = "getBadBlocks")]
async fn bad_blocks(&self) -> RpcResult<Vec<()>>;
}
Loading

0 comments on commit c17090d

Please sign in to comment.