Skip to content

Commit 5f13853

Browse files
authored
feat: add rpc v2 types and api (polkadot-evm#1427)
1 parent f0599e4 commit 5f13853

33 files changed

+3710
-0
lines changed

Cargo.lock

Lines changed: 68 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ members = [
2222
"client/consensus",
2323
"client/rpc-core",
2424
"client/rpc",
25+
"client/rpc-v2",
26+
"client/rpc-v2/api",
27+
"client/rpc-v2/types",
2528
"client/db",
2629
"client/storage",
2730
"client/mapping-sync",
@@ -48,6 +51,7 @@ repository = "https://github.com/paritytech/frontier/"
4851
async-trait = "0.1"
4952
bn = { package = "substrate-bn", version = "0.6", default-features = false }
5053
clap = { version = "4.5", features = ["derive", "deprecated"] }
54+
const-hex = { version = "1.11", default-features = false, features = ["alloc"] }
5155
derive_more = "0.99"
5256
environmental = { version = "1.1.4", default-features = false }
5357
ethereum = { version = "0.15.0", default-features = false }
@@ -169,6 +173,9 @@ fc-db = { path = "client/db", default-features = false }
169173
fc-mapping-sync = { path = "client/mapping-sync", default-features = false }
170174
fc-rpc = { path = "client/rpc", default-features = false }
171175
fc-rpc-core = { path = "client/rpc-core" }
176+
fc-rpc-v2 = { path = "client/rpc-v2" }
177+
fc-rpc-v2-api = { path = "client/rpc-v2/api" }
178+
fc-rpc-v2-types = { path = "client/rpc-v2/types" }
172179
fc-storage = { path = "client/storage" }
173180
# Frontier Primitive
174181
fp-account = { path = "primitives/account", default-features = false }

client/rpc-v2/Cargo.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "fc-rpc-v2"
3+
version = "2.0.0-dev"
4+
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
5+
description = "Ethereum RPC (web3) compatibility layer for Substrate."
6+
authors = { workspace = true }
7+
edition = { workspace = true }
8+
repository = { workspace = true }
9+
10+
[package.metadata.docs.rs]
11+
targets = ["x86_64-unknown-linux-gnu"]
12+
13+
[dependencies]

client/rpc-v2/api/Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "fc-rpc-v2-api"
3+
version = "0.1.0"
4+
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
5+
description = "Ethereum RPC (web3) interfaces."
6+
authors = { workspace = true }
7+
edition = { workspace = true }
8+
repository = { workspace = true }
9+
10+
[dependencies]
11+
ethereum-types = { workspace = true }
12+
jsonrpsee = { workspace = true, features = ["client-core", "server-core", "macros"] }
13+
14+
# Frontier
15+
fc-rpc-v2-types = { workspace = true }

client/rpc-v2/api/src/debug.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// This file is part of Frontier.
2+
3+
// Copyright (C) Parity Technologies (UK) Ltd.
4+
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
5+
6+
// This program is free software: you can redistribute it and/or modify
7+
// it under the terms of the GNU General Public License as published by
8+
// the Free Software Foundation, either version 3 of the License, or
9+
// (at your option) any later version.
10+
11+
// This program is distributed in the hope that it will be useful,
12+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
// GNU General Public License for more details.
15+
16+
// You should have received a copy of the GNU General Public License
17+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
19+
use ethereum_types::H256;
20+
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
21+
22+
use crate::types::{block_id::BlockNumberOrTagOrHash, bytes::Bytes};
23+
24+
/// Debug RPC interface.
25+
#[rpc(client, server, namespace = "debug")]
26+
#[async_trait]
27+
pub trait DebugApi {
28+
/// Returns an RLP-encoded header.
29+
#[method(name = "getRawHeader")]
30+
async fn raw_header(&self, block: BlockNumberOrTagOrHash) -> RpcResult<Option<Bytes>>;
31+
32+
/// Returns an RLP-encoded block.
33+
#[method(name = "getRawBlock")]
34+
async fn raw_block(&self, block: BlockNumberOrTagOrHash) -> RpcResult<Option<Bytes>>;
35+
36+
/// Returns the EIP-2718 binary-encoded transaction.
37+
#[method(name = "getRawTransaction")]
38+
async fn raw_transaction(&self, transaction_hash: H256) -> RpcResult<Option<Bytes>>;
39+
40+
/// Returns an array of EIP-2718 binary-encoded receipts.
41+
#[method(name = "getRawReceipts")]
42+
async fn raw_receipts(&self, block: BlockNumberOrTagOrHash) -> RpcResult<Vec<Bytes>>;
43+
44+
/// Returns an array of recent bad blocks that the client has seen on the network.
45+
#[method(name = "getBadBlocks")]
46+
async fn bad_blocks(&self) -> RpcResult<Vec<()>>;
47+
}

0 commit comments

Comments
 (0)