Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

Commit

Permalink
Support EVM and Frontier (#245)
Browse files Browse the repository at this point in the history
* bump: substrate

* companion: #6864

* companion: #6720

* companion: #6873

* companion: #5732

* fix: missing field

* update: dependencies
  • Loading branch information
aurexav authored Aug 19, 2020
1 parent 94aa102 commit 5ad59a5
Show file tree
Hide file tree
Showing 28 changed files with 481 additions and 361 deletions.
405 changes: 253 additions & 152 deletions Cargo.lock

Large diffs are not rendered by default.

87 changes: 44 additions & 43 deletions bin/node-template/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ name = "node-template"
# anonymous
node-template-runtime = { path = "../runtime" }
# crates
codec = { package = "parity-scale-codec", version = "1.3.4" }
futures = { version = "0.3.5" }
jsonrpc-core = { version = "14.2.0" }
log = { version = "0.4.11" }
structopt = { version = "0.3.16" }
tokio = { version = "0.2.22", optional = true, features = ["rt-threaded"] }
codec = { package = "parity-scale-codec", version = "1.3.4" }
futures = { version = "0.3.5" }
jsonrpc-core = { version = "14.2.0" }
jsonrpc-pubsub = { version = "14.2.0" }
log = { version = "0.4.11" }
structopt = { version = "0.3.16" }
tokio = { version = "0.2.22", optional = true, features = ["rt-threaded"] }
# darwinia
darwinia-balances-rpc = { path = "../../../frame/balances/rpc" }
darwinia-balances-rpc-runtime-api = { path = "../../../frame/balances/rpc/runtime-api" }
Expand All @@ -35,46 +36,46 @@ darwinia-staking = { path = "../../../frame/staking" }
darwinia-staking-rpc = { path = "../../../frame/staking/rpc" }
darwinia-staking-rpc-runtime-api = { path = "../../../frame/staking/rpc/runtime-api" }
# substrate
frame-system-rpc-runtime-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
pallet-im-online = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
pallet-transaction-payment-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
sc-basic-authorship = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
sc-cli = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
sc-client-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
sc-consensus = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
sc-consensus-babe = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
sc-consensus-babe-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
sc-consensus-epochs = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
sc-executor = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
sc-finality-grandpa = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
sc-finality-grandpa-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
sc-keystore = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
sc-network = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
sc-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
sc-rpc-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
sc-service = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
sc-transaction-pool = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
sp-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
sp-authority-discovery = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
sp-block-builder = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
sp-blockchain = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
sp-consensus = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
sp-consensus-babe = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
sp-finality-grandpa = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
sp-inherents = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
sp-offchain = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
sp-runtime = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
sp-session = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
sp-transaction-pool = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
sp-trie = { features = ["memory-tracker"], git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
substrate-frame-rpc-system = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
substrate-prometheus-endpoint = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
frame-system-rpc-runtime-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
pallet-im-online = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
pallet-transaction-payment-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
sc-basic-authorship = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
sc-cli = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
sc-client-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
sc-consensus = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
sc-consensus-babe = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
sc-consensus-babe-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
sc-consensus-epochs = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
sc-executor = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
sc-finality-grandpa = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
sc-finality-grandpa-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
sc-keystore = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
sc-network = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
sc-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
sc-rpc-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
sc-service = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
sc-transaction-pool = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
sp-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
sp-authority-discovery = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
sp-block-builder = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
sp-blockchain = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
sp-consensus = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
sp-consensus-babe = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
sp-finality-grandpa = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
sp-inherents = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
sp-offchain = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
sp-runtime = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
sp-session = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
sp-transaction-pool = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
sp-trie = { features = ["memory-tracker"], git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
substrate-frame-rpc-system = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }
substrate-prometheus-endpoint = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }

[build-dependencies]
# substrate
substrate-build-script-utils = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc5" }
substrate-build-script-utils = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-darwinia-rc6" }

[features]
default = [
Expand Down
14 changes: 13 additions & 1 deletion bin/node-template/node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#![warn(missing_docs)]

// --- substrate ---
pub use jsonrpc_pubsub::manager::SubscriptionManager;
pub use sc_rpc_api::DenyUnsafe;

// --- std ---
Expand Down Expand Up @@ -46,6 +47,10 @@ pub struct GrandpaDeps {
pub shared_voter_state: sc_finality_grandpa::SharedVoterState,
/// Authority set info.
pub shared_authority_set: sc_finality_grandpa::SharedAuthoritySet<Hash, BlockNumber>,
/// Receives notifications about justification events from Grandpa.
pub justification_stream: sc_finality_grandpa::GrandpaJustificationStream<Block>,
/// Subscription manager to keep track of pubsub subscribers.
pub subscriptions: jsonrpc_pubsub::manager::SubscriptionManager,
}

/// Full client dependencies.
Expand Down Expand Up @@ -140,9 +145,16 @@ where
let GrandpaDeps {
shared_voter_state,
shared_authority_set,
justification_stream,
subscriptions,
} = grandpa;
io.extend_with(sc_finality_grandpa_rpc::GrandpaApi::to_delegate(
GrandpaRpcHandler::new(shared_authority_set, shared_voter_state),
GrandpaRpcHandler::new(
shared_authority_set,
shared_voter_state,
justification_stream,
subscriptions,
),
));
}
io.extend_with(BalancesApi::to_delegate(Balances::new(client.clone())));
Expand Down
11 changes: 8 additions & 3 deletions bin/node-template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ use sp_runtime::traits::BlakeTwo256;
use sp_trie::PrefixedMemoryDB;
use substrate_prometheus_endpoint::Registry;
// --- darwinia ---
use crate::rpc::{self, BabeDeps, DenyUnsafe, FullDeps, GrandpaDeps, LightDeps, RpcExtension};
use crate::rpc::{
self, BabeDeps, DenyUnsafe, FullDeps, GrandpaDeps, LightDeps, RpcExtension, SubscriptionManager,
};
use node_template_runtime::{
opaque::Block,
primitives::{AccountId, Balance, Hash, Nonce, Power},
Expand Down Expand Up @@ -147,7 +149,7 @@ fn new_partial<RuntimeApi, Executor>(
DefaultImportQueue<Block, FullClient<RuntimeApi, Executor>>,
FullPool<Block, FullClient<RuntimeApi, Executor>>,
(
impl Fn(DenyUnsafe) -> RpcExtension,
impl Fn(DenyUnsafe, SubscriptionManager) -> RpcExtension,
(
BabeBlockImport<
Block,
Expand Down Expand Up @@ -207,6 +209,7 @@ where
&task_manager.spawn_handle(),
config.prometheus_registry(),
)?;
let justification_stream = grandpa_link.justification_stream();
let shared_authority_set = grandpa_link.shared_authority_set().clone();
let shared_voter_state = GrandpaSharedVoterState::empty();
let import_setup = (babe_import.clone(), grandpa_link, babe_link.clone());
Expand All @@ -219,7 +222,7 @@ where
let transaction_pool = transaction_pool.clone();
let select_chain = select_chain.clone();

move |deny_unsafe| -> RpcExtension {
move |deny_unsafe, subscriptions| -> RpcExtension {
let deps = FullDeps {
client: client.clone(),
pool: transaction_pool.clone(),
Expand All @@ -233,6 +236,8 @@ where
grandpa: GrandpaDeps {
shared_voter_state: shared_voter_state.clone(),
shared_authority_set: shared_authority_set.clone(),
justification_stream: justification_stream.clone(),
subscriptions,
},
};

Expand Down
Loading

0 comments on commit 5ad59a5

Please sign in to comment.