Skip to content

Commit

Permalink
Upgrade to v2.0.0-rc6 (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Forbes authored Aug 21, 2020
1 parent 8682ee4 commit c9fda53
Show file tree
Hide file tree
Showing 12 changed files with 1,387 additions and 786 deletions.
1,453 changes: 939 additions & 514 deletions Cargo.lock

Large diffs are not rendered by default.

14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ Substrate-based blockchain nodes expose a number of capabilities:
- Consensus: Blockchains must have a way to come to
[consensus](https://substrate.dev/docs/en/knowledgebase/advanced/consensus) on the state of the
network. Substrate makes it possible to supply custom consensus engines and also ships with
several consensus mechanisms that have been built on top of Web3 Foundation research.
several consensus mechanisms that have been built on top of
[Web3 Foundation research](https://research.web3.foundation/en/latest/polkadot/NPoS/index.html).
- RPC Server: A remote procedure call (RPC) server is used to interact with Substrate nodes.

There are several files in the `node` directory - take special note of the following:
Expand Down Expand Up @@ -104,12 +105,17 @@ capabilities and configuration parameters that it exposes:

### Runtime

The Substrate project in this repository uses the
[FRAME](https://substrate.dev/docs/en/knowledgebase/runtime/frame) framework to construct a
In Substrate, the terms
"[runtime](https://substrate.dev/docs/en/knowledgebase/getting-started/glossary#runtime)" and
"[state transition function](https://substrate.dev/docs/en/knowledgebase/getting-started/glossary#stf-state-transition-function)"
are analogous - they refer to the core logic of the blockchain that is responsible for validating
blocks and executing the state changes they define. The Substrate project in this repository uses
the [FRAME](https://substrate.dev/docs/en/knowledgebase/runtime/frame) framework to construct a
blockchain runtime. FRAME allows runtime developers to declare domain-specific logic in modules
called "pallets". At the heart of FRAME is a helpful
[macro language](https://substrate.dev/docs/en/knowledgebase/runtime/macros) that makes it easy to
create pallets and flexibly compose them to create blockchains that can address a variety of needs.
create pallets and flexibly compose them to create blockchains that can address
[a variety of needs](https://www.substrate.io/substrate-users/).

Review the [FRAME runtime implementation](./runtime/src/lib.rs) included in this template and note
the following:
Expand Down
112 changes: 74 additions & 38 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ homepage = 'https://substrate.dev'
license = 'Unlicense'
name = 'node-template'
repository = 'https://github.com/substrate-developer-hub/substrate-node-template/'
version = '2.0.0-rc5'
version = '2.0.0-rc6'

[package.metadata.docs.rs]
targets = ['x86_64-unknown-linux-gnu']
Expand All @@ -17,95 +17,131 @@ name = 'node-template'

[dependencies.node-template-runtime]
path = '../runtime'
version = '2.0.0-rc5'
version = '2.0.0-rc6'

[dependencies.pallet-transaction-payment-rpc]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '2.0.0-rc6'

[dependencies.sc-basic-authorship]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc5'
version = '0.8.0-rc5'
tag = 'v2.0.0-rc6'
version = '0.8.0-rc6'

[dependencies.sc-cli]
features = ['wasmtime']
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc5'
version = '0.8.0-rc5'
tag = 'v2.0.0-rc6'
version = '0.8.0-rc6'

[dependencies.sc-client-api]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc5'
version = '2.0.0-rc5'
tag = 'v2.0.0-rc6'
version = '2.0.0-rc6'

[dependencies.sc-consensus]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc5'
version = '0.8.0-rc5'
tag = 'v2.0.0-rc6'
version = '0.8.0-rc6'

[dependencies.sc-consensus-aura]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc5'
version = '0.8.0-rc5'
tag = 'v2.0.0-rc6'
version = '0.8.0-rc6'

[dependencies.sc-executor]
features = ['wasmtime']
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc5'
version = '0.8.0-rc5'
tag = 'v2.0.0-rc6'
version = '0.8.0-rc6'

[dependencies.sc-finality-grandpa]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc5'
version = '0.8.0-rc5'
tag = 'v2.0.0-rc6'
version = '0.8.0-rc6'

[dependencies.sc-rpc]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '2.0.0-rc6'

[dependencies.sc-rpc-api]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '0.8.0-rc6'

[dependencies.sc-service]
features = ['wasmtime']
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc5'
version = '0.8.0-rc5'
tag = 'v2.0.0-rc6'
version = '0.8.0-rc6'

[dependencies.sc-transaction-pool]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc5'
version = '2.0.0-rc5'
tag = 'v2.0.0-rc6'
version = '2.0.0-rc6'

[dependencies.sp-api]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '2.0.0-rc6'

[dependencies.sp-block-builder]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '2.0.0-rc6'

[dependencies.sp-blockchain]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '2.0.0-rc6'

[dependencies.sp-consensus]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc5'
version = '0.8.0-rc5'
tag = 'v2.0.0-rc6'
version = '0.8.0-rc6'

[dependencies.sp-consensus-aura]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc5'
version = '0.8.0-rc5'
tag = 'v2.0.0-rc6'
version = '0.8.0-rc6'

[dependencies.sp-core]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc5'
version = '2.0.0-rc5'
tag = 'v2.0.0-rc6'
version = '2.0.0-rc6'

[dependencies.sp-finality-grandpa]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc5'
version = '2.0.0-rc5'
tag = 'v2.0.0-rc6'
version = '2.0.0-rc6'

[dependencies.sp-inherents]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc5'
version = '2.0.0-rc5'
tag = 'v2.0.0-rc6'
version = '2.0.0-rc6'

[dependencies.sp-runtime]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc5'
version = '2.0.0-rc5'
tag = 'v2.0.0-rc6'
version = '2.0.0-rc6'

[dependencies.sp-transaction-pool]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc5'
version = '2.0.0-rc5'
tag = 'v2.0.0-rc6'
version = '2.0.0-rc6'

[dependencies.substrate-frame-rpc-system]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '2.0.0-rc6'

[dependencies.structopt]
version = '0.3.8'
[dependencies]
jsonrpc-core = '14.0.3'
structopt = '0.3.8'

[build-dependencies.substrate-build-script-utils]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc5'
version = '2.0.0-rc5'
tag = 'v2.0.0-rc6'
version = '2.0.0-rc6'
10 changes: 5 additions & 5 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,22 @@ fn testnet_genesis(
_enable_println: bool,
) -> GenesisConfig {
GenesisConfig {
system: Some(SystemConfig {
frame_system: Some(SystemConfig {
// Add Wasm runtime to storage.
code: wasm_binary.to_vec(),
changes_trie_config: Default::default(),
}),
balances: Some(BalancesConfig {
pallet_balances: Some(BalancesConfig {
// Configure endowed accounts with initial balance of 1 << 60.
balances: endowed_accounts.iter().cloned().map(|k|(k, 1 << 60)).collect(),
}),
aura: Some(AuraConfig {
pallet_aura: Some(AuraConfig {
authorities: initial_authorities.iter().map(|x| (x.0.clone())).collect(),
}),
grandpa: Some(GrandpaConfig {
pallet_grandpa: Some(GrandpaConfig {
authorities: initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect(),
}),
sudo: Some(SudoConfig {
pallet_sudo: Some(SudoConfig {
// Assign network admin rights.
key: root_key,
}),
Expand Down
12 changes: 6 additions & 6 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use crate::chain_spec;
use crate::cli::Cli;
use crate::service;
use sc_cli::{SubstrateCli, RuntimeVersion, Role, ChainSpec};
use sc_service::ServiceParams;
use crate::service::new_full_params;
use sc_service::PartialComponents;
use crate::service::new_partial;

impl SubstrateCli for Cli {
fn impl_name() -> String {
Expand Down Expand Up @@ -66,12 +66,12 @@ impl SubstrateCli for Cli {
pub fn run() -> sc_cli::Result<()> {
let cli = Cli::from_args();

match &cli.subcommand {
Some(subcommand) => {
match cli.subcommand {
Some(ref subcommand) => {
let runner = cli.create_runner(subcommand)?;
runner.run_subcommand(subcommand, |config| {
let (ServiceParams { client, backend, task_manager, import_queue, .. }, ..)
= new_full_params(config)?;
let PartialComponents { client, backend, task_manager, import_queue, .. }
= new_partial(&config)?;
Ok((client, backend, import_queue, task_manager))
})
}
Expand Down
1 change: 1 addition & 0 deletions node/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pub mod chain_spec;
pub mod service;
pub mod rpc;
1 change: 1 addition & 0 deletions node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ mod chain_spec;
mod service;
mod cli;
mod command;
mod rpc;

fn main() -> sc_cli::Result<()> {
command::run()
Expand Down
64 changes: 64 additions & 0 deletions node/src/rpc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//! A collection of node-specific RPC methods.
//! Substrate provides the `sc-rpc` crate, which defines the core RPC layer
//! used by Substrate nodes. This file extends those RPC definitions with
//! capabilities that are specific to this project's runtime configuration.
#![warn(missing_docs)]

use std::sync::Arc;

use node_template_runtime::{opaque::Block, AccountId, Balance, Index};
use sp_api::ProvideRuntimeApi;
use sp_blockchain::{Error as BlockChainError, HeaderMetadata, HeaderBackend};
use sp_block_builder::BlockBuilder;
pub use sc_rpc_api::DenyUnsafe;
use sp_transaction_pool::TransactionPool;


/// Full client dependencies.
pub struct FullDeps<C, P> {
/// The client instance to use.
pub client: Arc<C>,
/// Transaction pool instance.
pub pool: Arc<P>,
/// Whether to deny unsafe calls
pub deny_unsafe: DenyUnsafe,
}

/// Instantiate all full RPC extensions.
pub fn create_full<C, P>(
deps: FullDeps<C, P>,
) -> jsonrpc_core::IoHandler<sc_rpc::Metadata> where
C: ProvideRuntimeApi<Block>,
C: HeaderBackend<Block> + HeaderMetadata<Block, Error=BlockChainError> + 'static,
C: Send + Sync + 'static,
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
C::Api: BlockBuilder<Block>,
P: TransactionPool + 'static,
{
use substrate_frame_rpc_system::{FullSystem, SystemApi};
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};

let mut io = jsonrpc_core::IoHandler::default();
let FullDeps {
client,
pool,
deny_unsafe,
} = deps;

io.extend_with(
SystemApi::to_delegate(FullSystem::new(client.clone(), pool, deny_unsafe))
);

io.extend_with(
TransactionPaymentApi::to_delegate(TransactionPayment::new(client.clone()))
);

// Extend this RPC with a custom API by using the following syntax.
// `YourRpcStruct` should have a reference to a client, which is needed
// to call into the runtime.
// `io.extend_with(YourRpcTrait::to_delegate(YourRpcStruct::new(ReferenceToClient, ...)));`

io
}
Loading

0 comments on commit c9fda53

Please sign in to comment.