Skip to content

Commit

Permalink
Merge pull request #1 from gleb-urvanov/feature/substrate2-migration
Browse files Browse the repository at this point in the history
Feature/substrate2 migration
  • Loading branch information
gleb-urvanov committed Oct 8, 2020
2 parents 56b0f9e + a30f34c commit 41944df
Show file tree
Hide file tree
Showing 14 changed files with 1,567 additions and 1,009 deletions.
1,167 changes: 628 additions & 539 deletions Cargo.lock

Large diffs are not rendered by default.

176 changes: 40 additions & 136 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,148 +7,52 @@ homepage = 'https://substrate.dev'
license = 'Unlicense'
name = 'node-template'
repository = 'https://github.com/substrate-developer-hub/substrate-node-template/'
version = '2.0.0-rc6'

[package.metadata.docs.rs]
targets = ['x86_64-unknown-linux-gnu']
version = '2.0.0'

[[bin]]
name = 'node-template'

[dependencies.node-template-runtime]
path = '../runtime'
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-rc6'
version = '0.8.0-rc6'

[dependencies.sc-cli]
features = ['wasmtime']
git = 'https://github.com/paritytech/substrate.git'
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-rc6'
version = '2.0.0-rc6'

[dependencies.sc-consensus]
git = 'https://github.com/paritytech/substrate.git'
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-rc6'
version = '0.8.0-rc6'

[dependencies.sc-executor]
features = ['wasmtime']
git = 'https://github.com/paritytech/substrate.git'
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-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-rc6'
version = '0.8.0-rc6'

[dependencies.sc-transaction-pool]
git = 'https://github.com/paritytech/substrate.git'
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-rc6'
version = '0.8.0-rc6'

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

[dependencies.sp-core]
git = 'https://github.com/paritytech/substrate.git'
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-rc6'
version = '2.0.0-rc6'

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

[dependencies.sp-runtime]
git = 'https://github.com/paritytech/substrate.git'
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-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'
[package.metadata.docs.rs]
targets = ['x86_64-unknown-linux-gnu']

[dependencies.generic-asset]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'pallet-generic-asset'
tag = 'v2.0.0-rc6'
version = '2.0.0-rc6'
[build-dependencies]
substrate-build-script-utils = '2.0.0'

[dependencies]
jsonrpc-core = '14.0.3'
jsonrpc-core = '15.0.0'
structopt = '0.3.8'

[build-dependencies.substrate-build-script-utils]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '2.0.0-rc6'
# local dependencies
node-template-runtime = { path = '../runtime', version = '2.0.0' }

# Substrate dependencies
frame-benchmarking = '2.0.0'
frame-benchmarking-cli = '2.0.0'
pallet-transaction-payment-rpc = '2.0.0'
sc-basic-authorship = '0.8.0'
sc-cli = { features = ['wasmtime'], version = '0.8.0' }
sc-client-api = '2.0.0'
sc-consensus = '0.8.0'
sc-consensus-aura = '0.8.0'
sc-executor = { features = ['wasmtime'], version = '0.8.0' }
sc-finality-grandpa = '0.8.0'
sc-rpc = '2.0.0'
sc-rpc-api = '0.8.0'
sc-service = { features = ['wasmtime'], version = '0.8.0' }
sc-transaction-pool = '2.0.0'
sp-api = '2.0.0'
sp-block-builder = '2.0.0'
sp-blockchain = '2.0.0'
sp-consensus = '0.8.0'
sp-consensus-aura = '0.8.0'
sp-core = '2.0.0'
sp-finality-grandpa = '2.0.0'
sp-inherents = '2.0.0'
sp-runtime = '2.0.0'
sp-transaction-pool = '2.0.0'
substrate-frame-rpc-system = '2.0.0'
pallet-assets = { default-features = false, version = '2.0.0' }

[features]
default = []
runtime-benchmarks = ['node-template-runtime/runtime-benchmarks']
30 changes: 29 additions & 1 deletion node/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use sc_cli::{RunCmd, Subcommand};
use structopt::StructOpt;
use sc_cli::RunCmd;

