Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phala-node: Integrate frontier to support ETH RPC #1504

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,058 changes: 911 additions & 147 deletions Cargo.lock

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,41 @@ members = [
"scripts/debug-cli"
]

[workspace.dependencies]
# Frontier Client
fc-api = { git = "https://github.com/kvinwang/frontier", branch = "polkadot-v1.5.0" }
fc-cli = { git = "https://github.com/kvinwang/frontier", branch = "polkadot-v1.5.0", default-features = false }
fc-consensus = { git = "https://github.com/kvinwang/frontier", branch = "polkadot-v1.5.0" }
fc-db = { git = "https://github.com/kvinwang/frontier", branch = "polkadot-v1.5.0", default-features = false }
fc-mapping-sync = { git = "https://github.com/kvinwang/frontier", branch = "polkadot-v1.5.0", default-features = false }
fc-rpc = { git = "https://github.com/kvinwang/frontier", branch = "polkadot-v1.5.0", default-features = false }
fc-rpc-core = { git = "https://github.com/kvinwang/frontier", branch = "polkadot-v1.5.0" }
fc-storage = { git = "https://github.com/kvinwang/frontier", branch = "polkadot-v1.5.0" }
# Frontier Primitive
fp-account = { git = "https://github.com/kvinwang/frontier", branch = "polkadot-v1.5.0", default-features = false }
fp-consensus = { git = "https://github.com/kvinwang/frontier", branch = "polkadot-v1.5.0", default-features = false }
fp-dynamic-fee = { git = "https://github.com/kvinwang/frontier", branch = "polkadot-v1.5.0", default-features = false }
fp-ethereum = { git = "https://github.com/kvinwang/frontier", branch = "polkadot-v1.5.0", default-features = false }
fp-evm = { git = "https://github.com/kvinwang/frontier", branch = "polkadot-v1.5.0", default-features = false }
fp-rpc = { git = "https://github.com/kvinwang/frontier", branch = "polkadot-v1.5.0", default-features = false }
fp-self-contained = { git = "https://github.com/kvinwang/frontier", branch = "polkadot-v1.5.0", default-features = false }
fp-storage = { git = "https://github.com/kvinwang/frontier", branch = "polkadot-v1.5.0", default-features = false }
# Frontier FRAME
pallet-base-fee = { git = "https://github.com/kvinwang/frontier", branch = "polkadot-v1.5.0", default-features = false }
pallet-dynamic-fee = { git = "https://github.com/kvinwang/frontier", branch = "polkadot-v1.5.0", default-features = false }
pallet-ethereum = { git = "https://github.com/kvinwang/frontier", branch = "polkadot-v1.5.0", default-features = false }
pallet-evm = { git = "https://github.com/kvinwang/frontier", branch = "polkadot-v1.5.0", default-features = false }
pallet-evm-precompile-modexp = { git = "https://github.com/kvinwang/frontier", branch = "polkadot-v1.5.0", default-features = false }
pallet-evm-precompile-sha3fips = { git = "https://github.com/kvinwang/frontier", branch = "polkadot-v1.5.0", default-features = false }
pallet-evm-precompile-simple = { git = "https://github.com/kvinwang/frontier", branch = "polkadot-v1.5.0", default-features = false }
pallet-evm-precompile-dispatch = { git = "https://github.com/kvinwang/frontier", branch = "polkadot-v1.5.0", default-features = false }
pallet-evm-test-vector-support = { git = "https://github.com/kvinwang/frontier", branch = "polkadot-v1.5.0" }
pallet-hotfix-sufficients = { git = "https://github.com/kvinwang/frontier", branch = "polkadot-v1.5.0", default-features = false }
# Frontier Template
frontier-template-runtime = { git = "https://github.com/kvinwang/frontier", branch = "polkadot-v1.5.0", default-features = false }
# Frontier Utility
precompile-utils = { git = "https://github.com/kvinwang/frontier", branch = "polkadot-v1.5.0", default-features = false }

[patch.crates-io]
# TODO.kevin: Move back to crates.io once it released 1.0
derive_more = { version = "0.99.17", git = "https://github.com/JelteF/derive_more" }
Expand Down
11 changes: 4 additions & 7 deletions crates/phala-node-rpc-ext/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ struct NodeRpcExt<BE, Block: BlockT, Client, P> {
}

