Update to `d1cd01c7`

main
Joshy Orndorff 2019-12-16 15:46:39 -05:00
parent 43ee95347b
commit 25c494b81d
No known key found for this signature in database
GPG Key ID: 4656E06A96D0CF3A
10 changed files with 3061 additions and 2657 deletions

4996
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,43 +1,13 @@
[[bin]]
name = 'node-template'
path = 'src/main.rs'
[package]
authors = ['Anonymous']
build = 'build.rs'
edition = '2018'
name = 'node-template'
version = '2.0.0'
[build-dependencies]
vergen = '3.0.4'
[profile.release]
panic = 'unwind'
[workspace]
members = ['runtime']
[dependencies]
derive_more = '0.15.0'
exit-future = '0.1.4'
futures = '0.1.29'
futures = '0.3.1'
log = '0.4.8'
parking_lot = '0.9.0'
tokio = '0.1.22'
trie-root = '0.15.2'
[dependencies.aura]
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-consensus-aura'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
[dependencies.aura-primitives]
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-consensus-aura-primitives'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
[dependencies.basic-authorship]
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-basic-authorship'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
[dependencies.codec]
package = 'parity-scale-codec'
version = '1.0.0'
@ -46,58 +16,100 @@ version = '1.0.0'
features = ['termination']
version = '3.1.3'
[dependencies.futures01]
package = 'futures'
version = '0.1.29'
[dependencies.grandpa]
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-finality-grandpa'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
package = 'sc-finality-grandpa'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.grandpa-primitives]
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-finality-grandpa-primitives'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
[dependencies.inherents]
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-inherents'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
[dependencies.network]
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-network'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
package = 'sp-finality-grandpa'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.node-template-runtime]
path = 'runtime'
[dependencies.primitives]
[dependencies.sc-basic-authority]
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-primitives'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.sr-io]
[dependencies.sc-cli]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.substrate-cli]
[dependencies.sc-client]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.substrate-client]
[dependencies.sc-consensus-aura]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.substrate-executor]
[dependencies.sc-executor]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.substrate-service]
[dependencies.sc-network]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.transaction-pool]
[dependencies.sc-service]
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-transaction-pool'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[workspace]
members = ['runtime']
[dependencies.sc-transaction-pool]
git = 'https://github.com/paritytech/substrate.git'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.sp-consensus]
git = 'https://github.com/paritytech/substrate.git'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.sp-consensus-aura]
git = 'https://github.com/paritytech/substrate.git'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.sp-core]
git = 'https://github.com/paritytech/substrate.git'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.sp-inherents]
git = 'https://github.com/paritytech/substrate.git'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.sp-io]
git = 'https://github.com/paritytech/substrate.git'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.sp-runtime]
git = 'https://github.com/paritytech/substrate.git'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.sp-transaction-pool]
git = 'https://github.com/paritytech/substrate.git'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[package]
authors = ['Anonymous']
build = 'build.rs'
edition = '2018'
name = 'node-template'
version = '2.0.0'
[[bin]]
name = 'node-template'
path = 'src/main.rs'
[profile.release]
panic = 'unwind'
[build-dependencies]
vergen = '3.0.4'
[build-dependencies.build-script-utils]
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-build-script-utils'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'

View File

@ -1,5 +1,3 @@
use std::{env, path::PathBuf};
use vergen::{ConstantsFlags, generate_cargo_keys};
const ERROR_MSG: &str = "Failed to generate metadata files";
@ -7,18 +5,5 @@ const ERROR_MSG: &str = "Failed to generate metadata files";
fn main() {
generate_cargo_keys(ConstantsFlags::SHA_SHORT).expect(ERROR_MSG);
let mut manifest_dir = PathBuf::from(
env::var("CARGO_MANIFEST_DIR").expect("`CARGO_MANIFEST_DIR` is always set by cargo.")
);
while manifest_dir.parent().is_some() {
if manifest_dir.join(".git/HEAD").exists() {
println!("cargo:rerun-if-changed={}", manifest_dir.join(".git/HEAD").display());
return
}
manifest_dir.pop();
}
println!("cargo:warning=Could not find `.git/HEAD` from manifest dir!");
build_script_utils::rerun_if_git_head_changed();
}

View File