#[derive(Debug, StructOpt)]
pub struct Cli {
Expand All @@ -9,3 +9,31 @@ pub struct Cli {
#[structopt(flatten)]
pub run: RunCmd,
}

#[derive(Debug, StructOpt)]
pub enum Subcommand {
/// Build a chain specification.
BuildSpec(sc_cli::BuildSpecCmd),

/// Validate blocks.
CheckBlock(sc_cli::CheckBlockCmd),

/// Export blocks.
ExportBlocks(sc_cli::ExportBlocksCmd),

/// Export the state of a given block into a chain spec.
ExportState(sc_cli::ExportStateCmd),

/// Import blocks.
ImportBlocks(sc_cli::ImportBlocksCmd),

/// Remove the whole chain.
PurgeChain(sc_cli::PurgeChainCmd),

/// Revert the chain to a previous state.
Revert(sc_cli::RevertCmd),

/// The custom benchmark subcommmand benchmarking runtime pallets.
#[structopt(name = "benchmark", about = "Benchmark runtime pallets.")]
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
}
73 changes: 61 additions & 12 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::chain_spec;
use crate::cli::Cli;
use crate::service;
use crate::{chain_spec, service};
use crate::cli::{Cli, Subcommand};
use sc_cli::{SubstrateCli, RuntimeVersion, Role, ChainSpec};
use sc_service::PartialComponents;
use crate::service::new_partial;
use node_template_runtime::Block;

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

match cli.subcommand {
Some(ref subcommand) => {
let runner = cli.create_runner(subcommand)?;
runner.run_subcommand(subcommand, |config| {
let PartialComponents { client, backend, task_manager, import_queue, .. }
= new_partial(&config)?;
Ok((client, backend, import_queue, task_manager))
match &cli.subcommand {
Some(Subcommand::BuildSpec(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
},
Some(Subcommand::CheckBlock(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents { client, task_manager, import_queue, ..}
= service::new_partial(&config)?;
Ok((cmd.run(client, import_queue), task_manager))
})
}
},
Some(Subcommand::ExportBlocks(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents { client, task_manager, ..}
= service::new_partial(&config)?;
Ok((cmd.run(client, config.database), task_manager))
})
},
Some(Subcommand::ExportState(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents { client, task_manager, ..}
= service::new_partial(&config)?;
Ok((cmd.run(client, config.chain_spec), task_manager))
})
},
Some(Subcommand::ImportBlocks(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents { client, task_manager, import_queue, ..}
= service::new_partial(&config)?;
Ok((cmd.run(client, import_queue), task_manager))
})
},
Some(Subcommand::PurgeChain(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| cmd.run(config.database))
},
Some(Subcommand::Revert(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents { client, task_manager, backend, ..}
= service::new_partial(&config)?;
Ok((cmd.run(client, backend), task_manager))
})
},
Some(Subcommand::Benchmark(cmd)) => {
if cfg!(feature = "runtime-benchmarks") {
let runner = cli.create_runner(cmd)?;

runner.sync_run(|config| cmd.run::<Block, service::Executor>(config))
} else {
Err("Benchmarking wasn't enabled when building the node. \
You can enable it with `--features runtime-benchmarks`.".into())
}
},
None => {
let runner = cli.create_runner(&cli.run)?;
runner.run_node_until_exit(|config| match config.role {
Expand Down
1 change: 1 addition & 0 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ native_executor_instance!(
pub Executor,
node_template_runtime::api::dispatch,
node_template_runtime::native_version,
frame_benchmarking::benchmarking::HostFunctions,
);

type FullClient = sc_service::TFullClient<Block, RuntimeApi, Executor>;
Expand Down
38 changes: 38 additions & 0 deletions pallets/assets/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[package]
name = "pallet-assets"
version = "2.0.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
license = "Apache-2.0"
homepage = "https://substrate.dev"
repository = "https://github.com/paritytech/substrate/"
description = "FRAME asset management pallet"
readme = "README.md"

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

[dependencies]
serde = { version = "1.0.101", optional = true }
codec = { package = "parity-scale-codec", version = "1.3.4", default-features = false }
# Needed for various traits. In our case, `OnFinalize`.
sp-runtime = { default-features = false, version = '2.0.0' }
# Needed for type-safe access to storage DB.
frame-support = { default-features = false, version = '2.0.0' }
# `system` module provides us with all sorts of useful stuff and macros depend on it being around.
frame-system = { default-features = false, version = '2.0.0' }

[dev-dependencies]
sp-core = { default-features = false, version = '2.0.0' }
sp-std = { default-features = false, version = '2.0.0' }
sp-io = { default-features = false, version = '2.0.0' }

[features]
default = ["std"]
std = [
"serde",
"codec/std",
"sp-runtime/std",
"frame-support/std",
"frame-system/std",
]
Loading

0 comments on commit 41944df

Please sign in to comment.