impl<BE, Block: BlockT, Client, P> NodeRpcExt<BE, Block, Client, P> {
fn new(client: Arc<Client>, backend: Arc<BE>, _is_archive_mode: bool, pool: Arc<P>) -> Self {
fn new(client: Arc<Client>, backend: Arc<BE>, pool: Arc<P>) -> Self {
Self {
client,
backend,
Expand All @@ -89,8 +89,7 @@ where
+ BlockBackend<Block>
+ HeaderMetadata<Block, Error = sp_blockchain::Error>
+ ProvideRuntimeApi<Block>,
Client::Api:
sp_api::Metadata<Block> + ApiExt<Block>,
Client::Api: sp_api::Metadata<Block> + ApiExt<Block>,
Client::Api: MqApi<Block>,
Block: BlockT + 'static,
<<Block as BlockT>::Header as Header>::Number: Into<u64>,
Expand Down Expand Up @@ -143,7 +142,6 @@ pub fn extend_rpc<Client, BE, Block, P>(
io: &mut RpcModule<()>,
client: Arc<Client>,
backend: Arc<BE>,
is_archive_mode: bool,
pool: Arc<P>,
) where
BE: Backend<Block> + 'static,
Expand All @@ -154,12 +152,11 @@ pub fn extend_rpc<Client, BE, Block, P>(
+ ProvideRuntimeApi<Block>
+ 'static,
Block: BlockT + 'static,
Client::Api:
sp_api::Metadata<Block> + ApiExt<Block>,
Client::Api: sp_api::Metadata<Block> + ApiExt<Block>,
Client::Api: MqApi<Block>,
<<Block as BlockT>::Header as Header>::Number: Into<u64>,
P: TransactionPool + 'static,
{
io.merge(NodeRpcExt::new(client, backend, is_archive_mode, pool).into_rpc())
io.merge(NodeRpcExt::new(client, backend, pool).into_rpc())
.expect("Initialize Phala node RPC ext failed.");
}
2 changes: 1 addition & 1 deletion scripts/debug-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::fmt::Debug;
// use phala_types;

#[derive(Debug, Parser)]
#[clap(name = "Phala Debug Utility CLI")]
#[command(name = "Phala Debug Utility CLI")]
enum Cli {
DecodeWorkerRegistrationInfo {
#[arg(short)]
Expand Down
27 changes: 13 additions & 14 deletions standalone/headers-cache/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ mod web_api;
type BlockNumber = u32;

#[derive(Parser)]
#[clap(about = "Cache server for relaychain headers", version, author)]
#[command(about = "Cache server for relaychain headers", version, author)]
pub struct AppArgs {
#[command(subcommand)]
action: Action,
Expand Down Expand Up @@ -123,33 +123,32 @@ struct Serve {
#[arg(long, default_value = "cache.db")]
db: String,
/// If set, it will sync headers from the given mirror cache
#[clap(long)]
#[arg(long)]
mirror: Option<String>,
/// The genesis block bo be synced
#[clap(long, default_value_t = 8325311)]
#[arg(long, default_value_t = 8325311)]
genesis_block: BlockNumber,
/// Auto grab new headers from the node
#[clap(long)]
#[arg(long)]
#[arg(visible_alias = "grab")]
grab_headers: bool,
/// Auto grab new parachain headers from the node
#[clap(long)]
#[arg(long)]
grab_para_headers: bool,
/// Auto grab new storage changes from the node
#[clap(long)]
#[arg(long)]
grab_storage_changes: bool,
/// Batch size for grabing storage changes
#[clap(long)]
#[clap(default_value_t = 1)]
#[arg(long, default_value_t = 1)]
grab_storage_changes_batch: BlockNumber,
/// The relaychain RPC endpoint
#[clap(long, default_value = "ws://localhost:9945")]
#[arg(long, default_value = "ws://localhost:9945")]
node_uri: String,
/// The parachain RPC endpoint
#[clap(long, default_value = "ws://localhost:9944")]
#[arg(long, default_value = "ws://localhost:9944")]
para_node_uri: String,
/// Interval that start a batch of grab
#[clap(long, default_value_t = 30)]
#[arg(long, default_value_t = 30)]
interval: u64,
/// Prefered minimum number of blocks between justification
#[arg(long, default_value_t = 1000)]
Expand All @@ -158,13 +157,13 @@ struct Serve {
#[arg(long)]
token: Option<String>,
/// The max batch size to check headers
#[clap(long, default_value_t = 100000)]
#[arg(long, default_value_t = 100000)]
check_batch: BlockNumber,
/// Don't check state root for each storage changes
#[clap(long)]
#[arg(long)]
no_state_root: bool,
/// Skip blocks with empty state root while checking storage changes
#[clap(long)]
#[arg(long)]
allow_empty_state_root: bool,
}

Expand Down
2 changes: 1 addition & 1 deletion standalone/justification-validate/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mod feed_pruntime;
mod validator;

#[derive(Parser)]
#[clap(about = "Validate justifications", version, author)]
#[command(about = "Validate justifications", version, author)]
pub struct Args {
/// The genesis.bin grabbed with headers-cache.
#[arg(long)]
Expand Down
29 changes: 26 additions & 3 deletions standalone/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ path = "bin/main.rs"
required-features = ["cli"]

[lib]
crate-type = ["cdylib", "rlib"]
# crate-type = ["cdylib", "rlib"]

[dependencies]
phala-node-rpc-ext = { path = "../../crates/phala-node-rpc-ext" }
Expand Down Expand Up @@ -60,6 +60,8 @@ sp-keystore = { git = "https://github.com/paritytech/polkadot-sdk.git", branch =
sp-consensus = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.5.0" }
sp-transaction-storage-proof = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.5.0" }
sp-io = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.5.0" }
sp-blockchain = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.5.0" }
sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.5.0" }

# client dependencies
sc-client-api = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.5.0" }
Expand All @@ -72,7 +74,7 @@ sc-network = { git = "https://github.com/paritytech/polkadot-sdk.git", branch =
sc-network-sync = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.5.0" }
sc-consensus-slots = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.5.0" }
sc-consensus-babe = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.5.0" }
grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.5.0", package = "sc-consensus-grandpa" }
sc-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.5.0" }
sc-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.5.0" }
sc-basic-authorship = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.5.0" }
sc-service = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.5.0" }
Expand All @@ -82,6 +84,14 @@ sc-authority-discovery = { git = "https://github.com/paritytech/polkadot-sdk.git
sc-sync-state-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.5.0" }
sc-sysinfo = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.5.0" }

# RPC
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.5.0" }
sc-consensus-babe-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.5.0" }
sc-consensus-grandpa-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.5.0" }
sc-rpc-api = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.5.0" }
substrate-frame-rpc-system = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.5.0" }


# frame dependencies
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.5.0" }
frame-system = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.5.0" }
Expand All @@ -91,7 +101,6 @@ pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk

# node-specific dependencies
node-runtime = { path = "../runtime", package = "phala-node-runtime" }
node-rpc = { path = "../rpc" }
node-primitives = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.5.0" }
node-executor = { path = "../executor" }

Expand All @@ -101,6 +110,20 @@ frame-benchmarking-cli = { git = "https://github.com/paritytech/polkadot-sdk.git
node-inspect = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.5.0", package = "staging-node-inspect", optional = true }
try-runtime-cli = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.5.0", optional = true }

# Frontier
fc-api = { workspace = true }
fc-consensus = { workspace = true }
fc-db = { workspace = true }
fc-mapping-sync = { workspace = true, features = ["sql"] }
fc-rpc = { workspace = true }
fc-rpc-core = { workspace = true }
fc-storage = { workspace = true }
fp-account = { workspace = true }
fp-dynamic-fee = { workspace = true, features = ["default"] }
fp-evm = { workspace = true, features = ["default"] }
fp-rpc = { workspace = true, features = ["default"] }
fc-cli = { workspace = true, features = ["default"] }

[dev-dependencies]
sc-keystore = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.5.0" }
sc-client-db = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.5.0" }
Expand Down
65 changes: 3 additions & 62 deletions standalone/node/build.rs
Original file line number Diff line number Diff line change
@@ -1,66 +1,7 @@
// This file is part of Substrate.

// Copyright (C) 2017-2022 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 substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed};

fn main() {
#[cfg(feature = "cli")]
cli::main();
}

#[cfg(feature = "cli")]
mod cli {
include!("src/cli.rs");

use clap::{CommandFactory, ValueEnum};
use clap_complete::{generate_to, Shell};
use std::{env, fs, path::Path};
use substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed};

pub fn main() {
build_shell_completion();
generate_cargo_keys();

rerun_if_git_head_changed();
}

/// Build shell completion scripts for all known shells
fn build_shell_completion() {
for shell in Shell::value_variants() {
build_completion(shell);
}
}

/// Build the shell auto-completion for a given Shell
fn build_completion(shell: &Shell) {
let outdir = match env::var_os("OUT_DIR") {
None => return,
Some(dir) => dir,
};
let path = Path::new(&outdir)
.parent()
.unwrap()
.parent()
.unwrap()
.parent()
.unwrap()
.join("completion-scripts");

fs::create_dir(&path).ok();
generate_cargo_keys();

let _ = generate_to(*shell, &mut Cli::command(), "phala-node", &path);
}
rerun_if_git_head_changed();
}
Loading
Loading