@ -3,60 +3,53 @@ authors = ['Anonymous']
edition = '2018'
name = 'node-template-runtime'
version = '2.0.0'
[build-dependencies.wasm-builder-runner]
package = 'substrate-wasm-builder-runner'
version = '1.0.2'
[features]
default = ['std']
std = [
'codec/std',
'client/std',
'rstd/std',
'runtime-io/std',
'support/std',
'balances/std',
'aura/std',
'aura-primitives/std',
'balances/std',
'codec/std',
'frame-executive/std',
'frame-support/std',
'grandpa/std',
'executive/std',
'indices/std',
'primitives/std',
'sr-primitives/std',
'randomness-collective-flip/std',
'safe-mix/std',
'serde',
'sp-api/std',
'sp-block-builder/std',
'sp-consensus-aura/std',
'sp-core/std',
'sp-inherents/std',
'sp-io/std',
'sp-offchain/std',
'sp-runtime/std',
'sp-session/std',
'sp-std/std',
'sp-transaction-pool/std',
'sp-version/std',
'sudo/std',
'system/std',
'timestamp/std',
'sudo/std',
'transaction-payment/std',
'version/std',
'serde',
'safe-mix/std',
'offchain-primitives/std',
'substrate-session/std',
]
[build-dependencies.wasm-builder-runner]
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-wasm-builder-runner'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
version = '1.0.4'
[dependencies.aura]
default_features = false
default-features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-aura'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
[dependencies.aura-primitives]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-consensus-aura-primitives'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
package = 'pallet-aura'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.balances]
default_features = false
default-features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-balances'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
[dependencies.client]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-client'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
package = 'pallet-balances'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.codec]
default-features = false
@ -64,53 +57,33 @@ features = ['derive']
package = 'parity-scale-codec'
version = '1.0.0'
[dependencies.executive]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-executive'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
[dependencies.grandpa]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-grandpa'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
[dependencies.indices]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-indices'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
[dependencies.offchain-primitives]
[dependencies.frame-executive]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-offchain-primitives'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.primitives]
default_features = false
[dependencies.frame-support]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-primitives'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.grandpa]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'pallet-grandpa'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.indices]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'pallet-indices'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.randomness-collective-flip]
default_features = false
default-features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-randomness-collective-flip'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
[dependencies.rstd]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'sr-std'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
[dependencies.runtime-io]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'sr-io'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
package = 'pallet-randomness-collective-flip'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.safe-mix]
default-features = false
@ -121,48 +94,86 @@ features = ['derive']
optional = true
version = '1.0.101'
[dependencies.sr-primitives]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
[dependencies.substrate-session]
[dependencies.sp-api]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.sp-block-builder]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.sp-consensus-aura]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.sp-core]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.sp-inherents]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.sp-io]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.sp-offchain]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.sp-runtime]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.sp-session]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.sp-std]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.sp-transaction-pool]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.sp-version]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.sudo]
default_features = false
default-features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-sudo'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
[dependencies.support]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-support'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
package = 'pallet-sudo'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.system]
default_features = false
default-features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-system'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
package = 'frame-system'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.timestamp]
default_features = false
default-features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-timestamp'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
package = 'pallet-timestamp'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'
[dependencies.transaction-payment]
default_features = false
default-features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-transaction-payment'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
[dependencies.version]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'sr-version'
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
package = 'pallet-transaction-payment'
rev = '40a16efefc070faf5a25442bc3ae1d0ea2478eee'

View File

@ -8,42 +8,44 @@
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
use rstd::prelude::*;
use primitives::{OpaqueMetadata, crypto::key_types};
use sr_primitives::{
ApplyResult, transaction_validity::TransactionValidity, generic, create_runtime_str,
impl_opaque_keys, AnySignature
use sp_std::prelude::*;
use sp_core::OpaqueMetadata;
use sp_runtime::{
ApplyExtrinsicResult, transaction_validity::TransactionValidity, generic, create_runtime_str,
impl_opaque_keys, MultiSignature
};
use sr_primitives::traits::{NumberFor, BlakeTwo256, Block as BlockT, StaticLookup, Verify, ConvertInto};
use sr_primitives::weights::Weight;
use client::{
block_builder::api::{CheckInherentsResult, InherentData, self as block_builder_api},
runtime_api as client_api, impl_runtime_apis
use sp_runtime::traits::{
NumberFor, BlakeTwo256, Block as BlockT, StaticLookup, Verify, ConvertInto, IdentifyAccount
};
use aura_primitives::sr25519::AuthorityId as AuraId;
use grandpa::{AuthorityId as GrandpaId, AuthorityWeight as GrandpaWeight};
use sp_api::impl_runtime_apis;
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use grandpa::AuthorityList as GrandpaAuthorityList;
use grandpa::fg_primitives;
use version::RuntimeVersion;
use sp_version::RuntimeVersion;
#[cfg(feature = "std")]
use version::NativeVersion;
use sp_version::NativeVersion;
// A few exports that help ease life for downstream crates.
#[cfg(any(feature = "std", test))]
pub use sr_primitives::BuildStorage;
pub use sp_runtime::BuildStorage;
pub use timestamp::Call as TimestampCall;
pub use balances::Call as BalancesCall;
pub use sr_primitives::{Permill, Perbill};
pub use support::{StorageValue, construct_runtime, parameter_types, traits::Randomness};
pub use sp_runtime::{Permill, Perbill};
pub use frame_support::{
StorageValue, construct_runtime, parameter_types,
traits::Randomness,
weights::Weight,
};
/// An index to a block.
pub type BlockNumber = u32;
/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.
pub type Signature = AnySignature;
pub type Signature = MultiSignature;
/// Some way of identifying an account on the chain. We intentionally make it equivalent
/// to the public key of our transaction signing scheme.
pub type AccountId = <Signature as Verify>::Signer;
pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;
/// The type for looking up accounts. We don't expect more than 4 billion of them, but you
/// never know...
@ -56,7 +58,7 @@ pub type Balance = u128;
pub type Index = u32;
/// A hash of some data used by the chain.
pub type Hash = primitives::H256;
pub type Hash = sp_core::H256;
/// Digest item type.
pub type DigestItem = generic::DigestItem<Hash>;
@ -71,7 +73,7 @@ mod template;
pub mod opaque {
use super::*;
pub use sr_primitives::OpaqueExtrinsic as UncheckedExtrinsic;
pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;
/// Opaque block header type.
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
@ -82,10 +84,8 @@ pub mod opaque {
impl_opaque_keys! {
pub struct SessionKeys {
#[id(key_types::AURA)]
pub aura: AuraId,
#[id(key_types::GRANDPA)]
pub grandpa: GrandpaId,
pub aura: Aura,
pub grandpa: Grandpa,
}
}
}
@ -94,9 +94,9 @@ pub mod opaque {
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("node-template"),
impl_name: create_runtime_str!("node-template"),
authoring_version: 3,
spec_version: 4,
impl_version: 4,
authoring_version: 1,
spec_version: 1,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
};
@ -104,16 +104,11 @@ pub const MILLISECS_PER_BLOCK: u64 = 6000;
pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;
pub const EPOCH_DURATION_IN_BLOCKS: u32 = 10 * MINUTES;
// These time units are defined in number of blocks.
pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
pub const HOURS: BlockNumber = MINUTES * 60;
pub const DAYS: BlockNumber = HOURS * 24;
// 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks.
pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
/// The version infromation used to identify this runtime when compiled natively.
#[cfg(feature = "std")]
pub fn native_version() -> NativeVersion {
@ -175,7 +170,7 @@ impl grandpa::Trait for Runtime {
impl indices::Trait for Runtime {
/// The type for recording indexing into the account enumeration. If this ever overflows, there
/// will be problems!
type AccountIndex = u32;
type AccountIndex = AccountIndex;
/// Use the standard means of resolving an index hint from an id.
type ResolveHint = indices::SimpleResolveHint<Self::AccountId, Self::AccountIndex>;
/// Determine whether an account is dead.
@ -251,7 +246,7 @@ construct_runtime!(
Timestamp: timestamp::{Module, Call, Storage, Inherent},
Aura: aura::{Module, Config<T>, Inherent(Timestamp)},
Grandpa: grandpa::{Module, Call, Storage, Config, Event},
Indices: indices::{default, Config<T>},
Indices: indices,
Balances: balances::{default, Error},
TransactionPayment: transaction_payment::{Module, Storage},
Sudo: sudo,
@ -285,10 +280,10 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signatu
/// Extrinsic type that has already been checked.
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;
/// Executive: handles dispatch to the various modules.
pub type Executive = executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;
pub type Executive = frame_executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;
impl_runtime_apis! {
impl client_api::Core<Block> for Runtime {
impl sp_api::Core<Block> for Runtime {
fn version() -> RuntimeVersion {
VERSION
}
@ -302,14 +297,14 @@ impl_runtime_apis! {
}
}
impl client_api::Metadata<Block> for Runtime {
impl sp_api::Metadata<Block> for Runtime {
fn metadata() -> OpaqueMetadata {
Runtime::metadata().into()
}
}
impl block_builder_api::BlockBuilder<Block> for Runtime {
fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyResult {
impl sp_block_builder::BlockBuilder<Block> for Runtime {
fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
Executive::apply_extrinsic(extrinsic)
}
@ -317,11 +312,14 @@ impl_runtime_apis! {
Executive::finalize_block()
}
fn inherent_extrinsics(data: InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
data.create_extrinsics()
}
fn check_inherents(block: Block, data: InherentData) -> CheckInherentsResult {
fn check_inherents(
block: Block,
data: sp_inherents::InherentData,
) -> sp_inherents::CheckInherentsResult {
data.check_extrinsics(&block)
}
@ -330,37 +328,36 @@ impl_runtime_apis! {
}
}
impl client_api::TaggedTransactionQueue<Block> for Runtime {
impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
fn validate_transaction(tx: <Block as BlockT>::Extrinsic) -> TransactionValidity {
Executive::validate_transaction(tx)
}
}
impl offchain_primitives::OffchainWorkerApi<Block> for Runtime {
impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
fn offchain_worker(number: NumberFor<Block>) {
Executive::offchain_worker(number)
}
}
impl aura_primitives::AuraApi<Block, AuraId> for Runtime {
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
fn slot_duration() -> u64 {
Aura::slot_duration()
}
fn authorities() -> Vec<AuraId> {
Aura::authorities()
}
}
impl substrate_session::SessionKeys<Block> for Runtime {
impl sp_session::SessionKeys<Block> for Runtime {
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
let seed = seed.as_ref().map(|s| rstd::str::from_utf8(&s).expect("Seed is an utf8 string"));
opaque::SessionKeys::generate(seed)
}
}
impl fg_primitives::GrandpaApi<Block> for Runtime {
fn grandpa_authorities() -> Vec<(GrandpaId, GrandpaWeight)> {
fn grandpa_authorities() -> GrandpaAuthorityList {
Grandpa::grandpa_authorities()
}
}

View File

@ -6,9 +6,9 @@
/// For more guidance on Substrate modules, see the example module
/// https://github.com/paritytech/substrate/blob/master/srml/example/src/lib.rs
/// https://github.com/paritytech/substrate/blob/master/frame/example/src/lib.rs
use support::{decl_module, decl_storage, decl_event, dispatch::Result};
use frame_support::{decl_module, decl_storage, decl_event, dispatch};
use system::ensure_signed;
/// The module's configuration trait.
@ -24,8 +24,8 @@ decl_storage! {
trait Store for Module<T: Trait> as TemplateModule {
// Just a dummy storage item.
// Here we are declaring a StorageValue, `Something` as a Option<u32>
// `get(something)` is the default getter which returns either the stored `u32` or `None` if nothing stored
Something get(something): Option<u32>;
// `get(fn something)` is the default getter which returns either the stored `u32` or `None` if nothing stored
Something get(fn something): Option<u32>;
}
}
@ -40,7 +40,7 @@ decl_module! {
// Just a dummy entry point.
// function that can be called by the external world as an extrinsics call
// takes a parameter of the type `AccountId`, stores it and emits an event
pub fn do_something(origin, something: u32) -> Result {
pub fn do_something(origin, something: u32) -> dispatch::Result {
// TODO: You only need this if you want to check it was signed.
let who = ensure_signed(origin)?;
@ -69,10 +69,10 @@ decl_event!(
mod tests {
use super::*;
use primitives::H256;
use support::{impl_outer_origin, assert_ok, parameter_types};
use sr_primitives::{
traits::{BlakeTwo256, IdentityLookup}, testing::Header, weights::Weight, Perbill,
use sp_core::H256;
use frame_support::{impl_outer_origin, assert_ok, parameter_types, weights::Weight};
use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup}, testing::Header, Perbill,
};
impl_outer_origin! {
@ -114,7 +114,7 @@ mod tests {
// This function basically just builds a genesis storage key/value store according to
// our desired mockup.
fn new_test_ext() -> runtime_io::TestExternalities {
fn new_test_ext() -> sp_io::TestExternalities {
system::GenesisConfig::default().build_storage::<Test>().unwrap().into()
}

View File

@ -1,17 +1,18 @@
use primitives::{Pair, Public};
use sp_core::{Pair, Public, sr25519};
use node_template_runtime::{
AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig,
SudoConfig, IndicesConfig, SystemConfig, WASM_BINARY,
SudoConfig, IndicesConfig, SystemConfig, WASM_BINARY, Signature
};
use aura_primitives::sr25519::{AuthorityId as AuraId};
use sp_consensus_aura::sr25519::{AuthorityId as AuraId};
use grandpa_primitives::{AuthorityId as GrandpaId};
use substrate_service;
use sc_service;
use sp_runtime::traits::{Verify, IdentifyAccount};
// Note this is the URL for the telemetry server
//const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
pub type ChainSpec = substrate_service::ChainSpec<GenesisConfig>;
pub type ChainSpec = sc_service::ChainSpec<GenesisConfig>;
/// The chain specification option. This is expected to come in from the CLI and
/// is little more than one of a number of alternatives which can easily be converted
@ -31,8 +32,17 @@ pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Pu
.public()
}
type AccountPublic = <Signature as Verify>::Signer;
/// Helper function to generate an account ID from seed
pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId where
AccountPublic: From<<TPublic::Pair as Pair>::Public>
{
AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
}
/// Helper function to generate an authority key for Aura
pub fn get_authority_keys_from_seed(s: &str) -> (AuraId, GrandpaId) {
pub fn get_authority_keys_from_seed(s: &str) -> (AuraId, GrandpaId) {
(
get_from_seed::<AuraId>(s),
get_from_seed::<GrandpaId>(s),
@ -49,12 +59,12 @@ impl Alternative {
|| testnet_genesis(vec![
get_authority_keys_from_seed("Alice"),
],
get_from_seed::<AccountId>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Alice"),
vec![
get_from_seed::<AccountId>("Alice"),
get_from_seed::<AccountId>("Bob"),
get_from_seed::<AccountId>("Alice//stash"),
get_from_seed::<AccountId>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
],
true),
vec![],
@ -69,21 +79,21 @@ impl Alternative {
|| testnet_genesis(vec![
get_authority_keys_from_seed("Alice"),
get_authority_keys_from_seed("Bob"),
],
get_from_seed::<AccountId>("Alice"),
],
get_account_id_from_seed::<sr25519::Public>("Alice"),
vec![
get_from_seed::<AccountId>("Alice"),
get_from_seed::<AccountId>("Bob"),
get_from_seed::<AccountId>("Charlie"),
get_from_seed::<AccountId>("Dave"),
get_from_seed::<AccountId>("Eve"),
get_from_seed::<AccountId>("Ferdie"),
get_from_seed::<AccountId>("Alice//stash"),
get_from_seed::<AccountId>("Bob//stash"),
get_from_seed::<AccountId>("Charlie//stash"),
get_from_seed::<AccountId>("Dave//stash"),
get_from_seed::<AccountId>("Eve//stash"),
get_from_seed::<AccountId>("Ferdie//stash"),
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
],
true),
vec![],
@ -105,7 +115,7 @@ impl Alternative {
}
fn testnet_genesis(initial_authorities: Vec<(AuraId, GrandpaId)>,
root_key: AccountId,
root_key: AccountId,
endowed_accounts: Vec<AccountId>,
_enable_println: bool) -> GenesisConfig {
GenesisConfig {

View File

@ -1,11 +1,11 @@
use crate::service;
use futures::{future, Future, sync::oneshot};
use futures::{future::{select, Map}, FutureExt, TryFutureExt, channel::oneshot, compat::Future01CompatExt};
use std::cell::RefCell;
use tokio::runtime::Runtime;
pub use substrate_cli::{VersionInfo, IntoExit, error};
use substrate_cli::{informant, parse_and_prepare, ParseAndPrepare, NoCustom};
use substrate_service::{AbstractService, Roles as ServiceRoles, Configuration};
use aura_primitives::sr25519::{AuthorityPair as AuraPair};
pub use sc_cli::{VersionInfo, IntoExit, error};
use sc_cli::{display_role, informant, parse_and_prepare, ParseAndPrepare, NoCustom};
use sc_service::{AbstractService, Roles as ServiceRoles, Configuration};
use sp_consensus_aura::sr25519::{AuthorityPair as AuraPair};
use crate::chain_spec;
use log::info;
@ -24,26 +24,28 @@ pub fn run<I, T, E>(args: I, exit: E, version: VersionInfo) -> error::Result<()>
info!(" by {}, 2017, 2018", version.author);
info!("Chain specification: {}", config.chain_spec.name());
info!("Node name: {}", config.name);
info!("Roles: {:?}", config.roles);
info!("Roles: {}", display_role(&config));
let runtime = Runtime::new().map_err(|e| format!("{:?}", e))?;
match config.roles {
ServiceRoles::LIGHT => run_until_exit(
runtime,
service::new_light(config).map_err(|e| format!("{:?}", e))?,
service::new_light(config)?,
exit
),
_ => run_until_exit(
runtime,
service::new_full(config).map_err(|e| format!("{:?}", e))?,
service::new_full(config)?,
exit
),
}.map_err(|e| format!("{:?}", e))
}
}),
ParseAndPrepare::BuildSpec(cmd) => cmd.run(load_spec),
ParseAndPrepare::BuildSpec(cmd) => cmd.run::<NoCustom, _, _, _>(load_spec),
ParseAndPrepare::ExportBlocks(cmd) => cmd.run_with_builder(|config: Config<_>|
Ok(new_full_start!(config).0), load_spec, exit),
ParseAndPrepare::ImportBlocks(cmd) => cmd.run_with_builder(|config: Config<_>|
Ok(new_full_start!(config).0), load_spec, exit),
ParseAndPrepare::CheckBlock(cmd) => cmd.run_with_builder(|config: Config<_>|
Ok(new_full_start!(config).0), load_spec, exit),
ParseAndPrepare::PurgeChain(cmd) => cmd.run(load_spec),
ParseAndPrepare::RevertChain(cmd) => cmd.run_with_builder(|config: Config<_>|
Ok(new_full_start!(config).0), load_spec),
@ -69,25 +71,37 @@ where
T: AbstractService,
E: IntoExit,
{
let (exit_send, exit) = exit_future::signal();
let (exit_send, exit) = oneshot::channel();
let informant = informant::build(&service);
runtime.executor().spawn(exit.until(informant).map(|_| ()));
let future = select(exit, informant)
.map(|_| Ok(()))
.compat();
runtime.executor().spawn(future);
// we eagerly drop the service so that the internal exit future is fired,
// but we need to keep holding a reference to the global telemetry guard
let _telemetry = service.telemetry();
let service_res = {
let exit = e.into_exit().map_err(|_| error::Error::Other("Exit future failed.".into()));
let service = service.map_err(|err| error::Error::Service(err));
let select = service.select(exit).map(|_| ()).map_err(|(err, _)| err);
let exit = e.into_exit();
let service = service
.map_err(|err| error::Error::Service(err))
.compat();
let select = select(service, exit)
.map(|_| Ok(()))
.compat();
runtime.block_on(select)
};
exit_send.fire();
let _ = exit_send.send(());
// TODO [andre]: timeout this future #1318
use futures01::Future;
let _ = runtime.shutdown_on_idle().wait();
service_res
@ -96,7 +110,7 @@ where
// handles ctrl-c
pub struct Exit;
impl IntoExit for Exit {
type Exit = future::MapErr<oneshot::Receiver<()>, fn(oneshot::Canceled) -> ()>;
type Exit = Map<oneshot::Receiver<()>, fn(Result<(), oneshot::Canceled>) -> ()>;
fn into_exit(self) -> Self::Exit {
// can't use signal directly here because CtrlC takes only `Fn`.
let (exit_send, exit) = oneshot::channel();
@ -109,6 +123,6 @@ impl IntoExit for Exit {
}
}).expect("Error setting Ctrl-C handler");
exit.map_err(drop)
exit.map(drop)
}
}

View File

@ -8,9 +8,9 @@ mod chain_spec;
mod service;
mod cli;
pub use substrate_cli::{VersionInfo, IntoExit, error};
pub use sc_cli::{VersionInfo, IntoExit, error};
fn main() {
fn main() -> Result<(), cli::error::Error> {
let version = VersionInfo {
name: "Substrate Node",
commit: env!("VERGEN_SHA_SHORT"),
@ -21,8 +21,5 @@ fn main() {
support_url: "support.anonymous.an",
};
if let Err(e) = cli::run(::std::env::args(), cli::Exit, version) {
eprintln!("Fatal error: {}\n\n{:?}", e, e);
std::process::exit(1)
}
cli::run(std::env::args(), cli::Exit, version)
}

View File

@ -2,17 +2,16 @@
use std::sync::Arc;
use std::time::Duration;
use substrate_client::LongestChain;
use futures::prelude::*;
use sc_client::LongestChain;
use node_template_runtime::{self, GenesisConfig, opaque::Block, RuntimeApi};
use substrate_service::{error::{Error as ServiceError}, AbstractService, Configuration, ServiceBuilder};
use transaction_pool::{self, txpool::{Pool as TransactionPool}};
use inherents::InherentDataProviders;
use network::{construct_simple_protocol};
use substrate_executor::native_executor_instance;
pub use substrate_executor::NativeExecutor;
use aura_primitives::sr25519::{AuthorityPair as AuraPair};
use sc_service::{error::{Error as ServiceError}, AbstractService, Configuration, ServiceBuilder};
use sp_inherents::InherentDataProviders;
use sc_network::{construct_simple_protocol};
use sc_executor::native_executor_instance;
pub use sc_executor::NativeExecutor;
use sp_consensus_aura::sr25519::{AuthorityPair as AuraPair};
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
use sc_basic_authority;
// Our native executor instance.
native_executor_instance!(
@ -33,28 +32,32 @@ construct_simple_protocol! {
macro_rules! new_full_start {
($config:expr) => {{
let mut import_setup = None;
let inherent_data_providers = inherents::InherentDataProviders::new();
let inherent_data_providers = sp_inherents::InherentDataProviders::new();
let builder = substrate_service::ServiceBuilder::new_full::<
let builder = sc_service::ServiceBuilder::new_full::<
node_template_runtime::opaque::Block, node_template_runtime::RuntimeApi, crate::service::Executor
>($config)?
.with_select_chain(|_config, backend| {
Ok(substrate_client::LongestChain::new(backend.clone()))
Ok(sc_client::LongestChain::new(backend.clone()))
})?
.with_transaction_pool(|config, client, _fetcher| {
let pool_api = sc_transaction_pool::FullChainApi::new(client.clone());
let pool = sc_transaction_pool::BasicPool::new(config, pool_api);
let maintainer = sc_transaction_pool::FullBasicPoolMaintainer::new(pool.pool().clone(), client);
let maintainable_pool = sp_transaction_pool::MaintainableTransactionPool::new(pool, maintainer);
Ok(maintainable_pool)
})?
.with_transaction_pool(|config, client|
Ok(transaction_pool::txpool::Pool::new(config, transaction_pool::FullChainApi::new(client)))
)?
.with_import_queue(|_config, client, mut select_chain, transaction_pool| {
let select_chain = select_chain.take()
.ok_or_else(|| substrate_service::Error::SelectChainRequired)?;
.ok_or_else(|| sc_service::Error::SelectChainRequired)?;
let (grandpa_block_import, grandpa_link) =
grandpa::block_import::<_, _, _, node_template_runtime::RuntimeApi, _, _>(
grandpa::block_import::<_, _, _, node_template_runtime::RuntimeApi, _>(
client.clone(), &*client, select_chain
)?;
let import_queue = aura::import_queue::<_, _, AuraPair, _>(
aura::SlotDuration::get_or_compute(&*client)?,
let import_queue = sc_consensus_aura::import_queue::<_, _, AuraPair, _>(
sc_consensus_aura::SlotDuration::get_or_compute(&*client)?,
Box::new(grandpa_block_import.clone()),
Some(Box::new(grandpa_block_import.clone())),
None,
@ -81,6 +84,11 @@ pub fn new_full<C: Send + Default + 'static>(config: Configuration<C, GenesisCon
let name = config.name.clone();
let disable_grandpa = config.disable_grandpa;
// sentry nodes announce themselves as authorities to the network
// and should run the same protocols authorities do, but it should
// never actively participate in any consensus process.
let participates_in_consensus = is_authority && !config.sentry_mode;
let (builder, mut import_setup, inherent_data_providers) = new_full_start!(config);
let (block_import, grandpa_link) =
@ -93,8 +101,8 @@ pub fn new_full<C: Send + Default + 'static>(config: Configuration<C, GenesisCon
)?
.build()?;
if is_authority {
let proposer = basic_authorship::ProposerFactory {
if participates_in_consensus {
let proposer = sc_basic_authority::ProposerFactory {
client: service.client(),
transaction_pool: service.transaction_pool(),
};
@ -103,8 +111,11 @@ pub fn new_full<C: Send + Default + 'static>(config: Configuration<C, GenesisCon
let select_chain = service.select_chain()
.ok_or(ServiceError::SelectChainRequired)?;
let aura = aura::start_aura::<_, _, _, _, _, AuraPair, _, _, _>(
aura::SlotDuration::get_or_compute(&*client)?,
let can_author_with =
sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone());
let aura = sc_consensus_aura::start_aura::<_, _, _, _, _, AuraPair, _, _, _, _>(
sc_consensus_aura::SlotDuration::get_or_compute(&*client)?,
client,
select_chain,
block_import,
@ -113,32 +124,42 @@ pub fn new_full<C: Send + Default + 'static>(config: Configuration<C, GenesisCon
inherent_data_providers.clone(),
force_authoring,
service.keystore(),
can_author_with,
)?;
let select = aura.select(service.on_exit()).then(|_| Ok(()));
// the AURA authoring task is considered essential, i.e. if it
// fails we take down the service with it.
service.spawn_essential_task(select);
service.spawn_essential_task(aura);
}
// if the node isn't actively participating in consensus then it doesn't
// need a keystore, regardless of which protocol we use below.
let keystore = if participates_in_consensus {
Some(service.keystore())
} else {
None
};
let grandpa_config = grandpa::Config {
// FIXME #1578 make this available through chainspec
gossip_duration: Duration::from_millis(333),
justification_period: 512,
name: Some(name),
keystore: Some(service.keystore()),
observer_enabled: true,
keystore,
is_authority,
};
match (is_authority, disable_grandpa) {
(false, false) => {
// start the lightweight GRANDPA observer
service.spawn_task(Box::new(grandpa::run_grandpa_observer(
service.spawn_task(grandpa::run_grandpa_observer(
grandpa_config,
grandpa_link,
service.network(),
service.on_exit(),
)?));
service.spawn_task_handle(),
)?);
},
(true, false) => {
// start the full GRANDPA voter
@ -150,6 +171,7 @@ pub fn new_full<C: Send + Default + 'static>(config: Configuration<C, GenesisCon
on_exit: service.on_exit(),
telemetry_on_connect: Some(service.telemetry_on_connect_stream()),
voting_rule: grandpa::VotingRulesBuilder::default().build(),
executor: service.spawn_task_handle(),
};
// the GRANDPA voter task is considered infallible, i.e.
@ -178,22 +200,28 @@ pub fn new_light<C: Send + Default + 'static>(config: Configuration<C, GenesisCo
.with_select_chain(|_config, backend| {
Ok(LongestChain::new(backend.clone()))
})?
.with_transaction_pool(|config, client|
Ok(TransactionPool::new(config, transaction_pool::FullChainApi::new(client)))
)?
.with_transaction_pool(|config, client, fetcher| {
let fetcher = fetcher
.ok_or_else(|| "Trying to start light transaction pool without active fetcher")?;
let pool_api = sc_transaction_pool::LightChainApi::new(client.clone(), fetcher.clone());
let pool = sc_transaction_pool::BasicPool::new(config, pool_api);
let maintainer = sc_transaction_pool::LightBasicPoolMaintainer::with_defaults(pool.pool().clone(), client, fetcher);
let maintainable_pool = sp_transaction_pool::MaintainableTransactionPool::new(pool, maintainer);
Ok(maintainable_pool)
})?
.with_import_queue_and_fprb(|_config, client, backend, fetcher, _select_chain, _tx_pool| {
let fetch_checker = fetcher
.map(|fetcher| fetcher.checker().clone())
.ok_or_else(|| "Trying to start light import queue without active fetch checker")?;
let grandpa_block_import = grandpa::light_block_import::<_, _, _, RuntimeApi, _>(
client.clone(), backend, Arc::new(fetch_checker), client.clone()
let grandpa_block_import = grandpa::light_block_import::<_, _, _, RuntimeApi>(
client.clone(), backend, &*client.clone(), Arc::new(fetch_checker),
)?;
let finality_proof_import = grandpa_block_import.clone();
let finality_proof_request_builder =
finality_proof_import.create_finality_proof_request_builder();
let import_queue = aura::import_queue::<_, _, AuraPair, ()>(
aura::SlotDuration::get_or_compute(&*client)?,
let import_queue = sc_consensus_aura::import_queue::<_, _, AuraPair, ()>(
sc_consensus_aura::SlotDuration::get_or_compute(&*client)?,
Box::new(grandpa_block_import),
None,
Some(Box::new(finality_proof_import)),